diff options
Diffstat (limited to 'clang/lib/AST/CXXInheritance.cpp')
| -rw-r--r-- | clang/lib/AST/CXXInheritance.cpp | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index e4b77edc063d..7a3e7ea4e5b8 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -128,17 +128,11 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches) const { const CXXRecordDecl *Record = this; while (true) { for (const auto &I : Record->bases()) { - const RecordType *Ty = I.getType()->getAs<RecordType>(); - if (!Ty) + const auto *Base = I.getType()->getAsCXXRecordDecl(); + if (!Base || !(Base->isBeingDefined() || Base->isCompleteDefinition())) return false; - - CXXRecordDecl *Base = cast_if_present<CXXRecordDecl>( - Ty->getOriginalDecl()->getDefinition()); - if (!Base || - (Base->isDependentContext() && - !Base->isCurrentInstantiation(Record))) { + if (Base->isDependentContext() && !Base->isCurrentInstantiation(Record)) return false; - } Queue.push_back(Base); if (!BaseMatches(Base)) @@ -196,7 +190,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, if (isDetectingVirtual() && DetectedVirtual == nullptr) { // If this is the first virtual we find, remember it. If it turns out // there is no base path here, we'll reset it later. - DetectedVirtual = BaseType->getAs<RecordType>(); + DetectedVirtual = BaseType->getAsCanonical<RecordType>(); SetVirtual = true; } } else { @@ -255,9 +249,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, const TemplateSpecializationType *TST = BaseSpec.getType()->getAs<TemplateSpecializationType>(); if (!TST) { - if (auto *RT = BaseSpec.getType()->getAs<RecordType>()) - BaseRecord = cast<CXXRecordDecl>(RT->getOriginalDecl()) - ->getDefinitionOrSelf(); + BaseRecord = BaseSpec.getType()->getAsCXXRecordDecl(); } else { TemplateName TN = TST->getTemplateName(); if (auto *TD = @@ -271,7 +263,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, BaseRecord = nullptr; } } else { - BaseRecord = cast<CXXRecordDecl>(BaseSpec.getType()->getAsRecordDecl()); + BaseRecord = BaseSpec.getType()->castAsCXXRecordDecl(); } if (BaseRecord && lookupInBases(Context, BaseRecord, BaseMatches, LookupInDependent)) { @@ -335,10 +327,7 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback BaseMatches, if (!PE.Base->isVirtual()) continue; - CXXRecordDecl *VBase = nullptr; - if (const RecordType *Record = PE.Base->getType()->getAs<RecordType>()) - VBase = cast<CXXRecordDecl>(Record->getOriginalDecl()) - ->getDefinitionOrSelf(); + auto *VBase = PE.Base->getType()->getAsCXXRecordDecl(); if (!VBase) break; @@ -347,11 +336,8 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback BaseMatches, // base is a subobject of any other path; if so, then the // declaration in this path are hidden by that patch. for (const CXXBasePath &HidingP : Paths) { - CXXRecordDecl *HidingClass = nullptr; - if (const RecordType *Record = - HidingP.back().Base->getType()->getAs<RecordType>()) - HidingClass = cast<CXXRecordDecl>(Record->getOriginalDecl()) - ->getDefinitionOrSelf(); + auto *HidingClass = + HidingP.back().Base->getType()->getAsCXXRecordDecl(); if (!HidingClass) break; @@ -407,7 +393,7 @@ bool CXXRecordDecl::hasMemberName(DeclarationName Name) const { CXXBasePaths Paths(false, false, false); return lookupInBases( [Name](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) { - return findOrdinaryMember(Specifier->getType()->getAsCXXRecordDecl(), + return findOrdinaryMember(Specifier->getType()->castAsCXXRecordDecl(), Path, Name); }, Paths); @@ -470,9 +456,7 @@ void FinalOverriderCollector::Collect(const CXXRecordDecl *RD, = ++SubobjectCount[cast<CXXRecordDecl>(RD->getCanonicalDecl())]; for (const auto &Base : RD->bases()) { - if (const RecordType *RT = Base.getType()->getAs<RecordType>()) { - const CXXRecordDecl *BaseDecl = - cast<CXXRecordDecl>(RT->getOriginalDecl())->getDefinitionOrSelf(); + if (const auto *BaseDecl = Base.getType()->getAsCXXRecordDecl()) { if (!BaseDecl->isPolymorphic()) continue; |
