[flang-commits] [flang] 63b63c3 - [flang/unittests] Use std::nullopt instead of None (NFC)

Kazu Hirata via flang-commits flang-commits at lists.llvm.org
Sat Dec 3 19:08:10 PST 2022


Author: Kazu Hirata
Date: 2022-12-03T19:08:01-08:00
New Revision: 63b63c3dcd540c4182f1856b5570c7201cc4b3a9

URL: https://github.com/llvm/llvm-project/commit/63b63c3dcd540c4182f1856b5570c7201cc4b3a9
DIFF: https://github.com/llvm/llvm-project/commit/63b63c3dcd540c4182f1856b5570c7201cc4b3a9.diff

LOG: [flang/unittests] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 
    

Modified: 
    flang/unittests/Optimizer/Builder/CharacterTest.cpp
    flang/unittests/Optimizer/Builder/ComplexTest.cpp
    flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
    flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp
    flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
    flang/unittests/Optimizer/FortranVariableTest.cpp

Removed: 
    


################################################################################
diff  --git a/flang/unittests/Optimizer/Builder/CharacterTest.cpp b/flang/unittests/Optimizer/Builder/CharacterTest.cpp
index 347ec78e8fec3..21230ae39963c 100644
--- a/flang/unittests/Optimizer/Builder/CharacterTest.cpp
+++ b/flang/unittests/Optimizer/Builder/CharacterTest.cpp
@@ -28,7 +28,7 @@ struct CharacterTest : public testing::Test {
     // Set the insertion point in the function entry block.
     mlir::ModuleOp mod = builder.create<mlir::ModuleOp>(loc);
     mlir::func::FuncOp func = mlir::func::FuncOp::create(
-        loc, "func1", builder.getFunctionType(llvm::None, llvm::None));
+        loc, "func1", builder.getFunctionType(std::nullopt, std::nullopt));
     auto *entryBlock = func.addEntryBlock();
     mod.push_back(mod);
     builder.setInsertionPointToStart(entryBlock);

diff  --git a/flang/unittests/Optimizer/Builder/ComplexTest.cpp b/flang/unittests/Optimizer/Builder/ComplexTest.cpp
index 17a6307e6008b..4b895ee7d9e24 100644
--- a/flang/unittests/Optimizer/Builder/ComplexTest.cpp
+++ b/flang/unittests/Optimizer/Builder/ComplexTest.cpp
@@ -24,7 +24,7 @@ struct ComplexTest : public testing::Test {
     // Set the insertion point in the function entry block.
     mlir::ModuleOp mod = builder.create<mlir::ModuleOp>(loc);
     mlir::func::FuncOp func = mlir::func::FuncOp::create(
-        loc, "func1", builder.getFunctionType(llvm::None, llvm::None));
+        loc, "func1", builder.getFunctionType(std::nullopt, std::nullopt));
     auto *entryBlock = func.addEntryBlock();
     mod.push_back(mod);
     builder.setInsertionPointToStart(entryBlock);

diff  --git a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
index 9defe496b9c05..3dedf3d75c5ce 100644
--- a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
+++ b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
@@ -28,7 +28,7 @@ struct FIRBuilderTest : public testing::Test {
     // Set the insertion point in the function entry block.
     mlir::ModuleOp mod = builder.create<mlir::ModuleOp>(loc);
     mlir::func::FuncOp func = mlir::func::FuncOp::create(
-        loc, "func1", builder.getFunctionType(llvm::None, llvm::None));
+        loc, "func1", builder.getFunctionType(std::nullopt, std::nullopt));
     auto *entryBlock = func.addEntryBlock();
     mod.push_back(mod);
     builder.setInsertionPointToStart(entryBlock);
@@ -176,7 +176,7 @@ TEST_F(FIRBuilderTest, getNamedFunction) {
   EXPECT_EQ(nullptr, func2);
   auto loc = builder.getUnknownLoc();
   func2 = builder.createFunction(
-      loc, "func2", builder.getFunctionType(llvm::None, llvm::None));
+      loc, "func2", builder.getFunctionType(std::nullopt, std::nullopt));
   auto func2query = builder.getNamedFunction("func2");
   EXPECT_EQ(func2, func2query);
 }

