diff options
| author | Paul Robinson <paul.robinson@sony.com> | 2019-03-01 20:58:04 +0000 |
|---|---|---|
| committer | Paul Robinson <paul.robinson@sony.com> | 2019-03-01 20:58:04 +0000 |
| commit | 1ca25763f07c7c4565fee66dd9fd5143d0c0d3b0 (patch) | |
| tree | b8a9717a562d0056b39b2f075fd652b6b1abe81e /llvm/lib/MC/MCParser/AsmParser.cpp | |
| parent | 3bbac856f993138444b2a5ca421d01ff46cbe77a (diff) | |
| download | bcm5719-llvm-1ca25763f07c7c4565fee66dd9fd5143d0c0d3b0.tar.gz bcm5719-llvm-1ca25763f07c7c4565fee66dd9fd5143d0c0d3b0.zip | |
[DWARF] Make -g with empty assembler source work better.
This was sometimes causing clang or llvm-mc to crash, and in other
cases could emit a bogus DWARF line-table header. I did an interim
patch in r352541; this patch should be a cleaner and more complete
fix, and retains the test.
Addresses PR40538.
Differential Revision: https://reviews.llvm.org/D58750
llvm-svn: 355226
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp')
| -rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index a66a4eb29af..4b487825935 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -845,9 +845,13 @@ bool AsmParser::enabledGenDwarfForAssembly() { // If we haven't encountered any .file directives (which would imply that // the assembler source was produced with debug info already) then emit one // describing the assembler source file itself. - if (getContext().getGenDwarfFileNumber() == 0) + if (getContext().getGenDwarfFileNumber() == 0) { + const MCDwarfFile &RootFile = + getContext().getMCDwarfLineTable(/*CUID=*/0).getRootFile(); getContext().setGenDwarfFileNumber(getStreamer().EmitDwarfFileDirective( - 0, StringRef(), getContext().getMainFileName())); + /*CUID=*/0, getContext().getCompilationDir(), RootFile.Name, + RootFile.Checksum, RootFile.Source)); + } return true; } @@ -900,9 +904,6 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { eatToEndOfStatement(); } - // Make sure we get proper DWARF even for empty files. - (void)enabledGenDwarfForAssembly(); - getTargetParser().onEndOfFile(); printPendingErrors(); |

