diff options
author | Anna Zaks <ganna@apple.com> | 2013-12-06 18:56:29 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-12-06 18:56:29 +0000 |
commit | cf8d2165ffebd254927463af7d86f61d8bbd3fd2 (patch) | |
tree | cd59cde242b50c800597e0d404729d22141ed601 /clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | |
parent | ba0aea16e1902cf39d32e2617b88582519e31a28 (diff) | |
download | bcm5719-llvm-cf8d2165ffebd254927463af7d86f61d8bbd3fd2.tar.gz bcm5719-llvm-cf8d2165ffebd254927463af7d86f61d8bbd3fd2.zip |
Revert "[analyzer] Refactor conditional expression evaluating code"
This reverts commit r189090.
The original patch introduced regressions (see the added live-variables.* tests). The patch depends on the correctness of live variable analyses, which are not computed correctly. I've opened PR18159 to track the proper resolution to this problem.
The patch was a stepping block to r189746. This is why part of the patch reverts temporary destructor tests that started crashing. The temporary destructors feature is disabled by default.
llvm-svn: 196593
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngine.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 5664e41324e..e0a764a1a61 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1385,27 +1385,11 @@ void ExprEngine::processBranch(const Stmt *Condition, const Stmt *Term, return; } - SValBuilder &SVB = Pred->getState()->getStateManager().getSValBuilder(); - SVal TrueVal = SVB.makeTruthVal(true); - SVal FalseVal = SVB.makeTruthVal(false); if (const Expr *Ex = dyn_cast<Expr>(Condition)) Condition = Ex->IgnoreParens(); - // If the value is already available, we don't need to do anything. - if (Pred->getState()->getSVal(Condition, LCtx).isUnknownOrUndef()) { - // Resolve the condition in the presence of nested '||' and '&&'. - Condition = ResolveCondition(Condition, BldCtx.getBlock()); - } - - // Cast truth values to the correct type. - if (const Expr *Ex = dyn_cast<Expr>(Condition)) { - TrueVal = SVB.evalCast(TrueVal, Ex->getType(), - getContext().getLogicalOperationType()); - FalseVal = SVB.evalCast(FalseVal, Ex->getType(), - getContext().getLogicalOperationType()); - } - + Condition = ResolveCondition(Condition, BldCtx.getBlock()); PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(), Condition->getLocStart(), "Error evaluating branch"); @@ -1448,37 +1432,31 @@ void ExprEngine::processBranch(const Stmt *Condition, const Stmt *Term, } } - ProgramStateRef StTrue, StFalse; - // If the condition is still unknown, give up. if (X.isUnknownOrUndef()) { - - StTrue = PrevState->BindExpr(Condition, BldCtx.LC, TrueVal); - StFalse = PrevState->BindExpr(Condition, BldCtx.LC, FalseVal); - - builder.generateNode(StTrue, true, PredI); - builder.generateNode(StFalse, false, PredI); + builder.generateNode(PrevState, true, PredI); + builder.generateNode(PrevState, false, PredI); continue; } DefinedSVal V = X.castAs<DefinedSVal>(); + + ProgramStateRef StTrue, StFalse; tie(StTrue, StFalse) = PrevState->assume(V); // Process the true branch. if (builder.isFeasible(true)) { - if (StTrue) { - StTrue = StTrue->BindExpr(Condition, BldCtx.LC, TrueVal); + if (StTrue) builder.generateNode(StTrue, true, PredI); - } else + else builder.markInfeasible(true); } // Process the false branch. if (builder.isFeasible(false)) { - if (StFalse) { - StFalse = StFalse->BindExpr(Condition, BldCtx.LC, FalseVal); + if (StFalse) builder.generateNode(StFalse, false, PredI); - } else + else builder.markInfeasible(false); } } |