This patch is related to https://reviews.llvm.org/D29434, an attempt to fix bug 31813.
Currently the following case is not handled correctly:
{ global : local; local: *; };
Added look-ahead one more token to tell a variable named 'local' from a keyword 'local:'.
Details
Diff Detail
Event Timeline
ELF/LinkerScript.cpp | ||
---|---|---|
1999–2001 | This patch looks alright, but it substantially diverges from what we did here. | |
ELF/ScriptParser.cpp | ||
161 | Ditto. | |
ELF/ScriptParser.h | ||
31 | why size_t and not unsigned ? |
I think this is fine. We do have to improve the lexer, but it is not clear if we want the lexer to return a single token for "local :".
Rui, what do you think?
ELF/ScriptParser.h | ||
---|---|---|
31 | Why indeed... |
It is unfortunate that we change the grammar to LL(2) by this patch, but that's not necessarily a bad thing. We need to redesign the lexer as we had discussed in the linking Linux kernel thread, but until then, we need to improve this lexer.
ELF/ScriptParser.cpp | ||
---|---|---|
161–167 | Capitalize the variables. I think it is more natural to use a for loop here. for (size_t I = 0; I <= N; ++I) { Tok = next(); if (Error) return ""; } Pos = Pos - N - 1; (Note that ++I is more C++-ish than I++.) | |
ELF/ScriptParser.h | ||
31 | n -> N |
This patch looks alright, but it substantially diverges from what we did here.
In particular, we look ahead 2 tokens instead of one.
This is Rui's parser, so if he has no problems with that, I'm fine with it.