[flang-commits] [flang] 5591675 - [flang] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata via flang-commits
flang-commits at lists.llvm.org
Mon Jan 2 19:13:17 PST 2023
Author: Kazu Hirata
Date: 2023-01-02T19:13:11-08:00
New Revision: 55916758d754227888293501de87bc90b7328108
URL: https://github.com/llvm/llvm-project/commit/55916758d754227888293501de87bc90b7328108
DIFF: https://github.com/llvm/llvm-project/commit/55916758d754227888293501de87bc90b7328108.diff
LOG: [flang] 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:
flang/include/flang/Lower/StatementContext.h
flang/include/flang/Optimizer/Support/InternalNames.h
flang/unittests/Optimizer/InternalNamesTest.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Lower/StatementContext.h b/flang/include/flang/Lower/StatementContext.h
index 1ab1bd0faee38..ed8bdc2df165f 100644
--- a/flang/include/flang/Lower/StatementContext.h
+++ b/flang/include/flang/Lower/StatementContext.h
@@ -13,9 +13,9 @@
#ifndef FORTRAN_LOWER_STATEMENTCONTEXT_H
#define FORTRAN_LOWER_STATEMENTCONTEXT_H
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include <functional>
+#include <optional>
namespace Fortran::lower {
@@ -93,7 +93,7 @@ class StatementContext {
StatementContext(StatementContext &&) = delete;
// Stack of cleanup function "lists" (nested cleanup function calls).
- llvm::SmallVector<llvm::Optional<CleanupFunction>> cufs;
+ llvm::SmallVector<std::optional<CleanupFunction>> cufs;
};
} // namespace Fortran::lower
diff --git a/flang/include/flang/Optimizer/Support/InternalNames.h b/flang/include/flang/Optimizer/Support/InternalNames.h
index 52bdf724be5d2..9463a81328264 100644
--- a/flang/include/flang/Optimizer/Support/InternalNames.h
+++ b/flang/include/flang/Optimizer/Support/InternalNames.h
@@ -10,9 +10,9 @@
#define FORTRAN_OPTIMIZER_SUPPORT_INTERNALNAMES_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include <cstdint>
+#include <optional>
static constexpr llvm::StringRef typeDescriptorSeparator = ".dt.";
static constexpr llvm::StringRef bindingTableSeparator = ".v.";
@@ -53,13 +53,13 @@ struct NameUniquer {
struct DeconstructedName {
DeconstructedName(llvm::StringRef name) : name{name} {}
DeconstructedName(llvm::ArrayRef<std::string> modules,
- llvm::Optional<std::string> host, llvm::StringRef name,
+ std::optional<std::string> host, llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds)
: modules{modules.begin(), modules.end()}, host{host}, name{name},
kinds{kinds.begin(), kinds.end()} {}
llvm::SmallVector<std::string> modules;
- llvm::Optional<std::string> host;
+ std::optional<std::string> host;
std::string name;
llvm::SmallVector<std::int64_t> kinds;
};
@@ -72,12 +72,12 @@ struct NameUniquer {
/// Unique a (global) constant name
static std::string doConstant(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name);
/// Unique a dispatch table name
static std::string doDispatchTable(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds);
@@ -87,39 +87,39 @@ struct NameUniquer {
/// Unique an intrinsic type descriptor
static std::string
doIntrinsicTypeDescriptor(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
IntrinsicType type, std::int64_t kind);
/// Unique a procedure name
static std::string doProcedure(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name);
/// Unique a derived type name
static std::string doType(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds);
/// Unique a (derived) type descriptor name
static std::string doTypeDescriptor(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds);
static std::string doTypeDescriptor(llvm::ArrayRef<std::string> modules,
- llvm::Optional<std::string> host,
+ std::optional<std::string> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds);
/// Unique a (global) variable name. A variable with save attribute
/// defined inside a subprogram also needs to be handled here
static std::string doVariable(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name);
/// Unique a namelist group name
static std::string doNamelistGroup(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name);
/// Entry point for the PROGRAM (called by the runtime)
diff --git a/flang/unittests/Optimizer/InternalNamesTest.cpp b/flang/unittests/Optimizer/InternalNamesTest.cpp
index fca8ac16f919f..ecfefaabc4244 100644
--- a/flang/unittests/Optimizer/InternalNamesTest.cpp
+++ b/flang/unittests/Optimizer/InternalNamesTest.cpp
@@ -8,6 +8,7 @@
#include "flang/Optimizer/Support/InternalNames.h"
#include "gtest/gtest.h"
+#include <optional>
#include <string>
using namespace fir;
@@ -16,7 +17,7 @@ using llvm::StringRef;
struct DeconstructedName {
DeconstructedName(llvm::ArrayRef<std::string> modules,
- llvm::Optional<std::string> host, llvm::StringRef name,
+ std::optional<std::string> host, llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds)
: modules{modules.begin(), modules.end()}, host{host}, name{name},
kinds{kinds.begin(), kinds.end()} {}
@@ -31,7 +32,7 @@ struct DeconstructedName {
private:
llvm::SmallVector<std::string> modules;
- llvm::Optional<std::string> host;
+ std::optional<std::string> host;
std::string name;
llvm::SmallVector<std::int64_t> kinds;
};
More information about the flang-commits
mailing list