Skip to content

Commit e6bafbe

Browse files
[TableGen] Use StringRef::consume_{front,back} (NFC)
1 parent eeb0e9f commit e6bafbe

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -873,16 +873,12 @@ struct DiagTextDocPrinter : DiagTextVisitor<DiagTextDocPrinter> {
873873
auto &S = RST.back();
874874

875875
StringRef T = P->Text;
876-
while (!T.empty() && T.front() == ' ') {
876+
while (T.consume_front(" "))
877877
RST.back() += " |nbsp| ";
878-
T = T.drop_front();
879-
}
880878

881879
std::string Suffix;
882-
while (!T.empty() && T.back() == ' ') {
880+
while (T.consume_back(" "))
883881
Suffix += " |nbsp| ";
884-
T = T.drop_back();
885-
}
886882

887883
if (!T.empty()) {
888884
S += ':';
@@ -1121,9 +1117,8 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
11211117
if (!isdigit(Text[0]))
11221118
break;
11231119
Sub->Modifiers.push_back(parseModifier(Text));
1124-
if (Text.empty() || Text[0] != ',')
1120+
if (!Text.consume_front(","))
11251121
break;
1126-
Text = Text.drop_front(); // ','
11271122
assert(!Text.empty() && isdigit(Text[0]) &&
11281123
"expected another modifier");
11291124
}

clang/utils/TableGen/NeonEmitter.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -735,20 +735,15 @@ Type Type::fromTypedefName(StringRef Name) {
735735
Type T;
736736
T.Kind = SInt;
737737

738-
if (Name.front() == 'u') {
738+
if (Name.consume_front("u"))
739739
T.Kind = UInt;
740-
Name = Name.drop_front();
741-
}
742740

743-
if (Name.starts_with("float")) {
741+
if (Name.consume_front("float")) {
744742
T.Kind = Float;
745-
Name = Name.drop_front(5);
746-
} else if (Name.starts_with("poly")) {
743+
} else if (Name.consume_front("poly")) {
747744
T.Kind = Poly;
748-
Name = Name.drop_front(4);
749-
} else if (Name.starts_with("bfloat")) {
745+
} else if (Name.consume_front("bfloat")) {
750746
T.Kind = BFloat16;
751-
Name = Name.drop_front(6);
752747
} else {
753748
assert(Name.starts_with("int"));
754749
Name = Name.drop_front(3);
@@ -765,8 +760,7 @@ Type Type::fromTypedefName(StringRef Name) {
765760
T.Bitwidth = T.ElementBitwidth;
766761
T.NumVectors = 1;
767762

768-
if (Name.front() == 'x') {
769-
Name = Name.drop_front();
763+
if (Name.consume_front("x")) {
770764
unsigned I = 0;
771765
for (I = 0; I < Name.size(); ++I) {
772766
if (!isdigit(Name[I]))
@@ -780,8 +774,7 @@ Type Type::fromTypedefName(StringRef Name) {
780774
// Was scalar.
781775
T.NumVectors = 0;
782776
}
783-
if (Name.front() == 'x') {
784-
Name = Name.drop_front();
777+
if (Name.consume_front("x")) {
785778
unsigned I = 0;
786779
for (I = 0; I < Name.size(); ++I) {
787780
if (!isdigit(Name[I]))

0 commit comments

Comments
 (0)