Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions lld/ELF/ScriptLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,18 +289,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 @@ -30,7 +30,6 @@ class ScriptLexer {
void skip();
bool consume(StringRef tok);
void expect(StringRef expect);
bool consumeLabel(StringRef tok);
std::string getCurrentLocation();
MemoryBufferRef getCurrentMB();

Expand Down
4 changes: 2 additions & 2 deletions lld/ELF/ScriptParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1692,11 +1692,11 @@ ScriptParser::readSymbols() {
while (!errorCount()) {
if (consume("}"))
break;
if (consumeLabel("local")) {
if (consume("local:") || (consume("local") && consume(":"))) {
v = &locals;
continue;
}
if (consumeLabel("global")) {
if (consume("global:") || (consume("global") && consume(":"))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check local: and global: below at StringRef tok = next();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I am confused here why we need check local: and global below StringRef tok = next(); ? if the lexer didn't consume global:, global : , local:, local : , or extern, we do not need do other things for the symbol right? Please correct me if I understand here wrong. Thank you!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Manually inline the two consumeLabel calls
  • Move the expanded body to below, just above next()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I committed the change but I think it's not what you were trying to say? If it is not could you please specify it more?

v = &globals;
continue;
}
Expand Down