diff options
Diffstat (limited to 'lib/Analysis/RegionStore.cpp')
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index e065c5c410..defa80f324 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -287,7 +287,7 @@ SVal RegionStoreManager::getLValueElement(const GRState* St, SVal NewIdx = CI1->EvalBinOp(getBasicVals(), BinaryOperator::Add, *CI2); return loc::MemRegionVal(MRMgr.getElementRegion(NewIdx, - ElemR->getSuperRegion())); + ElemR->getArrayRegion())); } return UnknownVal(); @@ -360,8 +360,18 @@ SVal RegionStoreManager::getSizeInElements(const GRState* St, // Cast 'pointer to array' to 'pointer to the first element of array'. SVal RegionStoreManager::ArrayToPointer(SVal Array) { - const MemRegion* ArrayR = cast<loc::MemRegionVal>(&Array)->getRegion(); - + if (Array.isUnknownOrUndef()) + return Array; + + if (!isa<loc::MemRegionVal>(Array)) + return UnknownVal(); + + const MemRegion* R = cast<loc::MemRegionVal>(&Array)->getRegion(); + const TypedRegion* ArrayR = dyn_cast<TypedRegion>(R); + + if (ArrayR) + return UnknownVal(); + nonloc::ConcreteInt Idx(getBasicVals().getZeroWithPtrWidth(false)); ElementRegion* ER = MRMgr.getElementRegion(Idx, ArrayR); |