[clang] [Clang] make most enums trivially equality comparable (PR #169079)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 21 07:40:13 PST 2026
================
@@ -503,6 +503,41 @@ static bool HasNoThrowOperator(CXXRecordDecl *RD, OverloadedOperatorKind Op,
return false;
}
+static bool equalityComparisonIsDefaulted(Sema &S, const TagDecl *Decl,
+ SourceLocation KeyLoc) {
+ CanQualType T = S.Context.getCanonicalTagType(Decl);
+
+ EnterExpressionEvaluationContext UnevaluatedContext(
+ S, Sema::ExpressionEvaluationContext::Unevaluated);
+ Sema::SFINAETrap SFINAE(S, /*WithAccessChecking=*/true);
+ Sema::ContextRAII TUContext(S, S.Context.getTranslationUnitDecl());
+
+ // const ClassT& obj;
+ OpaqueValueExpr Operand(KeyLoc, T.withConst(), ExprValueKind::VK_LValue);
+ UnresolvedSet<16> Functions;
+ // obj == obj;
+ S.LookupBinOp(S.TUScope, {}, BinaryOperatorKind::BO_EQ, Functions);
+
+ auto Result = S.CreateOverloadedBinOp(KeyLoc, BinaryOperatorKind::BO_EQ,
----------------
Fznamznon wrote:
Could you please spell out the type?
```suggestion
ExprResult Result = S.CreateOverloadedBinOp(KeyLoc, BinaryOperatorKind::BO_EQ,
```
https://github.com/llvm/llvm-project/pull/169079
More information about the cfe-commits
mailing list