diff options
author | Cristian Cadar <cristic@cs.stanford.edu> | 2009-06-04 06:51:12 +0000 |
---|---|---|
committer | Cristian Cadar <cristic@cs.stanford.edu> | 2009-06-04 06:51:12 +0000 |
commit | e3bca69757a80b46d743195944fed6481dec7e4f (patch) | |
tree | 5e22dc79b1117d328cc8cd356687ceb180d2d5dc | |
parent | e8d9177a1533411eb53593c7a16cfa6c188952c9 (diff) | |
download | klee-e3bca69757a80b46d743195944fed6481dec7e4f.tar.gz |
Fixed a bug in Kleaver's parser: APInt does not allow "truncation" to
the same width. Added a test case that was previously triggering an assert violation. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@72850 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Expr/Parser.cpp | 5 | ||||
-rw-r--r-- | test/Expr/Parser/Concat64.pc | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/Expr/Parser.cpp b/lib/Expr/Parser.cpp index 9e1849ae..3bbe3334 100644 --- a/lib/Expr/Parser.cpp +++ b/lib/Expr/Parser.cpp @@ -1224,7 +1224,10 @@ ExprResult ParserImpl::ParseNumberToken(Expr::Width Type, const Token &Tok) { if (HasMinus) Val = -Val; - return ExprResult(ConstantExpr::alloc(Val.trunc(Type).getZExtValue(), Type)); + if (Type < Val.getBitWidth()) + Val = Val.trunc(Type); + + return ExprResult(ConstantExpr::alloc(Val.getZExtValue(), Type)); } /// ParseTypeSpecifier - Parse a type specifier. diff --git a/test/Expr/Parser/Concat64.pc b/test/Expr/Parser/Concat64.pc new file mode 100644 index 00000000..e57e9760 --- /dev/null +++ b/test/Expr/Parser/Concat64.pc @@ -0,0 +1,11 @@ +# RUN: kleaver --print-ast %s + +(query [(Eq 0 + (Concat w64 (Read w8 7 arr1) + (Concat w56 (Read w8 6 arr1) + (Concat w48 (Read w8 5 arr1) + (Concat w40 (Read w8 4 arr1) + (Concat w32 (Read w8 3 arr1) + (Concat w24 (Read w8 2 arr1) + (Concat w16 (Read w8 1 arr1) (Read w8 0 arr1)))))))))] + false) |