diff options
author | Nick Kledzik <kledzik@apple.com> | 2012-10-02 20:01:48 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2012-10-02 20:01:48 +0000 |
commit | 35c79da3f890c28dabedbe1be3880972f706e105 (patch) | |
tree | 8f6a81d19b0ede66d710665e3c5811b2d08a175d /llvm/lib/Support/StringRef.cpp | |
parent | 8a5bc6edca4f7ff8553957bedfab55e7f0b7041e (diff) | |
download | bcm5719-llvm-35c79da3f890c28dabedbe1be3880972f706e105.tar.gz bcm5719-llvm-35c79da3f890c28dabedbe1be3880972f706e105.zip |
Improve overflow detection in StringRef::getAsUnsignedInteger().
llvm-svn: 165038
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
-rw-r--r-- | llvm/lib/Support/StringRef.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp index 8aab4b2760e..f8e92084625 100644 --- a/llvm/lib/Support/StringRef.cpp +++ b/llvm/lib/Support/StringRef.cpp @@ -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); |