Skip to content

Commit 91fefaa

Browse files
committed
Revert "[Sema] Don't mark deleted special member functions as non-trivial"
This reverts commit d5dd37a. Apparently there's some ABI difference in the Sony builder that fails a test. Will hopefully investigate tomorrow. https://lab.llvm.org/buildbot/#/builders/139/builds/33769
1 parent 73c9f16 commit 91fefaa

File tree

4 files changed

+40
-65
lines changed

4 files changed

+40
-65
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,6 @@ ABI Changes in Clang
754754
classified such types as non-POD (for the purposes of Itanium ABI). Clang now
755755
matches the gcc behavior (except on Darwin and PS4). You can switch back to
756756
the old ABI behavior with the flag: ``-fclang-abi-compat=15.0``.
757-
- Some types with implicitly deleted special member functions were accidentally
758-
marked as non-trivially copyable. This has been fixed
759-
(`#59624 <https://github.com/llvm/llvm-project/issues/59624>`_).
760757

761758
OpenMP Support in Clang
762759
-----------------------

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14475,6 +14475,11 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) {
1447514475
nullptr);
1447614476
CopyAssignment->setParams(FromParam);
1447714477

14478+
CopyAssignment->setTrivial(
14479+
ClassDecl->needsOverloadResolutionForCopyAssignment()
14480+
? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
14481+
: ClassDecl->hasTrivialCopyAssignment());
14482+
1447814483
// Note that we have added this copy-assignment operator.
1447914484
++getASTContext().NumImplicitCopyAssignmentOperatorsDeclared;
1448014485

@@ -14484,11 +14489,6 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) {
1448414489
if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment)) {
1448514490
ClassDecl->setImplicitCopyAssignmentIsDeleted();
1448614491
SetDeclDeleted(CopyAssignment, ClassLoc);
14487-
} else {
14488-
CopyAssignment->setTrivial(
14489-
ClassDecl->needsOverloadResolutionForCopyAssignment()
14490-
? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
14491-
: ClassDecl->hasTrivialCopyAssignment());
1449214492
}
1449314493

1449414494
if (S)
@@ -14813,6 +14813,11 @@ CXXMethodDecl *Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) {
1481314813
nullptr);
1481414814
MoveAssignment->setParams(FromParam);
1481514815

14816+
MoveAssignment->setTrivial(
14817+
ClassDecl->needsOverloadResolutionForMoveAssignment()
14818+
? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
14819+
: ClassDecl->hasTrivialMoveAssignment());
14820+
1481614821
// Note that we have added this copy-assignment operator.
1481714822
++getASTContext().NumImplicitMoveAssignmentOperatorsDeclared;
1481814823

@@ -14822,11 +14827,6 @@ CXXMethodDecl *Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) {
1482214827
if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
1482314828
ClassDecl->setImplicitMoveAssignmentIsDeleted();
1482414829
SetDeclDeleted(MoveAssignment, ClassLoc);
14825-
} else {
14826-
MoveAssignment->setTrivial(
14827-
ClassDecl->needsOverloadResolutionForMoveAssignment()
14828-
? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
14829-
: ClassDecl->hasTrivialMoveAssignment());
1483014830
}
1483114831

1483214832
if (S)
@@ -15197,6 +15197,18 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor(
1519715197
/*TInfo=*/TSI, SC_None, nullptr);
1519815198
CopyConstructor->setParams(FromParam);
1519915199

15200+
CopyConstructor->setTrivial(
15201+
ClassDecl->needsOverloadResolutionForCopyConstructor()
15202+
? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
15203+
: ClassDecl->hasTrivialCopyConstructor());
15204+
15205+
CopyConstructor->setTrivialForCall(
15206+
ClassDecl->hasAttr<TrivialABIAttr>() ||
15207+
(ClassDecl->needsOverloadResolutionForCopyConstructor()
15208+
? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
15209+
TAH_ConsiderTrivialABI)
15210+
: ClassDecl->hasTrivialCopyConstructorForCall()));
15211+
1520015212
// Note that we have declared this constructor.
1520115213
++getASTContext().NumImplicitCopyConstructorsDeclared;
1520215214

@@ -15206,18 +15218,6 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor(
1520615218
if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
1520715219
ClassDecl->setImplicitCopyConstructorIsDeleted();
1520815220
SetDeclDeleted(CopyConstructor, ClassLoc);
15209-
} else {
15210-
CopyConstructor->setTrivial(
15211-
ClassDecl->needsOverloadResolutionForCopyConstructor()
15212-
? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
15213-
: ClassDecl->hasTrivialCopyConstructor());
15214-
15215-
CopyConstructor->setTrivialForCall(
15216-
ClassDecl->hasAttr<TrivialABIAttr>() ||
15217-
(ClassDecl->needsOverloadResolutionForCopyConstructor()
15218-
? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
15219-
TAH_ConsiderTrivialABI)
15220-
: ClassDecl->hasTrivialCopyConstructorForCall()));
1522115221
}
1522215222

