Skip to content

Commit ca7ae4e

Browse files
committed
[webkit.UncountedLambdaCapturesChecker] Ignore lambda invocation with arguments (llvm#117394)
Fixed a bug that UncountedLambdaCapturesChecker would emit a warning on a lambda capture when the lambda is invoked with arguments. LocalVisitor::VisitCallExpr was not tolerating a lambda invocation with more than 1 arguments.
1 parent 1e61f30 commit ca7ae4e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class UncountedLambdaCapturesChecker
117117
if (!DRE)
118118
return;
119119
auto *MD = dyn_cast_or_null<CXXMethodDecl>(DRE->getDecl());
120-
if (!MD || CE->getNumArgs() != 1)
120+
if (!MD || CE->getNumArgs() < 1)
121121
return;
122122
auto *Arg = CE->getArg(0)->IgnoreParenCasts();
123123
auto *ArgRef = dyn_cast<DeclRefExpr>(Arg);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void noescape_lambda() {
125125
}
126126

127127
void lambda_capture_param(RefCountable* obj) {
128-
auto someLambda = [&] {
128+
auto someLambda = [&]() {
129129
obj->method();
130130
};
131131
someLambda();
@@ -178,3 +178,10 @@ void trivial_lambda() {
178178
};
179179
trivial_lambda();
180180
}
181+
182+
void lambda_with_args(RefCountable* obj) {
183+
auto trivial_lambda = [&](int v) {
184+
obj->method();
185+
};
186+
trivial_lambda(1);
187+
}

0 commit comments

Comments
 (0)