aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/SimpleSValuator.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-10-16 20:46:24 +0000
committerTed Kremenek <kremenek@apple.com>2009-10-16 20:46:24 +0000
commitb5deae519b1f86d514427c412d9f8873d93c909c (patch)
treea0b03dd6a706fa48b65932d65c9da15ab4cfad68 /lib/Analysis/SimpleSValuator.cpp
parent40a5ef90ac8d3f29bc8fe4ff80e00eaf3ef5b79f (diff)
Fix static analyzer crash due to recently add symbolic-value constant folding. The issue was falsely
converting the constant value of the LHS of a '<<'/'>>' operation to the same APSInt value of the RHS. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84269 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/SimpleSValuator.cpp')
-rw-r--r--lib/Analysis/SimpleSValuator.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Analysis/SimpleSValuator.cpp b/lib/Analysis/SimpleSValuator.cpp
index 636ce15c33..5af4c062e0 100644
--- a/lib/Analysis/SimpleSValuator.cpp
+++ b/lib/Analysis/SimpleSValuator.cpp
@@ -349,7 +349,15 @@ SVal SimpleSValuator::EvalBinOpNN(const GRState *state,
// Does the symbol simplify to a constant?
if (Sym->getType(ValMgr.getContext())->isIntegerType())
if (const llvm::APSInt *Constant = state->getSymVal(Sym)) {
- // What should we convert it to?
+ // For shifts, there is no need to perform any conversions
+ // of the constant.
+ if (BinaryOperator::isShiftOp(op)) {
+ lhs = nonloc::ConcreteInt(*Constant);
+ continue;
+ }
+
+ // Other cases: do an implicit conversion. This shouldn't be
+ // necessary once we support truncation/extension of symbolic values.
if (nonloc::ConcreteInt *rhs_I = dyn_cast<nonloc::ConcreteInt>(&rhs)){
BasicValueFactory &BVF = ValMgr.getBasicValueFactory();
lhs = nonloc::ConcreteInt(BVF.Convert(rhs_I->getValue(),