[DWARF] Don't keep a ref to possibly stack allocated data.

llvm-svn: 335146
This commit is contained in:
Paul Robinson 2018-06-20 17:08:46 +00:00
parent 34b9112216
commit 8e3e374e5f
3 changed files with 11 additions and 9 deletions

View File

@ -213,7 +213,7 @@ struct MCDwarfLineTableHeader {
SmallVector<std::string, 3> MCDwarfDirs;
SmallVector<MCDwarfFile, 3> MCDwarfFiles;
StringMap<unsigned> SourceIdMap;
StringRef CompilationDir;
std::string CompilationDir;
MCDwarfFile RootFile;
bool HasSource = false;
private:

View File

@ -389,8 +389,8 @@ void MCDwarfLineTableHeader::emitV5FileDirTables(
: dwarf::DW_FORM_string);
MCOS->EmitULEB128IntValue(MCDwarfDirs.size() + 1);
// Try not to emit an empty compilation directory.
const StringRef &CompDir =
CompilationDir.empty() ? CtxCompilationDir : CompilationDir;
const StringRef CompDir =
CompilationDir.empty() ? CtxCompilationDir : StringRef(CompilationDir);
if (LineStr) {
// Record path strings, emit references here.
LineStr->emitRef(MCOS, CompDir);

View File

@ -3,18 +3,20 @@
# REQUIRES: default_triple
# Darwin is stuck on DWARF v2.
# XFAIL: darwin
.file 0 "root.cpp"
.file 1 "header.h"
.file 2 "root.cpp"
# CHECK-5: include_directories[ 0] = "{{.+}}"
# CHECK-4-NOT: include_directories
.file 0 "/test" "root.cpp"
.file 1 "/include" "header.h"
.file 2 "/test" "root.cpp"
# CHECK-5: include_directories[ 0] = "/test"
# CHECK-4-NOT: include_directories[ 0]
# CHECK: include_directories[ 1] = "/include"
# CHECK-NOT: include_directories
# CHECK-4-NOT: file_names[ 0]
# CHECK-5: file_names[ 0]:
# CHECK-5-NEXT: name: "root.cpp"
# CHECK-5-NEXT: dir_index: 0
# CHECK: file_names[ 1]:
# CHECK-NEXT: name: "header.h"
# CHECK-NEXT: dir_index: 0
# CHECK-NEXT: dir_index: 1
# CHECK: file_names[ 2]:
# CHECK-NEXT: name: "root.cpp"
# CHECK-NEXT: dir_index: 0