[clang] [analyzer][NFC] Out-line `ExplodedGraph::addEndOfPath` and `GraphTraits<ExplodedGraph *>` node iteration (PR #246988)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 07:49:31 PST 2026
https://github.com/steakhal created https://github.com/llvm/llvm-project/pull/246988
- Move the bodies of `ExplodedGraph::addEndOfPath` and of `GraphTraits<ExplodedGraph *>::nodes_begin`/`nodes_end` from `ExplodedGraph.h` into `ExplodedGraph.cpp`.
- They were inline in a header that most checkers include, so every such TU instantiated the `std::vector` push_back and the `llvm::df_begin`/`df_end` depth-first iterator machinery, though only a few places in the engine call them.
- No include changes: `nodes_iterator` still names `df_iterator` in the header.
Build-time impact (instructions retired, 196 `lib/StaticAnalyzer` TUs):
- Total: -0.37%
Assisted-by: Claude Code
>From 55db9aff51c8c68872f3b314fdd20257c5a16c2a Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Sun, 29 Nov 2026 15:46:41 +0000
Subject: [PATCH] [analyzer][NFC] Out-line `ExplodedGraph::addEndOfPath` and
`GraphTraits<ExplodedGraph *>` node iteration
- Move the bodies of `ExplodedGraph::addEndOfPath` and of
`GraphTraits<ExplodedGraph *>::nodes_begin`/`nodes_end` from
`ExplodedGraph.h` into `ExplodedGraph.cpp`.
- They were inline in a header that most checkers include, so every such TU
instantiated the `std::vector` push_back and the `llvm::df_begin`/`df_end`
depth-first iterator machinery, though only a few places in the engine call
them.
- No include changes: `nodes_iterator` still names `df_iterator` in the header.
Build-time impact (instructions retired, 196 `lib/StaticAnalyzer` TUs):
- Total: -0.37%
Assisted-by: Claude Code
---
.../Core/PathSensitive/ExplodedGraph.h | 13 +++----------
clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp | 15 +++++++++++++++
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
index c5929e2ffb7d11..91c1062787885c 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
@@ -364,10 +364,7 @@ class ExplodedGraph {
}
/// addEndOfPath - Add an untyped node to the set of EOP nodes.
- ExplodedNode *addEndOfPath(ExplodedNode *V) {
- EndNodes.push_back(V);
- return V;
- }
+ ExplodedNode *addEndOfPath(ExplodedNode *V);
unsigned num_eops() const { return EndNodes.size(); }
@@ -513,13 +510,9 @@ namespace llvm {
return N->succ_end();
}
- static nodes_iterator nodes_begin(const GraphTy G) {
- return df_begin(G);
- }
+ static nodes_iterator nodes_begin(const GraphTy G);
- static nodes_iterator nodes_end(const GraphTy G) {
- return df_end(G);
- }
+ static nodes_iterator nodes_end(const GraphTy G);
};
} // namespace llvm
diff --git a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
index 50b341c13a4cc8..2d1f661fc02c8c 100644
--- a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -147,6 +147,11 @@ bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {
return true;
}
+ExplodedNode *ExplodedGraph::addEndOfPath(ExplodedNode *V) {
+ EndNodes.push_back(V);
+ return V;
+}
+
void ExplodedGraph::collectNode(ExplodedNode *node) {
// Removing a node means:
// (a) changing the predecessors successor to the successor of this node
@@ -543,3 +548,13 @@ ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
return G;
}
+
+llvm::GraphTraits<ExplodedGraph *>::nodes_iterator
+llvm::GraphTraits<ExplodedGraph *>::nodes_begin(const GraphTy G) {
+ return df_begin(G);
+}
+
+llvm::GraphTraits<ExplodedGraph *>::nodes_iterator
+llvm::GraphTraits<ExplodedGraph *>::nodes_end(const GraphTy G) {
+ return df_end(G);
+}
More information about the cfe-commits
mailing list