diff --git a/lld/ELF/ScriptLexer.cpp b/lld/ELF/ScriptLexer.cpp index c8c02ab0f3e09..65055086d6bc2 100644 --- a/lld/ELF/ScriptLexer.cpp +++ b/lld/ELF/ScriptLexer.cpp @@ -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) { diff --git a/lld/ELF/ScriptLexer.h b/lld/ELF/ScriptLexer.h index d5393818ed553..7d945d8f570c3 100644 --- a/lld/ELF/ScriptLexer.h +++ b/lld/ELF/ScriptLexer.h @@ -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(); diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 49aa7e6374905..8637a8b0b2167 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -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 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(";");