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 /clang/tools/driver/cc1as_main.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 'clang/tools/driver/cc1as_main.cpp')
-rw-r--r-- | clang/tools/driver/cc1as_main.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index 0a38e355c7a..a234ba3fc1b 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -336,7 +336,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, SourceMgr SrcMgr; // Tell SrcMgr about this buffer, which is what the parser will pick up. - SrcMgr.AddNewSourceBuffer(std::move(*Buffer), SMLoc()); + unsigned BufferIndex = SrcMgr.AddNewSourceBuffer(std::move(*Buffer), SMLoc()); // Record the location of the include directories so that the lexer can find // it later. @@ -393,12 +393,21 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, Ctx.setDwarfDebugProducer(StringRef(Opts.DwarfDebugProducer)); if (!Opts.DebugCompilationDir.empty()) Ctx.setCompilationDir(Opts.DebugCompilationDir); + else { + // If no compilation dir is set, try to use the current directory. + SmallString<128> CWD; + if (!sys::fs::current_path(CWD)) + Ctx.setCompilationDir(CWD); + } if (!Opts.DebugPrefixMap.empty()) for (const auto &KV : Opts.DebugPrefixMap) Ctx.addDebugPrefixMapEntry(KV.first, KV.second); if (!Opts.MainFileName.empty()) Ctx.setMainFileName(StringRef(Opts.MainFileName)); Ctx.setDwarfVersion(Opts.DwarfVersion); + if (Opts.GenDwarfForAssembly) + Ctx.setGenDwarfRootFile(Opts.InputFile, + SrcMgr.getMemoryBuffer(BufferIndex)->getBuffer()); // Build up the feature string from the target feature list. std::string FS; |