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 named
135/// 'operator='.
136FIELD(HasInheritedAssignment, 1, NO_MERGE)
137
138/// These flags are \c true if a defaulted corresponding special
139/// member can't be fully analyzed without performing overload resolution.
140/// @{
141FIELD(NeedOverloadResolutionForCopyConstructor, 1, NO_MERGE)
142FIELD(NeedOverloadResolutionForMoveConstructor, 1, NO_MERGE)
143FIELD(NeedOverloadResolutionForMoveAssignment, 1, NO_MERGE)
144FIELD(NeedOverloadResolutionForDestructor, 1, NO_MERGE)
145/// @}
146
147/// These flags are \c true if an implicit defaulted corresponding
148/// special member would be defined as deleted.
149/// @{
150FIELD(DefaultedCopyConstructorIsDeleted, 1, NO_MERGE)
151FIELD(DefaultedMoveConstructorIsDeleted, 1, NO_MERGE)
152FIELD(DefaultedMoveAssignmentIsDeleted, 1, NO_MERGE)
153FIELD(DefaultedDestructorIsDeleted, 1, NO_MERGE)
154/// @}
155
156/// The trivial special members which this class has, per
157/// C++11 [class.ctor]p5, C++11 [class.copy]p12, C++11 [class.copy]p25,
158/// C++11 [class.dtor]p5, or would have if the member were not suppressed.
159///
160/// This excludes any user-declared but not user-provided special members
161/// which have been declared but not yet defined.
162FIELD(HasTrivialSpecialMembers, 6, MERGE_OR)
163
164/// These bits keep track of the triviality of special functions for the
165/// purpose of calls. Only the bits corresponding to SMF_CopyConstructor,
166/// SMF_MoveConstructor, and SMF_Destructor are meaningful here.
167FIELD(HasTrivialSpecialMembersForCall, 6, MERGE_OR)
168
169/// The declared special members of this class which are known to be
170/// non-trivial.
171///
172/// This excludes any user-declared but not user-provided special members
173/// which have been declared but not yet defined, and any implicit special
174/// members which have not yet been declared.
175FIELD(DeclaredNonTrivialSpecialMembers, 6, MERGE_OR)
176
177/// These bits keep track of the declared special members that are
178/// non-trivial for the purpose of calls.
179/// Only the bits corresponding to SMF_CopyConstructor,
180/// SMF_MoveConstructor, and SMF_Destructor are meaningful here.
181FIELD(DeclaredNonTrivialSpecialMembersForCall, 6, MERGE_OR)
182
183/// True when this class has a destructor with no semantic effect.
184FIELD(HasIrrelevantDestructor, 1, NO_MERGE)
185
186/// True when this class has at least one user-declared constexpr
187/// constructor which is neither the copy nor move constructor.
188FIELD(HasConstexprNonCopyMoveConstructor, 1, MERGE_OR)
189
190/// True if this class has a (possibly implicit) defaulted default
191/// constructor.
192FIELD(HasDefaultedDefaultConstructor, 1, MERGE_OR)
193
194/// True if a defaulted default constructor for this class would
195/// be constexpr.
196FIELD(DefaultedDefaultConstructorIsConstexpr, 1, NO_MERGE)
197
198/// True if this class has a constexpr default constructor.
199///
200/// This is true for either a user-declared constexpr default constructor
201/// or an implicitly declared constexpr default constructor.
202FIELD(HasConstexprDefaultConstructor, 1, MERGE_OR)
203
204/// True if a defaulted destructor for this class would be constexpr.
205FIELD(DefaultedDestructorIsConstexpr, 1, NO_MERGE)
206
207/// True when this class contains at least one non-static data
208/// member or base class of non-literal or volatile type.
209FIELD(HasNonLiteralTypeFieldsOrBases, 1, NO_MERGE)
210
211/// Whether we have a C++11 user-provided default constructor (not
212/// explicitly deleted or defaulted).
213FIELD(UserProvidedDefaultConstructor, 1, NO_MERGE)
214
215/// The special members which have been declared for this class,
216/// either by the user or implicitly.
217FIELD(DeclaredSpecialMembers, 6, MERGE_OR)
218
219/// Whether an implicit copy constructor could have a const-qualified
220/// parameter, for initializing virtual bases and for other subobjects.
221FIELD(ImplicitCopyConstructorCanHaveConstParamForVBase, 1, NO_MERGE)
222FIELD(ImplicitCopyConstructorCanHaveConstParamForNonVBase, 1, NO_MERGE)
223
224/// Whether an implicit copy assignment operator would have a
225/// const-qualified parameter.
226FIELD(ImplicitCopyAssignmentHasConstParam, 1, NO_MERGE)
227
228/// Whether any declared copy constructor has a const-qualified
229/// parameter.
230FIELD(HasDeclaredCopyConstructorWithConstParam, 1, MERGE_OR)
231
232/// Whether any declared copy assignment operator has either a
233/// const-qualified reference parameter or a non-reference parameter.
234FIELD(HasDeclaredCopyAssignmentWithConstParam, 1, MERGE_OR)
235
236#undef FIELD
237