diff options
author | Anna Zaks <ganna@apple.com> | 2011-12-05 18:58:30 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-12-05 18:58:30 +0000 |
commit | 5344baa704f42b22d9df25c24ffbbf6b4716603b (patch) | |
tree | bec0b29a373929c4d0555696500dc284bcb15cf3 /lib/StaticAnalyzer/Core/SVals.cpp | |
parent | 76462f00854171d2aa3ebc34f9aac1c60021b0ea (diff) |
[analyzer] Unify SymbolVal and SymExprVal under a single SymbolVal
class.
We are going into the direction of handling SymbolData and other SymExpr
uniformly, so it makes less sense to keep two different SVal classes.
For example, the checkers would have to take an extra step to reason
about each type separately.
The classes have the same members, we were just using the SVal kind
field for easy differentiation in 3 switch statements. The switch
statements look more ugly now, but we can make the code more readable in
other ways, for example, moving some code into separate functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145833 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/SVals.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/SVals.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/StaticAnalyzer/Core/SVals.cpp b/lib/StaticAnalyzer/Core/SVals.cpp index 6b71f184aa..4bdea1d9e1 100644 --- a/lib/StaticAnalyzer/Core/SVals.cpp +++ b/lib/StaticAnalyzer/Core/SVals.cpp @@ -98,8 +98,8 @@ SymbolRef SVal::getAsSymbol() const { if (const nonloc::SymbolVal *X = dyn_cast<nonloc::SymbolVal>(this)) return X->getSymbol(); - if (const nonloc::SymExprVal *X = dyn_cast<nonloc::SymExprVal>(this)) - if (SymbolRef Y = X->getSymbolicExpression()) + if (const nonloc::SymbolVal *X = dyn_cast<nonloc::SymbolVal>(this)) + if (SymbolRef Y = X->getSymbol()) return Y; return getAsLocSymbol(); @@ -108,8 +108,8 @@ SymbolRef SVal::getAsSymbol() const { /// getAsSymbolicExpression - If this Sval wraps a symbolic expression then /// return that expression. Otherwise return NULL. const SymExpr *SVal::getAsSymbolicExpression() const { - if (const nonloc::SymExprVal *X = dyn_cast<nonloc::SymExprVal>(this)) - return X->getSymbolicExpression(); + if (const nonloc::SymbolVal *X = dyn_cast<nonloc::SymbolVal>(this)) + return X->getSymbol(); return getAsSymbol(); } @@ -305,13 +305,8 @@ void NonLoc::dumpToStream(raw_ostream &os) const { << C.getValue().getBitWidth() << 'b'; break; } - case nonloc::SymbolValKind: - os << '$' << cast<nonloc::SymbolVal>(this)->getSymbol(); - break; - case nonloc::SymExprValKind: { - const nonloc::SymExprVal& C = *cast<nonloc::SymExprVal>(this); - const SymExpr *SE = C.getSymbolicExpression(); - os << SE; + case nonloc::SymbolValKind: { + os << cast<nonloc::SymbolVal>(this)->getSymbol(); break; } case nonloc::LocAsIntegerKind: { |