[PATCH] D24128: [ELF] PR30221 - linker script expression parser does not accept '~'

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 14:54:23 PDT 2016


ruiu added inline comments.

================
Comment at: ELF/LinkerScript.cpp:1236
@@ +1235,3 @@
+static bool readNumber(StringRef Tok, uint64_t &V) {
+  if (Tok.startswith("-"))
+    return Tok.getAsInteger(0, (int64_t &)V);
----------------
ruiu wrote:
> I think you want to fix the tokenizer (`tokenize` in ScritpParser.cpp) instead of handling `-<number>` in this file. Currently, `-` is allowed to be part of a token, but it is not correct. For example, with that tokenizer, an expression `3-1` is tokenized as `3-1` instead of `3`, `-` and `1`.
> 
> I think the only token that can contain `-` as part of it is `-=`. In all other cases, `-` shouldn't stick with adjacent characters.
> 
> Because we do not support `-=` yet, we don't care about that. So why don't you remove `-` from tokenize()?
I was wrong. `-` is allowed to be in a filename as well as `-l<library>` notation. So `-` can be part of a token. I think I'm fine with this new function.


Repository:
  rL LLVM

https://reviews.llvm.org/D24128





More information about the llvm-commits mailing list