QualType VarTy = VR->getValueType(getContext());
uint64_t EleSize = getContext().getTypeSize(EleTy);
uint64_t VarSize = getContext().getTypeSize(VarTy);
+ assert(VarSize != 0);
return NonLoc::MakeIntVal(getBasicVals(), VarSize / EleSize, false);
}
uint64_t ObjTySize = getContext().getTypeSize(ObjTy);
if ((PointeeTySize > 0 && PointeeTySize < ObjTySize) ||
- (ObjTy->isAggregateType() && PointeeTy->isScalarType())) {
+ (ObjTy->isAggregateType() && PointeeTy->isScalarType()) ||
+ ObjTySize == 0 /* R has 'void*' type. */) {
// Record the cast type of the region.
state = setCastType(state, R, ToTy);
SVal Idx = ValMgr.makeZeroArrayIndex();
ElementRegion* ER = MRMgr.getElementRegion(PointeeTy, Idx,R,getContext());
return CastResult(state, ER);
- } else
+ } else {
+ state = setCastType(state, R, ToTy);
return CastResult(state, R);
+ }
}
if (isa<ObjCObjectRegion>(R)) {
return UndefinedVal();
}
+ // If the region is already cast to another type, use that type to create the
+ // symbol value.
+ if (const QualType *p = state->get<RegionCasts>(R)) {
+ QualType T = *p;
+ RTy = T->getAsPointerType()->getPointeeType();
+ }
+
// All other integer values are symbolic.
if (Loc::IsLocType(RTy) || RTy->isIntegerType())
- return ValMgr.getRegionValueSymbolVal(R);
+ return ValMgr.getRegionValueSymbolVal(R, RTy);
else
return UnknownVal();
}
-SVal RegionStoreManager::RetrieveStruct(const GRState *state, const TypedRegion* R){
+SVal RegionStoreManager::RetrieveStruct(const GRState *state,
+ const TypedRegion* R){
QualType T = R->getValueType(getContext());
assert(T->isStructureType());
return state->set<RegionViewMap>(Base, RVFactory.Remove(*d, View));
}
-const GRState *RegionStoreManager::setCastType(const GRState *state, const MemRegion* R,
- QualType T) {
+const GRState *RegionStoreManager::setCastType(const GRState *state,
+ const MemRegion* R, QualType T) {
return state->set<RegionCasts>(R, T);
}
return nonloc::CompoundVal(BasicVals.getCompoundValData(T, Vals));
}
-SVal ValueManager::getRegionValueSymbolVal(const MemRegion* R) {
+SVal ValueManager::getRegionValueSymbolVal(const MemRegion* R, QualType T) {
SymbolRef sym = SymMgr.getRegionValueSymbol(R);
if (const TypedRegion* TR = dyn_cast<TypedRegion>(R)) {
- QualType T = TR->getValueType(SymMgr.getContext());
+ if (!T.getTypePtr())
+ T = TR->getValueType(SymMgr.getContext());
// If T is of function pointer type, create a CodeTextRegion wrapping a
// symbol.