[clang] [LifetimeSafety] Run analysis in post-order of CallGraph for better annotation propagation (PR #174178)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 5 10:07:28 PST 2026


================
@@ -2915,6 +2918,43 @@ class LifetimeSafetyReporterImpl : public LifetimeSafetyReporter {
 } // namespace
 } // namespace clang::lifetimes
 
+class CallGraphBuilder : public clang::RecursiveASTVisitor<CallGraphBuilder> {
----------------
usx95 wrote:

Maybe also try using the `CallGraph` ctor as well which uses `addToCallGraph`.
```cpp
CallGraph::CallGraph(Module &M)
    : M(M), ExternalCallingNode(getOrInsertFunction(nullptr)),
      CallsExternalNode(std::make_unique<CallGraphNode>(this, nullptr)) {
  // Add every interesting function to the call graph.
  for (Function &F : M)
    addToCallGraph(&F);
}
```
Maybe passing it `TU->getOwningModule()` would work.

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


More information about the cfe-commits mailing list