#include "llvm/FileCheck/FileCheck.h"
#include "FileCheckImpl.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/CheckedArithmetic.h"
#include "llvm/Support/FormatVariadic.h"
#include <cstdint>
#include <list>
#include <set>
#include <tuple>
#include <utility>
usingnamespacellvm;
StringRef ExpressionFormat::toString() const { … }
Expected<std::string> ExpressionFormat::getWildcardRegex() const { … }
Expected<std::string>
ExpressionFormat::getMatchingString(APInt IntValue) const { … }
static unsigned nextAPIntBitWidth(unsigned BitWidth) { … }
static APInt toSigned(APInt AbsVal, bool Negative) { … }
APInt ExpressionFormat::valueFromStringRepr(StringRef StrVal,
const SourceMgr &SM) const { … }
Expected<APInt> llvm::exprAdd(const APInt &LeftOperand,
const APInt &RightOperand, bool &Overflow) { … }
Expected<APInt> llvm::exprSub(const APInt &LeftOperand,
const APInt &RightOperand, bool &Overflow) { … }
Expected<APInt> llvm::exprMul(const APInt &LeftOperand,
const APInt &RightOperand, bool &Overflow) { … }
Expected<APInt> llvm::exprDiv(const APInt &LeftOperand,
const APInt &RightOperand, bool &Overflow) { … }
Expected<APInt> llvm::exprMax(const APInt &LeftOperand,
const APInt &RightOperand, bool &Overflow) { … }
Expected<APInt> llvm::exprMin(const APInt &LeftOperand,
const APInt &RightOperand, bool &Overflow) { … }
Expected<APInt> NumericVariableUse::eval() const { … }
Expected<APInt> BinaryOperation::eval() const { … }
Expected<ExpressionFormat>
BinaryOperation::getImplicitFormat(const SourceMgr &SM) const { … }
Expected<std::string> NumericSubstitution::getResult() const { … }
Expected<std::string> StringSubstitution::getResult() const { … }
bool Pattern::isValidVarNameStart(char C) { … }
Expected<Pattern::VariableProperties>
Pattern::parseVariable(StringRef &Str, const SourceMgr &SM) { … }
constexpr StringLiteral SpaceChars = …;
static char popFront(StringRef &S) { … }
char OverflowError::ID = …;
char UndefVarError::ID = …;
char ErrorDiagnostic::ID = …;
char NotFoundError::ID = …;
char ErrorReported::ID = …;
Expected<NumericVariable *> Pattern::parseNumericVariableDefinition(
StringRef &Expr, FileCheckPatternContext *Context,
std::optional<size_t> LineNumber, ExpressionFormat ImplicitFormat,
const SourceMgr &SM) { … }
Expected<std::unique_ptr<NumericVariableUse>> Pattern::parseNumericVariableUse(
StringRef Name, bool IsPseudo, std::optional<size_t> LineNumber,
FileCheckPatternContext *Context, const SourceMgr &SM) { … }
Expected<std::unique_ptr<ExpressionAST>> Pattern::parseNumericOperand(
StringRef &Expr, AllowedOperand AO, bool MaybeInvalidConstraint,
std::optional<size_t> LineNumber, FileCheckPatternContext *Context,
const SourceMgr &SM) { … }
Expected<std::unique_ptr<ExpressionAST>>
Pattern::parseParenExpr(StringRef &Expr, std::optional<size_t> LineNumber,
FileCheckPatternContext *Context, const SourceMgr &SM) { … }
Expected<std::unique_ptr<ExpressionAST>>
Pattern::parseBinop(StringRef Expr, StringRef &RemainingExpr,
std::unique_ptr<ExpressionAST> LeftOp,
bool IsLegacyLineExpr, std::optional<size_t> LineNumber,
FileCheckPatternContext *Context, const SourceMgr &SM) { … }
Expected<std::unique_ptr<ExpressionAST>>
Pattern::parseCallExpr(StringRef &Expr, StringRef FuncName,
std::optional<size_t> LineNumber,
FileCheckPatternContext *Context, const SourceMgr &SM) { … }
Expected<std::unique_ptr<Expression>> Pattern::parseNumericSubstitutionBlock(
StringRef Expr, std::optional<NumericVariable *> &DefinedNumericVariable,
bool IsLegacyLineExpr, std::optional<size_t> LineNumber,
FileCheckPatternContext *Context, const SourceMgr &SM) { … }
bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix,
SourceMgr &SM, const FileCheckRequest &Req) { … }
bool Pattern::AddRegExToRegEx(StringRef RS, unsigned &CurParen, SourceMgr &SM) { … }
void Pattern::AddBackrefToRegEx(unsigned BackrefNum) { … }
Pattern::MatchResult Pattern::match(StringRef Buffer,
const SourceMgr &SM) const { … }
unsigned Pattern::computeMatchDistance(StringRef Buffer) const { … }
void Pattern::printSubstitutions(const SourceMgr &SM, StringRef Buffer,
SMRange Range,
FileCheckDiag::MatchType MatchTy,
std::vector<FileCheckDiag> *Diags) const { … }
void Pattern::printVariableDefs(const SourceMgr &SM,
FileCheckDiag::MatchType MatchTy,
std::vector<FileCheckDiag> *Diags) const { … }
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 AdjustPrevDiags = false) { … }
void Pattern::printFuzzyMatch(const SourceMgr &SM, StringRef Buffer,
std::vector<FileCheckDiag> *Diags) const { … }
Expected<StringRef>
FileCheckPatternContext::getPatternVarValue(StringRef VarName) { … }
template <class... Types>
NumericVariable *FileCheckPatternContext::makeNumericVariable(Types... args) { … }
Substitution *
FileCheckPatternContext::makeStringSubstitution(StringRef VarName,
size_t InsertIdx) { … }
Substitution *FileCheckPatternContext::makeNumericSubstitution(
StringRef ExpressionStr, std::unique_ptr<Expression> Expression,
size_t InsertIdx) { … }
size_t Pattern::FindRegexVarEnd(StringRef Str, SourceMgr &SM) { … }
StringRef FileCheck::CanonicalizeFile(MemoryBuffer &MB,
SmallVectorImpl<char> &OutputBuffer) { … }
FileCheckDiag::FileCheckDiag(const SourceMgr &SM,
const Check::FileCheckType &CheckTy,
SMLoc CheckLoc, MatchType MatchTy,
SMRange InputRange, StringRef Note)
: … { … }
static bool IsPartOfWord(char c) { … }
Check::FileCheckType &Check::FileCheckType::setCount(int C) { … }
std::string Check::FileCheckType::getModifiersDescription() const { … }
std::string Check::FileCheckType::getDescription(StringRef Prefix) const { … }
static std::pair<Check::FileCheckType, StringRef>
FindCheckType(const FileCheckRequest &Req, StringRef Buffer, StringRef Prefix,
bool &Misspelled) { … }
static std::pair<Check::FileCheckType, StringRef>
FindCheckType(const FileCheckRequest &Req, StringRef Buffer, StringRef Prefix) { … }
static size_t SkipWord(StringRef Str, size_t Loc) { … }
static const char *DefaultCheckPrefixes[] = …;
static const char *DefaultCommentPrefixes[] = …;
static void addDefaultPrefixes(FileCheckRequest &Req) { … }
struct PrefixMatcher { … };
static std::pair<StringRef, StringRef>
FindFirstMatchingPrefix(const FileCheckRequest &Req, PrefixMatcher &Matcher,
StringRef &Buffer, unsigned &LineNumber,
Check::FileCheckType &CheckTy) { … }
void FileCheckPatternContext::createLineVariable() { … }
FileCheck::FileCheck(FileCheckRequest Req)
: … { … }
FileCheck::~FileCheck() = default;
bool FileCheck::readCheckFile(
SourceMgr &SM, StringRef Buffer,
std::pair<unsigned, unsigned> *ImpPatBufferIDRange) { … }
static Error printMatch(bool ExpectedMatch, const SourceMgr &SM,
StringRef Prefix, SMLoc Loc, const Pattern &Pat,
int MatchedCount, StringRef Buffer,
Pattern::MatchResult MatchResult,
const FileCheckRequest &Req,
std::vector<FileCheckDiag> *Diags) { … }
static Error printNoMatch(bool ExpectedMatch, const SourceMgr &SM,
StringRef Prefix, SMLoc Loc, const Pattern &Pat,
int MatchedCount, StringRef Buffer, Error MatchError,
bool VerboseVerbose,
std::vector<FileCheckDiag> *Diags) { … }
static Error reportMatchResult(bool ExpectedMatch, const SourceMgr &SM,
StringRef Prefix, SMLoc Loc, const Pattern &Pat,
int MatchedCount, StringRef Buffer,
Pattern::MatchResult MatchResult,
const FileCheckRequest &Req,
std::vector<FileCheckDiag> *Diags) { … }
static unsigned CountNumNewlinesBetween(StringRef Range,
const char *&FirstNewLine) { … }
size_t FileCheckString::Check(const SourceMgr &SM, StringRef Buffer,
bool IsLabelScanMode, size_t &MatchLen,
FileCheckRequest &Req,
std::vector<FileCheckDiag> *Diags) const { … }
bool FileCheckString::CheckNext(const SourceMgr &SM, StringRef Buffer) const { … }
bool FileCheckString::CheckSame(const SourceMgr &SM, StringRef Buffer) const { … }
bool FileCheckString::CheckNot(
const SourceMgr &SM, StringRef Buffer,
const std::vector<const DagNotPrefixInfo *> &NotStrings,
const FileCheckRequest &Req, std::vector<FileCheckDiag> *Diags) const { … }
size_t
FileCheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
std::vector<const DagNotPrefixInfo *> &NotStrings,
const FileCheckRequest &Req,
std::vector<FileCheckDiag> *Diags) const { … }
static bool ValidatePrefixes(StringRef Kind, StringSet<> &UniquePrefixes,
ArrayRef<StringRef> SuppliedPrefixes) { … }
bool FileCheck::ValidateCheckPrefixes() { … }
Error FileCheckPatternContext::defineCmdlineVariables(
ArrayRef<StringRef> CmdlineDefines, SourceMgr &SM) { … }
void FileCheckPatternContext::clearLocalVars() { … }
bool FileCheck::checkInput(SourceMgr &SM, StringRef Buffer,
std::vector<FileCheckDiag> *Diags) { … }