[clang] [Clang] Make enums trivially equality comparable (PR #133587)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 9 17:32:12 PDT 2025


================
@@ -5240,9 +5249,13 @@ static bool HasNonDeletedDefaultedEqualityComparison(Sema &S,
 static bool isTriviallyEqualityComparableType(Sema &S, QualType Type, SourceLocation KeyLoc) {
   QualType CanonicalType = Type.getCanonicalType();
   if (CanonicalType->isIncompleteType() || CanonicalType->isDependentType() ||
-      CanonicalType->isEnumeralType() || CanonicalType->isArrayType())
+      CanonicalType->isArrayType())
     return false;
 
+  if (CanonicalType->isEnumeralType())
+    return EqualityComparisonIsDefaulted(
----------------
shafik wrote:

It looks like you are currently only testing if it is defaulted, we should be testing all code paths if possible to insure this does what we expect and to prevent future regressions.

https://github.com/llvm/llvm-project/pull/133587


More information about the cfe-commits mailing list