blob: 2a0b635de85cf0b45c5e767b084496034b875019 [file] [log] [blame]
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +00001// Run lines are sensitive to line numbers and come below the code.
2
3#ifndef HEADER
4#define HEADER
5
6// Not a Doxygen comment. NOT_DOXYGEN
7void notdoxy1(void);
8
9/* Not a Doxygen comment. NOT_DOXYGEN */
10void notdoxy2(void);
11
12/*/ Not a Doxygen comment. NOT_DOXYGEN */
13void notdoxy3(void);
14
15/** Doxygen comment. isdoxy4 IS_DOXYGEN_SINGLE */
16void isdoxy4(void);
17
18/**
19 * Doxygen comment. isdoxy5 IS_DOXYGEN_SINGLE */
20void isdoxy5(void);
21
22/**
23 * Doxygen comment.
24 * isdoxy6 IS_DOXYGEN_SINGLE */
25void isdoxy6(void);
26
27/**
28 * Doxygen comment.
29 * isdoxy7 IS_DOXYGEN_SINGLE
30 */
31void isdoxy7(void);
32
33/*! Doxygen comment. isdoxy8 IS_DOXYGEN_SINGLE */
34void isdoxy8(void);
35
36/// Doxygen comment. isdoxy9 IS_DOXYGEN_SINGLE
37void isdoxy9(void);
38
39// Not a Doxygen comment. NOT_DOXYGEN
40/// Doxygen comment. isdoxy10 IS_DOXYGEN_SINGLE
41void isdoxy10(void);
42
43/// Doxygen comment. isdoxy11 IS_DOXYGEN_SINGLE
44// Not a Doxygen comment. NOT_DOXYGEN
45void isdoxy11(void);
46
47/** Doxygen comment. isdoxy12 IS_DOXYGEN_SINGLE */
48/* Not a Doxygen comment. NOT_DOXYGEN */
49void isdoxy12(void);
50
51/// Doxygen comment. isdoxy13 IS_DOXYGEN_START
52/// Doxygen comment. IS_DOXYGEN_END
53void isdoxy13(void);
54
55/// Doxygen comment. isdoxy14 IS_DOXYGEN_START
56/// Blah-blah-blah.
57/// Doxygen comment. IS_DOXYGEN_END
58void isdoxy14(void);
59
60/// Doxygen comment. isdoxy15 IS_DOXYGEN_START
61/** Blah-blah-blah */
62/// Doxygen comment. IS_DOXYGEN_END
63void isdoxy15(void);
64
65/** Blah-blah-blah. isdoxy16 IS_DOXYGEN_START *//** Blah */
66/// Doxygen comment. IS_DOXYGEN_END
67void isdoxy16(void);
68
Dmitri Gribenkoc88c6a42012-08-28 01:20:53 +000069/// NOT_DOXYGEN
70// NOT_DOXYGEN
71/// isdoxy17 IS_DOXYGEN_START IS_DOXYGEN_END
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +000072void isdoxy17(void);
73
74unsigned
75// NOT_DOXYGEN
Dmitri Gribenkoc88c6a42012-08-28 01:20:53 +000076/// NOT_DOXYGEN
77// NOT_DOXYGEN
78/// isdoxy18 IS_DOXYGEN_START IS_DOXYGEN_END
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +000079// NOT_DOXYGEN
80int isdoxy18(void);
81
82//! It all starts here. isdoxy19 IS_DOXYGEN_START
83/*! It's a little odd to continue line this,
84 *
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
89 */
90void isdoxy19(int, int);
91
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 */
96void isdoxy20(int);
97
Dmitri Gribenko9c006762012-07-06 23:27:33 +000098void notdoxy21(int); ///< This is a member comment. isdoxy21 IS_DOXYGEN_NOT_ATTACHED
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +000099
Dmitri Gribenko9c006762012-07-06 23:27:33 +0000100void notdoxy22(int); /*!< This is a member comment. isdoxy22 IS_DOXYGEN_NOT_ATTACHED */
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +0000101
Dmitri Gribenko9c006762012-07-06 23:27:33 +0000102void notdoxy23(int); /**< This is a member comment. isdoxy23 IS_DOXYGEN_NOT_ATTACHED */
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +0000103
104void notdoxy24(int); // NOT_DOXYGEN
105
106/// IS_DOXYGEN_SINGLE
107struct isdoxy25 {
108};
109
110struct test26 {
111 /// IS_DOXYGEN_SINGLE
112 int isdoxy26;
113};
114
115struct test27 {
116 int isdoxy27; ///< IS_DOXYGEN_SINGLE
117};
118
119struct notdoxy28 {
120}; ///< IS_DOXYGEN_NOT_ATTACHED
121
122/// IS_DOXYGEN_SINGLE
123enum isdoxy29 {
124};
125
126enum notdoxy30 {
127}; ///< IS_DOXYGEN_NOT_ATTACHED
128
129/// IS_DOXYGEN_SINGLE
130namespace isdoxy31 {
131};
132
133namespace notdoxy32 {
134}; ///< IS_DOXYGEN_NOT_ATTACHED
135
136class test33 {
137 ///< IS_DOXYGEN_NOT_ATTACHED
138 int isdoxy33; ///< isdoxy33 IS_DOXYGEN_SINGLE
139 int isdoxy34; ///< isdoxy34 IS_DOXYGEN_SINGLE
140
141 ///< IS_DOXYGEN_NOT_ATTACHED
142 int isdoxy35, ///< isdoxy35 IS_DOXYGEN_SINGLE
143 isdoxy36; ///< isdoxy36 IS_DOXYGEN_SINGLE
144
145 ///< IS_DOXYGEN_NOT_ATTACHED
146 int isdoxy37 ///< isdoxy37 IS_DOXYGEN_SINGLE
147 , isdoxy38 ///< isdoxy38 IS_DOXYGEN_SINGLE
148 , isdoxy39; ///< isdoxy39 IS_DOXYGEN_SINGLE
149};
150
151// Verified that Doxygen attaches these.
152
153/// isdoxy40 IS_DOXYGEN_SINGLE
154// NOT_DOXYGEN
155void isdoxy40(int);
156
157unsigned
158/// isdoxy41 IS_DOXYGEN_SINGLE
159// NOT_DOXYGEN
160int isdoxy41(int);
161
162class test42 {
163 int isdoxy42; /* NOT_DOXYGEN */ ///< isdoxy42 IS_DOXYGEN_SINGLE
164};
165
Dmitri Gribenko2d44d772012-06-26 20:39:18 +0000166/// IS_DOXYGEN_START
167/// It is fine to have a command at the end of comment.
168///\brief
169///
170/// Some malformed command.
Dmitri Gribenkoc88c6a42012-08-28 01:20:53 +0000171/** \*/
Dmitri Gribenko2d44d772012-06-26 20:39:18 +0000172/**
173 * \brief Aaa aaaaaaa aaaa.
174 * IS_DOXYGEN_END
175 */
176void isdoxy43(void);
177
178/// IS_DOXYGEN_START Aaa bbb
179/// ccc.
180///
181/// Ddd eee.
182/// Fff.
183///
184/// Ggg. IS_DOXYGEN_END
185void isdoxy44(void);
186
187/// IS_DOXYGEN_START Aaa bbb
188/// ccc.
189///
190/// \brief
191/// Ddd eee.
192/// Fff.
193///
194/// Ggg. IS_DOXYGEN_END
195void isdoxy45(void);
196
Dmitri Gribenko659a7122012-07-17 18:35:14 +0000197/// IS_DOXYGEN_START Aaa bbb
198/// ccc.
199///
200/// \short
201/// Ddd eee.
202/// Fff.
203///
204/// Ggg. IS_DOXYGEN_END
205void isdoxy46(void);
206
Dmitri Gribenko8bdb58a2012-06-27 23:43:37 +0000207/// IS_DOXYGEN_NOT_ATTACHED
208#define FOO
Dmitri Gribenko659a7122012-07-17 18:35:14 +0000209void notdoxy47(void);
Dmitri Gribenko8bdb58a2012-06-27 23:43:37 +0000210
Dmitri Gribenkof199b9c2012-06-28 00:01:41 +0000211/// IS_DOXYGEN_START Aaa bbb
212/// \param ccc
213/// \returns ddd IS_DOXYGEN_END
Dmitri Gribenko659a7122012-07-17 18:35:14 +0000214void isdoxy48(int);
Dmitri Gribenkof199b9c2012-06-28 00:01:41 +0000215
Dmitri Gribenko72021ff2012-07-20 17:01:34 +0000216/// \brief IS_DOXYGEN_START Aaa
217/// \returns bbb IS_DOXYGEN_END
218void isdoxy49(void);
219
220/// \param ccc IS_DOXYGEN_START
221/// \returns ddd IS_DOXYGEN_END
222void isdoxy50(int);
223
Dmitri Gribenko0ac4ec72012-08-21 21:15:34 +0000224// One of the following lines has trailing whitespace. It is intended, don't
225// fix it.
226/**
227 * Aaa. IS_DOXYGEN_START
228 *
229 * Bbb. IS_DOXYGEN_END
230 */
231void isdoxy51(int);
232
233// One of the following lines has trailing whitespace. It is intended, don't
234// fix it.
235/**
236 * Aaa. IS_DOXYGEN_START
237 * Bbb.
238 *
239 * Ccc. IS_DOXYGEN_END
240 */
241void isdoxy52(int);
242
243/**
244 * \fn isdoxy53
245 *
246 * Aaa. IS_DOXYGEN_START IS_DOXYGEN_END
247 */
248void isdoxy53(int);
249
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +0000250#endif
251
252// RUN: rm -rf %t
253// RUN: mkdir %t
Dmitri Gribenko61322bc2012-11-15 22:03:13 +0000254
255// Check that we serialize comment source locations properly.
Dmitri Gribenkof303d4c2012-08-07 17:54:38 +0000256// RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -o %t/out.pch %s
257// RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t/out.pch -fsyntax-only %s
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +0000258
Dmitri Gribenkof303d4c2012-08-07 17:54:38 +0000259// 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
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +0000260// RUN: c-index-test -test-load-tu %t/out.pch all > %t/out.c-index-pch
261
262// RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct
263// RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-pch
264
265// Declarations without Doxygen comments should not pick up some Doxygen comments.
266// WRONG-NOT: notdoxy{{.*}}Comment=
267// WRONG-NOT: test{{.*}}Comment=
268
269// Non-Doxygen comments should not be attached to anything.
270// WRONG-NOT: NOT_DOXYGEN
271
272// Some Doxygen comments are not attached to anything.
273// WRONG-NOT: IS_DOXYGEN_NOT_ATTACHED
274
275// Ensure we don't pick up extra comments.
Dmitri Gribenko2d44d772012-06-26 20:39:18 +0000276// WRONG-NOT: IS_DOXYGEN_START{{.*}}IS_DOXYGEN_START{{.*}}BriefComment=
277// WRONG-NOT: IS_DOXYGEN_END{{.*}}IS_DOXYGEN_END{{.*}}BriefComment=
Dmitri Gribenkof303d4c2012-08-07 17:54:38 +0000278//
279// Ensure that XML is not invalid
280// WRONG-NOT: CommentXMLInvalid
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +0000281
282// RUN: FileCheck %s < %t/out.c-index-direct
283// RUN: FileCheck %s < %t/out.c-index-pch
284
Dmitri Gribenko61322bc2012-11-15 22:03:13 +0000285// These CHECK lines are not located near the code on purpose. This test
286// checks that documentation comments are attached to declarations correctly.
287// Adding a non-documentation comment with CHECK line between every two
288// documentation comments will only test a single code path.
289//
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +0000290// CHECK: annotate-comments.cpp:16:6: FunctionDecl=isdoxy4:{{.*}} isdoxy4 IS_DOXYGEN_SINGLE
291// CHECK: annotate-comments.cpp:20:6: FunctionDecl=isdoxy5:{{.*}} isdoxy5 IS_DOXYGEN_SINGLE
292// CHECK: annotate-comments.cpp:25:6: FunctionDecl=isdoxy6:{{.*}} isdoxy6 IS_DOXYGEN_SINGLE
293// CHECK: annotate-comments.cpp:31:6: FunctionDecl=isdoxy7:{{.*}} isdoxy7 IS_DOXYGEN_SINGLE
294// CHECK: annotate-comments.cpp:34:6: FunctionDecl=isdoxy8:{{.*}} isdoxy8 IS_DOXYGEN_SINGLE
295// CHECK: annotate-comments.cpp:37:6: FunctionDecl=isdoxy9:{{.*}} isdoxy9 IS_DOXYGEN_SINGLE
296// CHECK: annotate-comments.cpp:41:6: FunctionDecl=isdoxy10:{{.*}} isdoxy10 IS_DOXYGEN_SINGLE
297// CHECK: annotate-comments.cpp:53:6: FunctionDecl=isdoxy13:{{.*}} isdoxy13 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
298// CHECK: annotate-comments.cpp:58:6: FunctionDecl=isdoxy14:{{.*}} isdoxy14 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
299// CHECK: annotate-comments.cpp:63:6: FunctionDecl=isdoxy15:{{.*}} isdoxy15 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
300// CHECK: annotate-comments.cpp:67:6: FunctionDecl=isdoxy16:{{.*}} isdoxy16 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
301// CHECK: annotate-comments.cpp:72:6: FunctionDecl=isdoxy17:{{.*}} isdoxy17 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
302// CHECK: annotate-comments.cpp:80:5: FunctionDecl=isdoxy18:{{.*}} isdoxy18 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
303// CHECK: annotate-comments.cpp:90:6: FunctionDecl=isdoxy19:{{.*}} isdoxy19 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
304// CHECK: annotate-comments.cpp:96:6: FunctionDecl=isdoxy20:{{.*}} isdoxy20 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +0000305// CHECK: annotate-comments.cpp:107:8: StructDecl=isdoxy25:{{.*}} IS_DOXYGEN_SINGLE
306// CHECK: annotate-comments.cpp:112:7: FieldDecl=isdoxy26:{{.*}} IS_DOXYGEN_SINGLE
307// CHECK: annotate-comments.cpp:116:7: FieldDecl=isdoxy27:{{.*}} IS_DOXYGEN_SINGLE
308// CHECK: annotate-comments.cpp:123:6: EnumDecl=isdoxy29:{{.*}} IS_DOXYGEN_SINGLE
309// CHECK: annotate-comments.cpp:130:11: Namespace=isdoxy31:{{.*}} IS_DOXYGEN_SINGLE
310// CHECK: annotate-comments.cpp:138:7: FieldDecl=isdoxy33:{{.*}} isdoxy33 IS_DOXYGEN_SINGLE
311// CHECK: annotate-comments.cpp:139:7: FieldDecl=isdoxy34:{{.*}} isdoxy34 IS_DOXYGEN_SINGLE
312// CHECK: annotate-comments.cpp:142:7: FieldDecl=isdoxy35:{{.*}} isdoxy35 IS_DOXYGEN_SINGLE
313// CHECK: annotate-comments.cpp:143:7: FieldDecl=isdoxy36:{{.*}} isdoxy36 IS_DOXYGEN_SINGLE
314// CHECK: annotate-comments.cpp:146:7: FieldDecl=isdoxy37:{{.*}} isdoxy37 IS_DOXYGEN_SINGLE
315// CHECK: annotate-comments.cpp:147:7: FieldDecl=isdoxy38:{{.*}} isdoxy38 IS_DOXYGEN_SINGLE
316// CHECK: annotate-comments.cpp:148:7: FieldDecl=isdoxy39:{{.*}} isdoxy39 IS_DOXYGEN_SINGLE
317// CHECK: annotate-comments.cpp:155:6: FunctionDecl=isdoxy40:{{.*}} isdoxy40 IS_DOXYGEN_SINGLE
318// CHECK: annotate-comments.cpp:160:5: FunctionDecl=isdoxy41:{{.*}} isdoxy41 IS_DOXYGEN_SINGLE
319// CHECK: annotate-comments.cpp:163:7: FieldDecl=isdoxy42:{{.*}} isdoxy42 IS_DOXYGEN_SINGLE
Dmitri Gribenko2d44d772012-06-26 20:39:18 +0000320// CHECK: annotate-comments.cpp:176:6: FunctionDecl=isdoxy43:{{.*}} IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
321
Dmitri Gribenkod558b522012-06-28 01:38:21 +0000322// CHECK: annotate-comments.cpp:185:6: FunctionDecl=isdoxy44:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb ccc.]
323// CHECK: annotate-comments.cpp:195:6: FunctionDecl=isdoxy45:{{.*}} BriefComment=[Ddd eee. Fff.]
Dmitri Gribenko659a7122012-07-17 18:35:14 +0000324// CHECK: annotate-comments.cpp:205:6: FunctionDecl=isdoxy46:{{.*}} BriefComment=[Ddd eee. Fff.]
325// CHECK: annotate-comments.cpp:214:6: FunctionDecl=isdoxy48:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb]
Dmitri Gribenko72021ff2012-07-20 17:01:34 +0000326// CHECK: annotate-comments.cpp:218:6: FunctionDecl=isdoxy49:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa]
327// CHECK: annotate-comments.cpp:222:6: FunctionDecl=isdoxy50:{{.*}} BriefComment=[Returns ddd IS_DOXYGEN_END]
Dmitri Gribenko0ac4ec72012-08-21 21:15:34 +0000328// CHECK: annotate-comments.cpp:231:6: FunctionDecl=isdoxy51:{{.*}} BriefComment=[Aaa. IS_DOXYGEN_START]
329// CHECK: annotate-comments.cpp:241:6: FunctionDecl=isdoxy52:{{.*}} BriefComment=[Aaa. IS_DOXYGEN_START Bbb.]
Dmitri Gribenkoaa0cd852012-06-20 00:34:58 +0000330