1 // Test without serialization:
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s \
3 // RUN: | FileCheck --strict-whitespace %s
5 // Test with serialization:
6 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t %s
7 // RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -include-pch %t -ast-dump-all /dev/null \
8 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
9 // RUN: | FileCheck --strict-whitespace %s
13 // CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:15> col:3 used constexpr R 'void () noexcept' default trivial
14 ~R() {} // not trivial
15 // CHECK: CXXDestructorDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9> col:3 used ~R 'void () noexcept'
17 // CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:22> col:3 R 'void (const R &)' delete trivial
19 // CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:18> col:3 constexpr R 'void (R &&)' default trivial noexcept-unevaluated
21 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-10]]:8> col:8 implicit operator= 'R &(const R &)' inline default_delete trivial noexcept-unevaluated
29 // CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:21> col:3 S 'void ()'
30 // CHECK-NEXT: CXXCtorInitializer Field 0x{{[^ ]*}} 'i' 'int'
31 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:11> 'int' 0
32 // CHECK-NEXT: CXXCtorInitializer Field 0x{{[^ ]*}} 'j' 'int'
33 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:17> 'int' 0
34 // CHECK-NEXT: CXXCtorInitializer Field 0x{{[^ ]*}} 'r' 'R'
35 // CHECK-NEXT: CXXConstructExpr 0x{{[^ ]*}} <col:3> 'R' 'void () noexcept'
36 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:20, col:21>
39 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:10> col:8 a 'void ()'
41 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> col:8 b 'void () const'
43 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> col:8 c 'void () volatile'
45 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> col:8 d 'void () &'
47 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> col:8 e 'void () &&'
48 virtual void f(float, int = 12);
49 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:33> col:16 f 'void (float, int)' virtual
50 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:18> col:23 'float'
51 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:25, col:31> col:29 'int' cinit
52 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:31> 'int' 12
55 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:22> col:16 g 'void ()' virtual pure
57 // CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-33]]:8> col:8 implicit S 'void (const S &)' inline default_delete noexcept-unevaluated
58 // CHECK: CXXConstructorDecl 0x{{[^ ]*}} <col:8> col:8 implicit constexpr S 'void (S &&)' inline default noexcept-unevaluated
59 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'S &(const S &)' inline default_delete noexcept-unevaluated
60 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'S &(S &&)' inline default_delete noexcept-unevaluated
61 // CHECK: CXXDestructorDecl 0x{{[^ ]*}} <col:8> col:8 implicit ~S 'void ()' inline default noexcept-unevaluated
64 struct T
: S
{ // T is not referenced, but S is
65 void f(float, int = 100) override
;
66 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:28> col:8 f 'void (float, int)'
67 // CHECK-NEXT: Overrides: [ 0x{{[^ ]*}} S::f 'void (float, int)' ]
68 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:10> col:15 'float'
69 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:17, col:23> col:21 'int' cinit
70 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:23> 'int' 100
71 // CHECK-NEXT: OverrideAttr
73 // CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-9]]:8> col:8 implicit T 'void (const T &)' inline default_delete noexcept-unevaluated
74 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'T &(const T &)' inline default_delete noexcept-unevaluated
75 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'T &(T &&)' inline default_delete noexcept-unevaluated
76 // CHECK: CXXDestructorDecl 0x{{[^ ]*}} <col:8> col:8 implicit ~T 'void ()' inline default noexcept-unevaluated
81 // CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:10> col:8 f 'void ()'
83 void U::f() {} // parent
84 // CHECK: CXXMethodDecl 0x{{[^ ]*}} parent 0x{{[^ ]*}} prev 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:14> col:9 f 'void ()'
85 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:13, col:14>
88 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:9> col:6 used a1 'void ()'
90 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:13> col:6 a2 'void ()'
92 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:20> col:6 b 'void (int, int)'
93 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:8, col:12> col:12 a 'int'
94 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:15, col:19> col:19 b 'int'
95 void c(int a
, int b
= 12);
96 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:25> col:6 c 'void (int, int)'
97 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:8, col:12> col:12 a 'int'
98 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:15, col:23> col:19 b 'int' cinit
99 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:23> 'int' 12
100 constexpr void d(void);
101 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:22> col:16 constexpr d 'void ()'
103 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:19> col:13 e 'void ()' static
105 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:19> col:13 f 'void ()' extern
106 extern "C" void g(void);
107 // CHECK: LinkageSpecDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:23> col:8 C
108 // CHECK: FunctionDecl 0x{{[^ ]*}} <col:12, col:23> col:17 g 'void ()'
110 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:19> col:13 h 'void ()' inline
111 void i(void) noexcept
;
112 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:14> col:6 i 'void () noexcept'
113 void j(void) noexcept(false);
114 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:28> col:6 j 'void () noexcept(false)'
115 void k(void) noexcept(1);
116 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:24> col:6 k 'void () noexcept(1)'
117 template <typename T
>
119 // CHECK: FunctionTemplateDecl 0x{{[^ ]*}} <line:[[@LINE-2]]:1, line:[[@LINE-1]]:7> col:3 l
120 // CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} <line:[[@LINE-3]]:11, col:20> col:20 referenced typename depth 0 index 0 T
121 // CHECK-NEXT: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-3]]:1, col:7> col:3 l 'T (T &)'
122 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:5, col:6> col:7 'T &'
125 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:14> col:6 m 'void (int)'
126 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:8> col:11 'int'
127 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:13, col:14>
130 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:19> col:6 n 'void (int, ...)'
131 // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}} <col:8> col:11 'int'
132 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:18, col:19>
135 // CHECK: FunctionDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+2]]:1> line:[[@LINE-1]]:5 main 'int ()'
136 a1(); // Causes this to be marked 'used'