diff --git a/flang/include/flang/Lower/IterationSpace.h b/flang/include/flang/Lower/IterationSpace.h --- a/flang/include/flang/Lower/IterationSpace.h +++ b/flang/include/flang/Lower/IterationSpace.h @@ -446,7 +446,9 @@ /// `load` must be a LHS array_load. Returns `llvm::None` on error. llvm::Optional findArgPosition(fir::ArrayLoadOp load); - bool isLHS(fir::ArrayLoadOp load) { return findArgPosition(load).hasValue(); } + bool isLHS(fir::ArrayLoadOp load) { + return findArgPosition(load).has_value(); + } /// `load` must be a LHS array_load. Determine the threaded inner argument /// corresponding to this load. @@ -472,7 +474,7 @@ /// Return the outermost loop in this FORALL nest. fir::DoLoopOp getOuterLoop() { - assert(outerLoop.hasValue()); + assert(outerLoop.has_value()); return outerLoop.getValue(); } diff --git a/flang/include/flang/Lower/StatementContext.h b/flang/include/flang/Lower/StatementContext.h --- a/flang/include/flang/Lower/StatementContext.h +++ b/flang/include/flang/Lower/StatementContext.h @@ -82,7 +82,7 @@ bool workListIsEmpty() const { return cufs.empty() || llvm::all_of(cufs, [](auto &opt) -> bool { - return !opt.hasValue(); + return !opt.has_value(); }); } diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -7291,14 +7291,14 @@ void setUnordered(bool b) { unordered = b; } - inline bool isPointerAssignment() const { return lbounds.hasValue(); } + inline bool isPointerAssignment() const { return lbounds.has_value(); } inline bool isBoundsSpec() const { - return isPointerAssignment() && !ubounds.hasValue(); + return isPointerAssignment() && !ubounds.has_value(); } inline bool isBoundsRemap() const { - return isPointerAssignment() && ubounds.hasValue(); + return isPointerAssignment() && ubounds.has_value(); } void setPointerAssignmentBounds( diff --git a/flang/lib/Lower/IterationSpace.cpp b/flang/lib/Lower/IterationSpace.cpp --- a/flang/lib/Lower/IterationSpace.cpp +++ b/flang/lib/Lower/IterationSpace.cpp @@ -867,7 +867,7 @@ llvm::Optional optPos; if (ld != loadBindings.end() && ld->second == load) optPos = static_cast(0u); - assert(optPos.hasValue() && "load does not correspond to lhs"); + assert(optPos.has_value() && "load does not correspond to lhs"); return optPos; } return llvm::None; diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -2635,7 +2635,7 @@ if (global.getInitVal()) initAttr = global.getInitVal().getValue(); auto linkage = convertLinkage(global.getLinkName()); - auto isConst = global.getConstant().hasValue(); + auto isConst = global.getConstant().has_value(); auto g = rewriter.create( loc, tyAttr, isConst, linkage, global.getSymName(), initAttr); auto &gr = g.getInitializerRegion(); diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -647,7 +647,7 @@ } void fir::CallOp::print(mlir::OpAsmPrinter &p) { - bool isDirect = getCallee().hasValue(); + bool isDirect = getCallee().has_value(); p << ' '; if (isDirect) p << getCallee().getValue(); @@ -749,7 +749,7 @@ op->template getAttrOfType( OPTY::getPredicateAttrName()) .getInt()); - assert(predSym.hasValue() && "invalid symbol value for predicate"); + assert(predSym.has_value() && "invalid symbol value for predicate"); p << '"' << mlir::arith::stringifyCmpFPredicate(predSym.getValue()) << '"' << ", "; p.printOperand(op.getLhs()); @@ -808,7 +808,7 @@ mlir::arith::CmpFPredicate fir::CmpcOp::getPredicateByName(llvm::StringRef name) { auto pred = mlir::arith::symbolizeCmpFPredicate(name); - assert(pred.hasValue() && "invalid predicate name"); + assert(pred.has_value() && "invalid predicate name"); return pred.getValue(); } diff --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp --- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp +++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp @@ -171,7 +171,7 @@ fromCmpIOp(condDef); } - bool hasIntegerSet() const { return integerSet.hasValue(); } + bool hasIntegerSet() const { return integerSet.has_value(); } mlir::IntegerSet getIntegerSet() const { assert(hasIntegerSet() && "integer set is missing"); diff --git a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp --- a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp +++ b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp @@ -189,12 +189,12 @@ loc, i64Type, "global1", builder.createInternalLinkage(), {}, true); EXPECT_TRUE(mlir::isa(global)); EXPECT_EQ("global1", global.getSymName()); - EXPECT_TRUE(global.getConstant().hasValue()); + EXPECT_TRUE(global.getConstant().has_value()); EXPECT_EQ(i64Type, global.getType()); - EXPECT_TRUE(global.getLinkName().hasValue()); + EXPECT_TRUE(global.getLinkName().has_value()); EXPECT_EQ(builder.createInternalLinkage().getValue(), global.getLinkName().getValue()); - EXPECT_FALSE(global.getInitVal().hasValue()); + EXPECT_FALSE(global.getInitVal().has_value()); auto g1 = builder.getNamedGlobal("global1"); EXPECT_EQ(global, g1); @@ -213,13 +213,13 @@ loc, i32Type, "global2", builder.createLinkOnceLinkage(), attr, false); EXPECT_TRUE(mlir::isa(global)); EXPECT_EQ("global2", global.getSymName()); - EXPECT_FALSE(global.getConstant().hasValue()); + EXPECT_FALSE(global.getConstant().has_value()); EXPECT_EQ(i32Type, global.getType()); - EXPECT_TRUE(global.getInitVal().hasValue()); + EXPECT_TRUE(global.getInitVal().has_value()); EXPECT_TRUE(global.getInitVal().getValue().isa()); EXPECT_EQ( 16, global.getInitVal().getValue().cast().getValue()); - EXPECT_TRUE(global.getLinkName().hasValue()); + EXPECT_TRUE(global.getLinkName().has_value()); EXPECT_EQ(builder.createLinkOnceLinkage().getValue(), global.getLinkName().getValue()); } @@ -333,9 +333,9 @@ EXPECT_TRUE(mlir::isa(var.getDefiningOp())); auto allocaOp = dyn_cast(var.getDefiningOp()); EXPECT_EQ(builder.getI64Type(), allocaOp.getInType()); - EXPECT_TRUE(allocaOp.getBindcName().hasValue()); + EXPECT_TRUE(allocaOp.getBindcName().has_value()); EXPECT_EQ(varName, allocaOp.getBindcName().getValue()); - EXPECT_FALSE(allocaOp.getUniqName().hasValue()); + EXPECT_FALSE(allocaOp.getUniqName().has_value()); EXPECT_FALSE(allocaOp.getPinned()); EXPECT_EQ(0u, allocaOp.getTypeparams().size()); EXPECT_EQ(0u, allocaOp.getShape().size()); diff --git a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h --- a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h +++ b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h @@ -87,7 +87,7 @@ unsigned nbArgs, bool addLocArgs = true) { EXPECT_TRUE(mlir::isa(*op)); auto callOp = mlir::dyn_cast(*op); - EXPECT_TRUE(callOp.getCallee().hasValue()); + EXPECT_TRUE(callOp.getCallee().has_value()); mlir::SymbolRefAttr callee = *callOp.getCallee(); EXPECT_EQ(fctName, callee.getRootReference().getValue()); // sourceFile and sourceLine are added arguments.