[alpha.webkit.UncheckedCallArgsChecker] Forwarding r-value reference should not result in a warning (#142471)

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.
This commit is contained in:
Ryosuke Niwa
2025-06-06 07:49:38 -06:00
committed by GitHub
parent 6a4b89055b
commit 7809b147fa
2 changed files with 28 additions and 0 deletions

View File

@@ -119,6 +119,11 @@ bool tryToFindPtrOrigin(
}
}
if (call->isCallToStdMove() && call->getNumArgs() == 1) {
E = call->getArg(0)->IgnoreParenCasts();
continue;
}
if (auto *callee = call->getDirectCallee()) {
if (isCtorOfSafePtr(callee)) {
if (StopAtFirstRefCountedObj)

View File

@@ -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));
}
}