• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
2 
3 // This file contains lots of corner cases, so ensure that XML we generate is not invalid.
4 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG
5 // WRONG-NOT: CommentXMLInvalid
6 
7 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
8 // expected-warning@+1 {{expected quoted string after equals sign}}
9 /// <a href=>
10 int test_html1(int);
11 
12 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
13 // expected-warning@+1 {{expected quoted string after equals sign}}
14 /// <a href==>
15 int test_html2(int);
16 
17 // expected-warning@+3 {{HTML tag 'a' requires an end tag}}
18 // expected-warning@+2 {{expected quoted string after equals sign}}
19 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
20 /// <a href= blah
21 int test_html3(int);
22 
23 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
24 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
25 /// <a =>
26 int test_html4(int);
27 
28 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
29 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
30 /// <a "aaa">
31 int test_html5(int);
32 
33 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
34 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
35 /// <a a="b" =>
36 int test_html6(int);
37 
38 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
39 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
40 /// <a a="b" "aaa">
41 int test_html7(int);
42 
43 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
44 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
45 /// <a a="b" =
46 int test_html8(int);
47 
48 // expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}}
49 /** Aaa bbb<img ddd eee
50  * fff ggg.
51  */
52 int test_html9(int);
53 
54 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
55 /** Aaa bbb<img ddd eee 42%
56  * fff ggg.
57  */
58 int test_html10(int);
59 
60 // expected-warning@+1 {{HTML end tag 'br' is forbidden}}
61 /// <br></br>
62 int test_html11(int);
63 
64 /// <blockquote>Meow</blockquote>
65 int test_html_nesting1(int);
66 
67 /// <b><i>Meow</i></b>
68 int test_html_nesting2(int);
69 
70 /// <p>Aaa<br>
71 /// Bbb</p>
72 int test_html_nesting3(int);
73 
74 /// <p>Aaa<br />
75 /// Bbb</p>
76 int test_html_nesting4(int);
77 
78 // expected-warning@+3 {{HTML tag 'b' requires an end tag}}
79 // expected-warning@+2 {{HTML tag 'i' requires an end tag}}
80 // expected-warning@+1 {{HTML end tag does not match any start tag}}
81 /// <b><i>Meow</a>
82 int test_html_nesting5(int);
83 
84 // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
85 // expected-warning@+1 {{HTML end tag does not match any start tag}}
86 /// <b><i>Meow</b></b>
87 int test_html_nesting6(int);
88 
89 // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
90 // expected-warning@+1 {{HTML end tag does not match any start tag}}
91 /// <b><i>Meow</b></i>
92 int test_html_nesting7(int);
93 
94 // expected-warning@+1 {{HTML tag 'b' requires an end tag}}
95 /// <b>Meow
96 int test_html_nesting8(int);
97 
98 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
99 /// \brief\returns Aaa
100 int test_block_command1(int);
101 
102 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
103 /// \brief \returns Aaa
104 int test_block_command2(int);
105 
106 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
107 /// \brief
108 /// \returns Aaa
109 int test_block_command3(int);
110 
111 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
112 /// \brief
113 ///
114 /// \returns Aaa
115 int test_block_command4(int);
116 
117 // There is trailing whitespace on one of the following lines, don't remove it!
118 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
119 /// \brief
120 ///
121 /// \returns Aaa
122 int test_block_command5(int);
123 
124 /// \brief \c Aaa
125 int test_block_command6(int);
126 
127 // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}}
128 /// \brief Aaa
129 ///
130 /// Bbb
131 ///
132 /// \brief Ccc
133 int test_duplicate_brief1(int);
134 
135 // expected-warning@+5 {{duplicated command '\short'}} expected-note@+1 {{previous command '\short' here}}
136 /// \short Aaa
137 ///
138 /// Bbb
139 ///
140 /// \short Ccc
141 int test_duplicate_brief2(int);
142 
143 // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\short' (an alias of '\brief') here}}
144 /// \short Aaa
145 ///
146 /// Bbb
147 ///
148 /// \brief Ccc
149 int test_duplicate_brief3(int);
150 
151 
152 /// \return Aaa
153 ///
154 /// Bbb
155 ///
156 /// \return Ccc
157 int test_multiple_returns1(int);
158 
159 /// \returns Aaa
160 ///
161 /// Bbb
162 ///
163 /// \returns Ccc
164 int test_multiple_returns2(int);
165 
166 /// \result Aaa
167 ///
168 /// Bbb
169 ///
170 /// \result Ccc
171 int test_multiple_returns3(int);
172 
173 /// \returns Aaa
174 ///
175 /// Bbb
176 ///
177 /// \return Ccc
178 int test_multiple_returns4(int);
179 
180 
181 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
182 /// \param a Blah blah.
183 int test_param1_backslash;
184 
185 // rdar://13066276
186 // Check that the diagnostic uses the same command marker as the comment.
187 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
188 /// @param a Blah blah.
189 int test_param1_at;
190 
191 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
192 /// \param
193 /// \param a Blah blah.
194 int test_param2(int a);
195 
196 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
197 /// \param a
198 int test_param3(int a);
199 
200 /// \param a Blah blah.
201 int test_param4(int a);
202 
203 /// \param [in] a Blah blah.
204 int test_param5(int a);
205 
206 /// \param [out] a Blah blah.
207 int test_param6(int a);
208 
209 /// \param [in,out] a Blah blah.
210 int test_param7(int a);
211 
212 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
213 /// \param [ in ] a Blah blah.
214 int test_param8(int a);
215 
216 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
217 /// \param [in, out] a Blah blah.
218 int test_param9(int a);
219 
220 // expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
221 /// \param [ junk] a Blah blah.
222 int test_param10(int a);
223 
224 // expected-warning@+1 {{parameter 'a' not found in the function declaration}}
225 /// \param a Blah blah.
226 int test_param11();
227 
228 // expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
229 /// \param A Blah blah.
230 int test_param12(int a);
231 
232 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
233 /// \param aab Blah blah.
234 int test_param13(int aaa, int bbb);
235 
236 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
237 /// \param aaa Blah blah.
238 /// \param aab Blah blah.
239 int test_param14(int aaa, int bbb);
240 
241 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
242 /// \param aab Blah blah.
243 int test_param15(int bbb, int ccc);
244 
245 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
246 /// \param aab Ccc.
247 /// \param aaa Aaa.
248 /// \param bbb Bbb.
249 int test_param16(int aaa, int bbb);
250 
251 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
252 /// \param aaa Aaa.
253 /// \param aab Ccc.
254 /// \param bbb Bbb.
255 int test_param17(int aaa, int bbb);
256 
257 // expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
258 /// \param aaa Aaa.
259 /// \param bbb Bbb.
260 /// \param aab Ccc.
261 int test_param18(int aaa, int bbb);
262 
263 class C {
264   // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
265   /// \param aaa Blah blah.
266   C(int bbb, int ccc);
267 
268   // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
269   /// \param aaa Blah blah.
270  int test_param19(int bbb, int ccc);
271 };
272 
273 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
274 /// \param aab Blah blah.
275 template<typename T>
276 void test_param20(int bbb, int ccc);
277 
278 // expected-warning@+3 {{parameter 'a' is already documented}}
279 // expected-note@+1 {{previous documentation}}
280 /// \param a Aaa.
281 /// \param a Aaa.
282 int test_param21(int a);
283 
284 // expected-warning@+4 {{parameter 'x2' is already documented}}
285 // expected-note@+2 {{previous documentation}}
286 /// \param x1 Aaa.
287 /// \param x2 Bbb.
288 /// \param x2 Ccc.
289 int test_param22(int x1, int x2, int x3);
290 
291 //===---
292 // Test that we treat typedefs to some non-function types as functions for the
293 // purposes of documentation comment parsing.
294 //===---
295 
296 namespace foo {
297   inline namespace bar {
298     template<typename>
299     struct function_wrapper {};
300 
301     template<unsigned>
302     struct not_a_function_wrapper {};
303   }
304 };
305 
306 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
307 /// \param aaa Meow.
308 /// \param bbb Bbb.
309 /// \returns aaa.
310 typedef int test_function_like_typedef1(int aaa, int ccc);
311 
312 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
313 /// \param aaa Meow.
314 /// \param bbb Bbb.
315 /// \returns aaa.
316 typedef int (*test_function_like_typedef2)(int aaa, int ccc);
317 
318 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
319 /// \param aaa Meow.
320 /// \param bbb Bbb.
321 /// \returns aaa.
322 typedef int (* const test_function_like_typedef3)(int aaa, int ccc);
323 
324 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
325 /// \param aaa Meow.
326 /// \param bbb Bbb.
327 /// \returns aaa.
328 typedef int (C::*test_function_like_typedef4)(int aaa, int ccc);
329 
330 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
331 /// \param aaa Meow.
332 /// \param bbb Bbb.
333 /// \returns aaa.
334 typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef5;
335 
336 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
337 /// \param aaa Meow.
338 /// \param bbb Bbb.
339 /// \returns aaa.
340 typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6;
341 
342 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
343 /// \param aaa Meow.
344 /// \param bbb Bbb.
345 /// \returns aaa.
346 typedef foo::function_wrapper<int (int aaa, int ccc)> &test_function_like_typedef7;
347 
348 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
349 /// \param aaa Meow.
350 /// \param bbb Bbb.
351 /// \returns aaa.
352 typedef foo::function_wrapper<int (int aaa, int ccc)> &&test_function_like_typedef8;
353 
354 
355 typedef int (*test_not_function_like_typedef1)(int aaa);
356 
357 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
358 /// \param aaa Meow.
359 typedef test_not_function_like_typedef1 test_not_function_like_typedef2;
360 
361 // rdar://13066276
362 // Check that the diagnostic uses the same command marker as the comment.
363 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
364 /// @param aaa Meow.
365 typedef unsigned int test_not_function_like_typedef3;
366 
367 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
368 /// \param aaa Meow.
369 typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4;
370 
371 /// \param aaa Aaa
372 /// \param ... Vararg
373 int test_vararg_param1(int aaa, ...);
374 
375 /// \param ... Vararg
376 int test_vararg_param2(...);
377 
378 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
379 /// \param ... Vararg
380 int test_vararg_param3(int aaa);
381 
382 // expected-warning@+1 {{parameter '...' not found in the function declaration}}
383 /// \param ... Vararg
384 int test_vararg_param4();
385 
386 
387 /// \param aaa Aaa
388 /// \param ... Vararg
389 template<typename T>
390 int test_template_vararg_param1(int aaa, ...);
391 
392 /// \param ... Vararg
393 template<typename T>
394 int test_template_vararg_param2(...);
395 
396 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
397 /// \param ... Vararg
398 template<typename T>
399 int test_template_vararg_param3(int aaa);
400 
401 // expected-warning@+1 {{parameter '...' not found in the function declaration}}
402 /// \param ... Vararg
403 template<typename T>
404 int test_template_vararg_param4();
405 
406 
407 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
408 /// \tparam T Aaa
409 int test_tparam1;
410 
411 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
412 /// \tparam T Aaa
413 void test_tparam2(int aaa);
414 
415 // expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
416 /// \tparam
417 /// \param aaa Blah blah
418 template<typename T>
419 void test_tparam3(T aaa);
420 
421 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
422 /// \tparam T Aaa
423 template<typename TT>
424 void test_tparam4(TT aaa);
425 
426 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
427 /// \tparam T Aaa
428 template<typename TT>
429 class test_tparam5 {
430   // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
431   /// \tparam T Aaa
432   template<typename TTT>
433   void test_tparam6(TTT aaa);
434 };
435 
436 /// \tparam T1 Aaa
437 /// \tparam T2 Bbb
438 template<typename T1, typename T2>
439 void test_tparam7(T1 aaa, T2 bbb);
440 
441 // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
442 /// \tparam SomTy Aaa
443 /// \tparam OtherTy Bbb
444 template<typename SomeTy, typename OtherTy>
445 void test_tparam8(SomeTy aaa, OtherTy bbb);
446 
447 // expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
448 /// \tparam T1 Aaa
449 /// \tparam T1 Bbb
450 template<typename T1, typename T2>
451 void test_tparam9(T1 aaa, T2 bbb);
452 
453 /// \tparam T Aaa
454 /// \tparam TT Bbb
455 template<template<typename T> class TT>
456 void test_tparam10(TT<int> aaa);
457 
458 /// \tparam T Aaa
459 /// \tparam TT Bbb
460 /// \tparam TTT Ccc
461 template<template<template<typename T> class TT, class C> class TTT>
462 void test_tparam11();
463 
464 /// \tparam I Aaa
465 template<int I>
466 void test_tparam12();
467 
468 template<typename T, typename U>
469 class test_tparam13 { };
470 
471 /// \tparam T Aaa
472 template<typename T>
473 using test_tparam14 = test_tparam13<T, int>;
474 
475 // expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
476 /// \tparam U Aaa
477 template<typename T>
478 using test_tparam15 = test_tparam13<T, int>;
479 
480 // ----
481 
482 /// \tparam T Aaa
483 template<typename T>
484 class test_tparam16 { };
485 
486 typedef test_tparam16<int> test_tparam17;
487 typedef test_tparam16<double> test_tparam18;
488 
489 // ----
490 
491 template<typename T>
492 class test_tparam19;
493 
494 typedef test_tparam19<int> test_tparam20;
495 typedef test_tparam19<double> test_tparam21;
496 
497 /// \tparam T Aaa
498 template<typename T>
499 class test_tparam19 { };
500 
501 // ----
502 
503 // expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}}
504 /// @tparam T Aaa
505 int test_tparam22;
506 
507 // ----
508 
509 
510 /// Aaa
511 /// \deprecated Bbb
512 void test_deprecated_1(int a) __attribute__((deprecated));
513 
514 // We don't want \deprecated to warn about empty paragraph.  It is fine to use
515 // \deprecated by itself without explanations.
516 
517 /// Aaa
518 /// \deprecated
519 void test_deprecated_2(int a) __attribute__((deprecated));
520 
521 /// Aaa
522 /// \deprecated
523 void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4)));
524 
525 /// Aaa
526 /// \deprecated
527 void test_deprecated_4(int a) __attribute__((unavailable));
528 
529 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
530 /// Aaa
531 /// \deprecated
532 void test_deprecated_5(int a);
533 
534 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
535 /// Aaa
536 /// \deprecated
test_deprecated_6(int a)537 void test_deprecated_6(int a) {
538 }
539 
540 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
541 /// Aaa
542 /// \deprecated
543 template<typename T>
544 void test_deprecated_7(T aaa);
545 
546 
547 // rdar://12397511
548 // expected-note@+2 {{previous command '\headerfile' here}}
549 // expected-warning@+2 {{duplicated command '\headerfile'}}
550 /// \headerfile ""
551 /// \headerfile foo.h
552 int test__headerfile_1(int a);
553 
554 
555 /// \invariant aaa
556 void test_invariant_1(int a);
557 
558 // expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
559 /// \invariant
560 void test_invariant_2(int a);
561 
562 
563 // no-warning
564 /// \returns Aaa
565 int test_returns_right_decl_1(int);
566 
567 class test_returns_right_decl_2 {
568   // no-warning
569   /// \returns Aaa
570   int test_returns_right_decl_3(int);
571 };
572 
573 // no-warning
574 /// \returns Aaa
575 template<typename T>
576 int test_returns_right_decl_4(T aaa);
577 
578 // no-warning
579 /// \returns Aaa
580 template<>
581 int test_returns_right_decl_4(int aaa);
582 
583 /// \returns Aaa
584 template<typename T>
585 T test_returns_right_decl_5(T aaa);
586 
587 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
588 /// \returns Aaa
589 int test_returns_wrong_decl_1_backslash;
590 
591 // rdar://13066276
592 // Check that the diagnostic uses the same command marker as the comment.
593 // expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
594 /// @returns Aaa
595 int test_returns_wrong_decl_1_at;
596 
597 // expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
598 /// \return Aaa
599 int test_returns_wrong_decl_2;
600 
601 // expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
602 /// \result Aaa
603 int test_returns_wrong_decl_3;
604 
605 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
606 /// \returns Aaa
607 void test_returns_wrong_decl_4(int);
608 
609 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
610 /// \returns Aaa
611 template<typename T>
612 void test_returns_wrong_decl_5(T aaa);
613 
614 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
615 /// \returns Aaa
616 template<>
617 void test_returns_wrong_decl_5(int aaa);
618 
619 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
620 /// \returns Aaa
621 struct test_returns_wrong_decl_6 { };
622 
623 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
624 /// \returns Aaa
625 class test_returns_wrong_decl_7 {
626   // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
627   /// \returns Aaa
628   test_returns_wrong_decl_7();
629 
630   // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
631   /// \returns Aaa
632   ~test_returns_wrong_decl_7();
633 };
634 
635 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
636 /// \returns Aaa
637 enum test_returns_wrong_decl_8 {
638   // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
639   /// \returns Aaa
640   test_returns_wrong_decl_9
641 };
642 
643 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
644 /// \returns Aaa
645 namespace test_returns_wrong_decl_10 { };
646 
647 // rdar://13094352
648 // expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
649 /*!	@function test_function
650 */
651 typedef unsigned int Base64Flags;
652 unsigned test_function(Base64Flags inFlags);
653 
654 // expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
655 /*! @callback test_callback
656 */
657 typedef unsigned int BaseFlags;
658 unsigned (*test_callback)(BaseFlags inFlags);
659 
660 // expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
661 /// \endverbatim
662 int test_verbatim_1();
663 
664 // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
665 /// \endcode
666 int test_verbatim_2();
667 
668 // FIXME: we give a bad diagnostic here because we throw away non-documentation
669 // comments early.
670 //
671 // expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
672 /// \code
673 //  foo
674 /// \endcode
675 int test_verbatim_3();
676 
677 
678 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
679 int test1; ///< \brief\author Aaa
680 
681 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
682 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
683 int test2, ///< \brief\author Aaa
684     test3; ///< \brief\author Aaa
685 
686 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
687 int test4; ///< \brief
688            ///< \author Aaa
689 
690 
691 class TestRelates {};
692 
693 /// \relates TestRelates
694 /// \brief Aaa
695 void test_relates_1();
696 
697 /// \related TestRelates
698 /// \brief Aaa
699 void test_relates_2();
700 
701 /// \relatesalso TestRelates
702 /// \brief Aaa
703 void test_relates_3();
704 
705 /// \relatedalso TestRelates
706 /// \brief Aaa
707 void test_relates_4();
708 
709 
710 // Check that we attach the comment to the declaration during parsing in the
711 // following cases.  The test is based on the fact that we don't parse
712 // documentation comments that are not attached to anything.
713 
714 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
715 /// \brief\author Aaa
716 int test_attach1;
717 
718 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
719 /// \brief\author Aaa
720 int test_attach2(int);
721 
722 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
723 /// \brief\author Aaa
724 struct test_attach3 {
725   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
726   /// \brief\author Aaa
727   int test_attach4;
728 
729   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
730   int test_attach5; ///< \brief\author Aaa
731 
732   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
733   /// \brief\author Aaa
734   int test_attach6(int);
735 };
736 
737 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
738 /// \brief\author Aaa
739 class test_attach7 {
740   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
741   /// \brief\author Aaa
742   int test_attach8;
743 
744   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
745   int test_attach9; ///< \brief\author Aaa
746 
747   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
748   /// \brief\author Aaa
749   int test_attach10(int);
750 };
751 
752 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
753 /// \brief\author Aaa
754 enum test_attach9 {
755   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
756   /// \brief\author Aaa
757   test_attach10,
758 
759   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
760   test_attach11 ///< \brief\author Aaa
761 };
762 
763 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
764 /// \brief\author Aaa
765 struct test_noattach12 *test_attach13;
766 
767 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
768 /// \brief\author Aaa
769 typedef struct test_noattach14 *test_attach15;
770 
771 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
772 /// \brief\author Aaa
773 typedef struct test_attach16 { int a; } test_attach17;
774 
775 struct S { int a; };
776 
777 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
778 /// \brief\author Aaa
779 struct S *test_attach18;
780 
781 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
782 /// \brief\author Aaa
783 typedef struct S *test_attach19;
784 
785 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
786 /// \brief\author Aaa
787 struct test_attach20;
788 
789 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
790 /// \brief\author Aaa
791 typedef struct test_attach21 {
792   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
793   /// \brief\author Aaa
794   int test_attach22;
795 } test_attach23;
796 
797 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
798 /// \brief\author Aaa
799 namespace test_attach24 {
800   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
801   /// \brief\author Aaa
802   namespace test_attach25 {
803   }
804 }
805 
806 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
807 /// \brief\author Aaa
808 /// \tparam T Aaa
809 template<typename T>
810 void test_attach26(T aaa);
811 
812 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
813 /// \brief\author Aaa
814 /// \tparam T Aaa
815 template<typename T, typename U>
816 void test_attach27(T aaa, U bbb);
817 
818 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
819 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
820 /// \brief\author Aaa
821 /// \tparam T Aaa
822 template<>
823 void test_attach27(int aaa, int bbb);
824 
825 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
826 /// \brief\author Aaa
827 /// \tparam T Aaa
828 template<typename T>
829 class test_attach28 {
830   T aaa;
831 };
832 
833 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
834 /// \brief\author Aaa
835 using test_attach29 = test_attach28<int>;
836 
837 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
838 /// \brief\author Aaa
839 /// \tparam T Aaa
840 template<typename T, typename U>
841 class test_attach30 { };
842 
843 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
844 /// \brief\author Aaa
845 /// \tparam T Aaa
846 template<typename T>
847 class test_attach30<T, int> { };
848 
849 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
850 /// \brief\author Aaa
851 template<>
852 class test_attach30<int, int> { };
853 
854 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
855 /// \brief\author Aaa
856 template<typename T>
857 using test_attach31 = test_attach30<T, int>;
858 
859 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
860 /// \brief\author Aaa
861 /// \tparam T Aaa
862 template<typename T, typename U, typename V>
863 class test_attach32 { };
864 
865 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
866 /// \brief\author Aaa
867 /// \tparam T Aaa
868 template<typename T, typename U>
869 class test_attach32<T, U, int> { };
870 
871 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
872 /// \brief\author Aaa
873 /// \tparam T Aaa
874 template<typename T>
875 class test_attach32<T, int, int> { };
876 
877 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
878 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
879 /// \brief\author Aaa
880 /// \tparam T Aaa
881 template<>
882 class test_attach32<int, int, int> { };
883 
884 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
885 /// \brief\author Aaa
886 class test_attach33 {
887   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
888   /// \brief\author Aaa
889   /// \tparam T Aaa
890   template<typename T, typename U>
891   void test_attach34(T aaa, U bbb);
892 };
893 
894 template<typename T>
895 class test_attach35 {
896   // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
897   // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
898   /// \brief\author Aaa
899   /// \tparam T Aaa
900   template<typename TT, typename UU>
901   void test_attach36(TT aaa, UU bbb);
902 };
903 
904 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
905 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
906 /// \brief\author Aaa
907 /// \tparam T Aaa
908 template<> template<>
test_attach36(int aaa,int bbb)909 void test_attach35<int>::test_attach36(int aaa, int bbb) {}
910 
911 template<typename T>
912 class test_attach37 {
913   // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
914   // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
915   /// \brief\author Aaa
916   /// \tparam T Aaa
917   void test_attach38(int aaa, int bbb);
918 
919   void test_attach39(int aaa, int bbb);
920 };
921 
922 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
923 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
924 /// \brief\author Aaa
925 /// \tparam T Aaa
926 template<>
test_attach38(int aaa,int bbb)927 void test_attach37<int>::test_attach38(int aaa, int bbb) {}
928 
929 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
930 /// \brief\author Aaa
931 /// \tparam T Aaa
932 template<typename T>
test_attach39(int aaa,int bbb)933 void test_attach37<T>::test_attach39(int aaa, int bbb) {}
934 
935 // We used to emit warning that parameter 'a' is not found because we parsed
936 // the comment in context of the redeclaration which does not have parameter
937 // names.
938 template <typename T>
939 struct test_attach38 {
940   /*!
941     \param a  First param
942     \param b  Second param
943   */
944   template <typename B>
945   void test_attach39(T a, B b);
946 };
947 
948 template <>
949 template <typename B>
950 void test_attach38<int>::test_attach39(int, B);
951 
952 
953 // PR13411, reduced.  We used to crash on this.
954 /**
955  * @code Aaa.
956  */
957 void test_nocrash1(int);
958 
959 // We used to crash on this.
960 // expected-warning@+2 {{empty paragraph passed to '\param' command}}
961 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
962 /// \param\brief
963 void test_nocrash2(int);
964 
965 // PR13593, example 1 and 2
966 
967 /**
968 * Bla.
969 */
970 template <typename>
971 void test_nocrash3();
972 
973 /// Foo
974 template <typename, typename>
test_nocrash4()975 void test_nocrash4() { }
976 
977 template <typename>
test_nocrash3()978 void test_nocrash3()
979 {
980 }
981 
982 // PR13593, example 3
983 
984 /**
985  * aaa
986  */
987 template <typename T>
test_nocrash5(T a1)988 inline T test_nocrash5(T a1)
989 {
990     return a1;
991 }
992 
993 ///
994 //,
995 
test_nocrash6()996 inline void test_nocrash6()
997 {
998     test_nocrash5(1);
999 }
1000 
1001 // We used to crash on this.
1002 
1003 /*!
1004   Blah.
1005 */
1006 typedef const struct test_nocrash7 * test_nocrash8;
1007 
1008 // We used to crash on this.
1009 
1010 // expected-warning@+1 {{unknown command tag name}}
1011 /// aaa \unknown aaa \unknown aaa
1012 int test_nocrash9;
1013 
1014 // We used to crash on this.  PR15068
1015 
1016 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1017 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1018 ///@param x
1019 ///@param y
1020 int test_nocrash10(int x, int y);
1021 
1022 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
1023 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
1024 ///@param x
1025 ///@param y
1026 int test_nocrash11();
1027 
1028 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
1029 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
1030 /**
1031 @param x
1032 @param y
1033 **/
1034 int test_nocrash12();
1035 
1036 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1037 // expected-warning@+1 {{empty paragraph passed to '@param' command}}
1038 ///@param x@param y
1039 int test_nocrash13(int x, int y);
1040 
1041 /**
1042  * \verbatim
1043  * Aaa
1044  **/
1045 int test_nocrash14();
1046 
1047 // rdar://12379114
1048 // expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
1049 /*!
1050    @union U This is new
1051 */
1052 struct U { int iS; };
1053 
1054 /*!
1055   @union U1
1056 */
1057 union U1 {int i; };
1058 
1059 // expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
1060 /*!
1061  @struct S2
1062 */
1063 union S2 {};
1064 
1065 /*!
1066   @class C1
1067 */
1068 class C1;
1069 
1070 /*!
1071   @struct S3;
1072 */
1073 class S3;
1074 
1075 // rdar://14124702
1076 //----------------------------------------------------------------------
1077 /// @class Predicate Predicate.h "lldb/Host/Predicate.h"
1078 /// @brief A C++ wrapper class for providing threaded access to a value
1079 /// of type T.
1080 ///
1081 /// A templatized class.
1082 /// specified values.
1083 //----------------------------------------------------------------------
1084 template <class T, class T1>
1085 class Predicate
1086 {
1087 };
1088 
1089 //----------------------------------------------------------------------
1090 /// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
1091 /// @brief A C++ wrapper class for providing threaded access to a value
1092 /// of type T.
1093 ///
1094 /// A template specilization class.
1095 //----------------------------------------------------------------------
1096 template<> class Predicate<int, char>
1097 {
1098 };
1099 
1100 //----------------------------------------------------------------------
1101 /// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
1102 /// @brief A C++ wrapper class for providing threaded access to a value
1103 /// of type T.
1104 ///
1105 /// A partial specialization template class.
1106 //----------------------------------------------------------------------
1107 template<class T> class Predicate<T, int>
1108 {
1109 };
1110 
1111 /*!     @function test_function
1112 */
1113 template <class T> T test_function (T arg);
1114 
1115 /*!     @function test_function<int>
1116 */
1117 template <> int test_function<int> (int arg);
1118