[clang] [Clang] make most enums trivially equality comparable (PR #169079)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 21 10:28:58 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- clang/lib/Sema/SemaTypeTraits.cpp clang/test/SemaCXX/type-traits.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Sema/SemaTypeTraits.cpp b/clang/lib/Sema/SemaTypeTraits.cpp
index 581989e6d..cfb451cf3 100644
--- a/clang/lib/Sema/SemaTypeTraits.cpp
+++ b/clang/lib/Sema/SemaTypeTraits.cpp
@@ -601,9 +601,7 @@ static bool EqualityComparisonIsDefaulted(Sema &S, const TypeDecl *Decl,
   Sema::ContextRAII TUContext(S, S.Context.getTranslationUnitDecl());
 
   // const ClassT& obj;
-  OpaqueValueExpr Operand(
-      KeyLoc, T.withConst(),
-      ExprValueKind::VK_LValue);
+  OpaqueValueExpr Operand(KeyLoc, T.withConst(), ExprValueKind::VK_LValue);
   UnresolvedSet<16> Functions;
   // obj == obj;
   S.LookupBinOp(S.TUScope, {}, BinaryOperatorKind::BO_EQ, Functions);
@@ -655,7 +653,9 @@ static bool HasNonDeletedDefaultedEqualityComparison(Sema &S,
            if (Type->isReferenceType())
              return false;
            if (Type->isEnumeralType()) {
-             EnumDecl *ED = Type->castAs<EnumType>()->getOriginalDecl()->getDefinitionOrSelf();
+             EnumDecl *ED = Type->castAs<EnumType>()
+                                ->getOriginalDecl()
+                                ->getDefinitionOrSelf();
              return EqualityComparisonIsDefaulted(S, ED, KeyLoc);
            } else if (const auto *RD = Type->getAsCXXRecordDecl())
              return HasNonDeletedDefaultedEqualityComparison(S, RD, KeyLoc);
@@ -671,7 +671,9 @@ static bool isTriviallyEqualityComparableType(Sema &S, QualType Type,
     return false;
 
   if (CanonicalType->isEnumeralType()) {
-    EnumDecl *ED = CanonicalType->castAs<EnumType>()->getOriginalDecl()->getDefinitionOrSelf();
+    EnumDecl *ED = CanonicalType->castAs<EnumType>()
+                       ->getOriginalDecl()
+                       ->getDefinitionOrSelf();
     return EqualityComparisonIsDefaulted(S, ED, KeyLoc);
   }
 

``````````

</details>


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


More information about the cfe-commits mailing list