royjacobson created this revision. royjacobson added a reviewer: shafik. Herald added a project: All. royjacobson requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Fix #63352 and one other similar issue by slightly adjusting the computation for the existance of non trivial special member functions. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D154893 Files: clang/docs/ReleaseNotes.rst clang/include/clang/AST/DeclCXX.h clang/test/SemaCXX/constrained-special-member-functions.cpp Index: clang/test/SemaCXX/constrained-special-member-functions.cpp =================================================================== --- clang/test/SemaCXX/constrained-special-member-functions.cpp +++ clang/test/SemaCXX/constrained-special-member-functions.cpp @@ -312,3 +312,16 @@ static_assert(__is_trivially_copyable(ExplicitTemplateArgs<true>)); } + + +namespace GH63352 { +template <bool B> class C1 { C1(const C1&) requires B; }; +template <bool B> class C2 { C2(C2&&) requires B; }; +template <bool B> class C3 { C3& operator=(const C3&) requires B; }; +template <bool B> class C4 { C4& operator=(C4&&) requires B; }; + +static_assert(__is_trivially_copyable(C1<false>)); +static_assert(__is_trivially_copyable(C2<false>)); +static_assert(__is_trivially_copyable(C3<false>)); +static_assert(__is_trivially_copyable(C4<false>)); +} Index: clang/include/clang/AST/DeclCXX.h =================================================================== --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -1269,13 +1269,14 @@ /// (C++ [class.copy]p6, C++11 [class.copy]p12) bool hasNonTrivialCopyConstructor() const { return data().DeclaredNonTrivialSpecialMembers & SMF_CopyConstructor || - !hasTrivialCopyConstructor(); + (needsImplicitCopyConstructor() && !hasTrivialCopyConstructor()); } bool hasNonTrivialCopyConstructorForCall() const { return (data().DeclaredNonTrivialSpecialMembersForCall & SMF_CopyConstructor) || - !hasTrivialCopyConstructorForCall(); + (needsImplicitCopyConstructor() && + !hasTrivialCopyConstructorForCall()); } /// Determine whether this class has a trivial move constructor @@ -1315,7 +1316,7 @@ /// operator (C++ [class.copy]p11, C++11 [class.copy]p25) bool hasNonTrivialCopyAssignment() const { return data().DeclaredNonTrivialSpecialMembers & SMF_CopyAssignment || - !hasTrivialCopyAssignment(); + (needsImplicitCopyAssignment() && !hasTrivialCopyAssignment()); } /// Determine whether this class has a trivial move assignment operator Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -67,8 +67,9 @@ ABI Changes in This Version --------------------------- -- A bug in evaluating the ineligibility of some special member functions has been fixed. This can - make some classes trivially copyable that were not trivially copyable before. (`#62555 <https://github.com/llvm/llvm-project/issues/62555>`_) +- Two bug in evaluating the ineligibility of some special member functions has been fixed. This can + make some classes trivially copyable that were not trivially copyable before. + (`#62555 <https://github.com/llvm/llvm-project/issues/62555>`_, `#63352 <https://github.com/llvm/llvm-project/issues/63352>`_) What's New in Clang |release|? ==============================
Index: clang/test/SemaCXX/constrained-special-member-functions.cpp =================================================================== --- clang/test/SemaCXX/constrained-special-member-functions.cpp +++ clang/test/SemaCXX/constrained-special-member-functions.cpp @@ -312,3 +312,16 @@ static_assert(__is_trivially_copyable(ExplicitTemplateArgs<true>)); } + + +namespace GH63352 { +template <bool B> class C1 { C1(const C1&) requires B; }; +template <bool B> class C2 { C2(C2&&) requires B; }; +template <bool B> class C3 { C3& operator=(const C3&) requires B; }; +template <bool B> class C4 { C4& operator=(C4&&) requires B; }; + +static_assert(__is_trivially_copyable(C1<false>)); +static_assert(__is_trivially_copyable(C2<false>)); +static_assert(__is_trivially_copyable(C3<false>)); +static_assert(__is_trivially_copyable(C4<false>)); +} Index: clang/include/clang/AST/DeclCXX.h =================================================================== --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -1269,13 +1269,14 @@ /// (C++ [class.copy]p6, C++11 [class.copy]p12) bool hasNonTrivialCopyConstructor() const { return data().DeclaredNonTrivialSpecialMembers & SMF_CopyConstructor || - !hasTrivialCopyConstructor(); + (needsImplicitCopyConstructor() && !hasTrivialCopyConstructor()); } bool hasNonTrivialCopyConstructorForCall() const { return (data().DeclaredNonTrivialSpecialMembersForCall & SMF_CopyConstructor) || - !hasTrivialCopyConstructorForCall(); + (needsImplicitCopyConstructor() && + !hasTrivialCopyConstructorForCall()); } /// Determine whether this class has a trivial move constructor @@ -1315,7 +1316,7 @@ /// operator (C++ [class.copy]p11, C++11 [class.copy]p25) bool hasNonTrivialCopyAssignment() const { return data().DeclaredNonTrivialSpecialMembers & SMF_CopyAssignment || - !hasTrivialCopyAssignment(); + (needsImplicitCopyAssignment() && !hasTrivialCopyAssignment()); } /// Determine whether this class has a trivial move assignment operator Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -67,8 +67,9 @@ ABI Changes in This Version --------------------------- -- A bug in evaluating the ineligibility of some special member functions has been fixed. This can - make some classes trivially copyable that were not trivially copyable before. (`#62555 <https://github.com/llvm/llvm-project/issues/62555>`_) +- Two bug in evaluating the ineligibility of some special member functions has been fixed. This can + make some classes trivially copyable that were not trivially copyable before. + (`#62555 <https://github.com/llvm/llvm-project/issues/62555>`_, `#63352 <https://github.com/llvm/llvm-project/issues/63352>`_) What's New in Clang |release|? ==============================
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits