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 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 372 /// \param aaa Meow. 373 /// \param bbb Bbb. 374 /// \returns aaa. 375 using test_function_like_using1 = int (int aaa, int ccc); 376 377 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 378 /// \param aaa Meow. 379 /// \param bbb Bbb. 380 /// \returns aaa. 381 using test_function_like_using2 = int (*)(int aaa, int ccc); 382 383 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 384 /// \param aaa Meow. 385 /// \param bbb Bbb. 386 /// \returns aaa. 387 using test_function_like_using3 = int (* const)(int aaa, int ccc); 388 389 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 390 /// \param aaa Meow. 391 /// \param bbb Bbb. 392 /// \returns aaa. 393 using test_function_like_using4 = int (C::*)(int aaa, int ccc); 394 395 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 396 /// \param aaa Meow. 397 /// \param bbb Bbb. 398 /// \returns aaa. 399 using test_function_like_using5 = foo::function_wrapper<int (int aaa, int ccc)>; 400 401 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 402 /// \param aaa Meow. 403 /// \param bbb Bbb. 404 /// \returns aaa. 405 using test_function_like_using6 = foo::function_wrapper<int (int aaa, int ccc)> *; 406 407 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 408 /// \param aaa Meow. 409 /// \param bbb Bbb. 410 /// \returns aaa. 411 using test_function_like_using7 = foo::function_wrapper<int (int aaa, int ccc)> &; 412 413 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 414 /// \param aaa Meow. 415 /// \param bbb Bbb. 416 /// \returns aaa. 417 using test_function_like_using8 = foo::function_wrapper<int (int aaa, int ccc)> &&; 418 419 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}} 420 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 421 /// \param aaa Meow. 422 /// \param bbb Bbb. 423 /// \tparam U Uuu. 424 template<typename T> 425 using test_function_like_using9 = int(T aaa, int ccc); 426 427 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}} 428 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 429 /// \param aaa Meow. 430 /// \param bbb Bbb. 431 /// \tparam U Uuu. 432 template<typename T> 433 using test_function_like_using10 = int (*)(T aaa, int ccc); 434 435 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}} 436 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 437 /// \param aaa Meow. 438 /// \param bbb Bbb. 439 /// \tparam U Uuu. 440 template<typename T> 441 using test_function_like_using11 = foo::function_wrapper<int (T aaa, int ccc)>; 442 443 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}} 444 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 445 /// \param aaa Meow. 446 /// \param bbb Bbb. 447 /// \tparam U Uuu. 448 template<typename T> 449 using test_function_like_using12 = foo::function_wrapper<int (T aaa, int ccc)> *; 450 451 using test_not_function_like_using1 = int (*)(int aaa); 452 453 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} 454 /// \param aaa Meow. 455 using test_not_function_like_using2 = test_not_function_like_using1; 456 457 // Check that the diagnostic uses the same command marker as the comment. 458 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}} 459 /// @param aaa Meow. 460 using test_not_function_like_using3 = unsigned int; 461 462 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} 463 /// \param aaa Meow. 464 using test_not_function_like_using4 = foo::not_a_function_wrapper<1>; 465 466 /// \param aaa Aaa 467 /// \param ... Vararg 468 int test_vararg_param1(int aaa, ...); 469 470 /// \param ... Vararg 471 int test_vararg_param2(...); 472 473 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} 474 /// \param ... Vararg 475 int test_vararg_param3(int aaa); 476 477 // expected-warning@+1 {{parameter '...' not found in the function declaration}} 478 /// \param ... Vararg 479 int test_vararg_param4(); 480 481 482 /// \param aaa Aaa 483 /// \param ... Vararg 484 template<typename T> 485 int test_template_vararg_param1(int aaa, ...); 486 487 /// \param ... Vararg 488 template<typename T> 489 int test_template_vararg_param2(...); 490 491 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} 492 /// \param ... Vararg 493 template<typename T> 494 int test_template_vararg_param3(int aaa); 495 496 // expected-warning@+1 {{parameter '...' not found in the function declaration}} 497 /// \param ... Vararg 498 template<typename T> 499 int test_template_vararg_param4(); 500 501 502 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}} 503 /// \tparam T Aaa 504 int test_tparam1; 505 506 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}} 507 /// \tparam T Aaa 508 void test_tparam2(int aaa); 509 510 // expected-warning@+1 {{empty paragraph passed to '\tparam' command}} 511 /// \tparam 512 /// \param aaa Blah blah 513 template<typename T> 514 void test_tparam3(T aaa); 515 516 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}} 517 /// \tparam T Aaa 518 template<typename TT> 519 void test_tparam4(TT aaa); 520 521 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}} 522 /// \tparam T Aaa 523 template<typename TT> 524 class test_tparam5 { 525 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}} 526 /// \tparam T Aaa 527 template<typename TTT> 528 void test_tparam6(TTT aaa); 529 }; 530 531 /// \tparam T1 Aaa 532 /// \tparam T2 Bbb 533 template<typename T1, typename T2> 534 void test_tparam7(T1 aaa, T2 bbb); 535 536 // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}} 537 /// \tparam SomTy Aaa 538 /// \tparam OtherTy Bbb 539 template<typename SomeTy, typename OtherTy> 540 void test_tparam8(SomeTy aaa, OtherTy bbb); 541 542 // expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}} 543 /// \tparam T1 Aaa 544 /// \tparam T1 Bbb 545 template<typename T1, typename T2> 546 void test_tparam9(T1 aaa, T2 bbb); 547 548 /// \tparam T Aaa 549 /// \tparam TT Bbb 550 template<template<typename T> class TT> 551 void test_tparam10(TT<int> aaa); 552 553 /// \tparam T Aaa 554 /// \tparam TT Bbb 555 /// \tparam TTT Ccc 556 template<template<template<typename T> class TT, class C> class TTT> 557 void test_tparam11(); 558 559 /// \tparam I Aaa 560 template<int I> 561 void test_tparam12(); 562 563 template<typename T, typename U> 564 class test_tparam13 { }; 565 566 /// \tparam T Aaa 567 template<typename T> 568 using test_tparam14 = test_tparam13<T, int>; 569 570 // expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}} 571 /// \tparam U Aaa 572 template<typename T> 573 using test_tparam15 = test_tparam13<T, int>; 574 575 // ---- 576 577 /// \tparam T Aaa 578 template<typename T> 579 class test_tparam16 { }; 580 581 typedef test_tparam16<int> test_tparam17; 582 typedef test_tparam16<double> test_tparam18; 583 584 // ---- 585 586 template<typename T> 587 class test_tparam19; 588 589 typedef test_tparam19<int> test_tparam20; 590 typedef test_tparam19<double> test_tparam21; 591 592 /// \tparam T Aaa 593 template<typename T> 594 class test_tparam19 { }; 595 596 // ---- 597 598 // expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}} 599 /// @tparam T Aaa 600 int test_tparam22; 601 602 // ---- 603 604 605 /// Aaa 606 /// \deprecated Bbb 607 void test_deprecated_1(int a) __attribute__((deprecated)); 608 609 // We don't want \deprecated to warn about empty paragraph. It is fine to use 610 // \deprecated by itself without explanations. 611 612 /// Aaa 613 /// \deprecated 614 void test_deprecated_2(int a) __attribute__((deprecated)); 615 616 /// Aaa 617 /// \deprecated 618 void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4))); 619 620 /// Aaa 621 /// \deprecated 622 void test_deprecated_4(int a) __attribute__((unavailable)); 623 624 // 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}} 625 /// Aaa 626 /// \deprecated 627 void test_deprecated_5(int a); 628 629 // 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}} 630 /// Aaa 631 /// \deprecated 632 void test_deprecated_6(int a) { 633 } 634 635 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} 636 /// Aaa 637 /// \deprecated 638 template<typename T> 639 void test_deprecated_7(T aaa); 640 641 642 // rdar://12397511 643 // expected-note@+2 {{previous command '\headerfile' here}} 644 // expected-warning@+2 {{duplicated command '\headerfile'}} 645 /// \headerfile "" 646 /// \headerfile foo.h 647 int test__headerfile_1(int a); 648 649 650 /// \invariant aaa 651 void test_invariant_1(int a); 652 653 // expected-warning@+1 {{empty paragraph passed to '\invariant' command}} 654 /// \invariant 655 void test_invariant_2(int a); 656 657 658 // no-warning 659 /// \returns Aaa 660 int test_returns_right_decl_1(int); 661 662 class test_returns_right_decl_2 { 663 // no-warning 664 /// \returns Aaa 665 int test_returns_right_decl_3(int); 666 }; 667 668 // no-warning 669 /// \returns Aaa 670 template<typename T> 671 int test_returns_right_decl_4(T aaa); 672 673 // no-warning 674 /// \returns Aaa 675 template<> 676 int test_returns_right_decl_4(int aaa); 677 678 /// \returns Aaa 679 template<typename T> 680 T test_returns_right_decl_5(T aaa); 681 682 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 683 /// \returns Aaa 684 int test_returns_wrong_decl_1_backslash; 685 686 // rdar://13066276 687 // Check that the diagnostic uses the same command marker as the comment. 688 // expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}} 689 /// @returns Aaa 690 int test_returns_wrong_decl_1_at; 691 692 // expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}} 693 /// \return Aaa 694 int test_returns_wrong_decl_2; 695 696 // expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}} 697 /// \result Aaa 698 int test_returns_wrong_decl_3; 699 700 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}} 701 /// \returns Aaa 702 void test_returns_wrong_decl_4(int); 703 704 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}} 705 /// \returns Aaa 706 template<typename T> 707 void test_returns_wrong_decl_5(T aaa); 708 709 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}} 710 /// \returns Aaa 711 template<> 712 void test_returns_wrong_decl_5(int aaa); 713 714 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 715 /// \returns Aaa 716 struct test_returns_wrong_decl_6 { }; 717 718 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 719 /// \returns Aaa 720 class test_returns_wrong_decl_7 { 721 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}} 722 /// \returns Aaa 723 test_returns_wrong_decl_7(); 724 725 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}} 726 /// \returns Aaa 727 ~test_returns_wrong_decl_7(); 728 }; 729 730 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 731 /// \returns Aaa 732 enum test_returns_wrong_decl_8 { 733 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 734 /// \returns Aaa 735 test_returns_wrong_decl_9 736 }; 737 738 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 739 /// \returns Aaa 740 namespace test_returns_wrong_decl_10 { }; 741 742 // rdar://13094352 743 // expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}} 744 /*! @function test_function 745 */ 746 typedef unsigned int Base64Flags; 747 unsigned test_function(Base64Flags inFlags); 748 749 // expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}} 750 /*! @callback test_callback 751 */ 752 typedef unsigned int BaseFlags; 753 unsigned (*test_callback)(BaseFlags inFlags); 754 755 // expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}} 756 /// \endverbatim 757 int test_verbatim_1(); 758 759 // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}} 760 /// \endcode 761 int test_verbatim_2(); 762 763 // FIXME: we give a bad diagnostic here because we throw away non-documentation 764 // comments early. 765 // 766 // expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}} 767 /// \code 768 // foo 769 /// \endcode 770 int test_verbatim_3(); 771 772 773 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 774 int test1; ///< \brief\author Aaa 775 776 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 777 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 778 int test2, ///< \brief\author Aaa 779 test3; ///< \brief\author Aaa 780 781 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 782 int test4; ///< \brief 783 ///< \author Aaa 784 785 786 class TestRelates {}; 787 788 /// \relates TestRelates 789 /// \brief Aaa 790 void test_relates_1(); 791 792 /// \related TestRelates 793 /// \brief Aaa 794 void test_relates_2(); 795 796 /// \relatesalso TestRelates 797 /// \brief Aaa 798 void test_relates_3(); 799 800 /// \relatedalso TestRelates 801 /// \brief Aaa 802 void test_relates_4(); 803 804 805 // Check that we attach the comment to the declaration during parsing in the 806 // following cases. The test is based on the fact that we don't parse 807 // documentation comments that are not attached to anything. 808 809 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 810 /// \brief\author Aaa 811 int test_attach1; 812 813 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 814 /// \brief\author Aaa 815 int test_attach2(int); 816 817 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 818 /// \brief\author Aaa 819 struct test_attach3 { 820 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 821 /// \brief\author Aaa 822 int test_attach4; 823 824 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 825 int test_attach5; ///< \brief\author Aaa 826 827 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 828 /// \brief\author Aaa 829 int test_attach6(int); 830 }; 831 832 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 833 /// \brief\author Aaa 834 class test_attach7 { 835 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 836 /// \brief\author Aaa 837 int test_attach8; 838 839 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 840 int test_attach9; ///< \brief\author Aaa 841 842 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 843 /// \brief\author Aaa 844 int test_attach10(int); 845 }; 846 847 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 848 /// \brief\author Aaa 849 enum test_attach9 { 850 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 851 /// \brief\author Aaa 852 test_attach10, 853 854 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 855 test_attach11 ///< \brief\author Aaa 856 }; 857 858 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 859 /// \brief\author Aaa 860 struct test_noattach12 *test_attach13; 861 862 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 863 /// \brief\author Aaa 864 typedef struct test_noattach14 *test_attach15; 865 866 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 867 /// \brief\author Aaa 868 typedef struct test_attach16 { int a; } test_attach17; 869 870 struct S { int a; }; 871 872 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 873 /// \brief\author Aaa 874 struct S *test_attach18; 875 876 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 877 /// \brief\author Aaa 878 typedef struct S *test_attach19; 879 880 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 881 /// \brief\author Aaa 882 struct test_attach20; 883 884 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 885 /// \brief\author Aaa 886 typedef struct test_attach21 { 887 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 888 /// \brief\author Aaa 889 int test_attach22; 890 } test_attach23; 891 892 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 893 /// \brief\author Aaa 894 namespace test_attach24 { 895 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 896 /// \brief\author Aaa 897 namespace test_attach25 { 898 } 899 } 900 901 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 902 /// \brief\author Aaa 903 /// \tparam T Aaa 904 template<typename T> 905 void test_attach26(T aaa); 906 907 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 908 /// \brief\author Aaa 909 /// \tparam T Aaa 910 template<typename T, typename U> 911 void test_attach27(T aaa, U bbb); 912 913 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 914 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 915 /// \brief\author Aaa 916 /// \tparam T Aaa 917 template<> 918 void test_attach27(int aaa, int bbb); 919 920 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 921 /// \brief\author Aaa 922 /// \tparam T Aaa 923 template<typename T> 924 class test_attach28 { 925 T aaa; 926 }; 927 928 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 929 /// \brief\author Aaa 930 using test_attach29 = test_attach28<int>; 931 932 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 933 /// \brief\author Aaa 934 /// \tparam T Aaa 935 template<typename T, typename U> 936 class test_attach30 { }; 937 938 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 939 /// \brief\author Aaa 940 /// \tparam T Aaa 941 template<typename T> 942 class test_attach30<T, int> { }; 943 944 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 945 /// \brief\author Aaa 946 template<> 947 class test_attach30<int, int> { }; 948 949 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 950 /// \brief\author Aaa 951 template<typename T> 952 using test_attach31 = test_attach30<T, int>; 953 954 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 955 /// \brief\author Aaa 956 /// \tparam T Aaa 957 template<typename T, typename U, typename V> 958 class test_attach32 { }; 959 960 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 961 /// \brief\author Aaa 962 /// \tparam T Aaa 963 template<typename T, typename U> 964 class test_attach32<T, U, int> { }; 965 966 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 967 /// \brief\author Aaa 968 /// \tparam T Aaa 969 template<typename T> 970 class test_attach32<T, int, int> { }; 971 972 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 973 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 974 /// \brief\author Aaa 975 /// \tparam T Aaa 976 template<> 977 class test_attach32<int, int, int> { }; 978 979 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 980 /// \brief\author Aaa 981 class test_attach33 { 982 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 983 /// \brief\author Aaa 984 /// \tparam T Aaa 985 template<typename T, typename U> 986 void test_attach34(T aaa, U bbb); 987 }; 988 989 template<typename T> 990 class test_attach35 { 991 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 992 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 993 /// \brief\author Aaa 994 /// \tparam T Aaa 995 template<typename TT, typename UU> 996 void test_attach36(TT aaa, UU bbb); 997 }; 998 999 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 1000 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 1001 /// \brief\author Aaa 1002 /// \tparam T Aaa 1003 template<> template<> 1004 void test_attach35<int>::test_attach36(int aaa, int bbb) {} 1005 1006 template<typename T> 1007 class test_attach37 { 1008 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 1009 // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}} 1010 /// \brief\author Aaa 1011 /// \tparam T Aaa 1012 void test_attach38(int aaa, int bbb); 1013 1014 void test_attach39(int aaa, int bbb); 1015 }; 1016 1017 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 1018 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 1019 /// \brief\author Aaa 1020 /// \tparam T Aaa 1021 template<> 1022 void test_attach37<int>::test_attach38(int aaa, int bbb) {} 1023 1024 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1025 /// \brief\author Aaa 1026 /// \tparam T Aaa 1027 template<typename T> 1028 void test_attach37<T>::test_attach39(int aaa, int bbb) {} 1029 1030 // We used to emit warning that parameter 'a' is not found because we parsed 1031 // the comment in context of the redeclaration which does not have parameter 1032 // names. 1033 template <typename T> 1034 struct test_attach38 { 1035 /*! 1036 \param a First param 1037 \param b Second param 1038 */ 1039 template <typename B> 1040 void test_attach39(T a, B b); 1041 }; 1042 1043 template <> 1044 template <typename B> 1045 void test_attach38<int>::test_attach39(int, B); 1046 1047 1048 // PR13411, reduced. We used to crash on this. 1049 /** 1050 * @code Aaa. 1051 */ 1052 void test_nocrash1(int); 1053 1054 // We used to crash on this. 1055 // expected-warning@+2 {{empty paragraph passed to '\param' command}} 1056 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1057 /// \param\brief 1058 void test_nocrash2(int); 1059 1060 // PR13593, example 1 and 2 1061 1062 /** 1063 * Bla. 1064 */ 1065 template <typename> 1066 void test_nocrash3(); 1067 1068 /// Foo 1069 template <typename, typename> 1070 void test_nocrash4() { } 1071 1072 template <typename> 1073 void test_nocrash3() 1074 { 1075 } 1076 1077 // PR13593, example 3 1078 1079 /** 1080 * aaa 1081 */ 1082 template <typename T> 1083 inline T test_nocrash5(T a1) 1084 { 1085 return a1; 1086 } 1087 1088 /// 1089 //, 1090 1091 inline void test_nocrash6() 1092 { 1093 test_nocrash5(1); 1094 } 1095 1096 // We used to crash on this. 1097 1098 /*! 1099 Blah. 1100 */ 1101 typedef const struct test_nocrash7 * test_nocrash8; 1102 1103 // We used to crash on this. 1104 1105 // expected-warning@+1 {{unknown command tag name}} 1106 /// aaa \unknown aaa \unknown aaa 1107 int test_nocrash9; 1108 1109 // We used to crash on this. PR15068 1110 1111 // expected-warning@+2 {{empty paragraph passed to '@param' command}} 1112 // expected-warning@+2 {{empty paragraph passed to '@param' command}} 1113 ///@param x 1114 ///@param y 1115 int test_nocrash10(int x, int y); 1116 1117 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}} 1118 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}} 1119 ///@param x 1120 ///@param y 1121 int test_nocrash11(); 1122 1123 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}} 1124 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}} 1125 /** 1126 @param x 1127 @param y 1128 **/ 1129 int test_nocrash12(); 1130 1131 // expected-warning@+2 {{empty paragraph passed to '@param' command}} 1132 // expected-warning@+1 {{empty paragraph passed to '@param' command}} 1133 ///@param x@param y 1134 int test_nocrash13(int x, int y); 1135 1136 /** 1137 * \verbatim 1138 * Aaa 1139 **/ 1140 int test_nocrash14(); 1141 1142 // rdar://12379114 1143 // expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}} 1144 /*! 1145 @union U This is new 1146 */ 1147 struct U { int iS; }; 1148 1149 /*! 1150 @union U1 1151 */ 1152 union U1 {int i; }; 1153 1154 // expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}} 1155 /*! 1156 @struct S2 1157 */ 1158 union S2 {}; 1159 1160 /*! 1161 @class C1 1162 */ 1163 class C1; 1164 1165 /*! 1166 @struct S3; 1167 */ 1168 class S3; 1169 1170 // rdar://14124702 1171 //---------------------------------------------------------------------- 1172 /// @class Predicate Predicate.h "lldb/Host/Predicate.h" 1173 /// @brief A C++ wrapper class for providing threaded access to a value 1174 /// of type T. 1175 /// 1176 /// A templatized class. 1177 /// specified values. 1178 //---------------------------------------------------------------------- 1179 template <class T, class T1> 1180 class Predicate 1181 { 1182 }; 1183 1184 //---------------------------------------------------------------------- 1185 /// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h" 1186 /// @brief A C++ wrapper class for providing threaded access to a value 1187 /// of type T. 1188 /// 1189 /// A template specilization class. 1190 //---------------------------------------------------------------------- 1191 template<> class Predicate<int, char> 1192 { 1193 }; 1194 1195 //---------------------------------------------------------------------- 1196 /// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h" 1197 /// @brief A C++ wrapper class for providing threaded access to a value 1198 /// of type T. 1199 /// 1200 /// A partial specialization template class. 1201 //---------------------------------------------------------------------- 1202 template<class T> class Predicate<T, int> 1203 { 1204 }; 1205 1206 /*! @function test_function 1207 */ 1208 template <class T> T test_function (T arg); 1209 1210 /*! @function test_function<int> 1211 */ 1212 template <> int test_function<int> (int arg); 1213