Go to the documentation of this file.
15 #ifndef LLVM_CLANG_AST_DECLCXX_H
16 #define LLVM_CLANG_AST_DECLCXX_H
37 #include "llvm/ADT/ArrayRef.h"
38 #include "llvm/ADT/DenseMap.h"
39 #include "llvm/ADT/PointerIntPair.h"
40 #include "llvm/ADT/PointerUnion.h"
41 #include "llvm/ADT/STLExtras.h"
42 #include "llvm/ADT/TinyPtrVector.h"
43 #include "llvm/ADT/iterator_range.h"
44 #include "llvm/Support/Casting.h"
45 #include "llvm/Support/Compiler.h"
46 #include "llvm/Support/PointerLikeTypeTraits.h"
47 #include "llvm/Support/TrailingObjects.h"
57 class ClassTemplateDecl;
58 class ConstructorUsingShadowDecl;
61 class CXXConstructorDecl;
62 class CXXDestructorDecl;
63 class CXXFinalOverriderMap;
64 class CXXIndirectPrimaryBaseSet;
66 class DecompositionDecl;
68 class FunctionTemplateDecl;
70 class MemberSpecializationInfo;
73 class TemplateParameterList;
92 :
Decl(AccessSpec, DC, ASLoc), ColonLoc(ColonLoc) {
98 virtual void anchor();
157 unsigned Virtual : 1;
163 unsigned BaseOfClass : 1;
173 unsigned InheritConstructors : 1;
185 : Range(R), EllipsisLoc(EllipsisLoc), Virtual(
V), BaseOfClass(BC),
186 Access(A), InheritConstructors(
false), BaseTypeInfo(TInfo) {}
213 InheritConstructors = Inherit;
268 enum SpecialMemberFlags {
269 SMF_DefaultConstructor = 0x1,
270 SMF_CopyConstructor = 0x2,
271 SMF_MoveConstructor = 0x4,
272 SMF_CopyAssignment = 0x8,
273 SMF_MoveAssignment = 0x10,
274 SMF_Destructor = 0x20,
286 struct DefinitionData {
287 #define FIELD(Name, Width, Merge) \
288 unsigned Name : Width;
289 #include "CXXRecordDeclDefinitionBits.def"
292 unsigned IsLambda : 1;
295 unsigned IsParsingBaseSpecifiers : 1;
299 unsigned ComputedVisibleConversions : 1;
301 unsigned HasODRHash : 1;
304 unsigned ODRHash = 0;
307 unsigned NumBases = 0;
310 unsigned NumVBases = 0;
324 LazyASTUnresolvedSet Conversions;
331 LazyASTUnresolvedSet VisibleConversions;
345 CXXBaseSpecifier *getBases()
const {
346 if (!Bases.isOffset())
347 return Bases.get(
nullptr);
348 return getBasesSlowCase();
352 CXXBaseSpecifier *getVBases()
const {
353 if (!VBases.isOffset())
354 return VBases.get(
nullptr);
355 return getVBasesSlowCase();
358 ArrayRef<CXXBaseSpecifier>
bases()
const {
359 return llvm::makeArrayRef(getBases(), NumBases);
362 ArrayRef<CXXBaseSpecifier>
vbases()
const {
363 return llvm::makeArrayRef(getVBases(), NumVBases);
367 CXXBaseSpecifier *getBasesSlowCase()
const;
368 CXXBaseSpecifier *getVBasesSlowCase()
const;
371 struct DefinitionData *DefinitionData;
374 struct LambdaDefinitionData :
public DefinitionData {
375 using Capture = LambdaCapture;
385 unsigned DependencyKind : 2;
388 unsigned IsGenericLambda : 1;
391 unsigned CaptureDefault : 2;
394 unsigned NumCaptures : 15;
397 unsigned NumExplicitCaptures : 13;
400 unsigned HasKnownInternalLinkage : 1;
404 unsigned ManglingNumber : 31;
414 Capture *Captures =
nullptr;
417 TypeSourceInfo *MethodTyInfo;
419 LambdaDefinitionData(
CXXRecordDecl *D, TypeSourceInfo *Info,
unsigned DK,
421 : DefinitionData(D), DependencyKind(DK), IsGenericLambda(IsGeneric),
422 CaptureDefault(CaptureDefault), NumCaptures(0),
423 NumExplicitCaptures(0), HasKnownInternalLinkage(0), ManglingNumber(0),
430 PlainOldData =
false;
434 struct DefinitionData *dataPtr()
const {
437 return DefinitionData;
440 struct DefinitionData &data()
const {
441 auto *DD = dataPtr();
442 assert(DD &&
"queried property of class with no definition");
446 struct LambdaDefinitionData &getLambdaData()
const {
449 auto *DD = DefinitionData;
450 assert(DD && DD->IsLambda &&
"queried lambda property of non-lambda class");
451 return static_cast<LambdaDefinitionData&
>(*DD);
463 llvm::PointerUnion<ClassTemplateDecl *, MemberSpecializationInfo *>
464 TemplateOrInstantiation;
475 void addedMember(
Decl *D);
477 void markedVirtualFunctionPure();
481 FriendDecl *getFirstFriend()
const;
486 bool hasSubobjectAtOffsetZeroOfEmptyBaseType(
ASTContext &Ctx,
491 SourceLocation StartLoc, SourceLocation IdLoc,
510 return cast_or_null<CXXRecordDecl>(
519 return cast<CXXRecordDecl>(
545 auto *DD = DefinitionData ? DefinitionData : dataPtr();
546 return DD ? DD->Definition :
nullptr;
555 bool DelayTypeCreation =
false);
558 unsigned DependencyKind,
bool IsGeneric,
563 return data().Polymorphic || data().NumVBases != 0;
581 return data().IsParsingBaseSpecifiers;
594 llvm::iterator_range<base_class_const_iterator>;
636 llvm::iterator_range<specific_decl_iterator<CXXMethodDecl>>;
656 llvm::iterator_range<specific_decl_iterator<CXXConstructorDecl>>;
670 class friend_iterator;
680 return data().FirstFriend.isValid();
687 (data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
688 "this property has not yet been computed by Sema");
689 return data().DefaultedCopyConstructorIsDeleted;
696 (data().DeclaredSpecialMembers & SMF_MoveConstructor)) &&
697 "this property has not yet been computed by Sema");
698 return data().DefaultedMoveConstructorIsDeleted;
704 (data().DeclaredSpecialMembers & SMF_Destructor)) &&
705 "this property has not yet been computed by Sema");
706 return data().DefaultedDestructorIsDeleted;
713 !data().DefaultedCopyConstructorIsDeleted;
720 !data().DefaultedMoveConstructorIsDeleted;
727 !data().DefaultedCopyAssignmentIsDeleted;
734 !data().DefaultedMoveAssignmentIsDeleted;
741 !data().DefaultedDestructorIsDeleted;
746 return (data().DeclaredSpecialMembers & SMF_DefaultConstructor) ||
755 return (!data().UserDeclaredConstructor &&
756 !(data().DeclaredSpecialMembers & SMF_DefaultConstructor) &&
761 (data().HasInheritedDefaultConstructor &&
762 !(data().DeclaredSpecialMembers & SMF_DefaultConstructor));
769 return data().UserDeclaredConstructor;
775 return data().UserProvidedDefaultConstructor;
782 return data().UserDeclaredSpecialMembers & SMF_CopyConstructor;
788 return !(data().DeclaredSpecialMembers & SMF_CopyConstructor);
800 if (data().UserDeclaredSpecialMembers &
801 (SMF_MoveConstructor | SMF_MoveAssignment))
803 return data().NeedOverloadResolutionForCopyConstructor;
809 return data().ImplicitCopyConstructorCanHaveConstParamForNonVBase &&
811 data().ImplicitCopyConstructorCanHaveConstParamForVBase);
817 return data().HasDeclaredCopyConstructorWithConstParam ||
828 return data().UserDeclaredSpecialMembers &
829 (SMF_MoveConstructor | SMF_MoveAssignment);
835 return data().UserDeclaredSpecialMembers & SMF_MoveConstructor;
840 return (data().DeclaredSpecialMembers & SMF_MoveConstructor) ||
847 assert((data().DefaultedCopyConstructorIsDeleted ||
849 "Copy constructor should not be deleted");
850 data().DefaultedCopyConstructorIsDeleted =
true;
856 assert((data().DefaultedMoveConstructorIsDeleted ||
858 "move constructor should not be deleted");
859 data().DefaultedMoveConstructorIsDeleted =
true;
865 assert((data().DefaultedDestructorIsDeleted ||
867 "destructor should not be deleted");
868 data().DefaultedDestructorIsDeleted =
true;
874 return !(data().DeclaredSpecialMembers & SMF_MoveConstructor) &&
884 return data().NeedOverloadResolutionForMoveConstructor;
892 return data().UserDeclaredSpecialMembers & SMF_CopyAssignment;
898 assert((data().DefaultedCopyAssignmentIsDeleted ||
900 "copy assignment should not be deleted");
901 data().DefaultedCopyAssignmentIsDeleted =
true;
907 return !(data().DeclaredSpecialMembers & SMF_CopyAssignment);
919 if (data().UserDeclaredSpecialMembers &
920 (SMF_MoveConstructor | SMF_MoveAssignment))
922 return data().NeedOverloadResolutionForCopyAssignment;
928 return data().ImplicitCopyAssignmentHasConstParam;
935 return data().HasDeclaredCopyAssignmentWithConstParam ||
943 return data().UserDeclaredSpecialMembers & SMF_MoveAssignment;
948 return (data().DeclaredSpecialMembers & SMF_MoveAssignment) ||
955 assert((data().DefaultedMoveAssignmentIsDeleted ||
957 "move assignment should not be deleted");
958 data().DefaultedMoveAssignmentIsDeleted =
true;
965 return !(data().DeclaredSpecialMembers & SMF_MoveAssignment) &&
976 return data().NeedOverloadResolutionForMoveAssignment;
983 return data().UserDeclaredSpecialMembers & SMF_Destructor;
989 return !(data().DeclaredSpecialMembers & SMF_Destructor);
995 return data().NeedOverloadResolutionForDestructor;
1001 auto *DD = DefinitionData;
1002 return DD && DD->IsLambda;
1060 void getCaptureFields(llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures,
1071 return isLambda() ? getLambdaData().Captures :
nullptr;
1098 llvm::iterator_range<conversion_iterator>
1122 data().HasUninitializedReferenceMember;
1133 bool isPOD()
const {
return data().PlainOldData; }
1154 return data().HasPrivateFields;
1158 return data().HasProtectedFields;
1164 return D.HasPublicFields || D.HasProtectedFields || D.HasPrivateFields;
1197 (data().HasTrivialSpecialMembers & SMF_DefaultConstructor);
1203 return (data().DeclaredNonTrivialSpecialMembers & SMF_DefaultConstructor) ||
1205 !(data().HasTrivialSpecialMembers & SMF_DefaultConstructor));
1211 return data().HasConstexprNonCopyMoveConstructor ||
1219 return data().DefaultedDefaultConstructorIsConstexpr &&
1226 return data().HasConstexprDefaultConstructor ||
1234 return data().HasTrivialSpecialMembers & SMF_CopyConstructor;
1238 return data().HasTrivialSpecialMembersForCall & SMF_CopyConstructor;
1244 return data().DeclaredNonTrivialSpecialMembers & SMF_CopyConstructor ||
1249 return (data().DeclaredNonTrivialSpecialMembersForCall &
1250 SMF_CopyConstructor) ||
1258 (data().HasTrivialSpecialMembers & SMF_MoveConstructor);
1263 (data().HasTrivialSpecialMembersForCall & SMF_MoveConstructor);
1269 return (data().DeclaredNonTrivialSpecialMembers & SMF_MoveConstructor) ||
1271 !(data().HasTrivialSpecialMembers & SMF_MoveConstructor));
1275 return (data().DeclaredNonTrivialSpecialMembersForCall &
1276 SMF_MoveConstructor) ||
1278 !(data().HasTrivialSpecialMembersForCall & SMF_MoveConstructor));
1284 return data().HasTrivialSpecialMembers & SMF_CopyAssignment;
1290 return data().DeclaredNonTrivialSpecialMembers & SMF_CopyAssignment ||
1298 (data().HasTrivialSpecialMembers & SMF_MoveAssignment);
1304 return (data().DeclaredNonTrivialSpecialMembers & SMF_MoveAssignment) ||
1306 !(data().HasTrivialSpecialMembers & SMF_MoveAssignment));
1312 return data().DefaultedDestructorIsConstexpr &&
1322 return data().HasTrivialSpecialMembers & SMF_Destructor;
1326 return data().HasTrivialSpecialMembersForCall & SMF_Destructor;
1332 return !(data().HasTrivialSpecialMembers & SMF_Destructor);
1336 return !(data().HasTrivialSpecialMembersForCall & SMF_Destructor);
1340 data().HasTrivialSpecialMembersForCall =
1341 (SMF_CopyConstructor | SMF_MoveConstructor | SMF_Destructor);
1347 return !data().HasUninitializedFields ||
1348 !(data().HasDefaultedDefaultConstructor ||
1358 return data().HasIrrelevantDestructor;
1364 return data().HasNonLiteralTypeFieldsOrBases;
1370 return data().HasInheritedConstructor;
1376 return data().HasInheritedAssignment;
1413 (!
isLambda() || LangOpts.CPlusPlus17) &&
1422 return isLiteral() && data().StructuralIfLiteral;
1512 return RD->isLocalClass();
1629 bool LookupInDependent =
false)
const;
1674 std::vector<const NamedDecl *>
1687 assert(DeclAccess !=
AS_none);
1689 return (PathAccess > DeclAccess ? PathAccess : DeclAccess);
1730 assert(
isLambda() &&
"Not a lambda closure type!");
1731 return getLambdaData().ManglingNumber;
1737 assert(
isLambda() &&
"Not a lambda closure type!");
1738 return getLambdaData().HasKnownInternalLinkage;
1755 bool HasKnownInternalLinkage =
false) {
1756 assert(
isLambda() &&
"Not a lambda closure type!");
1757 getLambdaData().ManglingNumber = ManglingNumber;
1758 getLambdaData().ContextDecl = ContextDecl;
1759 getLambdaData().HasKnownInternalLinkage = HasKnownInternalLinkage;
1808 return getLambdaData().DependencyKind;
1812 return getLambdaData().MethodTyInfo;
1821 return K >= firstCXXRecord && K <= lastCXXRecord;
1829 llvm::PointerIntPair<Expr *, 2, ExplicitSpecKind> ExplicitSpec{
1843 ExplicitSpec.getPointer();
1859 !ExplicitSpec.getPointer();
1884 void anchor()
override;
1892 :
FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
1894 Ctor(Ctor), ExplicitSpec(ES) {
1961 :
Decl(RequiresExprBody, DC, StartLoc),
DeclContext(RequiresExprBody) {}
1982 void anchor()
override;
1990 Expr *TrailingRequiresClause =
nullptr)
1992 isInline, ConstexprKind, TrailingRequiresClause) {
2003 Expr *TrailingRequiresClause =
nullptr);
2018 return OOK == OO_New || OOK == OO_Array_New || OOK == OO_Delete ||
2019 OOK == OO_Array_Delete;
2044 bool IsAppleKext)
const {
2074 return cast<CXXMethodDecl>(
2090 llvm::TinyPtrVector<const CXXMethodDecl *>::const_iterator>;
2163 bool MayBeBase =
false);
2167 bool MayBeBase =
false)
const {
2175 bool MayBeBase =
false);
2178 bool MayBeBase =
false)
const {
2186 return K >= firstCXXMethod && K <= lastCXXMethod;
2209 llvm::PointerUnion<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *>
2232 unsigned IsDelegating : 1;
2236 unsigned IsVirtual : 1;
2240 unsigned IsWritten : 1;
2244 unsigned SourceOrder : 13;
2297 return Init->getStmtClass() == Stmt::CXXDefaultInitExprClass;
2315 return MemberOrEllipsisLocation;
2363 return MemberOrEllipsisLocation;
2379 return IsWritten ?
static_cast<int>(SourceOrder) : -1;
2390 assert(!IsWritten &&
2391 "setSourceOrder() used on implicit initializer");
2392 assert(SourceOrder == 0 &&
2393 "calling twice setSourceOrder() on the same initializer");
2395 "setSourceOrder() used to make an initializer implicit");
2397 SourceOrder =
static_cast<unsigned>(Pos);
2416 : Shadow(Shadow), BaseCtor(BaseCtor) {}
2418 explicit operator bool()
const {
return Shadow; }
2436 private llvm::TrailingObjects<CXXConstructorDecl, InheritedConstructor,
2437 ExplicitSpecifier> {
2452 Expr *TrailingRequiresClause);
2454 void anchor()
override;
2456 size_t numTrailingObjects(OverloadToken<InheritedConstructor>)
const {
2459 size_t numTrailingObjects(OverloadToken<ExplicitSpecifier>)
const {
2465 return *getTrailingObjects<ExplicitSpecifier>();
2472 enum TrailingAllocKind {
2473 TAKInheritsConstructor = 1,
2474 TAKHasTailExplicit = 1 << 1,
2477 uint64_t getTrailingAllocKind()
const {
2478 return numTrailingObjects(OverloadToken<InheritedConstructor>()) |
2479 (numTrailingObjects(OverloadToken<ExplicitSpecifier>()) << 1);
2495 Expr *TrailingRequiresClause =
nullptr);
2500 "cannot set this explicit specifier. no trail-allocated space for "
2534 const auto *ConstThis =
this;
2553 std::reverse_iterator<init_const_iterator>;
2581 numCtorInitializers &&
"NumCtorInitializers overflow!");
2585 CtorInitializers = Initializers;
2621 unsigned TypeQuals = 0;
2635 unsigned TypeQuals = 0;
2708 Expr *OperatorDeleteThisArg =
nullptr;
2714 Expr *TrailingRequiresClause =
nullptr)
2715 :
CXXMethodDecl(CXXDestructor,
C, RD, StartLoc, NameInfo, T, TInfo,
2721 void anchor()
override;
2727 bool UsesFPIntrin,
bool isInline,
bool isImplicitlyDeclared,
2729 Expr *TrailingRequiresClause =
nullptr);
2770 Expr *TrailingRequiresClause =
nullptr)
2771 :
CXXMethodDecl(CXXConversion, C, RD, StartLoc, NameInfo, T, TInfo,
2773 EndLocation, TrailingRequiresClause),
2775 void anchor()
override;
2788 Expr *TrailingRequiresClause =
nullptr);
2831 virtual void anchor();
2938 :
NamedDecl(UsingDirective, DC, IdentLoc, getName()), UsingLoc(UsingLoc),
2939 NamespaceLoc(NamespcLoc), QualifierLoc(QualifierLoc),
2940 NominatedNamespace(Nominated), CommonAncestor(CommonAncestor) {}
2950 void anchor()
override;
2970 return NominatedNamespace;
3043 NamespaceLoc(NamespaceLoc), IdentLoc(IdentLoc),
3044 QualifierLoc(QualifierLoc), Namespace(Namespace) {}
3046 void anchor()
override;
3093 if (
auto *AD = dyn_cast<NamespaceAliasDecl>(Namespace))
3094 return AD->getNamespace();
3096 return cast<NamespaceDecl>(Namespace);
3129 public Mergeable<LifetimeExtendedTemporaryDecl> {
3133 Stmt *ExprWithTemporary =
nullptr;
3138 unsigned ManglingNumber;
3142 virtual void anchor();
3147 ExprWithTemporary(Temp), ExtendingDecl(EDecl),
3148 ManglingNumber(Mangling) {}
3151 :
Decl(
Decl::LifetimeExtendedTemporary, EmptyShell{}) {}
3155 unsigned Mangling) {
3197 return K == Decl::LifetimeExtendedTemporary;
3230 void anchor()
override;
3289 assert(ND &&
"Target decl is null!");
3305 return dyn_cast_or_null<UsingShadowDecl>(UsingOrNextShadow);
3310 return K == Decl::UsingShadow || K == Decl::ConstructorUsingShadow;
3323 llvm::PointerIntPair<UsingShadowDecl *, 1, bool> FirstUsingShadow;
3330 void anchor()
override;
3363 Current = Current->getNextUsingShadowDecl();
3374 return x.Current == y.Current;
3377 return x.Current != y.Current;
3427 UsingLocation(UL), QualifierLoc(QualifierLoc),
3432 void anchor()
override;
3470 bool HasTypenameKeyword);
3513 unsigned IsVirtual : 1;
3517 bool TargetInVirtualBase)
3519 Using->getDeclName(), Using,
3520 Target->getUnderlyingDecl()),
3521 NominatedBaseClassShadowDecl(
3522 dyn_cast<ConstructorUsingShadowDecl>(
Target)),
3523 ConstructedBaseClassShadowDecl(NominatedBaseClassShadowDecl),
3524 IsVirtual(TargetInVirtualBase) {
3528 if (NominatedBaseClassShadowDecl &&
3529 NominatedBaseClassShadowDecl->constructsVirtualBase()) {
3530 ConstructedBaseClassShadowDecl =
3531 NominatedBaseClassShadowDecl->ConstructedBaseClassShadowDecl;
3537 :
UsingShadowDecl(ConstructorUsingShadow, C, Empty), IsVirtual(
false) {}
3539 void anchor()
override;
3573 return NominatedBaseClassShadowDecl;
3579 return ConstructedBaseClassShadowDecl;
3589 return cast<CXXRecordDecl>((ConstructedBaseClassShadowDecl
3590 ? ConstructedBaseClassShadowDecl
3625 EnumLocation(EL), Enum(ED) {}
3627 void anchor()
override;
3679 private llvm::TrailingObjects<UsingPackDecl, NamedDecl *> {
3685 unsigned NumExpansions;
3690 InstantiatedFrom ? InstantiatedFrom->
getLocation()
3692 InstantiatedFrom ? InstantiatedFrom->
getDeclName()
3694 InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
3695 std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(),
3696 getTrailingObjects<NamedDecl *>());
3699 void anchor()
override;
3714 return llvm::makeArrayRef(getTrailingObjects<NamedDecl *>(), NumExpansions);
3722 unsigned NumExpansions);
3747 public Mergeable<UnresolvedUsingValueDecl> {
3768 UsingLocation(UsingLoc), EllipsisLoc(EllipsisLoc),
3769 QualifierLoc(QualifierLoc), DNLoc(NameInfo.
getInfo()) {}
3771 void anchor()
override;
3844 public Mergeable<UnresolvedUsingTypenameDecl> {
3862 :
TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName,
3864 TypenameLocation(TypenameLoc), EllipsisLoc(EllipsisLoc),
3865 QualifierLoc(QualifierLoc) {}
3867 void anchor()
override;
3929 void anchor()
override;
3944 llvm::PointerIntPair<Expr *, 1, bool> AssertExprAndFailed;
3951 :
Decl(StaticAssert, DC, StaticAssertLoc),
3952 AssertExprAndFailed(AssertExpr, Failed), Message(Message),
3953 RParenLoc(RParenLoc) {}
3955 virtual void anchor();
3972 bool isFailed()
const {
return AssertExprAndFailed.getInt(); }
3999 Expr *Binding =
nullptr;
4004 void anchor()
override;
4031 this->Binding = Binding;
4051 private llvm::TrailingObjects<DecompositionDecl, BindingDecl *> {
4053 unsigned NumBindings;
4059 :
VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc,
nullptr, T, TInfo,
4063 getTrailingObjects<BindingDecl *>());
4065 B->setDecomposedDecl(
this);
4068 void anchor()
override;
4081 unsigned NumBindings);
4084 return llvm::makeArrayRef(getTrailingObjects<BindingDecl *>(), NumBindings);
4087 void printName(raw_ostream &os)
const override;
4127 GetterId(Getter), SetterId(Setter) {}
4129 void anchor()
override;
4174 public llvm::FoldingSetNode {
4186 void anchor()
override;
4200 void printName(llvm::raw_ostream &OS)
const override;
4211 ID.AddInteger(
P.Part1);
4212 ID.AddInteger(
P.Part2);
4213 ID.AddInteger(
P.Part3);
4214 ID.AddInteger(
P.getPart4And5AsUint64());
4229 public Mergeable<UnnamedGlobalConstantDecl>,
4230 public llvm::FoldingSetNode {
4235 void anchor()
override;
4253 void printName(llvm::raw_ostream &OS)
const override;
4272 const StreamingDiagnostic &
operator<<(
const StreamingDiagnostic &DB,
4277 #endif // LLVM_CLANG_AST_DECLCXX_H
init_const_range inits() const
void printName(raw_ostream &os) const override
Pretty-print the unqualified name of this declaration.
Store information needed for an explicit specifier.
UsingDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
QualType getThisType() const
Return the type of the this pointer.
bool hasSimpleCopyConstructor() const
true if we know for sure that this class has a single, accessible, unambiguous copy constructor that ...
const DeclarationNameLoc & getInfo() const
ExplicitSpecifier getExplicitSpecifier()
init_reverse_iterator init_rbegin()
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
SourceLocation getMemberLocation() const
bool getShadowFlag() const
A bool flag for use by a derived type.
init_const_reverse_iterator init_rbegin() const
UsingShadowDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
FieldDecl * getAnyMember() const
bool hasNonTrivialMoveConstructorForCall() const
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
ASTContext & getASTContext() const LLVM_READONLY
Represents an access specifier followed by colon ':'.
static bool classofKind(Kind K)
std::reverse_iterator< init_const_iterator > init_const_reverse_iterator
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
decl_iterator decls_end() const
unsigned getDeviceLambdaManglingNumber() const
Retrieve the device side mangling number.
QualType getThisObjectType() const
Return the type of the object pointed by this.
void setAccessSpecifierLoc(SourceLocation ASLoc)
Sets the location of the access specifier.
void setImplicitDestructorIsDeleted()
Set that we attempted to declare an implicit destructor, but overload resolution failed so we deleted...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setRangeEnd(SourceLocation E)
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
Represents a C++ constructor within a class.
QualType getType() const
Retrieves the type of the base class.
bool isLambdaStaticInvoker() const
Determine whether this is a lambda closure type's static member function that is used for the result ...
void setCtorInitializers(CXXCtorInitializer **Initializers)
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
ConstructorUsingShadowDecl * getShadowDecl() const
void setSourceOrder(int Pos)
Set the source order of this initializer.
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
const CXXConstructorDecl * getCanonicalDecl() const
FunctionTemplateDecl * getDependentLambdaCallOperator() const
Retrieve the dependent lambda call operator of the closure type if this is a templated closure type.
static bool classof(const Decl *D)
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
friend bool operator==(shadow_iterator x, shadow_iterator y)
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Parts of a decomposed MSGuidDecl.
bool hasMoveConstructor() const
Determine whether this class has a move constructor.
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
bool hasSimpleDestructor() const
true if we know for sure that this class has an accessible destructor that is not deleted.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
static bool classofKind(Kind K)
void setLanguage(LanguageIDs L)
Set the language specified by this linkage specification.
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
QualType getType() const
Return the type wrapped by this type source info.
NamedDecl * getNominatedNamespaceAsWritten()
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
static UsingPackDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions)
void setImplicitCopyAssignmentIsDeleted()
Set that we attempted to declare an implicit copy assignment operator, but overload resolution failed...
A mapping from each virtual member function to its set of final overriders.
void setInitMethod(bool Val)
Provides information a specialization of a member of a class template, which may be a member function...
QualType getReturnType() const
bool hasNonTrivialCopyConstructorForCall() const
uint64_t getPart4And5AsUint64() const
SourceLocation getEndLoc() const LLVM_READONLY
DeclaratorDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL)
specific_decl_iterator< CXXConstructorDecl > ctor_iterator
Iterator access to constructor members.
DeclarationNameLoc - Additional source/type location info for a declaration name.
bool isExplicit() const
Determine whether this specifier is known to correspond to an explicit declaration.
Represents a linkage specification.
A trivial tuple used to represent a source range.
ArrayRef< BindingDecl * > bindings() const
bool isCLike() const
True if this class is C-like, without C++-specific features, e.g.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
bool getInheritConstructors() const
Determine whether this base class's constructors get inherited.
Describes the capture of a variable or of this, or of a C++1y init-capture.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents a C++ conversion function within a class.
Provides common interface for the Decls that can be redeclared.
void setHasTrivialSpecialMemberForCall()
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
Represents a C++ namespace alias.
APValue * getOrCreateValue(bool MayCreate) const
Get the storage for the constant value of a materialized temporary of static storage duration.
static bool classof(const Decl *D)
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl * > Bindings)
bool hasNonTrivialMoveConstructor() const
Determine whether this class has a non-trivial move constructor (C++11 [class.copy]p12)
std::reverse_iterator< init_iterator > init_reverse_iterator
IdentifierInfo * getGetterId() const
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class....
unsigned getLambdaDependencyKind() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
static void Profile(llvm::FoldingSetNodeID &ID, Parts P)
static bool classof(const Decl *D)
redecl_iterator redecls_begin() const
static bool classofKind(Kind K)
Represents C++ using-directive.
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
SourceLocation getBaseTypeLoc() const LLVM_READONLY
Get the location at which the base class type was written.
bool hasVariantMembers() const
Determine whether this class has any variant members.
A binding in a decomposition declaration.
void removeConversion(const NamedDecl *Old)
Removes a conversion function from this class.
const UnresolvedUsingTypenameDecl * getCanonicalDecl() const
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Encodes a location in the source.
conversion_iterator conversion_begin() const
CXXRecordDecl * getTemplateInstantiationPattern()
static bool classofKind(Kind K)
const ExplicitSpecifier getExplicitSpecifier() const
const ExplicitSpecifier getExplicitSpecifier() const
void Profile(llvm::FoldingSetNodeID &ID)
This represents a decl that may have a name.
void setIsParsingBaseSpecifiers()
TemplateDecl * getDeducedTemplate() const
Get the template for which this guide performs deduction.
bool isExplicit() const
Return true if the declartion is already resolved to be explicit.
void setTypename(bool TN)
Sets whether the using declaration has 'typename'.
friend_iterator friend_begin() const
CXXConstructorDecl * getCorrespondingConstructor() const
Get the constructor from which this deduction guide was generated, if this is an implicit deduction g...
bool constructsVirtualBase() const
Returns true if the constructed base class is a virtual base class subobject of this declaration's cl...
CXXConversionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared.
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
CXXRecordDecl * getDefinition() const
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
base_class_iterator vbases_end()
A (possibly-)qualified type.
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class....
const NamespaceDecl * getNamespace() const
redecl_iterator redecls_end() const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isPackExpansion() const
Determine whether this is a pack expansion.
const DeclContext * getCommonAncestor() const
void setCaptures(ASTContext &Context, ArrayRef< LambdaCapture > Captures)
Set the captures for this lambda closure type.
static bool classofKind(Kind K)
CXXRecordDecl * getParent()
Return the parent of this method declaration, which is the class in which this method is defined.
The iterator over UnresolvedSets.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
Represents a member of a struct/union/class.
llvm::iterator_range< redecl_iterator > redecl_range
static bool classofKind(Kind K)
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
The collection of all-type qualifiers we support.
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
NamespaceAliasDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
base_class_const_iterator vbases_begin() const
UnresolvedUsingTypenameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
DeclarationNameInfo getNameInfo() const
DeclarationNameInfo getNameInfo() const
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
unsigned getIdentifierNamespace() const
const CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext) const
bool isStructural() const
Determine whether this is a structural type.
base_class_const_range vbases() const
static bool classof(const Decl *D)
bool hasTrivialDestructorForCall() const
static bool classofKind(Kind K)
Parts getParts() const
Get the decomposed parts of this declaration.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID)
llvm::function_ref< bool(const CXXRecordDecl *BaseDefinition)> ForallBasesCallback
Function type used by forallBases() as a callback.
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
bool isAnyMemberInitializer() const
Represents a pack of using declarations that a single using-declarator pack-expanded into.
const FunctionDecl * getOperatorDelete() const
bool isNeverDependentLambda() const
uint32_t Part1
{01234567-...
unsigned getManglingNumber() const
NamedDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
FunctionType - C99 6.7.5.3 - Function Declarators.
static bool classof(const Decl *D)
static bool classofKind(Kind K)
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
friend_range friends() const
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
CXXRecordDecl * getConstructedBaseClass() const
Get the base class whose constructor or constructor shadow declaration is passed the constructor argu...
const CXXDestructorDecl * getCanonicalDecl() const
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
The name of a declaration.
IndirectFieldDecl * getIndirectMember() const
base_class_iterator bases_end()
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
void setDecomposedDecl(ValueDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
VarDecl * getHoldingVar() const
Get the variable (if any) that holds the value of evaluating the binding.
friend class BaseUsingDecl
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
bool isIndirectMemberInitializer() const
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
init_reverse_iterator init_rend()
llvm::iterator_range< base_class_iterator > base_class_range
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
const UsingDecl * getCanonicalDecl() const
static bool FindBaseClass(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, const CXXRecordDecl *BaseRecord)
Base-class lookup callback that determines whether the given base class specifier refers to a specifi...
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
The base class of the type hierarchy.
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
@ IDNS_TagFriend
This declaration is a friend class.
UsingShadowDecl * getNextUsingShadowDecl() const
The next using shadow declaration contained in the shadow decl chain of the using declaration which i...
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
FieldDecl * getAnonField() const
llvm::iterator_range< redecl_iterator > redecl_range
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
static bool classofKind(Kind K)
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
static bool classof(const Decl *D)
static bool classofKind(Kind K)
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
void setLambdaMangling(unsigned ManglingNumber, Decl *ContextDecl, bool HasKnownInternalLinkage=false)
Set the mangling number and context declaration for a lambda class.
void setImplicitMoveConstructorIsDeleted()
Set that we attempted to declare an implicit move constructor, but overload resolution failed so we d...
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
bool isExplicit() const
Return true if the declartion is already resolved to be explicit.
SourceLocation getBeginLoc() const
Get the begin source location.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin, bool isInlineSpecified, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, unsigned ID, uint64_t AllocKind)
bool hasMutableFields() const
Determine whether this class, or any of its class subobjects, contains a mutable field.
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
bool hasCopyConstructorWithConstParam() const
Determine whether this class has a copy constructor with a parameter type which is a reference to a c...
Represents a dependent using declaration which was marked with typename.
llvm::iterator_range< base_class_const_iterator > base_class_const_range
bool isInClassMemberInitializer() const
Determine whether this initializer is an implicit initializer generated for a field with an initializ...
static bool classofKind(Kind K)
static bool classof(const Decl *D)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Declaration of a template function.
base_class_iterator vbases_begin()
CXXBaseSpecifier()=default
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID)
const StringLiteral * getMessage() const
Kind
Lists the kind of concrete classes of Decl.
LambdaCaptureDefault getLambdaCaptureDefault() const
bool hasUserDeclaredMoveConstructor() const
Determine whether this class has had a move constructor declared by the user.
static bool classof(const Decl *D)
overridden_method_range overridden_methods() const
TypeLoc getBaseClassLoc() const
If this is a base class initializer, returns the type of the base class with location information.
const UnresolvedUsingValueDecl * getCanonicalDecl() const
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Represents the body of a requires-expression.
bool isDependentLambda() const
Determine whether this lambda expression was known to be dependent at the time it was created,...
const ExplicitSpecifier getExplicitSpecifier() const
static bool classof(const Decl *D)
method_range methods() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
bool isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is virtually derived from the class Base.
Stmt::const_child_range childrenExpr() const
bool isCurrentInstantiation(const DeclContext *CurContext) const
Determine whether this dependent class is a current instantiation, when viewed from within the given ...