[Mlir-commits] [mlir] 397f2e9 - Remove llvm::Optional

Kazu Hirata llvmlistbot at llvm.org
Tue May 30 15:32:56 PDT 2023


Author: Kazu Hirata
Date: 2023-05-30T15:32:43-07:00
New Revision: 397f2e9ebee8d8e45547e90dd05228d7f965df67

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

LOG: Remove llvm::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

Differential Revision: https://reviews.llvm.org/D149128

Added: 
    

Modified: 
    mlir/include/mlir/Support/LLVM.h

Removed: 
    llvm/include/llvm/ADT/None.h
    llvm/include/llvm/ADT/Optional.h


################################################################################
diff  --git a/llvm/include/llvm/ADT/None.h b/llvm/include/llvm/ADT/None.h
deleted file mode 100644
index c497821a696eb..0000000000000
--- a/llvm/include/llvm/ADT/None.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===-- None.h - Simple null value for implicit construction ------*- C++ -*-=//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-///  This file provides None, an enumerator for use in implicit constructors
-///  of various (usually templated) types to make such construction more
-///  terse.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_ADT_NONE_H
-#define LLVM_ADT_NONE_H
-
-#include "llvm/Support/Compiler.h"
-#include <optional>
-
-namespace llvm {
-/// A simple null object to allow implicit construction of std::optional<T>
-/// and similar types without having to spell out the specialization's name.
-LLVM_DEPRECATED("Use std::nullopt_t instead", "std::nullopt_t")
-typedef std::nullopt_t NoneType;
-LLVM_DEPRECATED("Use std::nullopt instead.", "std::nullopt")
-inline constexpr std::nullopt_t None = std::nullopt;
-}
-
-#endif

diff  --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h
deleted file mode 100644
index c3382837c0aea..0000000000000
--- a/llvm/include/llvm/ADT/Optional.h
+++ /dev/null
@@ -1,27 +0,0 @@
-//===- Optional.h - Simple variant for passing optional values --*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-///  This file provides Optional, a template class modeled in the spirit of
-///  OCaml's 'opt' variant.  The idea is to strongly type whether or not
-///  a value can be optional.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_ADT_OPTIONAL_H
-#define LLVM_ADT_OPTIONAL_H
-
-#include <optional>
-
-namespace llvm {
-// Legacy alias of llvm::Optional to std::optional.
-// FIXME: Remove this after LLVM 16.
-template <class T> using Optional = std::optional<T>;
-} // namespace llvm
-
-#endif // LLVM_ADT_OPTIONAL_H

diff  --git a/mlir/include/mlir/Support/LLVM.h b/mlir/include/mlir/Support/LLVM.h
index 216de42ad810e..e55ae06a8721e 100644
--- a/mlir/include/mlir/Support/LLVM.h
+++ b/mlir/include/mlir/Support/LLVM.h
@@ -18,9 +18,8 @@
 #ifndef MLIR_SUPPORT_LLVM_H
 #define MLIR_SUPPORT_LLVM_H
 
-// We include these two headers because they cannot be practically forward
+// We include this header because it cannot be practically forward
 // declared, and are effectively language features.
-#include "llvm/ADT/None.h"
 #include "llvm/Support/Casting.h"
 #include <vector>
 
@@ -58,7 +57,6 @@ class DenseSet;
 class MallocAllocator;
 template <typename T>
 class MutableArrayRef;
-template <typename T> using Optional = std::optional<T>;
 template <typename... PT>
 class PointerUnion;
 template <typename T, typename Vector, typename Set>
@@ -130,7 +128,6 @@ using SetVector = llvm::SetVector<T, Vector, Set>;
 template <typename AllocatorTy = llvm::MallocAllocator>
 using StringSet = llvm::StringSet<AllocatorTy>;
 using llvm::MutableArrayRef;
-using llvm::Optional;
 using llvm::PointerUnion;
 using llvm::SmallPtrSet;
 using llvm::SmallPtrSetImpl;


        


More information about the Mlir-commits mailing list