• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -E -frewrite-includes -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | FileCheck -strict-whitespace %s
2 // RUN: %clang_cc1 -E -frewrite-includes -P -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | FileCheck -check-prefix=CHECKNL -strict-whitespace %s
3 // RUN: %clang_cc1 -E -frewrite-includes -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | %clang_cc1 -Wall -Wextra -Wconversion -DFIRST -x c -fsyntax-only 2>&1 | FileCheck -check-prefix=COMPILE --implicit-check-not warning: %s
4 // STARTCOMPARE
5 #define A(a,b) a ## b
6 A(in,t) a;
7 #include "rewrite-includes1.h"
8 #ifdef FIRST
9 #define HEADER "rewrite-includes3.h"
10 #include HEADER
11 #else
12 #include "rewrite-includes4.h"
13 #endif
14   // indented
15 #/**/include /**/ "rewrite-includes5.h" /**/ \
16 
17 #include "rewrite-includes6.h" // comment
18 
19 #include "rewrite-includes6.h" /* comment
20                                   continues */
21 #include "rewrite-includes7.h"
22 #include "rewrite-includes7.h"
23 #include "rewrite-includes8.h"
24 #include "rewrite-includes9.h"
25 static int unused;
26 // ENDCOMPARE
27 // CHECK: {{^}}# 1 "{{.*}}rewrite-includes.c"{{$}}
28 // CHECK: {{^}}// STARTCOMPARE{{$}}
29 // CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}}
30 // CHECK-NEXT: {{^}}A(in,t) a;{{$}}
31 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
32 // CHECK-NEXT: {{^}}#include "rewrite-includes1.h"{{$}}
33 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
34 // CHECK-NEXT: {{^}}# 7 "{{.*}}rewrite-includes.c"{{$}}
35 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes1.h" 1{{$}}
36 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
37 // CHECK-NEXT: {{^}}#pragma clang system_header{{$}}
38 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
39 // CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes1.h" 3{{$}}
40 // CHECK-NEXT: {{^}}int included_line1;{{$}}
41 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
42 // CHECK-NEXT: {{^}}#include "rewrite-includes2.h"{{$}}
43 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
44 // CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes1.h" 3{{$}}
45 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes2.h" 1 3{{$}}
46 // CHECK-NEXT: {{^}}int included_line2;{{$}}
47 // CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes1.h" 2 3{{$}}
48 // CHECK-NEXT: {{^}}# 8 "{{.*}}rewrite-includes.c" 2{{$}}
49 // CHECK-NEXT: {{^}}#ifdef FIRST{{$}}
50 // CHECK-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}}
51 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
52 // CHECK-NEXT: {{^}}#include HEADER{{$}}
53 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
54 // CHECK-NEXT: {{^}}# 10 "{{.*}}rewrite-includes.c"{{$}}
55 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes3.h" 1{{$}}
56 // CHECK-NEXT: {{^}}unsigned int included_line3 = -10;{{$}}
57 // CHECK-NEXT: {{^}}# 11 "{{.*}}rewrite-includes.c" 2{{$}}
58 // CHECK-NEXT: {{^}}#else{{$}}
59 // CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}}
60 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
61 // CHECK-NEXT: {{^}}#include "rewrite-includes4.h"{{$}}
62 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
63 // CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}}
64 // CHECK-NEXT: {{^}}# 13 "{{.*}}rewrite-includes.c"{{$}}
65 // CHECK-NEXT: {{^}}#endif{{$}}
66 // CHECK-NEXT: {{^}}# 14 "{{.*}}rewrite-includes.c"{{$}}
67 // CHECK-NEXT: {{^}}  // indented{{$}}
68 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
69 // CHECK-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}}
70 // CHECK-NEXT: {{^}} {{$}}
71 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
72 // CHECK-NEXT: {{^}}# 16 "{{.*}}rewrite-includes.c"{{$}}
73 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes5.h" 1{{$}}
74 // CHECK-NEXT: {{^}}int included_line5;{{$}}
75 // CHECK-NEXT: {{^}}# 17 "{{.*}}rewrite-includes.c" 2{{$}}
76 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
77 // CHECK-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}}
78 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
79 // CHECK-NEXT: {{^}}# 17 "{{.*}}rewrite-includes.c"{{$}}
80 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes6.h" 1{{$}}
81 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
82 // CHECK-NEXT: {{^}}#pragma once{{$}}
83 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
84 // CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes6.h"{{$}}
85 // CHECK-NEXT: {{^}}int included_line6;{{$}}
86 // CHECK-NEXT: {{^}}# 18 "{{.*}}rewrite-includes.c" 2{{$}}
87 // CHECK-NEXT: {{^}} {{$}}
88 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
89 // CHECK-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}}
90 // CHECK-NEXT: {{^}}                                  continues */{{$}}
91 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
92 // CHECK-NEXT: {{^}}# 20 "{{.*}}rewrite-includes.c"{{$}}
93 // CHECK-NEXT: {{^}}# 21 "{{.*}}rewrite-includes.c"{{$}}
94 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
95 // CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
96 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
97 // CHECK-NEXT: {{^}}# 21 "{{.*}}rewrite-includes.c"{{$}}
98 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes7.h" 1{{$}}
99 // CHECK-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}}
100 // CHECK-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}}
101 // CHECK-NEXT: {{^}}int included_line7;{{$}}
102 // CHECK-NEXT: {{^}}#endif{{$}}
103 // CHECK-NEXT: {{^}}# 5 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes7.h"{{$}}
104 // CHECK-NEXT: {{^}}# 22 "{{.*}}rewrite-includes.c" 2{{$}}
105 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
106 // CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
107 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
108 // CHECK-NEXT: {{^}}# 22 "{{.*}}rewrite-includes.c"{{$}}
109 // CHECK-NEXT: {{^}}# 23 "{{.*}}rewrite-includes.c"{{$}}
110 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
111 // CHECK-NEXT: {{^}}#include "rewrite-includes8.h"{{$}}
112 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
113 // CHECK-NEXT: {{^}}# 23 "{{.*}}rewrite-includes.c"{{$}}
114 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h" 1{{$}}
115 // CHECK-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
116 // CHECK-NEXT: {{^}}#if __has_include_next(<rewrite-includes8.h>){{$}}
117 // CHECK-NEXT: {{^}}#endif{{$}}
118 // CHECK-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
119 // CHECK-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */{{$}}
120 // CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h"{{$}}
121 // CHECK-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
122 // CHECK-NEXT: {{^}}#if 0{{$}}
123 // CHECK-NEXT: {{^}}#elif __has_include(<rewrite-includes8.hfail>){{$}}
124 // CHECK-NEXT: {{^}}#endif{{$}}
125 // CHECK-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
126 // CHECK-NEXT: {{^}}#elif 0 /* evaluated by -frewrite-includes */{{$}}
127 // CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h"{{$}}
128 // CHECK-NEXT: {{^}}#endif{{$}}
129 // CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h"{{$}}
130 // CHECK-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
131 // CHECK-NEXT: {{^}}#if !__has_include("rewrite-includes8.h"){{$}}
132 // CHECK-NEXT: {{^}}#endif{{$}}
133 // CHECK-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
134 // CHECK-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */{{$}}
135 // CHECK-NEXT: {{^}}# 5 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h"{{$}}
136 // CHECK-NEXT: {{^}}#endif{{$}}
137 // CHECK-NEXT: {{^}}# 6 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes8.h"{{$}}
138 // CHECK-NEXT: {{^}}# 24 "{{.*}}rewrite-includes.c" 2{{$}}
139 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
140 // CHECK-NEXT: {{^}}#include "rewrite-includes9.h"{{$}}
141 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
142 // CHECK-NEXT: {{^}}# 24 "{{.*}}rewrite-includes.c"{{$}}
143 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes9.h" 1{{$}}
144 // CHECK-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
145 // CHECK-NEXT: {{^}}#if __has_include_next(<rewrite-includes9.h>){{$}}
146 // CHECK-NEXT: {{^}}#endif{{$}}
147 // CHECK-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
148 // CHECK-NEXT: {{^}}#if 1 /* evaluated by -frewrite-includes */{{$}}
149 // CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes9.h"{{$}}
150 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
151 // CHECK-NEXT: {{^}}#include_next <rewrite-includes9.h>{{$}}
152 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
153 // CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes9.h"{{$}}
154 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)NextIncludes(/|\\\\)}}rewrite-includes9.h" 1{{$}}
155 // CHECK-NEXT: {{^}}int included_line9;{{$}}
156 // CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes9.h" 2{{$}}
157 // CHECK-NEXT: {{^}}#endif{{$}}
158 // CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes9.h"{{$}}
159 // CHECK-NEXT: {{^}}# 25 "{{.*}}rewrite-includes.c" 2{{$}}
160 // CHECK-NEXT: {{^}}static int unused;{{$}}
161 // CHECK-NEXT: {{^}}// ENDCOMPARE{{$}}
162 
163 // CHECKNL: {{^}}// STARTCOMPARE{{$}}
164 // CHECKNL-NEXT: {{^}}#define A(a,b) a ## b{{$}}
165 // CHECKNL-NEXT: {{^}}A(in,t) a;{{$}}
166 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
167 // CHECKNL-NEXT: {{^}}#include "rewrite-includes1.h"{{$}}
168 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
169 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
170 // CHECKNL-NEXT: {{^}}#pragma clang system_header{{$}}
171 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
172 // CHECKNL-NEXT: {{^}}int included_line1;{{$}}
173 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
174 // CHECKNL-NEXT: {{^}}#include "rewrite-includes2.h"{{$}}
175 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
176 // CHECKNL-NEXT: {{^}}int included_line2;{{$}}
177 // CHECKNL-NEXT: {{^}}#ifdef FIRST{{$}}
178 // CHECKNL-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}}
179 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
180 // CHECKNL-NEXT: {{^}}#include HEADER{{$}}
181 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
182 // CHECKNL-NEXT: {{^}}unsigned int included_line3 = -10;{{$}}
183 // CHECKNL-NEXT: {{^}}#else{{$}}
184 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
185 // CHECKNL-NEXT: {{^}}#include "rewrite-includes4.h"{{$}}
186 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
187 // CHECKNL-NEXT: {{^}}#endif{{$}}
188 // CHECKNL-NEXT: {{^}}  // indented{{$}}
189 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
190 // CHECKNL-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}}
191 // CHECKNL-NEXT: {{^}} {{$}}
192 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
193 // CHECKNL-NEXT: {{^}}int included_line5;{{$}}
194 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
195 // CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}}
196 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
197 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
198 // CHECKNL-NEXT: {{^}}#pragma once{{$}}
199 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
200 // CHECKNL-NEXT: {{^}}int included_line6;{{$}}
201 // CHECKNL-NEXT: {{^}} {{$}}
202 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
203 // CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}}
204 // CHECKNL-NEXT: {{^}}                                  continues */{{$}}
205 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
206 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
207 // CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
208 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
209 // CHECKNL-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}}
210 // CHECKNL-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}}
211 // CHECKNL-NEXT: {{^}}int included_line7;{{$}}
212 // CHECKNL-NEXT: {{^}}#endif{{$}}
213 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
214 // CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
215 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
216 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
217 // CHECKNL-NEXT: {{^}}#include "rewrite-includes8.h"{{$}}
218 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
219 // CHECKNL-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
220 // CHECKNL-NEXT: {{^}}#if __has_include_next(<rewrite-includes8.h>){{$}}
221 // CHECKNL-NEXT: {{^}}#endif{{$}}
222 // CHECKNL-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
223 // CHECKNL-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */{{$}}
224 // CHECKNL-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
225 // CHECKNL-NEXT: {{^}}#if 0{{$}}
226 // CHECKNL-NEXT: {{^}}#elif __has_include(<rewrite-includes8.hfail>){{$}}
227 // CHECKNL-NEXT: {{^}}#endif{{$}}
228 // CHECKNL-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
229 // CHECKNL-NEXT: {{^}}#elif 0 /* evaluated by -frewrite-includes */{{$}}
230 // CHECKNL-NEXT: {{^}}#endif{{$}}
231 // CHECKNL-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
232 // CHECKNL-NEXT: {{^}}#if !__has_include("rewrite-includes8.h"){{$}}
233 // CHECKNL-NEXT: {{^}}#endif{{$}}
234 // CHECKNL-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
235 // CHECKNL-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */{{$}}
236 // CHECKNL-NEXT: {{^}}#endif{{$}}
237 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
238 // CHECKNL-NEXT: {{^}}#include "rewrite-includes9.h"{{$}}
239 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
240 // CHECKNL-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
241 // CHECKNL-NEXT: {{^}}#if __has_include_next(<rewrite-includes9.h>){{$}}
242 // CHECKNL-NEXT: {{^}}#endif{{$}}
243 // CHECKNL-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
244 // CHECKNL-NEXT: {{^}}#if 1 /* evaluated by -frewrite-includes */{{$}}
245 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
246 // CHECKNL-NEXT: {{^}}#include_next <rewrite-includes9.h>{{$}}
247 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
248 // CHECKNL-NEXT: {{^}}int included_line9;{{$}}
249 // CHECKNL-NEXT: {{^}}#endif{{$}}
250 // CHECKNL-NEXT: {{^}}static int unused;{{$}}
251 // CHECKNL-NEXT: {{^}}// ENDCOMPARE{{$}}
252 
253 // COMPILE: Inputs{{[/\\]}}rewrite-includes3.h:1:31: warning: implicit conversion changes signedness:
254 // COMPILE: rewrite-includes.c:25:12: warning: unused variable 'unused'
255