about summary refs log tree commit diff homepage
path: root/lib/Expr
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Expr')
-rw-r--r--lib/Expr/ExprBuilder.cpp12
-rw-r--r--lib/Expr/Parser.cpp8
2 files changed, 11 insertions, 9 deletions
diff --git a/lib/Expr/ExprBuilder.cpp b/lib/Expr/ExprBuilder.cpp
index 68a7fefd..009e621e 100644
--- a/lib/Expr/ExprBuilder.cpp
+++ b/lib/Expr/ExprBuilder.cpp
@@ -19,8 +19,8 @@ ExprBuilder::~ExprBuilder() {
 
 namespace {
   class DefaultExprBuilder : public ExprBuilder {
-    virtual ref<Expr> Constant(uint64_t Value, Expr::Width W) {
-      return ConstantExpr::alloc(Value, W);
+    virtual ref<Expr> Constant(const llvm::APInt &Value) {
+      return ConstantExpr::alloc(Value);
     }
 
     virtual ref<Expr> NotOptimized(const ref<Expr> &Index) {
@@ -164,8 +164,8 @@ namespace {
       : Builder(_Builder), Base(_Base) {}
     ~ChainedBuilder() { delete Base; }
 
-    ref<Expr> Constant(uint64_t Value, Expr::Width W) {
-      return Base->Constant(Value, W);
+    ref<Expr> Constant(const llvm::APInt &Value) {
+      return Base->Constant(Value);
     }
 
     ref<Expr> NotOptimized(const ref<Expr> &Index) {
@@ -307,8 +307,8 @@ namespace {
     ConstantSpecializedExprBuilder(ExprBuilder *Base) : Builder(this, Base) {}
     ~ConstantSpecializedExprBuilder() {}
 
-    virtual ref<Expr> Constant(uint64_t Value, Expr::Width W) {
-      return Builder.Constant(Value, W);
+    virtual ref<Expr> Constant(const llvm::APInt &Value) {
+      return Builder.Constant(Value);
     }
 
     virtual ref<Expr> NotOptimized(const ref<Expr> &Index) {
diff --git a/lib/Expr/Parser.cpp b/lib/Expr/Parser.cpp
index 2b9777cb..42e8af03 100644
--- a/lib/Expr/Parser.cpp
+++ b/lib/Expr/Parser.cpp
@@ -1462,7 +1462,7 @@ ExprResult ParserImpl::ParseNumberToken(Expr::Width Type, const Token &Tok) {
   }
 
   // This is a simple but slow way to handle overflow.
-  APInt Val(std::max(64U, RadixBits * N), 0);
+  APInt Val(RadixBits * N, 0);
   APInt RadixVal(Val.getBitWidth(), Radix);
   APInt DigitVal(Val.getBitWidth(), 0);
   for (unsigned i=0; i<N; ++i) {
@@ -1496,9 +1496,11 @@ ExprResult ParserImpl::ParseNumberToken(Expr::Width Type, const Token &Tok) {
     Val = -Val;
 
   if (Type < Val.getBitWidth())
-    Val = Val.trunc(Type);
+    Val.trunc(Type);
+  else if (Type > Val.getBitWidth())
+    Val.zext(Type);
 
-  return ExprResult(Builder->Constant(Val.getZExtValue(), Type));
+  return ExprResult(Builder->Constant(Val));
 }
 
 /// ParseTypeSpecifier - Parse a type specifier.