Use raw_ostream::write_escaped instead of EscapeString.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 17 Oct 2009 20:43:19 +0000 (20:43 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 17 Oct 2009 20:43:19 +0000 (20:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84356 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Hello/Hello.cpp
utils/TableGen/ClangDiagnosticsEmitter.cpp
utils/TableGen/StringToOffsetTable.h

index 8000d0d2ff4ae3d9c6bf71a6d231f73bc17539ed..91534a754a13e1d00c9b6deab59bfa55e4b31f9a 100644 (file)
@@ -30,9 +30,8 @@ namespace {
 
     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 @@ namespace {
 
     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;
     }
 
index c127afd77050ede5cd10275cdbcc3fe00a6f76a2..6f1080eb5eb20426df3f5a5ec9dc35bb838c608c 100644 (file)
@@ -52,15 +52,12 @@ void ClangDiagsDefsEmitter::run(raw_ostream &OS) {
     
     // 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 @@ void ClangDiagGroupsEmitter::run(raw_ostream &OS) {
   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())
index d9d7cf485efd09370231ae63423c798f491f68f1..ac9422c5d72daa0a1bf6f86b261a1e87df6f5894 100644 (file)
 #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 @@ public:
   }
   
   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    \"";