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

Rafael Auler rafaelauler at gmail.com
Mon Oct 27 18:59:13 PDT 2014


Thanks Sean and Rui for your code review.

================
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 << ")";
----------------
silvas wrote:
> 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.
Nice one, will use it.

================
Comment at: lib/ReaderWriter/LinkerScript.cpp:1617-1621
@@ +1616,7 @@
+      consumeToken();
+      if (numParen) {
+        while (numParen--)
+          if (!expectAndConsume(Token::r_paren, "expected )"))
+            return nullptr;
+      }
+    }
----------------
silvas wrote:
> 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.
Makes sense, I will change this code to use the simpler pattern

http://reviews.llvm.org/D5852






More information about the llvm-commits mailing list