[clang] [LifetimeSafety] Fix compiler crash with `static operator()` (PR #187853)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 23 06:45:30 PDT 2026


================
@@ -655,6 +656,13 @@ void FactsGenerator::handleFunctionCall(const Expr *Call,
   // All arguments to a function are a use of the corresponding expressions.
   for (const Expr *Arg : Args)
     handleUse(Arg);
+
+  if (const auto *OCE = dyn_cast<CXXOperatorCallExpr>(Call);
+      OCE && OCE->getOperator() == OO_Call && FD->isStatic()) {
+    // Ignore first element
+    Args = Args.slice(1);
+  }
+
   handleInvalidatingCall(Call, FD, Args);
   handleMovedArgsInCall(FD, Args);
----------------
hokein wrote:

hmm, it looks like there are multiple places (searching for `isInstance` in this file) that rely on the incorrect assumption that the function object exists only for non-static methods.

I think either fixing all of those locations or handling it in `VisitCXXOperatorCallExpr` should work. Fixing VisitCXXOperatorCallExpr is probably simpler as it avoids changing two/three different places.

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


More information about the cfe-commits mailing list