Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Index / annotate-comments.cpp
blob6f9f8f0bbbc9e587fb3c53d5c37a303a7dcecf84
1 // Run lines are sensitive to line numbers and come below the code.
3 #ifndef HEADER
4 #define HEADER
6 // Not a Doxygen comment. NOT_DOXYGEN
7 void notdoxy1(void);
9 /* Not a Doxygen comment. NOT_DOXYGEN */
10 void notdoxy2(void);
12 /*/ Not a Doxygen comment. NOT_DOXYGEN */
13 void notdoxy3(void);
15 /** Doxygen comment. isdoxy4 IS_DOXYGEN_SINGLE */
16 void isdoxy4(void);
18 /**
19 * Doxygen comment. isdoxy5 IS_DOXYGEN_SINGLE */
20 void isdoxy5(void);
22 /**
23 * Doxygen comment.
24 * isdoxy6 IS_DOXYGEN_SINGLE */
25 void isdoxy6(void);
27 /**
28 * Doxygen comment.
29 * isdoxy7 IS_DOXYGEN_SINGLE
31 void isdoxy7(void);
33 /*! Doxygen comment. isdoxy8 IS_DOXYGEN_SINGLE */
34 void isdoxy8(void);
36 /// Doxygen comment. isdoxy9 IS_DOXYGEN_SINGLE
37 void isdoxy9(void);
39 // Not a Doxygen comment. NOT_DOXYGEN
40 /// Doxygen comment. isdoxy10 IS_DOXYGEN_SINGLE
41 void isdoxy10(void);
43 /// Doxygen comment. isdoxy11 IS_DOXYGEN_SINGLE
44 // Not a Doxygen comment. NOT_DOXYGEN
45 void isdoxy11(void);
47 /** Doxygen comment. isdoxy12 IS_DOXYGEN_SINGLE */
48 /* Not a Doxygen comment. NOT_DOXYGEN */
49 void isdoxy12(void);
51 /// Doxygen comment. isdoxy13 IS_DOXYGEN_START
52 /// Doxygen comment. IS_DOXYGEN_END
53 void isdoxy13(void);
55 /// Doxygen comment. isdoxy14 IS_DOXYGEN_START
56 /// Blah-blah-blah.
57 /// Doxygen comment. IS_DOXYGEN_END
58 void isdoxy14(void);
60 /// Doxygen comment. isdoxy15 IS_DOXYGEN_START
61 /** Blah-blah-blah */
62 /// Doxygen comment. IS_DOXYGEN_END
63 void isdoxy15(void);
65 /** Blah-blah-blah. isdoxy16 IS_DOXYGEN_START *//** Blah */
66 /// Doxygen comment. IS_DOXYGEN_END
67 void isdoxy16(void);
69 /// NOT_DOXYGEN
70 // NOT_DOXYGEN
71 /// isdoxy17 IS_DOXYGEN_START IS_DOXYGEN_END
72 void isdoxy17(void);
74 unsigned
75 // NOT_DOXYGEN
76 /// NOT_DOXYGEN
77 // NOT_DOXYGEN
78 /// isdoxy18 IS_DOXYGEN_START IS_DOXYGEN_END
79 // NOT_DOXYGEN
80 int isdoxy18(void);
82 //! It all starts here. isdoxy19 IS_DOXYGEN_START
83 /*! It's a little odd to continue line this,
85 * but we need more multi-line comments. */
86 /// This comment comes before my other comments
87 /** This is a block comment that is associated with the function f. It
88 * runs for three lines. IS_DOXYGEN_END
90 void isdoxy19(int, int);
92 // NOT IN THE COMMENT NOT_DOXYGEN
93 /// This is a BCPL comment. isdoxy20 IS_DOXYGEN_START
94 /// It has only two lines.
95 /** But there are other blocks that are part of the comment, too. IS_DOXYGEN_END */
96 void isdoxy20(int);
98 void notdoxy21(int); ///< This is a member comment. isdoxy21 IS_DOXYGEN_NOT_ATTACHED
100 void notdoxy22(int); /*!< This is a member comment. isdoxy22 IS_DOXYGEN_NOT_ATTACHED */
102 void notdoxy23(int); /**< This is a member comment. isdoxy23 IS_DOXYGEN_NOT_ATTACHED */
104 void notdoxy24(int); // NOT_DOXYGEN
106 /// IS_DOXYGEN_SINGLE
107 struct isdoxy25 {
110 struct test26 {
111 /// IS_DOXYGEN_SINGLE
112 int isdoxy26;
115 struct test27 {
116 int isdoxy27; ///< IS_DOXYGEN_SINGLE
119 struct notdoxy28 {
120 }; ///< IS_DOXYGEN_NOT_ATTACHED
122 /// IS_DOXYGEN_SINGLE
123 enum isdoxy29 {
126 enum notdoxy30 {
127 }; ///< IS_DOXYGEN_NOT_ATTACHED
129 /// IS_DOXYGEN_SINGLE
130 namespace isdoxy31 {
133 namespace notdoxy32 {
134 }; ///< IS_DOXYGEN_NOT_ATTACHED
136 class test33 {
137 ///< IS_DOXYGEN_NOT_ATTACHED
138 int isdoxy33; ///< isdoxy33 IS_DOXYGEN_SINGLE
139 int isdoxy34; ///< isdoxy34 IS_DOXYGEN_SINGLE
141 ///< IS_DOXYGEN_NOT_ATTACHED
142 int isdoxy35, ///< isdoxy35 IS_DOXYGEN_SINGLE
143 isdoxy36; ///< isdoxy36 IS_DOXYGEN_SINGLE
145 ///< IS_DOXYGEN_NOT_ATTACHED
146 int isdoxy37 ///< isdoxy37 IS_DOXYGEN_SINGLE
147 , isdoxy38 ///< isdoxy38 IS_DOXYGEN_SINGLE
148 , isdoxy39; ///< isdoxy39 IS_DOXYGEN_SINGLE
151 // Verified that Doxygen attaches these.
153 /// isdoxy40 IS_DOXYGEN_SINGLE
154 // NOT_DOXYGEN
155 void isdoxy40(int);
157 unsigned
158 /// isdoxy41 IS_DOXYGEN_SINGLE
159 // NOT_DOXYGEN
160 int isdoxy41(int);
162 class test42 {
163 int isdoxy42; /* NOT_DOXYGEN */ ///< isdoxy42 IS_DOXYGEN_SINGLE
166 /// IS_DOXYGEN_START
167 /// It is fine to have a command at the end of comment.
168 ///\brief
170 /// Some malformed command.
171 /** \*/
173 * \brief Aaa aaaaaaa aaaa.
174 * IS_DOXYGEN_END
176 void isdoxy43(void);
178 /// IS_DOXYGEN_START Aaa bbb
179 /// ccc.
181 /// Ddd eee.
182 /// Fff.
184 /// Ggg. IS_DOXYGEN_END
185 void isdoxy44(void);
187 /// IS_DOXYGEN_START Aaa bbb
188 /// ccc.
190 /// \brief
191 /// Ddd eee.
192 /// Fff.
194 /// Ggg. IS_DOXYGEN_END
195 void isdoxy45(void);
197 /// IS_DOXYGEN_START Aaa bbb
198 /// ccc.
200 /// \short
201 /// Ddd eee.
202 /// Fff.
204 /// Ggg. IS_DOXYGEN_END
205 void isdoxy46(void);
207 /// IS_DOXYGEN_NOT_ATTACHED
208 #define FOO
209 void notdoxy47(void);
211 /// IS_DOXYGEN_START Aaa bbb
212 /// \param ccc
213 /// \returns ddd IS_DOXYGEN_END
214 void isdoxy48(int);
216 /// \brief IS_DOXYGEN_START Aaa
217 /// \returns bbb IS_DOXYGEN_END
218 void isdoxy49(void);
220 /// \param ccc IS_DOXYGEN_START
221 /// \returns ddd IS_DOXYGEN_END
222 void isdoxy50(int);
224 // One of the following lines has trailing whitespace. It is intended, don't
225 // fix it.
227 * Aaa. IS_DOXYGEN_START
229 * Bbb. IS_DOXYGEN_END
231 void isdoxy51(int);
233 // One of the following lines has trailing whitespace. It is intended, don't
234 // fix it.
236 * Aaa. IS_DOXYGEN_START
237 * Bbb.
239 * Ccc. IS_DOXYGEN_END
241 void isdoxy52(int);
244 * \fn isdoxy53
246 * Aaa. IS_DOXYGEN_START IS_DOXYGEN_END
248 void isdoxy53(int);
250 #define MYMAC(x,y)
252 * Aaa. IS_DOXYGEN_START IS_DOXYGEN_END
254 MYMAC(0,0)
255 void isdoxy54(int);
257 #endif
259 // RUN: rm -rf %t
260 // RUN: mkdir %t
262 // Check that we serialize comment source locations properly.
263 // RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -o %t/out.pch %s
264 // RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t/out.pch -fsyntax-only %s
266 // RUN: c-index-test -write-pch %t/out.pch -x c++ -std=c++11 %s
267 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s -std=c++11 > %t/out.c-index-direct
268 // RUN: c-index-test -test-load-tu %t/out.pch all > %t/out.c-index-pch
270 // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct
271 // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-pch
273 // Declarations without Doxygen comments should not pick up some Doxygen comments.
274 // WRONG-NOT: notdoxy{{.*}}Comment=
275 // WRONG-NOT: test{{.*}}Comment=
277 // Non-Doxygen comments should not be attached to anything.
278 // WRONG-NOT: NOT_DOXYGEN
280 // Some Doxygen comments are not attached to anything.
281 // WRONG-NOT: IS_DOXYGEN_NOT_ATTACHED
283 // Ensure we don't pick up extra comments.
284 // WRONG-NOT: IS_DOXYGEN_START{{.*}}IS_DOXYGEN_START{{.*}}BriefComment=
285 // WRONG-NOT: IS_DOXYGEN_END{{.*}}IS_DOXYGEN_END{{.*}}BriefComment=
287 // Ensure that XML is not invalid
288 // WRONG-NOT: CommentXMLInvalid
290 // RUN: FileCheck %s < %t/out.c-index-direct
291 // RUN: FileCheck %s < %t/out.c-index-pch
293 // These CHECK lines are not located near the code on purpose. This test
294 // checks that documentation comments are attached to declarations correctly.
295 // Adding a non-documentation comment with CHECK line between every two
296 // documentation comments will only test a single code path.
298 // CHECK: annotate-comments.cpp:16:6: FunctionDecl=isdoxy4:{{.*}} isdoxy4 IS_DOXYGEN_SINGLE
299 // CHECK: annotate-comments.cpp:20:6: FunctionDecl=isdoxy5:{{.*}} isdoxy5 IS_DOXYGEN_SINGLE
300 // CHECK: annotate-comments.cpp:25:6: FunctionDecl=isdoxy6:{{.*}} isdoxy6 IS_DOXYGEN_SINGLE
301 // CHECK: annotate-comments.cpp:31:6: FunctionDecl=isdoxy7:{{.*}} isdoxy7 IS_DOXYGEN_SINGLE
302 // CHECK: annotate-comments.cpp:34:6: FunctionDecl=isdoxy8:{{.*}} isdoxy8 IS_DOXYGEN_SINGLE
303 // CHECK: annotate-comments.cpp:37:6: FunctionDecl=isdoxy9:{{.*}} isdoxy9 IS_DOXYGEN_SINGLE
304 // CHECK: annotate-comments.cpp:41:6: FunctionDecl=isdoxy10:{{.*}} isdoxy10 IS_DOXYGEN_SINGLE
305 // CHECK: annotate-comments.cpp:53:6: FunctionDecl=isdoxy13:{{.*}} isdoxy13 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
306 // CHECK: annotate-comments.cpp:58:6: FunctionDecl=isdoxy14:{{.*}} isdoxy14 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
307 // CHECK: annotate-comments.cpp:63:6: FunctionDecl=isdoxy15:{{.*}} isdoxy15 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
308 // CHECK: annotate-comments.cpp:67:6: FunctionDecl=isdoxy16:{{.*}} isdoxy16 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
309 // CHECK: annotate-comments.cpp:72:6: FunctionDecl=isdoxy17:{{.*}} isdoxy17 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
310 // CHECK: annotate-comments.cpp:80:5: FunctionDecl=isdoxy18:{{.*}} isdoxy18 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
311 // CHECK: annotate-comments.cpp:90:6: FunctionDecl=isdoxy19:{{.*}} isdoxy19 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
312 // CHECK: annotate-comments.cpp:96:6: FunctionDecl=isdoxy20:{{.*}} isdoxy20 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
313 // CHECK: annotate-comments.cpp:107:8: StructDecl=isdoxy25:{{.*}} IS_DOXYGEN_SINGLE
314 // CHECK: annotate-comments.cpp:112:7: FieldDecl=isdoxy26:{{.*}} IS_DOXYGEN_SINGLE
315 // CHECK: annotate-comments.cpp:116:7: FieldDecl=isdoxy27:{{.*}} IS_DOXYGEN_SINGLE
316 // CHECK: annotate-comments.cpp:123:6: EnumDecl=isdoxy29:{{.*}} IS_DOXYGEN_SINGLE
317 // CHECK: annotate-comments.cpp:130:11: Namespace=isdoxy31:{{.*}} IS_DOXYGEN_SINGLE
318 // CHECK: annotate-comments.cpp:138:7: FieldDecl=isdoxy33:{{.*}} isdoxy33 IS_DOXYGEN_SINGLE
319 // CHECK: annotate-comments.cpp:139:7: FieldDecl=isdoxy34:{{.*}} isdoxy34 IS_DOXYGEN_SINGLE
320 // CHECK: annotate-comments.cpp:142:7: FieldDecl=isdoxy35:{{.*}} isdoxy35 IS_DOXYGEN_SINGLE
321 // CHECK: annotate-comments.cpp:143:7: FieldDecl=isdoxy36:{{.*}} isdoxy36 IS_DOXYGEN_SINGLE
322 // CHECK: annotate-comments.cpp:146:7: FieldDecl=isdoxy37:{{.*}} isdoxy37 IS_DOXYGEN_SINGLE
323 // CHECK: annotate-comments.cpp:147:7: FieldDecl=isdoxy38:{{.*}} isdoxy38 IS_DOXYGEN_SINGLE
324 // CHECK: annotate-comments.cpp:148:7: FieldDecl=isdoxy39:{{.*}} isdoxy39 IS_DOXYGEN_SINGLE
325 // CHECK: annotate-comments.cpp:155:6: FunctionDecl=isdoxy40:{{.*}} isdoxy40 IS_DOXYGEN_SINGLE
326 // CHECK: annotate-comments.cpp:160:5: FunctionDecl=isdoxy41:{{.*}} isdoxy41 IS_DOXYGEN_SINGLE
327 // CHECK: annotate-comments.cpp:163:7: FieldDecl=isdoxy42:{{.*}} isdoxy42 IS_DOXYGEN_SINGLE
328 // CHECK: annotate-comments.cpp:176:6: FunctionDecl=isdoxy43:{{.*}} IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
330 // CHECK: annotate-comments.cpp:185:6: FunctionDecl=isdoxy44:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb ccc.]
331 // CHECK: annotate-comments.cpp:195:6: FunctionDecl=isdoxy45:{{.*}} BriefComment=[Ddd eee. Fff.]
332 // CHECK: annotate-comments.cpp:205:6: FunctionDecl=isdoxy46:{{.*}} BriefComment=[Ddd eee. Fff.]
333 // CHECK: annotate-comments.cpp:214:6: FunctionDecl=isdoxy48:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb]
334 // CHECK: annotate-comments.cpp:218:6: FunctionDecl=isdoxy49:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa]
335 // CHECK: annotate-comments.cpp:222:6: FunctionDecl=isdoxy50:{{.*}} BriefComment=[Returns ddd IS_DOXYGEN_END]
336 // CHECK: annotate-comments.cpp:231:6: FunctionDecl=isdoxy51:{{.*}} BriefComment=[Aaa. IS_DOXYGEN_START]
337 // CHECK: annotate-comments.cpp:241:6: FunctionDecl=isdoxy52:{{.*}} BriefComment=[Aaa. IS_DOXYGEN_START Bbb.]
338 // CHECK: annotate-comments.cpp:248:6: FunctionDecl=isdoxy53:{{.*}} BriefComment=[Aaa. IS_DOXYGEN_START IS_DOXYGEN_END]
339 // CHECK: annotate-comments.cpp:255:6: FunctionDecl=isdoxy54:{{.*}} BriefComment=[Aaa. IS_DOXYGEN_START IS_DOXYGEN_END]