https://github.com/rniwa updated 
https://github.com/llvm/llvm-project/pull/142471

>From e915af753e5d51afea1b313adea4d89ecd5e678d Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa <rn...@webkit.org>
Date: Mon, 2 Jun 2025 13:58:50 -0600
Subject: [PATCH 1/2] [alpha.webkit.UncheckedCallArgsChecker] Forwarding
 r-value reference should not result in a warning

This PR fixes the bug that the checker emits a warning when a function takes 
T&& and passes it to
another function using std::move. We should treat std::move like any other 
pointer conversion and
the origin of the pointer to be that of the argument.
---
 .../Checkers/WebKit/ASTUtils.cpp              |  5 ++++
 .../Checkers/WebKit/call-args-checked.cpp     | 23 +++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index f087fc8fa19fd..7dedb8f8f6766 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -118,6 +118,11 @@ bool tryToFindPtrOrigin(
           }
         }
       }
+      
+      if (call->isCallToStdMove() && call->getNumArgs() == 1) {
+        E = call->getArg(0)->IgnoreParenCasts();
+        continue;
+      }
 
       if (auto *callee = call->getDirectCallee()) {
         if (isCtorOfSafePtr(callee)) {
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args-checked.cpp 
b/clang/test/Analysis/Checkers/WebKit/call-args-checked.cpp
index e24b04dcd3cf9..c938ba5f7de46 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args-checked.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args-checked.cpp
@@ -2,6 +2,20 @@
 
 #include "mock-types.h"
 
+namespace std {
+
+template <typename T> struct remove_reference {
+  typedef T type;
+};
+
+template <typename T> struct remove_reference<T&> {
+  typedef T type;
+};
+
+template<typename T> typename remove_reference<T>::type&& move(T&& t);
+
+} // namespace std
+
 RefCountableAndCheckable* makeObj();
 CheckedRef<RefCountableAndCheckable> makeObjChecked();
 void someFunction(RefCountableAndCheckable*);
@@ -54,3 +68,12 @@ void foo() {
 }
 
 }
+
+namespace call_with_std_move {
+
+void consume(CheckedObj&&);
+void foo(CheckedObj&& obj) {
+  consume(std::move(obj));
+}
+
+}

>From 73c949dc119ac458663f6c31d4a859c6528f7986 Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa <rn...@webkit.org>
Date: Tue, 3 Jun 2025 10:53:14 -0600
Subject: [PATCH 2/2] Fix formatting

---
 clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index 7dedb8f8f6766..81fca5d719b4d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -118,7 +118,7 @@ bool tryToFindPtrOrigin(
           }
         }
       }
-      
+
       if (call->isCallToStdMove() && call->getNumArgs() == 1) {
         E = call->getArg(0)->IgnoreParenCasts();
         continue;

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to