Compiling assembly files when newlines are reduced to line markers within a .macro context will generate wrong information in .debug_line section.
This patch fixes this issue by evaluating line markers within the macro scope but not when they are used and evaluated.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
llvm/lib/MC/MCParser/AsmParser.cpp | ||
---|---|---|
1706 | Is there code inside parseCppHashLineFilenameComment that could be hoisted out in a separate function that could be used here? If not, maybe you could create a function anyway which would make the code here smaller and more obvious. Might be nice having in the heading comment for that function the format of a line marker: # linenum filename flags. I don't know if it's customary to refer to documentation for a format when it's an online page, but if it is you could mention https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html in that heading comment. |
llvm/lib/MC/MCParser/AsmParser.cpp | ||
---|---|---|
1706 | parseCppHashLineFilenameComment() also calls Lex() 3 times but saves the content in the process. In here, we just want to skip it. I felt it wasn't worth to hoist out in a separate function (that in this case would simply discard token contents) and it's unlikely for this to repeat elsewhere... I would say to keep it like this (maybe) but let us wait for other reviewers. |
llvm/lib/MC/MCParser/AsmParser.cpp | ||
---|---|---|
1706 | I think that having a parameter to parseCppHashLineFilenameComment that indicates if the location should be preserved would be simple to add and avoid the duplication. We could default to to true and avoid altering the existing callers. |
llvm/lib/MC/MCParser/AsmParser.cpp | ||
---|---|---|
1702–1704 | You shouldn't need to change this with the default value. |
llvm/lib/MC/MCParser/AsmParser.cpp | ||
---|---|---|
1702–1704 | Oh my bad, I misread what was happening. Please disregard. |
Without this patch, I'm seeing line 109 reported, which makes no sense at all. The test shows with the patch we get line 105, which in effect means that the line directive is processed as if it was not inside a macro definition; that makes some sense.
LGTM
You shouldn't need to change this with the default value.