Skip to content

Commit 2ae862b

Browse files
authored
[ELF] Remove consumeLabel in ScriptLexer (#99567)
This commit removes `consumeLabel` since we can just use consume function to have the same functionalities.
1 parent 6461e53 commit 2ae862b

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

lld/ELF/ScriptLexer.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,6 @@ bool ScriptLexer::consume(StringRef tok) {
279279
return false;
280280
}
281281

282-
// Consumes Tok followed by ":". Space is allowed between Tok and ":".
283-
bool ScriptLexer::consumeLabel(StringRef tok) {
284-
if (consume((tok + ":").str()))
285-
return true;
286-
if (tokens.size() >= pos + 2 && tokens[pos] == tok &&
287-
tokens[pos + 1] == ":") {
288-
pos += 2;
289-
return true;
290-
}
291-
return false;
292-
}
293-
294282
void ScriptLexer::skip() { (void)next(); }
295283

296284
void ScriptLexer::expect(StringRef expect) {

lld/ELF/ScriptLexer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class ScriptLexer {
2929
void skip();
3030
bool consume(StringRef tok);
3131
void expect(StringRef expect);
32-
bool consumeLabel(StringRef tok);
3332
std::string getCurrentLocation();
3433
MemoryBufferRef getCurrentMB();
3534

lld/ELF/ScriptParser.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,20 +1719,20 @@ ScriptParser::readSymbols() {
17191719
while (!errorCount()) {
17201720
if (consume("}"))
17211721
break;
1722-
if (consumeLabel("local")) {
1723-
v = &locals;
1724-
continue;
1725-
}
1726-
if (consumeLabel("global")) {
1727-
v = &globals;
1728-
continue;
1729-
}
17301722

17311723
if (consume("extern")) {
17321724
SmallVector<SymbolVersion, 0> ext = readVersionExtern();
17331725
v->insert(v->end(), ext.begin(), ext.end());
17341726
} else {
17351727
StringRef tok = next();
1728+
if (tok == "local:" || (tok == "local" && consume(":"))) {
1729+
v = &locals;
1730+
continue;
1731+
}
1732+
if (tok == "global:" || (tok == "global" && consume(":"))) {
1733+
v = &globals;
1734+
continue;
1735+
}
17361736
v->push_back({unquote(tok), false, hasWildcard(tok)});
17371737
}
17381738
expect(";");

0 commit comments

Comments
 (0)