[lld] r276575 - Merge readSymbolAssignment with readAssignment. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 24 16:05:59 PDT 2016
Author: ruiu
Date: Sun Jul 24 18:05:57 2016
New Revision: 276575
URL: http://llvm.org/viewvc/llvm-project?rev=276575&view=rev
Log:
Merge readSymbolAssignment with readAssignment. NFC.
Modified:
lld/trunk/ELF/LinkerScript.cpp
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=276575&r1=276574&r2=276575&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sun Jul 24 18:05:57 2016
@@ -415,12 +415,11 @@ private:
void readSearchDir();
void readSections();
- void readAssignment();
+ SymbolAssignment *readAssignment(StringRef Name);
void readOutputSectionDescription(StringRef OutSec);
std::vector<StringRef> readOutputSectionPhdrs();
unsigned readPhdrType();
void readProvide(bool Hidden);
- SymbolAssignment *readSymbolAssignment(StringRef Name);
Expr readExpr();
Expr readExpr1(Expr Lhs, int MinPrec);
@@ -616,19 +615,14 @@ void ScriptParser::readSections() {
Opt.DoLayout = true;
expect("{");
while (!Error && !skip("}")) {
- StringRef Tok = peek();
- if (Tok == ".") {
- readAssignment();
- continue;
- }
- next();
- if (Tok == "PROVIDE") {
+ StringRef Tok = next();
+ if (peek() == "=") {
+ readAssignment(Tok);
+ expect(";");
+ } else if (Tok == "PROVIDE") {
readProvide(false);
} else if (Tok == "PROVIDE_HIDDEN") {
readProvide(true);
- } else if (peek() == "=") {
- readSymbolAssignment(Tok);
- expect(";");
} else {
readOutputSectionDescription(Tok);
}
@@ -651,14 +645,6 @@ static int precedence(StringRef Op) {
.Default(-1);
}
-void ScriptParser::readAssignment() {
- expect(".");
- expect("=");
- Expr E = readExpr();
- expect(";");
- Opt.Commands.push_back(llvm::make_unique<SymbolAssignment>(".", E));
-}
-
void ScriptParser::readOutputSectionDescription(StringRef OutSec) {
OutputSectionCommand *Cmd = new OutputSectionCommand(OutSec);
Opt.Commands.emplace_back(Cmd);
@@ -710,7 +696,7 @@ void ScriptParser::readOutputSectionDesc
void ScriptParser::readProvide(bool Hidden) {
expect("(");
- if (SymbolAssignment *Assignment = readSymbolAssignment(next())) {
+ if (SymbolAssignment *Assignment = readAssignment(next())) {
Assignment->Provide = true;
Assignment->Hidden = Hidden;
}
@@ -718,11 +704,12 @@ void ScriptParser::readProvide(bool Hidd
expect(";");
}
-SymbolAssignment *ScriptParser::readSymbolAssignment(StringRef Name) {
+SymbolAssignment *ScriptParser::readAssignment(StringRef Name) {
expect("=");
Expr E = readExpr();
- Opt.Commands.push_back(llvm::make_unique<SymbolAssignment>(Name, E));
- return static_cast<SymbolAssignment *>(Opt.Commands.back().get());
+ auto *Cmd = new SymbolAssignment(Name, E);
+ Opt.Commands.emplace_back(Cmd);
+ return Cmd;
}
// This is an operator-precedence parser to parse a linker
More information about the llvm-commits
mailing list