[clang] [webkit.RefCntblBaseVirtualDtor] Make ThreadSafeRefCounted not generate warnings (PR #107676)

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 10 20:01:06 PDT 2024


================
@@ -67,6 +68,48 @@ class DerefFuncDeleteExprVisitor
     const Decl *D = CE->getCalleeDecl();
     if (D && D->hasBody())
       return VisitBody(D->getBody());
+    else {
+      auto name = safeGetName(D);
+      if (name == "ensureOnMainThread" || name == "ensureOnMainRunLoop") {
+        for (unsigned i = 0; i < CE->getNumArgs(); ++i) {
+          auto *Arg = CE->getArg(i);
+          if (FindLabmda(Arg))
+            return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  bool FindLabmda(const Expr *E) {
+    while (E) {
+      if (auto *TempE = dyn_cast<MaterializeTemporaryExpr>(E)) {
----------------
haoNoQ wrote:

Aha great!

`Expr->IgnoreParenCasts()` skips all of these automatically, recursively too, except `CXXBindTemporaryExpr`. But IIRC `CXXBindTemporaryExpr` doesn't need to be skipped recursively anyway, it's a one-time thing that always appears immediately before the constructor.

https://github.com/llvm/llvm-project/pull/107676


More information about the cfe-commits mailing list