diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-06-26 04:33:37 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-06-26 04:33:37 +0000 |
commit | 2dbc6476cb5c1054109ee86b6d726d7f4a3c51e9 (patch) | |
tree | 6c78496140d718fd047768fe56306f87dd131722 /llvm/lib/Target/CppBackend/CPPBackend.cpp | |
parent | 5558e9fc55a1677798c3ac664e613e7fcd41da06 (diff) | |
download | bcm5719-llvm-2dbc6476cb5c1054109ee86b6d726d7f4a3c51e9.tar.gz bcm5719-llvm-2dbc6476cb5c1054109ee86b6d726d7f4a3c51e9.zip |
Escape the name of the module since it comes from the file name and may include
invalid characters like backslashes on Windows. Patch by James Abbatiello!
llvm-svn: 74265
Diffstat (limited to 'llvm/lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | llvm/lib/Target/CppBackend/CPPBackend.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Target/CppBackend/CPPBackend.cpp b/llvm/lib/Target/CppBackend/CPPBackend.cpp index 44418f6e436..28f58e86f62 100644 --- a/llvm/lib/Target/CppBackend/CPPBackend.cpp +++ b/llvm/lib/Target/CppBackend/CPPBackend.cpp @@ -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"; |