xref: /llvm-project/clang/test/AST/ast-print-method-decl.cpp (revision 9391ff8c86007562d40c240ea082b7c0cbf35947)
1 // RUN: %clang_cc1 -ast-print -triple i386-linux-gnu %s -o - -std=c++20 | FileCheck %s
2 
3 // CHECK: struct DelegatingCtor1 {
4 struct DelegatingCtor1 {
5   // CHECK-NEXT: DelegatingCtor1();
6   DelegatingCtor1();
7 
8   // CHECK-NEXT: DelegatingCtor1(int) : DelegatingCtor1() {
DelegatingCtor1DelegatingCtor19   DelegatingCtor1(int) : DelegatingCtor1() {
10     // CHECK-NEXT: }
11   }
12 
13   // CHECK-NEXT: };
14 };
15 
16 
17 // CHECK: struct DelegatingCtor2 {
18 struct DelegatingCtor2 {
19   // CHECK-NEXT: template <typename Ty> DelegatingCtor2(Ty);
20   template <typename Ty> DelegatingCtor2(Ty);
21 
22   // FIXME: Implicitly specialized method should not be output
23   // CHECK-NEXT: template<> DelegatingCtor2<float>(float);
24 
25   // CHECK-NEXT: DelegatingCtor2(int X) : DelegatingCtor2((float)X) {
DelegatingCtor2DelegatingCtor226   DelegatingCtor2(int X) : DelegatingCtor2((float)X) {
27   // CHECK-NEXT: }
28   }
29 
30   // CHECK-NEXT: };
31 };
32 
33 // CHECK: struct DelegatingCtor3 {
34 struct DelegatingCtor3 {
35   // CHECK: DelegatingCtor3(auto);
36   DelegatingCtor3(auto);
37 
38   // FIXME: Implicitly specialized method should not be output
39   // CHECK: template<> DelegatingCtor3<const char *>(const char *);
40 
41   // CHECK: DelegatingCtor3(int) : DelegatingCtor3("") {
DelegatingCtor3DelegatingCtor342   DelegatingCtor3(int) : DelegatingCtor3("") {
43   // CHECK-NEXT: }
44   }
45 
46   // CHECK-NEXT: };
47 };
48 
49 // CHECK: struct CurlyCtorInit {
50 struct CurlyCtorInit {
51   // CHECK-NEXT: struct A {
52   struct A {
53     // CHECK-NEXT: int x;
54     int x;
55   // CHECK-NEXT: };
56   };
57 
58   // CHECK-NEXT: A a;
59   A a;
60   // CHECK-NEXT: int i;
61   int i;
62 
63   // FIXME: /*implicit*/(int)0 should not be output
64   // CHECK-NEXT: CurlyCtorInit(int *) : a(), i(/*implicit*/(int)0) {
CurlyCtorInitCurlyCtorInit65   CurlyCtorInit(int *) : a(), i() {
66   // CHECK-NEXT: }
67   }
68 
69   // CHECK-NEXT: CurlyCtorInit(int **) : a{}, i{} {
CurlyCtorInitCurlyCtorInit70   CurlyCtorInit(int **) : a{}, i{} {
71   // CHECK-NEXT: }
72   }
73 
74   // CHECK-NEXT: CurlyCtorInit(int ***) : a({}), i(0) {
CurlyCtorInitCurlyCtorInit75   CurlyCtorInit(int ***) : a({}), i(0) {
76   // CHECK-NEXT: }
77   }
78 
79   // FIXME: Implicit this should not be output
80   // CHECK-NEXT: CurlyCtorInit(int ****) : a({.x = 0}), i(this->a.x) {
CurlyCtorInitCurlyCtorInit81   CurlyCtorInit(int ****) : a({.x = 0}), i(a.x) {
82   // CHECK-NEXT: }
83   }
84 
85   // CHECK-NEXT: };
86 };
87 
88 
89 // CHECK: struct DefMethodsWithoutBody {
90 struct DefMethodsWithoutBody {
91   // CHECK-NEXT: DefMethodsWithoutBody() = delete;
92   DefMethodsWithoutBody() = delete;
93 
94   // CHECK-NEXT: DefMethodsWithoutBody() = default;
95   ~DefMethodsWithoutBody() = default;
96 
97   // CHECK-NEXT: void m1() __attribute__((alias("X")));
98   void m1() __attribute__((alias("X")));
99 
100   // CHECK-NEXT: };
101 };
102 
103 
104 // ---- Check that implict (non-written) constructor initializers are not output
105 
106 struct ImplicitCtorInit1 {
107   int a;
108 };
109 
110 // CHECK: struct ImplicitCtorInit2 : ImplicitCtorInit1 {
111 struct ImplicitCtorInit2 : ImplicitCtorInit1 {
112 
113   // CHECK-NEXT: ImplicitCtorInit2(int *) {
ImplicitCtorInit2ImplicitCtorInit2114   ImplicitCtorInit2(int *) {
115   // CHECK-NEXT: }
116   }
117 
118   // CHECK-NEXT: ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
ImplicitCtorInit2ImplicitCtorInit2119   ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
120   // CHECK-NEXT: }
121   }
122 
123   // CHECK-NEXT: };
124 };
125