r207764 - do not use "1" for line marker for the main file
Lubos Lunak
l.lunak at centrum.cz
Thu May 1 06:50:45 PDT 2014
Author: llunak
Date: Thu May 1 08:50:44 2014
New Revision: 207764
URL: http://llvm.org/viewvc/llvm-project?rev=207764&view=rev
Log:
do not use "1" for line marker for the main file
"1" means entering a new file (from a different one), but the main
file is not included from anything (and this would e.g. confuse -Wunused-macros
to not report unused macros in the main file, see pr15610, or also see pr18948).
The line marker is still useful e.g. if the resulting file is renamed or used
via a pipe.
Modified:
cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
cfe/trunk/test/Frontend/rewrite-includes.c
Modified: cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp?rev=207764&r1=207763&r2=207764&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp Thu May 1 08:50:44 2014
@@ -352,8 +352,11 @@ bool InclusionRewriter::Process(FileID F
StringRef EOL = DetectEOL(FromFile);
- // Per the GNU docs: "1" indicates the start of a new file.
- WriteLineInfo(FileName, 1, FileType, EOL, " 1");
+ // Per the GNU docs: "1" indicates entering a new file.
+ if (FileId == SM.getMainFileID())
+ WriteLineInfo(FileName, 1, FileType, EOL, "");
+ else
+ WriteLineInfo(FileName, 1, FileType, EOL, " 1");
if (SM.getFileIDSize(FileId) == 0)
return false;
Modified: cfe/trunk/test/Frontend/rewrite-includes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/rewrite-includes.c?rev=207764&r1=207763&r2=207764&view=diff
==============================================================================
--- cfe/trunk/test/Frontend/rewrite-includes.c (original)
+++ cfe/trunk/test/Frontend/rewrite-includes.c Thu May 1 08:50:44 2014
@@ -21,6 +21,7 @@ A(1,2)
#include "rewrite-includes7.h"
#include "rewrite-includes8.h"
// ENDCOMPARE
+// CHECK: {{^}}# 1 "{{.*}}rewrite-includes.c"{{$}}
// CHECK: {{^}}// STARTCOMPARE{{$}}
// CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}}
// CHECK-NEXT: {{^}}A(1,2){{$}}
More information about the cfe-commits
mailing list