about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2014-12-08 20:21:57 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2014-12-08 20:21:57 +0000
commit3c042be7a340972c41165a2394702a4f613ef1f9 (patch)
tree4ce13d8e2e6cb6cb1b2dc1a2d0d4632c94ca406e /lib
parentf481b1e1503207443fc6100c0be489d58f12d787 (diff)
parentd0ca2fd3211f3bc0cfc582df978b6a82ea7ec390 (diff)
downloadklee-3c042be7a340972c41165a2394702a4f613ef1f9.tar.gz
Merge pull request #183 from hpalikareva/fix-overshift-metasmt
Handling overshift behaviour in MetaSMTBuilder
Diffstat (limited to 'lib')
-rw-r--r--lib/Solver/MetaSMTBuilder.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Solver/MetaSMTBuilder.h b/lib/Solver/MetaSMTBuilder.h
index b5c99907..458c55ba 100644
--- a/lib/Solver/MetaSMTBuilder.h
+++ b/lib/Solver/MetaSMTBuilder.h
@@ -499,6 +499,11 @@ typename SolverContext::result_type MetaSMTBuilder<SolverContext>::bvVarLeftShif
                                                     bvLeftShift(expr, width, i, shiftBits),
                                                     res));
     }
+    
+    // If overshifting, shift to zero    
+    res = evaluate(_solver, metaSMT::logic::Ite(bvult(shift, bvConst32(shiftBits, width)),
+                                                res,
+                                                bvZero(width)));                                                
 
     return(res);
 }
@@ -521,6 +526,11 @@ typename SolverContext::result_type MetaSMTBuilder<SolverContext>::bvVarRightShi
                                                     res));
          // ToDo Reconsider widht to provide to bvRightShift
     }
+    
+    // If overshifting, shift to zero
+    res = evaluate(_solver, metaSMT::logic::Ite(bvult(shift, bvConst32(shiftBits, width)),
+                                                res,
+                                                bvZero(width)));                                                
 
     return(res);
 }
@@ -548,6 +558,11 @@ typename SolverContext::result_type MetaSMTBuilder<SolverContext>::bvVarArithRig
                                                     constructAShrByConstant(expr, width, i, signedBool, shiftBits),
                                                     res));
     }
+    
+    // If overshifting, shift to zero
+    res = evaluate(_solver, metaSMT::logic::Ite(bvult(shift, bvConst32(shiftBits, width)),
+                                                res,
+                                                bvZero(width)));      
 
     return(res);
 }