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