mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Use existing PrintEscapedString in AssemblyWriter
r264884 introduced a helper to escape the backslashes in the source file path, but I since discovered an existing mechanism to escape strings. llvm-svn: 264936
This commit is contained in:
parent
c940ae83b9
commit
bc50c12eb6
@ -2203,22 +2203,6 @@ void AssemblyWriter::writeOperandBundles(ImmutableCallSite CS) {
|
|||||||
Out << " ]";
|
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) {
|
void AssemblyWriter::printModule(const Module *M) {
|
||||||
Machine.initialize();
|
Machine.initialize();
|
||||||
|
|
||||||
@ -2232,9 +2216,9 @@ void AssemblyWriter::printModule(const Module *M) {
|
|||||||
Out << "; ModuleID = '" << M->getModuleIdentifier() << "'\n";
|
Out << "; ModuleID = '" << M->getModuleIdentifier() << "'\n";
|
||||||
|
|
||||||
if (!M->getSourceFileName().empty()) {
|
if (!M->getSourceFileName().empty()) {
|
||||||
SmallString<128> EscapedName;
|
Out << "source_filename = \"";
|
||||||
EscapeBackslashes(M->getSourceFileName(), EscapedName);
|
PrintEscapedString(M->getSourceFileName(), Out);
|
||||||
Out << "source_filename = \"" << EscapedName << "\"\n";
|
Out << "\"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &DL = M->getDataLayoutStr();
|
const std::string &DL = M->getDataLayoutStr();
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
|
|
||||||
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
|
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
|
||||||
|
|
||||||
; CHECK: source_filename = "C:\\path\\with\\backslashes\\test.cc"
|
; CHECK: source_filename = "C:\5Cpath\5Cwith\5Cbackslashes\5Ctest.cc"
|
||||||
source_filename = "C:\\path\\with\\backslashes\\test.cc"
|
source_filename = "C:\5Cpath\5Cwith\5Cbackslashes\5Ctest.cc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user