MCDwarf: Oh, and move the directory string over to std::string as well
authorDavid Blaikie <dblaikie@gmail.com>
Thu, 13 Mar 2014 19:05:33 +0000 (19:05 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Thu, 13 Mar 2014 19:05:33 +0000 (19:05 +0000)
(see r203831 for similar stuff)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203833 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCContext.h
include/llvm/MC/MCDwarf.h
lib/MC/MCContext.cpp
lib/MC/MCDwarf.cpp

index 86578cc419c641e3f26d10d6e7e16ab67fbd075e..0183cfa79e67eec29e6c0b4648fd1794ee76cbc0 100644 (file)
@@ -325,7 +325,7 @@ namespace llvm {
     const SmallVectorImpl<MCDwarfFile> &getMCDwarfFiles(unsigned CUID = 0) {
       return getMCDwarfFileTable(CUID).getMCDwarfFiles();
     }
-    const SmallVectorImpl<StringRef> &getMCDwarfDirs(unsigned CUID = 0) {
+    const SmallVectorImpl<std::string> &getMCDwarfDirs(unsigned CUID = 0) {
       return getMCDwarfFileTable(CUID).getMCDwarfDirs();
     }
 
index 6ad26c4721b60fb947c14a8742eb7d8d1f0a2be6..b6998c590d6b6664e070869e6e93e6cb5da4076d 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include <map>
 #include <vector>
+#include <string>
 
 namespace llvm {
 class MCAsmBackend;
@@ -175,7 +176,7 @@ public:
 
 class MCDwarfFileTable {
   MCSymbol *Label;
-  SmallVector<StringRef, 3> MCDwarfDirs;
+  SmallVector<std::string, 3> MCDwarfDirs;
   SmallVector<MCDwarfFile, 3> MCDwarfFiles;
   MCLineSection MCLineSections;
 
@@ -189,11 +190,11 @@ public:
   //
   const MCSymbol *EmitCU(MCStreamer *MCOS) const;
 
-  const SmallVectorImpl<StringRef> &getMCDwarfDirs() const {
+  const SmallVectorImpl<std::string> &getMCDwarfDirs() const {
     return MCDwarfDirs;
   }
 
-  SmallVectorImpl<StringRef> &getMCDwarfDirs() {
+  SmallVectorImpl<std::string> &getMCDwarfDirs() {
     return MCDwarfDirs;
   }
 
index 3c8de997124d950e8b9f4eeedea6bff76dc08f18..48cb5aae1fbad89351ebca1769d32a70dafe4155 100644 (file)
@@ -339,7 +339,7 @@ unsigned MCContext::GetDwarfFile(StringRef Directory, StringRef FileName,
                                  unsigned FileNumber, unsigned CUID) {
   MCDwarfFileTable &Table = MCDwarfFileTablesCUMap[CUID];
   SmallVectorImpl<MCDwarfFile>& MCDwarfFiles = Table.getMCDwarfFiles();
-  SmallVectorImpl<StringRef>& MCDwarfDirs = Table.getMCDwarfDirs();
+  SmallVectorImpl<std::string>& MCDwarfDirs = Table.getMCDwarfDirs();
   // Make space for this FileNumber in the MCDwarfFiles vector if needed.
   if (FileNumber >= MCDwarfFiles.size()) {
     MCDwarfFiles.resize(FileNumber + 1);
@@ -374,11 +374,8 @@ unsigned MCContext::GetDwarfFile(StringRef Directory, StringRef FileName,
       if (Directory == MCDwarfDirs[DirIndex])
         break;
     }
-    if (DirIndex >= MCDwarfDirs.size()) {
-      char *Buf = static_cast<char *>(Allocate(Directory.size()));
-      memcpy(Buf, Directory.data(), Directory.size());
-      MCDwarfDirs.push_back(StringRef(Buf, Directory.size()));
-    }
+    if (DirIndex >= MCDwarfDirs.size())
+      MCDwarfDirs.push_back(Directory);
     // The DirIndex is one based, as DirIndex of 0 is used for FileNames with
     // no directories.  MCDwarfDirs[] is unlike MCDwarfFiles[] in that the
     // directory names are stored at MCDwarfDirs[DirIndex-1] where FileNames
index 2c1874f5e91436b9ff561b11fd372ff8602316b3..b0a75d5de20600fcb6218eca9e15e5145a7e2362 100644 (file)
@@ -596,8 +596,7 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
 
   // AT_name, the name of the source file.  Reconstruct from the first directory
   // and file table entries.
-  const SmallVectorImpl<StringRef> &MCDwarfDirs =
-    context.getMCDwarfDirs();
+  const SmallVectorImpl<std::string> &MCDwarfDirs = context.getMCDwarfDirs();
   if (MCDwarfDirs.size() > 0) {
     MCOS->EmitBytes(MCDwarfDirs[0]);
     MCOS->EmitBytes("/");