diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-28 01:27:57 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-28 01:27:57 +0000 |
commit | 73c498a08f4968b6987d1453c7b77929dcc6d5f7 (patch) | |
tree | 85a34e9b8361126db639bce6e4d23d4b6c4ea757 /lib/StaticAnalyzer | |
parent | 3ce2b48461115af047ee1e957e1892af255bf120 (diff) |
[analyzer] ExprEngine should not depend on checkers for not crashing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126622 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/ExprEngine.cpp | 10 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Core/FlatStore.cpp | 13 |
2 files changed, 19 insertions, 4 deletions
diff --git a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp index fc33639a86..004be0c1b1 100644 --- a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp @@ -1322,7 +1322,7 @@ void ExprEngine::processBranch(const Stmt* Condition, const Stmt* Term, const GRState* PrevState = builder.getState(); SVal X = PrevState->getSVal(Condition); - if (X.isUnknown()) { + if (X.isUnknownOrUndef()) { // Give it a chance to recover from unknown. if (const Expr *Ex = dyn_cast<Expr>(Condition)) { 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 (X.isUnknown()) { + if (X.isUnknownOrUndef()) { builder.generateNode(MarkBranch(PrevState, Term, true), true); builder.generateNode(MarkBranch(PrevState, Term, false), false); return; @@ -1858,7 +1858,8 @@ void ExprEngine::evalStore(ExplodedNodeSet& Dst, const Expr *AssignE, if (Tmp.empty()) return; - assert(!location.isUndef()); + if (location.isUndef()) + return; SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind, ProgramPoint::PostStoreKind); @@ -1918,7 +1919,8 @@ void ExprEngine::evalLoadCommon(ExplodedNodeSet& Dst, const Expr *Ex, if (Tmp.empty()) return; - assert(!location.isUndef()); + if (location.isUndef()) + return; SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind); diff --git a/lib/StaticAnalyzer/Core/FlatStore.cpp b/lib/StaticAnalyzer/Core/FlatStore.cpp index 99a5eadaca..7bdca6b7f1 100644 --- a/lib/StaticAnalyzer/Core/FlatStore.cpp +++ b/lib/StaticAnalyzer/Core/FlatStore.cpp @@ -90,6 +90,19 @@ StoreManager *ento::CreateFlatStoreManager(GRStateManager &StMgr) { } 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(); RegionInterval RI = RegionToInterval(R); // FIXME: FlatStore should handle regions with unknown intervals. |