summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/SimpleConstraintManager.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-03-25 05:58:37 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-03-25 05:58:37 +0000
commit24e7eade19c023132fe73eb85dedcd5b70ecf61d (patch)
tree4342dbec81c93b60ed1436ab41b87783666394cb /clang/lib/Analysis/SimpleConstraintManager.cpp
parentb2304ee0d191b7bb0b0c759a59ebeaa49c8b74d7 (diff)
downloadbcm5719-llvm-24e7eade19c023132fe73eb85dedcd5b70ecf61d.tar.gz
bcm5719-llvm-24e7eade19c023132fe73eb85dedcd5b70ecf61d.zip
This patch adds two more SymbolData subclasses: SymIntExpr and SymSymExpr, for
representing symbolic expressions like 'x'+3 and 'x'+'y'. The design is subjected to change later when we fix the class hierarchy of symbolic expressions. llvm-svn: 67678
Diffstat (limited to 'clang/lib/Analysis/SimpleConstraintManager.cpp')
-rw-r--r--clang/lib/Analysis/SimpleConstraintManager.cpp33
1 files changed, 11 insertions, 22 deletions
diff --git a/clang/lib/Analysis/SimpleConstraintManager.cpp b/clang/lib/Analysis/SimpleConstraintManager.cpp
index e6f940e57cc..50552c11440 100644
--- a/clang/lib/Analysis/SimpleConstraintManager.cpp
+++ b/clang/lib/Analysis/SimpleConstraintManager.cpp
@@ -21,28 +21,11 @@ namespace clang {
SimpleConstraintManager::~SimpleConstraintManager() {}
bool SimpleConstraintManager::canReasonAbout(SVal X) const {
- if (nonloc::SymIntConstraintVal *Y = dyn_cast<nonloc::SymIntConstraintVal>(&X)) {
- const SymIntConstraint& C = Y->getConstraint();
- switch (C.getOpcode()) {
- // We don't reason yet about bitwise-constraints on symbolic values.
- case BinaryOperator::And:
- case BinaryOperator::Or:
- case BinaryOperator::Xor:
- return false;
- // We don't reason yet about arithmetic constraints on symbolic values.
- case BinaryOperator::Mul:
- case BinaryOperator::Div:
- case BinaryOperator::Rem:
- case BinaryOperator::Add:
- case BinaryOperator::Sub:
- case BinaryOperator::Shl:
- case BinaryOperator::Shr:
- return false;
-
- // All other cases.
- default:
- return true;
- }
+ if (nonloc::SymbolVal* SymVal = dyn_cast<nonloc::SymbolVal>(&X)) {
+ const SymbolData& data
+ = getSymbolManager().getSymbolData(SymVal->getSymbol());
+ return !(data.getKind() == SymbolData::SymIntKind ||
+ data.getKind() == SymbolData::SymSymKind );
}
return true;
@@ -143,6 +126,12 @@ SimpleConstraintManager::Assume(const GRState* St, NonLoc Cond, bool Assumption,
const GRState*
SimpleConstraintManager::AssumeAux(const GRState* St,NonLoc Cond,
bool Assumption, bool& isFeasible) {
+ // We cannot reason about SymIntExpr and SymSymExpr.
+ if (!canReasonAbout(Cond)) {
+ isFeasible = true;
+ return St;
+ }
+
BasicValueFactory& BasicVals = StateMgr.getBasicVals();
SymbolManager& SymMgr = StateMgr.getSymbolManager();
OpenPOWER on IntegriCloud