[PATCH] D154778: [clang] Fix __is_trivially_equality_comparable for classes which contain arrays of non-trivially equality comparable types
Nikolas Klauser via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 10 11:09:57 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
philnik marked an inline comment as done.
Closed by commit rGc6b4433a0f20: [clang] Fix __is_trivially_equality_comparable for classes which contain arrays… (authored by philnik).
Changed prior to commit:
https://reviews.llvm.org/D154778?vs=538393&id=538742#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154778/new/
https://reviews.llvm.org/D154778
Files:
clang/lib/AST/Type.cpp
clang/test/SemaCXX/type-traits.cpp
Index: clang/test/SemaCXX/type-traits.cpp
===================================================================
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3141,6 +3141,13 @@
};
static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsArray));
+struct TriviallyEqualityComparableContainsMultiDimensionArray {
+ int a[4][4];
+
+ bool operator==(const TriviallyEqualityComparableContainsMultiDimensionArray&) const = default;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsMultiDimensionArray));
+
struct TriviallyEqualityComparableNonTriviallyCopyable {
TriviallyEqualityComparableNonTriviallyCopyable(const TriviallyEqualityComparableNonTriviallyCopyable&);
~TriviallyEqualityComparableNonTriviallyCopyable();
@@ -3292,6 +3299,20 @@
};
static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasEnum));
+struct NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs {
+ E e[1];
+
+ bool operator==(const NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs&) const = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs));
+
+struct NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs2 {
+ E e[1][1];
+
+ bool operator==(const NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs2&) const = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs2));
+
namespace hidden_friend {
struct TriviallyEqualityComparable {
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2672,6 +2672,9 @@
}) &&
llvm::all_of(Decl->fields(), [](const FieldDecl *FD) {
auto Type = FD->getType();
+ if (Type->isArrayType())
+ Type = Type->getBaseElementTypeUnsafe()->getCanonicalTypeUnqualified();
+
if (Type->isReferenceType() || Type->isEnumeralType())
return false;
if (const auto *RD = Type->getAsCXXRecordDecl())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154778.538742.patch
Type: text/x-patch
Size: 2254 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230710/6fa152b2/attachment.bin>
More information about the cfe-commits
mailing list