[clang] [clang] Diagnose invalid/unavailable operator overloads for scoped flag_enums (PR #218290)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 24 04:21:37 PDT 2026
================
@@ -1200,6 +1202,74 @@ static bool IsRecordFullyDefined(const CXXRecordDecl *RD,
return Complete;
}
+static void DiagnoseInvalidFlagEnumOperators(Sema &S, const EnumDecl *ED) {
+ assert(ED->hasAttr<FlagEnumAttr>() && "not a flag-like enum");
+ if (!ED->isScoped())
+ return;
+
+ QualType T = S.Context.getCanonicalTagType(ED);
+
+ Expr *LHS = new (S.Context) OpaqueValueExpr(SourceLocation(), T, VK_PRValue);
+ Expr *RHS = new (S.Context) OpaqueValueExpr(SourceLocation(), T, VK_PRValue);
----------------
cor3ntin wrote:
You should be able to put these on the stack, allocating transient nodes is something we should try to avoid (even if there are a few places where we can't avoid it)
https://github.com/llvm/llvm-project/pull/218290
More information about the cfe-commits
mailing list