15 #ifndef LLVM_LIB_SUPPORT_FILECHECKIMPL_H 16 #define LLVM_LIB_SUPPORT_FILECHECKIMPL_H 100 : Name(Name), DefLineNumber(DefLineNumber) {}
109 void setValue(uint64_t NewValue) { Value = NewValue; }
132 : Name(Name), Variable(Variable) {}
145 std::unique_ptr<ExpressionAST> LeftOperand;
148 std::unique_ptr<ExpressionAST> RightOperand;
155 std::unique_ptr<ExpressionAST> RightOp)
156 : EvalBinop(EvalBinop) {
157 LeftOperand = std::move(LeftOp);
158 RightOperand = std::move(RightOp);
191 : Context(Context), FromStr(VarName), InsertIdx(InsertIdx) {}
221 std::unique_ptr<ExpressionAST> ExpressionASTPointer;
225 std::unique_ptr<ExpressionAST> ExprAST,
size_t InsertIdx)
227 ExpressionASTPointer = std::move(ExprAST);
271 std::vector<std::unique_ptr<NumericVariable>> NumericVariables;
275 std::vector<std::unique_ptr<Substitution>> Substitutions;
286 Error defineCmdlineVariables(std::vector<std::string> &CmdlineDefines,
291 void createLineVariable();
297 void clearLocalVars();
302 template <
class... Types>
NumericVariable *makeNumericVariable(Types... args);
311 makeNumericSubstitution(
StringRef ExpressionStr,
335 return make_error<ErrorDiagnostic>(
354 OS <<
"String not found in input";
367 std::string RegExStr;
375 std::vector<Substitution *> Substitutions;
388 std::map<StringRef, unsigned> VariableDefs;
394 struct NumericVariableMatch {
401 unsigned CaptureParenGroup;
425 bool IgnoreCase =
false;
430 : Context(Context), CheckTy(Ty), LineNumber(Line) {}
440 static bool isValidVarNameStart(
char C);
497 std::vector<FileCheckDiag> *Diags)
const;
500 return !(Substitutions.empty() && VariableDefs.empty());
509 void AddBackrefToRegEx(
unsigned BackrefNum);
513 unsigned computeMatchDistance(
StringRef Buffer)
const;
539 enum class AllowedOperand { LineVar,
Literal,
Any };
548 parseNumericOperand(
StringRef &Expr, AllowedOperand AO,
559 parseBinop(
StringRef &Expr, std::unique_ptr<ExpressionAST> LeftOp,
584 : Pat(P), Prefix(S), Loc(L) {}
589 std::vector<FileCheckDiag> *Diags)
const;
601 const std::vector<const Pattern *> &NotStrings,
603 std::vector<FileCheckDiag> *Diags)
const;
606 std::vector<const Pattern *> &NotStrings,
608 std::vector<FileCheckDiag> *Diags)
const;
static bool Check(DecodeStatus &Out, DecodeStatus In)
FileCheckPatternContext * Context
Pointer to a class instance holding, among other things, the table with the values of live string var...
void log(raw_ostream &OS) const override
Print diagnostic associated with this error when printing the error.
Represents a range in source code.
Check::FileCheckType getCheckTy() const
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
NumericVariable(StringRef Name, Optional< size_t > DefLineNumber=None)
Constructor for a variable Name defined at line DefLineNumber or defined before input is parsed if De...
This class represents lattice values for constants.
void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true) const
StringRef getName() const
ExpressionLiteral(uint64_t Val)
Constructs a literal with the specified value.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Pattern(Check::FileCheckType Ty, FileCheckPatternContext *Context, Optional< size_t > Line=None)
Class representing a substitution to perform in the RegExStr string.
Class representing a single binary operation in the AST of an expression.
void log(raw_ostream &OS) const override
Print name of variable associated with this error.
Class to represent an error holding a diagnostic with location information used when printing it...
StringSubstitution(FileCheckPatternContext *Context, StringRef VarName, size_t InsertIdx)
Class representing a numeric variable and its associated current value.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckSame(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode *>> &RecordedNodes)
CheckSame - Implements OP_CheckSame.
StringRef Prefix
Which prefix name this check matched.
bool match(Val *V, const Pattern &P)
void clearValue()
Clears value of this numeric variable, regardless of whether it is currently defined or not...
Class holding the Pattern global state, shared by all patterns: tables holding values of variables an...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SMLoc Loc
The location in the match file that the check string was specified.
Class representing the use of a numeric variable in the AST of an expression.
NumericVariableUse(StringRef Name, NumericVariable *Variable)
Tagged union holding either a T or a Error.
FileCheckPatternContext * getContext() const
void setValue(uint64_t NewValue)
Sets value of this numeric variable to NewValue.
StringRef FromStr
The string that needs to be substituted for something else.
Contains info about various FileCheck options.
std::vector< Pattern > DagNotStrings
All of the strings that are disallowed from occurring between this match string and the previous one ...
A check that we found in the input file.
StringRef getFromString() const
Class representing an unsigned literal in the AST of an expression.
Class to represent an undefined variable error, which quotes that variable's name when printed...
virtual Expected< uint64_t > eval() const =0
Evaluates and.
Optional< uint64_t > getValue() const
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
void log(raw_ostream &OS) const override
Print diagnostic associated with this error when printing the error.
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an escape...
Substitution(FileCheckPatternContext *Context, StringRef VarName, size_t InsertIdx)
ErrorDiagnostic(SMDiagnostic &&Diag)
NumericSubstitution(FileCheckPatternContext *Context, StringRef Expr, std::unique_ptr< ExpressionAST > ExprAST, size_t InsertIdx)
BinaryOperation(binop_eval_t EvalBinop, std::unique_ptr< ExpressionAST > LeftOp, std::unique_ptr< ExpressionAST > RightOp)
uint64_t(*)(uint64_t, uint64_t) binop_eval_t
Type of functions evaluating a given binary operation.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Base class for user error types.
static SMLoc getFromPointer(const char *Ptr)
Expected< uint64_t > eval() const override
Base class representing the AST of a given expression.
FileCheckString(const Pattern &P, StringRef S, SMLoc L)
Pattern Pat
The pattern to match.
StringRef getVarName() const
Lightweight error class with error context and mandatory checking.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
Parsing information about a variable.
UndefVarError(StringRef VarName)
Represents a location in source code.
Optional< size_t > getDefLineNumber() const
virtual ~ExpressionAST()=default
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...