From: Craig Topper Date: Wed, 21 Oct 2015 04:52:36 +0000 (+0000) Subject: Parse into an unsigned type instead of a signed type and then checking for positive... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6bd3d26b25afc8582dbbb456da98e72024ff3a42;p=clang 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250879 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 3504495381..048a6d64ba 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -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]; } }