Skip to content

Commit 3b5d22f

Browse files
committed
Added more test cases
1 parent 97a721c commit 3b5d22f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,15 @@ struct RefCountableWithLambdaCapturingThis {
217217
});
218218
}
219219

220+
void method_captures_this_with_other_protected_var() {
221+
RefCountable* x = make_obj();
222+
call([this, protectedX = RefPtr { x }]() {
223+
// expected-warning@-1{{Captured raw-pointer 'this' to ref-counted type or CheckedPtr-capable type is unsafe [webkit.UncountedLambdaCapturesChecker]}}
224+
nonTrivial();
225+
protectedX->method();
226+
});
227+
}
228+
220229
void method_captures_this_unsafe_capture_local_var_explicitly_with_deref() {
221230
RefCountable* x = make_obj();
222231
call([this, protectedThis = Ref { *this }, x]() {
@@ -243,6 +252,13 @@ struct RefCountableWithLambdaCapturingThis {
243252
call(lambda);
244253
}
245254

255+
void method_captures_this_with_guardian_refPtr() {
256+
auto lambda = [this, protectedThis = RefPtr { &*this }]() {
257+
nonTrivial();
258+
};
259+
call(lambda);
260+
}
261+
246262
};
247263

248264
struct NonRefCountableWithLambdaCapturingThis {

0 commit comments

Comments
 (0)