[PATCH] D22625: [ELF] Support PROVIDE and PROVIDE_HIDDEN within SECTIONS {} block

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 12:35:04 PDT 2016


ruiu added inline comments.

================
Comment at: ELF/LinkerScript.cpp:450-451
@@ -450,3 +449,4 @@
 template <class ELFT> void LinkerScript<ELFT>::addScriptedSymbols() {
   for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands)
     if (auto *Cmd = dyn_cast<SymbolAssignment>(Base.get()))
+      if (Cmd->Name != ".") {
----------------
Negate the condition to reduce the indentation level.

  auto *Cmd = dyn_cast<...>(...);
  if (!Cmd || Cmd->Name == ".")
    continue;


================
Comment at: ELF/LinkerScript.cpp:795
@@ -773,3 +794,3 @@
     error("error in symbol assignment expression");
-  else
+  else {
     Opt.Commands.push_back(llvm::make_unique<SymbolAssignment>(Name, Expr));
----------------
When you add `{` please add {} to the previous if (or else) clauses, so that they look the same.

================
Comment at: ELF/LinkerScript.cpp:803-811
@@ -778,5 +802,11 @@
 std::vector<StringRef> ScriptParser::readSectionsCommandExpr() {
+  int Braces = 0;
   std::vector<StringRef> Expr;
   while (!Error) {
-    StringRef Tok = next();
+    StringRef Tok = peek();
+    Braces += (Tok == "(");
+    Braces -= (Tok == ")");
+    if (Braces < 0)
+      break;
+    next();
     if (Tok == ";")
----------------
Can you remove it?


Repository:
  rL LLVM

https://reviews.llvm.org/D22625





More information about the llvm-commits mailing list