From 67288a9b752e78d61d35267ea7be79ea385ad94b Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 21 Oct 2015 04:52:36 +0000 Subject: 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 --- clang/lib/Basic/TargetInfo.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'clang/lib/Basic') diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index 35044953810..048a6d64ba8 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/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]; } } -- cgit v1.2.3