From 960d25b4d97c2f37a30041204c0ece0bceb454e6 Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Thu, 6 Sep 2018 23:08:07 +0000 Subject: [PATCH] [analyzer] Dump stable identifiers for exploded nodes Differential Revision: https://reviews.llvm.org/D51667 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341602 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h | 2 ++ lib/StaticAnalyzer/Core/ExplodedGraph.cpp | 7 +++++++ lib/StaticAnalyzer/Core/ExprEngine.cpp | 10 +++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h index f974ef821d..29754c163a 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -240,6 +240,8 @@ public: return const_cast(this)->succ_end(); } + int64_t getID(ExplodedGraph *G) const; + private: void replaceSuccessor(ExplodedNode *node) { Succs.replaceNode(node); } void replacePredecessor(ExplodedNode *node) { Preds.replaceNode(node); } diff --git a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp index 68e47af108..66944c616b 100644 --- a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp +++ b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp @@ -283,6 +283,13 @@ ExplodedNode * const *ExplodedNode::NodeGroup::end() const { return Storage.getAddrOfPtr1() + 1; } +int64_t ExplodedNode::getID(ExplodedGraph *G) const { + Optional Out = G->getAllocator().identifyObject(this); + assert(Out && "Wrong allocator used"); + assert(*Out % alignof(ExplodedNode) == 0 && "Wrong alignment information"); + return *Out / alignof(ExplodedNode); +} + ExplodedNode *ExplodedGraph::getNode(const ProgramPoint &L, ProgramStateRef State, bool IsSink, diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index a9901a6cd7..7f13c7f0a0 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -3141,9 +3141,13 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { } ProgramStateRef state = N->getState(); - Out << "\\|StateID: " << state->getID() << " (" - << (const void*) state.get() << ")" - << " NodeID: " << (const void*) N << "\\|"; + ExplodedGraph &Graph = + static_cast(state->getStateManager().getOwningEngine()) + ->getGraph(); + + Out << "\\|StateID: " << state->getID() << " (" << (const void *)state.get() + << ")" + << " NodeID: " << N->getID(&Graph) << " (" << (const void *)N << ")\\|"; state->printDOT(Out, N->getLocationContext()); -- 2.40.0