Skip to content

Commit 70e303f

Browse files
authored
[webkit.UncountedLambdaCapturesChecker] Treat a call to lambda function via a variable as safe. (llvm#135688)
This PR makes the checker ignore a function call to lambda via a local variable.
1 parent be48c0d commit 70e303f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

-2
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ class RawPtrRefLambdaCapturesChecker
263263
return;
264264
DeclRefExprsToIgnore.insert(ArgRef);
265265
LambdasToIgnore.insert(L);
266-
Checker->visitLambdaExpr(L, shouldCheckThis() && !hasProtectedThis(L),
267-
ClsType, /* ignoreParamVarDecl */ true);
268266
}
269267

270268
bool hasProtectedThis(LambdaExpr *L) {

clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,17 @@ void trivial_lambda() {
372372
trivial_lambda();
373373
}
374374

375+
bool call_lambda_var_decl() {
376+
RefCountable* ref_countable = make_obj();
377+
auto lambda1 = [&]() -> bool {
378+
return ref_countable->next();
379+
};
380+
auto lambda2 = [=]() -> bool {
381+
return ref_countable->next();
382+
};
383+
return lambda1() && lambda2();
384+
}
385+
375386
void lambda_with_args(RefCountable* obj) {
376387
auto trivial_lambda = [&](int v) {
377388
obj->method();

0 commit comments

Comments
 (0)