[llvm-branch-commits] [llvm] [FileCheck][NFC] Introduce MatchResultDiag and MatchNoteDiag (PR #195569)

Joel E. Denny via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 5 06:57:06 PDT 2026


================
@@ -111,24 +112,29 @@ class FileCheckType {
 };
 } // namespace Check
 
-/// Summary of a FileCheck diagnostic.
-struct FileCheckDiag {
-  /// What is the FileCheck directive for this diagnostic?
-  Check::FileCheckType CheckTy;
-  /// Where is the FileCheck directive for this diagnostic?
-  SMLoc CheckLoc;
+class MatchResultDiag;
+
+/// Abstract base class for recording a FileCheck diagnostic for a pattern
+/// (e.g., \c CHECK-NEXT directive or \c --implicit-check-not).
+///
+/// \c FileCheckDiag has two direct derived classes:
+/// - \c MatchResultDiag records a match result for a pattern.  There might be
+///   more than one for a single pattern.  For example, for \c CHECK-DAG there
+///   might be several discarded matches before either a good match or a failure
+///   to match.
+/// - \c MatchNoteDiag provides an additional note about the most recent
+///   \c MatchResultDiag emitted by a FileCheck invocation.  For example, there
+///   might be a fuzzy match after a failure to match.
+class FileCheckDiag {
+public:
+  enum FileCheckDiagKind { FCDK_MatchResultDiag, FCDK_MatchNoteDiag };
----------------
jdenny-ornl wrote:

Without `FCDK_`, these enumerators collide with the derived class names in derived class methods, in particular `classof`.  Is it preferred to qualify them like `FileCheckDiag::MatchResultDiag` there instead?

Using `FCDK_` is an attempt to followed the examples in [LLVM's RTTI docs](https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html#basic-setup).  Do those docs need to be updated for LLVM's current preferred style?


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


More information about the llvm-branch-commits mailing list