[clang] [webkit.UncountedLambdaCapturesChecker] Recognize nested protectedThis pattern (PR #126443)
Rashmi Mudduluru via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 14 13:52:25 PST 2025
================
@@ -299,6 +300,29 @@ struct RefCountableWithLambdaCapturingThis {
return obj->next();
});
}
+
+ void callAsyncNoescape([[clang::noescape]] WTF::Function<bool(RefCountable&)>&&);
+ void method_temp_lambda(RefCountable* obj) {
+ callAsyncNoescape([this, otherObj = RefPtr { obj }](auto& obj) {
+ return otherObj == &obj;
+ });
+ }
+
+ void method_nested_lambda() {
+ callAsync([this, protectedThis = Ref { *this }] {
+ callAsync([this, protectedThis = static_cast<const Ref<RefCountableWithLambdaCapturingThis>&&>(protectedThis)] {
+ nonTrivial();
+ });
+ });
+ }
+
+ void method_nested_lambda2() {
+ callAsync([this, protectedThis = RefPtr { this }] {
+ callAsync([this, protectedThis = static_cast<const Ref<RefCountableWithLambdaCapturingThis>&&>(*protectedThis)] {
+ nonTrivial();
+ });
+ });
+ }
----------------
t-rasmud wrote:
Do we need a test for a lambda capture with a `this` and an unprotected `this`?
https://github.com/llvm/llvm-project/pull/126443
More information about the cfe-commits
mailing list