Parse into an unsigned type instead of a signed type and then checking for positive and casting to unsigned. Since we know the string starts with a digit it couldn't be negative anyway. NFCI
llvm-svn: 250879
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 3504495..048a6d6 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -358,9 +358,9 @@
// If we have a number it maps to an entry in the register name array.
if (isDigit(Name[0])) {
- int n;
+ unsigned n;
if (!Name.getAsInteger(0, n))
- return n >= 0 && (unsigned)n < Names.size();
+ return n < Names.size();
}
// Check register names.
@@ -406,10 +406,9 @@
// First, check if we have a number.
if (isDigit(Name[0])) {
- int n;
+ unsigned n;
if (!Name.getAsInteger(0, n)) {
- assert(n >= 0 && (unsigned)n < Names.size() &&
- "Out of bounds register number!");
+ assert(n < Names.size() && "Out of bounds register number!");
return Names[n];
}
}