Skip to content

Commit d66d437

Browse files
committed
Make hasDeletedDestructor a member
1 parent ebdea9c commit d66d437

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

clang/include/clang/AST/DeclCXX.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,9 @@ class CXXRecordDecl : public RecordDecl {
16251625
/// Returns the destructor decl for this class.
16261626
CXXDestructorDecl *getDestructor() const;
16271627

1628+
/// Returns the destructor decl for this class.
1629+
bool hasDeletedDestructor() const;
1630+
16281631
/// Returns true if the class destructor, or any implicitly invoked
16291632
/// destructors are marked noreturn.
16301633
bool isAnyDestructorNoReturn() const { return data().IsAnyDestructorNoReturn; }

clang/lib/AST/DeclCXX.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,12 @@ CXXDestructorDecl *CXXRecordDecl::getDestructor() const {
21242124
return nullptr;
21252125
}
21262126

2127+
bool CXXRecordDecl::hasDeletedDestructor() const {
2128+
if (const CXXDestructorDecl *D = getDestructor())
2129+
return D->isDeleted();
2130+
return false;
2131+
}
2132+
21272133
static bool isDeclContextInNamespace(const DeclContext *DC) {
21282134
while (!DC->isTranslationUnit()) {
21292135
if (DC->isNamespace())

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7400,13 +7400,6 @@ static bool isDefaultMovable(Sema &SemaRef, CXXRecordDecl *D) {
74007400
return !Dtr->isDeleted();
74017401
}
74027402

7403-
static bool hasDeletedDestructor(CXXRecordDecl *D) {
7404-
const auto *Dtr = D->getDestructor();
7405-
if (Dtr)
7406-
return Dtr->isDeleted();
7407-
return false;
7408-
}
7409-
74107403
// [C++26][class.prop]
74117404
// A class is eligible for trivial relocation unless it...
74127405
static bool isEligibleForTrivialRelocation(Sema &SemaRef, CXXRecordDecl *D) {
@@ -7435,7 +7428,7 @@ static bool isEligibleForTrivialRelocation(Sema &SemaRef, CXXRecordDecl *D) {
74357428
}
74367429

74377430
// ...has a deleted destructor
7438-
return !hasDeletedDestructor(D);
7431+
return !D->hasDeletedDestructor();
74397432
}
74407433

74417434
// [C++26][class.prop]
@@ -7461,7 +7454,7 @@ static bool isEligibleForReplacement(Sema &SemaRef, CXXRecordDecl *D) {
74617454
}
74627455

74637456
// it has a deleted destructor.
7464-
return !hasDeletedDestructor(D);
7457+
return !D->hasDeletedDestructor();
74657458
}
74667459

74677460
void Sema::CheckCXX2CRelocatableAndReplaceable(CXXRecordDecl *D) {
@@ -7511,9 +7504,9 @@ void Sema::CheckCXX2CRelocatableAndReplaceable(CXXRecordDecl *D) {
75117504
return true;
75127505

75137506
// is a union with no user-declared special member functions, or
7514-
if (IsUnion()) {
7507+
if (IsUnion())
75157508
return true;
7516-
}
7509+
75177510
// is default-movable.
75187511
return IsDefaultMovable();
75197512
}();
@@ -7533,9 +7526,8 @@ void Sema::CheckCXX2CRelocatableAndReplaceable(CXXRecordDecl *D) {
75337526
return HasSuitableSMP();
75347527

75357528
// is a union with no user-declared special member functions, or
7536-
if (IsUnion()) {
7529+
if (IsUnion())
75377530
return HasSuitableSMP();
7538-
}
75397531

75407532
// is default-movable.
75417533
return IsDefaultMovable();

0 commit comments

Comments
 (0)