forked from OSchip/llvm-project
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. llvm-svn: 207764
This commit is contained in:
parent
575f79a409
commit
10961c0eab
|
@ -352,8 +352,11 @@ bool InclusionRewriter::Process(FileID FileId,
|
||||||
|
|
||||||
StringRef EOL = DetectEOL(FromFile);
|
StringRef EOL = DetectEOL(FromFile);
|
||||||
|
|
||||||
// Per the GNU docs: "1" indicates the start of a new file.
|
// Per the GNU docs: "1" indicates entering a new file.
|
||||||
WriteLineInfo(FileName, 1, FileType, EOL, " 1");
|
if (FileId == SM.getMainFileID())
|
||||||
|
WriteLineInfo(FileName, 1, FileType, EOL, "");
|
||||||
|
else
|
||||||
|
WriteLineInfo(FileName, 1, FileType, EOL, " 1");
|
||||||
|
|
||||||
if (SM.getFileIDSize(FileId) == 0)
|
if (SM.getFileIDSize(FileId) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -21,6 +21,7 @@ A(1,2)
|
||||||
#include "rewrite-includes7.h"
|
#include "rewrite-includes7.h"
|
||||||
#include "rewrite-includes8.h"
|
#include "rewrite-includes8.h"
|
||||||
// ENDCOMPARE
|
// ENDCOMPARE
|
||||||
|
// CHECK: {{^}}# 1 "{{.*}}rewrite-includes.c"{{$}}
|
||||||
// CHECK: {{^}}// STARTCOMPARE{{$}}
|
// CHECK: {{^}}// STARTCOMPARE{{$}}
|
||||||
// CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}}
|
// CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}}
|
||||||
// CHECK-NEXT: {{^}}A(1,2){{$}}
|
// CHECK-NEXT: {{^}}A(1,2){{$}}
|
||||||
|
|
Loading…
Reference in New Issue