OSDN Git Service

[DWARF] Don't keep a ref to possibly stack allocated data.
authorPaul Robinson <paul.robinson@sony.com>
Wed, 20 Jun 2018 17:08:46 +0000 (17:08 +0000)
committerPaul Robinson <paul.robinson@sony.com>
Wed, 20 Jun 2018 17:08:46 +0000 (17:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335146 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCDwarf.h
lib/MC/MCDwarf.cpp
test/MC/ELF/dwarf-file0.s

index 6b9e55b..30baf5d 100644 (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:
index e7c805d..37e1263 100644 (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);
index 49e1208..38a8940 100644 (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