about summary refs log tree commit diff homepage
path: root/include
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-03 15:40:42 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-03 15:40:42 +0000
commit32461e170b16d2f6cbcd04830bf68ce2a6372db5 (patch)
tree59c8813624c9072d2ecd14526658d6751e5a9674 /include
parentd55171601a0537506ddd05d37a1dabe372454a6d (diff)
downloadklee-32461e170b16d2f6cbcd04830bf68ce2a6372db5.tar.gz
Kill off specialized ref<> forwarding methods, in the interest of making it a
more standard reference counting wrapper.
 - The only interesting changes here are in Ref.h, everything else is just
   updating foo.method to use foo->method instead.


git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@72777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/klee/Expr.h26
-rw-r--r--include/klee/util/Assignment.h2
-rw-r--r--include/klee/util/ExprHashMap.h2
-rw-r--r--include/klee/util/ExprRangeEvaluator.h30
-rw-r--r--include/klee/util/Ref.h49
5 files changed, 39 insertions, 70 deletions
diff --git a/include/klee/Expr.h b/include/klee/Expr.h
index 5585b102..ea5f18c9 100644
--- a/include/klee/Expr.h
+++ b/include/klee/Expr.h
@@ -327,7 +327,7 @@ public:
   static ref<Expr> alloc(uint64_t v, Width w) {
     // constructs an "optimized" ConstantExpr
     ref<Expr> r(new ConstantExpr(v, w));
-    r.computeHash();
+    r->computeHash();
     return r;
   }
   
@@ -379,13 +379,13 @@ public:
 
   static ref<Expr> alloc(const ref<Expr> &src) {
     ref<Expr> r(new NotOptimizedExpr(src));
-    r.computeHash();
+    r->computeHash();
     return r;
   }
   
   static ref<Expr> create(ref<Expr> src);
   
-  Width getWidth() const { return src.getWidth(); }
+  Width getWidth() const { return src->getWidth(); }
   Kind getKind() const { return NotOptimized; }
 
   unsigned getNumKids() const { return 1; }
@@ -502,7 +502,7 @@ public:
 public:
   static ref<Expr> alloc(const UpdateList &updates, const ref<Expr> &index) {
     ref<Expr> r(new ReadExpr(updates, index));
-    r.computeHash();
+    r->computeHash();
     return r;
   }
   
@@ -541,13 +541,13 @@ public:
   static ref<Expr> alloc(const ref<Expr> &c, const ref<Expr> &t, 
                          const ref<Expr> &f) {
     ref<Expr> r(new SelectExpr(c, t, f));
-    r.computeHash();
+    r->computeHash();
     return r;
   }
   
   static ref<Expr> create(ref<Expr> c, ref<Expr> t, ref<Expr> f);
 
-  Width getWidth() const { return trueExpr.getWidth(); }
+  Width getWidth() const { return trueExpr->getWidth(); }
   Kind getKind() const { return Select; }
 
   unsigned getNumKids() const { return numKids; }
@@ -592,7 +592,7 @@ private:
 public:
   static ref<Expr> alloc(const ref<Expr> &l, const ref<Expr> &r) {
     ref<Expr> c(new ConcatExpr(l, r));
-    c.computeHash();
+    c->computeHash();
     return c;
   }
   
@@ -629,7 +629,7 @@ public:
   
 private:
   ConcatExpr(const ref<Expr> &l, const ref<Expr> &r) : left(l), right(r) {
-    width = l.getWidth() + r.getWidth();
+    width = l->getWidth() + r->getWidth();
   }
 };
 
@@ -651,7 +651,7 @@ public:
 public:  
   static ref<Expr> alloc(const ref<Expr> &e, unsigned o, Width w) {
     ref<Expr> r(new ExtractExpr(e, o, w));
-    r.computeHash();
+    r->computeHash();
     return r;
   }
   
