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