r250879 - 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
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 20 21:52:36 PDT 2015
Author: ctopper
Date: Tue Oct 20 23:52:36 2015
New Revision: 250879
URL: http://llvm.org/viewvc/llvm-project?rev=250879&view=rev
Log:
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
Modified:
cfe/trunk/lib/Basic/TargetInfo.cpp
Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=250879&r1=250878&r2=250879&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Tue Oct 20 23:52:36 2015
@@ -358,9 +358,9 @@ bool TargetInfo::isValidGCCRegisterName(
// 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
// 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];
}
}
More information about the cfe-commits
mailing list