aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-06-26 04:33:37 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-06-26 04:33:37 +0000
commitb8b7347c101367ca6c22843db3ad60702330ec05 (patch)
tree54d0da8b85d718a43da7a6ed61afac036266b45f
parentfc0fc3aedb76175386f3d9be4b3592fe8da6ee84 (diff)
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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74265 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/CppBackend/CPPBackend.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index 44418f6e43..28f58e86f6 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/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";