]> granicus.if.org Git - clang/commitdiff
Added "Auditor" interface for auditing the construction of ExplodedGraphs.
authorTed Kremenek <kremenek@apple.com>
Wed, 27 Aug 2008 01:56:11 +0000 (01:56 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 27 Aug 2008 01:56:11 +0000 (01:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55403 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/ExplodedGraph.h
lib/Analysis/ExplodedGraph.cpp

index c85d1e9107a8ddc274440012cde0d43ebc0a0ce1..3406d178dd7d074911a2d153703bda86ebf0bf04 100644 (file)
@@ -123,7 +123,19 @@ public:
   bool pred_empty() const { return Preds.empty(); }
   
   bool isSink() const { return Succs.getFlag(); }
-  void markAsSink() { Succs.setFlag(); }  
+  void markAsSink() { Succs.setFlag(); } 
+  
+  // For debugging.
+  
+public:
+  
+  class Auditor {
+  public:
+    virtual ~Auditor();
+    virtual void AddEdge(ExplodedNodeImpl* Src, ExplodedNodeImpl* Dst) = 0;
+  };
+  
+  static void SetAuditor(Auditor* A);
 };
 
 
index 0835944250fdfcd489ad536c27462a59e5c3190e..945416b1b56e882cc38c9dde5a63360cde3084be 100644 (file)
 
 using namespace clang;
 
+//===----------------------------------------------------------------------===//
+// Node auditing.
+//===----------------------------------------------------------------------===//
+
+// An out of line virtual method to provide a home for the class vtable.
+ExplodedNodeImpl::Auditor::~Auditor() {}
+
+#ifndef NDEBUG
+static ExplodedNodeImpl::Auditor* NodeAuditor = 0;
+#endif
+
+void ExplodedNodeImpl::SetAuditor(ExplodedNodeImpl::Auditor* A) {
+#ifndef NDEBUG
+  NodeAuditor = A;
+#endif
+}
+
+//===----------------------------------------------------------------------===//
+// ExplodedNodeImpl.
+//===----------------------------------------------------------------------===//
 
 static inline std::vector<ExplodedNodeImpl*>& getVector(void* P) {
   return *reinterpret_cast<std::vector<ExplodedNodeImpl*>*>(P);
@@ -31,6 +51,9 @@ void ExplodedNodeImpl::addPredecessor(ExplodedNodeImpl* V) {
   assert (!V->isSink());
   Preds.addNode(V);
   V->Succs.addNode(this);
+#ifndef NDEBUG
+  if (NodeAuditor) NodeAuditor->AddEdge(V, this);
+#endif
 }
 
 void ExplodedNodeImpl::NodeGroup::addNode(ExplodedNodeImpl* N) {