From: Kazu Hirata Date: Tue, 3 Jan 2023 03:13:11 +0000 (-0800) Subject: [flang] Use std::optional instead of llvm::Optional (NFC) X-Git-Tag: upstream/17.0.6~22351 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55916758d754227888293501de87bc90b7328108;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/flang/include/flang/Lower/StatementContext.h b/flang/include/flang/Lower/StatementContext.h index 1ab1bd0..ed8bdc2 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 +#include namespace Fortran::lower { @@ -93,7 +93,7 @@ private: StatementContext(StatementContext &&) = delete; // Stack of cleanup function "lists" (nested cleanup function calls). - llvm::SmallVector> cufs; + llvm::SmallVector> cufs; }; } // namespace Fortran::lower diff --git a/flang/include/flang/Optimizer/Support/InternalNames.h b/flang/include/flang/Optimizer/Support/InternalNames.h index 52bdf72..9463a81 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 +#include 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 modules, - llvm::Optional host, llvm::StringRef name, + std::optional host, llvm::StringRef name, llvm::ArrayRef kinds) : modules{modules.begin(), modules.end()}, host{host}, name{name}, kinds{kinds.begin(), kinds.end()} {} llvm::SmallVector modules; - llvm::Optional host; + std::optional host; std::string name; llvm::SmallVector kinds; }; @@ -72,12 +72,12 @@ struct NameUniquer { /// Unique a (global) constant name static std::string doConstant(llvm::ArrayRef modules, - llvm::Optional host, + std::optional host, llvm::StringRef name); /// Unique a dispatch table name static std::string doDispatchTable(llvm::ArrayRef modules, - llvm::Optional host, + std::optional host, llvm::StringRef name, llvm::ArrayRef kinds); @@ -87,39 +87,39 @@ struct NameUniquer { /// Unique an intrinsic type descriptor static std::string doIntrinsicTypeDescriptor(llvm::ArrayRef modules, - llvm::Optional host, + std::optional host, IntrinsicType type, std::int64_t kind); /// Unique a procedure name static std::string doProcedure(llvm::ArrayRef modules, - llvm::Optional host, + std::optional host, llvm::StringRef name); /// Unique a derived type name static std::string doType(llvm::ArrayRef modules, - llvm::Optional host, + std::optional host, llvm::StringRef name, llvm::ArrayRef kinds); /// Unique a (derived) type descriptor name static std::string doTypeDescriptor(llvm::ArrayRef modules, - llvm::Optional host, + std::optional host, llvm::StringRef name, llvm::ArrayRef kinds); static std::string doTypeDescriptor(llvm::ArrayRef modules, - llvm::Optional host, + std::optional host, llvm::StringRef name, llvm::ArrayRef 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 modules, - llvm::Optional host, + std::optional host, llvm::StringRef name); /// Unique a namelist group name static std::string doNamelistGroup(llvm::ArrayRef modules, - llvm::Optional host, + std::optional 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 fca8ac1..ecfefaa 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 #include using namespace fir; @@ -16,7 +17,7 @@ using llvm::StringRef; struct DeconstructedName { DeconstructedName(llvm::ArrayRef modules, - llvm::Optional host, llvm::StringRef name, + std::optional host, llvm::StringRef name, llvm::ArrayRef kinds) : modules{modules.begin(), modules.end()}, host{host}, name{name}, kinds{kinds.begin(), kinds.end()} {} @@ -31,7 +32,7 @@ struct DeconstructedName { private: llvm::SmallVector modules; - llvm::Optional host; + std::optional host; std::string name; llvm::SmallVector kinds; };