[llvm] r203827 - MCDwarf: Simply MCDwarfFile since it really is just a StringRef and unsigned.

David Blaikie dblaikie at gmail.com
Thu Mar 13 11:21:24 PDT 2014


Author: dblaikie
Date: Thu Mar 13 13:21:24 2014
New Revision: 203827

URL: http://llvm.org/viewvc/llvm-project?rev=203827&view=rev
Log:
MCDwarf: Simply MCDwarfFile since it really is just a StringRef and unsigned.

Modified:
    llvm/trunk/include/llvm/MC/MCContext.h
    llvm/trunk/include/llvm/MC/MCDwarf.h
    llvm/trunk/lib/MC/MCContext.cpp
    llvm/trunk/lib/MC/MCDwarf.cpp
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp

Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=203827&r1=203826&r2=203827&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Thu Mar 13 13:21:24 2014
@@ -28,7 +28,7 @@ namespace llvm {
   class MCSection;
   class MCSymbol;
   class MCLabel;
-  class MCDwarfFile;
+  struct MCDwarfFile;
   class MCDwarfLoc;
   class MCObjectFileInfo;
   class MCRegisterInfo;

Modified: llvm/trunk/include/llvm/MC/MCDwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=203827&r1=203826&r2=203827&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCDwarf.h (original)
+++ llvm/trunk/include/llvm/MC/MCDwarf.h Thu Mar 13 13:21:24 2014
@@ -37,41 +37,15 @@ class SMLoc;
 /// and MCDwarfFile's are created and unique'd by the MCContext class where
 /// the file number for each is its index into the vector of DwarfFiles (note
 /// index 0 is not used and not a valid dwarf file number).
-class MCDwarfFile {
+struct MCDwarfFile {
   // Name - the base name of the file without its directory path.
   // The StringRef references memory allocated in the MCContext.
   StringRef Name;
 
   // DirIndex - the index into the list of directory names for this file name.
   unsigned DirIndex;
-
-private: // MCContext creates and uniques these.
-  friend class MCContext;
-  MCDwarfFile(StringRef name, unsigned dirIndex)
-      : Name(name), DirIndex(dirIndex) {}
-
-  MCDwarfFile(const MCDwarfFile &) LLVM_DELETED_FUNCTION;
-  void operator=(const MCDwarfFile &) LLVM_DELETED_FUNCTION;
-
-public:
-  /// getName - Get the base name of this MCDwarfFile.
-  StringRef getName() const { return Name; }
-
-  /// getDirIndex - Get the dirIndex of this MCDwarfFile.
-  unsigned getDirIndex() const { return DirIndex; }
-
-  /// print - Print the value to the stream \p OS.
-  void print(raw_ostream &OS) const;
-
-  /// dump - Print the value to stderr.
-  void dump() const;
 };
 
-inline raw_ostream &operator<<(raw_ostream &OS, const MCDwarfFile &DwarfFile) {
-  DwarfFile.print(OS);
-  return OS;
-}
-
 /// MCDwarfLoc - Instances of this class represent the information from a
 /// dwarf .loc directive.
 class MCDwarfLoc {

Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=203827&r1=203826&r2=203827&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Thu Mar 13 13:21:24 2014
@@ -391,7 +391,9 @@ unsigned MCContext::GetDwarfFile(StringR
   // vector.
   char *Buf = static_cast<char *>(Allocate(FileName.size()));
   memcpy(Buf, FileName.data(), FileName.size());
-  File = new (*this) MCDwarfFile(StringRef(Buf, FileName.size()), DirIndex);
+  File = new (*this) MCDwarfFile;
+  File->Name = StringRef(Buf, FileName.size());
+  File->DirIndex = DirIndex;
 
   // return the allocated FileNumber.
   return FileNumber;

Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=203827&r1=203826&r2=203827&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Mar 13 13:21:24 2014
@@ -289,10 +289,10 @@ const MCSymbol *MCDwarfFileTable::EmitCU
 
   // Second the file table.
   for (unsigned i = 1; i < MCDwarfFiles.size(); i++) {
-    MCOS->EmitBytes(MCDwarfFiles[i]->getName()); // FileName
+    MCOS->EmitBytes(MCDwarfFiles[i]->Name); // FileName
     MCOS->EmitBytes(StringRef("\0", 1)); // the null term. of the string
     // the Directory num
-    MCOS->EmitULEB128IntValue(MCDwarfFiles[i]->getDirIndex());
+    MCOS->EmitULEB128IntValue(MCDwarfFiles[i]->DirIndex);
     MCOS->EmitIntValue(0, 1); // last modification timestamp (always 0)
     MCOS->EmitIntValue(0, 1); // filesize (always 0)
   }
@@ -411,16 +411,6 @@ void MCDwarfLineAddr::Encode(MCContext &
     OS << char(Temp);
 }
 
-void MCDwarfFile::print(raw_ostream &OS) const {
-  OS << '"' << getName() << '"';
-}
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-void MCDwarfFile::dump() const {
-  print(dbgs());
-}
-#endif
-
 // Utility function to write a tuple for .debug_abbrev.
 static void EmitAbbrev(MCStreamer *MCOS, uint64_t Name, uint64_t Form) {
   MCOS->EmitULEB128IntValue(Name);
@@ -614,7 +604,7 @@ static void EmitGenDwarfInfo(MCStreamer
   }
   const SmallVectorImpl<MCDwarfFile *> &MCDwarfFiles =
     MCOS->getContext().getMCDwarfFiles();
-  MCOS->EmitBytes(MCDwarfFiles[1]->getName());
+  MCOS->EmitBytes(MCDwarfFiles[1]->Name);
   MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string.
 
   // AT_comp_dir, the working directory the assembly was done in.

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=203827&r1=203826&r2=203827&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Thu Mar 13 13:21:24 2014
@@ -1592,7 +1592,7 @@ bool AsmParser::parseStatement(ParseStat
     const SmallVectorImpl<MCDwarfFile *> &MCDwarfFiles =
         getContext().getMCDwarfFiles();
     if (CppHashFilename.size() != 0) {
-      if (MCDwarfFiles[getContext().getGenDwarfFileNumber()]->getName() !=
+      if (MCDwarfFiles[getContext().getGenDwarfFileNumber()]->Name !=
           CppHashFilename)
         getStreamer().EmitDwarfFileDirective(
             getContext().nextGenDwarfFileNumber(), StringRef(),





More information about the llvm-commits mailing list