Skip to content

Commit 10bb296

Browse files
committed
[ELF] Replace some while (peek() != ")" && !atEOF()) with till
1 parent 2a89356 commit 10bb296

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

lld/ELF/ScriptParser.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,9 @@ void ScriptParser::readAsNeeded() {
375375
expect("(");
376376
bool orig = config->asNeeded;
377377
config->asNeeded = true;
378-
while (peek() != ")" && !atEOF())
379-
addFile(unquote(next()));
378+
while (auto tok = till(")"))
379+
addFile(unquote(tok));
380380
config->asNeeded = orig;
381-
expect(")");
382381
}
383382

384383
void ScriptParser::readEntry() {
@@ -392,9 +391,8 @@ void ScriptParser::readEntry() {
392391

393392
void ScriptParser::readExtern() {
394393
expect("(");
395-
while (peek() != ")" && !atEOF())
396-
config->undefined.push_back(unquote(next()));
397-
expect(")");
394+
while (auto tok = till(")"))
395+
config->undefined.push_back(unquote(tok));
398396
}
399397

400398
void ScriptParser::readGroup() {
@@ -427,13 +425,12 @@ void ScriptParser::readInclude() {
427425

428426
void ScriptParser::readInput() {
429427
expect("(");
430-
while (peek() != ")" && !atEOF()) {
431-
if (consume("AS_NEEDED"))
428+
while (auto tok = till(")")) {
429+
if (tok == "AS_NEEDED")
432430
readAsNeeded();
433431
else
434-
addFile(unquote(next()));
432+
addFile(unquote(tok));
435433
}
436-
expect(")");
437434
}
438435

439436
void ScriptParser::readOutput() {
@@ -712,10 +709,8 @@ static int precedence(StringRef op) {
712709

713710
StringMatcher ScriptParser::readFilePatterns() {
714711
StringMatcher Matcher;
715-
716-
while (peek() != ")" && !atEOF())
717-
Matcher.addPattern(SingleStringMatcher(next()));
718-
expect(")");
712+
while (auto tok = till(")"))
713+
Matcher.addPattern(SingleStringMatcher(tok));
719714
return Matcher;
720715
}
721716

0 commit comments

Comments
 (0)