diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-09-25 00:18:15 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-09-25 00:18:15 +0000 |
commit | f694f421e1c906ef24d6d35c026346171c489609 (patch) | |
tree | 9f426a0747b577e93276e2e0b0b52b3ae18211e5 /clang/lib/Analysis/SimpleConstraintManager.cpp | |
parent | 6f95c705ea241b19c5562dca4fde0651d4759941 (diff) | |
download | bcm5719-llvm-f694f421e1c906ef24d6d35c026346171c489609.tar.gz bcm5719-llvm-f694f421e1c906ef24d6d35c026346171c489609.zip |
Fix <rdar://problem/7249327> by allowing silent conversions between signed and unsigned integer values for symbolic values. This is an intermediate solution (i.e. hack) until we support extension/truncation of symbolic integers.
llvm-svn: 82737
Diffstat (limited to 'clang/lib/Analysis/SimpleConstraintManager.cpp')
-rw-r--r-- | clang/lib/Analysis/SimpleConstraintManager.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Analysis/SimpleConstraintManager.cpp b/clang/lib/Analysis/SimpleConstraintManager.cpp index e4ad85aa836..015db76080d 100644 --- a/clang/lib/Analysis/SimpleConstraintManager.cpp +++ b/clang/lib/Analysis/SimpleConstraintManager.cpp @@ -162,8 +162,19 @@ const GRState *SimpleConstraintManager::AssumeAux(const GRState *state, case nonloc::SymExprValKind: { nonloc::SymExprVal V = cast<nonloc::SymExprVal>(Cond); - if (const SymIntExpr *SE = dyn_cast<SymIntExpr>(V.getSymbolicExpression())) - return AssumeSymInt(state, Assumption, SE); + if (const SymIntExpr *SE = dyn_cast<SymIntExpr>(V.getSymbolicExpression())){ + // FIXME: This is a hack. It silently converts the RHS integer to be + // of the same type as on the left side. This should be removed once + // we support truncation/extension of symbolic values. + GRStateManager &StateMgr = state->getStateManager(); + ASTContext &Ctx = StateMgr.getContext(); + QualType LHSType = SE->getLHS()->getType(Ctx); + BasicValueFactory &BasicVals = StateMgr.getBasicVals(); + const llvm::APSInt &RHS = BasicVals.Convert(LHSType, SE->getRHS()); + SymIntExpr SENew(SE->getLHS(), SE->getOpcode(), RHS, SE->getType(Ctx)); + + return AssumeSymInt(state, Assumption, &SENew); + } // For all other symbolic expressions, over-approximate and consider // the constraint feasible. |