diff options
author | Anton Yartsev <anton.yartsev@gmail.com> | 2016-12-23 04:09:18 +0000 |
---|---|---|
committer | Anton Yartsev <anton.yartsev@gmail.com> | 2016-12-23 04:09:18 +0000 |
commit | b2a5eb87f83bed3342e90c1ba50194953e73242a (patch) | |
tree | 650265d038b80180ab76abd71a2285cc7b675b78 /clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp | |
parent | 9f926f70c1460b7c181e02c79075aa8ebd2cbcfa (diff) | |
download | bcm5719-llvm-b2a5eb87f83bed3342e90c1ba50194953e73242a.tar.gz bcm5719-llvm-b2a5eb87f83bed3342e90c1ba50194953e73242a.zip |
Revert changes made by r290413 until regression is fixed.
llvm-svn: 290415
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 3e6343813ec..f1238f6d357 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -665,13 +665,23 @@ void ExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred, if (RHSVal.isUndef()) { X = RHSVal; } else { - // We evaluate "RHSVal != 0" expression which result in 0 if the value is - // known to be false, 1 if the value is known to be true and a new symbol - // when the assumption is unknown. - nonloc::ConcreteInt Zero(getBasicVals().getValue(0, B->getType())); - X = evalBinOp(N->getState(), BO_NE, - svalBuilder.evalCast(RHSVal, B->getType(), RHS->getType()), - Zero, B->getType()); + DefinedOrUnknownSVal DefinedRHS = RHSVal.castAs<DefinedOrUnknownSVal>(); + ProgramStateRef StTrue, StFalse; + std::tie(StTrue, StFalse) = N->getState()->assume(DefinedRHS); + if (StTrue) { + if (StFalse) { + // We can't constrain the value to 0 or 1. + // The best we can do is a cast. + X = getSValBuilder().evalCast(RHSVal, B->getType(), RHS->getType()); + } else { + // The value is known to be true. + X = getSValBuilder().makeIntVal(1, B->getType()); + } + } else { + // The value is known to be false. + assert(StFalse && "Infeasible path!"); + X = getSValBuilder().makeIntVal(0, B->getType()); + } } } Bldr.generateNode(B, Pred, state->BindExpr(B, Pred->getLocationContext(), X)); |