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.

llvm-svn: 66638
This commit is contained in:
Ted Kremenek 2009-03-11 04:04:20 +00:00
parent 154c963317
commit 90e213f025
1 changed files with 6 additions and 2 deletions

View File

@ -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);