1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s 2 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s 3 4 // This file contains lots of corner cases, so ensure that XML we generate is not invalid. 5 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG 6 // WRONG-NOT: CommentXMLInvalid 7 8 // expected-warning@+2 {{HTML tag 'a' requires an end tag}} 9 // expected-warning@+1 {{expected quoted string after equals sign}} 10 /// <a href=> 11 int test_html1(int); 12 13 // expected-warning@+2 {{HTML tag 'a' requires an end tag}} 14 // expected-warning@+1 {{expected quoted string after equals sign}} 15 /// <a href==> 16 int test_html2(int); 17 18 // expected-warning@+3 {{HTML tag 'a' requires an end tag}} 19 // expected-warning@+2 {{expected quoted string after equals sign}} 20 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 21 /// <a href= blah 22 int test_html3(int); 23 24 // expected-warning@+2 {{HTML tag 'a' requires an end tag}} 25 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 26 /// <a => 27 int test_html4(int); 28 29 // expected-warning@+2 {{HTML tag 'a' requires an end tag}} 30 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 31 /// <a "aaa"> 32 int test_html5(int); 33 34 // expected-warning@+2 {{HTML tag 'a' requires an end tag}} 35 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 36 /// <a a="b" => 37 int test_html6(int); 38 39 // expected-warning@+2 {{HTML tag 'a' requires an end tag}} 40 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 41 /// <a a="b" "aaa"> 42 int test_html7(int); 43 44 // expected-warning@+2 {{HTML tag 'a' requires an end tag}} 45 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 46 /// <a a="b" = 47 int test_html8(int); 48 49 // expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}} 50 /** Aaa bbb<img ddd eee 51 * fff ggg. 52 */ 53 int test_html9(int); 54 55 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 56 /** Aaa bbb<img ddd eee 42% 57 * fff ggg. 58 */ 59 int test_html10(int); 60 61 // expected-warning@+1 {{HTML end tag 'br' is forbidden}} 62 /// <br></br> 63 int test_html11(int); 64 65 /// <blockquote>Meow</blockquote> 66 int test_html_nesting1(int); 67 68 /// <b><i>Meow</i></b> 69 int test_html_nesting2(int); 70 71 /// <p>Aaa<br> 72 /// Bbb</p> 73 int test_html_nesting3(int); 74 75 /// <p>Aaa<br /> 76 /// Bbb</p> 77 int test_html_nesting4(int); 78 79 // expected-warning@+3 {{HTML tag 'b' requires an end tag}} 80 // expected-warning@+2 {{HTML tag 'i' requires an end tag}} 81 // expected-warning@+1 {{HTML end tag does not match any start tag}} 82 /// <b><i>Meow</a> 83 int test_html_nesting5(int); 84 85 // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}} 86 // expected-warning@+1 {{HTML end tag does not match any start tag}} 87 /// <b><i>Meow</b></b> 88 int test_html_nesting6(int); 89 90 // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}} 91 // expected-warning@+1 {{HTML end tag does not match any start tag}} 92 /// <b><i>Meow</b></i> 93 int test_html_nesting7(int); 94 95 // expected-warning@+1 {{HTML tag 'b' requires an end tag}} 96 /// <b>Meow 97 int test_html_nesting8(int); 98 99 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 100 /// \brief\returns Aaa 101 int test_block_command1(int); 102 103 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 104 /// \brief \returns Aaa 105 int test_block_command2(int); 106 107 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 108 /// \brief 109 /// \returns Aaa 110 int test_block_command3(int); 111 112 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 113 /// \brief 114 /// 115 /// \returns Aaa 116 int test_block_command4(int); 117 118 // There is trailing whitespace on one of the following lines, don't remove it! 119 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 120 /// \brief 121 /// 122 /// \returns Aaa 123 int test_block_command5(int); 124 125 /// \brief \c Aaa 126 int test_block_command6(int); 127 128 // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}} 129 /// \brief Aaa 130 /// 131 /// Bbb 132 /// 133 /// \brief Ccc 134 int test_duplicate_brief1(int); 135 136 // expected-warning@+5 {{duplicated command '\short'}} expected-note@+1 {{previous command '\short' here}} 137 /// \short Aaa 138 /// 139 /// Bbb 140 /// 141 /// \short Ccc 142 int test_duplicate_brief2(int); 143 144 // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\short' (an alias of '\brief') here}} 145 /// \short Aaa 146 /// 147 /// Bbb 148 /// 149 /// \brief Ccc 150 int test_duplicate_brief3(int); 151 152 153 /// \return Aaa 154 /// 155 /// Bbb 156 /// 157 /// \return Ccc 158 int test_multiple_returns1(int); 159 160 /// \returns Aaa 161 /// 162 /// Bbb 163 /// 164 /// \returns Ccc 165 int test_multiple_returns2(int); 166 167 /// \result Aaa 168 /// 169 /// Bbb 170 /// 171 /// \result Ccc 172 int test_multiple_returns3(int); 173 174 /// \returns Aaa 175 /// 176 /// Bbb 177 /// 178 /// \return Ccc 179 int test_multiple_returns4(int); 180 181 182 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} 183 /// \param a Blah blah. 184 int test_param1_backslash; 185 186 // rdar://13066276 187 // Check that the diagnostic uses the same command marker as the comment. 188 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}} 189 /// @param a Blah blah. 190 int test_param1_at; 191 192 // expected-warning@+1 {{empty paragraph passed to '\param' command}} 193 /// \param 194 /// \param a Blah blah. 195 int test_param2(int a); 196 197 // expected-warning@+1 {{empty paragraph passed to '\param' command}} 198 /// \param a 199 int test_param3(int a); 200 201 /// \param a Blah blah. 202 int test_param4(int a); 203 204 /// \param [in] a Blah blah. 205 int test_param5(int a); 206 207 /// \param [out] a Blah blah. 208 int test_param6(int a); 209 210 /// \param [in,out] a Blah blah. 211 int test_param7(int a); 212 213 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}} 214 /// \param [ in ] a Blah blah. 215 int test_param8(int a); 216 217 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}} 218 /// \param [in, out] a Blah blah. 219 int test_param9(int a); 220 221 // expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}} 222 /// \param [ junk] a Blah blah. 223 int test_param10(int a); 224 225 // expected-warning@+1 {{parameter 'a' not found in the function declaration}} 226 /// \param a Blah blah. 227 int test_param11(); 228 229 // expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}} 230 /// \param A Blah blah. 231 int test_param12(int a); 232 233 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} 234 /// \param aab Blah blah. 235 int test_param13(int aaa, int bbb); 236 237 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}} 238 /// \param aaa Blah blah. 239 /// \param aab Blah blah. 240 int test_param14(int aaa, int bbb); 241 242 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} 243 /// \param aab Blah blah. 244 int test_param15(int bbb, int ccc); 245 246 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} 247 /// \param aab Ccc. 248 /// \param aaa Aaa. 249 /// \param bbb Bbb. 250 int test_param16(int aaa, int bbb); 251 252 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}} 253 /// \param aaa Aaa. 254 /// \param aab Ccc. 255 /// \param bbb Bbb. 256 int test_param17(int aaa, int bbb); 257 258 // expected-warning@+3 {{parameter 'aab' not found in the function declaration}} 259 /// \param aaa Aaa. 260 /// \param bbb Bbb. 261 /// \param aab Ccc. 262 int test_param18(int aaa, int bbb); 263 264 class C { 265 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}} 266 /// \param aaa Blah blah. 267 C(int bbb, int ccc); 268 269 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}} 270 /// \param aaa Blah blah. 271 int test_param19(int bbb, int ccc); 272 }; 273 274 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} 275 /// \param aab Blah blah. 276 template<typename T> 277 void test_param20(int bbb, int ccc); 278 279 // expected-warning@+3 {{parameter 'a' is already documented}} 280 // expected-note@+1 {{previous documentation}} 281 /// \param a Aaa. 282 /// \param a Aaa. 283 int test_param21(int a); 284 285 // expected-warning@+4 {{parameter 'x2' is already documented}} 286 // expected-note@+2 {{previous documentation}} 287 /// \param x1 Aaa. 288 /// \param x2 Bbb. 289 /// \param x2 Ccc. 290 int test_param22(int x1, int x2, int x3); 291 292 // expected-warning@+1 {{empty paragraph passed to '\param' command}} 293 /// \param a 294 /// \retval 0 Blah blah. 295 int test_param23(int a); 296 297 /// \param a \ref test_param23 has an empty paragraph, this doesn't. 298 int test_param24(int a); 299 300 //===--- 301 // Test that we treat typedefs to some non-function types as functions for the 302 // purposes of documentation comment parsing. 303 //===--- 304 305 namespace foo { 306 inline namespace bar { 307 template<typename> 308 struct function_wrapper {}; 309 310 template<unsigned> 311 struct not_a_function_wrapper {}; 312 } 313 }; 314 315 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 316 /// \param aaa Meow. 317 /// \param bbb Bbb. 318 /// \returns aaa. 319 typedef int test_function_like_typedef1(int aaa, int ccc); 320 321 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 322 /// \param aaa Meow. 323 /// \param bbb Bbb. 324 /// \returns aaa. 325 typedef int (*test_function_like_typedef2)(int aaa, int ccc); 326 327 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 328 /// \param aaa Meow. 329 /// \param bbb Bbb. 330 /// \returns aaa. 331 typedef int (* const test_function_like_typedef3)(int aaa, int ccc); 332 333 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 334 /// \param aaa Meow. 335 /// \param bbb Bbb. 336 /// \returns aaa. 337 typedef int (C::*test_function_like_typedef4)(int aaa, int ccc); 338 339 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 340 /// \param aaa Meow. 341 /// \param bbb Bbb. 342 /// \returns aaa. 343 typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef5; 344 345 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 346 /// \param aaa Meow. 347 /// \param bbb Bbb. 348 /// \returns aaa. 349 typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6; 350 351 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 352 /// \param aaa Meow. 353 /// \param bbb Bbb. 354 /// \returns aaa. 355 typedef foo::function_wrapper<int (int aaa, int ccc)> &test_function_like_typedef7; 356 357 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 358 /// \param aaa Meow. 359 /// \param bbb Bbb. 360 /// \returns aaa. 361 typedef foo::function_wrapper<int (int aaa, int ccc)> &&test_function_like_typedef8; 362 363 364 typedef int (*test_not_function_like_typedef1)(int aaa); 365 366 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} 367 /// \param aaa Meow. 368 typedef test_not_function_like_typedef1 test_not_function_like_typedef2; 369 370 // rdar://13066276 371 // Check that the diagnostic uses the same command marker as the comment. 372 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}} 373 /// @param aaa Meow. 374 typedef unsigned int test_not_function_like_typedef3; 375 376 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} 377 /// \param aaa Meow. 378 typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4; 379 380 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 381 /// \param aaa Meow. 382 /// \param bbb Bbb. 383 /// \returns aaa. 384 using test_function_like_using1 = int (int aaa, int ccc); 385 386 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 387 /// \param aaa Meow. 388 /// \param bbb Bbb. 389 /// \returns aaa. 390 using test_function_like_using2 = int (*)(int aaa, int ccc); 391 392 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 393 /// \param aaa Meow. 394 /// \param bbb Bbb. 395 /// \returns aaa. 396 using test_function_like_using3 = int (* const)(int aaa, int ccc); 397 398 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 399 /// \param aaa Meow. 400 /// \param bbb Bbb. 401 /// \returns aaa. 402 using test_function_like_using4 = int (C::*)(int aaa, int ccc); 403 404 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 405 /// \param aaa Meow. 406 /// \param bbb Bbb. 407 /// \returns aaa. 408 using test_function_like_using5 = foo::function_wrapper<int (int aaa, int ccc)>; 409 410 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 411 /// \param aaa Meow. 412 /// \param bbb Bbb. 413 /// \returns aaa. 414 using test_function_like_using6 = foo::function_wrapper<int (int aaa, int ccc)> *; 415 416 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 417 /// \param aaa Meow. 418 /// \param bbb Bbb. 419 /// \returns aaa. 420 using test_function_like_using7 = foo::function_wrapper<int (int aaa, int ccc)> &; 421 422 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 423 /// \param aaa Meow. 424 /// \param bbb Bbb. 425 /// \returns aaa. 426 using test_function_like_using8 = foo::function_wrapper<int (int aaa, int ccc)> &&; 427 428 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}} 429 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 430 /// \param aaa Meow. 431 /// \param bbb Bbb. 432 /// \tparam U Uuu. 433 template<typename T> 434 using test_function_like_using9 = int(T aaa, int ccc); 435 436 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}} 437 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 438 /// \param aaa Meow. 439 /// \param bbb Bbb. 440 /// \tparam U Uuu. 441 template<typename T> 442 using test_function_like_using10 = int (*)(T aaa, int ccc); 443 444 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}} 445 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 446 /// \param aaa Meow. 447 /// \param bbb Bbb. 448 /// \tparam U Uuu. 449 template<typename T> 450 using test_function_like_using11 = foo::function_wrapper<int (T aaa, int ccc)>; 451 452 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}} 453 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}} 454 /// \param aaa Meow. 455 /// \param bbb Bbb. 456 /// \tparam U Uuu. 457 template<typename T> 458 using test_function_like_using12 = foo::function_wrapper<int (T aaa, int ccc)> *; 459 460 using test_not_function_like_using1 = int (*)(int aaa); 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_using2 = test_not_function_like_using1; 465 466 // Check that the diagnostic uses the same command marker as the comment. 467 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}} 468 /// @param aaa Meow. 469 using test_not_function_like_using3 = unsigned int; 470 471 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} 472 /// \param aaa Meow. 473 using test_not_function_like_using4 = foo::not_a_function_wrapper<1>; 474 475 /// \param aaa Aaa 476 /// \param ... Vararg 477 int test_vararg_param1(int aaa, ...); 478 479 /// \param ... Vararg 480 int test_vararg_param2(...); 481 482 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} 483 /// \param ... Vararg 484 int test_vararg_param3(int aaa); 485 486 // expected-warning@+1 {{parameter '...' not found in the function declaration}} 487 /// \param ... Vararg 488 int test_vararg_param4(); 489 490 491 /// \param aaa Aaa 492 /// \param ... Vararg 493 template<typename T> 494 int test_template_vararg_param1(int aaa, ...); 495 496 /// \param ... Vararg 497 template<typename T> 498 int test_template_vararg_param2(...); 499 500 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} 501 /// \param ... Vararg 502 template<typename T> 503 int test_template_vararg_param3(int aaa); 504 505 // expected-warning@+1 {{parameter '...' not found in the function declaration}} 506 /// \param ... Vararg 507 template<typename T> 508 int test_template_vararg_param4(); 509 510 511 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}} 512 /// \tparam T Aaa 513 int test_tparam1; 514 515 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}} 516 /// \tparam T Aaa 517 void test_tparam2(int aaa); 518 519 // expected-warning@+1 {{empty paragraph passed to '\tparam' command}} 520 /// \tparam 521 /// \param aaa Blah blah 522 template<typename T> 523 void test_tparam3(T aaa); 524 525 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}} 526 /// \tparam T Aaa 527 template<typename TT> 528 void test_tparam4(TT aaa); 529 530 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}} 531 /// \tparam T Aaa 532 template<typename TT> 533 class test_tparam5 { 534 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}} 535 /// \tparam T Aaa 536 template<typename TTT> 537 void test_tparam6(TTT aaa); 538 }; 539 540 /// \tparam T1 Aaa 541 /// \tparam T2 Bbb 542 template<typename T1, typename T2> 543 void test_tparam7(T1 aaa, T2 bbb); 544 545 // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}} 546 /// \tparam SomTy Aaa 547 /// \tparam OtherTy Bbb 548 template<typename SomeTy, typename OtherTy> 549 void test_tparam8(SomeTy aaa, OtherTy bbb); 550 551 // expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}} 552 /// \tparam T1 Aaa 553 /// \tparam T1 Bbb 554 template<typename T1, typename T2> 555 void test_tparam9(T1 aaa, T2 bbb); 556 557 /// \tparam T Aaa 558 /// \tparam TT Bbb 559 template<template<typename T> class TT> 560 void test_tparam10(TT<int> aaa); 561 562 /// \tparam T Aaa 563 /// \tparam TT Bbb 564 /// \tparam TTT Ccc 565 template<template<template<typename T> class TT, class C> class TTT> 566 void test_tparam11(); 567 568 /// \tparam I Aaa 569 template<int I> 570 void test_tparam12(); 571 572 template<typename T, typename U> 573 class test_tparam13 { }; 574 575 /// \tparam T Aaa 576 template<typename T> 577 using test_tparam14 = test_tparam13<T, int>; 578 579 // expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}} 580 /// \tparam U Aaa 581 template<typename T> 582 using test_tparam15 = test_tparam13<T, int>; 583 584 // ---- 585 586 /// \tparam T Aaa 587 template<typename T> 588 class test_tparam16 { }; 589 590 typedef test_tparam16<int> test_tparam17; 591 typedef test_tparam16<double> test_tparam18; 592 593 // ---- 594 595 template<typename T> 596 class test_tparam19; 597 598 typedef test_tparam19<int> test_tparam20; 599 typedef test_tparam19<double> test_tparam21; 600 601 /// \tparam T Aaa 602 template<typename T> 603 class test_tparam19 { }; 604 605 // ---- 606 607 // expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}} 608 /// @tparam T Aaa 609 int test_tparam22; 610 611 // ---- 612 613 614 /// Aaa 615 /// \deprecated Bbb 616 void test_deprecated_1(int a) __attribute__((deprecated)); 617 618 #if __cplusplus >= 201402L 619 /// Aaa 620 /// \deprecated Bbb 621 [[deprecated]] void test_deprecated_no_warning_std14(int a); 622 #endif 623 624 // We don't want \deprecated to warn about empty paragraph. It is fine to use 625 // \deprecated by itself without explanations. 626 627 /// Aaa 628 /// \deprecated 629 void test_deprecated_2(int a) __attribute__((deprecated)); 630 631 /// Aaa 632 /// \deprecated 633 void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4))); 634 635 /// Aaa 636 /// \deprecated 637 void test_deprecated_4(int a) __attribute__((unavailable)); 638 639 // 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}} 640 /// Aaa 641 /// \deprecated 642 void test_deprecated_5(int a); 643 644 // 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}} 645 /// Aaa 646 /// @deprecated 647 void test_deprecated_6(int a) { 648 } 649 650 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} 651 /// Aaa 652 /// \deprecated 653 template<typename T> 654 void test_deprecated_7(T aaa); 655 656 class PR43753 { 657 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} 658 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}} 659 /// \deprecated 660 static void test_deprecated_static(); 661 662 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} 663 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}} 664 /// \deprecated 665 static auto test_deprecated_static_trailing_return() -> int; 666 667 #if __cplusplus >= 201402L 668 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} 669 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}} 670 /// \deprecated 671 static decltype(auto) test_deprecated_static_decltype_auto() { return 1; } 672 #endif 673 674 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} 675 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}} 676 /// \deprecated 677 void test_deprecated_const() const; 678 679 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} 680 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}} 681 /// \deprecated 682 auto test_deprecated_trailing_return() -> int; 683 684 #if __cplusplus >= 201402L 685 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} 686 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}} 687 /// \deprecated 688 decltype(auto) test_deprecated_decltype_auto() const { return a; } 689 690 private: 691 int a{0}; 692 #endif 693 }; 694 695 // rdar://12397511 696 // expected-note@+2 {{previous command '\headerfile' here}} 697 // expected-warning@+2 {{duplicated command '\headerfile'}} 698 /// \headerfile "" 699 /// \headerfile foo.h 700 int test__headerfile_1(int a); 701 702 703 /// \invariant aaa 704 void test_invariant_1(int a); 705 706 // expected-warning@+1 {{empty paragraph passed to '\invariant' command}} 707 /// \invariant 708 void test_invariant_2(int a); 709 710 711 // no-warning 712 /// \returns Aaa 713 int test_returns_right_decl_1(int); 714 715 class test_returns_right_decl_2 { 716 // no-warning 717 /// \returns Aaa 718 int test_returns_right_decl_3(int); 719 }; 720 721 // no-warning 722 /// \returns Aaa 723 template<typename T> 724 int test_returns_right_decl_4(T aaa); 725 726 // no-warning 727 /// \returns Aaa 728 template<> 729 int test_returns_right_decl_4(int aaa); 730 731 /// \returns Aaa 732 template<typename T> 733 T test_returns_right_decl_5(T aaa); 734 735 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 736 /// \returns Aaa 737 int test_returns_wrong_decl_1_backslash; 738 739 // rdar://13066276 740 // Check that the diagnostic uses the same command marker as the comment. 741 // expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}} 742 /// @returns Aaa 743 int test_returns_wrong_decl_1_at; 744 745 // expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}} 746 /// \return Aaa 747 int test_returns_wrong_decl_2; 748 749 // expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}} 750 /// \result Aaa 751 int test_returns_wrong_decl_3; 752 753 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}} 754 /// \returns Aaa 755 void test_returns_wrong_decl_4(int); 756 757 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}} 758 /// \returns Aaa 759 template<typename T> 760 void test_returns_wrong_decl_5(T aaa); 761 762 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}} 763 /// \returns Aaa 764 template<> 765 void test_returns_wrong_decl_5(int aaa); 766 767 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 768 /// \returns Aaa 769 struct test_returns_wrong_decl_6 { }; 770 771 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 772 /// \returns Aaa 773 class test_returns_wrong_decl_7 { 774 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}} 775 /// \returns Aaa 776 test_returns_wrong_decl_7(); 777 778 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}} 779 /// \returns Aaa 780 ~test_returns_wrong_decl_7(); 781 }; 782 783 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 784 /// \returns Aaa 785 enum test_returns_wrong_decl_8 { 786 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 787 /// \returns Aaa 788 test_returns_wrong_decl_9 789 }; 790 791 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 792 /// \returns Aaa 793 namespace test_returns_wrong_decl_10 { }; 794 795 // rdar://13094352 796 // expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}} 797 /*! @function test_function 798 */ 799 typedef unsigned int Base64Flags; 800 unsigned test_function(Base64Flags inFlags); 801 802 // expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}} 803 /*! @callback test_callback 804 */ 805 typedef unsigned int BaseFlags; 806 unsigned (*test_callback)(BaseFlags inFlags); 807 808 // expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}} 809 /// \endverbatim 810 int test_verbatim_1(); 811 812 // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}} 813 /// \endcode 814 int test_verbatim_2(); 815 816 // FIXME: we give a bad diagnostic here because we throw away non-documentation 817 // comments early. 818 // 819 // expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}} 820 /// \code 821 // foo 822 /// \endcode 823 int test_verbatim_3(); 824 825 826 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 827 int test1; ///< \brief\author Aaa 828 829 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 830 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 831 int test2, ///< \brief\author Aaa 832 test3; ///< \brief\author Aaa 833 834 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 835 int test4; ///< \brief 836 ///< \author Aaa 837 838 839 class TestRelates {}; 840 841 /// \relates TestRelates 842 /// \brief Aaa 843 void test_relates_1(); 844 845 /// \related TestRelates 846 /// \brief Aaa 847 void test_relates_2(); 848 849 /// \relatesalso TestRelates 850 /// \brief Aaa 851 void test_relates_3(); 852 853 /// \relatedalso TestRelates 854 /// \brief Aaa 855 void test_relates_4(); 856 857 858 // Check that we attach the comment to the declaration during parsing in the 859 // following cases. The test is based on the fact that we don't parse 860 // documentation comments that are not attached to anything. 861 862 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 863 /// \brief\author Aaa 864 int test_attach1; 865 866 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 867 /// \brief\author Aaa 868 int test_attach2(int); 869 870 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 871 /// \brief\author Aaa 872 struct test_attach3 { 873 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 874 /// \brief\author Aaa 875 int test_attach4; 876 877 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 878 int test_attach5; ///< \brief\author Aaa 879 880 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 881 /// \brief\author Aaa 882 int test_attach6(int); 883 }; 884 885 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 886 /// \brief\author Aaa 887 class test_attach7 { 888 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 889 /// \brief\author Aaa 890 int test_attach8; 891 892 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 893 int test_attach9; ///< \brief\author Aaa 894 895 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 896 /// \brief\author Aaa 897 int test_attach10(int); 898 }; 899 900 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 901 /// \brief\author Aaa 902 enum test_attach9 { 903 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 904 /// \brief\author Aaa 905 test_attach10, 906 907 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 908 test_attach11 ///< \brief\author Aaa 909 }; 910 911 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 912 /// \brief\author Aaa 913 struct test_noattach12 *test_attach13; 914 915 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 916 /// \brief\author Aaa 917 typedef struct test_noattach14 *test_attach15; 918 919 // expected-warning@+1 + {{empty paragraph passed to '\brief' command}} 920 /// \brief\author Aaa 921 typedef struct test_attach16 { int a; } test_attach17; 922 923 struct S { int a; }; 924 925 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 926 /// \brief\author Aaa 927 struct S *test_attach18; 928 929 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 930 /// \brief\author Aaa 931 typedef struct S *test_attach19; 932 933 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 934 /// \brief\author Aaa 935 struct test_attach20; 936 937 // expected-warning@+1 + {{empty paragraph passed to '\brief' command}} 938 /// \brief\author Aaa 939 typedef struct test_attach21 { 940 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 941 /// \brief\author Aaa 942 int test_attach22; 943 } test_attach23; 944 945 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 946 /// \brief\author Aaa 947 namespace test_attach24 { 948 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 949 /// \brief\author Aaa 950 namespace test_attach25 { 951 } 952 } 953 954 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 955 /// \brief\author Aaa 956 /// \tparam T Aaa 957 template<typename T> 958 void test_attach26(T aaa); 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 void test_attach27(T aaa, U bbb); 965 966 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 967 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 968 /// \brief\author Aaa 969 /// \tparam T Aaa 970 template<> 971 void test_attach27(int aaa, int bbb); 972 973 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 974 /// \brief\author Aaa 975 /// \tparam T Aaa 976 template<typename T> 977 class test_attach28 { 978 T aaa; 979 }; 980 981 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 982 /// \brief\author Aaa 983 using test_attach29 = test_attach28<int>; 984 985 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 986 /// \brief\author Aaa 987 /// \tparam T Aaa 988 template<typename T, typename U> 989 class test_attach30 { }; 990 991 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 992 /// \brief\author Aaa 993 /// \tparam T Aaa 994 template<typename T> 995 class test_attach30<T, int> { }; 996 997 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 998 /// \brief\author Aaa 999 template<> 1000 class test_attach30<int, int> { }; 1001 1002 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1003 /// \brief\author Aaa 1004 template<typename T> 1005 using test_attach31 = test_attach30<T, int>; 1006 1007 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1008 /// \brief\author Aaa 1009 /// \tparam T Aaa 1010 template<typename T, typename U, typename V> 1011 class test_attach32 { }; 1012 1013 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1014 /// \brief\author Aaa 1015 /// \tparam T Aaa 1016 template<typename T, typename U> 1017 class test_attach32<T, U, int> { }; 1018 1019 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1020 /// \brief\author Aaa 1021 /// \tparam T Aaa 1022 template<typename T> 1023 class test_attach32<T, int, int> { }; 1024 1025 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 1026 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 1027 /// \brief\author Aaa 1028 /// \tparam T Aaa 1029 template<> 1030 class test_attach32<int, int, int> { }; 1031 1032 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1033 /// \brief\author Aaa 1034 class test_attach33 { 1035 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1036 /// \brief\author Aaa 1037 /// \tparam T Aaa 1038 template<typename T, typename U> 1039 void test_attach34(T aaa, U bbb); 1040 }; 1041 1042 template<typename T> 1043 class test_attach35 { 1044 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 1045 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 1046 /// \brief\author Aaa 1047 /// \tparam T Aaa 1048 template<typename TT, typename UU> 1049 void test_attach36(TT aaa, UU bbb); 1050 }; 1051 1052 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 1053 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 1054 /// \brief\author Aaa 1055 /// \tparam T Aaa 1056 template<> template<> 1057 void test_attach35<int>::test_attach36(int aaa, int bbb) {} 1058 1059 template<typename T> 1060 class test_attach37 { 1061 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 1062 // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}} 1063 /// \brief\author Aaa 1064 /// \tparam T Aaa 1065 void test_attach38(int aaa, int bbb); 1066 1067 void test_attach39(int aaa, int bbb); 1068 }; 1069 1070 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 1071 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 1072 /// \brief\author Aaa 1073 /// \tparam T Aaa 1074 template<> 1075 void test_attach37<int>::test_attach38(int aaa, int bbb) {} 1076 1077 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1078 /// \brief\author Aaa 1079 /// \tparam T Aaa 1080 template<typename T> 1081 void test_attach37<T>::test_attach39(int aaa, int bbb) {} 1082 1083 // We used to emit warning that parameter 'a' is not found because we parsed 1084 // the comment in context of the redeclaration which does not have parameter 1085 // names. 1086 template <typename T> 1087 struct test_attach38 { 1088 /*! 1089 \param a First param 1090 \param b Second param 1091 */ 1092 template <typename B> 1093 void test_attach39(T a, B b); 1094 }; 1095 1096 template <> 1097 template <typename B> 1098 void test_attach38<int>::test_attach39(int, B); 1099 1100 // The inline comments expect a string after the command. 1101 // expected-warning@+1 {{'\a' command does not have a valid word argument}} 1102 /// \a 1103 int test_inline_no_argument_a_bad(int); 1104 1105 /// \a A 1106 int test_inline_no_argument_a_good(int); 1107 1108 // expected-warning@+1 {{'\anchor' command does not have a valid word argument}} 1109 /// \anchor 1110 int test_inline_no_argument_anchor_bad(int); 1111 1112 /// \anchor A 1113 int test_inline_no_argument_anchor_good(int); 1114 1115 // expected-warning@+1 {{'@b' command does not have a valid word argument}} 1116 /// @b 1117 int test_inline_no_argument_b_bad(int); 1118 1119 /// @b A 1120 int test_inline_no_argument_b_good(int); 1121 1122 // expected-warning@+1 {{'\c' command does not have a valid word argument}} 1123 /// \c 1124 int test_inline_no_argument_c_bad(int); 1125 1126 /// \c A 1127 int test_inline_no_argument_c_good(int); 1128 1129 // expected-warning@+1 {{'\e' command does not have a valid word argument}} 1130 /// \e 1131 int test_inline_no_argument_e_bad(int); 1132 1133 /// \e A 1134 int test_inline_no_argument_e_good(int); 1135 1136 // expected-warning@+1 {{'\em' command does not have a valid word argument}} 1137 /// \em 1138 int test_inline_no_argument_em_bad(int); 1139 1140 /// \em A 1141 int test_inline_no_argument_em_good(int); 1142 1143 // expected-warning@+1 {{'\p' command does not have a valid word argument}} 1144 /// \p 1145 int test_inline_no_argument_p_bad(int); 1146 1147 /// \p A 1148 int test_inline_no_argument_p_good(int); 1149 1150 // PR13411, reduced. We used to crash on this. 1151 /** 1152 * @code Aaa. 1153 */ 1154 void test_nocrash1(int); 1155 1156 // We used to crash on this. 1157 // expected-warning@+2 {{empty paragraph passed to '\param' command}} 1158 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 1159 /// \param\brief 1160 void test_nocrash2(int); 1161 1162 // PR13593, example 1 and 2 1163 1164 /** 1165 * Bla. 1166 */ 1167 template <typename> 1168 void test_nocrash3(); 1169 1170 /// Foo 1171 template <typename, typename> 1172 void test_nocrash4() { } 1173 1174 template <typename> 1175 void test_nocrash3() 1176 { 1177 } 1178 1179 // PR13593, example 3 1180 1181 /** 1182 * aaa 1183 */ 1184 template <typename T> 1185 inline T test_nocrash5(T a1) 1186 { 1187 return a1; 1188 } 1189 1190 /// 1191 //, 1192 1193 inline void test_nocrash6() 1194 { 1195 test_nocrash5(1); 1196 } 1197 1198 // We used to crash on this. 1199 1200 /*! 1201 Blah. 1202 */ 1203 typedef const struct test_nocrash7 * test_nocrash8; 1204 1205 // We used to crash on this. 1206 1207 // expected-warning@+1 {{unknown command tag name}} 1208 /// aaa \unknown aaa \unknown aaa 1209 int test_nocrash9; 1210 1211 // We used to crash on this. PR15068 1212 1213 // expected-warning@+2 {{empty paragraph passed to '@param' command}} 1214 // expected-warning@+2 {{empty paragraph passed to '@param' command}} 1215 ///@param x 1216 ///@param y 1217 int test_nocrash10(int x, int y); 1218 1219 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}} 1220 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}} 1221 ///@param x 1222 ///@param y 1223 int test_nocrash11(); 1224 1225 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}} 1226 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}} 1227 /** 1228 @param x 1229 @param y 1230 **/ 1231 int test_nocrash12(); 1232 1233 // expected-warning@+2 {{empty paragraph passed to '@param' command}} 1234 // expected-warning@+1 {{empty paragraph passed to '@param' command}} 1235 ///@param x@param y 1236 int test_nocrash13(int x, int y); 1237 1238 /** 1239 * \verbatim 1240 * Aaa 1241 **/ 1242 int test_nocrash14(); 1243 1244 // rdar://12379114 1245 // expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}} 1246 /*! 1247 @union U This is new 1248 */ 1249 struct U { int iS; }; 1250 1251 /*! 1252 @union U1 1253 */ 1254 union U1 {int i; }; 1255 1256 // expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}} 1257 /*! 1258 @struct S2 1259 */ 1260 union S2 {}; 1261 1262 /*! 1263 @class C1 1264 */ 1265 class C1; 1266 1267 /*! 1268 @struct S3; 1269 */ 1270 class S3; 1271 1272 // rdar://14124702 1273 //---------------------------------------------------------------------- 1274 /// @class Predicate Predicate.h "lldb/Host/Predicate.h" 1275 /// @brief A C++ wrapper class for providing threaded access to a value 1276 /// of type T. 1277 /// 1278 /// A templatized class. 1279 /// specified values. 1280 //---------------------------------------------------------------------- 1281 template <class T, class T1> 1282 class Predicate 1283 { 1284 }; 1285 1286 //---------------------------------------------------------------------- 1287 /// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h" 1288 /// @brief A C++ wrapper class for providing threaded access to a value 1289 /// of type T. 1290 /// 1291 /// A template specialization class. 1292 //---------------------------------------------------------------------- 1293 template<> class Predicate<int, char> 1294 { 1295 }; 1296 1297 //---------------------------------------------------------------------- 1298 /// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h" 1299 /// @brief A C++ wrapper class for providing threaded access to a value 1300 /// of type T. 1301 /// 1302 /// A partial specialization template class. 1303 //---------------------------------------------------------------------- 1304 template<class T> class Predicate<T, int> 1305 { 1306 }; 1307 1308 /*! @function test_function 1309 */ 1310 template <class T> T test_function (T arg); 1311 1312 /*! @function test_function<int> 1313 */ 1314 template <> int test_function<int> (int arg); 1315 1316 namespace AllowParamAndReturnsOnFunctionPointerVars { 1317 1318 /** 1319 * functionPointerVariable 1320 * 1321 * @param i is integer. 1322 * @returns integer. 1323 */ 1324 int (*functionPointerVariable)(int i); 1325 1326 #if __cplusplus >= 201402L 1327 /** 1328 * functionPointerVariableTemplate 1329 * 1330 * @param i is something. 1331 * @returns integer. 1332 */ 1333 template<typename T> 1334 int (*functionPointerVariableTemplate)(T i); 1335 #endif 1336 1337 struct HasFields { 1338 /** 1339 * functionPointerField 1340 * 1341 * @param i is integer. 1342 * @returns integer. 1343 */ 1344 int (*functionPointerField)(int i); 1345 1346 #if __cplusplus >= 201402L 1347 /** 1348 * functionPointerTemplateMember 1349 * 1350 * @tparam T some type. 1351 * @param i is integer. 1352 * @returns integer. 1353 */ 1354 template<typename T> 1355 static int (*functionPointerTemplateMember)(int i); 1356 #endif 1357 }; 1358 1359 // expected-warning@+5 {{parameter 'p' not found in the function declaration}} 1360 // expected-warning@+5 {{'\returns' command used in a comment that is attached to a function returning void}} 1361 /** 1362 * functionPointerVariable 1363 * 1364 * \param p not here. 1365 * \returns integer. 1366 */ 1367 void (*functionPointerVariableThatLeadsNowhere)(); 1368 1369 #if __cplusplus >= 201402L 1370 // expected-warning@+8 {{template parameter 'X' not found in the template declaration}} 1371 // expected-note@+7 {{did you mean 'T'?}} 1372 // expected-warning@+7 {{parameter 'p' not found in the function declaration}} 1373 // expected-note@+6 {{did you mean 'x'?}} 1374 // expected-warning@+6 {{'\returns' command used in a comment that is attached to a function returning void}} 1375 /** 1376 * functionPointerVariable 1377 * 1378 * \tparam X typo 1379 * \param p not here. 1380 * \returns integer. 1381 */ 1382 template<typename T> 1383 void (*functionPointerVariableTemplateThatLeadsNowhere)(T x); 1384 #endif 1385 1386 // Still warn about param/returns commands for variables that don't specify 1387 // the type directly: 1388 1389 /** 1390 * FunctionPointerTypedef 1391 * 1392 * \param i is integer. 1393 * \returns integer. 1394 */ 1395 typedef int (*FunctionPointerTypedef)(int i); 1396 1397 /** 1398 * FunctionPointerTypealias 1399 * 1400 * \param i is integer. 1401 * \returns integer. 1402 */ 1403 using FunctionPointerTypealias = int (*)(int i); 1404 1405 // expected-warning@+5 {{'@param' command used in a comment that is not attached to a function declaration}} 1406 // expected-warning@+5 {{'@returns' command used in a comment that is not attached to a function or method declaration}} 1407 /** 1408 * functionPointerVariable 1409 * 1410 * @param i is integer. 1411 * @returns integer. 1412 */ 1413 FunctionPointerTypedef functionPointerTypedefVariable; 1414 1415 struct HasMoreFields { 1416 // expected-warning@+5 {{'\param' command used in a comment that is not attached to a function declaration}} 1417 // expected-warning@+5 {{'\returns' command used in a comment that is not attached to a function or method declaration}} 1418 /** 1419 * functionPointerTypealiasField 1420 * 1421 * \param i is integer. 1422 * \returns integer. 1423 */ 1424 FunctionPointerTypealias functionPointerTypealiasField; 1425 }; 1426 1427 } 1428 1429 /*! 1430 * Function pointer typedef with variadic params. 1431 * 1432 * @param a 1433 * works 1434 * 1435 * @param ... 1436 * now should work too. 1437 */ 1438 typedef void (*VariadicFnType)(int a, ...); 1439 1440 /*! 1441 * Function pointer type alias with variadic params. 1442 * 1443 * @param a 1444 * works 1445 * 1446 * @param ... 1447 * now should work too. 1448 */ 1449 using VariadicFnType2 = void (*)(int a, ...); 1450 1451 /*! 1452 * Function pointer type variable. 1453 * 1454 * @param a 1455 * works 1456 * 1457 * @param ... 1458 * now should work too. 1459 */ 1460 void (*variadicFnVar)(int a, ...); 1461 1462 // expected-warning@+2 {{empty paragraph passed to '@note' command}} 1463 /** 1464 @note 1465 \f$\texttt{mu}_{00}=\texttt{m}_{00}\f$, \f$\texttt{nu}_{00}=1\f$ 1466 \f$\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\f$ 1467 */ 1468 class EmptyNoteNoCrash { 1469 }; 1470 1471 namespace PR42844 { // Assertion failures when using typedefed function pointers 1472 typedef void (*AA)(); 1473 typedef AA A(); 1474 A *a; ///< \return none 1475 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}} 1476 1477 typedef void B(); 1478 B *b; ///< \return none 1479 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}} 1480 1481 void CC(); 1482 typedef void C(); 1483 C &c = CC; ///< \return none 1484 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}} 1485 1486 using DD = void(*)(); 1487 using D = DD(); 1488 D *d; ///< \return none 1489 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}} 1490 1491 using E = void(); 1492 E *e; ///< \return none 1493 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}} 1494 1495 void FF(); 1496 using F = void(); 1497 F &f = FF; ///< \return none 1498 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}} 1499 1500 } // namespace PR42844 1501