Skip to content

Commit f1a7d14

Browse files
authored
[ELF] Updated some while conditions with till (#100893)
This change is based on [commit](b32c38a) for a cleaner API usage. Thanks to @MaskRay !
1 parent bccff3b commit f1a7d14

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lld/ELF/ScriptParser.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -957,13 +957,15 @@ OutputDesc *ScriptParser::readOverlaySectionDescription() {
957957
OutputDesc *osd = script->createOutputSection(next(), getCurrentLocation());
958958
osd->osec.inOverlay = true;
959959
expect("{");
960-
while (!errorCount() && !consume("}")) {
960+
while (auto tok = till("}")) {
961961
uint64_t withFlags = 0;
962962
uint64_t withoutFlags = 0;
963-
if (consume("INPUT_SECTION_FLAGS"))
963+
if (tok == "INPUT_SECTION_FLAGS") {
964964
std::tie(withFlags, withoutFlags) = readInputSectionFlags();
965+
tok = till("");
966+
}
965967
osd->osec.commands.push_back(
966-
readInputSectionRules(next(), withFlags, withoutFlags));
968+
readInputSectionRules(tok, withFlags, withoutFlags));
967969
}
968970
osd->osec.phdrs = readOutputSectionPhdrs();
969971
return osd;
@@ -1090,7 +1092,7 @@ SymbolAssignment *ScriptParser::readProvideHidden(bool provide, bool hidden) {
10901092
StringRef name = next(), eq = peek();
10911093
if (eq != "=") {
10921094
setError("= expected, but got " + next());
1093-
while (!atEOF() && next() != ")")
1095+
while (till(")"))
10941096
;
10951097
return nullptr;
10961098
}
@@ -1731,15 +1733,11 @@ ScriptParser::readSymbols() {
17311733
SmallVector<SymbolVersion, 0> globals;
17321734
SmallVector<SymbolVersion, 0> *v = &globals;
17331735

1734-
while (!errorCount()) {
1735-
if (consume("}"))
1736-
break;
1737-
1738-
if (consume("extern")) {
1736+
while (auto tok = till("}")) {
1737+
if (tok == "extern") {
17391738
SmallVector<SymbolVersion, 0> ext = readVersionExtern();
17401739
v->insert(v->end(), ext.begin(), ext.end());
17411740
} else {
1742-
StringRef tok = next();
17431741
if (tok == "local:" || (tok == "local" && consume(":"))) {
17441742
v = &locals;
17451743
continue;

0 commit comments

Comments
 (0)