[clang] 465d487 - [clang] Fix __is_trivially_equality_comparable for non-trivially-copyable types
Nikolas Klauser via cfe-commits
cfe-commits at lists.llvm.org
Mon May 8 12:07:35 PDT 2023
Author: Nikolas Klauser
Date: 2023-05-08T12:07:28-07:00
New Revision: 465d487481313492e13435f3f03874b923b86ce3
URL: https://github.com/llvm/llvm-project/commit/465d487481313492e13435f3f03874b923b86ce3
DIFF: https://github.com/llvm/llvm-project/commit/465d487481313492e13435f3f03874b923b86ce3.diff
LOG: [clang] Fix __is_trivially_equality_comparable for non-trivially-copyable types
Reviewed By: aaron.ballman
Spies: cfe-commits
Differential Revision: https://reviews.llvm.org/D150072
Added:
Modified:
clang/lib/AST/Type.cpp
clang/test/SemaCXX/type-traits.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index ed481a4c0696..db369d127735 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2663,7 +2663,8 @@ bool QualType::isTriviallyEqualityComparableType(
return false;
}
- return Context.hasUniqueObjectRepresentations(CanonicalType);
+ return Context.hasUniqueObjectRepresentations(
+ CanonicalType, /*CheckIfTriviallyCopyable=*/false);
}
bool QualType::isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const {
diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp
index f9003b704099..75f172d1c345 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -3134,6 +3134,14 @@ struct TriviallyEqualityComparable {
};
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;
More information about the cfe-commits
mailing list