[lld] [ELF] ScriptLexer: generate tokens lazily (PR #100493)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 17:35:48 PDT 2024


================
@@ -123,45 +128,52 @@ void ScriptLexer::tokenize(MemoryBufferRef mb) {
     if (s.starts_with("\"")) {
       size_t e = s.find("\"", 1);
       if (e == StringRef::npos) {
-        StringRef filename = mb.getBufferIdentifier();
         size_t lineno = begin.substr(0, s.data() - begin.data()).count('\n');
----------------
MaskRay wrote:

Thanks for catching this. I added `Buffer::begin` and added a test `unquote.test` to catch the issue.

Eventually the lexer should track line number and fix the performance issue  https://reviews.llvm.org/D104137 , but that will be a future change.

https://github.com/llvm/llvm-project/pull/100493


More information about the llvm-commits mailing list