• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -E -frewrite-includes -DFIRST -I %S/Inputs %s -o - | FileCheck -strict-whitespace %s
2 // RUN: %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
5 A(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 #/**/include /**/ "rewrite-includes5.h" /**/ \
14 
15 #include "rewrite-includes6.h" // comment
16 
17 #include "rewrite-includes6.h" /* comment
18                                   continues */
19 #include "rewrite-includes7.h"
20 #include "rewrite-includes7.h"
21 // ENDCOMPARE
22 // CHECK: {{^}}// STARTCOMPARE{{$}}
23 // CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}}
24 // CHECK-NEXT: {{^}}A(1,2){{$}}
25 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
26 // CHECK-NEXT: {{^}}#include "rewrite-includes1.h"{{$}}
27 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
28 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes1.h" 1{{$}}
29 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
30 // CHECK-NEXT: {{^}}#pragma clang system_header{{$}}
31 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
32 // CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs[/\\]}}rewrite-includes1.h" 3{{$}}
33 // CHECK-NEXT: {{^}}included_line1{{$}}
34 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
35 // CHECK-NEXT: {{^}}#include "rewrite-includes2.h"{{$}}
36 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
37 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes2.h" 1 3{{$}}
38 // CHECK-NEXT: {{^}}included_line2{{$}}
39 // CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs[/\\]}}rewrite-includes1.h" 2 3{{$}}
40 // CHECK-NEXT: {{^}}# 7 "{{.*}}rewrite-includes.c" 2{{$}}
41 // CHECK-NEXT: {{^}}#ifdef FIRST{{$}}
42 // CHECK-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}}
43 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
44 // CHECK-NEXT: {{^}}#include HEADER{{$}}
45 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
46 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes3.h" 1{{$}}
47 // CHECK-NEXT: {{^}}included_line3{{$}}
48 // CHECK-NEXT: {{^}}# 10 "{{.*}}rewrite-includes.c" 2{{$}}
49 // CHECK-NEXT: {{^}}#else{{$}}
50 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
51 // CHECK-NEXT: {{^}}#include "rewrite-includes4.h"{{$}}
52 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
53 // CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}}
54 // CHECK-NEXT: {{^}}#endif{{$}}
55 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
56 // CHECK-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}}
57 // CHECK-NEXT: {{^}} {{$}}
58 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
59 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes5.h" 1{{$}}
60 // CHECK-NEXT: {{^}}included_line5{{$}}
61 // CHECK-NEXT: {{^}}# 15 "{{.*}}rewrite-includes.c" 2{{$}}
62 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
63 // CHECK-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}}
64 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
65 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes6.h" 1{{$}}
66 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
67 // CHECK-NEXT: {{^}}#pragma once{{$}}
68 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
69 // CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs[/\\]}}rewrite-includes6.h"{{$}}
70 // CHECK-NEXT: {{^}}included_line6{{$}}
71 // CHECK-NEXT: {{^}}# 16 "{{.*}}rewrite-includes.c" 2{{$}}
72 // CHECK-NEXT: {{^}} {{$}}
73 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
74 // CHECK-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}}
75 // CHECK-NEXT: {{^}}                                  continues */{{$}}
76 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
77 // CHECK-NEXT: {{^}}# 19 "{{.*}}rewrite-includes.c"{{$}}
78 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
79 // CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
80 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
81 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes7.h" 1{{$}}
82 // CHECK-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}}
83 // CHECK-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}}
84 // CHECK-NEXT: {{^}}included_line7{{$}}
85 // CHECK-NEXT: {{^}}#endif{{$}}
86 // CHECK-NEXT: {{^}}# 20 "{{.*}}rewrite-includes.c" 2{{$}}
87 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
88 // CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
89 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
90 // CHECK-NEXT: {{^}}# 21 "{{.*}}rewrite-includes.c"{{$}}
91 // CHECK-NEXT: {{^}}// ENDCOMPARE{{$}}
92 
93 // CHECKNL: {{^}}// STARTCOMPARE{{$}}
94 // CHECKNL-NEXT: {{^}}#define A(a,b) a ## b{{$}}
95 // CHECKNL-NEXT: {{^}}A(1,2){{$}}
96 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
97 // CHECKNL-NEXT: {{^}}#include "rewrite-includes1.h"{{$}}
98 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
99 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
100 // CHECKNL-NEXT: {{^}}#pragma clang system_header{{$}}
101 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
102 // CHECKNL-NEXT: {{^}}included_line1{{$}}
103 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
104 // CHECKNL-NEXT: {{^}}#include "rewrite-includes2.h"{{$}}
105 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
106 // CHECKNL-NEXT: {{^}}included_line2{{$}}
107 // CHECKNL-NEXT: {{^}}#ifdef FIRST{{$}}
108 // CHECKNL-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}}
109 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
110 // CHECKNL-NEXT: {{^}}#include HEADER{{$}}
111 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
112 // CHECKNL-NEXT: {{^}}included_line3{{$}}
113 // CHECKNL-NEXT: {{^}}#else{{$}}
114 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
115 // CHECKNL-NEXT: {{^}}#include "rewrite-includes4.h"{{$}}
116 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
117 // CHECKNL-NEXT: {{^}}#endif{{$}}
118 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
119 // CHECKNL-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}}
120 // CHECKNL-NEXT: {{^}} {{$}}
121 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
122 // CHECKNL-NEXT: {{^}}included_line5{{$}}
123 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
124 // CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}}
125 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
126 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
127 // CHECKNL-NEXT: {{^}}#pragma once{{$}}
128 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
129 // CHECKNL-NEXT: {{^}}included_line6{{$}}
130 // CHECKNL-NEXT: {{^}} {{$}}
131 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
132 // CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}}
133 // CHECKNL-NEXT: {{^}}                                  continues */{{$}}
134 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
135 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
136 // CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
137 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
138 // CHECKNL-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}}
139 // CHECKNL-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}}
140 // CHECKNL-NEXT: {{^}}included_line7{{$}}
141 // CHECKNL-NEXT: {{^}}#endif{{$}}
142 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
143 // CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}}
144 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
145 // CHECKNL-NEXT: {{^}}// ENDCOMPARE{{$}}
146