Properly escape filenames in line directives.
Fixes PR17018. Only partial test coverage because I don't want
to try to write a test which generates a file whose name contains a newline.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189557 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp
index a2297f9..3fba690 100644
--- a/lib/Rewrite/Frontend/InclusionRewriter.cpp
+++ b/lib/Rewrite/Frontend/InclusionRewriter.cpp
@@ -114,7 +114,9 @@
} else {
// Use GNU linemarkers as described here:
// http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
- OS << '#' << ' ' << Line << ' ' << '"' << Filename << '"';
+ OS << '#' << ' ' << Line << ' ' << '"';
+ OS.write_escaped(Filename);
+ OS << '"';
if (!Extra.empty())
OS << Extra;
if (FileType == SrcMgr::C_System)