From c82fb16f580c80b961cb1971df66ce70eaf7d87a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 11 Jul 2022 20:41:12 -0700 Subject: [flang] Use has_value instead of hasValue (NFC) This patch replaces hasValue with has_value in an effort to deprecate Optional::hasValue. Differential Revision: https://reviews.llvm.org/D129458 --- flang/include/flang/Lower/IterationSpace.h | 6 ++++-- flang/include/flang/Lower/StatementContext.h | 2 +- flang/lib/Lower/ConvertExpr.cpp | 6 +++--- flang/lib/Lower/IterationSpace.cpp | 2 +- flang/lib/Optimizer/CodeGen/CodeGen.cpp | 2 +- flang/lib/Optimizer/Dialect/FIROps.cpp | 6 +++--- flang/lib/Optimizer/Transforms/AffinePromotion.cpp | 2 +- flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp | 16 ++++++++-------- .../Optimizer/Builder/Runtime/RuntimeCallTestBase.h | 2 +- 9 files changed, 23 insertions(+), 21 deletions(-) (limited to 'flang') diff --git a/flang/include/flang/Lower/IterationSpace.h b/flang/include/flang/Lower/IterationSpace.h index 9ad3bd1..25c3f30 100644 --- a/flang/include/flang/Lower/IterationSpace.h +++ b/flang/include/flang/Lower/IterationSpace.h @@ -446,7 +446,9 @@ public: /// `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 @@ public: /// 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 index 69ceeae..1ab1bd0 100644 --- a/flang/include/flang/Lower/StatementContext.h +++ b/flang/include/flang/Lower/StatementContext.h @@ -82,7 +82,7 @@ public: 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 index 0351df2..5fe5314 100644 --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -7291,14 +7291,14 @@ private: 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 index f41bc51..e282563 100644 --- a/flang/lib/Lower/IterationSpace.cpp +++ b/flang/lib/Lower/IterationSpace.cpp @@ -867,7 +867,7 @@ Fortran::lower::ExplicitIterSpace::findArgPosition(fir::ArrayLoadOp load) { 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 index 632ab28..f9f6f93 100644 --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -2635,7 +2635,7 @@ struct GlobalOpConversion : public FIROpConversion { 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 index 0119bca..8337b16 100644 --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -647,7 +647,7 @@ mlir::FunctionType fir::CallOp::getFunctionType() { } 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 @@ static void printCmpOp(mlir::OpAsmPrinter &p, OPTY op) { 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 @@ void fir::buildCmpCOp(mlir::OpBuilder &builder, mlir::OperationState &result, 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 index dad4b47..e9f017c 100644 --- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp +++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp @@ -171,7 +171,7 @@ struct AffineIfCondition { 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 index 3997d8f..9fca611 100644 --- a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp +++ b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp @@ -189,12 +189,12 @@ TEST_F(FIRBuilderTest, createGlobal1) { 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 @@ TEST_F(FIRBuilderTest, createGlobal2) { 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 @@ TEST_F(FIRBuilderTest, allocateLocal) { 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 index 8d549c5..4b7c9f1 100644 --- a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h +++ b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h @@ -87,7 +87,7 @@ static inline void checkCallOp(mlir::Operation *op, llvm::StringRef fctName, 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. -- cgit v1.1