]> granicus.if.org Git - clang/commitdiff
Parse into an unsigned type instead of a signed type and then checking for positive...
authorCraig Topper <craig.topper@gmail.com>
Wed, 21 Oct 2015 04:52:36 +0000 (04:52 +0000)
committerCraig Topper <craig.topper@gmail.com>
Wed, 21 Oct 2015 04:52:36 +0000 (04:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250879 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/TargetInfo.cpp

index 350449538108098d68466e7c18ed44c7e0f440a7..048a6d64ba8b6e07b7659db07c6bd623cf7f12f4 100644 (file)
@@ -358,9 +358,9 @@ bool TargetInfo::isValidGCCRegisterName(StringRef Name) const {
 
   // 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 @@ TargetInfo::getNormalizedGCCRegisterName(StringRef Name) const {
 
   // 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];
     }
   }