remove one form of EmitString, just use EmitBytes instead. We must
authorChris Lattner <sabre@nondot.org>
Sat, 23 Jan 2010 03:11:46 +0000 (03:11 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 23 Jan 2010 03:11:46 +0000 (03:11 +0000)
be careful to add a \0 at the end though, because EmitString didn't
do this.

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

include/llvm/CodeGen/AsmPrinter.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DIE.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfException.cpp

index 305d24629804ccdbccf618931fbf6325a4ed408a..b45be2752be46f13281a6bc60cb752760ce27932 100644 (file)
@@ -265,12 +265,6 @@ namespace llvm {
     ///
     void EmitInt64(uint64_t Value) const;
 
-    /// EmitString - Emit a string with quotes and a null terminator.
-    /// Special characters are emitted properly.
-    /// @verbatim (Eg. '\t') @endverbatim
-    void EmitString(const StringRef String) const;
-    void EmitString(const char *String, unsigned Size) const;
-
     /// EmitFile - Emit a .file directive.
     void EmitFile(unsigned Number, StringRef Name) const;
 
index fcab4aa5e987736d842ef1cbf521a7f4359067a8..50842078b4632a4cd82afc3e769be3b6f3c24fe0 100644 (file)
@@ -715,29 +715,6 @@ static void printStringChar(formatted_raw_ostream &O, unsigned char C) {
   }
 }
 
-/// EmitString - Emit a string with quotes and a null terminator.
-/// Special characters are emitted properly.
-/// \literal (Eg. '\t') \endliteral
-void AsmPrinter::EmitString(const StringRef String) const {
-  EmitString(String.data(), String.size());
-}
-
-void AsmPrinter::EmitString(const char *String, unsigned Size) const {
-  const char* AscizDirective = MAI->getAscizDirective();
-  if (AscizDirective)
-    O << AscizDirective;
-  else
-    O << MAI->getAsciiDirective();
-  O << '\"';
-  for (unsigned i = 0; i < Size; ++i)
-    printStringChar(O, String[i]);
-  if (AscizDirective)
-    O << '\"';
-  else
-    O << "\\0\"";
-}
-
-
 /// EmitFile - Emit a .file directive.
 void AsmPrinter::EmitFile(unsigned Number, StringRef Name) const {
   O << "\t.file\t" << Number << " \"";
index 3bdc50d89394eef528c71e9c124f5224107c0c72..349e0ac40f1edfb109749b241ee0d2bbecadcf70 100644 (file)
@@ -242,7 +242,9 @@ void DIEInteger::print(raw_ostream &O) {
 /// EmitValue - Emit string value.
 ///
 void DIEString::EmitValue(DwarfPrinter *D, unsigned Form) const {
-  D->getAsm()->EmitString(Str);
+  D->getAsm()->OutStreamer.EmitBytes(Str, /*addrspace*/0);
+  // Emit nul terminator.
+  D->getAsm()->OutStreamer.EmitIntValue(0, 1, /*addrspace*/0);
 }
 
 #ifndef NDEBUG
index cc2ff8c5711e945680ce352681f09e62aed2c818..513987f902037777fdccf26d193d914a79e3d2d8 100644 (file)
@@ -344,7 +344,7 @@ void DwarfDebug::addSInt(DIE *Die, unsigned Attribute,
 /// addString - Add a string attribute data and value. DIEString only
 /// keeps string reference. 
 void DwarfDebug::addString(DIE *Die, unsigned Attribute, unsigned Form,
-                           const StringRef String) {
+                           StringRef String) {
   DIEValue *Value = new DIEString(String);
   DIEValues.push_back(Value);
   Die->addValue(Attribute, Form, Value);
@@ -2526,8 +2526,9 @@ void DwarfDebug::emitDebugLines() {
 
   // Emit directories.
   for (unsigned DI = 1, DE = getNumSourceDirectories()+1; DI != DE; ++DI) {
-    Asm->EmitString(getSourceDirectoryName(DI));
-    EOL("Directory");
+    const std::string &Dir = getSourceDirectoryName(DI);
+    if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("Directory");
+    Asm->OutStreamer.EmitBytes(StringRef(Dir.c_str(), Dir.size()+1), 0);
   }
 
   Asm->EmitInt8(0); EOL("End of directories");
@@ -2536,8 +2537,10 @@ void DwarfDebug::emitDebugLines() {
   for (unsigned SI = 1, SE = getNumSourceIds()+1; SI != SE; ++SI) {
     // Remember source id starts at 1.
     std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(SI);
-    Asm->EmitString(getSourceFileName(Id.second));
-    EOL("Source");
+    const std::string &FN = getSourceFileName(Id.second);
+    if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("Source");
+    Asm->OutStreamer.EmitBytes(StringRef(FN.c_str(), FN.size()+1), 0);
+    
     EmitULEB128(Id.first, "Directory #");
     EmitULEB128(0, "Mod date");
     EmitULEB128(0, "File size");
@@ -2661,7 +2664,7 @@ void DwarfDebug::emitCommonDebugFrame() {
   EOL("CIE Identifier Tag");
   Asm->EmitInt8(dwarf::DW_CIE_VERSION);
   EOL("CIE Version");
-  Asm->EmitString("");
+  Asm->OutStreamer.EmitIntValue(0, 1, /*addrspace*/0); // nul terminator.
   EOL("CIE Augmentation");
   EmitULEB128(1, "CIE Code Alignment Factor");
   EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
@@ -2743,7 +2746,10 @@ void DwarfDebug::emitDebugPubNames() {
     DIE * Entity = GI->second;
 
     Asm->EmitInt32(Entity->getOffset()); EOL("DIE offset");
-    Asm->EmitString(Name, strlen(Name)); EOL("External Name");
+    
+    if (Asm->VerboseAsm)
+      Asm->OutStreamer.AddComment("External Name");
+    Asm->OutStreamer.EmitBytes(StringRef(Name, strlen(Name)+1), 0);
   }
 
   Asm->EmitInt32(0); EOL("End Mark");
@@ -2778,7 +2784,9 @@ void DwarfDebug::emitDebugPubTypes() {
     DIE * Entity = GI->second;
 
     Asm->EmitInt32(Entity->getOffset()); EOL("DIE offset");
-    Asm->EmitString(Name, strlen(Name)); EOL("External Name");
+    
+    if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("External Name");
+    Asm->OutStreamer.EmitBytes(StringRef(Name, strlen(Name)), 0);
   }
 
   Asm->EmitInt32(0); EOL("End Mark");
@@ -2803,8 +2811,7 @@ void DwarfDebug::emitDebugStr() {
 
       // Emit the string itself.
       const std::string &String = StringPool[StringID];
-      Asm->EmitString(String);
-      Asm->O << '\n';
+      Asm->OutStreamer.EmitBytes(StringRef(String.c_str(), String.size()+1), 0);
     }
 
     Asm->O << '\n';
@@ -2920,11 +2927,12 @@ void DwarfDebug::emitDebugInlineInfo() {
     StringRef LName = SP.getLinkageName();
     StringRef Name = SP.getName();
 
-    if (LName.empty())
-      Asm->EmitString(Name);
-    else 
+    if (LName.empty()) {
+      Asm->OutStreamer.EmitBytes(Name, 0);
+      Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator.
+    } else 
       EmitSectionOffset("string", "section_str",
-                        StringPool.idFor(getRealLinkageName(LName)), false, true);
+                      StringPool.idFor(getRealLinkageName(LName)), false, true);
 
     EOL("MIPS linkage name");
     EmitSectionOffset("string", "section_str",
index 3cb9d3b511bd365333ea44cc85a0d158008ae1cd..9a1c41c2a6241bb3851aff545bf3786843b030c8 100644 (file)
@@ -146,7 +146,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
   unsigned LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
   unsigned FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
 
-  char Augmentation[5] = { 0 };
+  char Augmentation[6] = { 0 };
   unsigned AugmentationSize = 0;
   char *APtr = Augmentation + 1;
 
@@ -171,7 +171,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
   if (APtr != Augmentation + 1)
     Augmentation[0] = 'z';
 
-  Asm->EmitString(Augmentation);
+  Asm->OutStreamer.EmitBytes(StringRef(Augmentation, strlen(Augmentation)+1),0);
   EOL("CIE Augmentation");
 
   // Round out reader.