]> granicus.if.org Git - clang/commitdiff
Fix a serious bug.
authorZhongxing Xu <xuzhongxing@gmail.com>
Fri, 28 Nov 2008 08:41:39 +0000 (08:41 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Fri, 28 Nov 2008 08:41:39 +0000 (08:41 +0000)
When initialized, the index of the ElementRegion was unsigned. But the index
value of the ArraySubscriptExpr is signed. This inconsistency caused the value
of the array element retrieved to be UnknownVal despite it was initialized to
symbolic.

This is only a hack. Real fix of this problem is required.

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

lib/Analysis/RegionStore.cpp

index 157248f21bd25b9ef11cbfab9bb394b77730c210..981d69c8223a42e58bbd74ae6f168f608591d6ea 100644 (file)
@@ -669,8 +669,9 @@ Store RegionStoreManager::BindArrayToVal(Store store, const TypedRegion* BaseR,
 
     llvm::APInt Size = CAT->getSize();
     llvm::APInt i = llvm::APInt::getNullValue(Size.getBitWidth());
+
     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, BaseR);
 
@@ -693,7 +694,7 @@ Store RegionStoreManager::BindArrayToSymVal(Store store,
     llvm::APInt Size = CAT->getSize();
     llvm::APInt i = llvm::APInt::getNullValue(Size.getBitWidth());
     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, BaseR);