[PATCH] D51395: [analyzer] Dump a reproducible, deterministic ID of program state to exploded graph

George Karpenkov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 29 18:16:55 PDT 2018


george.karpenkov updated this revision to Diff 163247.

https://reviews.llvm.org/D51395

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp


Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -69,6 +69,13 @@
     stateMgr->getStoreManager().decrementReferenceCount(store);
 }
 
+long ProgramState::getID() const {
+  Optional<long> Out = getStateManager().Alloc.identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
+  return *Out / alignof(ProgramState);
+}
+
 ProgramStateManager::ProgramStateManager(ASTContext &Ctx,
                                          StoreManagerCreator CreateSMgr,
                                          ConstraintManagerCreator CreateCMgr,
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3141,7 +3141,8 @@
     }
 
     ProgramStateRef state = N->getState();
-    Out << "\\|StateID: " << (const void*) state.get()
+    Out << "\\|StateID: " << state->getID() << " ("
+        << (const void*) state.get() << ")"
         << " NodeID: " << (const void*) N << "\\|";
 
     state->printDOT(Out, N->getLocationContext());
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -107,6 +107,8 @@
 
   ~ProgramState();
 
+  long getID() const;
+
   /// Return the ProgramStateManager associated with this state.
   ProgramStateManager &getStateManager() const {
     return *stateMgr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51395.163247.patch
Type: text/x-patch
Size: 1849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180830/16a0e617/attachment-0001.bin>


More information about the cfe-commits mailing list