warn-documentation-fixits.cpp 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -verify %s
  2. // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
  3. // expected-warning@+1 {{parameter 'ZZZZZZZZZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
  4. /// \param ZZZZZZZZZZ Blah blah.
  5. int test1(int a);
  6. // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
  7. /// \param aab Blah blah.
  8. int test2(int aaa, int bbb);
  9. // expected-warning@+1 {{template parameter 'ZZZZZZZZZZ' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
  10. /// \tparam ZZZZZZZZZZ Aaa
  11. template<typename T>
  12. void test3(T aaa);
  13. // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
  14. /// \tparam SomTy Aaa
  15. /// \tparam OtherTy Bbb
  16. template<typename SomeTy, typename OtherTy>
  17. void test4(SomeTy aaa, OtherTy bbb);
  18. // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
  19. /// \deprecated
  20. void test_deprecated_1();
  21. // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
  22. /// \deprecated
  23. void test_deprecated_2(int a);
  24. struct test_deprecated_3 {
  25. // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
  26. /// \deprecated
  27. void test_deprecated_4();
  28. // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
  29. /// \deprecated
  30. void test_deprecated_5() {
  31. }
  32. };
  33. template<typename T>
  34. struct test_deprecated_6 {
  35. // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
  36. /// \deprecated
  37. void test_deprecated_7();
  38. // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
  39. /// \deprecated
  40. void test_deprecated_8() {
  41. }
  42. };
  43. #define MY_ATTR_DEPRECATED __attribute__((deprecated))
  44. // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
  45. /// \deprecated
  46. void test_deprecated_9(int a);
  47. // rdar://12381408
  48. // expected-warning@+2 {{unknown command tag name 'retur'; did you mean 'return'?}}
  49. /// \brief testing fixit
  50. /// \retur int in FooBar
  51. int FooBar();
  52. // expected-warning@+1 {{unknown command tag name 'fooba'; did you mean 'foobar'?}}
  53. /// \fooba bbb IS_DOXYGEN_END
  54. int gorf();
  55. // expected-warning@+1 {{unknown command tag name}}
  56. /// \t bbb IS_DOXYGEN_END
  57. int Bar();
  58. // expected-warning@+2 {{unknown command tag name 'encode'; did you mean 'endcode'?}}
  59. // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
  60. /// \encode PR18051
  61. int PR18051();
  62. // CHECK: fix-it:"{{.*}}":{5:12-5:22}:"a"
  63. // CHECK: fix-it:"{{.*}}":{9:12-9:15}:"aaa"
  64. // CHECK: fix-it:"{{.*}}":{13:13-13:23}:"T"
  65. // CHECK: fix-it:"{{.*}}":{18:13-18:18}:"SomeTy"
  66. // CHECK: fix-it:"{{.*}}":{25:25-25:25}:" __attribute__((deprecated))"
  67. // CHECK: fix-it:"{{.*}}":{29:30-29:30}:" __attribute__((deprecated))"
  68. // CHECK: fix-it:"{{.*}}":{34:27-34:27}:" __attribute__((deprecated))"
  69. // CHECK: fix-it:"{{.*}}":{38:27-38:27}:" __attribute__((deprecated))"
  70. // CHECK: fix-it:"{{.*}}":{46:27-46:27}:" __attribute__((deprecated))"
  71. // CHECK: fix-it:"{{.*}}":{50:27-50:27}:" __attribute__((deprecated))"
  72. // CHECK: fix-it:"{{.*}}":{58:30-58:30}:" MY_ATTR_DEPRECATED"
  73. // CHECK: fix-it:"{{.*}}":{63:6-63:11}:"return"
  74. // CHECK: fix-it:"{{.*}}":{67:6-67:11}:"foobar"
  75. // CHECK: fix-it:"{{.*}}":{76:6-76:12}:"endcode"