diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp index 4f5fcb4857e80..bdf7a9aa5c7e0 100644 --- a/llvm/lib/Support/StringRef.cpp +++ b/llvm/lib/Support/StringRef.cpp @@ -409,6 +409,9 @@ static unsigned GetAutoSenseRadix(StringRef &Str) { bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result) { + // Consume the + value + Str.consume_front("+"); + // Autosense radix if not specified. if (Radix == 0) Radix = GetAutoSenseRadix(Str); diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp index ec9cdc197597d..55d222a915ab5 100644 --- a/llvm/unittests/ADT/StringRefTest.cpp +++ b/llvm/unittests/ADT/StringRefTest.cpp @@ -622,19 +622,21 @@ TEST(StringRefTest, Hashing) { struct UnsignedPair { const char *Str; uint64_t Expected; -} Unsigned[] = - { {"0", 0} - , {"255", 255} - , {"256", 256} - , {"65535", 65535} - , {"65536", 65536} - , {"4294967295", 4294967295ULL} - , {"4294967296", 4294967296ULL} - , {"18446744073709551615", 18446744073709551615ULL} - , {"042", 34} - , {"0x42", 66} - , {"0b101010", 42} - }; +} Unsigned[] = {{"0", 0}, + {"255", 255}, + {"256", 256}, + {"65535", 65535}, + {"65536", 65536}, + {"4294967295", 4294967295ULL}, + {"4294967296", 4294967296ULL}, + {"18446744073709551615", 18446744073709551615ULL}, + {"042", 34}, + {"0x42", 66}, + {"0b101010", 42}, + {"+42", 42}, + {"+042", 34}, + {"+0x42", 66}, + {"+0b101010", 42}}; struct SignedPair { const char *Str;