@@ -5452,29 +5452,18 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
5452
5452
5453
5453
SourceLocation Location = Constructor->getLocation();
5454
5454
5455
+ // Constructors implicitly reference the base and member
5456
+ // destructors.
5457
+
5455
5458
for (CXXCtorInitializer *Initializer : Info.AllToInit) {
5456
5459
FieldDecl *Field = Initializer->getAnyMember();
5457
5460
if (!Field)
5458
5461
continue;
5459
5462
5460
- RecordDecl *Parent = Field->getParent();
5461
-
5462
- while (Parent) {
5463
- if (Parent->isUnion()) {
5464
- MarkFieldDestructorReferenced(Location, Field);
5465
- break;
5466
- }
5467
-
5468
- if (!Parent->isAnonymousStructOrUnion() || Parent == ClassDecl) {
5469
- break;
5470
- }
5471
-
5472
- Parent = cast<RecordDecl>(Parent->getDeclContext());
5473
- }
5463
+ MarkFieldDestructorReferenced(Location, Field);
5474
5464
}
5475
- // Constructors implicitly reference the base and member
5476
- // destructors.
5477
- MarkBaseAndMemberDestructorsReferenced(Location, Constructor->getParent());
5465
+
5466
+ MarkBaseDestructorsReferenced(Location, Constructor->getParent());
5478
5467
}
5479
5468
5480
5469
return HadError;
@@ -5815,24 +5804,11 @@ void Sema::MarkFieldDestructorReferenced(SourceLocation Location,
5815
5804
DiagnoseUseOfDecl(Dtor, Location);
5816
5805
}
5817
5806
5818
- void
5819
- Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location,
5820
- CXXRecordDecl *ClassDecl) {
5821
- // Ignore dependent contexts. Also ignore unions, since their members never
5822
- // have destructors implicitly called.
5823
- if (ClassDecl->isDependentContext() || ClassDecl->isUnion())
5807
+ void Sema::MarkBaseDestructorsReferenced(SourceLocation Location,
5808
+ CXXRecordDecl *ClassDecl) {
5809
+ if (ClassDecl->isDependentContext())
5824
5810
return;
5825
5811
5826
- // FIXME: all the access-control diagnostics are positioned on the
5827
- // field/base declaration. That's probably good; that said, the
5828
- // user might reasonably want to know why the destructor is being
5829
- // emitted, and we currently don't say.
5830
-
5831
- // Non-static data members.
5832
- for (auto *Field : ClassDecl->fields()) {
5833
- MarkFieldDestructorReferenced(Location, Field);
5834
- }
5835
-
5836
5812
// We only potentially invoke the destructors of potentially constructed
5837
5813
// subobjects.
5838
5814
bool VisitVirtualBases = !ClassDecl->isAbstract();
@@ -5888,6 +5864,26 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location,
5888
5864
&DirectVirtualBases);
5889
5865
}
5890
5866
5867
+ void Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location,
5868
+ CXXRecordDecl *ClassDecl) {
5869
+ // Ignore dependent contexts. Also ignore unions, since their members never
5870
+ // have destructors implicitly called.
5871
+ if (ClassDecl->isDependentContext() || ClassDecl->isUnion())
5872
+ return;
5873
+
5874
+ // FIXME: all the access-control diagnostics are positioned on the
5875
+ // field/base declaration. That's probably good; that said, the
5876
+ // user might reasonably want to know why the destructor is being
5877
+ // emitted, and we currently don't say.
5878
+
5879
+ // Non-static data members.
5880
+ for (auto *Field : ClassDecl->fields()) {
5881
+ MarkFieldDestructorReferenced(Location, Field);
5882
+ }
5883
+
5884
+ MarkBaseDestructorsReferenced(Location, ClassDecl);
5885
+ }
5886
+
5891
5887
void Sema::MarkVirtualBaseDestructorsReferenced(
5892
5888
SourceLocation Location, CXXRecordDecl *ClassDecl,
5893
5889
llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases) {
0 commit comments