LLVM 23.0.0git
llvm::FileCheckDiag Class Referenceabstract

Abstract base class for recording a FileCheck diagnostic for a pattern (e.g., CHECK-NEXT directive or --implicit-check-not). More...

#include "llvm/FileCheck/FileCheck.h"

Inheritance diagram for llvm::FileCheckDiag:
[legend]

Public Types

enum  FileCheckDiagKind {
  MatchResultDiag_First , MatchFoundDiag = MatchResultDiag_First , MatchNoneDiag , MatchResultDiag_Last = MatchNoneDiag ,
  MatchNoteDiag_First , MatchFuzzyDiag = MatchNoteDiag_First , MatchCustomNoteDiag , MatchNoteDiag_Last = MatchCustomNoteDiag
}

Public Member Functions

 FileCheckDiag (FileCheckDiagKind Kind)
virtual ~FileCheckDiag ()=0
 Destructor is purely virtual to ensure this remains an abstract class.
FileCheckDiagKind getKind () const
 Of what derived class is this an instance?
virtual const MatchResultDiaggetMatchResultDiag () const =0
 If this is a MatchResultDiag, return itself.
virtual bool isError () const =0
 Does this diagnostic reveal a new error?
virtual std::optional< SMRangegetMatchRange () const =0
 Return the input range for which this diagnostic indicates text that was matched in some way (e.g., successful pattern match, discarded pattern match, or variable capture), or return std::nullopt if the diagnostic has no such input range.

Detailed Description

Abstract base class for recording a FileCheck diagnostic for a pattern (e.g., CHECK-NEXT directive or --implicit-check-not).

FileCheckDiag has two direct derived classes:

  • MatchResultDiag records a match result for a pattern. There might be more than one for a single pattern. For example, for CHECK-DAG there might be several discarded matches before either a good match or a failure to match.
  • MatchNoteDiag provides an additional note about the most recent MatchResultDiag emitted by a FileCheck invocation. For example, there might be a fuzzy match after a failure to match.

Throughout this class hierarchy, a pattern is said to be either expected or excluded depending on whether the pattern must have or must not have a match in order for it to succeed. For example, a CHECK directive's pattern is expected, and a CHECK-NOT directive's pattern is excluded.

Definition at line 133 of file FileCheck.h.

Member Enumeration Documentation

◆ FileCheckDiagKind

Enumerator
MatchResultDiag_First 
MatchFoundDiag 
MatchNoneDiag 
MatchResultDiag_Last 
MatchNoteDiag_First 
MatchFuzzyDiag 
MatchCustomNoteDiag 
MatchNoteDiag_Last 

Definition at line 135 of file FileCheck.h.

Constructor & Destructor Documentation

◆ FileCheckDiag()

◆ ~FileCheckDiag()

FileCheckDiag::~FileCheckDiag ( )
pure virtual

Destructor is purely virtual to ensure this remains an abstract class.

Definition at line 1507 of file FileCheck.cpp.

Member Function Documentation

◆ getKind()

FileCheckDiagKind llvm::FileCheckDiag::getKind ( ) const
inline

◆ getMatchRange()

virtual std::optional< SMRange > llvm::FileCheckDiag::getMatchRange ( ) const
pure virtual

Return the input range for which this diagnostic indicates text that was matched in some way (e.g., successful pattern match, discarded pattern match, or variable capture), or return std::nullopt if the diagnostic has no such input range.

Implemented in llvm::MatchCustomNoteDiag, llvm::MatchFoundDiag, llvm::MatchFuzzyDiag, and llvm::MatchNoneDiag.

◆ getMatchResultDiag()

virtual const MatchResultDiag & llvm::FileCheckDiag::getMatchResultDiag ( ) const
pure virtual

If this is a MatchResultDiag, return itself.

If this is a MatchNoteDiag, return its associated MatchResultDiag.

Implemented in llvm::MatchNoteDiag, and llvm::MatchResultDiag.

◆ isError()

virtual bool llvm::FileCheckDiag::isError ( ) const
pure virtual

Does this diagnostic reveal a new error?

For MatchResultDiag, !isError() is not always the same as a successful pattern match result. For MatchNoteDiag, !isError() does not indicate the lack of an error but rather the lack of an additional error beyond its associated MatchResultDiag. See documentation on derived types for details.

Implemented in llvm::MatchCustomNoteDiag, llvm::MatchFoundDiag, llvm::MatchFuzzyDiag, and llvm::MatchNoneDiag.


The documentation for this class was generated from the following files: