From 80e45b8cd4cce838cd314cbbe83bea819e6e1d1e Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 29 Aug 2013 01:42:42 +0000 Subject: 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. llvm-svn: 189557 --- clang/lib/Frontend/PrintPreprocessedOutput.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'clang/lib/Frontend/PrintPreprocessedOutput.cpp') diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 83b2a271ec3..e0ec08fb90a 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -190,11 +190,11 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo, // Emit #line directives or GNU line markers depending on what mode we're in. if (UseLineDirective) { OS << "#line" << ' ' << LineNo << ' ' << '"'; - OS.write(CurFilename.data(), CurFilename.size()); + OS.write_escaped(CurFilename); OS << '"'; } else { OS << '#' << ' ' << LineNo << ' ' << '"'; - OS.write(CurFilename.data(), CurFilename.size()); + OS.write_escaped(CurFilename); OS << '"'; if (ExtraLen) @@ -285,7 +285,6 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc, CurFilename.clear(); CurFilename += UserLoc.getFilename(); - Lexer::Stringify(CurFilename); FileType = NewFileType; if (DisableLineMarkers) { -- cgit v1.2.3