Skip to content

Commit cf8b93d

Browse files
rniwaRyosuke Niwa
and
Ryosuke Niwa
authored
[alpha.webkit.UncountedCallArgsChecker] Allow explicit instantiation of Ref/RefPtr on call arguments. (#91875)
Co-authored-by: Ryosuke Niwa <[email protected]>
1 parent f608ac2 commit cf8b93d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ bool tryToFindPtrOrigin(
2828
E = tempExpr->getSubExpr();
2929
continue;
3030
}
31+
if (auto *tempExpr = dyn_cast<CXXTemporaryObjectExpr>(E)) {
32+
if (auto *C = tempExpr->getConstructor()) {
33+
if (auto *Class = C->getParent(); Class && isRefCounted(Class))
34+
return callback(E, true);
35+
break;
36+
}
37+
}
3138
if (auto *tempExpr = dyn_cast<ParenExpr>(E)) {
3239
E = tempExpr->getSubExpr();
3340
continue;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,10 @@ namespace call_with_ptr_on_ref {
358358
// expected-warning@-1{{Call argument for parameter 'bad' is uncounted and unsafe}}
359359
}
360360
}
361+
362+
namespace call_with_explicit_temporary_obj {
363+
void foo() {
364+
Ref { *provide() }->method();
365+
RefPtr { provide() }->method();
366+
}
367+
}

0 commit comments

Comments
 (0)