From ae779383bec1fd571dfd296ce56bc4cd1d8c8138 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Tue, 26 Jan 2010 14:55:04 +0000 Subject: [PATCH] Escape double quotes in 'help'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94543 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/LLVMCConfigurationEmitter.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp index 88fb6c3b2c7..2abc94bbcda 100644 --- a/utils/TableGen/LLVMCConfigurationEmitter.cpp +++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp @@ -116,7 +116,7 @@ bool IsDagEmpty (const DagInit& d) { // 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 @@ std::string EscapeVariableName(const std::string& Var) { 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 @@ private: 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) { -- 2.34.1