Out << " ]";
}
-/// Escape any backslashes in the source file (e.g. Windows paths)
-/// before emitting, so that it is parsed properly by the lexer on input.
-static void EscapeBackslashes(std::string Str,
- SmallVectorImpl<char> &Res) {
- for (auto C : Str) {
- switch (C) {
- default:
- break;
- case '\\':
- Res.push_back('\\');
- break;
- }
- Res.push_back(C);
- }
-}
-
void AssemblyWriter::printModule(const Module *M) {
Machine.initialize();
Out << "; ModuleID = '" << M->getModuleIdentifier() << "'\n";
if (!M->getSourceFileName().empty()) {
- SmallString<128> EscapedName;
- EscapeBackslashes(M->getSourceFileName(), EscapedName);
- Out << "source_filename = \"" << EscapedName << "\"\n";
+ Out << "source_filename = \"";
+ PrintEscapedString(M->getSourceFileName(), Out);
+ Out << "\"\n";
}
const std::string &DL = M->getDataLayoutStr();
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
-; CHECK: source_filename = "C:\\path\\with\\backslashes\\test.cc"
-source_filename = "C:\\path\\with\\backslashes\\test.cc"
+; CHECK: source_filename = "C:\5Cpath\5Cwith\5Cbackslashes\5Ctest.cc"
+source_filename = "C:\5Cpath\5Cwith\5Cbackslashes\5Ctest.cc"