about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-04 09:06:35 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-04 09:06:35 +0000
commit4203dcc7637fce437af56e51ed7d9fef8f1ceeca (patch)
tree7166c33a9bb0127bb62163ed94a1d340375d66cf
parent92004d6524c7633aa1e014e5b727a39475652dda (diff)
downloadklee-4203dcc7637fce437af56e51ed7d9fef8f1ceeca.tar.gz
Make ConstantExpr's value and constructor private.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@72863 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/klee/Expr.h20
-rw-r--r--lib/Expr/Expr.cpp18
2 files changed, 15 insertions, 23 deletions
diff --git a/include/klee/Expr.h b/include/klee/Expr.h
index cc3a392b..bbaa55e4 100644
--- a/include/klee/Expr.h
+++ b/include/klee/Expr.h
@@ -222,8 +222,6 @@ public:
   
   static ref<Expr> createPointer(uint64_t v);
 
-  static Expr *createConstant(uint64_t val, Width w);
-  
   struct CreateArg;
   static ref<Expr> createFromKind(Kind k, std::vector<CreateArg> args);
 
@@ -288,17 +286,17 @@ class ConstantExpr : public Expr {
 public:
   static const Kind kind = Constant;
   static const unsigned numKids = 0;
-  
+
+private:
+  uint64_t value;
+
+  ConstantExpr(uint64_t v, Width w) : value(v), width(w) {}
+
 public:
-  union {
-    uint64_t asUInt64;
-  };
   Width width;
 
 public:
   ~ConstantExpr() {};
-  // should change the code to make this private
-  ConstantExpr(uint64_t v, Width w) : asUInt64(v), width(w) {}
   
   Width getWidth() const { return width; }
   Kind getKind() const { return Constant; }
@@ -306,14 +304,14 @@ public:
   unsigned getNumKids() const { return 0; }
   ref<Expr> getKid(unsigned i) const { return 0; }
 
-  uint64_t getConstantValue() const { return asUInt64; }
+  uint64_t getConstantValue() const { return value; }
 
   int compareContents(const Expr &b) const { 
     const ConstantExpr &cb = static_cast<const ConstantExpr&>(b);
     if (width != cb.width) return width < cb.width ? -1 : 1;
-    if (asUInt64 < cb.asUInt64) {
+    if (value < cb.value) {
       return -1;
-    } else if (asUInt64 > cb.asUInt64) {
+    } else if (value > cb.value) {
       return 1;
     } else {
       return 0;
diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp
index c645f37c..bc871808 100644
--- a/lib/Expr/Expr.cpp
+++ b/lib/Expr/Expr.cpp
@@ -165,7 +165,7 @@ unsigned Expr::computeHash() {
 }
 
 unsigned ConstantExpr::computeHash() {
-  hashValue = asUInt64 ^ (width * MAGIC_HASH_CONSTANT);
+  hashValue = value ^ (width * MAGIC_HASH_CONSTANT);
   return hashValue;
 }
 
@@ -319,12 +319,6 @@ ref<Expr> Expr::createPointer(uint64_t v) {
   return ConstantExpr::create(v, kMachinePointerType);
 }
 
-Expr* Expr::createConstant(uint64_t val, Width w) {
-  Expr *r = new ConstantExpr(val, w);
-  r->computeHash();
-  return r;
-}
-
 void Expr::print(std::ostream &os) const {
   const ref<Expr> tmp((Expr*)this);
   ExprPPrinter::printOne(os, "", tmp);
@@ -345,11 +339,11 @@ ref<Expr> ConstantExpr::fromMemory(void *address, Width width) {
 
 void ConstantExpr::toMemory(void *address) {
   switch (width) {
-  case  Expr::Bool: *(( uint8_t*) address) = asUInt64; break;
-  case  Expr::Int8: *(( uint8_t*) address) = asUInt64; break;
-  case Expr::Int16: *((uint16_t*) address) = asUInt64; break;
-  case Expr::Int32: *((uint32_t*) address) = asUInt64; break;
-  case Expr::Int64: *((uint64_t*) address) = asUInt64; break;
+  case  Expr::Bool: *(( uint8_t*) address) = value; break;
+  case  Expr::Int8: *(( uint8_t*) address) = value; break;
+  case Expr::Int16: *((uint16_t*) address) = value; break;
+  case Expr::Int32: *((uint32_t*) address) = value; break;
+  case Expr::Int64: *((uint64_t*) address) = value; break;
   default: assert(0 && "invalid type");
   }
 }