[llvm-commits] [llvm] r84356 - in /llvm/trunk: lib/Transforms/Hello/Hello.cpp utils/TableGen/ClangDiagnosticsEmitter.cpp utils/TableGen/StringToOffsetTable.h

Daniel Dunbar daniel at zuster.org
Sat Oct 17 13:43:19 PDT 2009


Author: ddunbar
Date: Sat Oct 17 15:43:19 2009
New Revision: 84356

URL: http://llvm.org/viewvc/llvm-project?rev=84356&view=rev
Log:
Use raw_ostream::write_escaped instead of EscapeString.

Modified:
    llvm/trunk/lib/Transforms/Hello/Hello.cpp
    llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
    llvm/trunk/utils/TableGen/StringToOffsetTable.h

Modified: llvm/trunk/lib/Transforms/Hello/Hello.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Hello/Hello.cpp?rev=84356&r1=84355&r2=84356&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Hello/Hello.cpp (original)
+++ llvm/trunk/lib/Transforms/Hello/Hello.cpp Sat Oct 17 15:43:19 2009
@@ -30,9 +30,8 @@
 
     virtual bool runOnFunction(Function &F) {
       HelloCounter++;
-      std::string fname = F.getName();
-      EscapeString(fname);
-      errs() << "Hello: " << fname << "\n";
+      errs() << "Hello: ";
+      errs().write_escaped(F.getName()) << '\n';
       return false;
     }
   };
@@ -49,9 +48,8 @@
 
     virtual bool runOnFunction(Function &F) {
       HelloCounter++;
-      std::string fname = F.getName();
-      EscapeString(fname);
-      errs() << "Hello: " << fname << "\n";
+      errs() << "Hello: ";
+      errs().write_escaped(F.getName()) << '\n';
       return false;
     }
 

Modified: llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=84356&r1=84355&r2=84356&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Sat Oct 17 15:43:19 2009
@@ -52,15 +52,12 @@
     
     // Description string.
     OS << ", \"";
-    std::string S = R.getValueAsString("Text");
-    EscapeString(S);
-    OS << S << "\"";
+    OS.write_escaped(R.getValueAsString("Text")) << '"';
     
     // Warning associated with the diagnostic.
     if (DefInit *DI = dynamic_cast<DefInit*>(R.getValueInit("Group"))) {
-      S = DI->getDef()->getValueAsString("GroupName");
-      EscapeString(S);
-      OS << ", \"" << S << "\"";
+      OS << ", \"";
+      OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"';
     } else {
       OS << ", 0";
     }
@@ -151,11 +148,10 @@
   OS << "\n#ifdef GET_DIAG_TABLE\n";
   for (std::map<std::string, GroupInfo>::iterator
        I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I) {
-    std::string S = I->first;
-    EscapeString(S);
     // Group option string.
-    OS << "  { \"" << S << "\","
-      << std::string(MaxLen-I->first.size()+1, ' ');
+    OS << "  { \"";
+    OS.write_escaped(I->first) << "\","
+                               << std::string(MaxLen-I->first.size()+1, ' ');
     
     // Diagnostics in the group.
     if (I->second.DiagsInGroup.empty())

Modified: llvm/trunk/utils/TableGen/StringToOffsetTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/StringToOffsetTable.h?rev=84356&r1=84355&r2=84356&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/StringToOffsetTable.h (original)
+++ llvm/trunk/utils/TableGen/StringToOffsetTable.h Sat Oct 17 15:43:19 2009
@@ -10,9 +10,10 @@
 #ifndef TBLGEN_STRING_TO_OFFSET_TABLE_H
 #define TBLGEN_STRING_TO_OFFSET_TABLE_H
 
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace llvm {
 
@@ -38,9 +39,13 @@
   }
   
   void EmitString(raw_ostream &O) {
+    // Escape the string.
+    SmallString<256> Str;
+    raw_svector_ostream(Str).write_escaped(AggregateString);
+    AggregateString = Str.str();
+
     O << "    \"";
     unsigned CharsPrinted = 0;
-    EscapeString(AggregateString);
     for (unsigned i = 0, e = AggregateString.size(); i != e; ++i) {
       if (CharsPrinted > 70) {
         O << "\"\n    \"";





More information about the llvm-commits mailing list