class FileCheckPatternContext

Declaration

class FileCheckPatternContext { /* full declaration omitted */ };

Description

Class holding the Pattern global state, shared by all patterns: tables holding values of variables and whether they are defined or not at any given time in the matching process.

Declared at: llvm/lib/FileCheck/FileCheckImpl.h:459

Member Variables

private StringMap<llvm::StringRef> GlobalVariableTable
When matching a given pattern, this holds the value of all the string variables defined in previous patterns. In a pattern, only the last definition for a given variable is recorded in this table. Back-references are used for uses after any the other definition.
private StringMap<bool> DefinedVariableTable
Map of all string variables defined so far. Used at parse time to detect a name conflict between a numeric variable and a string variable when the former is defined on a later line than the latter.
private StringMap<llvm::NumericVariable*> GlobalNumericVariableTable
When matching a given pattern, this holds the pointers to the classes representing the numeric variables defined in previous patterns. When matching a pattern all definitions for that pattern are recorded in the NumericVariableDefs table in the Pattern instance of that pattern.
private llvm::NumericVariable* LineVariable = nullptr
Pointer to the class instance representing the @LINEpseudo variable for easily updating its value.
private std::vector<std::unique_ptr<NumericVariable>> NumericVariables
Vector holding pointers to all parsed numeric variables. Used to automatically free them once they are guaranteed to no longer be used.
private std::vector<std::unique_ptr<Expression>> Expressions
Vector holding pointers to all parsed expressions. Used to automatically free the expressions once they are guaranteed to no longer be used.
private std::vector<std::unique_ptr<Substitution>> Substitutions
Vector holding pointers to all substitutions. Used to automatically free them once they are guaranteed to no longer be used.

Method Overview

Methods

void clearLocalVars()

Description

Undefines local variables (variables whose name does not start with a '$' sign), i.e. removes them from GlobalVariableTable and from GlobalNumericVariableTable and also clears the value of numeric variables.

Declared at: llvm/lib/FileCheck/FileCheckImpl.h:516

void createLineVariable()

Description

Create @LINEpseudo variable. Value is set when pattern are being matched.

Declared at: llvm/lib/FileCheck/FileCheckImpl.h:510

llvm::Error defineCmdlineVariables(
    ArrayRef<llvm::StringRef> CmdlineDefines,
    llvm::SourceMgr& SM)

Description

Defines string and numeric variables from definitions given on the command line, passed as a vector of [#]VAR=VAL strings in\p CmdlineDefines.

Declared at: llvm/lib/FileCheck/FileCheckImpl.h:505

Parameters

ArrayRef<llvm::StringRef> CmdlineDefines
llvm::SourceMgr& SM

Returns

an error list containing diagnostics against\p SM for all definition parsing failures, if any, or Success otherwise.

Expected<llvm::StringRef> getPatternVarValue(
    llvm::StringRef VarName)

Declared at: llvm/lib/FileCheck/FileCheckImpl.h:499

Parameters

llvm::StringRef VarName

Returns

the value of string variable \p VarName or an error if no such variable has been defined.

llvm::Substitution* makeNumericSubstitution(
    llvm::StringRef ExpressionStr,
    std::unique_ptr<Expression> Expression,
    size_t InsertIdx)

Description

Makes a new numeric substitution and registers it for destruction when the context is destroyed.

Declared at: llvm/lib/FileCheck/FileCheckImpl.h:529

Parameters

llvm::StringRef ExpressionStr
std::unique_ptr<Expression> Expression
size_t InsertIdx

template <class... Types>
llvm::NumericVariable* makeNumericVariable(
    Types... args)

Description

Makes a new numeric variable and registers it for destruction when the context is destroyed.

Declared at: llvm/lib/FileCheck/FileCheckImpl.h:521

Templates

Types

Parameters

Types... args

llvm::Substitution* makeStringSubstitution(
    llvm::StringRef VarName,
    size_t InsertIdx)

Description

Makes a new string substitution and registers it for destruction when the context is destroyed.

Declared at: llvm/lib/FileCheck/FileCheckImpl.h:525

Parameters

llvm::StringRef VarName
size_t InsertIdx