}
SVal GetSValAsScalarOrLoc(const GRState* state, const MemRegion *R) {
+ // We only want to do fetches from regions that we can actually bind
+ // values. For example, SymbolicRegions of type 'id<...>' cannot
+ // have direct bindings (but their can be bindings on their subregions).
+ if (!R->isBoundable(getContext()))
+ return UnknownVal();
+
if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) {
QualType T = TR->getRValueType(getContext());
if (Loc::IsLocType(T) || T->isIntegerType())
virtual void print(llvm::raw_ostream& os) const;
Kind getKind() const { return kind; }
+
+ virtual bool isBoundable(ASTContext&) const { return true; }
static bool classof(const MemRegion*) { return true; }
};
void Profile(llvm::FoldingSetNodeID& ID) const;
+ bool isBoundable(ASTContext &) const { return false; }
+
static bool classof(const MemRegion* R) {
return R->getKind() == MemSpaceRegionKind;
}
QualType getDesugaredLValueType(ASTContext& C) const {
return getLValueType(C)->getDesugaredType();
}
+
+ bool isBoundable(ASTContext &C) const {
+ // FIXME: This needs to be adjusted for structures and arrays.
+ // All this will reject right now is ObjCQualifiedIdType and
+ // BlockPointerType.
+ return getLValueType(C)->isPointerType();
+ }
static bool classof(const MemRegion* R) {
unsigned k = R->getKind();
}
QualType getRValueType(ASTContext& C) const;
+ QualType getLValueType(ASTContext& C) const;
void Profile(llvm::FoldingSetNodeID& ID) const;
R = dyn_cast<TypedRegion>(ATR->getSuperRegion());
}
- if (R) {
+ if (R && R->isBoundable(Ctx)) {
// Is the invalidated variable something that we were tracking?
SymbolRef Sym = state.GetSValAsScalarOrLoc(R).getAsLocSymbol();
if (Sym.isValid())
// Get the type of the symbol.
QualType T = data.getType(C);
- // Only when the symbol has pointer type it can have a symbolic region
- // associated with it.
- PointerType* PTy = cast<PointerType>(T.getTypePtr()->getDesugaredType());
+ if (const PointerType* PTy = T->getAsPointerType())
+ return PTy->getPointeeType();
+
+ if (const BlockPointerType* PTy = T->getAsBlockPointerType())
+ return PTy->getPointeeType();
- // The type of the symbolic region is the pointee type of the symbol.
- return PTy->getPointeeType();
+ assert(!T->getAsObjCQualifiedIdType() &&
+ "There is no rvalue type for id<...>");
+
+ assert(Loc::IsLocType(T) && "Non-location type.");
+ return QualType();
+}
+
+QualType SymbolicRegion::getLValueType(ASTContext& C) const {
+ const SymbolData& data = SymMgr.getSymbolData(sym);
+ return data.getType(C);
}
QualType ElementRegion::getRValueType(ASTContext& C) const {
}
void TypedViewRegion::print(llvm::raw_ostream& os) const {
- os << "anon_type{" << T.getAsString() << ',';
+ os << "typed_view{" << T.getAsString() << ',';
getSuperRegion()->print(os);
os << '}';
}