[clang] [analyzer][NFC] Out-line `ExplodedGraph::addEndOfPath` and `GraphTraits<ExplodedGraph *>` node iteration (PR #246988)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 07:50:05 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Balázs Benics (steakhal)
<details>
<summary>Changes</summary>
- 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
---
Full diff: https://github.com/llvm/llvm-project/pull/246988.diff
2 Files Affected:
- (modified) clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h (+3-10)
- (modified) clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (+15)
``````````diff
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
index c5929e2ffb7d1..91c1062787885 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 50b341c13a4cc..2d1f661fc02c8 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);
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/246988
More information about the cfe-commits
mailing list