aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/FileCheck/FileCheck.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/FileCheck/FileCheck.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/contrib/llvm-project/llvm/lib/FileCheck/FileCheck.cpp b/contrib/llvm-project/llvm/lib/FileCheck/FileCheck.cpp
index 5d4cfceefb3e..ec963c2de45b 100644
--- a/contrib/llvm-project/llvm/lib/FileCheck/FileCheck.cpp
+++ b/contrib/llvm-project/llvm/lib/FileCheck/FileCheck.cpp
@@ -206,7 +206,7 @@ Expected<ExpressionValue> llvm::operator+(const ExpressionValue &LeftOperand,
if (LeftOperand.isNegative() && RightOperand.isNegative()) {
int64_t LeftValue = cantFail(LeftOperand.getSignedValue());
int64_t RightValue = cantFail(RightOperand.getSignedValue());
- Optional<int64_t> Result = checkedAdd<int64_t>(LeftValue, RightValue);
+ std::optional<int64_t> Result = checkedAdd<int64_t>(LeftValue, RightValue);
if (!Result)
return make_error<OverflowError>();
@@ -224,7 +224,7 @@ Expected<ExpressionValue> 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<uint64_t> Result =
+ std::optional<uint64_t> Result =
checkedAddUnsigned<uint64_t>(LeftValue, RightValue);
if (!Result)
return make_error<OverflowError>();
@@ -241,7 +241,7 @@ Expected<ExpressionValue> llvm::operator-(const ExpressionValue &LeftOperand,
// Result <= -1 - (max int64_t) which overflows on 1- and 2-complement.
if (RightValue > (uint64_t)std::numeric_limits<int64_t>::max())
return make_error<OverflowError>();
- Optional<int64_t> Result =
+ std::optional<int64_t> Result =
checkedSub(LeftValue, static_cast<int64_t>(RightValue));
if (!Result)
return make_error<OverflowError>();
@@ -306,7 +306,7 @@ Expected<ExpressionValue> 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<uint64_t> Result =
+ std::optional<uint64_t> Result =
checkedMulUnsigned<uint64_t>(LeftValue, RightValue);
if (!Result)
return make_error<OverflowError>();
@@ -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,19 +690,19 @@ 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("("));
- auto OptFunc = StringSwitch<Optional<binop_eval_t>>(FuncName)
+ auto OptFunc = StringSwitch<binop_eval_t>(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<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();
- 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<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,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<NumericVariable *> DefinedNumericVariable;
+ std::optional<NumericVariable *> DefinedNumericVariable;
Expected<std::unique_ptr<Expression>> 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;