about summary refs log tree commit diff homepage
path: root/lib/Core
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-04 00:49:34 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-04 00:49:34 +0000
commitb9c0914f3d27e04e3335760b7fd13c5e9953103d (patch)
treecf3971704bc3c7bede7592b046f8f28b4751a423 /lib/Core
parent32461e170b16d2f6cbcd04830bf68ce2a6372db5 (diff)
downloadklee-b9c0914f3d27e04e3335760b7fd13c5e9953103d.tar.gz
Move isConstant from ref<> to Expr::
 - Ref.h is now freestanding.


git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@72824 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/AddressSpace.cpp4
-rw-r--r--lib/Core/Executor.cpp34
-rw-r--r--lib/Core/ImpliedValue.cpp18
-rw-r--r--lib/Core/Memory.cpp12
-rw-r--r--lib/Core/SeedInfo.cpp2
-rw-r--r--lib/Core/SpecialFunctionHandler.cpp25
-rw-r--r--lib/Core/TimingSolver.cpp6
7 files changed, 51 insertions, 50 deletions
diff --git a/lib/Core/AddressSpace.cpp b/lib/Core/AddressSpace.cpp
index 9a9a0235..92d75aa8 100644
--- a/lib/Core/AddressSpace.cpp
+++ b/lib/Core/AddressSpace.cpp
@@ -72,7 +72,7 @@ bool AddressSpace::resolveOne(ExecutionState &state,
                               ref<Expr> address,
                               ObjectPair &result,
                               bool &success) {
-  if (address.isConstant()) {
+  if (address->isConstant()) {
     success = resolveOne(address->getConstantValue(), result);
     return true;
   } else {
@@ -163,7 +163,7 @@ bool AddressSpace::resolve(ExecutionState &state,
                            ResolutionList &rl, 
                            unsigned maxResolutions,
                            double timeout) {
-  if (p.isConstant()) {
+  if (p->isConstant()) {
     ObjectPair res;
     if (resolveOne(p->getConstantValue(), res))
       rl.push_back(res);
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index bb4bcb53..a1687f58 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -663,7 +663,7 @@ Executor::fork(ExecutionState &current, ref<Expr> condition, bool isInternal) {
   bool isSeeding = it != seedMap.end();
 
   if (!isSeeding &&
-      !condition.isConstant() && 
+      !condition->isConstant() && 
       (MaxStaticForkPct!=1. || MaxStaticSolvePct != 1. ||
        MaxStaticCPForkPct!=1. || MaxStaticCPSolvePct != 1.) &&
       statsTracker->elapsed() > 60.) {
@@ -753,7 +753,7 @@ Executor::fork(ExecutionState &current, ref<Expr> condition, bool isInternal) {
       bool success = 
         solver->getValue(current, siit->assignment.evaluate(condition), res);
       assert(success && "FIXME: Unhandled solver failure");
-      if (res.isConstant()) {
+      if (res->isConstant()) {
         if (res->getConstantValue()) {
           trueSeed = true;
         } else {
@@ -874,7 +874,7 @@ Executor::fork(ExecutionState &current, ref<Expr> condition, bool isInternal) {
 }
 
 void Executor::addConstraint(ExecutionState &state, ref<Expr> condition) {
-  if (condition.isConstant()) {
+  if (condition->isConstant()) {
     assert(condition->getConstantValue() &&
            "attempt to add invalid constraint");
     return;
@@ -998,7 +998,7 @@ ref<Expr> Executor::toUnique(const ExecutionState &state,
                              ref<Expr> &e) {
   ref<Expr> result = e;
 
-  if (!e.isConstant()) {
+  if (!e->isConstant()) {
     ref<Expr> value(0);
     bool isTrue = false;
 
@@ -1020,7 +1020,7 @@ ref<Expr> Executor::toConstant(ExecutionState &state,
                                ref<Expr> e,
                                const char *reason) {
   e = state.constraints.simplifyExpr(e);
-  if (!e.isConstant()) {
+  if (!e->isConstant()) {
     ref<Expr> value;
     bool success = solver->getValue(state, e, value);
     assert(success && "FIXME: Unhandled solver failure");
@@ -1049,7 +1049,7 @@ void Executor::executeGetValue(ExecutionState &state,
   e = state.constraints.simplifyExpr(e);
   std::map< ExecutionState*, std::vector<SeedInfo> >::iterator it = 
     seedMap.find(&state);
-  if (it==seedMap.end() || e.isConstant()) {
+  if (it==seedMap.end() || e->isConstant()) {
     ref<Expr> value;
     bool success = solver->getValue(state, e, value);
     assert(success && "FIXME: Unhandled solver failure");
@@ -1393,7 +1393,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     BasicBlock *bb = si->getParent();
 
     cond = toUnique(state, cond);
-    if (cond.isConstant()) {
+    if (cond->isConstant()) {
       // Somewhat gross to create these all the time, but fine till we
       // switch to an internal rep.
       ConstantInt *ci = ConstantInt::get(si->getCondition()->getType(),
@@ -2180,7 +2180,7 @@ void Executor::bindInstructionConstants(KInstruction *KI) {
     }
     index++;
   }
-  assert(constantOffset.isConstant());
+  assert(constantOffset->isConstant());
   kgepi->offset = constantOffset->getConstantValue();
 }
 
@@ -2346,7 +2346,7 @@ std::string Executor::getAddressInfo(ExecutionState &state,
   std::ostringstream info;
   info << "\taddress: " << address << "\n";
   uint64_t example;
-  if (address.isConstant()) {
+  if (address->isConstant()) {
     example = address->getConstantValue();
   } else {
     ref<Expr> value;
@@ -2466,7 +2466,7 @@ void Executor::terminateStateOnError(ExecutionState &state,
         msg << ai->getName();
         // XXX should go through function
         ref<Expr> value = sf.locals[sf.kf->getArgRegister(index++)].value; 
-        if (value.isConstant())
+        if (value->isConstant())
           msg << "=" << value;
       }
       msg << ")";
@@ -2521,7 +2521,7 @@ void Executor::callExternalFunction(ExecutionState &state,
       static_cast<ConstantExpr*>(ce.get())->toMemory((void*) &args[i]);
     } else {
       ref<Expr> arg = toUnique(state, *ai);
-      if (arg.isConstant()) {
+      if (arg->isConstant()) {
         // XXX kick toMemory functions from here
         static_cast<ConstantExpr*>(arg.get())->toMemory((void*) &args[i]);
       } else {
@@ -2578,7 +2578,7 @@ ref<Expr> Executor::replaceReadWithSymbolic(ExecutionState &state,
     return e;
 
   // right now, we don't replace symbolics (is there any reason too?)
-  if (!e.isConstant())
+  if (!e->isConstant())
     return e;
 
   if (n != 1 && random() %  n)
@@ -2620,7 +2620,7 @@ void Executor::executeAlloc(ExecutionState &state,
                             bool zeroMemory,
                             const ObjectState *reallocFrom) {
   size = toUnique(state, size);
-  if (size.isConstant()) {
+  if (size->isConstant()) {
     MemoryObject *mo = 
       memory->allocate(size->getConstantValue(), isLocal, false, 
                        state.prevPC->inst);
@@ -2793,9 +2793,9 @@ void Executor::executeMemoryOperation(ExecutionState &state,
   unsigned bytes = Expr::getMinBytesForWidth(type);
 
   if (SimplifySymIndices) {
-    if (!address.isConstant())
+    if (!address->isConstant())
       address = state.constraints.simplifyExpr(address);
-    if (isWrite && !value.isConstant())
+    if (isWrite && !value->isConstant())
       value = state.constraints.simplifyExpr(value);
   }
 
@@ -3175,7 +3175,7 @@ void Executor::getCoveredLines(const ExecutionState &state,
 void Executor::doImpliedValueConcretization(ExecutionState &state,
                                             ref<Expr> e,
                                             ref<Expr> value) {
-  assert(value.isConstant() && "non-constant passed in place of constant");
+  assert(value->isConstant() && "non-constant passed in place of constant");
   
   if (DebugCheckForImpliedValues)
     ImpliedValue::checkForImpliedValues(solver->solver, e, value);
@@ -3186,7 +3186,7 @@ void Executor::doImpliedValueConcretization(ExecutionState &state,
        it != ie; ++it) {
     ReadExpr *re = it->first.get();
     
-    if (re->index.isConstant()) {
+    if (re->index->isConstant()) {
       // FIXME: This is the sole remaining usage of the Array object
       // variable. Kill me.
       const MemoryObject *mo = re->updates.root->object;
diff --git a/lib/Core/ImpliedValue.cpp b/lib/Core/ImpliedValue.cpp
index c73ae4f1..d1037839 100644
--- a/lib/Core/ImpliedValue.cpp
+++ b/lib/Core/ImpliedValue.cpp
@@ -53,8 +53,8 @@ static void _getImpliedValue(ref<Expr> e,
     // not much to do, could improve with range analysis
     SelectExpr *se = static_ref_cast<SelectExpr>(e);
     
-    if (se->trueExpr.isConstant()) {
-      if (se->falseExpr.isConstant()) {
+    if (se->trueExpr->isConstant()) {
+      if (se->falseExpr->isConstant()) {
         if (se->trueExpr->getConstantValue() != se->falseExpr->getConstantValue()) {
           if (value == se->trueExpr->getConstantValue()) {
             _getImpliedValue(se->cond, 1, results);
@@ -97,7 +97,7 @@ static void _getImpliedValue(ref<Expr> e,
 
   case Expr::Add: { // constants on left
     BinaryExpr *be = static_ref_cast<BinaryExpr>(e);
-    if (be->left.isConstant()) {
+    if (be->left->isConstant()) {
       uint64_t nvalue = ints::sub(value,
                                   be->left->getConstantValue(),
                                   be->left->getWidth());
@@ -107,7 +107,7 @@ static void _getImpliedValue(ref<Expr> e,
   }
   case Expr::Sub: { // constants on left
     BinaryExpr *be = static_ref_cast<BinaryExpr>(e);
-    if (be->left.isConstant()) {
+    if (be->left->isConstant()) {
       uint64_t nvalue = ints::sub(be->left->getConstantValue(),
                                   value,
                                   be->left->getWidth());
@@ -156,7 +156,7 @@ static void _getImpliedValue(ref<Expr> e,
   }
   case Expr::Xor: { // constants on left
     BinaryExpr *be = static_ref_cast<BinaryExpr>(e);
-    if (be->left.isConstant()) {
+    if (be->left->isConstant()) {
       _getImpliedValue(be->right, value ^ be->left->getConstantValue(), results);
     }
     break;
@@ -169,7 +169,7 @@ static void _getImpliedValue(ref<Expr> e,
   case Expr::Eq: {
     EqExpr *ee = static_ref_cast<EqExpr>(e);
     if (value) {
-      if (ee->left.isConstant())
+      if (ee->left->isConstant())
         _getImpliedValue(ee->right, ee->left->getConstantValue(), results);
     } else {
       // look for limited value range, woohoo
@@ -180,7 +180,7 @@ 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->isConstant()) {
         if (ee->left->getWidth() == Expr::Bool) {
           _getImpliedValue(ee->right, !ee->left->getConstantValue(), results);
         }
@@ -197,13 +197,13 @@ static void _getImpliedValue(ref<Expr> e,
 void ImpliedValue::getImpliedValues(ref<Expr> e, 
                                     ref<Expr> value, 
                                     ImpliedValueList &results) {
-  assert(value.isConstant() && "non-constant in place of constant");
+  assert(value->isConstant() && "non-constant in place of constant");
   _getImpliedValue(e, value->getConstantValue(), results);
 }
 
 void ImpliedValue::checkForImpliedValues(Solver *S, ref<Expr> e, 
                                          ref<Expr> value) {
-  assert(value.isConstant() && "non-constant in place of constant");
+  assert(value->isConstant() && "non-constant in place of constant");
 
   std::vector<ref<ReadExpr> > reads;
   std::map<ref<ReadExpr>, ref<Expr> > found;
diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp
index e03254a5..de48651b 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(!offset->isConstant() && "constant offset passed to symbolic read8");
   unsigned base, size;
   fastRangeCheckOffset(offset, &base, &size);
   flushRangeForRead(base, size);
@@ -328,7 +328,7 @@ 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()) {
+  if (value->isConstant()) {
     write8(offset, (uint8_t) value->getConstantValue());
   } else {
     setKnownSymbolic(offset, value.get());
@@ -339,7 +339,7 @@ void ObjectState::write8(unsigned offset, ref<Expr> value) {
 }
 
 void ObjectState::write8(ref<Expr> offset, ref<Expr> value) {
-  assert(!offset.isConstant() && "constant offset passed to symbolic write8");
+  assert(!offset->isConstant() && "constant offset passed to symbolic write8");
   unsigned base, size;
   fastRangeCheckOffset(offset, &base, &size);
   flushRangeForWrite(base, size);
@@ -358,7 +358,7 @@ void ObjectState::write8(ref<Expr> offset, ref<Expr> value) {
 /***/
 
 ref<Expr> ObjectState::read(ref<Expr> offset, Expr::Width width) const {
-  if (offset.isConstant()) {
+  if (offset->isConstant()) {
     return read((unsigned) offset->getConstantValue(), width);
   } else { 
     switch (width) {
@@ -547,7 +547,7 @@ 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()) {
+  if (offset->isConstant()) {
     write(offset->getConstantValue(), value);
   } else {
     switch(w) {
@@ -563,7 +563,7 @@ 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()) {
+  if (value->isConstant()) {
     uint64_t val = value->getConstantValue();
     switch(w) {
     case  Expr::Bool:
diff --git a/lib/Core/SeedInfo.cpp b/lib/Core/SeedInfo.cpp
index bb6496ac..30377ee4 100644
--- a/lib/Core/SeedInfo.cpp
+++ b/lib/Core/SeedInfo.cpp
@@ -77,7 +77,7 @@ void SeedInfo::patchSeed(const ExecutionState &state,
   for (std::vector< ref<ReadExpr> >::iterator it = reads.begin(), 
          ie = reads.end(); it != ie; ++it) {
     ReadExpr *re = it->get();
-    if (re->index.isConstant()) {
+    if (re->index->isConstant()) {
       unsigned index = (unsigned) re->index->getConstantValue();
       directReads.insert(std::make_pair(re->updates.root, index));
     }
diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp
index 594a6518..b2e5d277 100644
--- a/lib/Core/SpecialFunctionHandler.cpp
+++ b/lib/Core/SpecialFunctionHandler.cpp
@@ -176,7 +176,7 @@ std::string SpecialFunctionHandler::readStringAtAddress(ExecutionState &state,
                                                         ref<Expr> address) {
   ObjectPair op;
   address = executor.toUnique(state, address);
-  assert(address.isConstant() && "symbolic string arg to intrinsic");  
+  assert(address->isConstant() && "symbolic string arg to intrinsic");  
   if (!state.addressSpace.resolveOne(address->getConstantValue(), op))
     assert(0 && "XXX out of bounds / multiple resolution unhandled");
   bool res;
@@ -195,7 +195,7 @@ std::string SpecialFunctionHandler::readStringAtAddress(ExecutionState &state,
   for (i = 0; i < mo->size - 1; i++) {
     ref<Expr> cur = os->read8(i);
     cur = executor.toUnique(state, cur);
-    assert(cur.isConstant() && 
+    assert(cur->isConstant() && 
            "hit symbolic char while reading concrete string");
     buf[i] = cur->getConstantValue();
   }
@@ -375,7 +375,7 @@ 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(!arguments[0]->isConstant(), Expr::Int32));
 }
 
 void SpecialFunctionHandler::handlePreferCex(ExecutionState &state,
@@ -414,7 +414,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(arguments[0]->isConstant() &&
    	 "symbolic argument given to klee_under_constrained!");
 
   unsigned v = arguments[0]->getConstantValue();
@@ -438,7 +438,7 @@ void SpecialFunctionHandler::handleSetForking(ExecutionState &state,
          "invalid number of arguments to klee_set_forking");
   ref<Expr> value = executor.toUnique(state, arguments[0]);
   
-  if (!value.isConstant()) {
+  if (!value->isConstant()) {
     executor.terminateStateOnError(state, 
                                    "klee_set_forking requires a constant arg",
                                    "user.err");
@@ -476,7 +476,7 @@ void SpecialFunctionHandler::handlePrintRange(ExecutionState &state,
 
   std::string msg_str = readStringAtAddress(state, arguments[0]);
   llvm::cerr << msg_str << ":" << arguments[1];
-  if (!arguments[1].isConstant()) {
+  if (!arguments[1]->isConstant()) {
     // FIXME: Pull into a unique value method?
     ref<Expr> value;
     bool success = executor.solver->getValue(state, arguments[1], value);
@@ -582,14 +582,15 @@ void SpecialFunctionHandler::handleFree(ExecutionState &state,
 }
 
 void SpecialFunctionHandler::handleCheckMemoryAccess(ExecutionState &state,
-                                            KInstruction *target,
-                                            std::vector<ref<Expr> > &arguments) {
+                                                     KInstruction *target,
+                                                     std::vector<ref<Expr> > 
+                                                       &arguments) {
   assert(arguments.size()==2 &&
          "invalid number of arguments to klee_check_memory_access");
 
   ref<Expr> address = executor.toUnique(state, arguments[0]);
   ref<Expr> size = executor.toUnique(state, arguments[1]);
-  if (!address.isConstant() || !size.isConstant()) {
+  if (!address->isConstant() || !size->isConstant()) {
     executor.terminateStateOnError(state, 
                                    "check_memory_access requires constant args",
                                    "user.err");
@@ -604,7 +605,7 @@ void SpecialFunctionHandler::handleCheckMemoryAccess(ExecutionState &state,
     } else {
       ref<Expr> chk = op.first->getBoundsCheckPointer(address, 
                                                       size->getConstantValue());
-      assert(chk.isConstant());
+      assert(chk->isConstant());
       if (!chk->getConstantValue()) {
         executor.terminateStateOnError(state,
                                        "check_memory_access: memory error",
@@ -629,9 +630,9 @@ void SpecialFunctionHandler::handleDefineFixedObject(ExecutionState &state,
                                                      std::vector<ref<Expr> > &arguments) {
   assert(arguments.size()==2 &&
          "invalid number of arguments to klee_define_fixed_object");
-  assert(arguments[0].isConstant() &&
+  assert(arguments[0]->isConstant() &&
          "expect constant address argument to klee_define_fixed_object");
-  assert(arguments[1].isConstant() &&
+  assert(arguments[1]->isConstant() &&
          "expect constant size argument to klee_define_fixed_object");
   
   uint64_t address = arguments[0]->getConstantValue();
diff --git a/lib/Core/TimingSolver.cpp b/lib/Core/TimingSolver.cpp
index 55fa7c8d..9efb77b8 100644
--- a/lib/Core/TimingSolver.cpp
+++ b/lib/Core/TimingSolver.cpp
@@ -25,7 +25,7 @@ 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()) {
+  if (expr->isConstant()) {
     result = expr->getConstantValue() ? Solver::True : Solver::False;
     return true;
   }
@@ -49,7 +49,7 @@ 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()) {
+  if (expr->isConstant()) {
     result = expr->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 (expr->isConstant()) {
     result = expr;
     return true;
   }