[llvm] [AsmParser][NFCI] Restructure DiagnosticPredicate (PR #126653)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 11 10:08:59 PST 2025
================
@@ -198,21 +192,36 @@ enum class DiagnosticPredicateTy {
// This is a light-weight alternative to the 'NearMissInfo' approach
// below which collects *all* possible diagnostics. This alternative
// is optional and fully backward compatible with existing
-// PredicateMethods that return a 'bool' (match or no match).
-struct DiagnosticPredicate {
- DiagnosticPredicateTy Type;
-
- explicit DiagnosticPredicate(bool Match)
- : Type(Match ? DiagnosticPredicateTy::Match
- : DiagnosticPredicateTy::NearMatch) {}
- DiagnosticPredicate(DiagnosticPredicateTy T) : Type(T) {}
- DiagnosticPredicate(const DiagnosticPredicate &) = default;
+// PredicateMethods that return a 'bool' (match or near match).
+class DiagnosticPredicate {
+ enum class PredicateTy {
+ Match, // Matches
+ NearMatch, // Close Match: use Specific Diagnostic
+ NoMatch, // No Match: use `InvalidOperand`
+ } Predicate;
+
+public:
+#if __cplusplus >= 202002L
+ using enum PredicateTy;
+#else
+ static constexpr PredicateTy Match = PredicateTy::Match;
+ static constexpr PredicateTy NearMatch = PredicateTy::NearMatch;
+ static constexpr PredicateTy NoMatch = PredicateTy::NoMatch;
+#endif
----------------
lenary wrote:
@s-barannikov do you have an opinion either way here? You wrote the original structure of `ParseStatus` - my view is that these two similar types (which have small differences in the details) should at least be structured similarly.
https://github.com/llvm/llvm-project/pull/126653
More information about the llvm-commits
mailing list