]> granicus.if.org Git - clang/commitdiff
Make assertions for all addresses passed to ProgramPoint that they have at least...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 26 Apr 2008 15:19:51 +0000 (15:19 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 26 Apr 2008 15:19:51 +0000 (15:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50310 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/ProgramPoint.h
lib/Analysis/ProgramPoint.cpp

index a046268cfd7e8321f27edb09df0c616a85ff8a5b..5fc1fb651b090d8335bb48994d14a2fb5a098e40 100644 (file)
@@ -31,14 +31,18 @@ protected:
   uintptr_t Data;
 
   ProgramPoint(const void* Ptr, Kind k) {
+    setRawData(Ptr, k);
+  }
+  
+  ProgramPoint() : Data(0) {}
+
+  void setRawData(const void* Ptr, Kind k) {
     assert ((reinterpret_cast<uintptr_t>(const_cast<void*>(Ptr)) & 0x7) == 0
             && "Address must have at least an 8-byte alignment.");
     
     Data = reinterpret_cast<uintptr_t>(const_cast<void*>(Ptr)) | k;
   }
   
-  ProgramPoint() : Data(0) {}
-  
 public:    
   unsigned getKind() const { return Data & 0x7; }  
   void* getRawPtr() const { return reinterpret_cast<void*>(Data & ~0x7); }
@@ -114,10 +118,8 @@ public:
   /// This ctor forces the BlockEdge to be constructed using an explicitly
   ///  allocated pair object that is stored in the CFG.  This is usually
   ///  used to construct edges representing jumps using computed gotos.
-  BlockEdge(CFG& cfg, const CFGBlock* B1, const CFGBlock* B2, bool) {
-    Data = reinterpret_cast<uintptr_t>(cfg.getBlockEdgeImpl(B1, B2))
-           | BlockEdgeAuxKind;
-  }
+  BlockEdge(CFG& cfg, const CFGBlock* B1, const CFGBlock* B2, bool)
+    : ProgramPoint(cfg.getBlockEdgeImpl(B1, B2), BlockEdgeAuxKind) {}
 
 
   CFGBlock* getSrc() const;
index c089e4869880f2d1ab830c7b735966f9a3e796c1..d95680ff38928e7a95ecaaba58a2d99e8ae5dee8 100644 (file)
@@ -19,15 +19,14 @@ using namespace clang;
 BlockEdge::BlockEdge(CFG& cfg, const CFGBlock* B1, const CFGBlock* B2) {    
   if (B1->succ_size() == 1) {
     assert (*(B1->succ_begin()) == B2);
-    Data = reinterpret_cast<uintptr_t>(B1) | BlockEdgeSrcKind;
+    setRawData(B1, BlockEdgeSrcKind);
   }
   else if (B2->pred_size() == 1) {
     assert (*(B2->pred_begin()) == B1);
-    Data = reinterpret_cast<uintptr_t>(B2) | BlockEdgeDstKind;
+    setRawData(B2, BlockEdgeDstKind);
   }
   else 
-    Data = reinterpret_cast<uintptr_t>(cfg.getBlockEdgeImpl(B1,B2)) 
-            | BlockEdgeAuxKind;
+    setRawData(cfg.getBlockEdgeImpl(B1,B2), BlockEdgeAuxKind);
 }
 
 CFGBlock* BlockEdge::getSrc() const {