LLVM  9.0.0svn
Public Member Functions | List of all members
llvm::FileCheckPattern Class Reference

#include "llvm/Support/FileCheck.h"

Public Member Functions

 FileCheckPattern (Check::FileCheckType Ty, FileCheckPatternContext *Context)
 
SMLoc getLoc () const
 Returns the location in source code. More...
 
FileCheckPatternContextgetContext () const
 Returns the pointer to the global state for all patterns in this FileCheck instance. More...
 
bool ParsePattern (StringRef PatternStr, StringRef Prefix, SourceMgr &SM, unsigned LineNumber, const FileCheckRequest &Req)
 Parses the given string into the Pattern. More...
 
size_t match (StringRef Buffer, size_t &MatchLen) const
 Matches the pattern string against the input buffer Buffer. More...
 
void printVariableUses (const SourceMgr &SM, StringRef Buffer, SMRange MatchRange=None) const
 Print value of successful substitutions or name of undefined pattern variables preventing such a successful substitution. More...
 
void printFuzzyMatch (const SourceMgr &SM, StringRef Buffer, std::vector< FileCheckDiag > *Diags) const
 
bool hasVariable () const
 
Check::FileCheckType getCheckTy () const
 
int getCount () const
 

Detailed Description

Definition at line 113 of file FileCheck.h.

Constructor & Destructor Documentation

◆ FileCheckPattern()

llvm::FileCheckPattern::FileCheckPattern ( Check::FileCheckType  Ty,
FileCheckPatternContext Context 
)
inlineexplicit

Definition at line 146 of file FileCheck.h.

Member Function Documentation

◆ getCheckTy()

Check::FileCheckType llvm::FileCheckPattern::getCheckTy ( ) const
inline

◆ getContext()

FileCheckPatternContext* llvm::FileCheckPattern::getContext ( ) const
inline

Returns the pointer to the global state for all patterns in this FileCheck instance.

Definition at line 155 of file FileCheck.h.

References Context, llvm::PatternMatch::match(), llvm::None, and llvm::cl::Prefix.

◆ getCount()

int llvm::FileCheckPattern::getCount ( ) const
inline

Definition at line 172 of file FileCheck.h.

References EvaluateExpression(), and llvm::Check::FileCheckType::getCount().

Referenced by PrintMatch(), and PrintNoMatch().

◆ getLoc()

SMLoc llvm::FileCheckPattern::getLoc ( ) const
inline

Returns the location in source code.

Definition at line 151 of file FileCheck.h.

Referenced by printFuzzyMatch().

◆ hasVariable()

bool llvm::FileCheckPattern::hasVariable ( ) const
inline

Definition at line 166 of file FileCheck.h.

◆ match()

size_t FileCheckPattern::match ( StringRef  Buffer,
size_t &  MatchLen 
) const

Matches the pattern string against the input buffer Buffer.

This returns the position that is matched or npos if there is no match. If there is a match, the size of the matched string is returned in MatchLen.

The GlobalVariableTable StringMap in the FileCheckPatternContext class instance provides the current values of FileCheck variables and is updated if this match defines new values.

Definition at line 275 of file FileCheck.cpp.

References assert(), llvm::Check::CheckEmpty, llvm::Check::CheckEOF, llvm::StringRef::data(), llvm::StringRef::edit_distance(), llvm::SmallVectorBase::empty(), llvm::StringRef::empty(), llvm::Regex::escape(), llvm::StringRef::find(), llvm::FileCheckPatternContext::getVarValue(), llvm::Regex::Newline, llvm::StringRef::npos, llvm::SmallVectorBase::size(), llvm::StringRef::size(), llvm::StringRef::split(), and llvm::StringRef::substr().

◆ ParsePattern()

bool FileCheckPattern::ParsePattern ( StringRef  PatternStr,
StringRef  Prefix,
SourceMgr SM,
unsigned  LineNumber,
const FileCheckRequest Req 
)

Parses the given string into the Pattern.

Prefix provides which prefix is being matched, SM provides the SourceMgr used for error reports, and LineNumber is the line number in the input file from which the pattern string was read. Returns true in case of an error, false otherwise.

Definition at line 33 of file FileCheck.cpp.

References llvm::StringRef::back(), llvm::Check::CheckEmpty, llvm::Check::CheckNot, llvm::StringRef::data(), llvm::SourceMgr::DK_Error, llvm::StringRef::empty(), llvm::StringRef::find(), llvm::SMLoc::getFromPointer(), llvm::FileCheckRequest::MatchFullLines, llvm::FileCheckRequest::NoCanonicalizeWhiteSpace, llvm::StringRef::npos, llvm::SourceMgr::PrintMessage(), llvm::StringRef::size(), llvm::StringRef::startswith(), and llvm::StringRef::substr().

◆ printFuzzyMatch()

void FileCheckPattern::printFuzzyMatch ( const SourceMgr SM,
StringRef  Buffer,
std::vector< FileCheckDiag > *  Diags 
) const

◆ printVariableUses()

void FileCheckPattern::printVariableUses ( const SourceMgr SM,
StringRef  Buffer,
SMRange  MatchRange = None 
) const

Print value of successful substitutions or name of undefined pattern variables preventing such a successful substitution.

Definition at line 368 of file FileCheck.cpp.

References llvm::StringRef::data(), llvm::SourceMgr::DK_Note, llvm::SMLoc::getFromPointer(), llvm::FileCheckPatternContext::getVarValue(), llvm::SMRange::isValid(), llvm::SourceMgr::PrintMessage(), llvm::SMRange::Start, llvm::raw_svector_ostream::str(), and llvm::raw_ostream::write_escaped().

Referenced by PrintMatch(), and PrintNoMatch().


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