r207794 - do not use "1" for line marker for the predefines "file" either
Lubos Lunak
l.lunak at centrum.cz
Thu May 1 14:10:09 PDT 2014
Author: llunak
Date: Thu May 1 16:10:08 2014
New Revision: 207794
URL: http://llvm.org/viewvc/llvm-project?rev=207794&view=rev
Log:
do not use "1" for line marker for the predefines "file" either
Similar to r207764.
Added:
cfe/trunk/test/Frontend/rewrite-includes-cli-include.c
Modified:
cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
Modified: cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp?rev=207794&r1=207793&r2=207794&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp Thu May 1 16:10:08 2014
@@ -250,6 +250,10 @@ void InclusionRewriter::CommentOutDirect
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 F
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");
Added: cfe/trunk/test/Frontend/rewrite-includes-cli-include.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/rewrite-includes-cli-include.c?rev=207794&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/rewrite-includes-cli-include.c (added)
+++ cfe/trunk/test/Frontend/rewrite-includes-cli-include.c Thu May 1 16:10:08 2014
@@ -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{{$}}
More information about the cfe-commits
mailing list