[clang] b86accc - [alpha.webkit.UncountedCallArgsChecker] Treat (foo())->bar() like foo()->bar(). (#91052)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 6 15:59:11 PDT 2024
Author: Ryosuke Niwa
Date: 2024-05-06T15:59:08-07:00
New Revision: b86accceee0c7c5d36ecdc1629d00e6303f29955
URL: https://github.com/llvm/llvm-project/commit/b86accceee0c7c5d36ecdc1629d00e6303f29955
DIFF: https://github.com/llvm/llvm-project/commit/b86accceee0c7c5d36ecdc1629d00e6303f29955.diff
LOG: [alpha.webkit.UncountedCallArgsChecker] Treat (foo())->bar() like foo()->bar(). (#91052)
Added:
Modified:
clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
clang/test/Analysis/Checkers/WebKit/call-args.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index b36fa95bc73f3e..5c49eecacc0f27 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -27,6 +27,10 @@ tryToFindPtrOrigin(const Expr *E, bool StopAtFirstRefCountedObj) {
E = tempExpr->getSubExpr();
continue;
}
+ if (auto *tempExpr = dyn_cast<ParenExpr>(E)) {
+ E = tempExpr->getSubExpr();
+ continue;
+ }
if (auto *cast = dyn_cast<CastExpr>(E)) {
if (StopAtFirstRefCountedObj) {
if (auto *ConversionFunc =
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args.cpp b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
index 2a4b6bb1f1063a..45d900d4ba880e 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
@@ -313,6 +313,17 @@ namespace default_arg {
}
}
+namespace cxx_member_func {
+ Ref<RefCountable> provideProtected();
+ void foo() {
+ provide()->trivial();
+ provide()->method();
+ // expected-warning at -1{{Call argument for 'this' parameter is uncounted and unsafe}}
+ provideProtected()->method();
+ (provideProtected())->method();
+ };
+}
+
namespace cxx_member_operator_call {
// The hidden this-pointer argument without a corresponding parameter caused couple bugs in parameter <-> argument attribution.
struct Foo {
More information about the cfe-commits
mailing list