From e3b557809604d036af6e00c60f012c2025b59a5e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 11 Feb 2023 13:38:04 +0100 Subject: Vendor import of llvm-project main llvmorg-16-init-18548-gb0daacf58f41, the last commit before the upstream release/17.x branch was created. --- llvm/lib/FileCheck/FileCheckImpl.h | 78 +++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'llvm/lib/FileCheck/FileCheckImpl.h') diff --git a/llvm/lib/FileCheck/FileCheckImpl.h b/llvm/lib/FileCheck/FileCheckImpl.h index 29e721e088d2..fd3568e7a5b0 100644 --- a/llvm/lib/FileCheck/FileCheckImpl.h +++ b/llvm/lib/FileCheck/FileCheckImpl.h @@ -15,13 +15,13 @@ #ifndef LLVM_LIB_FILECHECK_FILECHECKIMPL_H #define LLVM_LIB_FILECHECK_FILECHECKIMPL_H -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/FileCheck/FileCheck.h" #include "llvm/Support/Error.h" #include "llvm/Support/SourceMgr.h" #include +#include #include #include @@ -265,24 +265,24 @@ private: /// format. ExpressionFormat ImplicitFormat; - /// Value of numeric variable, if defined, or None otherwise. - Optional Value; + /// Value of numeric variable, if defined, or std::nullopt otherwise. + std::optional Value; - /// The input buffer's string from which Value was parsed, or None. See - /// comments on getStringValue for a discussion of the None case. - Optional StrValue; + /// The input buffer's string from which Value was parsed, or std::nullopt. + /// See comments on getStringValue for a discussion of the None case. + std::optional StrValue; - /// Line number where this variable is defined, or None if defined before - /// input is parsed. Used to determine whether a variable is defined on the - /// same line as a given use. - Optional DefLineNumber; + /// Line number where this variable is defined, or std::nullopt if defined + /// before input is parsed. Used to determine whether a variable is defined on + /// the same line as a given use. + std::optional DefLineNumber; public: /// Constructor for a variable \p Name with implicit format \p ImplicitFormat /// defined at line \p DefLineNumber or defined before input is parsed if /// \p DefLineNumber is None. explicit NumericVariable(StringRef Name, ExpressionFormat ImplicitFormat, - Optional DefLineNumber = None) + std::optional DefLineNumber = std::nullopt) : Name(Name), ImplicitFormat(ImplicitFormat), DefLineNumber(DefLineNumber) {} @@ -293,20 +293,20 @@ public: ExpressionFormat getImplicitFormat() const { return ImplicitFormat; } /// \returns this variable's value. - Optional getValue() const { return Value; } + std::optional getValue() const { return Value; } /// \returns the input buffer's string from which this variable's value was - /// parsed, or None if the value is not yet defined or was not parsed from the - /// input buffer. For example, the value of @LINE is not parsed from the - /// input buffer, and some numeric variables are parsed from the command + /// parsed, or std::nullopt if the value is not yet defined or was not parsed + /// from the input buffer. For example, the value of @LINE is not parsed from + /// the input buffer, and some numeric variables are parsed from the command /// line instead. - Optional getStringValue() const { return StrValue; } + std::optional getStringValue() const { return StrValue; } /// Sets value of this numeric variable to \p NewValue, and sets the input /// buffer string from which it was parsed to \p NewStrValue. See comments on /// getStringValue for a discussion of when the latter can be None. void setValue(ExpressionValue NewValue, - Optional NewStrValue = None) { + std::optional NewStrValue = std::nullopt) { Value = NewValue; StrValue = NewStrValue; } @@ -314,13 +314,13 @@ public: /// Clears value of this numeric variable, regardless of whether it is /// currently defined or not. void clearValue() { - Value = None; - StrValue = None; + Value = std::nullopt; + StrValue = std::nullopt; } - /// \returns the line number where this variable is defined, if any, or None - /// if defined before input is parsed. - Optional getDefLineNumber() const { return DefLineNumber; } + /// \returns the line number where this variable is defined, if any, or + /// std::nullopt if defined before input is parsed. + std::optional getDefLineNumber() const { return DefLineNumber; } }; /// Class representing the use of a numeric variable in the AST of an @@ -555,7 +555,7 @@ public: SMRange getRange() const { return Range; } static Error get(const SourceMgr &SM, SMLoc Loc, const Twine &ErrMsg, - SMRange Range = None) { + SMRange Range = std::nullopt) { return make_error( SM.GetMessage(Loc, SourceMgr::DK_Error, ErrMsg), Range); } @@ -672,17 +672,17 @@ class Pattern { Check::FileCheckType CheckTy; - /// Line number for this CHECK pattern or None if it is an implicit pattern. - /// Used to determine whether a variable definition is made on an earlier - /// line to the one with this CHECK. - Optional LineNumber; + /// Line number for this CHECK pattern or std::nullopt if it is an implicit + /// pattern. Used to determine whether a variable definition is made on an + /// earlier line to the one with this CHECK. + std::optional LineNumber; /// Ignore case while matching if set to true. bool IgnoreCase = false; public: Pattern(Check::FileCheckType Ty, FileCheckPatternContext *Context, - Optional Line = None) + std::optional Line = std::nullopt) : Context(Context), CheckTy(Ty), LineNumber(Line) {} /// \returns the location in source code. @@ -717,10 +717,10 @@ public: /// 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 substitution - /// block, or None if this block does not define any variable. + /// block, or std::nullopt if this block does not define any variable. static Expected> parseNumericSubstitutionBlock( - StringRef Expr, Optional &DefinedNumericVariable, - bool IsLegacyLineExpr, Optional LineNumber, + StringRef Expr, std::optional &DefinedNumericVariable, + bool IsLegacyLineExpr, std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM); /// Parses the pattern in \p PatternStr and initializes this Pattern instance /// accordingly. @@ -736,7 +736,7 @@ public: size_t Len; }; struct MatchResult { - Optional TheMatch; + std::optional TheMatch; Error TheError; MatchResult(size_t MatchPos, size_t MatchLen, Error E) : TheMatch(Match{MatchPos, MatchLen}), TheError(std::move(E)) {} @@ -794,7 +794,7 @@ private: /// should defining such a variable be invalid. static Expected parseNumericVariableDefinition( StringRef &Expr, FileCheckPatternContext *Context, - Optional LineNumber, ExpressionFormat ImplicitFormat, + std::optional LineNumber, ExpressionFormat ImplicitFormat, 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 @@ -803,7 +803,7 @@ private: /// representing that variable if successful, or an error holding a /// diagnostic against \p SM otherwise. static Expected> parseNumericVariableUse( - StringRef Name, bool IsPseudo, Optional LineNumber, + StringRef Name, bool IsPseudo, std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM); enum class AllowedOperand { LineVar, LegacyLiteral, Any }; /// Parses \p Expr for use of a numeric operand at line \p LineNumber, or @@ -817,7 +817,7 @@ private: /// function will attempt to parse a parenthesized expression. static Expected> parseNumericOperand(StringRef &Expr, AllowedOperand AO, bool ConstraintParsed, - Optional LineNumber, + std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM); /// Parses and updates \p RemainingExpr for a binary operation at line /// \p LineNumber, or before input is parsed if \p LineNumber is None. The @@ -831,7 +831,7 @@ private: static Expected> parseBinop(StringRef Expr, StringRef &RemainingExpr, std::unique_ptr LeftOp, bool IsLegacyLineExpr, - Optional LineNumber, FileCheckPatternContext *Context, + std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM); /// Parses a parenthesized expression inside \p Expr at line \p LineNumber, or @@ -841,7 +841,7 @@ private: /// 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> - parseParenExpr(StringRef &Expr, Optional LineNumber, + parseParenExpr(StringRef &Expr, std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM); /// Parses \p Expr for an argument list belonging to a call to function \p @@ -853,8 +853,8 @@ private: /// otherwise. static Expected> parseCallExpr(StringRef &Expr, StringRef FuncName, - Optional LineNumber, FileCheckPatternContext *Context, - const SourceMgr &SM); + std::optional LineNumber, + FileCheckPatternContext *Context, const SourceMgr &SM); }; //===----------------------------------------------------------------------===// -- cgit v1.2.3