Skip to content

Commit 0dc0498

Browse files
committedFeb 7, 2025
Fix a bug that CXXConstructExpr wasn't recognized by tryToFindPtrOrigin (llvm#119336)
Prior to this PR, only CXXTemporaryObjectExpr, not CXXConstructExpr was recognized in tryToFindPtrOrigin.
1 parent a06f0bd commit 0dc0498

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bool tryToFindPtrOrigin(
3333
E = tempExpr->getSubExpr();
3434
continue;
3535
}
36-
if (auto *tempExpr = dyn_cast<CXXTemporaryObjectExpr>(E)) {
36+
if (auto *tempExpr = dyn_cast<CXXConstructExpr>(E)) {
3737
if (auto *C = tempExpr->getConstructor()) {
3838
if (auto *Class = C->getParent(); Class && isSafePtr(Class))
3939
return callback(E, true);

‎clang/test/Analysis/Checkers/WebKit/call-args.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,15 @@ namespace call_with_explicit_temporary_obj {
364364
Ref { *provide() }->method();
365365
RefPtr { provide() }->method();
366366
}
367+
template <typename T>
368+
void bar() {
369+
Ref(*provide())->method();
370+
RefPtr(provide())->method();
371+
}
372+
void baz() {
373+
bar<int>();
374+
}
375+
}
376+
377+
namespace call_with_explicit_construct {
367378
}

0 commit comments

Comments
 (0)
Please sign in to comment.