Escape the name of the module since it comes from the file name and may include
authorNick Lewycky <nicholas@mxc.ca>
Fri, 26 Jun 2009 04:33:37 +0000 (04:33 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Fri, 26 Jun 2009 04:33:37 +0000 (04:33 +0000)
invalid characters like backslashes on Windows. Patch by James Abbatiello!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74265 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CppBackend/CPPBackend.cpp

index 44418f6e4361c0ac1dd930b1adf28f831ee90fbe..28f58e86f62340aceaadecaa9ebe9574833f074b 100644 (file)
@@ -1834,7 +1834,9 @@ namespace {
                               const std::string& mName) {
     nl(Out) << "Module* " << fname << "() {";
     nl(Out,1) << "// Module Construction";
-    nl(Out) << "Module* mod = new Module(\"" << mName << "\");";
+    nl(Out) << "Module* mod = new Module(\"";
+    printEscapedString(mName);
+    Out << "\");";
     if (!TheModule->getTargetTriple().empty()) {
       nl(Out) << "mod->setDataLayout(\"" << TheModule->getDataLayout() << "\");";
     }
@@ -1867,7 +1869,9 @@ namespace {
   void CppWriter::printContents(const std::string& fname,
                                 const std::string& mName) {
     Out << "\nModule* " << fname << "(Module *mod) {\n";
-    Out << "\nmod->setModuleIdentifier(\"" << mName << "\");\n";
+    Out << "\nmod->setModuleIdentifier(\"";
+    printEscapedString(mName);
+    Out << "\");\n";
     printModuleBody();
     Out << "\nreturn mod;\n";
     Out << "\n}\n";