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

via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 23 06:16:42 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);
----------------
NeKon69 wrote:

Exactly what I thought. Still I didn't want to add those checks somewhere they aren't supposed to be, so I added them in the safest place. My guess is that handling this in `VisitCXXOperatorCallExpr` as you suggested would be the right play then?

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


More information about the cfe-commits mailing list