]> granicus.if.org Git - clang/commitdiff
To be consistent, make the index of the ElementRegion always signed.
authorZhongxing Xu <xuzhongxing@gmail.com>
Sat, 29 Nov 2008 12:05:04 +0000 (12:05 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Sat, 29 Nov 2008 12:05:04 +0000 (12:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60248 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/MemRegion.h
lib/Analysis/RegionStore.cpp

index e2f15375511606489ebd269ecb10cfaa93a1972a..35df7df5f4183692c5ee7120197b1a1a16d95801 100644 (file)
@@ -415,7 +415,11 @@ class ElementRegion : public TypedRegion {
   SVal Index;
 
   ElementRegion(SVal Idx, const MemRegion* sReg)
-    : TypedRegion(sReg, ElementRegionKind), Index(Idx) {}
+    : TypedRegion(sReg, ElementRegionKind), Index(Idx) {
+    // The index must be signed.
+    if (nonloc::ConcreteInt* CI = dyn_cast<nonloc::ConcreteInt>(&Idx))
+      assert(CI->getValue().isSigned());
+  }
 
   static void ProfileRegion(llvm::FoldingSetNodeID& ID, SVal Idx, 
                             const MemRegion* superRegion);
index 981d69c8223a42e58bbd74ae6f168f608591d6ea..1b62cc503232d913f119a372a3af1a69b8c0716e 100644 (file)
@@ -646,7 +646,7 @@ Store RegionStoreManager::InitializeArray(Store store, const TypedRegion* R,
   nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
 
   for (; i != Size; ++i) {
-    nonloc::ConcreteInt Idx(getBasicVals().getValue(llvm::APSInt(i)));
+    nonloc::ConcreteInt Idx(getBasicVals().getValue(llvm::APSInt(i, false)));
 
     ElementRegion* ER = MRMgr.getElementRegion(Idx, R);