]> granicus.if.org Git - clang/commitdiff
Added type "CFG::Edge" to encapsulate the notion of directed-edges
authorTed Kremenek <kremenek@apple.com>
Tue, 18 Sep 2007 18:01:15 +0000 (18:01 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 18 Sep 2007 18:01:15 +0000 (18:01 +0000)
within source-level CFGs.

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

include/clang/AST/CFG.h

index f940a534c80df58e6c8346af9bbe0f2893439766..2772d1858074729d89e843b94e8d53fb4aca976d 100644 (file)
@@ -212,6 +212,33 @@ public:
   CFGBlock*        getIndirectGotoBlock() { return IndirectGotoBlock; }
   const CFGBlock*  getIndirectGotoBlock() const { return IndirectGotoBlock; }
   
+  // Edges
+  
+  class Edge {
+    const CFGBlock* Src;
+    const CFGBlock* Dst;
+  public:
+    Edge(const CFGBlock* src, const CFGBlock* dst) : Src(src), Dst(dst) {}
+    Edge(const Edge& RHS) : Src(RHS.Src), Dst(RHS.Dst) {}
+    
+    Edge& operator=(const Edge& RHS) { 
+      Src = RHS.Src;
+      Dst = RHS.Dst;
+      return *this; 
+    }
+    
+    const CFGBlock* getSrc() const { return Src; }
+    const CFGBlock* getDst() const { return Dst; }
+        
+    bool operator==(const Edge& RHS) const {
+      return Src == RHS.Src && Dst == RHS.Dst;
+    }
+    
+    bool operator!=(const Edge& RHS) const {
+      return !(*this == RHS);
+    }
+  };
+  
   // Utility
   
   CFGBlock* createBlock();