diff options
author | Anna Zaks <ganna@apple.com> | 2011-12-10 23:36:51 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-12-10 23:36:51 +0000 |
commit | 24d052cdb75d3c1afa5bef32eacaa224e9d0b85d (patch) | |
tree | e27747c97305835135103193ef28ca989bbe933a /lib/StaticAnalyzer/Core/SValBuilder.cpp | |
parent | 6fcd932dfd6835f70cc00d6f7c6789793f6d7b66 (diff) |
[analyzer] Introduce IntSymExpr, where the integer is on the lhs.
Fix a bug in SimpleSValBuilder, where we should swap lhs and rhs when calling generateUnknownVal(), - the function which creates symbolic expressions when data is tainted. The issue is not visible when we only create the expressions for taint since all expressions are commutative from taint perspective.
Refactor SymExpr::symbol_iterator::expand() to use a switch instead of a chain of ifs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/SValBuilder.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/SValBuilder.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/SValBuilder.cpp b/lib/StaticAnalyzer/Core/SValBuilder.cpp index f381f1a5ad..81f84f90ae 100644 --- a/lib/StaticAnalyzer/Core/SValBuilder.cpp +++ b/lib/StaticAnalyzer/Core/SValBuilder.cpp @@ -47,6 +47,14 @@ NonLoc SValBuilder::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, return nonloc::SymbolVal(SymMgr.getSymIntExpr(lhs, op, rhs, type)); } +NonLoc SValBuilder::makeNonLoc(const llvm::APSInt& lhs, + BinaryOperator::Opcode op, const SymExpr *rhs, + QualType type) { + assert(rhs); + assert(!Loc::isLocType(type)); + return nonloc::SymbolVal(SymMgr.getIntSymExpr(lhs, op, rhs, type)); +} + NonLoc SValBuilder::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType type) { assert(lhs && rhs); @@ -173,6 +181,11 @@ SVal SValBuilder::generateUnknownVal(const ProgramState *State, return makeNonLoc(symLHS, Op, rInt->getValue(), ResultTy); } + if (const nonloc::ConcreteInt *lInt = dyn_cast<nonloc::ConcreteInt>(&LHS)) { + symRHS = RHS.getAsSymExpr(); + return makeNonLoc(symRHS, Op, lInt->getValue(), ResultTy); + } + symLHS = LHS.getAsSymExpr(); symRHS = RHS.getAsSymExpr(); return makeNonLoc(symLHS, Op, symRHS, ResultTy); |