Convert the offset to signed before making an ElementRegion with it. It seems

that this problem arises from time to time. We should find a fundamental 
solution for it.

llvm-svn: 65035
This commit is contained in:
Zhongxing Xu 2009-02-19 08:37:16 +00:00
parent 13aada6fc4
commit f74ab25e22
1 changed files with 11 additions and 1 deletions

View File

@ -367,6 +367,16 @@ SVal RegionStoreManager::getLValueElement(const GRState* St,
//
// Observe that 'p' binds to an AnonTypedRegion<AllocaRegion>.
//
// Offset might be unsigned. We have to convert it to signed ConcreteInt.
if (nonloc::ConcreteInt* CI = dyn_cast<nonloc::ConcreteInt>(&Offset)) {
const llvm::APSInt& OffI = CI->getValue();
if (OffI.isUnsigned()) {
llvm::APSInt Tmp = OffI;
Tmp.setIsSigned(true);
Offset = NonLoc::MakeVal(getBasicVals(), Tmp);
}
}
return loc::MemRegionVal(MRMgr.getElementRegion(Offset, BaseRegion));
}
@ -397,7 +407,7 @@ SVal RegionStoreManager::getLValueElement(const GRState* St,
Tmp.setIsSigned(true);
Tmp += BaseIdxI; // Compute the new offset.
NewIdx = nonloc::ConcreteInt(getBasicVals().getValue(Tmp));
NewIdx = NonLoc::MakeVal(getBasicVals(), Tmp);
}
else
NewIdx = nonloc::ConcreteInt(getBasicVals().getValue(BaseIdxI + OffI));