StringRef::compare_numeric also differed from StringRef::compare for characters > 127.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112189 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2010-08-26 15:25:35 +00:00
parent 0043e35b82
commit 837bccd052
2 changed files with 2 additions and 1 deletions

View File

@ -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;

View File

@ -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) {