[PATCH] D22912: [ELF] - Linkerscript: implemented ASSERT() keyword.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 02:02:11 PDT 2016


grimar added inline comments.

================
Comment at: ELF/LinkerScript.cpp:675-676
@@ -665,1 +674,4 @@
   while (!Error && !skip("}")) {
+    if (peek() == "ASSERT") {
+      Opt.Commands.emplace_back(new AssertCommand(readExpr()));
+      continue;
----------------
ruiu wrote:
> Is this correct? I mean, you didn't consume the token "ASSERT", so readExpr() will read "ASSERT" as an expression, no?
Initially I did it to reuse new code from below:

```
  if (Tok == "ASSERT") {
    expect("(");
    Expr E = readExpr();
    expect(",");
    StringRef Msg = next();
    expect(")");
    return [=](uint64_t Dot) {
      uint64_t V = E(Dot);
      if (!V)
        error(Msg);
      return V;
    };
  }
```

But you right, it was not 100% correct as probably allowed things like
ASSERT(...) + 55;
And there is a better way to achieve the same. I changed that.



https://reviews.llvm.org/D22912





More information about the llvm-commits mailing list