39 #include "llvm/ADT/None.h" 40 #include "llvm/ADT/SmallPtrSet.h" 41 #include "llvm/ADT/SmallVector.h" 42 #include "llvm/ADT/iterator_range.h" 43 #include "llvm/Support/Casting.h" 44 #include "llvm/Support/ErrorHandling.h" 45 #include "llvm/Support/raw_ostream.h" 51 using namespace clang;
57 void AccessSpecDecl::anchor() {}
63 void LazyASTUnresolvedSet::getFromExternalSource(
ASTContext &
C)
const {
65 assert(Impl.Decls.isLazy() &&
"getFromExternalSource for non-lazy set");
66 assert(Source &&
"getFromExternalSource with no external source");
70 reinterpret_cast<uintptr_t>(I.getDecl()) >> 2)));
71 Impl.Decls.setLazy(
false);
74 CXXRecordDecl::DefinitionData::DefinitionData(
CXXRecordDecl *D)
75 : UserDeclaredConstructor(
false), UserDeclaredSpecialMembers(0),
76 Aggregate(
true), PlainOldData(
true), Empty(
true), Polymorphic(
false),
77 Abstract(
false), IsStandardLayout(
true), HasNoNonEmptyBases(
true),
78 HasPrivateFields(
false), HasProtectedFields(
false),
79 HasPublicFields(
false), HasMutableFields(
false), HasVariantMembers(
false),
80 HasOnlyCMembers(
true), HasInClassInitializer(
false),
81 HasUninitializedReferenceMember(
false), HasUninitializedFields(
false),
82 HasInheritedConstructor(
false), HasInheritedAssignment(
false),
83 NeedOverloadResolutionForCopyConstructor(
false),
84 NeedOverloadResolutionForMoveConstructor(
false),
85 NeedOverloadResolutionForMoveAssignment(
false),
86 NeedOverloadResolutionForDestructor(
false),
87 DefaultedCopyConstructorIsDeleted(
false),
88 DefaultedMoveConstructorIsDeleted(
false),
89 DefaultedMoveAssignmentIsDeleted(
false),
90 DefaultedDestructorIsDeleted(
false), HasTrivialSpecialMembers(SMF_All),
91 DeclaredNonTrivialSpecialMembers(0), HasIrrelevantDestructor(
true),
92 HasConstexprNonCopyMoveConstructor(
false),
93 HasDefaultedDefaultConstructor(
false),
94 CanPassInRegisters(
true),
95 DefaultedDefaultConstructorIsConstexpr(
true),
96 HasConstexprDefaultConstructor(
false),
97 HasNonLiteralTypeFieldsOrBases(
false), ComputedVisibleConversions(
false),
98 UserProvidedDefaultConstructor(
false), DeclaredSpecialMembers(0),
99 ImplicitCopyConstructorCanHaveConstParamForVBase(
true),
100 ImplicitCopyConstructorCanHaveConstParamForNonVBase(
true),
101 ImplicitCopyAssignmentHasConstParam(
true),
102 HasDeclaredCopyConstructorWithConstParam(
false),
103 HasDeclaredCopyAssignmentWithConstParam(
false), IsLambda(
false),
104 IsParsingBaseSpecifiers(
false), HasODRHash(
false), Definition(D) {}
107 return Bases.get(Definition->getASTContext().getExternalSource());
110 CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getVBasesSlowCase()
const {
111 return VBases.get(Definition->getASTContext().getExternalSource());
118 :
RecordDecl(K, TK, C, DC, StartLoc, IdLoc, Id, PrevDecl),
119 DefinitionData(PrevDecl ? PrevDecl->DefinitionData
126 bool DelayTypeCreation) {
128 IdLoc, Id, PrevDecl);
132 if (!DelayTypeCreation)
140 bool Dependent,
bool IsGeneric,
147 new (
C)
struct LambdaDefinitionData(R, Info, Dependent, IsGeneric,
169 if (!data().Bases.isOffset() && data().NumBases > 0)
176 data().Aggregate =
false;
181 data().PlainOldData =
false;
185 llvm::SmallPtrSet<CanQualType, 8> SeenVBaseTypes;
191 data().NumBases = NumBases;
192 for (
unsigned i = 0; i < NumBases; ++i) {
193 data().getBases()[i] = *Bases[i];
203 if (!BaseClassDecl->
isEmpty()) {
213 data().IsStandardLayout =
false;
219 data().Empty =
false;
220 data().HasNoNonEmptyBases =
false;
226 data().Aggregate =
false;
232 data().Polymorphic =
true;
238 data().IsStandardLayout =
false;
242 data().HasNonLiteralTypeFieldsOrBases =
true;
245 for (
const auto &VBase : BaseClassDecl->
vbases()) {
248 VBases.push_back(&VBase);
255 if (
CXXRecordDecl *VBaseDecl = VBase.getType()->getAsCXXRecordDecl())
256 if (!VBaseDecl->hasCopyConstructorWithConstParam())
257 data().ImplicitCopyConstructorCanHaveConstParamForVBase =
false;
261 data().Aggregate =
false;
268 VBases.push_back(Base);
273 data().Empty =
false;
277 data().Aggregate =
false;
283 data().HasTrivialSpecialMembers &= SMF_Destructor;
288 data().IsStandardLayout =
false;
293 data().DefaultedDefaultConstructorIsConstexpr =
false;
301 data().ImplicitCopyConstructorCanHaveConstParamForVBase =
false;
308 data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
316 data().HasTrivialSpecialMembers &= ~SMF_CopyConstructor;
322 data().HasTrivialSpecialMembers &= ~SMF_MoveConstructor;
330 data().HasTrivialSpecialMembers &= ~SMF_CopyAssignment;
336 data().HasTrivialSpecialMembers &= ~SMF_MoveAssignment;
343 data().DefaultedDefaultConstructorIsConstexpr =
false;
351 data().ImplicitCopyConstructorCanHaveConstParamForNonVBase =
false;
358 data().HasTrivialSpecialMembers &= ~SMF_Destructor;
361 data().HasIrrelevantDestructor =
false;
369 data().ImplicitCopyAssignmentHasConstParam =
false;
381 data().HasMutableFields =
true;
382 data().NeedOverloadResolutionForCopyConstructor =
true;
386 data().HasUninitializedReferenceMember =
true;
389 data().HasUninitializedFields =
true;
391 addedClassSubobject(BaseClassDecl);
394 if (VBases.empty()) {
395 data().IsParsingBaseSpecifiers =
false;
401 data().NumVBases = VBases.size();
402 for (
int I = 0, E = VBases.size(); I != E; ++I) {
406 data().getVBases()[I] = *VBases[I];
409 data().IsParsingBaseSpecifiers =
false;
413 assert(
hasDefinition() &&
"ODRHash only for records with definitions");
416 if (DefinitionData->HasODRHash)
417 return DefinitionData->ODRHash;
422 DefinitionData->HasODRHash =
true;
425 return DefinitionData->ODRHash;
428 void CXXRecordDecl::addedClassSubobject(
CXXRecordDecl *Subobj) {
436 data().NeedOverloadResolutionForCopyConstructor =
true;
438 data().NeedOverloadResolutionForMoveConstructor =
true;
447 data().NeedOverloadResolutionForMoveAssignment =
true;
457 data().NeedOverloadResolutionForCopyConstructor =
true;
458 data().NeedOverloadResolutionForMoveConstructor =
true;
459 data().NeedOverloadResolutionForDestructor =
true;
487 void CXXRecordDecl::markedVirtualFunctionPure() {
490 data().Abstract =
true;
493 void CXXRecordDecl::addedMember(
Decl *D) {
495 !isa<FieldDecl>(D) &&
496 !isa<IndirectFieldDecl>(D) &&
497 (!isa<TagDecl>(D) || cast<TagDecl>(D)->getTagKind() ==
TTK_Class ||
499 data().HasOnlyCMembers =
false;
510 Decl *DUnderlying = D;
511 if (
auto *ND = dyn_cast<NamedDecl>(DUnderlying)) {
512 DUnderlying = ND->getUnderlyingDecl();
514 dyn_cast<FunctionTemplateDecl>(DUnderlying))
515 DUnderlying = UnderlyingFunTmpl->getTemplatedDecl();
519 if (Method->isVirtual()) {
522 data().Aggregate =
false;
526 data().PlainOldData =
false;
530 data().Empty =
false;
535 data().Polymorphic =
true;
541 data().HasTrivialSpecialMembers &= SMF_Destructor;
546 data().IsStandardLayout =
false;
554 L->AddedCXXImplicitMember(data().Definition, D);
561 if (!Constructor->isImplicit()) {
563 data().UserDeclaredConstructor =
true;
569 data().PlainOldData =
false;
572 if (Constructor->isDefaultConstructor()) {
573 SMKind |= SMF_DefaultConstructor;
575 if (Constructor->isUserProvided())
576 data().UserProvidedDefaultConstructor =
true;
577 if (Constructor->isConstexpr())
578 data().HasConstexprDefaultConstructor =
true;
579 if (Constructor->isDefaulted())
580 data().HasDefaultedDefaultConstructor =
true;
585 if (Constructor->isCopyConstructor(Quals)) {
586 SMKind |= SMF_CopyConstructor;
589 data().HasDeclaredCopyConstructorWithConstParam =
true;
590 }
else if (Constructor->isMoveConstructor())
591 SMKind |= SMF_MoveConstructor;
597 if (Constructor->isUserProvided() || Constructor->isExplicit())
598 data().Aggregate =
false;
603 dyn_cast<CXXConstructorDecl>(DUnderlying)) {
610 if (Constructor->isConstexpr() && !Constructor->isCopyOrMoveConstructor())
611 data().HasConstexprNonCopyMoveConstructor =
true;
616 SMKind |= SMF_Destructor;
618 if (DD->isUserProvided())
619 data().HasIrrelevantDestructor =
false;
627 data().HasTrivialSpecialMembers &= ~SMF_Destructor;
632 if (Method->isCopyAssignmentOperator()) {
633 SMKind |= SMF_CopyAssignment;
638 data().HasDeclaredCopyAssignmentWithConstParam =
true;
641 if (Method->isMoveAssignmentOperator())
642 SMKind |= SMF_MoveAssignment;
654 if (Conversion->getPrimaryTemplate()) {
660 FunTmpl ? cast<NamedDecl>(FunTmpl) : cast<NamedDecl>(Conversion);
665 Conversions.
addDecl(Ctx, Primary, AS);
672 data().HasTrivialSpecialMembers &=
673 data().DeclaredSpecialMembers | ~SMKind;
675 if (!Method->isImplicit() && !Method->isUserProvided()) {
679 }
else if (Method->isTrivial())
680 data().HasTrivialSpecialMembers |= SMKind;
682 data().DeclaredNonTrivialSpecialMembers |= SMKind;
686 data().DeclaredSpecialMembers |= SMKind;
688 if (!Method->isImplicit()) {
689 data().UserDeclaredSpecialMembers |= SMKind;
702 data().PlainOldData =
false;
710 if (
FieldDecl *Field = dyn_cast<FieldDecl>(D)) {
715 if (Field->isUnnamedBitfield())
724 data().Aggregate =
false;
725 data().PlainOldData =
false;
733 case AS_private: data().HasPrivateFields =
true;
break;
734 case AS_protected: data().HasProtectedFields =
true;
break;
735 case AS_public: data().HasPublicFields =
true;
break;
736 case AS_none: llvm_unreachable(
"Invalid access specifier");
738 if ((data().HasPrivateFields + data().HasProtectedFields +
739 data().HasPublicFields) > 1)
740 data().IsStandardLayout =
false;
743 if (Field->isMutable()) {
744 data().HasMutableFields =
true;
745 data().NeedOverloadResolutionForCopyConstructor =
true;
751 if (
isUnion() && !Field->isAnonymousStructOrUnion())
752 data().HasVariantMembers =
true;
772 struct DefinitionData &Data = data();
773 Data.PlainOldData =
false;
774 Data.HasTrivialSpecialMembers = 0;
775 Data.HasIrrelevantDestructor =
false;
776 }
else if (!Context.
getLangOpts().ObjCAutoRefCount) {
780 data().PlainOldData =
false;
783 if (!Field->hasInClassInitializer())
784 data().HasUninitializedReferenceMember =
true;
789 data().IsStandardLayout =
false;
795 data().DefaultedCopyConstructorIsDeleted =
true;
798 if (!Field->hasInClassInitializer() && !Field->isMutable()) {
800 if (FieldType->hasDefinition() && !FieldType->allowConstDefaultInit())
801 data().HasUninitializedFields =
true;
803 data().HasUninitializedFields =
true;
809 data().HasNonLiteralTypeFieldsOrBases =
true;
811 if (Field->hasInClassInitializer() ||
812 (Field->isAnonymousStructOrUnion() &&
813 Field->getType()->getAsCXXRecordDecl()->hasInClassInitializer())) {
814 data().HasInClassInitializer =
true;
819 data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
827 data().Aggregate =
false;
831 data().PlainOldData =
false;
839 data().DefaultedMoveAssignmentIsDeleted =
true;
842 CXXRecordDecl* FieldRec = cast<CXXRecordDecl>(RecordTy->getDecl());
844 addedClassSubobject(FieldRec);
852 data().NeedOverloadResolutionForCopyConstructor =
true;
853 data().NeedOverloadResolutionForMoveConstructor =
true;
854 data().NeedOverloadResolutionForMoveAssignment =
true;
864 data().DefaultedCopyConstructorIsDeleted =
true;
866 data().DefaultedMoveConstructorIsDeleted =
true;
868 data().DefaultedMoveAssignmentIsDeleted =
true;
870 data().DefaultedDestructorIsDeleted =
true;
875 if (Field->isAnonymousStructOrUnion()) {
876 data().NeedOverloadResolutionForCopyConstructor |=
877 FieldRec->data().NeedOverloadResolutionForCopyConstructor;
878 data().NeedOverloadResolutionForMoveConstructor |=
879 FieldRec->data().NeedOverloadResolutionForMoveConstructor;
880 data().NeedOverloadResolutionForMoveAssignment |=
881 FieldRec->data().NeedOverloadResolutionForMoveAssignment;
882 data().NeedOverloadResolutionForDestructor |=
883 FieldRec->data().NeedOverloadResolutionForDestructor;
892 data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
901 data().HasTrivialSpecialMembers &= ~SMF_CopyConstructor;
906 data().HasTrivialSpecialMembers &= ~SMF_MoveConstructor;
915 data().HasTrivialSpecialMembers &= ~SMF_CopyAssignment;
920 data().HasTrivialSpecialMembers &= ~SMF_MoveAssignment;
923 data().HasTrivialSpecialMembers &= ~SMF_Destructor;
925 data().HasIrrelevantDestructor =
false;
936 data().IsStandardLayout =
false;
953 if (data().IsStandardLayout && data().Empty) {
954 for (
const auto &BI :
bases()) {
956 data().IsStandardLayout =
false;
964 data().HasMutableFields =
true;
965 data().NeedOverloadResolutionForCopyConstructor =
true;
975 if (!Field->hasInClassInitializer() &&
979 data().DefaultedDefaultConstructorIsConstexpr =
false;
987 data().ImplicitCopyConstructorCanHaveConstParamForNonVBase =
false;
996 data().ImplicitCopyAssignmentHasConstParam =
false;
999 !Field->hasInClassInitializer())
1000 data().HasUninitializedReferenceMember =
true;
1006 Field->isAnonymousStructOrUnion())
1007 data().HasVariantMembers =
true;
1012 (!Field->hasInClassInitializer() && !
isUnion()))
1013 data().DefaultedDefaultConstructorIsConstexpr =
false;
1021 data().DefaultedMoveAssignmentIsDeleted =
true;
1032 if (!data().HasNoNonEmptyBases)
1033 data().IsStandardLayout =
false;
1039 if (!Field->isBitField() ||
1040 (!Field->getBitWidth()->isTypeDependent() &&
1041 !Field->getBitWidth()->isValueDependent() &&
1042 Field->getBitWidthValue(Context) != 0))
1043 data().Empty =
false;
1049 if (Shadow->getDeclName().getNameKind()
1052 data().Conversions.get(Ctx).addDecl(Ctx, Shadow, Shadow->getAccess());
1056 if (
UsingDecl *Using = dyn_cast<UsingDecl>(D)) {
1057 if (Using->getDeclName().getNameKind() ==
1059 data().HasInheritedConstructor =
true;
1062 data().Aggregate =
false;
1065 if (Using->getDeclName().getCXXOverloadedOperator() == OO_Equal)
1066 data().HasInheritedAssignment =
true;
1074 unsigned SMKind = 0;
1077 if (Constructor->isDefaultConstructor()) {
1078 SMKind |= SMF_DefaultConstructor;
1079 if (Constructor->isConstexpr())
1080 data().HasConstexprDefaultConstructor =
true;
1082 if (Constructor->isCopyConstructor())
1083 SMKind |= SMF_CopyConstructor;
1084 else if (Constructor->isMoveConstructor())
1085 SMKind |= SMF_MoveConstructor;
1086 else if (Constructor->isConstexpr())
1088 data().HasConstexprNonCopyMoveConstructor =
true;
1089 }
else if (isa<CXXDestructorDecl>(D)) {
1090 SMKind |= SMF_Destructor;
1092 data().HasIrrelevantDestructor =
false;
1094 SMKind |= SMF_CopyAssignment;
1096 SMKind |= SMF_MoveAssignment;
1101 data().HasTrivialSpecialMembers |= SMKind;
1103 data().DeclaredNonTrivialSpecialMembers |= SMKind;
1108 !TemplateOrInstantiation.isNull())
1113 return isPOD() && data().HasOnlyCMembers;
1118 return getLambdaData().IsGenericLambda;
1127 assert(!Calls.
empty() &&
"Missing lambda call operator!");
1128 assert(Calls.
size() == 1 &&
"More than one lambda call operator!");
1132 dyn_cast<FunctionTemplateDecl>(CallOp))
1133 return cast<CXXMethodDecl>(CallOpTmpl->getTemplatedDecl());
1135 return cast<CXXMethodDecl>(CallOp);
1143 if (Invoker.
empty())
return nullptr;
1144 assert(Invoker.
size() == 1 &&
"More than one static invoker operator!");
1147 dyn_cast<FunctionTemplateDecl>(InvokerFun))
1148 return cast<CXXMethodDecl>(InvokerTemplate->getTemplatedDecl());
1150 return cast<CXXMethodDecl>(InvokerFun);
1154 llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures,
1157 ThisCapture =
nullptr;
1159 LambdaDefinitionData &Lambda = getLambdaData();
1161 for (
const LambdaCapture *C = Lambda.Captures, *CEnd = C + Lambda.NumCaptures;
1162 C != CEnd; ++C, ++Field) {
1163 if (C->capturesThis())
1164 ThisCapture = *Field;
1165 else if (C->capturesVariable())
1166 Captures[C->getCapturedVar()] = *Field;
1176 return Tmpl->getTemplateParameters();
1181 assert(
isLambda() &&
"Not a lambda closure type!");
1183 return getLambdaData().ContextDecl.get(Source);
1189 ->getConversionType();
1209 const llvm::SmallPtrSet<CanQualType, 8> &ParentHiddenTypes,
1212 llvm::SmallPtrSet<NamedDecl*, 8> &HiddenVBaseCs) {
1216 const llvm::SmallPtrSet<CanQualType, 8> *HiddenTypes = &ParentHiddenTypes;
1217 llvm::SmallPtrSet<CanQualType, 8> HiddenTypesBuffer;
1223 if (ConvI != ConvE) {
1224 HiddenTypesBuffer = ParentHiddenTypes;
1225 HiddenTypes = &HiddenTypesBuffer;
1229 bool Hidden = ParentHiddenTypes.count(ConvType);
1231 HiddenTypesBuffer.insert(ConvType);
1235 if (Hidden && InVirtual)
1236 HiddenVBaseCs.insert(cast<NamedDecl>(I.getDecl()->getCanonicalDecl()));
1244 VOutput.
addDecl(I.getDecl(), IAccess);
1246 Output.
addDecl(Context, I.getDecl(), IAccess);
1252 for (
const auto &I : Record->
bases()) {
1258 bool BaseInVirtual = InVirtual || I.isVirtual();
1262 *HiddenTypes, Output, VOutput, HiddenVBaseCs);
1280 llvm::SmallPtrSet<NamedDecl*, 8> HiddenVBaseCs;
1283 llvm::SmallPtrSet<CanQualType, 8> HiddenTypes;
1289 Output.
append(Context, ConvI, ConvE);
1290 for (; ConvI != ConvE; ++ConvI)
1294 for (
const auto &I : Record->
bases()) {
1299 I.isVirtual(), I.getAccessSpecifier(),
1300 HiddenTypes, Output, VBaseCs, HiddenVBaseCs);
1306 if (!HiddenVBaseCs.count(cast<NamedDecl>(I.getDecl()->getCanonicalDecl())))
1307 Output.
addDecl(Context, I.getDecl(), I.getAccess());
1313 llvm::iterator_range<CXXRecordDecl::conversion_iterator>
1320 Set = &data().Conversions.get(Ctx);
1322 Set = &data().VisibleConversions.get(Ctx);
1324 if (!data().ComputedVisibleConversions) {
1326 data().ComputedVisibleConversions =
true;
1329 return llvm::make_range(Set->
begin(), Set->
end());
1345 for (
unsigned I = 0, E = Convs.
size(); I != E; ++I) {
1346 if (Convs[I].getDecl() == ConvDecl) {
1348 assert(std::find(Convs.
begin(), Convs.
end(), ConvDecl) == Convs.
end()
1349 &&
"conversion was found multiple times in unresolved set");
1354 llvm_unreachable(
"conversion not found in set!");
1359 return cast<CXXRecordDecl>(MSInfo->getInstantiatedFrom());
1371 assert(TemplateOrInstantiation.isNull() &&
1372 "Previous template or instantiation?");
1373 assert(!isa<ClassTemplatePartialSpecializationDecl>(
this));
1374 TemplateOrInstantiation
1383 TemplateOrInstantiation = Template;
1388 = dyn_cast<ClassTemplateSpecializationDecl>(
this))
1389 return Spec->getSpecializationKind();
1392 return MSInfo->getTemplateSpecializationKind();
1400 = dyn_cast<ClassTemplateSpecializationDecl>(
this)) {
1401 Spec->setSpecializationKind(TSK);
1406 MSInfo->setTemplateSpecializationKind(TSK);
1410 llvm_unreachable(
"Not a class template or member class specialization");
1414 auto GetDefinitionOrSelf =
1416 if (
auto *Def = D->getDefinition())
1423 if (
auto *TD = dyn_cast<ClassTemplateSpecializationDecl>(
this)) {
1424 auto From = TD->getInstantiatedFrom();
1426 while (
auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) {
1427 if (NewCTD->isMemberSpecialization())
1431 return GetDefinitionOrSelf(CTD->getTemplatedDecl());
1435 while (
auto *NewCTPSD = CTPSD->getInstantiatedFromMember()) {
1436 if (NewCTPSD->isMemberSpecialization())
1440 return GetDefinitionOrSelf(CTPSD);
1449 return GetDefinitionOrSelf(RD);
1454 "couldn't find pattern for class template instantiation");
1474 if (Destructor->isNoReturn())
1480 if (RD->isAnyDestructorNoReturn())
1484 for (
const auto *Field :
fields())
1486 Field->getType()->getBaseElementTypeUnsafe()->getAsCXXRecordDecl())
1487 if (RD->isAnyDestructorNoReturn())
1504 assert(
hasDefinition() &&
"checking for interface-like without a definition");
1518 for (
const auto *
const Method :
methods())
1519 if (Method->isDefined() && !Method->isImplicit())
1523 const auto *Uuid = getAttr<UuidAttr>();
1530 Uuid->getGuid() ==
"00000000-0000-0000-C000-000000000046") ||
1532 Uuid->getGuid() ==
"00020400-0000-0000-C000-000000000046"))) {
1546 if (BaseSpec.isVirtual() || BaseSpec.getAccessSpecifier() !=
AS_public)
1548 const auto *
Base = BaseSpec.getType()->getAsCXXRecordDecl();
1549 if (
Base->isInterface() || !
Base->isInterfaceLike())
1565 if (!FinalOverriders) {
1567 FinalOverriders = &MyFinalOverriders;
1571 for (CXXFinalOverriderMap::iterator M = FinalOverriders->begin(),
1572 MEnd = FinalOverriders->end();
1573 M != MEnd && !Done; ++M) {
1575 SOEnd = M->second.end();
1576 SO != SOEnd && !Done; ++SO) {
1577 assert(SO->second.size() > 0 &&
1578 "All virtual functions have overridding virtual functions");
1584 if (SO->second.front().Method->isPure()) {
1585 data().Abstract =
true;
1596 I.setAccess((*I)->getAccess());
1600 if (data().Abstract ||
isInvalidDecl() || !data().Polymorphic ||
1604 for (
const auto &B :
bases()) {
1606 = cast<CXXRecordDecl>(B.getType()->getAs<
RecordType>()->getDecl());
1614 void CXXDeductionGuideDecl::anchor() {}
1621 NameInfo, T, TInfo, EndLocation);
1631 void CXXMethodDecl::anchor() {}
1640 return isStaticOverloadedOperator(OOK);
1661 if (isa<CXXDestructorDecl>(
this)) {
1682 for (
const auto &I : RD->
bases()) {
1702 return new (
C, RD)
CXXMethodDecl(CXXMethod, C, RD, StartLoc, NameInfo,
1703 T, TInfo, SC, isInline, isConstexpr,
1715 assert(isVirtual() &&
"this method is expected to be virtual");
1724 if (hasAttr<FinalAttr>())
1725 return isPure() ? nullptr :
this;
1739 if (!BestDynamicDecl)
1744 getCorrespondingMethodInClass(BestDynamicDecl);
1749 if (DevirtualizedMethod->
isPure())
1753 if (DevirtualizedMethod->
hasAttr<FinalAttr>())
1754 return DevirtualizedMethod;
1758 if (BestDynamicDecl->
hasAttr<FinalAttr>())
1759 return DevirtualizedMethod;
1761 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
1762 if (
const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl()))
1763 if (VD->getType()->isRecordType())
1765 return DevirtualizedMethod;
1773 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(Base))
1774 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(ME->getMemberDecl()))
1779 if (
auto *BO = dyn_cast<BinaryOperator>(Base)) {
1780 if (BO->isPtrMemOp()) {
1782 if (MPT->getPointeeType()->isRecordType())
1783 return DevirtualizedMethod;
1792 if (getOverloadedOperator() != OO_Delete &&
1793 getOverloadedOperator() != OO_Array_Delete)
1799 if (getPrimaryTemplate())
1806 if (getNumParams() == 1)
1808 unsigned UsualParams = 1;
1815 if (isDestroyingOperatorDelete())
1829 if (UsualParams < getNumParams() &&
1834 if (UsualParams < getNumParams() &&
1835 getParamDecl(UsualParams)->getType()->isAlignValT())
1838 if (UsualParams != getNumParams())
1851 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I))
1852 if (FD->getNumParams() == 1)
1864 if (getOverloadedOperator() != OO_Equal ||
1866 getPrimaryTemplate() || getDescribedFunctionTemplate() ||
1867 getNumParams() != 1)
1870 QualType ParamType = getParamDecl(0)->getType();
1885 if (getOverloadedOperator() != OO_Equal || isStatic() ||
1886 getPrimaryTemplate() || getDescribedFunctionTemplate() ||
1887 getNumParams() != 1)
1890 QualType ParamType = getParamDecl(0)->getType();
1891 if (!isa<RValueReferenceType>(ParamType))
1904 "Can't add an overridden method to a class template!");
1905 assert(MD->
isVirtual() &&
"Method is not virtual!");
1911 if (isa<CXXConstructorDecl>(
this))
return nullptr;
1916 if (isa<CXXConstructorDecl>(
this))
return nullptr;
1921 if (isa<CXXConstructorDecl>(
this))
return 0;
1927 if (isa<CXXConstructorDecl>(
this))
1939 assert(isInstance() &&
"No 'this' for static methods!");
1963 if (StaticInvoker ==
this)
return true;
1965 return StaticInvoker == this->getPrimaryTemplate()->getTemplatedDecl();
1976 : Initializee(TInfo), MemberOrEllipsisLocation(EllipsisLoc), Init(Init),
1977 LParenLoc(L), RParenLoc(R), IsDelegating(
false), IsVirtual(IsVirtual),
1978 IsWritten(
false), SourceOrder(0) {}
1985 : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init),
1986 LParenLoc(L), RParenLoc(R), IsDelegating(
false), IsVirtual(
false),
1987 IsWritten(
false), SourceOrder(0) {}
1994 : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init),
1995 LParenLoc(L), RParenLoc(R), IsDelegating(
false), IsVirtual(
false),
1996 IsWritten(
false), SourceOrder(0) {}
2002 : Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R),
2003 IsDelegating(
true), IsVirtual(
false), IsWritten(
false), SourceOrder(0) {}
2014 return Initializee.get<
TypeSourceInfo*>()->getType().getTypePtr();
2027 return TSInfo->getTypeLoc().getLocalSourceRange().getBegin();
2036 return I->getSourceRange();
2043 void CXXConstructorDecl::anchor() {}
2048 unsigned Extra = additionalSizeToAlloc<InheritedConstructor>(Inherited);
2052 Result->IsInheritingConstructor = Inherited;
2061 bool isExplicit,
bool isInline,
2062 bool isImplicitlyDeclared,
bool isConstexpr,
2066 "Name must refer to a constructor");
2068 additionalSizeToAlloc<InheritedConstructor>(Inherited ? 1 : 0);
2070 C, RD, StartLoc, NameInfo, T, TInfo, isExplicit, isInline,
2071 isImplicitlyDeclared, isConstexpr, Inherited);
2075 return CtorInitializers.get(getASTContext().getExternalSource());
2079 assert(isDelegatingConstructor() &&
"Not a delegating constructor!");
2082 return Construct->getConstructor();
2091 return (getNumParams() == 0) ||
2092 (getNumParams() > 0 && getParamDecl(0)->hasDefaultArg());
2097 return isCopyOrMoveConstructor(TypeQuals) &&
2098 getParamDecl(0)->getType()->isLValueReferenceType();
2102 return isCopyOrMoveConstructor(TypeQuals) &&
2103 getParamDecl(0)->getType()->isRValueReferenceType();
2118 if ((getNumParams() < 1) ||
2119 (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) ||
2120 (getPrimaryTemplate() !=
nullptr) ||
2121 (getDescribedFunctionTemplate() !=
nullptr))
2155 if (isExplicit() && !AllowExplicit)
2158 return (getNumParams() == 0 &&
2159 getType()->getAs<FunctionProtoType>()->isVariadic()) ||
2160 (getNumParams() == 1) ||
2161 (getNumParams() > 1 &&
2162 (getParamDecl(1)->hasDefaultArg() ||
2163 getParamDecl(1)->isParameterPack()));
2167 if ((getNumParams() < 1) ||
2168 (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) ||
2169 (getDescribedFunctionTemplate() !=
nullptr))
2186 void CXXDestructorDecl::anchor() {}
2192 QualType(),
nullptr,
false,
false);
2200 bool isInline,
bool isImplicitlyDeclared) {
2203 "Name must refer to a destructor");
2205 isInline, isImplicitlyDeclared);
2209 auto *First = cast<CXXDestructorDecl>(getFirstDecl());
2210 if (OD && !First->OperatorDelete) {
2211 First->OperatorDelete = OD;
2212 First->OperatorDeleteThisArg = ThisArg;
2213 if (
auto *L = getASTMutationListener())
2214 L->ResolvedOperatorDelete(First, OD, ThisArg);
2218 void CXXConversionDecl::anchor() {}
2224 nullptr,
false,
false,
false,
2233 bool isInline,
bool isExplicit,
2237 "Name must refer to a conversion function");
2239 isInline, isExplicit, isConstexpr,
2244 return isImplicit() && getParent()->isLambda() &&
2245 getConversionType()->isBlockPointerType();
2248 void LinkageSpecDecl::anchor() {}
2256 return new (
C, DC)
LinkageSpecDecl(DC, ExternLoc, LangLoc, Lang, HasBraces);
2265 void UsingDirectiveDecl::anchor() {}
2274 if (
NamespaceDecl *NS = dyn_cast_or_null<NamespaceDecl>(Used))
2275 Used = NS->getOriginalNamespace();
2277 IdentLoc, Used, CommonAncestor);
2290 dyn_cast_or_null<NamespaceAliasDecl>(NominatedNamespace))
2291 return NA->getNamespace();
2292 return cast_or_null<NamespaceDecl>(NominatedNamespace);
2299 redeclarable_base(C), LocStart(StartLoc),
2300 AnonOrFirstNamespaceAndInline(
nullptr, Inline) {
2301 setPreviousDecl(PrevDecl);
2311 return new (
C, DC)
NamespaceDecl(C, DC, Inline, StartLoc, IdLoc, Id,
2324 return AnonOrFirstNamespaceAndInline.getPointer();
2331 return AnonOrFirstNamespaceAndInline.getPointer();
2337 return getNextRedeclaration();
2341 return getPreviousDecl();
2345 return getMostRecentDecl();
2348 void NamespaceAliasDecl::anchor() {}
2351 return getNextRedeclaration();
2355 return getPreviousDecl();
2359 return getMostRecentDecl();
2370 if (
NamespaceDecl *NS = dyn_cast_or_null<NamespaceDecl>(Namespace))
2371 Namespace = NS->getOriginalNamespace();
2373 QualifierLoc, IdentLoc, Namespace);
2384 void UsingShadowDecl::anchor() {}
2409 dyn_cast<UsingShadowDecl>(Shadow->UsingOrNextShadow))
2410 Shadow = NextShadow;
2411 return cast<UsingDecl>(Shadow->UsingOrNextShadow);
2414 void ConstructorUsingShadowDecl::anchor() {}
2433 void UsingDecl::anchor() {}
2436 assert(std::find(shadow_begin(), shadow_end(), S) == shadow_end() &&
2437 "declaration already in set");
2440 if (FirstUsingShadow.getPointer())
2441 S->UsingOrNextShadow = FirstUsingShadow.getPointer();
2442 FirstUsingShadow.setPointer(S);
2446 assert(std::find(shadow_begin(), shadow_end(), S) != shadow_end() &&
2447 "declaration not in set");
2452 if (FirstUsingShadow.getPointer() == S) {
2453 FirstUsingShadow.setPointer(
2454 dyn_cast<UsingShadowDecl>(S->UsingOrNextShadow));
2455 S->UsingOrNextShadow =
this;
2460 while (Prev->UsingOrNextShadow != S)
2461 Prev = cast<UsingShadowDecl>(Prev->UsingOrNextShadow);
2462 Prev->UsingOrNextShadow = S->UsingOrNextShadow;
2463 S->UsingOrNextShadow =
this;
2470 return new (
C, DC)
UsingDecl(DC, UL, QualifierLoc, NameInfo, HasTypename);
2481 ? getQualifierLoc().getBeginLoc() : UsingLocation;
2482 return SourceRange(Begin, getNameInfo().getEndLoc());
2485 void UsingPackDecl::anchor() {}
2490 size_t Extra = additionalSizeToAlloc<NamedDecl *>(UsingDecls.size());
2491 return new (
C, DC, Extra)
UsingPackDecl(DC, InstantiatedFrom, UsingDecls);
2495 unsigned NumExpansions) {
2496 size_t Extra = additionalSizeToAlloc<NamedDecl *>(NumExpansions);
2498 Result->NumExpansions = NumExpansions;
2499 auto *Trail = Result->getTrailingObjects<
NamedDecl *>();
2500 for (
unsigned I = 0; I != NumExpansions; ++I)
2505 void UnresolvedUsingValueDecl::anchor() {}
2514 QualifierLoc, NameInfo,
2529 ? getQualifierLoc().getBeginLoc() : UsingLocation;
2530 return SourceRange(Begin, getNameInfo().getEndLoc());
2533 void UnresolvedUsingTypenameDecl::anchor() {}
2544 DC, UsingLoc, TypenameLoc, QualifierLoc, TargetNameLoc,
2555 void StaticAssertDecl::anchor() {}
2573 void BindingDecl::anchor() {}
2585 Expr *B = getBinding();
2592 auto *VD = dyn_cast<
VarDecl>(DRE->getDecl());
2593 assert(VD->isImplicit() &&
"holding var for binding decl not implicit");
2597 void DecompositionDecl::anchor() {}
2605 size_t Extra = additionalSizeToAlloc<BindingDecl *>(Bindings.size());
2606 return new (
C, DC, Extra)
2612 unsigned NumBindings) {
2613 size_t Extra = additionalSizeToAlloc<BindingDecl *>(NumBindings);
2618 Result->NumBindings = NumBindings;
2619 auto *Trail = Result->getTrailingObjects<
BindingDecl *>();
2620 for (
unsigned I = 0; I != NumBindings; ++I)
2628 for (
auto *B : bindings()) {
2643 return new (
C, DC)
MSPropertyDecl(DC, L, N, T, TInfo, StartL, Getter, Setter);
2656 llvm_unreachable(
"Invalid access specifier!");
2664 llvm_unreachable(
"Invalid access specifier!");
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
Defines the clang::ASTContext interface.
static const char * getAccessName(AccessSpecifier AS)
void setImplicit(bool I=true)
An instance of this class is created to represent a function declaration or definition.
static Qualifiers fromCVRUMask(unsigned CVRU)
Expr * getInit() const
Get the initializer.
A (possibly-)qualified type.
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
bool isStandardLayout() const
Determine whether this class has standard layout per (C++ [class]p7)
virtual Decl * GetExternalDecl(uint32_t ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
bool replace(const NamedDecl *Old, NamedDecl *New, AccessSpecifier AS)
Replaces the given declaration with the new one, once.
const CXXMethodDecl *const * method_iterator
unsigned getNumBases() const
Retrieves the number of base classes of this class.
static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID)
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes...
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> UsingDecls)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isInClassMemberInitializer() const
Determine whether this initializer is an implicit initializer generated for a field with an initializ...
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function...
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
static AccessSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
C Language Family Type Representation.
bool hasVolatileMember() const
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
bool isRecordType() const
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
Decl - This represents one declaration (or definition), e.g.
void append(ASTContext &C, iterator I, iterator E)
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
bool isPOD() const
Whether this class is a POD-type (C++ [class]p4)
Defines the C++ template declaration subclasses.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions()
Get all conversion functions visible in current class, including conversion function templates...
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
NamespaceDecl - Represent a C++ namespace.
Represents a call to a C++ constructor.
virtual void completeDefinition()
completeDefinition - Notes that the definition of this type is now complete.
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function is defined at all, including a deleted definition.
bool hasFriends() const
Determines whether this record has any friends.
Describes the capture of a variable or of this, or of a C++1y init-capture.
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
bool mayBeAbstract() const
Determine whether this class may end up being abstract, even though it is not yet known to be abstrac...
unsigned Access
Access - Used by C++ decls for the access specifier.
CXXCtorInitializer(ASTContext &Context, TypeSourceInfo *TInfo, bool IsVirtual, SourceLocation L, Expr *Init, SourceLocation R, SourceLocation EllipsisLoc)
Creates a new base-class initializer.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
This file provides some common utility functions for processing Lambda related AST Constructs...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
ASTMutationListener * getASTMutationListener() const
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isExplicit, bool isConstexpr, SourceLocation EndLocation)
void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD)
Indicates that the declaration of a defaulted or deleted special member function is now complete...
const T * getAs() const
Member-template getAs<specific type>'.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
The "__interface" keyword.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
unsigned getODRHash() const
bool isInterfaceLike() const
bool hasDefinition() const
ParmVarDecl - Represents a parameter to a function.
TemplateParameterList * getGenericLambdaTemplateParameterList() const
Retrieve the generic lambda's template parameter list.
Defines the clang::Expr interface and subclasses for C++ expressions.
SourceLocation getRParenLoc() const
VarDecl * getHoldingVar() const
Get the variable (if any) that holds the value of evaluating the binding.
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Base wrapper for a particular "section" of type source info.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
RecordDecl - Represents a struct/union/class.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
Description of a constructor that was inherited from a base class.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
const Expr * getBestDynamicClassTypeExpr() const
Get the inner expression that determines the best dynamic class.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
The results of name lookup within a DeclContext.
field_range fields() const
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl *> Bindings)
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
static CXXRecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
conversion_iterator conversion_end() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isCopyOrMoveConstructor() const
Determine whether this a copy or move constructor.
bool isReferenceType() const
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class.copy]p25)
The iterator over UnresolvedSets.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, bool IsExplicit, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation)
Represents an access specifier followed by colon ':'.
void addShadowDecl(UsingShadowDecl *S)
static StaticAssertDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, bool DependentLambda, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
static NamespaceDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Represents a C++ using-declaration.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
void completeDefinition() override
Indicates that the definition of this class is now complete.
bool hasNonLiteralTypeFieldsOrBases() const
Determine whether this class has a non-literal or/ volatile type non-static data member or base class...
void addDecl(ASTContext &C, NamedDecl *D, AccessSpecifier AS)
TagKind getTagKind() const
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setHasObjectMember(bool val)
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
A set of unresolved declarations.
bool isRValueReferenceType() const
Defines the Diagnostic-related interfaces.
bool isLambda() const
Determine whether this class describes a lambda function object.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
field_iterator field_begin() const
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isAnyMemberInitializer() const
base_class_iterator bases_begin()
FieldDecl * getAnyMember() const
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
bool hasSimpleCopyConstructor() const
true if we know for sure that this class has a single, accessible, unambiguous copy constructor that ...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Represents a linkage specification.
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
StringRef getLambdaStaticInvokerName()
bool isAbstract() const
Determine whether this class has a pure virtual function.
A binding in a decomposition declaration.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
init_iterator init_begin()
Retrieve an iterator to the first initializer.
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
CXXRecordDecl(Kind K, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl)
bool isLambdaStaticInvoker() const
Determine whether this is a lambda closure type's static member function that is used for the result ...
static CXXDeductionGuideDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setBases(CXXBaseSpecifier const *const *Bases, unsigned NumBases)
Sets the base classes of this struct or class.
bool hasCopyAssignmentWithConstParam() const
Determine whether this class has a copy assignment operator with a parameter type which is a referenc...
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
A little helper class used to produce diagnostics.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
method_iterator end_overridden_methods() const
DeclarationNameTable DeclarationNames
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
CXXCtorInitializer *const * init_const_iterator
Iterates through the member/base initializer list.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
bool isCLike() const
True if this class is C-like, without C++-specific features, e.g.
static bool recursivelyOverrides(const CXXMethodDecl *DerivedMD, const CXXMethodDecl *BaseMD)
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
bool isObjCGCStrong() const
true when Type is objc's strong.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
Defines the clang::LangOptions interface.
QualType getPointeeType() const
static LinkageSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
const FunctionProtoType * T
const T * castAs() const
Member-template castAs<specific type>.
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
bool isObjCRetainableType() const
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
Represents a C++ destructor within a class.
bool isCopyConstructor() const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
Defines an enumeration for C++ overloaded operators.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
field_iterator field_end() const
overridden_method_range overridden_methods() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Defines the clang::TypeLoc interface and its subclasses.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv)
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool InheritsConstructor)
unsigned getCVRQualifiers() const
Retrieve the const/volatile/restrict qualifiers.
StorageClass
Storage classes.
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
An lvalue reference type, per C++11 [dcl.ref].
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool hasSimpleMoveConstructor() const
true if we know for sure that this class has a single, accessible, unambiguous move constructor that ...
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class...
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
Represents a C++ deduction guide declaration.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class.copy]p25)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
bool hasNonTrivialMoveConstructor() const
Determine whether this class has a non-trivial move constructor (C++11 [class.copy]p12) ...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
bool isConstQualified() const
Determine whether this type is const-qualified.
RecordDecl * getDecl() const
bool hasVariantMembers() const
Determine whether this class has any variant members.
Abstract interface for external sources of AST nodes.
unsigned size_overridden_methods() const
static UsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
static CXXDestructorDecl * CreateDeserialized(ASTContext &C, unsigned ID)
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool isPure() const
Whether this virtual function is pure, i.e.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
DeclarationName getName() const
getName - Returns the embedded declaration name.
ASTContext & getASTContext() const LLVM_READONLY
static DecompositionDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumBindings)
Represents a dependent using declaration which was not marked with typename.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
void removeShadowDecl(UsingShadowDecl *S)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Represents a static or instance method of a struct/union/class.
void addOverriddenMethod(const CXXMethodDecl *MD)
bool isUsualDeallocationFunction() const
Determine whether this is a usual deallocation function (C++ [basic.stc.dynamic.deallocation]p2), which is an overloaded delete or delete[] operator with a particular signature.
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
void addDecl(NamedDecl *D)
static MSPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static ConstructorUsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static bool isDeclContextInNamespace(const DeclContext *DC)
bool forallBases(ForallBasesCallback BaseMatches, bool AllowShortCircuit=true) const
Determines if the given callback holds for all the direct or indirect base classes of this type...
static ConstructorUsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool IsVirtual)
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
SourceLocation getMemberLocation() const
Represents a C++11 static_assert declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
NamedDecl * getDecl() const
TypeLoc getBaseClassLoc() const
If this is a base class initializer, returns the type of the base class with location information...
Defines various enumerations that describe declaration and type specifiers.
bool hasSimpleDestructor() const
true if we know for sure that this class has an accessible destructor that is not deleted...
TagTypeKind
The kind of a tag type.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Dataflow Directional Tag Classes.
static CXXConversionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
void setHasVolatileMember(bool val)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
method_iterator begin_overridden_methods() const
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
AccessSpecifier getAccess() const
void removeConversion(const NamedDecl *Old)
Removes a conversion function from this class.
A decomposition declaration.
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
MapType::iterator iterator
bool hasInlineBody() const
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
Represents a dependent using declaration which was marked with typename.
conversion_iterator conversion_begin() const
void AddCXXRecordDecl(const CXXRecordDecl *Record)
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
DeclarationName - The name of a declaration.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isSpecializationCopyingObject() const
Determine whether this is a member template specialization that would copy the object to itself...
bool isAnyDestructorNoReturn() const
Returns true if the class destructor, or any implicitly invoked destructors are marked noreturn...
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
U cast(CodeGen::Address addr)
A mapping from each virtual member function to its set of final overriders.
UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target)
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
bool isMoveConstructor() const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
unsigned MayHaveOutOfDateDef
Indicates whether it is possible for declarations of this kind to have an out-of-date definition...
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
LanguageIDs
Represents the language in a linkage specification.
bool hasNonTrivialObjCLifetime() const
An UnresolvedSet-like class which uses the ASTContext's allocator.
static CXXMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Base for LValueReferenceType and RValueReferenceType.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
Represents a base class of a C++ class.
unsigned IsBeingDefined
IsBeingDefined - True if this is currently being defined.
void getCaptureFields(llvm::DenseMap< const VarDecl *, FieldDecl *> &Captures, FieldDecl *&ThisCapture) const
For a closure type, retrieve the mapping from captured variables and this to the non-static data memb...
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
bool hasMutableFields() const
Determine whether this class, or any of its class subobjects, contains a mutable field.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Defines the clang::SourceLocation class and associated facilities.
Represents a C++ struct/union/class.
bool hasSimpleMoveAssignment() const
true if we know for sure that this class has a single, accessible, unambiguous move assignment operat...
Provides information a specialization of a member of a class template, which may be a member function...
void printName(raw_ostream &os) const override
base_class_iterator bases_end()
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Declaration of a class template.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
StringLiteral - This represents a string literal expression, e.g.
ASTContext & getParentASTContext() const
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body - that is, if it is a non-delete...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Kind
Lists the kind of concrete classes of Decl.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
static UsingPackDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions)
bool isConvertingConstructor(bool AllowExplicit) const
Whether this constructor is a converting constructor (C++ [class.conv.ctor]), which can be used for u...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
A reference to a declared variable, function, enum, etc.
bool isDeleted() const
Whether this function has been deleted.
bool hasObjectMember() const
ASTContext::overridden_method_range overridden_method_range
An instance of this class represents the declaration of a property member.
A trivial tuple used to represent a source range.
CXXRecordDecl * getNominatedBaseClass() const
Get the base class that was named in the using declaration.
NamedDecl - This represents a decl with a name.
bool isTranslationUnit() const
bool hasCopyConstructorWithConstParam() const
Determine whether this class has a copy constructor with a parameter type which is a reference to a c...
Represents a C++ namespace alias.
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
static UsingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static void CollectVisibleConversions(ASTContext &Context, CXXRecordDecl *Record, bool InVirtual, AccessSpecifier Access, const llvm::SmallPtrSet< CanQualType, 8 > &ParentHiddenTypes, ASTUnresolvedSet &Output, UnresolvedSetImpl &VOutput, llvm::SmallPtrSet< NamedDecl *, 8 > &HiddenVBaseCs)
Collect the visible conversions of a base class.
Represents C++ using-directive.
static BindingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
const LangOptions & getLangOpts() const
base_class_range vbases()
Declaration of a template function.
SourceLocation getLocation() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Represents a pack of using declarations that a single using-declarator pack-expanded into...
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
Defines the LambdaCapture class.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
method_range methods() const
QualType getType() const
Retrieves the type of the base class.