Skip to content

Commit

Permalink
[ELF] Remove consumeLabel in ScriptLexer (#99567)
Browse files Browse the repository at this point in the history
This commit removes `consumeLabel` since we can just use consume
function to have the same functionalities.
  • Loading branch information
hongyu-dev authored Jul 24, 2024
1 parent 6461e53 commit 2ae862b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
12 changes: 0 additions & 12 deletions lld/ELF/ScriptLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,18 +279,6 @@ bool ScriptLexer::consume(StringRef tok) {
return false;
}

// Consumes Tok followed by ":". Space is allowed between Tok and ":".
bool ScriptLexer::consumeLabel(StringRef tok) {
if (consume((tok + ":").str()))
return true;
if (tokens.size() >= pos + 2 && tokens[pos] == tok &&
tokens[pos + 1] == ":") {
pos += 2;
return true;
}
return false;
}

void ScriptLexer::skip() { (void)next(); }

void ScriptLexer::expect(StringRef expect) {
Expand Down
1 change: 0 additions & 1 deletion lld/ELF/ScriptLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class ScriptLexer {
void skip();
bool consume(StringRef tok);
void expect(StringRef expect);
bool consumeLabel(StringRef tok);
std::string getCurrentLocation();
MemoryBufferRef getCurrentMB();

Expand Down
16 changes: 8 additions & 8 deletions lld/ELF/ScriptParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1719,20 +1719,20 @@ ScriptParser::readSymbols() {
while (!errorCount()) {
if (consume("}"))
break;
if (consumeLabel("local")) {
v = &locals;
continue;
}
if (consumeLabel("global")) {
v = &globals;
continue;
}

if (consume("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;
}
if (tok == "global:" || (tok == "global" && consume(":"))) {
v = &globals;
continue;
}
v->push_back({unquote(tok), false, hasWildcard(tok)});
}
expect(";");
Expand Down

0 comments on commit 2ae862b

Please sign in to comment.