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