1//===-- CXXRecordDeclDefinitionBits.def - Class definition bits -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file enumerates the various bitfields that we want to store on C++ class
10// definitions.
11//
12//===----------------------------------------------------------------------===//
13//
14/// @file CXXRecordDeclDefinitionBits.def
15///
16/// In this file, each of the bitfields representing data about a C++ class
17/// results in an expansion of the FIELD macro, which should be defined before
18/// including this file.
19///
20/// The macro have three operands:
21///
22/// Name: The name of the field, as a member of CXXRecordDecl::DefinitionData.
23///
24/// BitWidth: The width of the field in bits.
25///
26/// MergePolicy: How to behave when the value of the field is different in
27/// multiple translation units, one of:
28///   NO_MERGE: It is an ODR violation if the fields do not match.
29///   MERGE_OR: Merge the fields by ORing them together.
30
31#ifndef FIELD
32#error define FIELD before including this file
33#endif
34
35/// True if this class has any user-declared constructors.
36FIELD(UserDeclaredConstructor, 1, NO_MERGE)
37
38/// The user-declared special members which this class has.
39FIELD(UserDeclaredSpecialMembers, 6, NO_MERGE)
40
41/// True when this class is an aggregate.
42FIELD(Aggregate, 1, NO_MERGE)
43
44/// True when this class is a POD-type.
45FIELD(PlainOldData, 1, NO_MERGE)
46
47/// True when this class is empty for traits purposes, that is:
48///  * has no data members other than 0-width bit-fields and empty fields
49///    marked [[no_unique_address]]
50///  * has no virtual function/base, and
51///  * doesn't inherit from a non-empty class.
52/// Doesn't take union-ness into account.
53FIELD(Empty, 1, NO_MERGE)
54
55/// True when this class is polymorphic, i.e., has at
56/// least one virtual member or derives from a polymorphic class.
57FIELD(Polymorphic, 1, NO_MERGE)
58
59/// True when this class is abstract, i.e., has at least
60/// one pure virtual function, (that can come from a base class).
61FIELD(Abstract, 1, NO_MERGE)
62
63/// True when this class is standard-layout, per the applicable
64/// language rules (including DRs).
65FIELD(IsStandardLayout, 1, NO_MERGE)
66
67/// True when this class was standard-layout under the C++11
68/// definition.
69///
70/// C++11 [class]p7.  A standard-layout class is a class that:
71/// * has no non-static data members of type non-standard-layout class (or
72///   array of such types) or reference,
73/// * has no virtual functions (10.3) and no virtual base classes (10.1),
74/// * has the same access control (Clause 11) for all non-static data
75///   members
76/// * has no non-standard-layout base classes,
77/// * either has no non-static data members in the most derived class and at
78///   most one base class with non-static data members, or has no base
79///   classes with non-static data members, and
80/// * has no base classes of the same type as the first non-static data
81///   member.
82FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
83
84/// True when any base class has any declared non-static data
85/// members or bit-fields.
86/// This is a helper bit of state used to implement IsStandardLayout more
87/// efficiently.
88FIELD(HasBasesWithFields, 1, NO_MERGE)
89
90/// True when any base class has any declared non-static data
91/// members.
92/// This is a helper bit of state used to implement IsCXX11StandardLayout
93/// more efficiently.
94FIELD(HasBasesWithNonStaticDataMembers, 1, NO_MERGE)
95
96/// True when there are private non-static data members.
97FIELD(HasPrivateFields, 1, NO_MERGE)
98
99/// True when there are protected non-static data members.
100FIELD(HasProtectedFields, 1, NO_MERGE)
101
102/// True when there are private non-static data members.
103FIELD(HasPublicFields, 1, NO_MERGE)
104
105/// True if this class (or any subobject) has mutable fields.
106FIELD(HasMutableFields, 1, NO_MERGE)
107
108/// True if this class (or any nested anonymous struct or union)
109/// has variant members.
110FIELD(HasVariantMembers, 1, NO_MERGE)
111
112/// True if there no non-field members declared by the user.
113FIELD(HasOnlyCMembers, 1, NO_MERGE)
114
115/// True if any field has an in-class initializer, including those
116/// within anonymous unions or structs.
117FIELD(HasInClassInitializer, 1, NO_MERGE)
118
119/// True if any field is of reference type, and does not have an
120/// in-class initializer.
121///
122/// In this case, value-initialization of this class is illegal in C++98
123/// even if the class has a trivial default constructor.
124FIELD(HasUninitializedReferenceMember, 1, NO_MERGE)
125
126/// True if any non-mutable field whose type doesn't have a user-
127/// provided default ctor also doesn't have an in-class initializer.
128FIELD(HasUninitializedFields, 1, NO_MERGE)
129
130/// True if there are any member using-declarations that inherit
131/// constructors from a base class.
132FIELD(HasInheritedConstructor, 1, NO_MERGE)
133
134/// True if there are any member using-declarations that inherit
135/// default constructors from a base class.
136FIELD(HasInheritedDefaultConstructor, 1, NO_MERGE)
137
138/// True if there are any member using-declarations named
139/// 'operator='.
140FIELD(HasInheritedAssignment, 1, NO_MERGE)
141
142/// These flags are \c true if a defaulted corresponding special
143/// member can't be fully analyzed without performing overload resolution.
144/// @{
145FIELD(NeedOverloadResolutionForCopyConstructor, 1, NO_MERGE)
146FIELD(NeedOverloadResolutionForMoveConstructor, 1, NO_MERGE)
147FIELD(NeedOverloadResolutionForCopyAssignment, 1, NO_MERGE)
148FIELD(NeedOverloadResolutionForMoveAssignment, 1, NO_MERGE)
149FIELD(NeedOverloadResolutionForDestructor, 1, NO_MERGE)
150/// @}
151
152/// These flags are \c true if an implicit defaulted corresponding
153/// special member would be defined as deleted.
154/// @{
155FIELD(DefaultedCopyConstructorIsDeleted, 1, NO_MERGE)
156FIELD(DefaultedMoveConstructorIsDeleted, 1, NO_MERGE)
157FIELD(DefaultedCopyAssignmentIsDeleted, 1, NO_MERGE)
158FIELD(DefaultedMoveAssignmentIsDeleted, 1, NO_MERGE)
159FIELD(DefaultedDestructorIsDeleted, 1, NO_MERGE)
160/// @}
161
162/// The trivial special members which this class has, per
163/// C++11 [class.ctor]p5, C++11 [class.copy]p12, C++11 [class.copy]p25,
164/// C++11 [class.dtor]p5, or would have if the member were not suppressed.
165///
166/// This excludes any user-declared but not user-provided special members
167/// which have been declared but not yet defined.
168FIELD(HasTrivialSpecialMembers, 6, MERGE_OR)
169
170/// These bits keep track of the triviality of special functions for the
171/// purpose of calls. Only the bits corresponding to SMF_CopyConstructor,
172/// SMF_MoveConstructor, and SMF_Destructor are meaningful here.
173FIELD(HasTrivialSpecialMembersForCall, 6, MERGE_OR)
174
175/// The declared special members of this class which are known to be
176/// non-trivial.
177///
178/// This excludes any user-declared but not user-provided special members
179/// which have been declared but not yet defined, and any implicit special
180/// members which have not yet been declared.
181FIELD(DeclaredNonTrivialSpecialMembers, 6, MERGE_OR)
182
183/// These bits keep track of the declared special members that are
184/// non-trivial for the purpose of calls.
185/// Only the bits corresponding to SMF_CopyConstructor,
186/// SMF_MoveConstructor, and SMF_Destructor are meaningful here.
187FIELD(DeclaredNonTrivialSpecialMembersForCall, 6, MERGE_OR)
188
189/// True when this class has a destructor with no semantic effect.
190FIELD(HasIrrelevantDestructor, 1, NO_MERGE)
191
192/// True when this class has at least one user-declared constexpr
193/// constructor which is neither the copy nor move constructor.
194FIELD(HasConstexprNonCopyMoveConstructor, 1, MERGE_OR)
195
196/// True if this class has a (possibly implicit) defaulted default
197/// constructor.
198FIELD(HasDefaultedDefaultConstructor, 1, MERGE_OR)
199
200/// True if a defaulted default constructor for this class would
201/// be constexpr.
202FIELD(DefaultedDefaultConstructorIsConstexpr, 1, NO_MERGE)
203
204/// True if this class has a constexpr default constructor.
205///
206/// This is true for either a user-declared constexpr default constructor
207/// or an implicitly declared constexpr default constructor.
208FIELD(HasConstexprDefaultConstructor, 1, MERGE_OR)
209
210/// True if a defaulted destructor for this class would be constexpr.
211FIELD(DefaultedDestructorIsConstexpr, 1, NO_MERGE)
212
213/// True when this class contains at least one non-static data
214/// member or base class of non-literal or volatile type.
215FIELD(HasNonLiteralTypeFieldsOrBases, 1, NO_MERGE)
216
217/// True if this class is a structural type, assuming it is a literal type.
218FIELD(StructuralIfLiteral, 1, NO_MERGE)
219
220/// Whether we have a C++11 user-provided default constructor (not
221/// explicitly deleted or defaulted).
222FIELD(UserProvidedDefaultConstructor, 1, NO_MERGE)
223
224/// The special members which have been declared for this class,
225/// either by the user or implicitly.
226FIELD(DeclaredSpecialMembers, 6, MERGE_OR)
227
228/// Whether an implicit copy constructor could have a const-qualified
229/// parameter, for initializing virtual bases and for other subobjects.
230FIELD(ImplicitCopyConstructorCanHaveConstParamForVBase, 1, NO_MERGE)
231FIELD(ImplicitCopyConstructorCanHaveConstParamForNonVBase, 1, NO_MERGE)
232
233/// Whether an implicit copy assignment operator would have a
234/// const-qualified parameter.
235FIELD(ImplicitCopyAssignmentHasConstParam, 1, NO_MERGE)
236
237/// Whether any declared copy constructor has a const-qualified
238/// parameter.
239FIELD(HasDeclaredCopyConstructorWithConstParam, 1, MERGE_OR)
240
241/// Whether any declared copy assignment operator has either a
242/// const-qualified reference parameter or a non-reference parameter.
243FIELD(HasDeclaredCopyAssignmentWithConstParam, 1, MERGE_OR)
244
245/// Whether the destructor is no-return. Either explicitly, or if any
246/// base classes or fields have a no-return destructor
247FIELD(IsAnyDestructorNoReturn, 1, NO_MERGE)
248
249#undef FIELD
250