[PATCH] D150072: [clang] Fix __is_trivially_equality_comparable for non-trivially-copyable types
Nikolas Klauser via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun May 7 11:09:57 PDT 2023
philnik created this revision.
philnik added a reviewer: aaron.ballman.
Herald added a project: All.
philnik requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150072
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
@@ -3134,6 +3134,14 @@
};
static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable), "");
+struct TriviallyEqualityComparableNonTriviallyCopyable {
+ TriviallyEqualityComparableNonTriviallyCopyable(const TriviallyEqualityComparableNonTriviallyCopyable&);
+ ~TriviallyEqualityComparableNonTriviallyCopyable();
+ bool operator==(const TriviallyEqualityComparableNonTriviallyCopyable&) const = default;
+ int i;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableNonTriviallyCopyable));
+
struct NotTriviallyEqualityComparableHasPadding {
short i;
int j;
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2663,7 +2663,8 @@
return false;
}
- return Context.hasUniqueObjectRepresentations(CanonicalType);
+ return Context.hasUniqueObjectRepresentations(
+ CanonicalType, /*CheckIfTriviallyCopyable=*/false);
}
bool QualType::isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150072.520201.patch
Type: text/x-patch
Size: 1264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230507/d82a73ab/attachment.bin>
More information about the cfe-commits
mailing list