From: Zhongxing Xu Date: Sat, 29 Nov 2008 12:05:04 +0000 (+0000) Subject: To be consistent, make the index of the ElementRegion always signed. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0395b5d4987fe5baa818015e9d294c128619e4ec;p=clang 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 --- 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(&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);