[lld] f1a7d14 - [ELF] Updated some while conditions with till (#100893)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 27 14:16:16 PDT 2024
Author: Hongyu Chen
Date: 2024-07-27T14:16:12-07:00
New Revision: f1a7d146e002e109ac8776c9ed7ddd078b6d4247
URL: https://github.com/llvm/llvm-project/commit/f1a7d146e002e109ac8776c9ed7ddd078b6d4247
DIFF: https://github.com/llvm/llvm-project/commit/f1a7d146e002e109ac8776c9ed7ddd078b6d4247.diff
LOG: [ELF] Updated some while conditions with till (#100893)
This change is based on
[commit](https://github.com/llvm/llvm-project/commit/b32c38ab5b4cf5c66469180ba3594e98eff2c124)
for a cleaner API usage. Thanks to @MaskRay !
Added:
Modified:
lld/ELF/ScriptParser.cpp
Removed:
################################################################################
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index a79a0b34892fc..b80db28764fd3 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -957,13 +957,15 @@ OutputDesc *ScriptParser::readOverlaySectionDescription() {
OutputDesc *osd = script->createOutputSection(next(), getCurrentLocation());
osd->osec.inOverlay = true;
expect("{");
- while (!errorCount() && !consume("}")) {
+ while (auto tok = till("}")) {
uint64_t withFlags = 0;
uint64_t withoutFlags = 0;
- if (consume("INPUT_SECTION_FLAGS"))
+ if (tok == "INPUT_SECTION_FLAGS") {
std::tie(withFlags, withoutFlags) = readInputSectionFlags();
+ tok = till("");
+ }
osd->osec.commands.push_back(
- readInputSectionRules(next(), withFlags, withoutFlags));
+ readInputSectionRules(tok, withFlags, withoutFlags));
}
osd->osec.phdrs = readOutputSectionPhdrs();
return osd;
@@ -1090,7 +1092,7 @@ SymbolAssignment *ScriptParser::readProvideHidden(bool provide, bool hidden) {
StringRef name = next(), eq = peek();
if (eq != "=") {
setError("= expected, but got " + next());
- while (!atEOF() && next() != ")")
+ while (till(")"))
;
return nullptr;
}
@@ -1731,15 +1733,11 @@ ScriptParser::readSymbols() {
SmallVector<SymbolVersion, 0> globals;
SmallVector<SymbolVersion, 0> *v = &globals;
- while (!errorCount()) {
- if (consume("}"))
- break;
-
- if (consume("extern")) {
+ while (auto tok = till("}")) {
+ if (tok == "extern") {
SmallVector<SymbolVersion, 0> ext = readVersionExtern();
v->insert(v->end(), ext.begin(), ext.end());
} else {
- StringRef tok = next();
if (tok == "local:" || (tok == "local" && consume(":"))) {
v = &locals;
continue;
More information about the llvm-commits
mailing list