From: Eli Friedman Date: Wed, 9 Jan 2013 03:16:42 +0000 (+0000) Subject: Make sure clang puts tokens from different files on separate lines in "-E -P" mode... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=086cc83a84bfab60685b69e3afa3e4500daebb4d;p=clang Make sure clang puts tokens from different files on separate lines in "-E -P" mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171944 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index afad0a9f5f..02da71bbbe 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/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/test/Preprocessor/print_line_include.c b/test/Preprocessor/print_line_include.c new file mode 100644 index 0000000000..d65873cb73 --- /dev/null +++ b/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/test/Preprocessor/print_line_include.h b/test/Preprocessor/print_line_include.h new file mode 100644 index 0000000000..6d1a0d47b7 --- /dev/null +++ b/test/Preprocessor/print_line_include.h @@ -0,0 +1 @@ +int x;