Skip to content

Commit 5485bb0

Browse files
committed
[alpha.webkit.UncheckedCallArgsChecker] Don't emit a warning for passing a temporary object as an argument. (llvm#155033)
Since a temporary object lives until the end of the statement, it's safe to pass such an object as a function argument without explicitly creating a CheckedRef/CheckedPtr in stack.
1 parent 4a2e929 commit 5485bb0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ bool isASafeCallArg(const Expr *E) {
209209
return true;
210210
}
211211
}
212+
if (isa<CXXTemporaryObjectExpr>(E))
213+
return true; // A temporary lives until the end of this statement.
212214
if (isConstOwnerPtrMemberExpr(E))
213215
return true;
214216

clang/test/Analysis/Checkers/WebKit/unchecked-call-arg.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ void foo() {
3232
provide()->doWork();
3333
// expected-warning@-1{{Call argument for 'this' parameter is unchecked and unsafe}}
3434
}
35+
36+
void doWorkWithObject(const CheckedObject&);
37+
void bar() {
38+
doWorkWithObject(CheckedObject());
39+
}

0 commit comments

Comments
 (0)