do not use "1" for line marker for the predefines "file" either

Similar to r207764.

llvm-svn: 207794
This commit is contained in:
Lubos Lunak 2014-05-01 21:10:08 +00:00
parent bf8a9ac768
commit 72cad68b30
2 changed files with 14 additions and 1 deletions

View File

@ -250,6 +250,10 @@ void InclusionRewriter::CommentOutDirective(Lexer &DirectiveLex,
do {
DirectiveLex.LexFromRawLexer(DirectiveToken);
} while (!DirectiveToken.is(tok::eod) && DirectiveToken.isNot(tok::eof));
if (&FromFile == PredefinesBuffer) {
// OutputContentUpTo() would not output anything anyway.
return;
}
OS << "#if 0 /* expanded by -frewrite-includes */" << EOL;
OutputContentUpTo(FromFile, NextToWrite,
SM.getFileOffset(DirectiveToken.getLocation()) + DirectiveToken.getLength(),
@ -353,7 +357,7 @@ bool InclusionRewriter::Process(FileID FileId,
StringRef EOL = DetectEOL(FromFile);
// Per the GNU docs: "1" indicates entering a new file.
if (FileId == SM.getMainFileID())
if (FileId == SM.getMainFileID() || FileId == PP.getPredefinesFileID())
WriteLineInfo(FileName, 1, FileType, EOL, "");
else
WriteLineInfo(FileName, 1, FileType, EOL, " 1");

View File

@ -0,0 +1,9 @@
// RUN: not %clang_cc1 -verify -E -frewrite-includes -include %S/Inputs/rewrite-includes2.h %s -o - | FileCheck -strict-whitespace %s
main_file_line
// CHECK: {{^}}# 1 "<built-in>"{{$}}
// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes2.h" 1{{$}}
// CHECK-NEXT: {{^}}included_line2{{$}}
// CHECK-NEXT: {{^}}# 1 "<built-in>" 2{{$}}
// CHECK-NEXT: {{^}}# 1 "{{.*}}rewrite-includes-cli-include.c"{{$}}
// CHECK-NEXT: FileCheck
// CHECK-NEXT: {{^}}main_file_line{{$}}