diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-06-04 08:31:20 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-06-04 08:31:20 +0000 |
commit | f870aa1e0723e9203df495020ee2bf2bc47a6246 (patch) | |
tree | d15a78c7c6f4106ce141fc92c8dce5dc8217bd84 /lib/Core | |
parent | 44e3d58b59099f5fd0e6f88893ce431171b3fef6 (diff) | |
download | klee-f870aa1e0723e9203df495020ee2bf2bc47a6246.tar.gz |
Finish removing uses of Expr::isConstant.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@72859 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Core')
-rw-r--r-- | lib/Core/ImpliedValue.cpp | 36 | ||||
-rw-r--r-- | lib/Core/Memory.cpp | 18 | ||||
-rw-r--r-- | lib/Core/SpecialFunctionHandler.cpp | 5 | ||||
-rw-r--r-- | lib/Core/TimingSolver.cpp | 10 |
4 files changed, 35 insertions, 34 deletions
diff --git a/lib/Core/ImpliedValue.cpp b/lib/Core/ImpliedValue.cpp index dfb91344..b8d44eea 100644 --- a/lib/Core/ImpliedValue.cpp +++ b/lib/Core/ImpliedValue.cpp @@ -53,13 +53,13 @@ static void _getImpliedValue(ref<Expr> e, // not much to do, could improve with range analysis SelectExpr *se = cast<SelectExpr>(e); - if (se->trueExpr->isConstant()) { - if (se->falseExpr->isConstant()) { - if (se->trueExpr->getConstantValue() != se->falseExpr->getConstantValue()) { - if (value == se->trueExpr->getConstantValue()) { + if (ConstantExpr *TrueCE = dyn_cast<ConstantExpr>(se->trueExpr)) { + if (ConstantExpr *FalseCE = dyn_cast<ConstantExpr>(se->falseExpr)) { + if (TrueCE->getConstantValue() != FalseCE->getConstantValue()) { + if (value == TrueCE->getConstantValue()) { _getImpliedValue(se->cond, 1, results); } else { - assert(value == se->falseExpr->getConstantValue() && + assert(value == FalseCE->getConstantValue() && "err in implied value calculation"); _getImpliedValue(se->cond, 0, results); } @@ -97,20 +97,20 @@ static void _getImpliedValue(ref<Expr> e, case Expr::Add: { // constants on left BinaryExpr *be = cast<BinaryExpr>(e); - if (be->left->isConstant()) { + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(be->left)) { uint64_t nvalue = ints::sub(value, - be->left->getConstantValue(), - be->left->getWidth()); + CE->getConstantValue(), + CE->getWidth()); _getImpliedValue(be->right, nvalue, results); } break; } case Expr::Sub: { // constants on left BinaryExpr *be = cast<BinaryExpr>(e); - if (be->left->isConstant()) { - uint64_t nvalue = ints::sub(be->left->getConstantValue(), + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(be->left)) { + uint64_t nvalue = ints::sub(CE->getConstantValue(), value, - be->left->getWidth()); + CE->getWidth()); _getImpliedValue(be->right, nvalue, results); } break; @@ -156,8 +156,8 @@ static void _getImpliedValue(ref<Expr> e, } case Expr::Xor: { // constants on left BinaryExpr *be = cast<BinaryExpr>(e); - if (be->left->isConstant()) { - _getImpliedValue(be->right, value ^ be->left->getConstantValue(), results); + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(be->left)) { + _getImpliedValue(be->right, value ^ CE->getConstantValue(), results); } break; } @@ -169,8 +169,8 @@ static void _getImpliedValue(ref<Expr> e, case Expr::Eq: { EqExpr *ee = cast<EqExpr>(e); if (value) { - if (ee->left->isConstant()) - _getImpliedValue(ee->right, ee->left->getConstantValue(), results); + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(ee->left)) + _getImpliedValue(ee->right, CE->getConstantValue(), results); } else { // look for limited value range, woohoo // @@ -180,9 +180,9 @@ static void _getImpliedValue(ref<Expr> e, // expression where the true and false branches are single // valued and distinct. - if (ee->left->isConstant()) { - if (ee->left->getWidth() == Expr::Bool) { - _getImpliedValue(ee->right, !ee->left->getConstantValue(), results); + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(ee->left)) { + if (CE->getWidth() == Expr::Bool) { + _getImpliedValue(ee->right, !CE->getConstantValue(), results); } } } diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp index b4c433b1..5a3af34c 100644 --- a/lib/Core/Memory.cpp +++ b/lib/Core/Memory.cpp @@ -301,7 +301,7 @@ ref<Expr> ObjectState::read8(unsigned offset) const { } ref<Expr> ObjectState::read8(ref<Expr> offset) const { - assert(!offset->isConstant() && "constant offset passed to symbolic read8"); + assert(!isa<ConstantExpr>(offset) && "constant offset passed to symbolic read8"); unsigned base, size; fastRangeCheckOffset(offset, &base, &size); flushRangeForRead(base, size); @@ -328,8 +328,8 @@ void ObjectState::write8(unsigned offset, uint8_t value) { void ObjectState::write8(unsigned offset, ref<Expr> value) { // can happen when ExtractExpr special cases - if (value->isConstant()) { - write8(offset, (uint8_t) value->getConstantValue()); + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(value)) { + write8(offset, (uint8_t) CE->getConstantValue()); } else { setKnownSymbolic(offset, value.get()); @@ -358,8 +358,8 @@ void ObjectState::write8(ref<Expr> offset, ref<Expr> value) { /***/ ref<Expr> ObjectState::read(ref<Expr> offset, Expr::Width width) const { - if (offset->isConstant()) { - return read((unsigned) offset->getConstantValue(), width); + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(offset)) { + return read((unsigned) CE->getConstantValue(), width); } else { switch (width) { case Expr::Bool: return read1(offset); @@ -547,8 +547,8 @@ ref<Expr> ObjectState::read64(ref<Expr> offset) const { void ObjectState::write(ref<Expr> offset, ref<Expr> value) { Expr::Width w = value->getWidth(); - if (offset->isConstant()) { - write(offset->getConstantValue(), value); + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(offset)) { + write(CE->getConstantValue(), value); } else { switch(w) { case Expr::Bool: write1(offset, value); break; @@ -563,8 +563,8 @@ void ObjectState::write(ref<Expr> offset, ref<Expr> value) { void ObjectState::write(unsigned offset, ref<Expr> value) { Expr::Width w = value->getWidth(); - if (value->isConstant()) { - uint64_t val = value->getConstantValue(); + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(value)) { + uint64_t val = CE->getConstantValue(); switch(w) { case Expr::Bool: case Expr::Int8: write8(offset, val); break; diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp index e1182cf0..0ec9a5ac 100644 --- a/lib/Core/SpecialFunctionHandler.cpp +++ b/lib/Core/SpecialFunctionHandler.cpp @@ -376,7 +376,8 @@ void SpecialFunctionHandler::handleIsSymbolic(ExecutionState &state, assert(arguments.size()==1 && "invalid number of arguments to klee_is_symbolic"); executor.bindLocal(target, state, - ConstantExpr::create(!arguments[0]->isConstant(), Expr::Int32)); + ConstantExpr::create(!isa<ConstantExpr>(arguments[0]), + Expr::Int32)); } void SpecialFunctionHandler::handlePreferCex(ExecutionState &state, @@ -415,7 +416,7 @@ void SpecialFunctionHandler::handleUnderConstrained(ExecutionState &state, // XXX should type check args assert(arguments.size()==1 && "invalid number of arguments to klee_under_constrained()."); - assert(arguments[0]->isConstant() && + assert(isa<ConstantExpr>(arguments[0]) && "symbolic argument given to klee_under_constrained!"); unsigned v = arguments[0]->getConstantValue(); diff --git a/lib/Core/TimingSolver.cpp b/lib/Core/TimingSolver.cpp index 9efb77b8..b26551cc 100644 --- a/lib/Core/TimingSolver.cpp +++ b/lib/Core/TimingSolver.cpp @@ -25,8 +25,8 @@ using namespace llvm; bool TimingSolver::evaluate(const ExecutionState& state, ref<Expr> expr, Solver::Validity &result) { // Fast path, to avoid timer and OS overhead. - if (expr->isConstant()) { - result = expr->getConstantValue() ? Solver::True : Solver::False; + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(expr)) { + result = CE->getConstantValue() ? Solver::True : Solver::False; return true; } @@ -49,8 +49,8 @@ bool TimingSolver::evaluate(const ExecutionState& state, ref<Expr> expr, bool TimingSolver::mustBeTrue(const ExecutionState& state, ref<Expr> expr, bool &result) { // Fast path, to avoid timer and OS overhead. - if (expr->isConstant()) { - result = expr->getConstantValue() ? true : false; + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(expr)) { + result = CE->getConstantValue() ? true : false; return true; } @@ -96,7 +96,7 @@ bool TimingSolver::mayBeFalse(const ExecutionState& state, ref<Expr> expr, bool TimingSolver::getValue(const ExecutionState& state, ref<Expr> expr, ref<Expr> &result) { // Fast path, to avoid timer and OS overhead. - if (expr->isConstant()) { + if (isa<ConstantExpr>(expr)) { result = expr; return true; } |