[analyzer] ExprEngine should not depend on checkers for not crashing.

llvm-svn: 126622
This commit is contained in:
Argyrios Kyrtzidis 2011-02-28 01:27:57 +00:00
parent 68ed625bd3
commit 4f7745a3b1
2 changed files with 19 additions and 4 deletions

View File

@ -1322,7 +1322,7 @@ void ExprEngine::processBranch(const Stmt* Condition, const Stmt* Term,
const GRState* PrevState = builder.getState(); const GRState* PrevState = builder.getState();
SVal X = PrevState->getSVal(Condition); SVal X = PrevState->getSVal(Condition);
if (X.isUnknown()) { if (X.isUnknownOrUndef()) {
// Give it a chance to recover from unknown. // Give it a chance to recover from unknown.
if (const Expr *Ex = dyn_cast<Expr>(Condition)) { if (const Expr *Ex = dyn_cast<Expr>(Condition)) {
if (Ex->getType()->isIntegerType()) { if (Ex->getType()->isIntegerType()) {
@ -1340,7 +1340,7 @@ void ExprEngine::processBranch(const Stmt* Condition, const Stmt* Term,
} }
} }
// If the condition is still unknown, give up. // If the condition is still unknown, give up.
if (X.isUnknown()) { if (X.isUnknownOrUndef()) {
builder.generateNode(MarkBranch(PrevState, Term, true), true); builder.generateNode(MarkBranch(PrevState, Term, true), true);
builder.generateNode(MarkBranch(PrevState, Term, false), false); builder.generateNode(MarkBranch(PrevState, Term, false), false);
return; return;
@ -1858,7 +1858,8 @@ void ExprEngine::evalStore(ExplodedNodeSet& Dst, const Expr *AssignE,
if (Tmp.empty()) if (Tmp.empty())
return; return;
assert(!location.isUndef()); if (location.isUndef())
return;
SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind, SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind,
ProgramPoint::PostStoreKind); ProgramPoint::PostStoreKind);
@ -1918,7 +1919,8 @@ void ExprEngine::evalLoadCommon(ExplodedNodeSet& Dst, const Expr *Ex,
if (Tmp.empty()) if (Tmp.empty())
return; return;
assert(!location.isUndef()); if (location.isUndef())
return;
SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind); SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind);

View File

@ -90,6 +90,19 @@ StoreManager *ento::CreateFlatStoreManager(GRStateManager &StMgr) {
} }
SVal FlatStoreManager::Retrieve(Store store, Loc L, QualType T) { SVal FlatStoreManager::Retrieve(Store store, Loc L, QualType T) {
// For access to concrete addresses, return UnknownVal. Checks
// for null dereferences (and similar errors) are done by checkers, not
// the Store.
// FIXME: We can consider lazily symbolicating such memory, but we really
// should defer this when we can reason easily about symbolicating arrays
// of bytes.
if (isa<loc::ConcreteInt>(L)) {
return UnknownVal();
}
if (!isa<loc::MemRegionVal>(L)) {
return UnknownVal();
}
const MemRegion *R = cast<loc::MemRegionVal>(L).getRegion(); const MemRegion *R = cast<loc::MemRegionVal>(L).getRegion();
RegionInterval RI = RegionToInterval(R); RegionInterval RI = RegionToInterval(R);
// FIXME: FlatStore should handle regions with unknown intervals. // FIXME: FlatStore should handle regions with unknown intervals.