diff options
author | Fangrui Song <i@maskray.me> | 2022-12-14 18:44:30 +0000 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-12-14 18:44:30 +0000 |
commit | 9408164254d26d5305fe4e0267b668c41c1266ed (patch) | |
tree | 9b74a433214097d8ec97d7daaa00bdafb2705937 /llvm/lib/FileCheck/FileCheck.cpp | |
parent | bd672e2fc03823e536866da6721b9f053cfd586b (diff) | |
download | llvm-9408164254d26d5305fe4e0267b668c41c1266ed.zip llvm-9408164254d26d5305fe4e0267b668c41c1266ed.tar.gz llvm-9408164254d26d5305fe4e0267b668c41c1266ed.tar.bz2 |
[FileCheck] llvm::Optional => std::optional
Don't touch FileCheck.cpp:698 StringSwitch<Optional<binop_eval_t>>(FuncName).
MSVC and older GCC may report errors:
error C2664: 'llvm::StringSwitch<std::optional<llvm::binop_eval_t>,T> &llvm::StringSwitch<T,T>::Case(llvm::StringLiteral,T)': cannot convert argument 2 from 'overloaded-function' to 'T'
with
[
T=std::optional<llvm::binop_eval_t>
]
llvm/lib/FileCheck/FileCheck.cpp:699:44: error: no matching function for call to ‘llvm::StringSwitch<std::optional<llvm::Expected<llvm::ExpressionValue> (*)(const llvm::ExpressionValue&, const llvm::ExpressionValue&)> >::Case(const char [4], <unresolved overloaded function type>)’
.Case("add", operator+)
^
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
-rw-r--r-- | llvm/lib/FileCheck/FileCheck.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index e2cc6dc..119d369 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -363,7 +363,7 @@ Expected<ExpressionValue> llvm::min(const ExpressionValue &LeftOperand, } Expected<ExpressionValue> NumericVariableUse::eval() const { - Optional<ExpressionValue> Value = Variable->getValue(); + std::optional<ExpressionValue> Value = Variable->getValue(); if (Value) return *Value; @@ -480,7 +480,7 @@ char ErrorReported::ID = 0; Expected<NumericVariable *> Pattern::parseNumericVariableDefinition( StringRef &Expr, FileCheckPatternContext *Context, - Optional<size_t> LineNumber, ExpressionFormat ImplicitFormat, + std::optional<size_t> LineNumber, ExpressionFormat ImplicitFormat, const SourceMgr &SM) { Expected<VariableProperties> ParseVarResult = parseVariable(Expr, SM); if (!ParseVarResult) @@ -518,7 +518,7 @@ Expected<NumericVariable *> Pattern::parseNumericVariableDefinition( } Expected<std::unique_ptr<NumericVariableUse>> Pattern::parseNumericVariableUse( - StringRef Name, bool IsPseudo, Optional<size_t> LineNumber, + StringRef Name, bool IsPseudo, std::optional<size_t> LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { if (IsPseudo && !Name.equals("@LINE")) return ErrorDiagnostic::get( @@ -542,7 +542,7 @@ Expected<std::unique_ptr<NumericVariableUse>> Pattern::parseNumericVariableUse( Context->GlobalNumericVariableTable[Name] = NumericVariable; } - Optional<size_t> DefLineNumber = NumericVariable->getDefLineNumber(); + std::optional<size_t> DefLineNumber = NumericVariable->getDefLineNumber(); if (DefLineNumber && LineNumber && *DefLineNumber == *LineNumber) return ErrorDiagnostic::get( SM, Name, @@ -554,7 +554,7 @@ Expected<std::unique_ptr<NumericVariableUse>> Pattern::parseNumericVariableUse( Expected<std::unique_ptr<ExpressionAST>> Pattern::parseNumericOperand( StringRef &Expr, AllowedOperand AO, bool MaybeInvalidConstraint, - Optional<size_t> LineNumber, FileCheckPatternContext *Context, + std::optional<size_t> LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { if (Expr.startswith("(")) { if (AO != AllowedOperand::Any) @@ -611,7 +611,7 @@ Expected<std::unique_ptr<ExpressionAST>> Pattern::parseNumericOperand( } Expected<std::unique_ptr<ExpressionAST>> -Pattern::parseParenExpr(StringRef &Expr, Optional<size_t> LineNumber, +Pattern::parseParenExpr(StringRef &Expr, std::optional<size_t> LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { Expr = Expr.ltrim(SpaceChars); assert(Expr.startswith("(")); @@ -646,7 +646,7 @@ Pattern::parseParenExpr(StringRef &Expr, Optional<size_t> LineNumber, Expected<std::unique_ptr<ExpressionAST>> Pattern::parseBinop(StringRef Expr, StringRef &RemainingExpr, std::unique_ptr<ExpressionAST> LeftOp, - bool IsLegacyLineExpr, Optional<size_t> LineNumber, + bool IsLegacyLineExpr, std::optional<size_t> LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { RemainingExpr = RemainingExpr.ltrim(SpaceChars); if (RemainingExpr.empty()) @@ -690,7 +690,7 @@ Pattern::parseBinop(StringRef Expr, StringRef &RemainingExpr, Expected<std::unique_ptr<ExpressionAST>> Pattern::parseCallExpr(StringRef &Expr, StringRef FuncName, - Optional<size_t> LineNumber, + std::optional<size_t> LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { Expr = Expr.ltrim(SpaceChars); assert(Expr.startswith("(")); @@ -765,8 +765,8 @@ Pattern::parseCallExpr(StringRef &Expr, StringRef FuncName, } Expected<std::unique_ptr<Expression>> Pattern::parseNumericSubstitutionBlock( - StringRef Expr, Optional<NumericVariable *> &DefinedNumericVariable, - bool IsLegacyLineExpr, Optional<size_t> LineNumber, + StringRef Expr, std::optional<NumericVariable *> &DefinedNumericVariable, + bool IsLegacyLineExpr, std::optional<size_t> LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { std::unique_ptr<ExpressionAST> ExpressionASTPointer = nullptr; StringRef DefExpr = StringRef(); @@ -1099,7 +1099,7 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix, // Parse numeric substitution block. std::unique_ptr<Expression> ExpressionPointer; - Optional<NumericVariable *> DefinedNumericVariable; + std::optional<NumericVariable *> DefinedNumericVariable; if (IsNumBlock) { Expected<std::unique_ptr<Expression>> ParseResult = parseNumericSubstitutionBlock(MatchStr, DefinedNumericVariable, @@ -1412,7 +1412,7 @@ void Pattern::printVariableDefs(const SourceMgr &SM, for (const auto &VariableDef : NumericVariableDefs) { VarCapture VC; VC.Name = VariableDef.getKey(); - Optional<StringRef> StrValue = + std::optional<StringRef> StrValue = VariableDef.getValue().DefinedNumericVariable->getStringValue(); if (!StrValue) continue; @@ -2701,7 +2701,7 @@ Error FileCheckPatternContext::defineCmdlineVariables( // Now parse the definition both to check that the syntax is correct and // to create the necessary class instance. StringRef CmdlineDefExpr = CmdlineDef.substr(1); - Optional<NumericVariable *> DefinedNumericVariable; + std::optional<NumericVariable *> DefinedNumericVariable; Expected<std::unique_ptr<Expression>> ExpressionResult = Pattern::parseNumericSubstitutionBlock(CmdlineDefExpr, DefinedNumericVariable, false, |