RegionStore::getLValueElement: Handle the case where the signedness of the
offset may be different that the base. Ultimately we need a better solution for
these issues, but this point-by-point fixes are gradually outlining the scope of
the problem.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66638 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 2f4d70a..6253e61 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -630,8 +630,12 @@
// Only support concrete integer indexes for now.
if (Base && Offset) {
- SVal NewIdx = Base->EvalBinOp(getBasicVals(), Op, *Offset);
-
+ // For now, convert the signedness of offset in case it doesn't match.
+ const llvm::APSInt &I =
+ getBasicVals().ConvertSignedness(Base->getValue(), Offset->getValue());
+ nonloc::ConcreteInt OffsetConverted(I);
+
+ SVal NewIdx = Base->EvalBinOp(getBasicVals(), Op, OffsetConverted);
const MemRegion* NewER = MRMgr.getElementRegion(NewIdx,
ER->getArrayRegion());
return Loc::MakeVal(NewER);