[clang] [LifetimeSafety] Add bailout for large CFGs (PR #170444)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 2 01:16:10 PST 2026


================
@@ -49,13 +49,25 @@ static void DebugOnlyFunction(AnalysisDeclContext &AC, const CFG &Cfg,
 #endif
 
 LifetimeSafetyAnalysis::LifetimeSafetyAnalysis(AnalysisDeclContext &AC,
-                                               LifetimeSafetyReporter *Reporter)
-    : AC(AC), Reporter(Reporter) {}
+                                               LifetimeSafetyReporter *Reporter,
+                                               const LifetimeSafetyOpts &LSOpts)
+    : LSOpts(LSOpts), AC(AC), Reporter(Reporter) {}
 
 void LifetimeSafetyAnalysis::run() {
   llvm::TimeTraceScope TimeProfile("LifetimeSafetyAnalysis");
 
   const CFG &Cfg = *AC.getCFG();
+  if (LSOpts.MaxCFGBlocks > 0 && Cfg.getNumBlockIDs() > LSOpts.MaxCFGBlocks) {
+    DEBUG_WITH_TYPE(
+        "LifetimeSafety", std::string FuncName = "<unknown>";
+        if (const Decl *D = AC.getDecl()) if (const auto *ND =
----------------
Xazax-hun wrote:

Is this clang formatted? I find this formatting very confusing. Maybe clang format got confused by the macro?

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


More information about the cfe-commits mailing list