@@ -721,7 +721,7 @@ public:                                                     \
     _class_kind ## Expr(ref<Expr> e, Width w) : CastExpr(e,w) {} \
     static ref<Expr> alloc(const ref<Expr> &e, Width w) {                   \
       ref<Expr> r(new _class_kind ## Expr(e, w));                     \
-      r.computeHash();                                                    \
+      r->computeHash();                                                    \
       return r;                                                       \
     }                                                       \
     static ref<Expr> create(const ref<Expr> &e, Width w);                   \
@@ -745,11 +745,11 @@ public:                                                         \
     _class_kind ## Expr(const ref<Expr> &l, const ref<Expr> &r) : BinaryExpr(l,r) {}  \
     static ref<Expr> alloc(const ref<Expr> &l, const ref<Expr> &r) {          \
       ref<Expr> res(new _class_kind ## Expr (l, r));                      \
-      res.computeHash();                                                      \
+      res->computeHash();                                                      \
       return res;                                                         \
     }                                                           \
     static ref<Expr> create(const ref<Expr> &l, const ref<Expr> &r);                      \
-    Width getWidth() const { return left.getWidth(); }            \
+    Width getWidth() const { return left->getWidth(); }            \
     Kind getKind() const { return _class_kind; }                \
     virtual ref<Expr> rebuild(ref<Expr> kids[]) const { \
       return create(kids[0], kids[1]); \
@@ -781,7 +781,7 @@ public:                                                     \
     _class_kind ## Expr(const ref<Expr> &l, const ref<Expr> &r) : CmpExpr(l,r) {} \
     static ref<Expr> alloc(const ref<Expr> &l, const ref<Expr> &r) {                  \
       ref<Expr> res(new _class_kind ## Expr (l, r));                    \
-      res.computeHash();                                                    \
+      res->computeHash();                                                    \
       return res;                                                       \
     }                                                       \
     static ref<Expr> create(const ref<Expr> &l, const ref<Expr> &r);                  \
diff --git a/include/klee/util/Assignment.h b/include/klee/util/Assignment.h
index cb001415..54f6b0af 100644
--- a/include/klee/util/Assignment.h
+++ b/include/klee/util/Assignment.h
@@ -90,7 +90,7 @@ namespace klee {
     AssignmentEvaluator v(*this);
     for (; begin!=end; ++begin) {
       ref<Expr> res = v.visit(*begin);
-      if (!res.isConstant() || !res.getConstantValue())
+      if (!res.isConstant() || !res->getConstantValue())
         return false;
     }
     return true;
diff --git a/include/klee/util/ExprHashMap.h b/include/klee/util/ExprHashMap.h
index d9f95bff..d2e6cb1a 100644
--- a/include/klee/util/ExprHashMap.h
+++ b/include/klee/util/ExprHashMap.h
@@ -19,7 +19,7 @@ namespace klee {
   namespace util {
     struct ExprHash  {
       unsigned operator()(const ref<Expr> e) const {
-        return e.hash();
+        return e->hash();
       }
     };
     
diff --git a/include/klee/util/ExprRangeEvaluator.h b/include/klee/util/ExprRangeEvaluator.h
index 3729b5c2..b40b9e02 100644
--- a/include/klee/util/ExprRangeEvaluator.h
+++ b/include/klee/util/ExprRangeEvaluator.h
@@ -89,9 +89,9 @@ T ExprRangeEvaluator<T>::evalRead(const UpdateList &ul,
 
 template<class T>
 T ExprRangeEvaluator<T>::evaluate(const ref<Expr> &e) {
-  switch (e.getKind()) {
+  switch (e->getKind()) {
   case Expr::Constant:
-    return T(e.getConstantValue());
+    return T(e->getConstantValue());
 
   case Expr::NotOptimized: 
     break;
@@ -131,37 +131,37 @@ T ExprRangeEvaluator<T>::evaluate(const ref<Expr> &e) {
 
   case Expr::Add: {
     const BinaryExpr *be = static_ref_cast<const BinaryExpr>(e);
-    unsigned width = be->left.getWidth();
+    unsigned width = be->left->getWidth();
     return evaluate(be->left).add(evaluate(be->right), width);
   }
   case Expr::Sub: {
     const BinaryExpr *be = static_ref_cast<const BinaryExpr>(e);
-    unsigned width = be->left.getWidth();
+    unsigned width = be->left->getWidth();
     return evaluate(be->left).sub(evaluate(be->right), width);
   }
   case Expr::Mul: {
     const BinaryExpr *be = static_ref_cast<const BinaryExpr>(e);
-    unsigned width = be->left.getWidth();
+    unsigned width = be->left->getWidth();
     return evaluate(be->left).mul(evaluate(be->right), width);
   }
   case Expr::UDiv: {
     const BinaryExpr *be = static_ref_cast<const BinaryExpr>(e);
-    unsigned width = be->left.getWidth();
+    unsigned width = be->left->getWidth();
     return evaluate(be->left).udiv(evaluate(be->right), width);
   }
   case Expr::SDiv: {
     const BinaryExpr *be = static_ref_cast<const BinaryExpr>(e);
-    unsigned width = be->left.getWidth();
+    unsigned width = be->left->getWidth();
     return evaluate(be->left).sdiv(evaluate(be->right), width);
   }
   case Expr::URem: {
     const BinaryExpr *be = static_ref_cast<const BinaryExpr>(e);
-    unsigned width = be->left.getWidth();
+    unsigned width = be->left->getWidth();
     return evaluate(be->left).urem(evaluate(be->right), width);
   }
   case Expr::SRem: {
     const BinaryExpr *be = static_ref_cast<const BinaryExpr>(e);
-    unsigned width = be->left.getWidth();
+    unsigned width = be->left->getWidth();
     return evaluate(be->left).srem(evaluate(be->right), width);
   }
 
@@ -181,19 +181,19 @@ T ExprRangeEvaluator<T>::evaluate(const ref<Expr> &e) {
   }
   case Expr::Shl: {
     //    BinaryExpr *be = static_ref_cast<BinaryExpr>(e);
-    //    unsigned width = be->left.getWidth();
+    //    unsigned width = be->left->getWidth();
     //    return evaluate(be->left).shl(evaluate(be->right), width);
     break;
   }
   case Expr::LShr: {
     //    BinaryExpr *be = static_ref_cast<BinaryExpr>(e);
-    //    unsigned width = be->left.getWidth();
+    //    unsigned width = be->left->getWidth();
     //    return evaluate(be->left).lshr(evaluate(be->right), width);
     break;
   }
   case Expr::AShr: {
     //    BinaryExpr *be = static_ref_cast<BinaryExpr>(e);
-    //    unsigned width = be->left.getWidth();
+    //    unsigned width = be->left->getWidth();
     //    return evaluate(be->left).ashr(evaluate(be->right), width);
     break;
   }
@@ -241,7 +241,7 @@ T ExprRangeEvaluator<T>::evaluate(const ref<Expr> &e) {
     const BinaryExpr *be = static_ref_cast<const BinaryExpr>(e);
     T left = evaluate(be->left);
     T right = evaluate(be->right);
-    unsigned bits = be->left.getWidth();
+    unsigned bits = be->left->getWidth();
 
     if (left.maxSigned(bits) < right.minSigned(bits)) {
       return T(1);
@@ -254,7 +254,7 @@ T ExprRangeEvaluator<T>::evaluate(const ref<Expr> &e) {
     const BinaryExpr *be = static_ref_cast<const BinaryExpr>(e);
     T left = evaluate(be->left);
     T right = evaluate(be->right);
-    unsigned bits = be->left.getWidth();
+    unsigned bits = be->left->getWidth();
       
     if (left.maxSigned(bits) <= right.minSigned(bits)) {
       return T(1);
@@ -275,7 +275,7 @@ T ExprRangeEvaluator<T>::evaluate(const ref<Expr> &e) {
     break;
   }
 
-  return T(0, bits64::maxValueOfNBits(e.getWidth()));
+  return T(0, bits64::maxValueOfNBits(e->getWidth()));
 }
 
 }
diff --git a/include/klee/util/Ref.h b/include/klee/util/Ref.h
index 5e6aab4b..e2421bb0 100644
--- a/include/klee/util/Ref.h
+++ b/include/klee/util/Ref.h
@@ -15,10 +15,6 @@
 class Expr;
 class ConstantExpr;
 
-class ExprVisitor;
-class StackFrame;
-class ObjectState;
-
 template<class T>
 class ref {
   T *ptr;
@@ -77,37 +73,6 @@ public:
     return ptr && ptr->getKind() == Expr::Constant;
   }
 
-  uint64_t getConstantValue() const {
-    assert(isConstant() && "Invalid call to getConstantValue()");
-    return ptr->getConstantValue();
-  }
-
-  unsigned hash() const {
-    assert(!isNull() && "Invalid call to hash()");
-    return ptr->hash();
-  }
-
-  unsigned computeHash() const {
-    assert(!isNull() && "Invalid call to computeHash()");
-    return ptr->computeHash();
-  }
-  
-  Expr::Width getWidth() const {
-    return ptr->getWidth();
-  }
-
-  Expr::Kind getKind() const {
-    return ptr->getKind();
-  }
-
-  unsigned getNumKids() const {
-    return ptr->getNumKids();
-  }
-
-  ref<Expr> getKid(unsigned k) {
-    return ptr->getKid(k);
-  }
-
   /* The copy assignment operator must also explicitly be defined,
    * despite a redundant template. */
   ref<T> &operator= (const ref<T> &r) {
@@ -126,6 +91,14 @@ public:
     return *this;
   }
 
+  T& operator*() const {
+    return *ptr;
+  }
+
+  T* operator->() const {
+    return ptr;
+  }
+
   bool isNull() const { return ptr == 0; }
 
   // assumes non-null arguments
@@ -143,11 +116,7 @@ public:
 
 template<class T>
 inline std::ostream &operator<<(std::ostream &os, const ref<T> &e) {
-  if (e.isConstant()) {
-    os << e.getConstantValue();
-  } else {
-    os << *e.get();
-  }
+  os << *e.get();
   return os;
 }