[mlir] Use std::optional instead of llvm::Optional (NFC)
authorKazu Hirata <kazu@google.com>
Tue, 3 Jan 2023 02:56:09 +0000 (18:56 -0800)
committerKazu Hirata <kazu@google.com>
Tue, 3 Jan 2023 02:56:09 +0000 (18:56 -0800)
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

mlir/lib/ExecutionEngine/OptUtils.cpp

index a720305..69216c5 100644 (file)
 #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,