forked from OSchip/llvm-project
[C++11] Replacing CXXRecordDecl iterators vbases_begin() and vbases_end() with iterator_range vbases(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203808
This commit is contained in:
parent
996e992bf2
commit
445a939db8
|
@ -689,6 +689,13 @@ public:
|
|||
/// \brief Retrieves the number of virtual base classes of this class.
|
||||
unsigned getNumVBases() const { return data().NumVBases; }
|
||||
|
||||
base_class_range vbases() {
|
||||
return base_class_range(vbases_begin(), vbases_end());
|
||||
}
|
||||
base_class_const_range vbases() const {
|
||||
return base_class_const_range(vbases_begin(), vbases_end());
|
||||
}
|
||||
|
||||
base_class_iterator vbases_begin() { return data().getVBases(); }
|
||||
base_class_const_iterator vbases_begin() const { return data().getVBases(); }
|
||||
base_class_iterator vbases_end() { return vbases_begin() + data().NumVBases; }
|
||||
|
|
|
@ -496,11 +496,10 @@ comments::FullComment *ASTContext::getCommentForDecl(
|
|||
}
|
||||
}
|
||||
// Check virtual bases.
|
||||
for (CXXRecordDecl::base_class_const_iterator I =
|
||||
RD->vbases_begin(), E = RD->vbases_end(); I != E; ++I) {
|
||||
if (I->getAccessSpecifier() != AS_public)
|
||||
for (const auto &I : RD->vbases()) {
|
||||
if (I.getAccessSpecifier() != AS_public)
|
||||
continue;
|
||||
QualType Ty = I->getType();
|
||||
QualType Ty = I.getType();
|
||||
if (Ty.isNull())
|
||||
continue;
|
||||
if (const CXXRecordDecl *VirtualBase = Ty->getAsCXXRecordDecl()) {
|
||||
|
@ -5617,10 +5616,8 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
|
|||
}
|
||||
|
||||
if (CXXRec && includeVBases) {
|
||||
for (CXXRecordDecl::base_class_iterator
|
||||
BI = CXXRec->vbases_begin(),
|
||||
BE = CXXRec->vbases_end(); BI != BE; ++BI) {
|
||||
CXXRecordDecl *base = BI->getType()->getAsCXXRecordDecl();
|
||||
for (const auto &BI : CXXRec->vbases()) {
|
||||
CXXRecordDecl *base = BI.getType()->getAsCXXRecordDecl();
|
||||
if (base->isEmpty())
|
||||
continue;
|
||||
uint64_t offs = toBits(layout.getVBaseClassOffset(base));
|
||||
|
|
|
@ -202,19 +202,17 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
|
|||
data().HasNonLiteralTypeFieldsOrBases = true;
|
||||
|
||||
// Now go through all virtual bases of this base and add them.
|
||||
for (CXXRecordDecl::base_class_iterator VBase =
|
||||
BaseClassDecl->vbases_begin(),
|
||||
E = BaseClassDecl->vbases_end(); VBase != E; ++VBase) {
|
||||
for (const auto &VBase : BaseClassDecl->vbases()) {
|
||||
// Add this base if it's not already in the list.
|
||||
if (SeenVBaseTypes.insert(C.getCanonicalType(VBase->getType()))) {
|
||||
VBases.push_back(VBase);
|
||||
if (SeenVBaseTypes.insert(C.getCanonicalType(VBase.getType()))) {
|
||||
VBases.push_back(&VBase);
|
||||
|
||||
// C++11 [class.copy]p8:
|
||||
// The implicitly-declared copy constructor for a class X will have
|
||||
// the form 'X::X(const X&)' if each [...] virtual base class B of X
|
||||
// has a copy constructor whose first parameter is of type
|
||||
// 'const B&' or 'const volatile B&' [...]
|
||||
if (CXXRecordDecl *VBaseDecl = VBase->getType()->getAsCXXRecordDecl())
|
||||
if (CXXRecordDecl *VBaseDecl = VBase.getType()->getAsCXXRecordDecl())
|
||||
if (!VBaseDecl->hasCopyConstructorWithConstParam())
|
||||
data().ImplicitCopyConstructorHasConstParam = false;
|
||||
}
|
||||
|
|
|
@ -359,10 +359,9 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
|
|||
|
||||
if (RD == Class) {
|
||||
// This is the most derived class, traverse virtual bases as well.
|
||||
for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),
|
||||
E = RD->vbases_end(); I != E; ++I) {
|
||||
for (const auto &I : RD->vbases()) {
|
||||
const CXXRecordDecl *VBaseDecl =
|
||||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
cast<CXXRecordDecl>(I.getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
CharUnits VBaseOffset = Offset + Layout.getVBaseClassOffset(VBaseDecl);
|
||||
if (!CanPlaceFieldSubobjectAtOffset(VBaseDecl, Class, VBaseOffset))
|
||||
|
@ -469,10 +468,9 @@ void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD,
|
|||
|
||||
if (RD == Class) {
|
||||
// This is the most derived class, traverse virtual bases as well.
|
||||
for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),
|
||||
E = RD->vbases_end(); I != E; ++I) {
|
||||
for (const auto &I : RD->vbases()) {
|
||||
const CXXRecordDecl *VBaseDecl =
|
||||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
cast<CXXRecordDecl>(I.getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
CharUnits VBaseOffset = Offset + Layout.getVBaseClassOffset(VBaseDecl);
|
||||
UpdateEmptyFieldSubobjects(VBaseDecl, Class, VBaseOffset);
|
||||
|
@ -1324,10 +1322,9 @@ void RecordLayoutBuilder::Layout(const CXXRecordDecl *RD) {
|
|||
}
|
||||
|
||||
// And all virtual bases.
|
||||
for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),
|
||||
E = RD->vbases_end(); I != E; ++I) {
|
||||
for (const auto &I : RD->vbases()) {
|
||||
const CXXRecordDecl *BaseDecl =
|
||||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
cast<CXXRecordDecl>(I.getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
assert(VBases.count(BaseDecl) && "Did not find base offset!");
|
||||
}
|
||||
|
@ -2658,10 +2655,8 @@ void MicrosoftRecordLayoutBuilder::layoutVirtualBases(const CXXRecordDecl *RD) {
|
|||
// The alignment of the vtordisp is at least the required alignment of the
|
||||
// entire record. This requirement may be present to support vtordisp
|
||||
// injection.
|
||||
for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(),
|
||||
e = RD->vbases_end();
|
||||
i != e; ++i) {
|
||||
const CXXRecordDecl *BaseDecl = i->getType()->getAsCXXRecordDecl();
|
||||
for (const auto &I : RD->vbases()) {
|
||||
const CXXRecordDecl *BaseDecl = I.getType()->getAsCXXRecordDecl();
|
||||
const ASTRecordLayout &BaseLayout = Context.getASTRecordLayout(BaseDecl);
|
||||
RequiredAlignment =
|
||||
std::max(RequiredAlignment, BaseLayout.getRequiredAlignment());
|
||||
|
@ -2672,10 +2667,8 @@ void MicrosoftRecordLayoutBuilder::layoutVirtualBases(const CXXRecordDecl *RD) {
|
|||
computeVtorDispSet(RD);
|
||||
// Iterate through the virtual bases and lay them out.
|
||||
const ASTRecordLayout* PreviousBaseLayout = 0;
|
||||
for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(),
|
||||
e = RD->vbases_end();
|
||||
i != e; ++i) {
|
||||
const CXXRecordDecl *BaseDecl = i->getType()->getAsCXXRecordDecl();
|
||||
for (const auto &I : RD->vbases()) {
|
||||
const CXXRecordDecl *BaseDecl = I.getType()->getAsCXXRecordDecl();
|
||||
const ASTRecordLayout &BaseLayout = Context.getASTRecordLayout(BaseDecl);
|
||||
bool HasVtordisp = HasVtordispSet.count(BaseDecl);
|
||||
// If the last field we laid out was a non-zero length bitfield then add
|
||||
|
@ -2747,10 +2740,8 @@ MicrosoftRecordLayoutBuilder::computeVtorDispSet(const CXXRecordDecl *RD) {
|
|||
// /vd2 or #pragma vtordisp(2): Always use vtordisps for virtual bases with
|
||||
// vftables.
|
||||
if (RD->getMSVtorDispMode() == MSVtorDispAttr::ForVFTable) {
|
||||
for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),
|
||||
E = RD->vbases_end();
|
||||
I != E; ++I) {
|
||||
const CXXRecordDecl *BaseDecl = I->getType()->getAsCXXRecordDecl();
|
||||
for (const auto &I : RD->vbases()) {
|
||||
const CXXRecordDecl *BaseDecl = I.getType()->getAsCXXRecordDecl();
|
||||
const ASTRecordLayout &Layout = Context.getASTRecordLayout(BaseDecl);
|
||||
if (Layout.hasExtendableVFPtr())
|
||||
HasVtordispSet.insert(BaseDecl);
|
||||
|
@ -2806,10 +2797,8 @@ MicrosoftRecordLayoutBuilder::computeVtorDispSet(const CXXRecordDecl *RD) {
|
|||
}
|
||||
// Re-check all of our vbases for vtordisp requirements (in case their
|
||||
// non-virtual bases have vtordisp requirements).
|
||||
for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(),
|
||||
e = RD->vbases_end();
|
||||
i != e; ++i) {
|
||||
const CXXRecordDecl *BaseDecl = i->getType()->getAsCXXRecordDecl();
|
||||
for (const auto &I : RD->vbases()) {
|
||||
const CXXRecordDecl *BaseDecl = I.getType()->getAsCXXRecordDecl();
|
||||
if (!HasVtordispSet.count(BaseDecl) &&
|
||||
RequiresVtordisp(HasVtordispSet, BaseDecl))
|
||||
HasVtordispSet.insert(BaseDecl);
|
||||
|
@ -3134,11 +3123,10 @@ static void DumpCXXRecordLayout(raw_ostream &OS,
|
|||
// Dump virtual bases.
|
||||
const ASTRecordLayout::VBaseOffsetsMapTy &vtordisps =
|
||||
Layout.getVBaseOffsetsMap();
|
||||
for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),
|
||||
E = RD->vbases_end(); I != E; ++I) {
|
||||
assert(I->isVirtual() && "Found non-virtual class!");
|
||||
for (const auto &I : RD->vbases()) {
|
||||
assert(I.isVirtual() && "Found non-virtual class!");
|
||||
const CXXRecordDecl *VBase =
|
||||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
cast<CXXRecordDecl>(I.getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
CharUnits VBaseOffset = Offset + Layout.getVBaseClassOffset(VBase);
|
||||
|
||||
|
|
|
@ -3221,10 +3221,8 @@ void MicrosoftVTableContext::computeVTablePaths(bool ForVBTables,
|
|||
|
||||
// After visiting any direct base, we've transitively visited all of its
|
||||
// morally virtual bases.
|
||||
for (CXXRecordDecl::base_class_const_iterator II = Base->vbases_begin(),
|
||||
EE = Base->vbases_end();
|
||||
II != EE; ++II)
|
||||
VBasesSeen.insert(II->getType()->getAsCXXRecordDecl());
|
||||
for (const auto &I : Base->vbases())
|
||||
VBasesSeen.insert(I.getType()->getAsCXXRecordDecl());
|
||||
}
|
||||
|
||||
// Sort the paths into buckets, and if any of them are ambiguous, extend all
|
||||
|
@ -3407,10 +3405,8 @@ const VirtualBaseInfo *MicrosoftVTableContext::computeVBTableRelatedInformation(
|
|||
// New vbases are added to the end of the vbtable.
|
||||
// Skip the self entry and vbases visited in the non-virtual base, if any.
|
||||
unsigned VBTableIndex = 1 + VBI->VBTableIndices.size();
|
||||
for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),
|
||||
E = RD->vbases_end();
|
||||
I != E; ++I) {
|
||||
const CXXRecordDecl *CurVBase = I->getType()->getAsCXXRecordDecl();
|
||||
for (const auto &I : RD->vbases()) {
|
||||
const CXXRecordDecl *CurVBase = I.getType()->getAsCXXRecordDecl();
|
||||
if (!VBI->VBTableIndices.count(CurVBase))
|
||||
VBI->VBTableIndices[CurVBase] = VBTableIndex++;
|
||||
}
|
||||
|
|
|
@ -880,12 +880,11 @@ void CFGBuilder::addImplicitDtorsForDestructor(const CXXDestructorDecl *DD) {
|
|||
const CXXRecordDecl *RD = DD->getParent();
|
||||
|
||||
// At the end destroy virtual base objects.
|
||||
for (CXXRecordDecl::base_class_const_iterator VI = RD->vbases_begin(),
|
||||
VE = RD->vbases_end(); VI != VE; ++VI) {
|
||||
const CXXRecordDecl *CD = VI->getType()->getAsCXXRecordDecl();
|
||||
for (const auto &VI : RD->vbases()) {
|
||||
const CXXRecordDecl *CD = VI.getType()->getAsCXXRecordDecl();
|
||||
if (!CD->hasTrivialDestructor()) {
|
||||
autoCreateBlock();
|
||||
appendBaseDtor(Block, VI);
|
||||
appendBaseDtor(Block, &VI);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1213,11 +1213,9 @@ HasTrivialDestructorBody(ASTContext &Context,
|
|||
|
||||
if (BaseClassDecl == MostDerivedClassDecl) {
|
||||
// Check virtual bases.
|
||||
for (CXXRecordDecl::base_class_const_iterator I =
|
||||
BaseClassDecl->vbases_begin(), E = BaseClassDecl->vbases_end();
|
||||
I != E; ++I) {
|
||||
for (const auto &I : BaseClassDecl->vbases()) {
|
||||
const CXXRecordDecl *VirtualBase =
|
||||
cast<CXXRecordDecl>(I->getType()->castAs<RecordType>()->getDecl());
|
||||
cast<CXXRecordDecl>(I.getType()->castAs<RecordType>()->getDecl());
|
||||
if (!HasTrivialDestructorBody(Context, VirtualBase,
|
||||
MostDerivedClassDecl))
|
||||
return false;
|
||||
|
@ -1460,10 +1458,7 @@ void CodeGenFunction::EnterDtorCleanups(const CXXDestructorDecl *DD,
|
|||
|
||||
// We push them in the forward order so that they'll be popped in
|
||||
// the reverse order.
|
||||
for (CXXRecordDecl::base_class_const_iterator I =
|
||||
ClassDecl->vbases_begin(), E = ClassDecl->vbases_end();
|
||||
I != E; ++I) {
|
||||
const CXXBaseSpecifier &Base = *I;
|
||||
for (const auto &Base : ClassDecl->vbases()) {
|
||||
CXXRecordDecl *BaseClassDecl
|
||||
= cast<CXXRecordDecl>(Base.getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
|
|
|
@ -1372,10 +1372,9 @@ static llvm::Constant *EmitNullConstant(CodeGenModule &CGM,
|
|||
|
||||
// Fill in the virtual bases, if we're working with the complete object.
|
||||
if (asCompleteObject) {
|
||||
for (CXXRecordDecl::base_class_const_iterator
|
||||
I = record->vbases_begin(), E = record->vbases_end(); I != E; ++I) {
|
||||
for (const auto &I : record->vbases()) {
|
||||
const CXXRecordDecl *base =
|
||||
cast<CXXRecordDecl>(I->getType()->castAs<RecordType>()->getDecl());
|
||||
cast<CXXRecordDecl>(I.getType()->castAs<RecordType>()->getDecl());
|
||||
|
||||
// Ignore empty bases.
|
||||
if (base->isEmpty())
|
||||
|
|
|
@ -442,10 +442,8 @@ void CGRecordLowering::accumulateVPtrs() {
|
|||
void CGRecordLowering::accumulateVBases() {
|
||||
Members.push_back(MemberInfo(Layout.getNonVirtualSize(),
|
||||
MemberInfo::Scissor, 0, RD));
|
||||
for (CXXRecordDecl::base_class_const_iterator Base = RD->vbases_begin(),
|
||||
BaseEnd = RD->vbases_end();
|
||||
Base != BaseEnd; ++Base) {
|
||||
const CXXRecordDecl *BaseDecl = Base->getType()->getAsCXXRecordDecl();
|
||||
for (const auto &Base : RD->vbases()) {
|
||||
const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl();
|
||||
if (BaseDecl->isEmpty())
|
||||
continue;
|
||||
CharUnits Offset = Layout.getVBaseClassOffset(BaseDecl);
|
||||
|
|
|
@ -1118,10 +1118,8 @@ void MicrosoftCXXABI::emitVBTableDefinition(const VPtrInfo &VBT,
|
|||
Offsets[0] = llvm::ConstantInt::get(CGM.IntTy, -VBPtrOffset.getQuantity());
|
||||
|
||||
MicrosoftVTableContext &Context = CGM.getMicrosoftVTableContext();
|
||||
for (CXXRecordDecl::base_class_const_iterator I = ReusingBase->vbases_begin(),
|
||||
E = ReusingBase->vbases_end();
|
||||
I != E; ++I) {
|
||||
const CXXRecordDecl *VBase = I->getType()->getAsCXXRecordDecl();
|
||||
for (const auto &I : ReusingBase->vbases()) {
|
||||
const CXXRecordDecl *VBase = I.getType()->getAsCXXRecordDecl();
|
||||
CharUnits Offset = DerivedLayout.getVBaseClassOffset(VBase);
|
||||
assert(!Offset.isNegative());
|
||||
|
||||
|
|
|
@ -4266,21 +4266,19 @@ void Sema::CodeCompleteConstructorInitializer(
|
|||
}
|
||||
|
||||
// Add completions for virtual base classes.
|
||||
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->vbases_begin(),
|
||||
BaseEnd = ClassDecl->vbases_end();
|
||||
Base != BaseEnd; ++Base) {
|
||||
if (!InitializedBases.insert(Context.getCanonicalType(Base->getType()))) {
|
||||
for (const auto &Base : ClassDecl->vbases()) {
|
||||
if (!InitializedBases.insert(Context.getCanonicalType(Base.getType()))) {
|
||||
SawLastInitializer
|
||||
= !Initializers.empty() &&
|
||||
Initializers.back()->isBaseInitializer() &&
|
||||
Context.hasSameUnqualifiedType(Base->getType(),
|
||||
Context.hasSameUnqualifiedType(Base.getType(),
|
||||
QualType(Initializers.back()->getBaseClass(), 0));
|
||||
continue;
|
||||
}
|
||||
|
||||
Builder.AddTypedTextChunk(
|
||||
Builder.getAllocator().CopyString(
|
||||
Base->getType().getAsString(Policy)));
|
||||
Base.getType().getAsString(Policy)));
|
||||
Builder.AddChunk(CodeCompletionString::CK_LeftParen);
|
||||
Builder.AddPlaceholderChunk("args");
|
||||
Builder.AddChunk(CodeCompletionString::CK_RightParen);
|
||||
|
|
|
@ -761,10 +761,9 @@ bool Sema::CheckConstexprFunctionDecl(const FunctionDecl *NewFD) {
|
|||
Diag(NewFD->getLocation(), diag::err_constexpr_virtual_base)
|
||||
<< isa<CXXConstructorDecl>(NewFD)
|
||||
<< getRecordDiagFromTagKind(RD->getTagKind()) << RD->getNumVBases();
|
||||
for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),
|
||||
E = RD->vbases_end(); I != E; ++I)
|
||||
Diag(I->getLocStart(),
|
||||
diag::note_constexpr_virtual_base_here) << I->getSourceRange();
|
||||
for (const auto &I : RD->vbases())
|
||||
Diag(I.getLocStart(),
|
||||
diag::note_constexpr_virtual_base_here) << I.getSourceRange();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3577,11 +3576,9 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
|
|||
}
|
||||
|
||||
// Push virtual bases before others.
|
||||
for (CXXRecordDecl::base_class_iterator VBase = ClassDecl->vbases_begin(),
|
||||
E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
|
||||
|
||||
for (auto &VBase : ClassDecl->vbases()) {
|
||||
if (CXXCtorInitializer *Value
|
||||
= Info.AllBaseFields.lookup(VBase->getType()->getAs<RecordType>())) {
|
||||
= Info.AllBaseFields.lookup(VBase.getType()->getAs<RecordType>())) {
|
||||
// [class.base.init]p7, per DR257:
|
||||
// A mem-initializer where the mem-initializer-id names a virtual base
|
||||
// class is ignored during execution of a constructor of any class that
|
||||
|
@ -3590,7 +3587,7 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
|
|||
// FIXME: Provide a fixit to remove the base specifier. This requires
|
||||
// tracking the location of the associated comma for a base specifier.
|
||||
Diag(Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
|
||||
<< VBase->getType() << ClassDecl;
|
||||
<< VBase.getType() << ClassDecl;
|
||||
DiagnoseAbstractType(ClassDecl);
|
||||
}
|
||||
|
||||
|
@ -3600,10 +3597,10 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
|
|||
// If a given [...] base class is not named by a mem-initializer-id
|
||||
// [...] and the entity is not a virtual base class of an abstract
|
||||
// class, then [...] the entity is default-initialized.
|
||||
bool IsInheritedVirtualBase = !DirectVBases.count(VBase);
|
||||
bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
|
||||
CXXCtorInitializer *CXXBaseInit;
|
||||
if (BuildImplicitBaseInitializer(*this, Constructor, Info.IIK,
|
||||
VBase, IsInheritedVirtualBase,
|
||||
&VBase, IsInheritedVirtualBase,
|
||||
CXXBaseInit)) {
|
||||
HadError = true;
|
||||
continue;
|
||||
|
@ -3746,10 +3743,8 @@ static void DiagnoseBaseOrMemInitializerOrder(
|
|||
const CXXRecordDecl *ClassDecl = Constructor->getParent();
|
||||
|
||||
// 1. Virtual bases.
|
||||
for (CXXRecordDecl::base_class_const_iterator VBase =
|
||||
ClassDecl->vbases_begin(),
|
||||
E = ClassDecl->vbases_end(); VBase != E; ++VBase)
|
||||
IdealInitKeys.push_back(GetKeyForBase(SemaRef.Context, VBase->getType()));
|
||||
for (const auto &VBase : ClassDecl->vbases())
|
||||
IdealInitKeys.push_back(GetKeyForBase(SemaRef.Context, VBase.getType()));
|
||||
|
||||
// 2. Non-virtual bases.
|
||||
for (const auto &Base : ClassDecl->bases()) {
|
||||
|
@ -4026,11 +4021,9 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location,
|
|||
}
|
||||
|
||||
// Virtual bases.
|
||||
for (CXXRecordDecl::base_class_iterator VBase = ClassDecl->vbases_begin(),
|
||||
E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
|
||||
|
||||
for (const auto &VBase : ClassDecl->vbases()) {
|
||||
// Bases are always records in a well-formed non-dependent class.
|
||||
const RecordType *RT = VBase->getType()->castAs<RecordType>();
|
||||
const RecordType *RT = VBase.getType()->castAs<RecordType>();
|
||||
|
||||
// Ignore direct virtual bases.
|
||||
if (DirectVirtualBases.count(RT))
|
||||
|
@ -4048,11 +4041,11 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location,
|
|||
if (CheckDestructorAccess(
|
||||
ClassDecl->getLocation(), Dtor,
|
||||
PDiag(diag::err_access_dtor_vbase)
|
||||
<< Context.getTypeDeclType(ClassDecl) << VBase->getType(),
|
||||
<< Context.getTypeDeclType(ClassDecl) << VBase.getType(),
|
||||
Context.getTypeDeclType(ClassDecl)) ==
|
||||
AR_accessible) {
|
||||
CheckDerivedToBaseConversion(
|
||||
Context.getTypeDeclType(ClassDecl), VBase->getType(),
|
||||
Context.getTypeDeclType(ClassDecl), VBase.getType(),
|
||||
diag::err_access_dtor_vbase, 0, ClassDecl->getLocation(),
|
||||
SourceRange(), DeclarationName(), 0);
|
||||
}
|
||||
|
@ -5355,10 +5348,8 @@ bool Sema::ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM,
|
|||
// Per DR1611, do not consider virtual bases of constructors of abstract
|
||||
// classes, since we are not going to construct them.
|
||||
if (!RD->isAbstract() || !SMI.IsConstructor) {
|
||||
for (CXXRecordDecl::base_class_iterator BI = RD->vbases_begin(),
|
||||
BE = RD->vbases_end();
|
||||
BI != BE; ++BI)
|
||||
if (SMI.shouldDeleteForBase(BI))
|
||||
for (auto &BI : RD->vbases())
|
||||
if (SMI.shouldDeleteForBase(&BI))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8005,16 +7996,14 @@ Sema::ComputeDefaultedDefaultCtorExceptionSpec(SourceLocation Loc,
|
|||
}
|
||||
|
||||
// Virtual base-class constructors.
|
||||
for (CXXRecordDecl::base_class_iterator B = ClassDecl->vbases_begin(),
|
||||
BEnd = ClassDecl->vbases_end();
|
||||
B != BEnd; ++B) {
|
||||
if (const RecordType *BaseType = B->getType()->getAs<RecordType>()) {
|
||||
for (const auto &B : ClassDecl->vbases()) {
|
||||
if (const RecordType *BaseType = B.getType()->getAs<RecordType>()) {
|
||||
CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
|
||||
CXXConstructorDecl *Constructor = LookupDefaultConstructor(BaseClassDecl);
|
||||
// If this is a deleted function, add it anyway. This might be conformant
|
||||
// with the standard. This might not. I'm not sure. It might not matter.
|
||||
if (Constructor)
|
||||
ExceptSpec.CalledDecl(B->getLocStart(), Constructor);
|
||||
ExceptSpec.CalledDecl(B.getLocStart(), Constructor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8090,16 +8079,14 @@ Sema::ComputeInheritingCtorExceptionSpec(CXXConstructorDecl *CD) {
|
|||
}
|
||||
|
||||
// Virtual base-class constructors.
|
||||
for (CXXRecordDecl::base_class_iterator B = ClassDecl->vbases_begin(),
|
||||
BEnd = ClassDecl->vbases_end();
|
||||
B != BEnd; ++B) {
|
||||
if (const RecordType *BaseType = B->getType()->getAs<RecordType>()) {
|
||||
for (const auto &B : ClassDecl->vbases()) {
|
||||
if (const RecordType *BaseType = B.getType()->getAs<RecordType>()) {
|
||||
CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
|
||||
if (BaseClassDecl == InheritedDecl)
|
||||
continue;
|
||||
CXXConstructorDecl *Constructor = LookupDefaultConstructor(BaseClassDecl);
|
||||
if (Constructor)
|
||||
ExceptSpec.CalledDecl(B->getLocStart(), Constructor);
|
||||
ExceptSpec.CalledDecl(B.getLocStart(), Constructor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8599,11 +8586,9 @@ Sema::ComputeDefaultedDtorExceptionSpec(CXXMethodDecl *MD) {
|
|||
}
|
||||
|
||||
// Virtual base-class destructors.
|
||||
for (CXXRecordDecl::base_class_iterator B = ClassDecl->vbases_begin(),
|
||||
BEnd = ClassDecl->vbases_end();
|
||||
B != BEnd; ++B) {
|
||||
if (const RecordType *BaseType = B->getType()->getAs<RecordType>())
|
||||
ExceptSpec.CalledDecl(B->getLocStart(),
|
||||
for (const auto &B : ClassDecl->vbases()) {
|
||||
if (const RecordType *BaseType = B.getType()->getAs<RecordType>())
|
||||
ExceptSpec.CalledDecl(B.getLocStart(),
|
||||
LookupDestructor(cast<CXXRecordDecl>(BaseType->getDecl())));
|
||||
}
|
||||
|
||||
|
@ -9204,14 +9189,12 @@ Sema::ComputeDefaultedCopyAssignmentExceptionSpec(CXXMethodDecl *MD) {
|
|||
ExceptSpec.CalledDecl(Base.getLocStart(), CopyAssign);
|
||||
}
|
||||
|
||||
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->vbases_begin(),
|
||||
BaseEnd = ClassDecl->vbases_end();
|
||||
Base != BaseEnd; ++Base) {
|
||||
for (const auto &Base : ClassDecl->vbases()) {
|
||||
CXXRecordDecl *BaseClassDecl
|
||||
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
|
||||
= cast<CXXRecordDecl>(Base.getType()->getAs<RecordType>()->getDecl());
|
||||
if (CXXMethodDecl *CopyAssign = LookupCopyingAssignment(BaseClassDecl,
|
||||
ArgQuals, false, 0))
|
||||
ExceptSpec.CalledDecl(Base->getLocStart(), CopyAssign);
|
||||
ExceptSpec.CalledDecl(Base.getLocStart(), CopyAssign);
|
||||
}
|
||||
|
||||
for (const auto *Field : ClassDecl->fields()) {
|
||||
|
@ -9586,14 +9569,12 @@ Sema::ComputeDefaultedMoveAssignmentExceptionSpec(CXXMethodDecl *MD) {
|
|||
ExceptSpec.CalledDecl(Base.getLocStart(), MoveAssign);
|
||||
}
|
||||
|
||||
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->vbases_begin(),
|
||||
BaseEnd = ClassDecl->vbases_end();
|
||||
Base != BaseEnd; ++Base) {
|
||||
for (const auto &Base : ClassDecl->vbases()) {
|
||||
CXXRecordDecl *BaseClassDecl
|
||||
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
|
||||
= cast<CXXRecordDecl>(Base.getType()->getAs<RecordType>()->getDecl());
|
||||
if (CXXMethodDecl *MoveAssign = LookupMovingAssignment(BaseClassDecl,
|
||||
0, false, 0))
|
||||
ExceptSpec.CalledDecl(Base->getLocStart(), MoveAssign);
|
||||
ExceptSpec.CalledDecl(Base.getLocStart(), MoveAssign);
|
||||
}
|
||||
|
||||
for (const auto *Field : ClassDecl->fields()) {
|
||||
|
@ -10001,15 +9982,12 @@ Sema::ComputeDefaultedCopyCtorExceptionSpec(CXXMethodDecl *MD) {
|
|||
LookupCopyingConstructor(BaseClassDecl, Quals))
|
||||
ExceptSpec.CalledDecl(Base.getLocStart(), CopyConstructor);
|
||||
}
|
||||
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->vbases_begin(),
|
||||
BaseEnd = ClassDecl->vbases_end();
|
||||
Base != BaseEnd;
|
||||
++Base) {
|
||||
for (const auto &Base : ClassDecl->vbases()) {
|
||||
CXXRecordDecl *BaseClassDecl
|
||||
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
|
||||
= cast<CXXRecordDecl>(Base.getType()->getAs<RecordType>()->getDecl());
|
||||
if (CXXConstructorDecl *CopyConstructor =
|
||||
LookupCopyingConstructor(BaseClassDecl, Quals))
|
||||
ExceptSpec.CalledDecl(Base->getLocStart(), CopyConstructor);
|
||||
ExceptSpec.CalledDecl(Base.getLocStart(), CopyConstructor);
|
||||
}
|
||||
for (const auto *Field : ClassDecl->fields()) {
|
||||
QualType FieldType = Context.getBaseElementType(Field->getType());
|
||||
|
@ -10160,17 +10138,15 @@ Sema::ComputeDefaultedMoveCtorExceptionSpec(CXXMethodDecl *MD) {
|
|||
}
|
||||
|
||||
// Virtual base-class constructors.
|
||||
for (CXXRecordDecl::base_class_iterator B = ClassDecl->vbases_begin(),
|
||||
BEnd = ClassDecl->vbases_end();
|
||||
B != BEnd; ++B) {
|
||||
if (const RecordType *BaseType = B->getType()->getAs<RecordType>()) {
|
||||
for (const auto &B : ClassDecl->vbases()) {
|
||||
if (const RecordType *BaseType = B.getType()->getAs<RecordType>()) {
|
||||
CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(BaseType->getDecl());
|
||||
CXXConstructorDecl *Constructor =
|
||||
LookupMovingConstructor(BaseClassDecl, 0);
|
||||
// If this is a deleted function, add it anyway. This might be conformant
|
||||
// with the standard. This might not. I'm not sure. It might not matter.
|
||||
if (Constructor)
|
||||
ExceptSpec.CalledDecl(B->getLocStart(), Constructor);
|
||||
ExceptSpec.CalledDecl(B.getLocStart(), Constructor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5319,10 +5319,9 @@ bool Sema::RequireLiteralType(SourceLocation Loc, QualType T,
|
|||
if (RD->getNumVBases()) {
|
||||
Diag(RD->getLocation(), diag::note_non_literal_virtual_base)
|
||||
<< getLiteralDiagFromTagKind(RD->getTagKind()) << RD->getNumVBases();
|
||||
for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),
|
||||
E = RD->vbases_end(); I != E; ++I)
|
||||
Diag(I->getLocStart(),
|
||||
diag::note_constexpr_virtual_base_here) << I->getSourceRange();
|
||||
for (const auto &I : RD->vbases())
|
||||
Diag(I.getLocStart(), diag::note_constexpr_virtual_base_here)
|
||||
<< I.getSourceRange();
|
||||
} else if (!RD->isAggregate() && !RD->hasConstexprNonCopyMoveConstructor() &&
|
||||
!RD->hasTrivialDefaultConstructor()) {
|
||||
Diag(RD->getLocation(), diag::note_non_literal_no_constexpr_ctors) << RD;
|
||||
|
|
Loading…
Reference in New Issue