aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/StringRef.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-09-22 15:55:05 +0000
committerZachary Turner <zturner@google.com>2016-09-22 15:55:05 +0000
commitd5d57635baf6f3aa8d937e20f43dad75179f2cee (patch)
tree49fd94438cbfb61edf2522d5f67bc1f098a18fce /llvm/lib/Support/StringRef.cpp
parent74c3fd17984737a0ef87fd3a83eb035fc58adf21 (diff)
downloadllvm-d5d57635baf6f3aa8d937e20f43dad75179f2cee.zip
llvm-d5d57635baf6f3aa8d937e20f43dad75179f2cee.tar.gz
llvm-d5d57635baf6f3aa8d937e20f43dad75179f2cee.tar.bz2
Speculative fix for build failures due to consumeInteger.
A recent patch added support for consumeInteger() and made getAsInteger delegate to this function. A few buildbots are failing as a result with an assertion failure. On a hunch, I tested what happens if I call getAsInteger() on an empty string, and sure enough it crashes the same way that the buildbots are crashing. I confirmed that getAsInteger() on an empty string did not crash before my patch, so I suspect this to be the cause. I also added a unit test for the empty string. llvm-svn: 282170
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
-rw-r--r--llvm/lib/Support/StringRef.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 7503fac..51e0394 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -351,6 +351,9 @@ size_t StringRef::count(StringRef Str) const {
}
static unsigned GetAutoSenseRadix(StringRef &Str) {
+ if (Str.empty())
+ return 10;
+
if (Str.startswith("0x") || Str.startswith("0X")) {
Str = Str.substr(2);
return 16;