1// RUN: not %clang_cc1 -verify -E -frewrite-includes -DFIRST -I %S/Inputs %s -o - | FileCheck -strict-whitespace %s
2// RUN: not %clang_cc1 -verify -E -frewrite-includes -P -DFIRST -I %S/Inputs %s -o - | FileCheck -check-prefix=CHECKNL -strict-whitespace %s
3// STARTCOMPARE
4#define A(a,b) a ## b
5A(1,2)
6#include "rewrite-includes1.h"
7#ifdef FIRST
8#define HEADER "rewrite-includes3.h"
9#include HEADER
10#else
11#include "rewrite-includes4.h"
12#endif
13  // indented
14#/**/include /**/ "rewrite-includes5.h" /**/ \
15
16#include "rewrite-includes6.h" // comment
17
18#include "rewrite-includes6.h" /* comment
19                                  continues */
20#include "rewrite-includes7.h"
21#include "rewrite-includes7.h"
22#include "rewrite-includes8.h"
23// ENDCOMPARE
24// CHECK: {{^}}# 1 "{{.*}}rewrite-includes.c"{{$}}
25// CHECK: {{^}}// STARTCOMPARE{{$}}
26// CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}}
27// CHECK-NEXT: {{^}}A(1,2){{$}}
28// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
29// CHECK-NEXT: {{^}}#include "rewrite-includes1.h"{{$}}
30// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
31// CHECK-NEXT: {{^}}# 6 "{{.*}}rewrite-includes.c"{{$}}
32// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes1.h" 1{{$}}
33// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
34// CHECK-NEXT: {{^}}#pragma clang system_header{{$}}
35// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
36// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes1.h" 3{{$}}
37// CHECK-NEXT: {{^}}included_line1{{$}}
38// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
39// CHECK-NEXT: {{^}}#include "rewrite-includes2.h"{{$}}
40// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
41// CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes1.h" 3{{$}}
42// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes2.h" 1 3{{$}}
43// CHECK-NEXT: {{^}}included_line2{{$}}
44// CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes1.h" 2 3{{$}}
45// CHECK-NEXT: {{^}}# 7 "{{.*}}rewrite-includes.c" 2{{$}}
46// CHECK-NEXT: {{^}}#ifdef FIRST{{$}}
47// CHECK-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}}
48// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
49// CHECK-NEXT: {{^}}#include HEADER{{$}}
50// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
51// CHECK-NEXT: {{^}}# 9 "{{.*}}rewrite-includes.c"{{$}}
52// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes3.h" 1{{$}}
53// CHECK-NEXT: {{^}}included_line3{{$}}
54// CHECK-NEXT: {{^}}# 10 "{{.*}}rewrite-includes.c" 2{{$}}
55// CHECK-NEXT: {{^}}#else{{$}}
56// CHECK-NEXT: {{^}}# 11 "{{.*}}rewrite-includes.c"{{$}}
57// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
58// CHECK-NEXT: {{^}}#include "rewrite-includes4.h"{{$}}
59// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
60// CHECK-NEXT: {{^}}# 11 "{{.*}}rewrite-includes.c"{{$}}
61// CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}}
62// CHECK-NEXT: {{^}}#endif{{$}}
63// CHECK-NEXT: {{^}}# 13 "{{.*}}rewrite-includes.c"{{$}}
64// CHECK-NEXT: {{^}}  // indented{{$}}
65// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
66// CHECK-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}}
67// CHECK-NEXT: {{^}} {{$}}
68// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
69// CHECK-NEXT: {{^}}# 15 "{{.*}}rewrite-includes.c"{{$}}
70// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes5.h" 1{{$}}
71// CHECK-NEXT: {{^}}included_line5{{$}}
72// CHECK-NEXT: {{^}}# 16 "{{.*}}rewrite-includes.c" 2{{$}}
73// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
74// CHECK-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}}
75// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
76// CHECK-NEXT: {{^}}# 16 "{{.*}}rewrite-includes.c"{{$}}
77// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes6.h" 1{{$}}
78// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
79// CHECK-NEXT: {{^}}#pragma once{{$}}
80// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
81// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes6.h"{{$}}
82// CHECK-NEXT: {{^}}included_line6{{$}}
83// CHECK-NEXT: {{^}}# 17 "{{.*}}rewrite-includes.c" 2{{$}}
84// CHECK-NEXT: {{^}} {{$}}
85// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
86// CHECK-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}}
87// CHECK-NEXT: {{^}}                                  continues */{{$}}
88// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
89// CHECK-NEXT: {{^}}# 19 "{{.*}}rewrite-includes.c"{{$}}
90// CHECK-NEXT: {{^}}# 20 "{{.*}}rewrite-includes.c"{{$}}
91// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
92// CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
93// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
94// CHECK-NEXT: {{^}}# 20 "{{.*}}rewrite-includes.c"{{$}}
95// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes7.h" 1{{$}}
96// CHECK-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}}
97// CHECK-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}}
98// CHECK-NEXT: {{^}}included_line7{{$}}
99// CHECK-NEXT: {{^}}#endif{{$}}
100// CHECK-NEXT: {{^}}# 5 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes7.h"{{$}}
101// CHECK-NEXT: {{^}}# 21 "{{.*}}rewrite-includes.c" 2{{$}}
102// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
103// CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
104// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
105// CHECK-NEXT: {{^}}# 21 "{{.*}}rewrite-includes.c"{{$}}
106// CHECK-NEXT: {{^}}# 22 "{{.*}}rewrite-includes.c"{{$}}
107// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
108// CHECK-NEXT: {{^}}#include "rewrite-includes8.h"{{$}}
109// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
110// CHECK-NEXT: {{^}}# 22 "{{.*}}rewrite-includes.c"{{$}}
111// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h" 1{{$}}
112// CHECK-NEXT: {{^}}#if (1)/*__has_include_next(<rewrite-includes8.h>)*/{{$}}
113// CHECK-NEXT: {{^}}#elif (0)/*__has_include(<rewrite-includes8.hfail>)*/{{$}}
114// CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h"{{$}}
115// CHECK-NEXT: {{^}}#endif{{$}}
116// CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h"{{$}}
117// CHECK-NEXT: {{^}}#if !(1)/*__has_include("rewrite-includes8.h")*/{{$}}
118// CHECK-NEXT: {{^}}#endif{{$}}
119// CHECK-NEXT: {{^}}# 6 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h"{{$}}
120// CHECK-NEXT: {{^}}# 23 "{{.*}}rewrite-includes.c" 2{{$}}
121// CHECK-NEXT: {{^}}// ENDCOMPARE{{$}}
122
123// CHECKNL: {{^}}// STARTCOMPARE{{$}}
124// CHECKNL-NEXT: {{^}}#define A(a,b) a ## b{{$}}
125// CHECKNL-NEXT: {{^}}A(1,2){{$}}
126// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
127// CHECKNL-NEXT: {{^}}#include "rewrite-includes1.h"{{$}}
128// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
129// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
130// CHECKNL-NEXT: {{^}}#pragma clang system_header{{$}}
131// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
132// CHECKNL-NEXT: {{^}}included_line1{{$}}
133// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
134// CHECKNL-NEXT: {{^}}#include "rewrite-includes2.h"{{$}}
135// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
136// CHECKNL-NEXT: {{^}}included_line2{{$}}
137// CHECKNL-NEXT: {{^}}#ifdef FIRST{{$}}
138// CHECKNL-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}}
139// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
140// CHECKNL-NEXT: {{^}}#include HEADER{{$}}
141// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
142// CHECKNL-NEXT: {{^}}included_line3{{$}}
143// CHECKNL-NEXT: {{^}}#else{{$}}
144// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
145// CHECKNL-NEXT: {{^}}#include "rewrite-includes4.h"{{$}}
146// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
147// CHECKNL-NEXT: {{^}}#endif{{$}}
148// CHECKNL-NEXT: {{^}}  // indented{{$}}
149// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
150// CHECKNL-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}}
151// CHECKNL-NEXT: {{^}} {{$}}
152// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
153// CHECKNL-NEXT: {{^}}included_line5{{$}}
154// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
155// CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}}
156// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
157// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
158// CHECKNL-NEXT: {{^}}#pragma once{{$}}
159// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
160// CHECKNL-NEXT: {{^}}included_line6{{$}}
161// CHECKNL-NEXT: {{^}} {{$}}
162// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
163// CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}}
164// CHECKNL-NEXT: {{^}}                                  continues */{{$}}
165// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
166// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
167// CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
168// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
169// CHECKNL-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}}
170// CHECKNL-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}}
171// CHECKNL-NEXT: {{^}}included_line7{{$}}
172// CHECKNL-NEXT: {{^}}#endif{{$}}
173// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
174// CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
175// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
176// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
177// CHECKNL-NEXT: {{^}}#include "rewrite-includes8.h"{{$}}
178// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
179// CHECKNL-NEXT: {{^}}#if (1)/*__has_include_next(<rewrite-includes8.h>)*/{{$}}
180// CHECKNL-NEXT: {{^}}#elif (0)/*__has_include(<rewrite-includes8.hfail>)*/{{$}}
181// CHECKNL-NEXT: {{^}}#endif{{$}}
182// CHECKNL-NEXT: {{^}}#if !(1)/*__has_include("rewrite-includes8.h")*/{{$}}
183// CHECKNL-NEXT: {{^}}#endif{{$}}
184// CHECKNL-NEXT: {{^}}// ENDCOMPARE{{$}}
185