-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix a bug that CXXConstructExpr wasn't recognized by tryToFindPtrOrigin #119336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Prior to this PR, only CXXTemporaryObjectExpr, not CXXConstructExpr was recognized in tryToFindPtrOrigin.
@llvm/pr-subscribers-clang Author: Ryosuke Niwa (rniwa) ChangesPrior to this PR, only CXXTemporaryObjectExpr, not CXXConstructExpr was recognized in tryToFindPtrOrigin. Full diff: https://github.com/llvm/llvm-project/pull/119336.diff 2 Files Affected:
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index b3cd594a0f3529..69b63240d2075e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -33,7 +33,7 @@ bool tryToFindPtrOrigin(
E = tempExpr->getSubExpr();
continue;
}
- if (auto *tempExpr = dyn_cast<CXXTemporaryObjectExpr>(E)) {
+ if (auto *tempExpr = dyn_cast<CXXConstructExpr>(E)) {
if (auto *C = tempExpr->getConstructor()) {
if (auto *Class = C->getParent(); Class && isSafePtr(Class))
return callback(E, true);
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args.cpp b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
index 94efddeaf66cd8..d4420c59b41ca8 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
@@ -364,4 +364,15 @@ namespace call_with_explicit_temporary_obj {
Ref { *provide() }->method();
RefPtr { provide() }->method();
}
+ template <typename T>
+ void bar() {
+ Ref { *provide() }->method();
+ RefPtr { provide() }->method();
+ }
+ void baz() {
+ bar<int>();
+ }
+}
+
+namespace call_with_explicit_construct {
}
|
@llvm/pr-subscribers-clang-static-analyzer-1 Author: Ryosuke Niwa (rniwa) ChangesPrior to this PR, only CXXTemporaryObjectExpr, not CXXConstructExpr was recognized in tryToFindPtrOrigin. Full diff: https://github.com/llvm/llvm-project/pull/119336.diff 2 Files Affected:
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index b3cd594a0f3529..69b63240d2075e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -33,7 +33,7 @@ bool tryToFindPtrOrigin(
E = tempExpr->getSubExpr();
continue;
}
- if (auto *tempExpr = dyn_cast<CXXTemporaryObjectExpr>(E)) {
+ if (auto *tempExpr = dyn_cast<CXXConstructExpr>(E)) {
if (auto *C = tempExpr->getConstructor()) {
if (auto *Class = C->getParent(); Class && isSafePtr(Class))
return callback(E, true);
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args.cpp b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
index 94efddeaf66cd8..d4420c59b41ca8 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
@@ -364,4 +364,15 @@ namespace call_with_explicit_temporary_obj {
Ref { *provide() }->method();
RefPtr { provide() }->method();
}
+ template <typename T>
+ void bar() {
+ Ref { *provide() }->method();
+ RefPtr { provide() }->method();
+ }
+ void baz() {
+ bar<int>();
+ }
+}
+
+namespace call_with_explicit_construct {
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing the tests, LGTM!
Thanks for the review! |
…in (llvm#119336) Prior to this PR, only CXXTemporaryObjectExpr, not CXXConstructExpr was recognized in tryToFindPtrOrigin.
…in (llvm#119336) Prior to this PR, only CXXTemporaryObjectExpr, not CXXConstructExpr was recognized in tryToFindPtrOrigin.
https://bugs.webkit.org/show_bug.cgi?id=292007 Reviewed by NOBODY (OOPS!). llvm/llvm-project#119336 was merged four months ago. Presumably this is all good now. * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h: (WebKit::RemoteGraphicsContextGL::send const): * Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.h:
https://bugs.webkit.org/show_bug.cgi?id=292007 Reviewed by Ryosuke Niwa and Mike Wyrzykowski. llvm/llvm-project#119336 was merged four months ago. Presumably this is all good now. * Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h: (WebKit::RemoteGraphicsContextGL::send const): * Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.h: Canonical link: https://commits.webkit.org/294073@main
Prior to this PR, only CXXTemporaryObjectExpr, not CXXConstructExpr was recognized in tryToFindPtrOrigin.