1522315223
if (S)
@@ -15331,6 +15331,18 @@ CXXConstructorDecl *Sema::DeclareImplicitMoveConstructor(
1533115331
SC_None, nullptr);
1533215332
MoveConstructor->setParams(FromParam);
1533315333

15334+
MoveConstructor->setTrivial(
15335+
ClassDecl->needsOverloadResolutionForMoveConstructor()
15336+
? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
15337+
: ClassDecl->hasTrivialMoveConstructor());
15338+
15339+
MoveConstructor->setTrivialForCall(
15340+
ClassDecl->hasAttr<TrivialABIAttr>() ||
15341+
(ClassDecl->needsOverloadResolutionForMoveConstructor()
15342+
? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
15343+
TAH_ConsiderTrivialABI)
15344+
: ClassDecl->hasTrivialMoveConstructorForCall()));
15345+
1533415346
// Note that we have declared this constructor.
1533515347
++getASTContext().NumImplicitMoveConstructorsDeclared;
1533615348

@@ -15340,18 +15352,6 @@ CXXConstructorDecl *Sema::DeclareImplicitMoveConstructor(
1534015352
if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
1534115353
ClassDecl->setImplicitMoveConstructorIsDeleted();
1534215354
SetDeclDeleted(MoveConstructor, ClassLoc);
15343-
} else {
15344-
MoveConstructor->setTrivial(
15345-
ClassDecl->needsOverloadResolutionForMoveConstructor()
15346-
? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
15347-
: ClassDecl->hasTrivialMoveConstructor());
15348-
15349-
MoveConstructor->setTrivialForCall(
15350-
ClassDecl->hasAttr<TrivialABIAttr>() ||
15351-
(ClassDecl->needsOverloadResolutionForMoveConstructor()
15352-
? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
15353-
TAH_ConsiderTrivialABI)
15354-
: ClassDecl->hasTrivialMoveConstructorForCall()));
1535515355
}
1535615356

1535715357
if (S)
@@ -17569,9 +17569,6 @@ void Sema::SetDeclDeleted(Decl *Dcl, SourceLocation DelLoc) {
1756917569
// A deleted function is implicitly inline.
1757017570
Fn->setImplicitlyInline();
1757117571
Fn->setDeletedAsWritten();
17572-
17573-
Fn->setTrivial(true);
17574-
Fn->setTrivialForCall(true);
1757517572
}
1757617573

1757717574
void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation DefaultLoc) {

clang/test/AST/ast-dump-funcs.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ struct S {
5454
virtual void g() = 0;
5555
// CHECK: CXXMethodDecl 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:22> col:16 g 'void ()' virtual pure
5656

57-
// CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-33]]:8> col:8 implicit S 'void (const S &)' inline default_delete trivial noexcept-unevaluated
57+
// CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-33]]:8> col:8 implicit S 'void (const S &)' inline default_delete noexcept-unevaluated
5858
// CHECK: CXXConstructorDecl 0x{{[^ ]*}} <col:8> col:8 implicit constexpr S 'void (S &&)' inline default noexcept-unevaluated
59-
// CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'S &(const S &)' inline default_delete trivial noexcept-unevaluated
60-
// CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'S &(S &&)' inline default_delete trivial noexcept-unevaluated
59+
// CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'S &(const S &)' inline default_delete noexcept-unevaluated
60+
// CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'S &(S &&)' inline default_delete noexcept-unevaluated
6161
// CHECK: CXXDestructorDecl 0x{{[^ ]*}} <col:8> col:8 implicit ~S 'void ()' inline default noexcept-unevaluated
6262
};
6363

@@ -70,9 +70,9 @@ struct T : S { // T is not referenced, but S is
7070
// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:23> 'int' 100
7171
// CHECK-NEXT: OverrideAttr
7272

73-
// CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-9]]:8> col:8 implicit T 'void (const T &)' inline default_delete trivial noexcept-unevaluated
74-
// CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'T &(const T &)' inline default_delete trivial noexcept-unevaluated
75-
// CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'T &(T &&)' inline default_delete trivial noexcept-unevaluated
73+
// CHECK: CXXConstructorDecl 0x{{[^ ]*}} <line:[[@LINE-9]]:8> col:8 implicit T 'void (const T &)' inline default_delete noexcept-unevaluated
74+
// CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'T &(const T &)' inline default_delete noexcept-unevaluated
75+
// CHECK: CXXMethodDecl 0x{{[^ ]*}} <col:8> col:8 implicit operator= 'T &(T &&)' inline default_delete noexcept-unevaluated
7676
// CHECK: CXXDestructorDecl 0x{{[^ ]*}} <col:8> col:8 implicit ~T 'void ()' inline default noexcept-unevaluated
7777
};
7878

clang/test/SemaCXX/GH59624.cpp

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)