[flang/unittests] Use std::nullopt instead of None (NFC)
authorKazu Hirata <kazu@google.com>
Sun, 4 Dec 2022 03:08:01 +0000 (19:08 -0800)
committerKazu Hirata <kazu@google.com>
Sun, 4 Dec 2022 03:08:01 +0000 (19:08 -0800)
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

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

index 347ec78e8fec3d9eaf8b305e33b6e4afbd8181e4..21230ae39963c9fef8c070378e8f0b2fefe099f8 100644 (file)
@@ -28,7 +28,7 @@ public:
     // 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);
index 17a6307e6008b4f05c97d48c1a853dbe3b317ae3..4b895ee7d9e24724143fccdda17d7670142649b2 100644 (file)
@@ -24,7 +24,7 @@ public:
     // 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);
index 9defe496b9c05636e8d1ff02221fb0680b4bf947..3dedf3d75c5ced9ddead49c6c051543e3d7f0bfb 100644 (file)
@@ -28,7 +28,7 @@ public:
     // 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);
 }
index 22d580feda72467ce76431552b4fbb8e18087ad7..429f75a1e1a19e2407ab4b26b4d50c087b13d024 100644 (file)
@@ -27,7 +27,7 @@ public:
     // 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);
index 6b387eca9b9883eb368a7b16b36b39f1e28901e3..0e1c0f4cb60e204e1b42aec30b84139079da7e69 100644 (file)
@@ -27,7 +27,7 @@ public:
     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);
index ed248fc72b0aec52cbd95ae5f166744aee56149e..45262239d6166b89b1014865ac8ffb4450130091 100644 (file)
@@ -22,7 +22,7 @@ public:
     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;