[cfe-commits] r50310 - in /cfe/trunk: include/clang/Analysis/ProgramPoint.h lib/Analysis/ProgramPoint.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Sat Apr 26 08:19:52 PDT 2008


Author: akirtzidis
Date: Sat Apr 26 10:19:51 2008
New Revision: 50310

URL: http://llvm.org/viewvc/llvm-project?rev=50310&view=rev
Log:
Make assertions for all addresses passed to ProgramPoint that they have at least an 8-byte alignment.

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

Modified: cfe/trunk/include/clang/Analysis/ProgramPoint.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ProgramPoint.h?rev=50310&r1=50309&r2=50310&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/ProgramPoint.h (original)
+++ cfe/trunk/include/clang/Analysis/ProgramPoint.h Sat Apr 26 10:19:51 2008
@@ -31,14 +31,18 @@
   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 @@
   /// 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;

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

==============================================================================
--- cfe/trunk/lib/Analysis/ProgramPoint.cpp (original)
+++ cfe/trunk/lib/Analysis/ProgramPoint.cpp Sat Apr 26 10:19:51 2008
@@ -19,15 +19,14 @@
 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 {





More information about the cfe-commits mailing list