Improve overflow detection in StringRef::getAsUnsignedInteger().

llvm-svn: 165038
This commit is contained in:
Nick Kledzik 2012-10-02 20:01:48 +00:00
parent 8a5bc6edca
commit 35c79da3f8
1 changed files with 2 additions and 2 deletions

View File

@ -350,8 +350,8 @@ bool llvm::getAsUnsignedInteger(StringRef Str, unsigned Radix,
unsigned long long PrevResult = Result;
Result = Result*Radix+CharVal;
// Check for overflow.
if (Result < PrevResult)
// Check for overflow by shifting back and seeing if bits were lost.
if (Result/Radix < PrevResult)
return true;
Str = Str.substr(1);