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

Kazu Hirata llvmlistbot at llvm.org
Mon Jan 2 18:56:15 PST 2023


Author: Kazu Hirata
Date: 2023-01-02T18:56:09-08:00
New Revision: 5273219e57a85ea360639e21d2fcc8b3edc429f5

URL: https://github.com/llvm/llvm-project/commit/5273219e57a85ea360639e21d2fcc8b3edc429f5
DIFF: https://github.com/llvm/llvm-project/commit/5273219e57a85ea360639e21d2fcc8b3edc429f5.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/ExecutionEngine/OptUtils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/ExecutionEngine/OptUtils.cpp b/mlir/lib/ExecutionEngine/OptUtils.cpp
index a7203055e65ff..69216c57c2868 100644
--- a/mlir/lib/ExecutionEngine/OptUtils.cpp
+++ b/mlir/lib/ExecutionEngine/OptUtils.cpp
@@ -20,11 +20,12 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Target/TargetMachine.h"
+#include <optional>
 
 using namespace llvm;
 
-static Optional<OptimizationLevel> mapToLevel(unsigned optLevel,
-                                              unsigned sizeLevel) {
+static std::optional<OptimizationLevel> mapToLevel(unsigned optLevel,
+                                                   unsigned sizeLevel) {
   switch (optLevel) {
   case 0:
     return OptimizationLevel::O0;
@@ -55,7 +56,7 @@ std::function<Error(Module *)>
 mlir::makeOptimizingTransformer(unsigned optLevel, unsigned sizeLevel,
                                 TargetMachine *targetMachine) {
   return [optLevel, sizeLevel, targetMachine](Module *m) -> Error {
-    Optional<OptimizationLevel> ol = mapToLevel(optLevel, sizeLevel);
+    std::optional<OptimizationLevel> ol = mapToLevel(optLevel, sizeLevel);
     if (!ol) {
       return make_error<StringError>(
           formatv("invalid optimization/size level {0}/{1}", optLevel,


        


More information about the Mlir-commits mailing list