summaryrefslogtreecommitdiffstats
path: root/clang/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
commit70bf6d61028ee5c12b910f191a3a6113218a4e77 (patch)
treeb980db97f7279ad58a1981392f51caba5b20ad47 /clang/lib/Analysis/SimpleSValuator.cpp
parent31fcde13ac7d7e44a9287632e9c8826cefa76a96 (diff)
downloadbcm5719-llvm-70bf6d61028ee5c12b910f191a3a6113218a4e77.tar.gz
bcm5719-llvm-70bf6d61028ee5c12b910f191a3a6113218a4e77.zip
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. llvm-svn: 84269
Diffstat (limited to 'clang/lib/Analysis/SimpleSValuator.cpp')
-rw-r--r--clang/lib/Analysis/SimpleSValuator.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Analysis/SimpleSValuator.cpp b/clang/lib/Analysis/SimpleSValuator.cpp
index 636ce15c332..5af4c062e08 100644
--- a/clang/lib/Analysis/SimpleSValuator.cpp
+++ b/clang/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(),
OpenPOWER on IntegriCloud