CXXRecordDeclDefinitionBits.def 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. #ifndef FIELD
  31. #error define FIELD before including this file
  32. #endif
  33. /// True if this class has any user-declared constructors.
  34. FIELD(UserDeclaredConstructor, 1, NO_MERGE)
  35. /// The user-declared special members which this class has.
  36. FIELD(UserDeclaredSpecialMembers, 6, NO_MERGE)
  37. /// True when this class is an aggregate.
  38. FIELD(Aggregate, 1, NO_MERGE)
  39. /// True when this class is a POD-type.
  40. FIELD(PlainOldData, 1, NO_MERGE)
  41. /// True when this class is empty for traits purposes, that is:
  42. /// * has no data members other than 0-width bit-fields and empty fields
  43. /// marked [[no_unique_address]]
  44. /// * has no virtual function/base, and
  45. /// * doesn't inherit from a non-empty class.
  46. /// Doesn't take union-ness into account.
  47. FIELD(Empty, 1, NO_MERGE)
  48. /// True when this class is polymorphic, i.e., has at
  49. /// least one virtual member or derives from a polymorphic class.
  50. FIELD(Polymorphic, 1, NO_MERGE)
  51. /// True when this class is abstract, i.e., has at least
  52. /// one pure virtual function, (that can come from a base class).
  53. FIELD(Abstract, 1, NO_MERGE)
  54. /// True when this class is standard-layout, per the applicable
  55. /// language rules (including DRs).
  56. FIELD(IsStandardLayout, 1, NO_MERGE)
  57. /// True when this class was standard-layout under the C++11
  58. /// definition.
  59. ///
  60. /// C++11 [class]p7. A standard-layout class is a class that:
  61. /// * has no non-static data members of type non-standard-layout class (or
  62. /// array of such types) or reference,
  63. /// * has no virtual functions (10.3) and no virtual base classes (10.1),
  64. /// * has the same access control (Clause 11) for all non-static data
  65. /// members
  66. /// * has no non-standard-layout base classes,
  67. /// * either has no non-static data members in the most derived class and at
  68. /// most one base class with non-static data members, or has no base
  69. /// classes with non-static data members, and
  70. /// * has no base classes of the same type as the first non-static data
  71. /// member.
  72. FIELD(IsCXX11StandardLayout, 1, NO_MERGE)
  73. /// True when any base class has any declared non-static data
  74. /// members or bit-fields.
  75. /// This is a helper bit of state used to implement IsStandardLayout more
  76. /// efficiently.
  77. FIELD(HasBasesWithFields, 1, NO_MERGE)
  78. /// True when any base class has any declared non-static data
  79. /// members.
  80. /// This is a helper bit of state used to implement IsCXX11StandardLayout
  81. /// more efficiently.
  82. FIELD(HasBasesWithNonStaticDataMembers, 1, NO_MERGE)
  83. /// True when there are private non-static data members.
  84. FIELD(HasPrivateFields, 1, NO_MERGE)
  85. /// True when there are protected non-static data members.
  86. FIELD(HasProtectedFields, 1, NO_MERGE)
  87. /// True when there are private non-static data members.
  88. FIELD(HasPublicFields, 1, NO_MERGE)
  89. /// True if this class (or any subobject) has mutable fields.
  90. FIELD(HasMutableFields, 1, NO_MERGE)
  91. /// True if this class (or any nested anonymous struct or union)
  92. /// has variant members.
  93. FIELD(HasVariantMembers, 1, NO_MERGE)
  94. /// True if there no non-field members declared by the user.
  95. FIELD(HasOnlyCMembers, 1, NO_MERGE)
  96. /// True if there is an '__init' method defined by the user.
  97. FIELD(HasInitMethod, 1, NO_MERGE)
  98. /// True if any field has an in-class initializer, including those
  99. /// within anonymous unions or structs.
  100. FIELD(HasInClassInitializer, 1, NO_MERGE)
  101. /// True if any field is of reference type, and does not have an
  102. /// in-class initializer.
  103. ///
  104. /// In this case, value-initialization of this class is illegal in C++98
  105. /// even if the class has a trivial default constructor.
  106. FIELD(HasUninitializedReferenceMember, 1, NO_MERGE)
  107. /// True if any non-mutable field whose type doesn't have a user-
  108. /// provided default ctor also doesn't have an in-class initializer.
  109. FIELD(HasUninitializedFields, 1, NO_MERGE)
  110. /// True if there are any member using-declarations that inherit
  111. /// constructors from a base class.
  112. FIELD(HasInheritedConstructor, 1, NO_MERGE)
  113. /// True if there are any member using-declarations that inherit
  114. /// default constructors from a base class.
  115. FIELD(HasInheritedDefaultConstructor, 1, NO_MERGE)
  116. /// True if there are any member using-declarations named
  117. /// 'operator='.
  118. FIELD(HasInheritedAssignment, 1, NO_MERGE)
  119. /// These flags are \c true if a defaulted corresponding special
  120. /// member can't be fully analyzed without performing overload resolution.
  121. /// @{
  122. FIELD(NeedOverloadResolutionForCopyConstructor, 1, NO_MERGE)
  123. FIELD(NeedOverloadResolutionForMoveConstructor, 1, NO_MERGE)
  124. FIELD(NeedOverloadResolutionForCopyAssignment, 1, NO_MERGE)
  125. FIELD(NeedOverloadResolutionForMoveAssignment, 1, NO_MERGE)
  126. FIELD(NeedOverloadResolutionForDestructor, 1, NO_MERGE)
  127. /// @}
  128. /// These flags are \c true if an implicit defaulted corresponding
  129. /// special member would be defined as deleted.
  130. /// @{
  131. FIELD(DefaultedCopyConstructorIsDeleted, 1, NO_MERGE)
  132. FIELD(DefaultedMoveConstructorIsDeleted, 1, NO_MERGE)
  133. FIELD(DefaultedCopyAssignmentIsDeleted, 1, NO_MERGE)
  134. FIELD(DefaultedMoveAssignmentIsDeleted, 1, NO_MERGE)
  135. FIELD(DefaultedDestructorIsDeleted, 1, NO_MERGE)
  136. /// @}
  137. /// The trivial special members which this class has, per
  138. /// C++11 [class.ctor]p5, C++11 [class.copy]p12, C++11 [class.copy]p25,
  139. /// C++11 [class.dtor]p5, or would have if the member were not suppressed.
  140. ///
  141. /// This excludes any user-declared but not user-provided special members
  142. /// which have been declared but not yet defined.
  143. FIELD(HasTrivialSpecialMembers, 6, MERGE_OR)
  144. /// These bits keep track of the triviality of special functions for the
  145. /// purpose of calls. Only the bits corresponding to SMF_CopyConstructor,
  146. /// SMF_MoveConstructor, and SMF_Destructor are meaningful here.
  147. FIELD(HasTrivialSpecialMembersForCall, 6, MERGE_OR)
  148. /// The declared special members of this class which are known to be
  149. /// non-trivial.
  150. ///
  151. /// This excludes any user-declared but not user-provided special members
  152. /// which have been declared but not yet defined, and any implicit special
  153. /// members which have not yet been declared.
  154. FIELD(DeclaredNonTrivialSpecialMembers, 6, MERGE_OR)
  155. /// These bits keep track of the declared special members that are
  156. /// non-trivial for the purpose of calls.
  157. /// Only the bits corresponding to SMF_CopyConstructor,
  158. /// SMF_MoveConstructor, and SMF_Destructor are meaningful here.
  159. FIELD(DeclaredNonTrivialSpecialMembersForCall, 6, MERGE_OR)
  160. /// True when this class has a destructor with no semantic effect.
  161. FIELD(HasIrrelevantDestructor, 1, NO_MERGE)
  162. /// True when this class has at least one user-declared constexpr
  163. /// constructor which is neither the copy nor move constructor.
  164. FIELD(HasConstexprNonCopyMoveConstructor, 1, MERGE_OR)
  165. /// True if this class has a (possibly implicit) defaulted default
  166. /// constructor.
  167. FIELD(HasDefaultedDefaultConstructor, 1, MERGE_OR)
  168. /// True if a defaulted default constructor for this class would
  169. /// be constexpr.
  170. FIELD(DefaultedDefaultConstructorIsConstexpr, 1, NO_MERGE)
  171. /// True if this class has a constexpr default constructor.
  172. ///
  173. /// This is true for either a user-declared constexpr default constructor
  174. /// or an implicitly declared constexpr default constructor.
  175. FIELD(HasConstexprDefaultConstructor, 1, MERGE_OR)
  176. /// True if a defaulted destructor for this class would be constexpr.
  177. FIELD(DefaultedDestructorIsConstexpr, 1, NO_MERGE)
  178. /// True when this class contains at least one non-static data
  179. /// member or base class of non-literal or volatile type.
  180. FIELD(HasNonLiteralTypeFieldsOrBases, 1, NO_MERGE)
  181. /// True if this class is a structural type, assuming it is a literal type.
  182. FIELD(StructuralIfLiteral, 1, NO_MERGE)
  183. /// Whether we have a C++11 user-provided default constructor (not
  184. /// explicitly deleted or defaulted).
  185. FIELD(UserProvidedDefaultConstructor, 1, NO_MERGE)
  186. /// The special members which have been declared for this class,
  187. /// either by the user or implicitly.
  188. FIELD(DeclaredSpecialMembers, 6, MERGE_OR)
  189. /// Whether an implicit copy constructor could have a const-qualified
  190. /// parameter, for initializing virtual bases and for other subobjects.
  191. FIELD(ImplicitCopyConstructorCanHaveConstParamForVBase, 1, NO_MERGE)
  192. FIELD(ImplicitCopyConstructorCanHaveConstParamForNonVBase, 1, NO_MERGE)
  193. /// Whether an implicit copy assignment operator would have a
  194. /// const-qualified parameter.
  195. FIELD(ImplicitCopyAssignmentHasConstParam, 1, NO_MERGE)
  196. /// Whether any declared copy constructor has a const-qualified
  197. /// parameter.
  198. FIELD(HasDeclaredCopyConstructorWithConstParam, 1, MERGE_OR)
  199. /// Whether any declared copy assignment operator has either a
  200. /// const-qualified reference parameter or a non-reference parameter.
  201. FIELD(HasDeclaredCopyAssignmentWithConstParam, 1, MERGE_OR)
  202. /// Whether the destructor is no-return. Either explicitly, or if any
  203. /// base classes or fields have a no-return destructor
  204. FIELD(IsAnyDestructorNoReturn, 1, NO_MERGE)
  205. #undef FIELD