Skip to content

Commit 5e9da33

Browse files
[llvm] Use StringRef::consume_front_insensitive (NFC)
1 parent bfb026e commit 5e9da33

File tree

4 files changed

+9
-32
lines changed

4 files changed

+9
-32
lines changed

llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,9 @@ std::optional<std::string> MarkupFilter::parseMode(StringRef Str) const {
611611

612612
// Pop off each of r/R, w/W, and x/X from the front, in that order.
613613
StringRef Remainder = Str;
614-
if (!Remainder.empty() && tolower(Remainder.front()) == 'r')
615-
Remainder = Remainder.drop_front();
616-
if (!Remainder.empty() && tolower(Remainder.front()) == 'w')
617-
Remainder = Remainder.drop_front();
618-
if (!Remainder.empty() && tolower(Remainder.front()) == 'x')
619-
Remainder = Remainder.drop_front();
614+
Remainder.consume_front_insensitive("r");
615+
Remainder.consume_front_insensitive("w");
616+
Remainder.consume_front_insensitive("x");
620617

621618
// If anything remains, then the string wasn't a mode.
622619
if (!Remainder.empty()) {

llvm/lib/Support/StringRef.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -388,20 +388,14 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
388388
if (Str.empty())
389389
return 10;
390390

391-
if (Str.starts_with("0x") || Str.starts_with("0X")) {
392-
Str = Str.substr(2);
391+
if (Str.consume_front_insensitive("0x"))
393392
return 16;
394-
}
395393

396-
if (Str.starts_with("0b") || Str.starts_with("0B")) {
397-
Str = Str.substr(2);
394+
if (Str.consume_front_insensitive("0b"))
398395
return 2;
399-
}
400396

401-
if (Str.starts_with("0o")) {
402-
Str = Str.substr(2);
397+
if (Str.consume_front("0o"))
403398
return 8;
404-
}
405399

406400
if (Str[0] == '0' && Str.size() > 1 && isDigit(Str[1])) {
407401
Str = Str.substr(1);

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6894,12 +6894,7 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
68946894
FeatureBitset Features = STI.getFeatureBits();
68956895
setAvailableFeatures(ComputeAvailableFeatures(Features));
68966896
for (auto Name : RequestedExtensions) {
6897-
bool EnableFeature = true;
6898-
6899-
if (Name.starts_with_insensitive("no")) {
6900-
EnableFeature = false;
6901-
Name = Name.substr(2);
6902-
}
6897+
bool EnableFeature = !Name.consume_front_insensitive("no");
69036898

69046899
for (const auto &Extension : ExtensionMap) {
69056900
if (Extension.Name != Name)
@@ -6990,12 +6985,7 @@ bool AArch64AsmParser::parseDirectiveCPU(SMLoc L) {
69906985
// Advance source location past '+'.
69916986
CurLoc = incrementLoc(CurLoc, 1);
69926987

6993-
bool EnableFeature = true;
6994-
6995-
if (Name.starts_with_insensitive("no")) {
6996-
EnableFeature = false;
6997-
Name = Name.substr(2);
6998-
}
6988+
bool EnableFeature = !Name.consume_front_insensitive("no");
69996989

70006990
bool FoundExtension = false;
70016991
for (const auto &Extension : ExtensionMap) {

llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12668,11 +12668,7 @@ bool ARMAsmParser::enableArchExtFeature(StringRef Name, SMLoc &ExtLoc) {
1266812668
{ARM::AEK_MAVERICK, {}, {}},
1266912669
{ARM::AEK_XSCALE, {}, {}},
1267012670
};
12671-
bool EnableFeature = true;
12672-
if (Name.starts_with_insensitive("no")) {
12673-
EnableFeature = false;
12674-
Name = Name.substr(2);
12675-
}
12671+
bool EnableFeature = !Name.consume_front_insensitive("no");
1267612672
uint64_t FeatureKind = ARM::parseArchExt(Name);
1267712673
if (FeatureKind == ARM::AEK_INVALID)
1267812674
return Error(ExtLoc, "unknown architectural extension: " + Name);

0 commit comments

Comments
 (0)