about summary refs log tree commit diff homepage
path: root/lib/Expr
diff options
context:
space:
mode:
authorDan Liew <delcypher@gmail.com>2016-09-29 21:04:27 +0100
committerGitHub <noreply@github.com>2016-09-29 21:04:27 +0100
commit96b77a4a211745cdee375b38ce4313dfc70efe8f (patch)
treec2bbce1f697a31d9b8c8716cf765b651b266185a /lib/Expr
parenta936dcbaefe0efa67e97f4ea14893bdae63db99b (diff)
downloadklee-96b77a4a211745cdee375b38ce4313dfc70efe8f.tar.gz
Fix bug in `AssignmentEvaluator` where NotOptimizedExpr would not (#466)
* Add unittest to check that the `Assignment` class can evaluate
expressions containing a `NotOptimizedExpr`.

* Fix the `AssignmentTest.FoldNotOptimized` unit test by
teaching the `ExprEvaluator` to fold `NotOptimizedExpr` nodes.
Diffstat (limited to 'lib/Expr')
-rw-r--r--lib/Expr/ExprEvaluator.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Expr/ExprEvaluator.cpp b/lib/Expr/ExprEvaluator.cpp
index 1a146641..6b84cd6f 100644
--- a/lib/Expr/ExprEvaluator.cpp
+++ b/lib/Expr/ExprEvaluator.cpp
@@ -97,3 +97,12 @@ ExprVisitor::Action ExprEvaluator::visitURem(const URemExpr &e) {
 ExprVisitor::Action ExprEvaluator::visitSRem(const SRemExpr &e) { 
   return protectedDivOperation(e); 
 }
+
+ExprVisitor::Action ExprEvaluator::visitExprPost(const Expr& e) {
+  // When evaluating an assignment we should fold NotOptimizedExpr
+  // nodes so we can fully evaluate.
+  if (e.getKind() == Expr::NotOptimized) {
+    return Action::changeTo(static_cast<const NotOptimizedExpr&>(e).src);
+  }
+  return Action::skipChildren();
+}