forked from OSchip/llvm-project
Improve overflow detection in StringRef::getAsUnsignedInteger().
llvm-svn: 165038
This commit is contained in:
parent
8a5bc6edca
commit
35c79da3f8
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue