Skip to content

Commit

Permalink
[ELF] Replace some while (peek() != ")" && !atEOF()) with till
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Jul 27, 2024
1 parent cd354e3 commit b32c38a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lld/ELF/ScriptParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,8 @@ void ScriptParser::readDefsym(StringRef name) {
void ScriptParser::readNoCrossRefs(bool to) {
expect("(");
NoCrossRefCommand cmd{{}, to};
while (peek() != ")" && !atEOF())
cmd.outputSections.push_back(unquote(next()));
expect(")");
while (auto tok = till(")"))
cmd.outputSections.push_back(unquote(tok));
if (cmd.outputSections.size() < 2)
warn(getCurrentLocation() + ": ignored with fewer than 2 output sections");
else
Expand Down Expand Up @@ -1769,16 +1768,13 @@ SmallVector<SymbolVersion, 0> ScriptParser::readVersionExtern() {
expect("{");

SmallVector<SymbolVersion, 0> ret;
while (!errorCount() && peek() != "}") {
StringRef tok = next();
while (auto tok = till("}")) {
ret.push_back(
{unquote(tok), isCXX, !tok.starts_with("\"") && hasWildcard(tok)});
{unquote(tok), isCXX, !tok.str.starts_with("\"") && hasWildcard(tok)});
if (consume("}"))
return ret;
expect(";");
}

expect("}");
return ret;
}

Expand Down

0 comments on commit b32c38a

Please sign in to comment.