summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/AsmWriter.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-03-30 22:17:28 +0000
committerTeresa Johnson <tejohnson@google.com>2016-03-30 22:17:28 +0000
commitd8d94652b2345f596b3a62dbcd32cbb0a1a50856 (patch)
tree20930d4a8b8f316ff77f2d3886389f5fc4c1c188 /llvm/lib/IR/AsmWriter.cpp
parent2bc252acd5625cb0fb167f0d9b3fd05292f7cc47 (diff)
downloadbcm5719-llvm-d8d94652b2345f596b3a62dbcd32cbb0a1a50856.tar.gz
bcm5719-llvm-d8d94652b2345f596b3a62dbcd32cbb0a1a50856.zip
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
Diffstat (limited to 'llvm/lib/IR/AsmWriter.cpp')
-rw-r--r--llvm/lib/IR/AsmWriter.cpp22
1 files changed, 3 insertions, 19 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 4750cf6071d..c64291cbbfc 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2203,22 +2203,6 @@ void AssemblyWriter::writeOperandBundles(ImmutableCallSite CS) {
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();
@@ -2232,9 +2216,9 @@ void AssemblyWriter::printModule(const Module *M) {
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();
OpenPOWER on IntegriCloud