Skip to content

Commit 2988246

Browse files
committed
Add more test cases for passing a lambda to a static member function and a non-member function.
1 parent b4c9048 commit 2988246

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class HashMap {
7070
HashMap([[clang::noescape]] const Function<ValueType()>&);
7171
void ensure(const KeyType&, [[clang::noescape]] const Function<ValueType()>&);
7272
bool operator+([[clang::noescape]] const Function<ValueType()>&) const;
73+
static void ifAny(HashMap, [[clang::noescape]] const Function<bool(ValueType)>&);
7374

7475
private:
7576
ValueType* m_table { nullptr };
@@ -281,6 +282,7 @@ struct RefCountableWithLambdaCapturingThis {
281282
});
282283
}
283284

285+
static void callLambda([[clang::noescape]] const WTF::Function<RefPtr<RefCountable>()>&);
284286
void method_captures_this_in_template_method() {
285287
RefCountable* obj = make_obj();
286288
WTF::HashMap<int, RefPtr<RefCountable>> nextMap;
@@ -290,6 +292,12 @@ struct RefCountableWithLambdaCapturingThis {
290292
nextMap+[&] {
291293
return obj->next();
292294
};
295+
WTF::HashMap<int, RefPtr<RefCountable>>::ifAny(nextMap, [&](auto& item) -> bool {
296+
return item->next() && obj->next();
297+
});
298+
callLambda([&]() -> RefPtr<RefCountable> {
299+
return obj->next();
300+
});
293301
}
294302
};
295303

0 commit comments

Comments
 (0)