summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/MC/MCDwarf.h2
-rw-r--r--llvm/lib/MC/MCDwarf.cpp4
-rw-r--r--llvm/test/MC/ELF/dwarf-file0.s14
3 files changed, 11 insertions, 9 deletions
diff --git a/llvm/include/llvm/MC/MCDwarf.h b/llvm/include/llvm/MC/MCDwarf.h
index 6b9e55b2b92..30baf5d83b1 100644
--- a/llvm/include/llvm/MC/MCDwarf.h
+++ b/llvm/include/llvm/MC/MCDwarf.h
@@ -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:
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index e7c805da9a9..37e1263be65 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -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);
diff --git a/llvm/test/MC/ELF/dwarf-file0.s b/llvm/test/MC/ELF/dwarf-file0.s
index 49e120894e4..38a89405e5a 100644
--- a/llvm/test/MC/ELF/dwarf-file0.s
+++ b/llvm/test/MC/ELF/dwarf-file0.s
@@ -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
OpenPOWER on IntegriCloud