diff options
author | Hongyu Chen <hongyc4@uci.edu> | 2024-07-20 16:35:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-20 16:35:38 -0700 |
commit | b828c13f3ceb336bf517fab0223b966ccace100e (patch) | |
tree | 604c02459adcb51d7520c3b2520a2198e9fd0c65 /lld/ELF/ScriptParser.cpp | |
parent | ba9b5ff4f745b2c604e13656cdca0e66835dc99a (diff) | |
download | llvm-b828c13f3ceb336bf517fab0223b966ccace100e.zip llvm-b828c13f3ceb336bf517fab0223b966ccace100e.tar.gz llvm-b828c13f3ceb336bf517fab0223b966ccace100e.tar.bz2 |
[ELF] Delete peek2 in Lexer (#99790)
Thanks to Fangrui's change
https://github.com/llvm/llvm-project/commit/28045ceab08d41a8a42d93ebc445e8fe906f884c
so peek2 can be removed.
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index f20de5e..49aa7e6 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -92,7 +92,7 @@ private: SymbolAssignment *readSymbolAssignment(StringRef name); ByteCommand *readByteCommand(StringRef tok); std::array<uint8_t, 4> readFill(); - bool readSectionDirective(OutputSection *cmd, StringRef tok2); + bool readSectionDirective(OutputSection *cmd, StringRef tok); void readSectionAddressType(OutputSection *cmd); OutputDesc *readOverlaySectionDescription(); OutputDesc *readOutputSectionDescription(StringRef outSec); @@ -873,14 +873,11 @@ constexpr std::pair<const char *, unsigned> typeMap[] = { // Tries to read the special directive for an output section definition which // can be one of following: "(NOLOAD)", "(COPY)", "(INFO)", "(OVERLAY)", and // "(TYPE=<value>)". -// Tok1 and Tok2 are next 2 tokens peeked. See comment for -// readSectionAddressType below. -bool ScriptParser::readSectionDirective(OutputSection *cmd, StringRef tok2) { - if (tok2 != "NOLOAD" && tok2 != "COPY" && tok2 != "INFO" && - tok2 != "OVERLAY" && tok2 != "TYPE") +bool ScriptParser::readSectionDirective(OutputSection *cmd, StringRef tok) { + if (tok != "NOLOAD" && tok != "COPY" && tok != "INFO" && tok != "OVERLAY" && + tok != "TYPE") return false; - expect("("); if (consume("NOLOAD")) { cmd->type = SHT_NOBITS; cmd->typeIsSet = true; @@ -919,19 +916,22 @@ bool ScriptParser::readSectionDirective(OutputSection *cmd, StringRef tok2) { // https://sourceware.org/binutils/docs/ld/Output-Section-Address.html // https://sourceware.org/binutils/docs/ld/Output-Section-Type.html void ScriptParser::readSectionAddressType(OutputSection *cmd) { - if (peek() == "(") { + if (consume("(")) { // Temporarily set inExpr to support TYPE=<value> without spaces. SaveAndRestore saved(inExpr, true); - if (readSectionDirective(cmd, peek2())) + if (readSectionDirective(cmd, peek())) return; + cmd->addrExpr = readExpr(); + expect(")"); + } else { + cmd->addrExpr = readExpr(); } - cmd->addrExpr = readExpr(); - if (peek() == "(") { + if (consume("(")) { SaveAndRestore saved(inExpr, true); - StringRef tok2 = peek2(); - if (!readSectionDirective(cmd, tok2)) - setError("unknown section directive: " + tok2); + StringRef tok = peek(); + if (!readSectionDirective(cmd, tok)) + setError("unknown section directive: " + tok); } } |