[llvm-commits] [llvm] r69212 - /llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp

Chris Lattner sabre at nondot.org
Wed Apr 15 13:13:19 PDT 2009


Author: lattner
Date: Wed Apr 15 15:13:18 2009
New Revision: 69212

URL: http://llvm.org/viewvc/llvm-project?rev=69212&view=rev
Log:
use escape string.

Modified:
    llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp

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

==============================================================================
--- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Wed Apr 15 15:13:18 2009
@@ -16,8 +16,9 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Streams.h"
-#include "llvm/ADT/VectorExtras.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/VectorExtras.h"
 #include <set>
 #include <map>
 using namespace llvm;
@@ -39,15 +40,6 @@
   return 0;
 }
 
-static void EmitEscaped(std::ostream& OS, const std::string &s) {
-  for (std::string::const_iterator I=s.begin(), E=s.end(); I!=E; ++I)
-    switch (*I) {
-      default: OS << *I; break;
-      case '\"': OS << "\\" << *I; break;
-      case '\\': OS << "\\\\"; break;
-    }
-}
-
 static void EmitAllCaps(std::ostream& OS, const std::string &s) {
   for (std::string::const_iterator I=s.begin(), E=s.end(); I!=E; ++I)
     OS << char(toupper(*I));  
@@ -63,8 +55,9 @@
   OS << R.getValueAsDef("Class")->getName();
   OS << ", diag::" << R.getValueAsDef("DefaultMapping")->getName();
   OS << ", \"";
-  EmitEscaped(OS, R.getValueAsString("Text"));
-  OS << "\")\n";
+  std::string S = R.getValueAsString("Text");
+  EscapeString(S);
+  OS << S << "\")\n";
 }
 
 void ClangDiagsDefsEmitter::run(std::ostream &OS) {
@@ -168,7 +161,7 @@
 void ClangDiagGroupsEmitter::run(std::ostream &OS) {
   // Build up a map from options to controlled diagnostics.
   OptionMap OM;
-       
+  
   const RecordVector &Opts = Records.getAllDerivedDefinitions("Option");
   for (RecordVector::const_iterator I=Opts.begin(), E=Opts.end(); I != E; ++I)
     if (const RecordVal* V = findRecordVal(**I, "Members"))





More information about the llvm-commits mailing list