Merge readAt and readAlign.
Now that they are identical.
llvm-svn: 278953
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index fd2dfa2..4d8cec0 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -621,8 +621,6 @@
SortKind readSortKind();
SymbolAssignment *readProvideHidden(bool Provide, bool Hidden);
SymbolAssignment *readProvideOrAssignment(StringRef Tok);
- Expr readAt();
- Expr readAlign();
void readSort();
Expr readAssert();
@@ -630,6 +628,7 @@
Expr readExpr1(Expr Lhs, int MinPrec);
Expr readPrimary();
Expr readTernary(Expr Cond);
+ Expr readParenExpr();
const static StringMap<Handler> Cmd;
ScriptConfiguration &Opt = *ScriptConfig;
@@ -900,13 +899,6 @@
return readInputSectionRules();
}
-Expr ScriptParser::readAlign() {
- expect("(");
- Expr E = readExpr();
- expect(")");
- return E;
-}
-
void ScriptParser::readSort() {
expect("(");
expect("CONSTRUCTORS");
@@ -927,13 +919,6 @@
};
}
-Expr ScriptParser::readAt() {
- expect("(");
- Expr E = readExpr();
- expect(")");
- return E;
-}
-
OutputSectionCommand *
ScriptParser::readOutputSectionDescription(StringRef OutSec) {
OutputSectionCommand *Cmd = new OutputSectionCommand(OutSec);
@@ -946,10 +931,9 @@
expect(":");
if (skip("AT"))
- Cmd->LmaExpr = readAt();
-
+ Cmd->LmaExpr = readParenExpr();
if (skip("ALIGN"))
- Cmd->AlignExpr = readAlign();
+ Cmd->AlignExpr = readParenExpr();
// Parse constraints.
if (skip("ONLY_IF_RO"))
@@ -1166,22 +1150,17 @@
}
Expr ScriptParser::readPrimary() {
- StringRef Tok = next();
+ if (peek() == "(")
+ return readParenExpr();
- if (Tok == "(") {
- Expr E = readExpr();
- expect(")");
- return E;
- }
+ StringRef Tok = next();
// Built-in functions are parsed here.
// https://sourceware.org/binutils/docs/ld/Builtin-Functions.html.
if (Tok == "ASSERT")
return readAssert();
if (Tok == "ALIGN") {
- expect("(");
- Expr E = readExpr();
- expect(")");
+ Expr E = readParenExpr();
return [=](uint64_t Dot) { return alignTo(Dot, E(Dot)); };
}
if (Tok == "CONSTANT") {
@@ -1251,6 +1230,13 @@
return [=](uint64_t Dot) { return Cond(Dot) ? L(Dot) : R(Dot); };
}
+Expr ScriptParser::readParenExpr() {
+ expect("(");
+ Expr E = readExpr();
+ expect(")");
+ return E;
+}
+
std::vector<StringRef> ScriptParser::readOutputSectionPhdrs() {
std::vector<StringRef> Phdrs;
while (!Error && peek().startswith(":")) {