aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2008-11-29 12:05:04 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2008-11-29 12:05:04 +0000
commit0395b5d4987fe5baa818015e9d294c128619e4ec (patch)
treeb1ea3b88d3eb8713cfaefcbcda248f8c37951135
parent2d8b273470684a9cd47f0ce24743cc1f71ef7cbc (diff)
To be consistent, make the index of the ElementRegion always signed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60248 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Analysis/PathSensitive/MemRegion.h6
-rw-r--r--lib/Analysis/RegionStore.cpp2
2 files changed, 6 insertions, 2 deletions
diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h
index e2f1537551..35df7df5f4 100644
--- a/include/clang/Analysis/PathSensitive/MemRegion.h
+++ b/include/clang/Analysis/PathSensitive/MemRegion.h
@@ -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);
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 981d69c822..1b62cc5032 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -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);