[PATCH] [lld] Teach LLD how to parse complete linker scripts

Sean Silva chisophugis at gmail.com
Mon Oct 27 13:55:47 PDT 2014


A couple nits, but I agree with Rui that this is good to land.

================
Comment at: lib/ReaderWriter/LinkerScript.cpp:586-592
@@ +585,9 @@
+  os << _name << "(";
+  if (unsigned e = _args.size()) {
+    _args[0]->dump(os);
+    for (unsigned i = 1; i != e; ++i) {
+      os << ", ";
+      _args[i]->dump(os);
+    }
+  }
+  os << ")";
----------------
fwiw, my favorite pattern for doing this "intersperse with commas" operation is:

```
for (int i = 0, e = _args.size(); i != e; ++i) {
  if (i)
    os << ", ";
  _args[i]->dump(os);
}
```

It's a bit cleaner than the pattern you're currently using.

================
Comment at: lib/ReaderWriter/LinkerScript.cpp:1617-1621
@@ +1616,7 @@
+      consumeToken();
+      if (numParen) {
+        while (numParen--)
+          if (!expectAndConsume(Token::r_paren, "expected )"))
+            return nullptr;
+      }
+    }
----------------
You use this simpler pattern elsewhere:

```
for (int i = 0; i != numParen; ++i)
  if (!expectAndConsume(Token::r_paren, "expected )"))
    return nullptr;
```

also, just above you use this more complicated if-while pattern.

http://reviews.llvm.org/D5852






More information about the llvm-commits mailing list