Skip to content

Commit 918cdae

Browse files
[TableGen] Use StringRef::substr instead of StringRef::slice (NFC) (llvm#139485)
StringRef::substr is shorter here because we can rely on its default second parameter.
1 parent 5971b41 commit 918cdae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
10891089

10901090
if (End) {
10911091
Parsed.push_back(New<TextPiece>(Text.slice(0, End), "diagtext"));
1092-
Text = Text.slice(End, StringRef::npos);
1092+
Text = Text.substr(End);
10931093
if (Text.empty())
10941094
break;
10951095
}
@@ -1103,7 +1103,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
11031103
// Extract the (optional) modifier.
11041104
size_t ModLength = Text.find_first_of("0123456789<{");
11051105
StringRef Modifier = Text.slice(0, ModLength);
1106-
Text = Text.slice(ModLength, StringRef::npos);
1106+
Text = Text.substr(ModLength);
11071107
ModifierType ModType = StringSwitch<ModifierType>{Modifier}
11081108
.Case("select", MT_Select)
11091109
.Case("enum_select", MT_EnumSelect)
@@ -1154,7 +1154,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
11541154
Text = Text.drop_front(); // Drop '<'
11551155
size_t EnumNameLen = Text.find_first_of('>');
11561156
EnumSelect->EnumName = Text.slice(0, EnumNameLen);
1157-
Text = Text.slice(EnumNameLen, StringRef::npos);
1157+
Text = Text.substr(EnumNameLen);
11581158
ExpectAndConsume(">");
11591159

11601160
if (Text[0] != '{')
@@ -1169,7 +1169,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
11691169
Text = Text.drop_front(); // '%'
11701170
size_t OptionNameLen = Text.find_first_of("{");
11711171
EnumSelect->OptionEnumNames.push_back(Text.slice(0, OptionNameLen));
1172-
Text = Text.slice(OptionNameLen, StringRef::npos);
1172+
Text = Text.substr(OptionNameLen);
11731173
} else {
11741174
EnumSelect->OptionEnumNames.push_back({});
11751175
}
@@ -1206,7 +1206,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
12061206
assert(!Text.empty());
12071207
Plural->OptionPrefixes.push_back(
12081208
New<TextPiece>(Text.slice(0, End), "diagtext"));
1209-
Text = Text.slice(End, StringRef::npos);
1209+
Text = Text.substr(End);
12101210
Plural->Options.push_back(
12111211
parseDiagText(Text, StopAt::PipeOrCloseBrace));
12121212
assert(!Text.empty() && "malformed %plural");

0 commit comments

Comments
 (0)