1 // Test without serialization: 2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -ast-dump %s \ 3 // RUN: | FileCheck -strict-whitespace %s 4 // 5 // Test with serialization: 6 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -emit-pch -o %t %s 7 // RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -std=c++17 -include-pch %t -ast-dump-all /dev/null \ 8 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \ 9 // RUN: | FileCheck -strict-whitespace %s 10 11 void f() { 12 auto IsNotGenericLambda = [](){}; 13 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <col:29> col:29 implicit class definition 14 // CHECK-NOT: DefinitionData {{.*}}generic{{.*}} 15 // CHECK-NEXT: DefinitionData {{.*}}lambda{{.*}} 16 auto IsGenericLambda = [](auto){}; 17 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <col:26> col:26 implicit class definition 18 // CHECK-NEXT: DefinitionData {{.*}}generic{{.*}}lambda{{.*}} 19 } 20 21 struct CanPassInRegisters { 22 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct CanPassInRegisters definition 23 // CHECK-NEXT: DefinitionData {{.*}}pass_in_registers{{.*}} 24 CanPassInRegisters(const CanPassInRegisters&) = default; 25 }; 26 27 struct CantPassInRegisters { 28 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct CantPassInRegisters definition 29 // CHECK-NOT: DefinitionData {{.*}}pass_in_registers{{.*}} 30 CantPassInRegisters(const CantPassInRegisters&) = delete; 31 }; 32 33 struct IsEmpty { 34 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+2]]:1> line:[[@LINE-1]]:8 struct IsEmpty definition 35 // CHECK-NEXT: DefinitionData {{.*}}empty{{.*}} 36 }; 37 38 struct IsNotEmpty { 39 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsNotEmpty definition 40 // CHECK-NOT: DefinitionData {{.*}}empty{{.*}} 41 int a; 42 }; 43 44 struct IsAggregate { 45 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsAggregate definition 46 // CHECK-NEXT: DefinitionData {{.*}}aggregate{{.*}} 47 int a; 48 }; 49 50 struct IsNotAggregate { 51 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+4]]:1> line:[[@LINE-1]]:8 struct IsNotAggregate definition 52 // CHECK-NOT: DefinitionData {{.*}}aggregate{{.*}} 53 private: 54 int a; 55 }; 56 57 struct IsStandardLayout { 58 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsStandardLayout definition 59 // CHECK-NEXT: DefinitionData {{.*}}standard_layout{{.*}} 60 void f(); 61 }; 62 63 struct IsNotStandardLayout { 64 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsNotStandardLayout definition 65 // CHECK-NOT: DefinitionData {{.*}}standard_layout{{.*}} 66 virtual void f(); 67 }; 68 69 struct IsTriviallyCopyable { 70 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+2]]:1> line:[[@LINE-1]]:8 struct IsTriviallyCopyable definition 71 // CHECK-NEXT: DefinitionData {{.*}}trivially_copyable{{.*}} 72 }; 73 74 struct IsNotTriviallyCopyable { 75 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsNotTriviallyCopyable definition 76 // CHECK-NOT: DefinitionData {{.*}}trivially_copyable{{.*}} 77 IsNotTriviallyCopyable(const IsNotTriviallyCopyable&) {} 78 }; 79 80 struct IsPOD { 81 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsPOD definition 82 // CHECK-NEXT: DefinitionData {{.*}}pod{{.*}} 83 int a; 84 }; 85 86 struct IsNotPOD { 87 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsNotPOD definition 88 // CHECK-NOT: DefinitionData {{.*}}pod{{.*}} 89 int &a; 90 }; 91 92 struct IsTrivial { 93 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsTrivial definition 94 // CHECK-NEXT: DefinitionData {{.*}}trivial {{.*}} 95 IsTrivial() = default; 96 }; 97 98 struct IsNotTrivial { 99 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsNotTrivial definition 100 // CHECK-NOT: DefinitionData {{.*}}trivial {{.*}} 101 IsNotTrivial() {} 102 }; 103 104 struct IsPolymorphic { 105 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsPolymorphic definition 106 // CHECK-NEXT: DefinitionData {{.*}}polymorphic{{.*}} 107 virtual void f(); 108 }; 109 110 struct IsNotPolymorphic { 111 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsNotPolymorphic definition 112 // CHECK-NOT: DefinitionData {{.*}}polymorphic{{.*}} 113 void f(); 114 }; 115 116 struct IsAbstract { 117 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsAbstract definition 118 // CHECK-NEXT: DefinitionData {{.*}}abstract{{.*}} 119 virtual void f() = 0; 120 }; 121 122 struct IsNotAbstract { 123 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsNotAbstract definition 124 // CHECK-NOT: DefinitionData {{.*}}abstract{{.*}} 125 virtual void f(); 126 }; 127 128 struct IsLiteral { 129 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsLiteral definition 130 // CHECK-NEXT: DefinitionData {{.*}}literal{{.*}} 131 ~IsLiteral() = default; 132 }; 133 134 struct IsNotLiteral { 135 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct IsNotLiteral definition 136 // CHECK-NOT: DefinitionData {{.*}}literal{{.*}} 137 ~IsNotLiteral() {} 138 }; 139 140 struct HasUserDeclaredConstructor { 141 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct HasUserDeclaredConstructor definition 142 // CHECK-NEXT: DefinitionData {{.*}}has_user_declared_ctor{{.*}} 143 HasUserDeclaredConstructor() {} 144 }; 145 146 struct HasNoUserDeclaredConstructor { 147 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+2]]:1> line:[[@LINE-1]]:8 struct HasNoUserDeclaredConstructor definition 148 // CHECK-NOT: DefinitionData {{.*}}has_user_declared_ctor{{.*}} 149 }; 150 151 struct HasConstexprNonCopyMoveConstructor { 152 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct HasConstexprNonCopyMoveConstructor definition 153 // CHECK-NEXT: DefinitionData {{.*}}has_constexpr_non_copy_move_ctor{{.*}} 154 constexpr HasConstexprNonCopyMoveConstructor() {} 155 }; 156 157 struct HasNoConstexprNonCopyMoveConstructor { 158 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct HasNoConstexprNonCopyMoveConstructor definition 159 // CHECK-NOT: DefinitionData {{.*}}has_constexpr_non_copy_move_ctor{{.*}} 160 HasNoConstexprNonCopyMoveConstructor() {} 161 }; 162 163 struct HasMutableFields { 164 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct HasMutableFields definition 165 // CHECK-NEXT: DefinitionData {{.*}}has_mutable_fields{{.*}} 166 mutable int i; 167 }; 168 169 struct HasNoMutableFields { 170 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct HasNoMutableFields definition 171 // CHECK-NOT: DefinitionData {{.*}}has_mutable_fields{{.*}} 172 int i; 173 }; 174 175 struct HasVariantMembers { 176 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+5]]:1> line:[[@LINE-1]]:8 struct HasVariantMembers definition 177 // CHECK-NEXT: DefinitionData {{.*}}has_variant_members{{.*}} 178 union { 179 int i; 180 }; 181 }; 182 183 struct HasNoVariantMembers { 184 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+2]]:1> line:[[@LINE-1]]:8 struct HasNoVariantMembers definition 185 // CHECK-NOT: DefinitionData {{.*}}has_variant_members{{.*}} 186 }; 187 188 struct AllowsConstDefaultInit { 189 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct AllowsConstDefaultInit definition 190 // CHECK-NEXT: DefinitionData {{.*}}can_const_default_init{{.*}} 191 int i = 12; 192 }; 193 194 struct DoesNotAllowConstDefaultInit { 195 // CHECK: CXXRecordDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:1, line:[[@LINE+3]]:1> line:[[@LINE-1]]:8 struct DoesNotAllowConstDefaultInit definition 196 // CHECK-NOT: DefinitionData {{.*}}can_const_default_init{{.*}} 197 int i; 198 }; 199