From 7f55a455d1f7c55e8602e555828f5bcdfa20d819 Mon Sep 17 00:00:00 2001 From: Timur Iskhodzhanov Date: Tue, 2 Jul 2013 16:00:40 +0000 Subject: [PATCH] Simplify getting CXXRecordDecl from a base iterator llvm-svn: 185438 --- clang/lib/AST/VTableBuilder.cpp | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp index 90087b8..6c968bf 100644 --- a/clang/lib/AST/VTableBuilder.cpp +++ b/clang/lib/AST/VTableBuilder.cpp @@ -224,8 +224,7 @@ static BaseOffset ComputeBaseOffset(ASTContext &Context, if (Element.Base->isVirtual()) { NonVirtualStart = I; QualType VBaseType = Element.Base->getType(); - VirtualBase = - cast(VBaseType->getAs()->getDecl()); + VirtualBase = VBaseType->getAsCXXRecordDecl(); break; } } @@ -237,8 +236,7 @@ static BaseOffset ComputeBaseOffset(ASTContext &Context, // Check the base class offset. const ASTRecordLayout &Layout = Context.getASTRecordLayout(Element.Class); - const RecordType *BaseType = Element.Base->getType()->getAs(); - const CXXRecordDecl *Base = cast(BaseType->getDecl()); + const CXXRecordDecl *Base = Element.Base->getType()->getAsCXXRecordDecl(); NonVirtualOffset += Layout.getBaseClassOffset(Base); } @@ -341,8 +339,7 @@ FinalOverriders::ComputeBaseOffsets(BaseSubobject Base, bool IsVirtual, // Traverse our bases. for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), E = RD->bases_end(); I != E; ++I) { - const CXXRecordDecl *BaseDecl = - cast(I->getType()->getAs()->getDecl()); + const CXXRecordDecl *BaseDecl = I->getType()->getAsCXXRecordDecl(); CharUnits BaseOffset; CharUnits BaseOffsetInLayoutClass; @@ -379,8 +376,7 @@ void FinalOverriders::dump(raw_ostream &Out, BaseSubobject Base, for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), E = RD->bases_end(); I != E; ++I) { - const CXXRecordDecl *BaseDecl = - cast(I->getType()->getAs()->getDecl()); + const CXXRecordDecl *BaseDecl = I->getType()->getAsCXXRecordDecl(); // Ignore bases that don't have any virtual member functions. if (!BaseDecl->isPolymorphic()) @@ -725,8 +721,7 @@ void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base, if (I->isVirtual()) continue; - const CXXRecordDecl *BaseDecl = - cast(I->getType()->getAs()->getDecl()); + const CXXRecordDecl *BaseDecl = I->getType()->getAsCXXRecordDecl(); if (BaseDecl == PrimaryBase) continue; @@ -748,8 +743,7 @@ VCallAndVBaseOffsetBuilder::AddVBaseOffsets(const CXXRecordDecl *RD, // Add vbase offsets. for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), E = RD->bases_end(); I != E; ++I) { - const CXXRecordDecl *BaseDecl = - cast(I->getType()->getAs()->getDecl()); + const CXXRecordDecl *BaseDecl = I->getType()->getAsCXXRecordDecl(); // Check if this is a virtual base that we haven't visited before. if (I->isVirtual() && VisitedVirtualBases.insert(BaseDecl)) { @@ -1772,8 +1766,7 @@ void VTableBuilder::LayoutSecondaryVTables(BaseSubobject Base, if (I->isVirtual()) continue; - const CXXRecordDecl *BaseDecl = - cast(I->getType()->getAs()->getDecl()); + const CXXRecordDecl *BaseDecl = I->getType()->getAsCXXRecordDecl(); // Ignore bases that don't have a vtable. if (!BaseDecl->isDynamicClass()) @@ -1849,8 +1842,7 @@ VTableBuilder::DeterminePrimaryVirtualBases(const CXXRecordDecl *RD, // Traverse bases, looking for more primary virtual bases. for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), E = RD->bases_end(); I != E; ++I) { - const CXXRecordDecl *BaseDecl = - cast(I->getType()->getAs()->getDecl()); + const CXXRecordDecl *BaseDecl = I->getType()->getAsCXXRecordDecl(); CharUnits BaseOffsetInLayoutClass; @@ -1881,8 +1873,7 @@ VTableBuilder::LayoutVTablesForVirtualBases(const CXXRecordDecl *RD, // the classes for which they are primary). for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), E = RD->bases_end(); I != E; ++I) { - const CXXRecordDecl *BaseDecl = - cast(I->getType()->getAs()->getDecl()); + const CXXRecordDecl *BaseDecl = I->getType()->getAsCXXRecordDecl(); // Check if this base needs a vtable. (If it's virtual, not a primary base // of some other class, and we haven't visited it before). @@ -2362,9 +2353,8 @@ void VTableContext::ComputeVTableRelatedInformation(const CXXRecordDecl *RD) { if (!RD->getNumVBases()) return; - const RecordType *VBaseRT = - RD->vbases_begin()->getType()->getAs(); - const CXXRecordDecl *VBase = cast(VBaseRT->getDecl()); + const CXXRecordDecl *VBase = + RD->vbases_begin()->getType()->getAsCXXRecordDecl(); if (VirtualBaseClassOffsetOffsets.count(std::make_pair(RD, VBase))) return; -- 2.7.4