[llvm-commits] [llvm] r94543 - /llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp

Mikhail Glushenkov foldr at codedgers.com
Tue Jan 26 06:55:04 PST 2010


Author: foldr
Date: Tue Jan 26 08:55:04 2010
New Revision: 94543

URL: http://llvm.org/viewvc/llvm-project?rev=94543&view=rev
Log:
Escape double quotes in 'help'.

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

Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=94543&r1=94542&r2=94543&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Tue Jan 26 08:55:04 2010
@@ -116,7 +116,7 @@
 // EscapeVariableName - Escape commas and other symbols not allowed
 // in the C++ variable names. Makes it possible to use options named
 // like "Wa," (useful for prefix options).
-std::string EscapeVariableName(const std::string& Var) {
+std::string EscapeVariableName (const std::string& Var) {
   std::string ret;
   for (unsigned i = 0; i != Var.size(); ++i) {
     char cur_char = Var[i];
@@ -136,6 +136,21 @@
   return ret;
 }
 
+/// EscapeQuotes - Replace '"' with '\"'.
+std::string EscapeQuotes (const std::string& Var) {
+  std::string ret;
+  for (unsigned i = 0; i != Var.size(); ++i) {
+    char cur_char = Var[i];
+    if (cur_char == '"') {
+      ret += "\\\"";
+    }
+    else {
+      ret.push_back(cur_char);
+    }
+  }
+  return ret;
+}
+
 /// OneOf - Does the input string contain this character?
 bool OneOf(const char* lst, char c) {
   while (*lst) {
@@ -594,7 +609,7 @@
 
   void onHelp (const DagInit& d) {
     CheckNumberOfArguments(d, 1);
-    optDesc_.Help = InitPtrToString(d.getArg(0));
+    optDesc_.Help = EscapeQuotes(InitPtrToString(d.getArg(0)));
   }
 
   void onHidden (const DagInit& d) {





More information about the llvm-commits mailing list