about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorDan Liew <delcypher@gmail.com>2014-04-24 17:26:51 +0100
committerDan Liew <delcypher@gmail.com>2014-04-24 17:26:51 +0100
commit7ce1eed6334be42dae30435acfae4f98f6ac3950 (patch)
treedeac2388bba38541741efc6ef171418286442061
parent9dd4766a3f58070501ed6498e6aa42c14776cc0f (diff)
parentb058af7f05be473e31a82fa1cdacf675eea784da (diff)
downloadklee-7ce1eed6334be42dae30435acfae4f98f6ac3950.tar.gz
Merge pull request #121 from hpalikareva/domain-range-metasmt
Fixed creation of arrays with variable domains and ranges in STPBuilder ...
-rw-r--r--lib/Solver/MetaSMTBuilder.h12
-rw-r--r--lib/Solver/STPBuilder.cpp3
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/Solver/MetaSMTBuilder.h b/lib/Solver/MetaSMTBuilder.h
index 2b084ac7..deb12e77 100644
--- a/lib/Solver/MetaSMTBuilder.h
+++ b/lib/Solver/MetaSMTBuilder.h
@@ -187,7 +187,7 @@ typename SolverContext::result_type MetaSMTBuilder<SolverContext>::getInitialArr
 
     if (!hashed) {
 
-        array_expr = evaluate(_solver, buildArray(8, 32));	
+        array_expr = evaluate(_solver, buildArray(root->getDomain(), root->getRange()));
 
         if (root->isConstantArray()) {    
             for (unsigned i = 0, e = root->size; i != e; ++i) {
@@ -603,7 +603,7 @@ typename SolverContext::result_type MetaSMTBuilder<SolverContext>::constructActu
 //     ExprPPrinter::printSingleExpr(std::cerr, e);
 //     std::cerr << "\n";
 
-    switch (e->getKind()) {    
+    switch (e->getKind()) {
 
         case Expr::Constant:
         {
@@ -614,7 +614,7 @@ typename SolverContext::result_type MetaSMTBuilder<SolverContext>::constructActu
 
             // Coerce to bool if necessary.
             if (coe_width == 1) {
-                res = (coe->isTrue()) ? getTrue() : getFalse();      
+                res = (coe->isTrue()) ? getTrue() : getFalse();
             }
             else if (coe_width <= 32) {
                  res = bvConst32(coe_width, coe->getZExtValue(32));
@@ -624,7 +624,7 @@ typename SolverContext::result_type MetaSMTBuilder<SolverContext>::constructActu
             }
             else {
                  ref<ConstantExpr> tmp = coe;
-                 res = bvConst64(64, tmp->Extract(0, 64)->getZExtValue());                 
+                 res = bvConst64(64, tmp->Extract(0, 64)->getZExtValue());
                  while (tmp->getWidth() > 64) {
                      tmp = tmp->Extract(64, tmp->getWidth() -  64);
                      unsigned min_width = std::min(64U, tmp->getWidth());
@@ -658,9 +658,9 @@ typename SolverContext::result_type MetaSMTBuilder<SolverContext>::constructActu
         case Expr::Read:
         {
             ReadExpr *re = cast<ReadExpr>(e);
-            assert(re);
+            assert(re && re->updates.root);
+            *width_out = re->updates.root->getRange();
             // FixMe call method of Array
-            *width_out = 8;
             res = evaluate(_solver, 
                            metaSMT::logic::Array::select(
                                   getArrayForUpdate(re->updates.root, re->updates.head),
diff --git a/lib/Solver/STPBuilder.cpp b/lib/Solver/STPBuilder.cpp
index ebc096df..e4a21f74 100644
--- a/lib/Solver/STPBuilder.cpp
+++ b/lib/Solver/STPBuilder.cpp
@@ -553,7 +553,8 @@ ExprHandle STPBuilder::constructActual(ref<Expr> e, int *width_out) {
 
   case Expr::Read: {
     ReadExpr *re = cast<ReadExpr>(e);
-    *width_out = 8;
+    assert(re && re->updates.root);
+    *width_out = re->updates.root->getRange();
     return vc_readExpr(vc,
                        getArrayForUpdate(re->updates.root, re->updates.head),
                        construct(re->index, 0));