From c52435b4a254af96128c19e473071ec30cfb51f2 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 9 Jan 2013 03:16:42 +0000 Subject: [PATCH] Make sure clang puts tokens from different files on separate lines in "-E -P" mode. llvm-svn: 171944 --- clang/lib/Frontend/PrintPreprocessedOutput.cpp | 5 ++++- clang/test/Preprocessor/print_line_include.c | 6 ++++++ clang/test/Preprocessor/print_line_include.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 clang/test/Preprocessor/print_line_include.c create mode 100644 clang/test/Preprocessor/print_line_include.h diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index afad0a9f5ff3..02da71bbbe85 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -268,7 +268,10 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc, Lexer::Stringify(CurFilename); FileType = NewFileType; - if (DisableLineMarkers) return; + if (DisableLineMarkers) { + startNewLineIfNeeded(/*ShouldUpdateCurrentLine=*/false); + return; + } if (!Initialized) { WriteLineInfo(CurLine); diff --git a/clang/test/Preprocessor/print_line_include.c b/clang/test/Preprocessor/print_line_include.c new file mode 100644 index 000000000000..d65873cb7366 --- /dev/null +++ b/clang/test/Preprocessor/print_line_include.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -E -P %s | FileCheck %s +// CHECK: int x; +// CHECK-NEXT: int x; + +#include "print_line_include.h" +#include "print_line_include.h" diff --git a/clang/test/Preprocessor/print_line_include.h b/clang/test/Preprocessor/print_line_include.h new file mode 100644 index 000000000000..6d1a0d47b7f7 --- /dev/null +++ b/clang/test/Preprocessor/print_line_include.h @@ -0,0 +1 @@ +int x;