[llvm] [AsmParser][NFCI] Restructure DiagnosticPredicate (PR #126653)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 22:56:52 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
+
+  constexpr DiagnosticPredicate(PredicateTy T) : Predicate(T) {}
+
   DiagnosticPredicate& operator=(const DiagnosticPredicate &) = default;
+  DiagnosticPredicate(const DiagnosticPredicate &) = default;
----------------
lenary wrote:

Removed.

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


More information about the llvm-commits mailing list