LLVM 20.0.0git
|
#include "FileCheck/FileCheckImpl.h"
Classes | |
struct | Match |
struct | MatchResult |
struct | VariableProperties |
Parsing information about a variable. More... | |
Public Member Functions | |
Pattern (Check::FileCheckType Ty, FileCheckPatternContext *Context, std::optional< size_t > Line=std::nullopt) | |
SMLoc | getLoc () const |
FileCheckPatternContext * | getContext () const |
bool | parsePattern (StringRef PatternStr, StringRef Prefix, SourceMgr &SM, const FileCheckRequest &Req) |
Parses the pattern in PatternStr and initializes this Pattern instance accordingly. | |
MatchResult | match (StringRef Buffer, const SourceMgr &SM) const |
Matches the pattern string against the input buffer Buffer . | |
void | printSubstitutions (const SourceMgr &SM, StringRef Buffer, SMRange MatchRange, FileCheckDiag::MatchType MatchTy, std::vector< FileCheckDiag > *Diags) const |
Prints the value of successful substitutions. | |
void | printFuzzyMatch (const SourceMgr &SM, StringRef Buffer, std::vector< FileCheckDiag > *Diags) const |
bool | hasVariable () const |
void | printVariableDefs (const SourceMgr &SM, FileCheckDiag::MatchType MatchTy, std::vector< FileCheckDiag > *Diags) const |
Check::FileCheckType | getCheckTy () const |
int | getCount () const |
Static Public Member Functions | |
static bool | isValidVarNameStart (char C) |
static Expected< VariableProperties > | parseVariable (StringRef &Str, const SourceMgr &SM) |
Parses the string at the start of Str for a variable name. | |
static Expected< std::unique_ptr< Expression > > | parseNumericSubstitutionBlock (StringRef Expr, std::optional< NumericVariable * > &DefinedNumericVariable, bool IsLegacyLineExpr, std::optional< size_t > LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) |
Parses Expr for a numeric substitution block at line LineNumber , or before input is parsed if LineNumber is None. | |
Definition at line 565 of file FileCheckImpl.h.
|
inline |
Definition at line 635 of file FileCheckImpl.h.
|
inline |
Definition at line 722 of file FileCheckImpl.h.
Referenced by llvm::FileCheckString::Check(), llvm::FileCheckString::CheckDag(), llvm::FileCheck::checkInput(), llvm::FileCheckString::CheckNext(), llvm::FileCheckString::CheckSame(), printFuzzyMatch(), printMatch(), and printNoMatch().
|
inline |
Definition at line 644 of file FileCheckImpl.h.
|
inline |
Definition at line 724 of file FileCheckImpl.h.
References llvm::Check::FileCheckType::getCount().
Referenced by llvm::FileCheckString::Check(), printMatch(), and printNoMatch().
|
inline |
Definition at line 640 of file FileCheckImpl.h.
Referenced by llvm::FileCheckString::CheckDag(), printFuzzyMatch(), printSubstitutions(), and printVariableDefs().
|
inline |
Definition at line 716 of file FileCheckImpl.h.
C
is a valid first character for a variable name. Definition at line 286 of file FileCheck.cpp.
References llvm::CallingConv::C.
Referenced by parseVariable().
Pattern::MatchResult Pattern::match | ( | StringRef | Buffer, |
const SourceMgr & | SM | ||
) | const |
Matches the pattern string against the input buffer Buffer
.
The GlobalVariableTable StringMap in the FileCheckPatternContext class instance provides the current values of FileCheck string variables and is updated if this match defines new values. Likewise, the GlobalNumericVariableTable StringMap in the same class provides the current values of FileCheck numeric variables and is updated if this match defines new numeric values.
Definition at line 1077 of file FileCheck.cpp.
References assert(), llvm::Check::CheckEmpty, llvm::Check::CheckEOF, llvm::StringRef::data(), llvm::SmallVectorBase< Size_T >::empty(), llvm::StringRef::empty(), llvm::StringRef::find(), llvm::StringRef::find_insensitive(), llvm::Format, llvm::NumericVariable::getImplicitFormat(), llvm::Substitution::getIndex(), llvm::Substitution::getResult(), llvm::handleErrors(), llvm::Regex::IgnoreCase, llvm::joinErrors(), llvm::Pattern::Match::Len, match(), llvm::Regex::Newline, llvm::StringRef::npos, llvm::Pattern::Match::Pos, llvm::NumericVariable::setValue(), llvm::SmallVectorBase< Size_T >::size(), llvm::StringRef::size(), and llvm::Error::success().
Referenced by llvm::FileCheckString::Check(), llvm::FileCheckString::CheckDag(), llvm::ifs::filterIFSSyms(), llvm::SDPatternMatch::NUses_match< NumUses, Pattern >::match(), llvm::SDPatternMatch::TLI_pred_match< Pattern, PredFuncT >::match(), llvm::SDPatternMatch::ValueType_match< Pattern, PredFuncT >::match(), llvm::SDPatternMatch::SwitchContext< NewMatchContext, Pattern >::match(), and match().
|
static |
Parses Expr
for a numeric substitution block at line LineNumber
, or before input is parsed if LineNumber
is None.
Parameter IsLegacyLineExpr
indicates whether Expr
should be a legacy @LINE expression and Context
points to the class instance holding the live string and numeric variables.
SM
if parsing fails. If substitution was successful, sets DefinedNumericVariable
to point to the class representing the numeric variable defined in this numeric substitution block, or std::nullopt if this block does not define any variable. Definition at line 617 of file FileCheck.cpp.
References llvm::StringRef::consume_front(), llvm::StringRef::consumeInteger(), llvm::StringRef::data(), llvm::StringRef::drop_front(), llvm::StringRef::empty(), llvm::StringRef::find(), llvm::Format, llvm::ErrorDiagnostic::get(), llvm::SMLoc::getFromPointer(), llvm::ExpressionFormat::HexLower, llvm::ExpressionFormat::HexUpper, llvm::StringRef::ltrim(), llvm::StringRef::npos, popFront(), llvm::StringRef::rtrim(), llvm::ExpressionFormat::Signed, SpaceChars, llvm::StringRef::substr(), llvm::StringRef::take_front(), llvm::Expected< T >::takeError(), llvm::StringRef::trim(), and llvm::ExpressionFormat::Unsigned.
Referenced by llvm::FileCheckPatternContext::defineCmdlineVariables(), and parsePattern().
bool Pattern::parsePattern | ( | StringRef | PatternStr, |
StringRef | Prefix, | ||
SourceMgr & | SM, | ||
const FileCheckRequest & | Req | ||
) |
Parses the pattern in PatternStr
and initializes this Pattern instance accordingly.
Prefix
provides which prefix is being matched, Req
describes the global options that influence the parsing such as whitespace canonicalization, SM
provides the SourceMgr used for error reports.
Definition at line 764 of file FileCheck.cpp.
References llvm::cantFail(), llvm::Check::CheckEmpty, llvm::Check::CheckNot, llvm::StringRef::consume_front(), llvm::StringRef::contains(), llvm::StringRef::data(), llvm::SourceMgr::DK_Error, llvm::StringRef::empty(), End, llvm::errs(), llvm::Regex::escape(), llvm::StringRef::find(), llvm::StringRef::find_first_of(), llvm::Format, llvm::SMLoc::getFromPointer(), llvm::FileCheckRequest::IgnoreCase, llvm::Check::FileCheckType::isLiteralMatch(), llvm::logAllUnhandledErrors(), llvm::FileCheckRequest::MatchFullLines, Name, llvm::FileCheckRequest::NoCanonicalizeWhiteSpace, llvm::StringRef::npos, parseNumericSubstitutionBlock(), parseVariable(), llvm::SourceMgr::PrintMessage(), llvm::StringRef::rtrim(), llvm::StringRef::size(), llvm::StringRef::starts_with(), llvm::StringRef::substr(), and llvm::Expected< T >::takeError().
|
static |
Parses the string at the start of Str
for a variable name.
SM
if parsing fail. If parsing was successful, also strips Str
from the variable name. Definition at line 289 of file FileCheck.cpp.
References llvm::ErrorDiagnostic::get(), I, isValidVarNameStart(), and Name.
Referenced by llvm::FileCheckPatternContext::defineCmdlineVariables(), and parsePattern().
void Pattern::printFuzzyMatch | ( | const SourceMgr & | SM, |
StringRef | Buffer, | ||
std::vector< FileCheckDiag > * | Diags | ||
) | const |
Definition at line 1313 of file FileCheck.cpp.
References llvm::SourceMgr::DK_Note, getCheckTy(), getLoc(), llvm::FileCheckDiag::MatchFuzzy, llvm::StringRef::npos, llvm::SourceMgr::PrintMessage(), ProcessMatchResult(), llvm::StringRef::size(), llvm::SMRange::Start, and llvm::StringRef::substr().
Referenced by printNoMatch().
void Pattern::printSubstitutions | ( | const SourceMgr & | SM, |
StringRef | Buffer, | ||
SMRange | MatchRange, | ||
FileCheckDiag::MatchType | MatchTy, | ||
std::vector< FileCheckDiag > * | Diags | ||
) | const |
Prints the value of successful substitutions.
Definition at line 1205 of file FileCheck.cpp.
References llvm::consumeError(), llvm::SourceMgr::DK_Note, llvm::Substitution::getFromString(), getLoc(), llvm::Substitution::getResult(), OS, llvm::SourceMgr::PrintMessage(), Range, llvm::Expected< T >::takeError(), and llvm::raw_ostream::write_escaped().
Referenced by printMatch(), and printNoMatch().
void Pattern::printVariableDefs | ( | const SourceMgr & | SM, |
FileCheckDiag::MatchType | MatchTy, | ||
std::vector< FileCheckDiag > * | Diags | ||
) | const |
Definition at line 1239 of file FileCheck.cpp.
References A, assert(), B, llvm::SourceMgr::DK_Note, llvm::StringMapImpl::empty(), End, llvm::SMLoc::getFromPointer(), getLoc(), Name, OS, llvm::SourceMgr::PrintMessage(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), Range, and llvm::sort().
Referenced by printMatch().