[cfe-commits] r55403 - in /cfe/trunk: include/clang/Analysis/PathSensitive/ExplodedGraph.h lib/Analysis/ExplodedGraph.cpp

Ted Kremenek kremenek at apple.com
Tue Aug 26 20:56:11 CDT 2008


Author: kremenek
Date: Tue Aug 26 20:56:11 2008
New Revision: 55403

URL: http://llvm.org/viewvc/llvm-project?rev=55403&view=rev
Log:
Added "Auditor" interface for auditing the construction of ExplodedGraphs.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h
    cfe/trunk/lib/Analysis/ExplodedGraph.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h?rev=55403&r1=55402&r2=55403&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h Tue Aug 26 20:56:11 2008
@@ -123,7 +123,19 @@
   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);
 };
 
 

Modified: cfe/trunk/lib/Analysis/ExplodedGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ExplodedGraph.cpp?rev=55403&r1=55402&r2=55403&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/ExplodedGraph.cpp (original)
+++ cfe/trunk/lib/Analysis/ExplodedGraph.cpp Tue Aug 26 20:56:11 2008
@@ -22,6 +22,26 @@
 
 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 @@
   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) {




More information about the cfe-commits mailing list