[cfe-commits] r110106 - in /cfe/trunk: include/clang/Checker/PathSensitive/MemRegion.h lib/Checker/FlatStore.cpp lib/Checker/MemRegion.cpp

Zhongxing Xu xuzhongxing at gmail.com
Mon Aug 2 23:34:25 PDT 2010


Author: zhongxingxu
Date: Tue Aug  3 01:34:25 2010
New Revision: 110106

URL: http://llvm.org/viewvc/llvm-project?rev=110106&view=rev
Log:
Allow offsets to be negative. Out-of-bound cases are checked elsewhere. We 
shouldn't put restrictions in store manager.

Modified:
    cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h
    cfe/trunk/lib/Checker/FlatStore.cpp
    cfe/trunk/lib/Checker/MemRegion.cpp

Modified: cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h?rev=110106&r1=110105&r2=110106&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h Tue Aug  3 01:34:25 2010
@@ -45,14 +45,14 @@
   const MemRegion *R;
 
   /// The bit offset within the base region. It shouldn't be negative.
-  uint64_t Offset;
+  int64_t Offset;
 
 public:
   RegionOffset(const MemRegion *r) : R(r), Offset(0) {}
-  RegionOffset(const MemRegion *r, uint64_t off) : R(r), Offset(off) {}
+  RegionOffset(const MemRegion *r, int64_t off) : R(r), Offset(off) {}
 
   const MemRegion *getRegion() const { return R; }
-  uint64_t getOffset() const { return Offset; }
+  int64_t getOffset() const { return Offset; }
 };
 
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/Checker/FlatStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/FlatStore.cpp?rev=110106&r1=110105&r2=110106&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/FlatStore.cpp (original)
+++ cfe/trunk/lib/Checker/FlatStore.cpp Tue Aug  3 01:34:25 2010
@@ -78,7 +78,7 @@
   public:
     const MemRegion *R;
     Interval I;
-    RegionInterval(const MemRegion *r, uint64_t s, uint64_t e) : R(r), I(s, e){}
+    RegionInterval(const MemRegion *r, int64_t s, int64_t e) : R(r), I(s, e){}
   };
 
   RegionInterval RegionToInterval(const MemRegion *R);
@@ -186,7 +186,7 @@
   switch (R->getKind()) {
   case MemRegion::VarRegionKind: {
     QualType T = cast<VarRegion>(R)->getValueType(Ctx);
-    uint64_t Size = Ctx.getTypeSize(T);
+    int64_t Size = Ctx.getTypeSize(T);
     return RegionInterval(R, 0, Size-1);
   }
 
@@ -197,8 +197,8 @@
     // with symbolic offsets.
     if (!Offset.getRegion())
       return RegionInterval(0, 0, 0);
-    uint64_t Start = Offset.getOffset();
-    uint64_t Size = Ctx.getTypeSize(cast<TypedRegion>(R)->getValueType(Ctx));
+    int64_t Start = Offset.getOffset();
+    int64_t Size = Ctx.getTypeSize(cast<TypedRegion>(R)->getValueType(Ctx));
     return RegionInterval(Offset.getRegion(), Start, Start+Size);
   }
 

Modified: cfe/trunk/lib/Checker/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/MemRegion.cpp?rev=110106&r1=110105&r2=110106&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/MemRegion.cpp (original)
+++ cfe/trunk/lib/Checker/MemRegion.cpp Tue Aug  3 01:34:25 2010
@@ -830,7 +830,7 @@
 
 RegionOffset MemRegion::getAsOffset() const {
   const MemRegion *R = this;
-  uint64_t Offset = 0;
+  int64_t Offset = 0;
 
   while (1) {
     switch (R->getKind()) {
@@ -854,7 +854,6 @@
       SVal Index = ER->getIndex();
       if (const nonloc::ConcreteInt *CI=dyn_cast<nonloc::ConcreteInt>(&Index)) {
         int64_t i = CI->getValue().getSExtValue();
-        assert(i >= 0);
         CharUnits Size = getContext().getTypeSizeInChars(EleTy);
         Offset += i * Size.getQuantity() * 8;
       } else {





More information about the cfe-commits mailing list