[lld] [lld][ELF] remove `consumeLabel` in ScriptLexer (PR #99567)
Hongyu Chen via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 20 16:39:00 PDT 2024
https://github.com/yugier updated https://github.com/llvm/llvm-project/pull/99567
>From 7b33db99581a3a9fcf60bf2b67ba8e6bd6092d7c Mon Sep 17 00:00:00 2001
From: Hongyu Chen <hongyuchy at google.com>
Date: Thu, 18 Jul 2024 19:19:55 +0000
Subject: [PATCH] [lld][ELF] remove `consumeLabel` in ScriptLexer
This commit removes `consumeLabel` since we can just use consume
function to have the same functionalities.
---
lld/ELF/ScriptLexer.cpp | 12 ------------
lld/ELF/ScriptLexer.h | 1 -
lld/ELF/ScriptParser.cpp | 4 ++--
3 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/lld/ELF/ScriptLexer.cpp b/lld/ELF/ScriptLexer.cpp
index 14f39ed10e17c..5ac1c15043ce6 100644
--- a/lld/ELF/ScriptLexer.cpp
+++ b/lld/ELF/ScriptLexer.cpp
@@ -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) {
diff --git a/lld/ELF/ScriptLexer.h b/lld/ELF/ScriptLexer.h
index 7919e493fa28b..b4d2ab8627a91 100644
--- a/lld/ELF/ScriptLexer.h
+++ b/lld/ELF/ScriptLexer.h
@@ -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();
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index db46263115242..830c4f315a5a8 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -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(":"))) {
v = &globals;
continue;
}
More information about the llvm-commits
mailing list