From b1f64426a00d1d12747f30a9394fdd9db6b9e279 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 16 Oct 2008 06:39:30 +0000 Subject: [PATCH] Simplify overflow-on-add check in NumericLiteralParser::GetIntegerValue. llvm-svn: 57629 --- clang/lib/Lex/LiteralSupport.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index f63e6cfffc0d..1b86ba5def85 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -481,10 +481,9 @@ bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) { Val *= RadixVal; OverflowOccurred |= Val.udiv(RadixVal) != OldVal; - OldVal = Val; // Add value, did overflow occur on the value? + // (a + b) ult b <=> overflow Val += CharVal; - OverflowOccurred |= Val.ult(OldVal); OverflowOccurred |= Val.ult(CharVal); } return OverflowOccurred;