Add array index assertion: BasicStore should not expect any fancy

ElementRegions that have non-zero array indices.

llvm-svn: 70867
This commit is contained in:
Ted Kremenek 2009-05-04 15:25:46 +00:00
parent c1fd2284c1
commit a68556c4cc
1 changed files with 4 additions and 1 deletions

View File

@ -212,11 +212,14 @@ SVal BasicStoreManager::getLValueElement(const GRState* St,
case loc::MemRegionKind: {
const MemRegion *R = cast<loc::MemRegionVal>(BaseL).getRegion();
if (isa<ElementRegion>(R)) {
if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
// int x;
// char* y = (char*) &x;
// 'y' => ElementRegion(0, VarRegion('x'))
// y[0] = 'a';
assert(ER->getIndex().isUnknown() ||
cast<nonloc::ConcreteInt>(ER->getIndex()).getValue() == 0);
ER = ER; // silence 'unused' warning in release modes.
return Base;
}