LLVM  8.0.1
Functions
FileCheck.cpp File Reference
#include "llvm/Support/FileCheck.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/FormatVariadic.h"
#include <cstdint>
#include <list>
#include <map>
#include <tuple>
#include <utility>
Include dependency graph for FileCheck.cpp:

Go to the source code of this file.

Functions

static SMRange ProcessMatchResult (FileCheckDiag::MatchType MatchTy, const SourceMgr &SM, SMLoc Loc, Check::FileCheckType CheckTy, StringRef Buffer, size_t Pos, size_t Len, std::vector< FileCheckDiag > *Diags, bool AdjustPrevDiag=false)
 
static bool IsPartOfWord (char c)
 
static std::pair< Check::FileCheckType, StringRefFindCheckType (StringRef Buffer, StringRef Prefix)
 
static size_t SkipWord (StringRef Str, size_t Loc)
 
static std::pair< StringRef, StringRefFindFirstMatchingPrefix (Regex &PrefixRE, StringRef &Buffer, unsigned &LineNumber, Check::FileCheckType &CheckTy)
 Search the buffer for the first prefix in the prefix regular expression. More...
 
static void PrintMatch (bool ExpectedMatch, const SourceMgr &SM, StringRef Prefix, SMLoc Loc, const FileCheckPattern &Pat, int MatchedCount, StringRef Buffer, StringMap< StringRef > &VariableTable, size_t MatchPos, size_t MatchLen, const FileCheckRequest &Req, std::vector< FileCheckDiag > *Diags)
 
static void PrintMatch (bool ExpectedMatch, const SourceMgr &SM, const FileCheckString &CheckStr, int MatchedCount, StringRef Buffer, StringMap< StringRef > &VariableTable, size_t MatchPos, size_t MatchLen, FileCheckRequest &Req, std::vector< FileCheckDiag > *Diags)
 
static void PrintNoMatch (bool ExpectedMatch, const SourceMgr &SM, StringRef Prefix, SMLoc Loc, const FileCheckPattern &Pat, int MatchedCount, StringRef Buffer, StringMap< StringRef > &VariableTable, bool VerboseVerbose, std::vector< FileCheckDiag > *Diags)
 
static void PrintNoMatch (bool ExpectedMatch, const SourceMgr &SM, const FileCheckString &CheckStr, int MatchedCount, StringRef Buffer, StringMap< StringRef > &VariableTable, bool VerboseVerbose, std::vector< FileCheckDiag > *Diags)
 
static unsigned CountNumNewlinesBetween (StringRef Range, const char *&FirstNewLine)
 Count the number of newlines in the specified range. More...
 
static bool ValidateCheckPrefix (StringRef CheckPrefix)
 
static void ClearLocalVars (StringMap< StringRef > &VariableTable)
 

Function Documentation

◆ ClearLocalVars()

static void ClearLocalVars ( StringMap< StringRef > &  VariableTable)
static

◆ CountNumNewlinesBetween()

static unsigned CountNumNewlinesBetween ( StringRef  Range,
const char *&  FirstNewLine 
)
static

◆ FindCheckType()

static std::pair<Check::FileCheckType, StringRef> FindCheckType ( StringRef  Buffer,
StringRef  Prefix 
)
static

◆ FindFirstMatchingPrefix()

static std::pair<StringRef, StringRef> FindFirstMatchingPrefix ( Regex PrefixRE,
StringRef Buffer,
unsigned LineNumber,
Check::FileCheckType CheckTy 
)
static

Search the buffer for the first prefix in the prefix regular expression.

This searches the buffer using the provided regular expression, however it enforces constraints beyond that: 1) The found prefix must not be a suffix of something that looks like a valid prefix. 2) The found prefix must be followed by a valid check type suffix using FindCheckType above.

Returns a pair of StringRefs into the Buffer, which combines:

  • the first match of the regular expression to satisfy these two is returned, otherwise an empty StringRef is returned to indicate failure.
  • buffer rewound to the location right after parsed suffix, for parsing to continue from

If this routine returns a valid prefix, it will also shrink Buffer to start at the beginning of the returned prefix, increment LineNumber for each new line consumed from Buffer, and set CheckTy to the type of check found by examining the suffix.

If no valid prefix is found, the state of Buffer, LineNumber, and CheckTy is unspecified.

Definition at line 701 of file FileCheck.cpp.

References assert(), llvm::StringRef::back(), llvm::Check::CheckNone, llvm::SmallVectorImpl< T >::clear(), llvm::StringRef::count(), llvm::StringRef::data(), llvm::StringRef::drop_front(), llvm::StringRef::empty(), FindCheckType(), IsPartOfWord(), llvm::Regex::match(), llvm::cl::Prefix, llvm::StringRef::size(), SkipWord(), and llvm::StringRef::substr().

Referenced by llvm::FileCheck::ReadCheckFile().

◆ IsPartOfWord()

static bool IsPartOfWord ( char  c)
static

Definition at line 572 of file FileCheck.cpp.

Referenced by FindFirstMatchingPrefix(), and SkipWord().

◆ PrintMatch() [1/2]

static void PrintMatch ( bool  ExpectedMatch,
const SourceMgr SM,
StringRef  Prefix,
SMLoc  Loc,
const FileCheckPattern Pat,
int  MatchedCount,
StringRef  Buffer,
StringMap< StringRef > &  VariableTable,
size_t  MatchPos,
size_t  MatchLen,
const FileCheckRequest Req,
std::vector< FileCheckDiag > *  Diags 
)
static

◆ PrintMatch() [2/2]

static void PrintMatch ( bool  ExpectedMatch,
const SourceMgr SM,
const FileCheckString CheckStr,
int  MatchedCount,
StringRef  Buffer,
StringMap< StringRef > &  VariableTable,
size_t  MatchPos,
size_t  MatchLen,
FileCheckRequest Req,
std::vector< FileCheckDiag > *  Diags 
)
static

◆ PrintNoMatch() [1/2]

static void PrintNoMatch ( bool  ExpectedMatch,
const SourceMgr SM,
StringRef  Prefix,
SMLoc  Loc,
const FileCheckPattern Pat,
int  MatchedCount,
StringRef  Buffer,
StringMap< StringRef > &  VariableTable,
bool  VerboseVerbose,
std::vector< FileCheckDiag > *  Diags 
)
static

◆ PrintNoMatch() [2/2]

static void PrintNoMatch ( bool  ExpectedMatch,
const SourceMgr SM,
const FileCheckString CheckStr,
int  MatchedCount,
StringRef  Buffer,
StringMap< StringRef > &  VariableTable,
bool  VerboseVerbose,
std::vector< FileCheckDiag > *  Diags 
)
static

◆ ProcessMatchResult()

static SMRange ProcessMatchResult ( FileCheckDiag::MatchType  MatchTy,
const SourceMgr SM,
SMLoc  Loc,
Check::FileCheckType  CheckTy,
StringRef  Buffer,
size_t  Pos,
size_t  Len,
std::vector< FileCheckDiag > *  Diags,
bool  AdjustPrevDiag = false 
)
static

◆ SkipWord()

static size_t SkipWord ( StringRef  Str,
size_t  Loc 
)
static

Definition at line 671 of file FileCheck.cpp.

References IsPartOfWord(), and llvm::StringRef::size().

Referenced by FindFirstMatchingPrefix().

◆ ValidateCheckPrefix()

static bool ValidateCheckPrefix ( StringRef  CheckPrefix)
static

Definition at line 1320 of file FileCheck.cpp.

References llvm::Regex::match().

Referenced by llvm::FileCheck::ValidateCheckPrefixes().