Skip to content

Commit b32c38a

Browse files
committed
[ELF] Replace some while (peek() != ")" && !atEOF()) with till
1 parent cd354e3 commit b32c38a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lld/ELF/ScriptParser.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,8 @@ void ScriptParser::readDefsym(StringRef name) {
313313
void ScriptParser::readNoCrossRefs(bool to) {
314314
expect("(");
315315
NoCrossRefCommand cmd{{}, to};
316-
while (peek() != ")" && !atEOF())
317-
cmd.outputSections.push_back(unquote(next()));
318-
expect(")");
316+
while (auto tok = till(")"))
317+
cmd.outputSections.push_back(unquote(tok));
319318
if (cmd.outputSections.size() < 2)
320319
warn(getCurrentLocation() + ": ignored with fewer than 2 output sections");
321320
else
@@ -1769,16 +1768,13 @@ SmallVector<SymbolVersion, 0> ScriptParser::readVersionExtern() {
17691768
expect("{");
17701769

17711770
SmallVector<SymbolVersion, 0> ret;
1772-
while (!errorCount() && peek() != "}") {
1773-
StringRef tok = next();
1771+
while (auto tok = till("}")) {
17741772
ret.push_back(
1775-
{unquote(tok), isCXX, !tok.starts_with("\"") && hasWildcard(tok)});
1773+
{unquote(tok), isCXX, !tok.str.starts_with("\"") && hasWildcard(tok)});
17761774
if (consume("}"))
17771775
return ret;
17781776
expect(";");
17791777
}
1780-
1781-
expect("}");
17821778
return ret;
17831779
}
17841780

0 commit comments

Comments
 (0)