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/FileCheck.cpp | 45 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'llvm/lib/FileCheck/FileCheck.cpp') diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index 5d4cfceefb3e..ec963c2de45b 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -206,7 +206,7 @@ Expected llvm::operator+(const ExpressionValue &LeftOperand, if (LeftOperand.isNegative() && RightOperand.isNegative()) { int64_t LeftValue = cantFail(LeftOperand.getSignedValue()); int64_t RightValue = cantFail(RightOperand.getSignedValue()); - Optional Result = checkedAdd(LeftValue, RightValue); + std::optional Result = checkedAdd(LeftValue, RightValue); if (!Result) return make_error(); @@ -224,7 +224,7 @@ Expected llvm::operator+(const ExpressionValue &LeftOperand, // Both values are positive at this point. uint64_t LeftValue = cantFail(LeftOperand.getUnsignedValue()); uint64_t RightValue = cantFail(RightOperand.getUnsignedValue()); - Optional Result = + std::optional Result = checkedAddUnsigned(LeftValue, RightValue); if (!Result) return make_error(); @@ -241,7 +241,7 @@ Expected llvm::operator-(const ExpressionValue &LeftOperand, // Result <= -1 - (max int64_t) which overflows on 1- and 2-complement. if (RightValue > (uint64_t)std::numeric_limits::max()) return make_error(); - Optional Result = + std::optional Result = checkedSub(LeftValue, static_cast(RightValue)); if (!Result) return make_error(); @@ -306,7 +306,7 @@ Expected llvm::operator*(const ExpressionValue &LeftOperand, // Result will be positive and can overflow. uint64_t LeftValue = cantFail(LeftOperand.getUnsignedValue()); uint64_t RightValue = cantFail(RightOperand.getUnsignedValue()); - Optional Result = + std::optional Result = checkedMulUnsigned(LeftValue, RightValue); if (!Result) return make_error(); @@ -363,7 +363,7 @@ Expected llvm::min(const ExpressionValue &LeftOperand, } Expected NumericVariableUse::eval() const { - Optional Value = Variable->getValue(); + std::optional Value = Variable->getValue(); if (Value) return *Value; @@ -480,7 +480,7 @@ char ErrorReported::ID = 0; Expected Pattern::parseNumericVariableDefinition( StringRef &Expr, FileCheckPatternContext *Context, - Optional LineNumber, ExpressionFormat ImplicitFormat, + std::optional LineNumber, ExpressionFormat ImplicitFormat, const SourceMgr &SM) { Expected ParseVarResult = parseVariable(Expr, SM); if (!ParseVarResult) @@ -518,7 +518,7 @@ Expected Pattern::parseNumericVariableDefinition( } Expected> Pattern::parseNumericVariableUse( - StringRef Name, bool IsPseudo, Optional LineNumber, + StringRef Name, bool IsPseudo, std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { if (IsPseudo && !Name.equals("@LINE")) return ErrorDiagnostic::get( @@ -542,7 +542,7 @@ Expected> Pattern::parseNumericVariableUse( Context->GlobalNumericVariableTable[Name] = NumericVariable; } - Optional DefLineNumber = NumericVariable->getDefLineNumber(); + std::optional DefLineNumber = NumericVariable->getDefLineNumber(); if (DefLineNumber && LineNumber && *DefLineNumber == *LineNumber) return ErrorDiagnostic::get( SM, Name, @@ -554,7 +554,7 @@ Expected> Pattern::parseNumericVariableUse( Expected> Pattern::parseNumericOperand( StringRef &Expr, AllowedOperand AO, bool MaybeInvalidConstraint, - Optional LineNumber, FileCheckPatternContext *Context, + std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { if (Expr.startswith("(")) { if (AO != AllowedOperand::Any) @@ -611,7 +611,7 @@ Expected> Pattern::parseNumericOperand( } Expected> -Pattern::parseParenExpr(StringRef &Expr, Optional LineNumber, +Pattern::parseParenExpr(StringRef &Expr, std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { Expr = Expr.ltrim(SpaceChars); assert(Expr.startswith("(")); @@ -646,7 +646,7 @@ Pattern::parseParenExpr(StringRef &Expr, Optional LineNumber, Expected> Pattern::parseBinop(StringRef Expr, StringRef &RemainingExpr, std::unique_ptr LeftOp, - bool IsLegacyLineExpr, Optional LineNumber, + bool IsLegacyLineExpr, std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { RemainingExpr = RemainingExpr.ltrim(SpaceChars); if (RemainingExpr.empty()) @@ -690,19 +690,19 @@ Pattern::parseBinop(StringRef Expr, StringRef &RemainingExpr, Expected> Pattern::parseCallExpr(StringRef &Expr, StringRef FuncName, - Optional LineNumber, + std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { Expr = Expr.ltrim(SpaceChars); assert(Expr.startswith("(")); - auto OptFunc = StringSwitch>(FuncName) + auto OptFunc = StringSwitch(FuncName) .Case("add", operator+) .Case("div", operator/) .Case("max", max) .Case("min", min) .Case("mul", operator*) .Case("sub", operator-) - .Default(None); + .Default(nullptr); if (!OptFunc) return ErrorDiagnostic::get( @@ -765,12 +765,12 @@ Pattern::parseCallExpr(StringRef &Expr, StringRef FuncName, } Expected> Pattern::parseNumericSubstitutionBlock( - StringRef Expr, Optional &DefinedNumericVariable, - bool IsLegacyLineExpr, Optional LineNumber, + StringRef Expr, std::optional &DefinedNumericVariable, + bool IsLegacyLineExpr, std::optional LineNumber, FileCheckPatternContext *Context, const SourceMgr &SM) { std::unique_ptr ExpressionASTPointer = nullptr; StringRef DefExpr = StringRef(); - DefinedNumericVariable = None; + DefinedNumericVariable = std::nullopt; ExpressionFormat ExplicitFormat = ExpressionFormat(); unsigned Precision = 0; @@ -1099,7 +1099,7 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix, // Parse numeric substitution block. std::unique_ptr ExpressionPointer; - Optional DefinedNumericVariable; + std::optional DefinedNumericVariable; if (IsNumBlock) { Expected> 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 StrValue = + std::optional StrValue = VariableDef.getValue().DefinedNumericVariable->getStringValue(); if (!StrValue) continue; @@ -2701,10 +2701,11 @@ 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 DefinedNumericVariable; + std::optional DefinedNumericVariable; Expected> ExpressionResult = - Pattern::parseNumericSubstitutionBlock( - CmdlineDefExpr, DefinedNumericVariable, false, None, this, SM); + Pattern::parseNumericSubstitutionBlock(CmdlineDefExpr, + DefinedNumericVariable, false, + std::nullopt, this, SM); if (!ExpressionResult) { Errs = joinErrors(std::move(Errs), ExpressionResult.takeError()); continue; -- cgit v1.2.3