From e3bca69757a80b46d743195944fed6481dec7e4f Mon Sep 17 00:00:00 2001 From: Cristian Cadar Date: Thu, 4 Jun 2009 06:51:12 +0000 Subject: 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 --- lib/Expr/Parser.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/Expr') 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. -- cgit 1.4.1