From: Ted Kremenek Date: Wed, 11 Mar 2009 04:04:20 +0000 (+0000) Subject: RegionStore::getLValueElement: Handle the case where the signedness of the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac6ff48cc3821b0177828392ea83db9bf015f4c1;p=clang 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 2f4d70a577..6253e6182f 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -630,8 +630,12 @@ SVal RegionStoreManager::EvalBinOp(BinaryOperator::Opcode Op, Loc L, NonLoc R) { // 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);