[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
Mon May 8 12:07:51 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG465d48748131: [clang] Fix __is_trivially_equality_comparable for non-trivially-copyable types (authored by philnik).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150072/new/

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.520460.patch
Type: text/x-patch
Size: 1264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230508/6f0e5f45/attachment.bin>


More information about the cfe-commits mailing list