warn-documentation.cpp 32 KB

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