[clang] [webkit.RefCntblBaseVirtualDtor] Make ThreadSafeRefCounted not generate warnings (PR #107676)
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 10 13:34:52 PDT 2024
================
@@ -67,6 +68,15 @@ class DerefFuncDeleteExprVisitor
const Decl *D = CE->getCalleeDecl();
if (D && D->hasBody())
return VisitBody(D->getBody());
+ else if (!VisitLambdaBody) {
+ for (unsigned i = 0; i < CE->getNumArgs(); ++i) {
+ auto *Arg = CE->getArg(i);
+ VisitLambdaBody = true;
+ auto Restore = llvm::make_scope_exit([&] { VisitLambdaBody = false; });
+ if (VisitChildren(Arg))
----------------
haoNoQ wrote:
You can probably avoid statefulness here if you directly pattern-match the argument as a lambda (with the help of a few manual `dyn_cast`s) and then invoke `Visit()` directly on that lambda's body. It'd also make `VisitLambdaExpr()` unnecessary.
It's usually not a good idea to search for a nested object at arbitrary nesting depths. When you do that, you lose your ability to confirm the exact relationship between the current object and the nested object (in our case, "the lambda is passed to the opaque call as an argument" as opposed to "the lambda is lexically nested into an argument in any shape or form"). The only time you actually want to ignore that relationship is in the very top-level visitor that simply looks for all matching code patterns in the entire translation unit no matter where they're written in the translation unit. It typically doesn't make a lot of sense in the middle of the pattern.
https://github.com/llvm/llvm-project/pull/107676
More information about the cfe-commits
mailing list