return UnknownVal();
}
+ if (isa<ElementRegion>(R)) {
+ return UnknownVal();
+ }
+
assert(0 && "Other regions are not supported yet.");
return UnknownVal();
}
return loc::MemRegionVal(ER);
}
+static bool isSmallerThan(QualType T1, QualType T2) {
+ if (T1->isCharType())
+ return true;
+ else
+ return false;
+}
+
RegionStoreManager::CastResult
RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R,
QualType CastToTy) {
// VarRegion.
if (isa<VarRegion>(R) || isa<ElementRegion>(R) || isa<FieldRegion>(R)
|| isa<ObjCIvarRegion>(R) || isa<CompoundLiteralRegion>(R)) {
- // FIXME: create an ElementRegion when the size of the pointee type is
- // smaller than the region.
- return CastResult(state, R);
+ if (isSmallerThan(PointeeTy,
+ cast<TypedRegion>(R)->getRValueType(getContext()))) {
+ SVal Idx = ValMgr.makeZeroArrayIndex();
+ ElementRegion* ER = MRMgr.getElementRegion(PointeeTy, Idx,
+ cast<TypedRegion>(R));
+ return CastResult(state, ER);
+ } else
+ return CastResult(state, R);
}
if (isa<TypedViewRegion>(R)) {
struct load_wine *cmd = (void*) &wonky[1];
cmd = cmd;
char *p = (void*) &wonky[1];
- *p = 1; // expected-warning{{Load or store into an out-of-bound memory}}
+ *p = 1;
+ kernel_tea_cheese_t *q = &wonky[1];
+ kernel_tea_cheese_t r = *q; // expected-warning{{out-of-bound memory position}}
}