aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);