[lld] r278953 - Merge readAt and readAlign.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 11:59:16 PDT 2016


Author: ruiu
Date: Wed Aug 17 13:59:16 2016
New Revision: 278953

URL: http://llvm.org/viewvc/llvm-project?rev=278953&view=rev
Log:
Merge readAt and readAlign.

Now that they are identical.

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=278953&r1=278952&r2=278953&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Aug 17 13:59:16 2016
@@ -621,8 +621,6 @@ private:
   SortKind readSortKind();
   SymbolAssignment *readProvideHidden(bool Provide, bool Hidden);
   SymbolAssignment *readProvideOrAssignment(StringRef Tok);
-  Expr readAt();
-  Expr readAlign();
   void readSort();
   Expr readAssert();
 
@@ -630,6 +628,7 @@ private:
   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 @@ InputSectionDescription *ScriptParser::r
   return readInputSectionRules();
 }
 
-Expr ScriptParser::readAlign() {
-  expect("(");
-  Expr E = readExpr();
-  expect(")");
-  return E;
-}
-
 void ScriptParser::readSort() {
   expect("(");
   expect("CONSTRUCTORS");
@@ -927,13 +919,6 @@ Expr ScriptParser::readAssert() {
   };
 }
 
-Expr ScriptParser::readAt() {
-  expect("(");
-  Expr E = readExpr();
-  expect(")");
-  return E;
-}
-
 OutputSectionCommand *
 ScriptParser::readOutputSectionDescription(StringRef OutSec) {
   OutputSectionCommand *Cmd = new OutputSectionCommand(OutSec);
@@ -946,10 +931,9 @@ ScriptParser::readOutputSectionDescripti
   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 @@ uint64_t static getConstant(StringRef S)
 }
 
 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 @@ Expr ScriptParser::readTernary(Expr Cond
   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(":")) {




More information about the llvm-commits mailing list