aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Support/StringRef.cpp2
-rw-r--r--unittests/ADT/StringRefTest.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/lib/Support/StringRef.cpp b/lib/Support/StringRef.cpp
index c33ca6a2eb..46f26b242a 100644
--- a/lib/Support/StringRef.cpp
+++ b/lib/Support/StringRef.cpp
@@ -59,7 +59,7 @@ int StringRef::compare_numeric(StringRef RHS) const {
break;
}
}
- return Data[I] < RHS.Data[I] ? -1 : 1;
+ return (unsigned char)Data[I] < (unsigned char)RHS.Data[I] ? -1 : 1;
}
if (Length == RHS.Length)
return 0;
diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp
index de5c349cd6..7e4d0dcd41 100644
--- a/unittests/ADT/StringRefTest.cpp
+++ b/unittests/ADT/StringRefTest.cpp
@@ -72,6 +72,7 @@ TEST(StringRefTest, StringOps) {
EXPECT_EQ( 0, StringRef("10a").compare_numeric("10a"));
EXPECT_EQ( 1, StringRef("2").compare_numeric("1"));
EXPECT_EQ( 0, StringRef("llvm_v1i64_ty").compare_numeric("llvm_v1i64_ty"));
+ EXPECT_EQ( 1, StringRef("\xFF").compare_numeric("\1"));
}
TEST(StringRefTest, Operators) {