[Mlir-commits] [mlir] eed9932 - [mlir] Use std::optional instead of llvm::Optional (NFC)

Kazu Hirata llvmlistbot at llvm.org
Thu May 4 22:39:21 PDT 2023


Author: Kazu Hirata
Date: 2023-05-04T22:39:09-07:00
New Revision: eed9932ab25c11fa32b4c1823e76be569c5bc960

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

LOG: [mlir] Use std::optional instead of llvm::Optional (NFC)

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: 
    mlir/lib/AsmParser/Parser.cpp
    mlir/lib/Dialect/Affine/IR/AffineOps.cpp
    mlir/lib/IR/MLIRContext.cpp
    mlir/lib/IR/Operation.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/AsmParser/Parser.cpp b/mlir/lib/AsmParser/Parser.cpp
index 3186b0aa420b9..ade2465d7fd0a 100644
--- a/mlir/lib/AsmParser/Parser.cpp
+++ b/mlir/lib/AsmParser/Parser.cpp
@@ -1424,7 +1424,8 @@ Operation *OperationParser::parseGenericOperation() {
   // would be "missing foo attribute" instead of something like "expects a 32
   // bits float attribute but got a 32 bits integer attribute".
   if (!properties && !result.getRawProperties()) {
-    Optional<RegisteredOperationName> info = result.name.getRegisteredInfo();
+    std::optional<RegisteredOperationName> info =
+        result.name.getRegisteredInfo();
     if (info) {
       if (failed(info->verifyInherentAttrs(result.attributes, [&]() {
             return mlir::emitError(srcLocation) << "'" << name << "' op ";

diff  --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 6c239cf18c371..7a0f1e0983c7b 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -962,7 +962,7 @@ static void simplifyMinOrMaxExprWithOperands(AffineMap &map,
   // bound is redundant by checking if its highest (in case of max) and its
   // lowest (in the case of min) value is already lower than (or higher than)
   // the lower bound (or upper bound in the case of min) of another bound.
-  SmallVector<Optional<int64_t>, 4> lowerBounds, upperBounds;
+  SmallVector<std::optional<int64_t>, 4> lowerBounds, upperBounds;
   lowerBounds.reserve(map.getNumResults());
   upperBounds.reserve(map.getNumResults());
   for (AffineExpr e : map.getResults()) {

diff  --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index 5e0f9581e97f6..e47221f79f1b7 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -802,7 +802,7 @@ OperationName::UnregisteredOpModel::verifyRegionInvariants(Operation *) {
   return success();
 }
 
-Optional<Attribute>
+std::optional<Attribute>
 OperationName::UnregisteredOpModel::getInherentAttr(Operation *op,
                                                     StringRef name) {
   auto dict = dyn_cast_or_null<DictionaryAttr>(getPropertiesAsAttr(op));

diff  --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index d9a3abad74ed3..bc7a9d852fd0f 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include <numeric>
+#include <optional>
 
 using namespace mlir;
 
@@ -328,7 +329,7 @@ void Operation::setInherentAttr(StringAttr name, Attribute value) {
 }
 
 Attribute Operation::getPropertiesAsAttribute() {
-  Optional<RegisteredOperationName> info = getRegisteredInfo();
+  std::optional<RegisteredOperationName> info = getRegisteredInfo();
   if (LLVM_UNLIKELY(!info))
     return *getPropertiesStorage().as<Attribute *>();
   return info->getOpPropertiesAsAttribute(this);
@@ -336,7 +337,7 @@ Attribute Operation::getPropertiesAsAttribute() {
 LogicalResult
 Operation::setPropertiesFromAttribute(Attribute attr,
                                       InFlightDiagnostic *diagnostic) {
-  Optional<RegisteredOperationName> info = getRegisteredInfo();
+  std::optional<RegisteredOperationName> info = getRegisteredInfo();
   if (LLVM_UNLIKELY(!info)) {
     *getPropertiesStorage().as<Attribute *>() = attr;
     return success();


        


More information about the Mlir-commits mailing list