Introduce a string_ostream string builder facilty
[oota-llvm.git] / tools / llvm-objdump / llvm-objdump.cpp
index d98691b4b044f27b79ebf069e238bd8a00f6d366..d9886c10aeb5e9b932e9ccbcc451ecaeec3fb04a 100644 (file)
@@ -222,8 +222,7 @@ static void emitDOTFile(const char *FileName, const MCFunction &f,
         Out << "<o>";
 
       // Escape special chars and print the instruction in mnemonic form.
-      std::string Str;
-      raw_string_ostream OS(Str);
+      string_ostream OS;
       IP->printInst(&(*i)->getInsts()->at(ii).Inst, OS, "");
       Out << DOT::EscapeString(OS.str());
     }
@@ -473,9 +472,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
     if (Symbols.empty())
       Symbols.push_back(std::make_pair(0, name));
 
-
-    SmallString<40> Comments;
-    raw_svector_ostream CommentStream(Comments);
+    small_string_ostream<40> Comments;
 
     StringRef Bytes;
     if (error(Section.getContents(Bytes)))
@@ -513,15 +510,14 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
         MCInst Inst;
 
         if (DisAsm->getInstruction(Inst, Size, memoryObject,
-                                   SectionAddr + Index,
-                                   DebugOut, CommentStream)) {
+                                   SectionAddr + Index, DebugOut, Comments)) {
           outs() << format("%8" PRIx64 ":", SectionAddr + Index);
           if (!NoShowRawInsn) {
             outs() << "\t";
             DumpBytes(StringRef(Bytes.data() + Index, Size));
           }
           IP->printInst(&Inst, outs(), "");
-          outs() << CommentStream.str();
+          outs() << Comments.str();
           Comments.clear();
           outs() << "\n";
         } else {