[clang] [LifetimeSafety] Overhaul CFG and analysis to also work with trivially destructed temporary objects (PR #177985)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 10 10:55:19 PST 2026


================
@@ -114,9 +107,9 @@ void FactsGenerator::run() {
       else if (std::optional<CFGLifetimeEnds> LifetimeEnds =
                    Element.getAs<CFGLifetimeEnds>())
         handleLifetimeEnds(*LifetimeEnds);
-      else if (std::optional<CFGTemporaryDtor> TemporaryDtor =
-                   Element.getAs<CFGTemporaryDtor>())
-        handleTemporaryDtor(*TemporaryDtor);
+      else if (std::optional<CFGFullExprCleanup> FullExprCleanup =
+                   Element.getAs<CFGFullExprCleanup>())
+        handleFullExprCleanup(*FullExprCleanup);
     }
     if (Block == &Cfg.getExit())
       handleExitBlock();
----------------
usx95 wrote:

Now that we do not need destructors, can you try to remove `TemporaryDtor` and `ImplicitDtor` in `LifetimeSafetyTUAnalysis` in `AnalysisBasedWarnings.cpp`.

This is already tested in warn-lifetime-safety.cpp so it would fail if something goes wrong.

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


More information about the cfe-commits mailing list