about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorDaniel Schemmel <daniel@schemmel.net>2023-06-28 22:37:05 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2023-07-08 22:53:34 +0200
commit3034ae5878f2b1f3216ab1a7d2706edf27c8ae4c (patch)
tree40a12a228abade1a9140facaac81acc6e3b9e19d /lib
parentc8acc60e25a120f9b2c8f0773068c2ce963d947e (diff)
downloadklee-3034ae5878f2b1f3216ab1a7d2706edf27c8ae4c.tar.gz
Combine all `ConstantExpr::toMemory` cases into one.
Note that (as it did previously), this relies on the native types having
the same internal representation as the ApInt type.
Diffstat (limited to 'lib')
-rw-r--r--lib/Expr/Expr.cpp14
1 files changed, 1 insertions, 13 deletions
diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp
index 2026a07b..7feba8ab 100644
--- a/lib/Expr/Expr.cpp
+++ b/lib/Expr/Expr.cpp
@@ -363,19 +363,7 @@ ref<Expr> ConstantExpr::fromMemory(void *address, Width width) {
 
 void ConstantExpr::toMemory(void *address) {
   auto width = getWidth();
-  switch (width) {
-  default: assert(0 && "invalid type");
-  case  Expr::Bool: *(( uint8_t*) address) = getZExtValue(1); break;
-  case  Expr::Int8: *(( uint8_t*) address) = getZExtValue(8); break;
-  case Expr::Int16: *((uint16_t*) address) = getZExtValue(16); break;
-  case Expr::Int32: *((uint32_t*) address) = getZExtValue(32); break;
-  case Expr::Int64: *((uint64_t*) address) = getZExtValue(64); break;
-  case Expr::Fl80:
-  case Expr::Int128:
-  case Expr::Int256:
-  case Expr::Int512:
-      std::memcpy(address, value.getRawData(), width / 8);
-  }
+  std::memcpy(address, value.getRawData(), (width + 7) / 8);
 }
 
 void ConstantExpr::toString(std::string &Res, unsigned radix) const {