Skip to content

Commit

Permalink
[analyzer] Dump stable identifiers for exploded nodes
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D51667

llvm-svn: 341602
  • Loading branch information
George Karpenkov committed Sep 6, 2018
1 parent 95363e3 commit 84a2b30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Expand Up @@ -240,6 +240,8 @@ class ExplodedNode : public llvm::FoldingSetNode {
return const_cast<ExplodedNode*>(this)->succ_end();
}

int64_t getID(ExplodedGraph *G) const;

private:
void replaceSuccessor(ExplodedNode *node) { Succs.replaceNode(node); }
void replacePredecessor(ExplodedNode *node) { Preds.replaceNode(node); }
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
Expand Up @@ -283,6 +283,13 @@ ExplodedNode * const *ExplodedNode::NodeGroup::end() const {
return Storage.getAddrOfPtr1() + 1;
}

int64_t ExplodedNode::getID(ExplodedGraph *G) const {
Optional<int64_t> 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,
Expand Down
10 changes: 7 additions & 3 deletions clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
Expand Up @@ -3141,9 +3141,13 @@ struct DOTGraphTraits<ExplodedNode*> : public DefaultDOTGraphTraits {
}

ProgramStateRef state = N->getState();
Out << "\\|StateID: " << state->getID() << " ("
<< (const void*) state.get() << ")"
<< " NodeID: " << (const void*) N << "\\|";
ExplodedGraph &Graph =
static_cast<ExprEngine *>(state->getStateManager().getOwningEngine())
->getGraph();

Out << "\\|StateID: " << state->getID() << " (" << (const void *)state.get()
<< ")"
<< " NodeID: " << N->getID(&Graph) << " (" << (const void *)N << ")\\|";

state->printDOT(Out, N->getLocationContext());

Expand Down

0 comments on commit 84a2b30

Please sign in to comment.