diff options
| author | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-07-24 07:32:34 +0000 |
|---|---|---|
| committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2019-07-24 07:32:34 +0000 |
| commit | 5ecb8802414ce55affd02a54ee7b1cff76ae1397 (patch) | |
| tree | 19897e42656ff8f4d9a71f453c709978594d1567 /llvm/include | |
| parent | 75299de1911c899b7fb014ed73b24f1541fa21e9 (diff) | |
| download | bcm5719-llvm-5ecb8802414ce55affd02a54ee7b1cff76ae1397.tar.gz bcm5719-llvm-5ecb8802414ce55affd02a54ee7b1cff76ae1397.zip | |
Revert "FileCheck [8/12]: Define numeric var from expr"
This reverts commit 1b05977538d9487aa845ee2f3bec8b89c63c4f29.
llvm-svn: 366872
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/Support/FileCheck.h | 116 |
1 files changed, 39 insertions, 77 deletions
diff --git a/llvm/include/llvm/Support/FileCheck.h b/llvm/include/llvm/Support/FileCheck.h index dfe7513ac98..69345266f2e 100644 --- a/llvm/include/llvm/Support/FileCheck.h +++ b/llvm/include/llvm/Support/FileCheck.h @@ -94,11 +94,6 @@ private: /// Name of the numeric variable. StringRef Name; - /// Pointer to expression defining this numeric variable. Null for pseudo - /// variable whose value is known at parse time (e.g. @LINE pseudo variable) - /// or cleared local variable. - FileCheckExpressionAST *ExpressionAST; - /// Value of numeric variable, if defined, or None otherwise. Optional<uint64_t> Value; @@ -109,14 +104,10 @@ private: public: /// Constructor for a variable \p Name defined at line \p DefLineNumber or - /// defined before input is parsed if \p DefLineNumber is None. If not null, - /// the value set with setValue must match the result of evaluating - /// \p ExpressionAST. + /// defined before input is parsed if DefLineNumber is None. FileCheckNumericVariable(StringRef Name, - Optional<size_t> DefLineNumber = None, - FileCheckExpressionAST *ExpressionAST = nullptr) - : Name(Name), ExpressionAST(ExpressionAST), DefLineNumber(DefLineNumber) { - } + Optional<size_t> DefLineNumber = None) + : Name(Name), DefLineNumber(DefLineNumber) {} /// \returns name of this numeric variable. StringRef getName() const { return Name; } @@ -124,25 +115,12 @@ public: /// \returns this variable's value. Optional<uint64_t> getValue() const { return Value; } - /// \returns the pointer to the expression defining this numeric variable, if - /// any, or null otherwise. - FileCheckExpressionAST *getExpressionAST() const { return ExpressionAST; } - - /// \returns whether this variable's value is known when performing the - /// substitutions of the line where it is defined. - bool isValueKnownAtMatchTime() const; - - /// Sets value of this numeric variable to \p NewValue. Triggers an assertion - /// failure if the variable is defined by an expression and the expression - /// cannot be evaluated to be equal to \p NewValue. - void setValue(uint64_t NewValue); + /// Sets value of this numeric variable to \p NewValue. + void setValue(uint64_t NewValue) { Value = NewValue; } /// Clears value of this numeric variable, regardless of whether it is /// currently defined or not. - void clearValue() { - Value = None; - ExpressionAST = nullptr; - } + void clearValue() { Value = None; } /// \returns the line number where this variable is defined, if any, or None /// if defined before input is parsed. @@ -529,22 +507,27 @@ public: /// \p Str from the variable name. static Expected<VariableProperties> parseVariable(StringRef &Str, const SourceMgr &SM); - /// Parses \p Expr for a numeric substitution block at line \p LineNumber, - /// or before input is parsed if \p LineNumber is None. Parameter + /// Parses \p Expr for the name of a numeric variable to be defined at line + /// \p LineNumber or before input is parsed if \p LineNumber is None. + /// \returns a pointer to the class instance representing that variable, + /// creating it if needed, or an error holding a diagnostic against \p SM + /// should defining such a variable be invalid. + static Expected<FileCheckNumericVariable *> parseNumericVariableDefinition( + StringRef &Expr, FileCheckPatternContext *Context, + Optional<size_t> LineNumber, const SourceMgr &SM); + /// Parses \p Expr for a numeric substitution block. Parameter /// \p IsLegacyLineExpr indicates whether \p Expr should be a legacy @LINE - /// expression and \p Context points to the class instance holding the live - /// string and numeric variables. \returns a pointer to the class instance - /// representing the AST of the expression whose value must be substitued, or - /// an error holding a diagnostic against \p SM if parsing fails. If - /// substitution was successful, sets \p DefinedNumericVariable to point to - /// the class representing the numeric variable defined in this numeric + /// expression. \returns a pointer to the class instance representing the AST + /// of the expression whose value must be substituted, or an error holding a + /// diagnostic against \p SM if parsing fails. If substitution was + /// successful, sets \p DefinedNumericVariable to point to the class + /// representing the numeric variable being defined in this numeric /// substitution block, or None if this block does not define any variable. - static Expected<std::unique_ptr<FileCheckExpressionAST>> + Expected<std::unique_ptr<FileCheckExpressionAST>> parseNumericSubstitutionBlock( StringRef Expr, Optional<FileCheckNumericVariable *> &DefinedNumericVariable, - bool IsLegacyLineExpr, Optional<size_t> LineNumber, - FileCheckPatternContext *Context, const SourceMgr &SM); + bool IsLegacyLineExpr, const SourceMgr &SM) const; /// Parses the pattern in \p PatternStr and initializes this FileCheckPattern /// instance accordingly. /// @@ -598,49 +581,28 @@ private: /// was not found. size_t FindRegexVarEnd(StringRef Str, SourceMgr &SM); - /// Parses \p Expr for the name of a numeric variable to be defined at line - /// \p LineNumber, or before input is parsed if \p LineNumber is None. - /// \returns a pointer to the class instance representing that variable, - /// creating it if needed, or an error holding a diagnostic against \p SM - /// should defining such a variable be invalid. - static Expected<FileCheckNumericVariable *> parseNumericVariableDefinition( - StringRef &Expr, FileCheckPatternContext *Context, - Optional<size_t> LineNumber, FileCheckExpressionAST *ExpressionAST, - const SourceMgr &SM); - /// Parses \p Name as a (pseudo if \p IsPseudo is true) numeric variable use - /// at line \p LineNumber, or before input is parsed if \p LineNumber is - /// None. Parameter \p Context points to the class instance holding the live - /// string and numeric variables. \returns the pointer to the class instance - /// representing that variable if successful, or an error holding a - /// diagnostic against \p SM otherwise. - static Expected<std::unique_ptr<FileCheckNumericVariableUse>> + /// Parses \p Name as a (pseudo if \p IsPseudo is true) numeric variable use. + /// \returns the pointer to the class instance representing that variable if + /// successful, or an error holding a diagnostic against \p SM otherwise. + Expected<std::unique_ptr<FileCheckNumericVariableUse>> parseNumericVariableUse(StringRef Name, bool IsPseudo, - Optional<size_t> LineNumber, - FileCheckPatternContext *Context, - const SourceMgr &SM); + const SourceMgr &SM) const; enum class AllowedOperand { LineVar, Literal, Any }; - /// Parses \p Expr for use of a numeric operand at line \p LineNumber, or - /// before input is parsed if \p LineNumber is None. Accepts both literal - /// values and numeric variables, depending on the value of \p AO. Parameter - /// \p Context points to the class instance holding the live string and - /// numeric variables. \returns the class representing that operand in the - /// AST of the expression or an error holding a diagnostic against \p SM - /// otherwise. - static Expected<std::unique_ptr<FileCheckExpressionAST>> + /// Parses \p Expr for use of a numeric operand. Accepts both literal values + /// and numeric variables, depending on the value of \p AO. \returns the + /// class representing that operand in the AST of the expression or an error + /// holding a diagnostic against \p SM otherwise. + Expected<std::unique_ptr<FileCheckExpressionAST>> parseNumericOperand(StringRef &Expr, AllowedOperand AO, - Optional<size_t> LineNumber, - FileCheckPatternContext *Context, const SourceMgr &SM); - /// Parses \p Expr for a binary operation at line \p LineNumber, or before - /// input is parsed if \p LineNumber is None. The left operand of this binary + const SourceMgr &SM) const; + /// Parses \p Expr for a binary operation. The left operand of this binary /// operation is given in \p LeftOp and \p IsLegacyLineExpr indicates whether - /// we are parsing a legacy @LINE expression. Parameter \p Context points to - /// the class instance holding the live string and numeric variables. - /// \returns the class representing the binary operation in the AST of the - /// expression, or an error holding a diagnostic against \p SM otherwise. - static Expected<std::unique_ptr<FileCheckExpressionAST>> + /// we are parsing a legacy @LINE expression. \returns the class representing + /// the binary operation in the AST of the expression, or an error holding a + /// diagnostic against \p SM otherwise. + Expected<std::unique_ptr<FileCheckExpressionAST>> parseBinop(StringRef &Expr, std::unique_ptr<FileCheckExpressionAST> LeftOp, - bool IsLegacyLineExpr, Optional<size_t> LineNumber, - FileCheckPatternContext *Context, const SourceMgr &SM); + bool IsLegacyLineExpr, const SourceMgr &SM) const; }; //===----------------------------------------------------------------------===// |

