[PATCH] D154893: [Clang] Fix some triviality computations
Roy Jacobson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 23 12:45:59 PDT 2023
royjacobson updated this revision to Diff 543319.
royjacobson added a comment.
Update release note
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154893/new/
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,10 @@
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 bugs 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|?
==============================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154893.543319.patch
Type: text/x-patch
Size: 3005 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230723/2ce90e19/attachment-0001.bin>
More information about the cfe-commits
mailing list