summaryrefslogtreecommitdiff
path: root/clang/lib/AST/DeclCXX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/DeclCXX.cpp')
-rw-r--r--clang/lib/AST/DeclCXX.cpp51
1 files changed, 25 insertions, 26 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 50b1a1d00009..aa1f5a114659 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -216,9 +216,7 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
// Skip dependent types; we can't do any checking on them now.
if (BaseType->isDependentType())
continue;
- auto *BaseClassDecl =
- cast<CXXRecordDecl>(BaseType->castAs<RecordType>()->getOriginalDecl())
- ->getDefinitionOrSelf();
+ auto *BaseClassDecl = BaseType->castAsCXXRecordDecl();
// C++2a [class]p7:
// A standard-layout class is a class that:
@@ -1207,9 +1205,8 @@ void CXXRecordDecl::addedMember(Decl *D) {
// those because they are always unnamed.
bool IsZeroSize = Field->isZeroSize(Context);
- if (const auto *RecordTy = T->getAs<RecordType>()) {
- auto *FieldRec = cast<CXXRecordDecl>(RecordTy->getOriginalDecl());
- if (FieldRec->getDefinition()) {
+ if (auto *FieldRec = T->getAsCXXRecordDecl()) {
+ if (FieldRec->isBeingDefined() || FieldRec->isCompleteDefinition()) {
addedClassSubobject(FieldRec);
// We may need to perform overload resolution to determine whether a
@@ -1438,6 +1435,13 @@ void CXXRecordDecl::addedMember(Decl *D) {
data().StructuralIfLiteral = false;
}
+ // If this type contains any address discriminated values we should
+ // have already indicated that the only special member functions that
+ // can possibly be trivial are the default constructor and destructor.
+ if (T.hasAddressDiscriminatedPointerAuth())
+ data().HasTrivialSpecialMembers &=
+ SMF_DefaultConstructor | SMF_Destructor;
+
// C++14 [meta.unary.prop]p4:
// T is a class type [...] with [...] no non-static data members other
// than subobjects of zero size
@@ -1908,15 +1912,14 @@ static void CollectVisibleConversions(
// Collect information recursively from any base classes.
for (const auto &I : Record->bases()) {
- const auto *RT = I.getType()->getAs<RecordType>();
- if (!RT) continue;
+ const auto *Base = I.getType()->getAsCXXRecordDecl();
+ if (!Base)
+ continue;
AccessSpecifier BaseAccess
= CXXRecordDecl::MergeAccess(Access, I.getAccessSpecifier());
bool BaseInVirtual = InVirtual || I.isVirtual();
- auto *Base =
- cast<CXXRecordDecl>(RT->getOriginalDecl())->getDefinitionOrSelf();
CollectVisibleConversions(Context, Base, BaseInVirtual, BaseAccess,
*HiddenTypes, Output, VOutput, HiddenVBaseCs);
}
@@ -1951,14 +1954,13 @@ static void CollectVisibleConversions(ASTContext &Context,
// Recursively collect conversions from base classes.
for (const auto &I : Record->bases()) {
- const auto *RT = I.getType()->getAs<RecordType>();
- if (!RT) continue;
+ const auto *Base = I.getType()->getAsCXXRecordDecl();
+ if (!Base)
+ continue;
- CollectVisibleConversions(
- Context,
- cast<CXXRecordDecl>(RT->getOriginalDecl())->getDefinitionOrSelf(),
- I.isVirtual(), I.getAccessSpecifier(), HiddenTypes, Output, VBaseCs,
- HiddenVBaseCs);
+ CollectVisibleConversions(Context, Base, I.isVirtual(),
+ I.getAccessSpecifier(), HiddenTypes, Output,
+ VBaseCs, HiddenVBaseCs);
}
// Add any unhidden conversions provided by virtual bases.
@@ -2312,7 +2314,7 @@ bool CXXRecordDecl::mayBeAbstract() const {
for (const auto &B : bases()) {
const auto *BaseDecl = cast<CXXRecordDecl>(
- B.getType()->castAs<RecordType>()->getOriginalDecl());
+ B.getType()->castAsCanonical<RecordType>()->getOriginalDecl());
if (BaseDecl->isAbstract())
return true;
}
@@ -2472,11 +2474,9 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD,
};
for (const auto &I : RD->bases()) {
- const RecordType *RT = I.getType()->getAs<RecordType>();
- if (!RT)
+ const auto *Base = I.getType()->getAsCXXRecordDecl();
+ if (!Base)
continue;
- const auto *Base =
- cast<CXXRecordDecl>(RT->getOriginalDecl())->getDefinitionOrSelf();
if (CXXMethodDecl *D = this->getCorrespondingMethodInClass(Base))
AddFinalOverrider(D);
}
@@ -3437,13 +3437,12 @@ SourceRange UsingDecl::getSourceRange() const {
void UsingEnumDecl::anchor() {}
UsingEnumDecl *UsingEnumDecl::Create(ASTContext &C, DeclContext *DC,
- SourceLocation UL,
- SourceLocation EL,
+ SourceLocation UL, SourceLocation EL,
SourceLocation NL,
TypeSourceInfo *EnumType) {
- assert(isa<EnumDecl>(EnumType->getType()->getAsTagDecl()));
return new (C, DC)
- UsingEnumDecl(DC, EnumType->getType()->getAsTagDecl()->getDeclName(), UL, EL, NL, EnumType);
+ UsingEnumDecl(DC, EnumType->getType()->castAsEnumDecl()->getDeclName(),
+ UL, EL, NL, EnumType);
}
UsingEnumDecl *UsingEnumDecl::CreateDeserialized(ASTContext &C,