LLVM 24.0.0git
llvm::SourceMgrDiagnosticVerifier::ExpectedDiag Struct Reference

A single diagnostic expected via an 'expected-<kind>' comment. More...

#include "llvm/Support/SourceMgrDiagnosticVerifier.h"

Public Member Functions

 ExpectedDiag (SourceMgr::DiagKind kind, unsigned lineNo, SMLoc fileLoc, StringRef substring)
LLVM_ABI bool match (StringRef str) const
 Returns true if this diagnostic matches the given message.
LLVM_ABI bool computeRegex (raw_ostream &os, SourceMgr &mgr)
 Computes the regex matcher for a '-re' diagnostic's substring.
LLVM_ABI bool emitError (raw_ostream &os, SourceMgr &mgr, const Twine &msg) const
 Prints msg at this diagnostic's location and returns false, for use as return emitError(...); in functions that report failure via a bool return.

Public Attributes

SourceMgr::DiagKind kind
 The severity of the diagnostic expected.
unsigned lineNo
 The line number the expected diagnostic should be on.
unsigned colNo = 0
 The column the expected diagnostic should be at, or 0 if any column matches.
SMLoc fileLoc
 The location of the expected diagnostic within the input file.
bool matched = false
 A flag indicating if the expected diagnostic has been matched yet.
StringRef substring
 The substring that is expected to be within the diagnostic.
std::optional< Regex > substringRegex
 An optional regex matcher, if the expected diagnostic substring was a regex string.

Detailed Description

A single diagnostic expected via an 'expected-<kind>' comment.

Definition at line 55 of file SourceMgrDiagnosticVerifier.h.

Constructor & Destructor Documentation

◆ ExpectedDiag()

llvm::SourceMgrDiagnosticVerifier::ExpectedDiag::ExpectedDiag ( SourceMgr::DiagKind kind,
unsigned lineNo,
SMLoc fileLoc,
StringRef substring )
inline

Definition at line 56 of file SourceMgrDiagnosticVerifier.h.

References fileLoc, kind, lineNo, and substring.

Member Function Documentation

◆ computeRegex()

bool SourceMgrDiagnosticVerifier::ExpectedDiag::computeRegex ( raw_ostream & os,
SourceMgr & mgr )

Computes the regex matcher for a '-re' diagnostic's substring.

Returns false and prints a message through mgr on error.

Definition at line 59 of file SourceMgrDiagnosticVerifier.cpp.

References llvm::StringRef::drop_front(), emitError(), llvm::StringRef::empty(), llvm::Regex::escape(), llvm::StringRef::find(), isValid(), llvm::StringRef::npos, substring, substringRegex, and llvm::StringRef::take_front().

Referenced by llvm::SourceMgrDiagnosticVerifier::computeExpectedDiags().

◆ emitError()

bool SourceMgrDiagnosticVerifier::ExpectedDiag::emitError ( raw_ostream & os,
SourceMgr & mgr,
const Twine & msg ) const

Prints msg at this diagnostic's location and returns false, for use as return emitError(...); in functions that report failure via a bool return.

Definition at line 39 of file SourceMgrDiagnosticVerifier.cpp.

References fileLoc, llvm::SMLoc::getFromPointer(), llvm::SourceMgrDiagnosticVerifier::printMessage(), and substring.

Referenced by llvm::SourceMgrDiagnosticVerifier::computeExpectedDiags(), and computeRegex().

◆ match()

bool SourceMgrDiagnosticVerifier::ExpectedDiag::match ( StringRef str) const

Returns true if this diagnostic matches the given message.

Definition at line 51 of file SourceMgrDiagnosticVerifier.cpp.

References llvm::StringRef::contains(), substring, and substringRegex.

Member Data Documentation

◆ colNo

unsigned llvm::SourceMgrDiagnosticVerifier::ExpectedDiag::colNo = 0

The column the expected diagnostic should be at, or 0 if any column matches.

Definition at line 79 of file SourceMgrDiagnosticVerifier.h.

Referenced by llvm::SourceMgrDiagnosticVerifier::computeExpectedDiags().

◆ fileLoc

SMLoc llvm::SourceMgrDiagnosticVerifier::ExpectedDiag::fileLoc

The location of the expected diagnostic within the input file.

Definition at line 81 of file SourceMgrDiagnosticVerifier.h.

Referenced by llvm::SourceMgrDiagnosticVerifier::computeExpectedDiags(), emitError(), ExpectedDiag(), and llvm::SourceMgrDiagnosticVerifier::process().

◆ kind

SourceMgr::DiagKind llvm::SourceMgrDiagnosticVerifier::ExpectedDiag::kind

The severity of the diagnostic expected.

Definition at line 74 of file SourceMgrDiagnosticVerifier.h.

Referenced by ExpectedDiag(), and llvm::SourceMgrDiagnosticVerifier::process().

◆ lineNo

unsigned llvm::SourceMgrDiagnosticVerifier::ExpectedDiag::lineNo

The line number the expected diagnostic should be on.

Definition at line 76 of file SourceMgrDiagnosticVerifier.h.

Referenced by llvm::SourceMgrDiagnosticVerifier::computeExpectedDiags(), and ExpectedDiag().

◆ matched

bool llvm::SourceMgrDiagnosticVerifier::ExpectedDiag::matched = false

A flag indicating if the expected diagnostic has been matched yet.

Definition at line 83 of file SourceMgrDiagnosticVerifier.h.

◆ substring

StringRef llvm::SourceMgrDiagnosticVerifier::ExpectedDiag::substring

The substring that is expected to be within the diagnostic.

Definition at line 85 of file SourceMgrDiagnosticVerifier.h.

Referenced by computeRegex(), emitError(), ExpectedDiag(), and match().

◆ substringRegex

std::optional<Regex> llvm::SourceMgrDiagnosticVerifier::ExpectedDiag::substringRegex

An optional regex matcher, if the expected diagnostic substring was a regex string.

Definition at line 88 of file SourceMgrDiagnosticVerifier.h.

Referenced by computeRegex(), and match().


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