diff  --git a/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp b/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp
index 22d580feda724..429f75a1e1a19 100644
--- a/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp
+++ b/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp
@@ -27,7 +27,7 @@ struct HLFIRToolsTest : public testing::Test {
     // Set the insertion point in the function entry block.
     mlir::ModuleOp mod = builder.create<mlir::ModuleOp>(loc);
     mlir::func::FuncOp func = mlir::func::FuncOp::create(
-        loc, "func1", builder.getFunctionType(llvm::None, llvm::None));
+        loc, "func1", builder.getFunctionType(std::nullopt, std::nullopt));
     auto *entryBlock = func.addEntryBlock();
     mod.push_back(mod);
     builder.setInsertionPointToStart(entryBlock);

diff  --git a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
index 6b387eca9b988..0e1c0f4cb60e2 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
+++ b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
@@ -27,7 +27,7 @@ struct RuntimeCallTest : public testing::Test {
     mlir::ModuleOp mod = builder.create<mlir::ModuleOp>(loc);
     mlir::func::FuncOp func =
         mlir::func::FuncOp::create(loc, "runtime_unit_tests_func",
-            builder.getFunctionType(llvm::None, llvm::None));
+            builder.getFunctionType(std::nullopt, std::nullopt));
     auto *entryBlock = func.addEntryBlock();
     mod.push_back(mod);
     builder.setInsertionPointToStart(entryBlock);

diff  --git a/flang/unittests/Optimizer/FortranVariableTest.cpp b/flang/unittests/Optimizer/FortranVariableTest.cpp
index ed248fc72b0ae..45262239d6166 100644
--- a/flang/unittests/Optimizer/FortranVariableTest.cpp
+++ b/flang/unittests/Optimizer/FortranVariableTest.cpp
@@ -22,7 +22,7 @@ struct FortranVariableTest : public testing::Test {
     mlir::ModuleOp mod = builder->create<mlir::ModuleOp>(loc);
     mlir::func::FuncOp func =
         mlir::func::FuncOp::create(loc, "fortran_variable_tests",
-            builder->getFunctionType(llvm::None, llvm::None));
+            builder->getFunctionType(std::nullopt, std::nullopt));
     auto *entryBlock = func.addEntryBlock();
     mod.push_back(mod);
     builder->setInsertionPointToStart(entryBlock);
@@ -49,7 +49,7 @@ TEST_F(FortranVariableTest, SimpleScalar) {
   mlir::Value addr = builder->create<fir::AllocaOp>(loc, eleType);
   auto name = mlir::StringAttr::get(&context, "x");
   auto declare = builder->create<fir::DeclareOp>(loc, addr.getType(), addr,
-      /*shape=*/mlir::Value{}, /*typeParams=*/llvm::None, name,
+      /*shape=*/mlir::Value{}, /*typeParams=*/std::nullopt, name,
       /*fortran_attrs=*/fir::FortranVariableFlagsAttr{});
 
   fir::FortranVariableOpInterface fortranVariable = declare;
@@ -100,11 +100,11 @@ TEST_F(FortranVariableTest, SimpleArray) {
       extents.size(), fir::SequenceType::getUnknownExtent());
   mlir::Type seqTy = fir::SequenceType::get(typeShape, eleType);
   mlir::Value addr = builder->create<fir::AllocaOp>(
-      loc, seqTy, /*pinned=*/false, /*typeParams=*/llvm::None, extents);
+      loc, seqTy, /*pinned=*/false, /*typeParams=*/std::nullopt, extents);
   mlir::Value shape = createShape(extents);
   auto name = mlir::StringAttr::get(&context, "x");
   auto declare = builder->create<fir::DeclareOp>(loc, addr.getType(), addr,
-      shape, /*typeParams*/ llvm::None, name,
+      shape, /*typeParams*/ std::nullopt, name,
       /*fortran_attrs=*/fir::FortranVariableFlagsAttr{});
 
   fir::FortranVariableOpInterface fortranVariable = declare;


        


More information about the flang-commits mailing list