]> granicus.if.org Git - clang/commitdiff
[analyzer] Dump stable identifiers for exploded nodes
authorGeorge Karpenkov <ekarpenkov@apple.com>
Thu, 6 Sep 2018 23:08:07 +0000 (23:08 +0000)
committerGeorge Karpenkov <ekarpenkov@apple.com>
Thu, 6 Sep 2018 23:08:07 +0000 (23:08 +0000)
Differential Revision: https://reviews.llvm.org/D51667

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341602 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
lib/StaticAnalyzer/Core/ExplodedGraph.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp

index f974ef821d7729363c6985aeeb693bb9b3367ebf..29754c163ac2fa77c58dc0ea8b09d97d589b095d 100644 (file)
@@ -240,6 +240,8 @@ public:
     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); }
index 68e47af1086ba19d1fe538a28af54710c958d782..66944c616b96c222f8a73c624432440ac7629506 100644 (file)
@@ -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,
index a9901a6cd7d057b750e1fbfa7f365df9e58d3dc8..7f13c7f0a0519facd16958cda5819fcb405bcfba 100644 (file)
@@ -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());