From c589730ad5286fc784b8aacf2f0214149603f312 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Mon, 5 Dec 2022 15:19:30 -0800 Subject: [PATCH] [YAML] Convert Optional to std::optional --- clang-tools-extra/clang-doc/BitcodeReader.cpp | 3 +- clang-tools-extra/clang-doc/Representation.h | 5 +- clang-tools-extra/clang-doc/YAMLGenerator.cpp | 3 +- .../clang-tidy/ClangTidyOptions.cpp | 9 +- .../clang-tidy/ClangTidyOptions.h | 21 +-- .../clang-tidy/google/TodoCommentCheck.cpp | 3 +- .../misc/MisleadingBidirectional.cpp | 3 +- .../clang-tidy/tool/ClangTidyMain.cpp | 16 +- clang-tools-extra/clangd/TidyProvider.cpp | 10 +- clang/lib/APINotes/APINotesYAMLCompiler.cpp | 65 +++---- .../llvm/Analysis/BlockFrequencyInfo.h | 8 +- .../llvm/Analysis/BlockFrequencyInfoImpl.h | 27 ++- .../llvm/Analysis/OptimizationRemarkEmitter.h | 4 +- .../llvm/Analysis/ProfileSummaryInfo.h | 6 +- llvm/include/llvm/CodeGen/MBFIWrapper.h | 5 +- llvm/include/llvm/CodeGen/MIRYamlMapping.h | 11 +- .../llvm/CodeGen/MachineBlockFrequencyInfo.h | 7 +- .../MachineOptimizationRemarkEmitter.h | 3 +- .../llvm/DebugInfo/CodeView/TypeRecord.h | 2 +- llvm/include/llvm/IR/DiagnosticInfo.h | 6 +- llvm/include/llvm/InterfaceStub/IFSHandler.h | 9 +- llvm/include/llvm/InterfaceStub/IFSStub.h | 20 +-- llvm/include/llvm/ObjectYAML/ArchiveYAML.h | 9 +- llvm/include/llvm/ObjectYAML/COFFYAML.h | 20 ++- llvm/include/llvm/ObjectYAML/DWARFYAML.h | 73 ++++---- .../include/llvm/ObjectYAML/DXContainerYAML.h | 19 ++- llvm/include/llvm/ObjectYAML/ELFYAML.h | 159 +++++++++--------- llvm/include/llvm/ObjectYAML/MachOYAML.h | 5 +- llvm/include/llvm/ObjectYAML/OffloadYAML.h | 19 ++- llvm/include/llvm/ObjectYAML/XCOFFYAML.h | 127 +++++++------- .../llvm/ProfileData/InstrProfCorrelator.h | 7 +- .../llvm/Remarks/BitstreamRemarkSerializer.h | 15 +- llvm/include/llvm/Remarks/Remark.h | 9 +- llvm/include/llvm/Remarks/RemarkSerializer.h | 5 +- .../llvm/Remarks/YAMLRemarkSerializer.h | 23 +-- llvm/include/llvm/Support/YAMLTraits.h | 34 ++-- llvm/lib/Analysis/BlockFrequencyInfo.cpp | 5 +- llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp | 5 +- .../Analysis/OptimizationRemarkEmitter.cpp | 4 +- llvm/lib/Analysis/ProfileSummaryInfo.cpp | 3 +- llvm/lib/CodeGen/MBFIWrapper.cpp | 4 +- .../lib/CodeGen/MachineBlockFrequencyInfo.cpp | 5 +- llvm/lib/CodeGen/MachineFunctionSplitter.cpp | 3 +- .../MachineOptimizationRemarkEmitter.cpp | 3 +- llvm/lib/IR/LLVMRemarkStreamer.cpp | 3 +- llvm/lib/InterfaceStub/IFSHandler.cpp | 10 +- llvm/lib/ObjectYAML/COFFEmitter.cpp | 3 +- llvm/lib/ObjectYAML/DWARFEmitter.cpp | 3 +- llvm/lib/ObjectYAML/ELFEmitter.cpp | 9 +- llvm/lib/ObjectYAML/ELFYAML.cpp | 15 +- llvm/lib/ProfileData/InstrProfCorrelator.cpp | 1 + .../lib/Remarks/BitstreamRemarkSerializer.cpp | 9 +- llvm/lib/Remarks/Remark.cpp | 7 +- llvm/lib/Remarks/YAMLRemarkParser.cpp | 2 +- llvm/lib/Remarks/YAMLRemarkSerializer.cpp | 15 +- llvm/lib/Support/AMDGPUMetadata.cpp | 3 +- .../AArch64/AArch64MachineFunctionInfo.h | 7 +- .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 2 +- .../Target/AMDGPU/SIMachineFunctionInfo.cpp | 5 +- .../lib/Target/AMDGPU/SIMachineFunctionInfo.h | 43 ++--- .../Transforms/Instrumentation/CGProfile.cpp | 3 +- .../ControlHeightReduction.cpp | 3 +- llvm/tools/dsymutil/DebugMap.cpp | 6 +- llvm/tools/dsymutil/DebugMap.h | 8 +- llvm/tools/dsymutil/MachODebugMapParser.cpp | 6 +- llvm/tools/llvm-ifs/llvm-ifs.cpp | 20 +-- llvm/tools/llvm-opt-report/OptReport.cpp | 3 +- llvm/tools/llvm-pdbutil/PdbYaml.h | 22 +-- llvm/tools/obj2yaml/dwarf2yaml.cpp | 3 +- llvm/tools/obj2yaml/elf2yaml.cpp | 13 +- llvm/tools/yaml2obj/yaml2obj.cpp | 7 +- .../mlir-linalg-ods-yaml-gen.cpp | 33 ++-- 72 files changed, 558 insertions(+), 508 deletions(-) diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp b/clang-tools-extra/clang-doc/BitcodeReader.cpp index 524b82d9fcc5..072011448330 100644 --- a/clang-tools-extra/clang-doc/BitcodeReader.cpp +++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" +#include namespace clang { namespace doc { @@ -81,7 +82,7 @@ llvm::Error decodeRecord(const Record &R, TagTypeKind &Field, } } -llvm::Error decodeRecord(const Record &R, llvm::Optional &Field, +llvm::Error decodeRecord(const Record &R, std::optional &Field, llvm::StringRef Blob) { if (R[0] > INT_MAX) return llvm::createStringError(llvm::inconvertibleErrorCode(), diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h index 7d7684446288..2a690883b33e 100644 --- a/clang-tools-extra/clang-doc/Representation.h +++ b/clang-tools-extra/clang-doc/Representation.h @@ -22,6 +22,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include +#include #include namespace clang { @@ -295,7 +296,7 @@ struct SymbolInfo : public Info { void merge(SymbolInfo &&I); - llvm::Optional DefLoc; // Location where this decl is defined. + std::optional DefLoc; // Location where this decl is defined. llvm::SmallVector Loc; // Locations where this decl is declared. }; @@ -421,7 +422,7 @@ struct EnumInfo : public SymbolInfo { // Set to nonempty to the type when this is an explicitly typed enum. For // enum Foo : short { ... }; // this will be "short". - llvm::Optional BaseType; + std::optional BaseType; llvm::SmallVector Members; // List of enum members. }; diff --git a/clang-tools-extra/clang-doc/YAMLGenerator.cpp b/clang-tools-extra/clang-doc/YAMLGenerator.cpp index b54486102ccc..0e662c0d9006 100644 --- a/clang-tools-extra/clang-doc/YAMLGenerator.cpp +++ b/clang-tools-extra/clang-doc/YAMLGenerator.cpp @@ -11,6 +11,7 @@ #include "Generators.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include using namespace clang::doc; @@ -125,7 +126,7 @@ static void InfoMapping(IO &IO, Info &I) { static void SymbolInfoMapping(IO &IO, SymbolInfo &I) { InfoMapping(IO, I); - IO.mapOptional("DefLocation", I.DefLoc, Optional()); + IO.mapOptional("DefLocation", I.DefLoc, std::optional()); IO.mapOptional("Location", I.Loc, llvm::SmallVector()); } diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp index c98ecb8bb29a..cf790f9f579a 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp @@ -16,6 +16,7 @@ #include "llvm/Support/MemoryBufferRef.h" #include "llvm/Support/Path.h" #include "llvm/Support/YAMLTraits.h" +#include #include #define DEBUG_TYPE "clang-tidy-options" @@ -155,7 +156,7 @@ ClangTidyOptions ClangTidyOptions::getDefaults() { } template -static void mergeVectors(Optional &Dest, const Optional &Src) { +static void mergeVectors(std::optional &Dest, const std::optional &Src) { if (Src) { if (Dest) Dest->insert(Dest->end(), Src->begin(), Src->end()); @@ -164,14 +165,14 @@ static void mergeVectors(Optional &Dest, const Optional &Src) { } } -static void mergeCommaSeparatedLists(Optional &Dest, - const Optional &Src) { +static void mergeCommaSeparatedLists(std::optional &Dest, + const std::optional &Src) { if (Src) Dest = (Dest && !Dest->empty() ? *Dest + "," : "") + *Src; } template -static void overrideValue(Optional &Dest, const Optional &Src) { +static void overrideValue(std::optional &Dest, const std::optional &Src) { if (Src) Dest = Src; } diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h index 20e54215ac8a..6102399d9d38 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h @@ -17,6 +17,7 @@ #include "llvm/Support/MemoryBufferRef.h" #include "llvm/Support/VirtualFileSystem.h" #include +#include #include #include #include @@ -67,17 +68,17 @@ struct ClangTidyOptions { unsigned Order) const; /// Checks filter. - llvm::Optional Checks; + std::optional Checks; /// WarningsAsErrors filter. - llvm::Optional WarningsAsErrors; + std::optional WarningsAsErrors; /// Output warnings from headers matching this filter. Warnings from /// main files will always be displayed. - llvm::Optional HeaderFilterRegex; + std::optional HeaderFilterRegex; /// Output warnings from system headers matching \c HeaderFilterRegex. - llvm::Optional SystemHeaders; + std::optional SystemHeaders; /// Format code around applied fixes with clang-format using this /// style. @@ -91,13 +92,13 @@ struct ClangTidyOptions { /// * '{inline-formatting-style-in-yaml-format}'. /// /// See clang-format documentation for more about configuring format style. - llvm::Optional FormatStyle; + std::optional FormatStyle; /// Specifies the name or e-mail of the user running clang-tidy. /// /// This option is used, for example, to place the correct user name in TODO() /// comments in the relevant check. - llvm::Optional User; + std::optional User; /// Helper structure for storing option value with priority of the value. struct ClangTidyValue { @@ -120,10 +121,10 @@ struct ClangTidyOptions { typedef std::vector ArgList; /// Add extra compilation arguments to the end of the list. - llvm::Optional ExtraArgs; + std::optional ExtraArgs; /// Add extra compilation arguments to the start of the list. - llvm::Optional ExtraArgsBefore; + std::optional ExtraArgsBefore; /// Only used in the FileOptionsProvider and ConfigOptionsProvider. If true /// and using a FileOptionsProvider, it will take a configuration file in the @@ -132,10 +133,10 @@ struct ClangTidyOptions { /// config on top of any configuration file it finds in the directory using /// the same logic as FileOptionsProvider. If false or missing, only this /// configuration file will be used. - llvm::Optional InheritParentConfig; + std::optional InheritParentConfig; /// Use colors in diagnostics. If missing, it will be auto detected. - llvm::Optional UseColor; + std::optional UseColor; }; /// Abstract interface for retrieving various ClangTidy options. diff --git a/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp b/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp index ec099f0e400c..afc7fa40db0a 100644 --- a/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp @@ -9,6 +9,7 @@ #include "TodoCommentCheck.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Lex/Preprocessor.h" +#include namespace clang { namespace tidy { @@ -17,7 +18,7 @@ namespace readability { class TodoCommentCheck::TodoCommentHandler : public CommentHandler { public: - TodoCommentHandler(TodoCommentCheck &Check, llvm::Optional User) + TodoCommentHandler(TodoCommentCheck &Check, std::optional User) : Check(Check), User(User ? *User : "unknown"), TodoMatch("^// *TODO *(\\(.*\\))?:?( )?(.*)$") {} diff --git a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp index c2948451ac5f..3706f43d255b 100644 --- a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp +++ b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp @@ -11,6 +11,7 @@ #include "clang/Frontend/CompilerInstance.h" #include "clang/Lex/Preprocessor.h" #include "llvm/Support/ConvertUTF.h" +#include using namespace clang; using namespace clang::tidy::misc; @@ -90,7 +91,7 @@ class MisleadingBidirectionalCheck::MisleadingBidirectionalHandler : public CommentHandler { public: MisleadingBidirectionalHandler(MisleadingBidirectionalCheck &Check, - llvm::Optional User) + std::optional User) : Check(Check) {} bool HandleComment(Preprocessor &PP, SourceRange Range) override { diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp index 422ae6c772d7..3ff4cbdad4da 100644 --- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -26,6 +26,7 @@ #include "llvm/Support/Signals.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/WithColor.h" +#include using namespace clang::tooling; using namespace llvm; @@ -308,19 +309,10 @@ static std::unique_ptr createOptionsProvider( DefaultOptions.HeaderFilterRegex = HeaderFilter; DefaultOptions.SystemHeaders = SystemHeaders; DefaultOptions.FormatStyle = FormatStyle; - if (auto User = llvm::sys::Process::GetEnv("USER")) // FIXME(kparzysz-quic) - DefaultOptions.User = *User; - else - DefaultOptions.User = std::nullopt; + DefaultOptions.User = llvm::sys::Process::GetEnv("USER"); // USERNAME is used on Windows. - // if (!DefaultOptions.User) - // DefaultOptions.User = llvm::sys::Process::GetEnv("USERNAME"); - if (!DefaultOptions.User) { // FIXME(kparzysz-quic) - if (auto Username = llvm::sys::Process::GetEnv("USERNAME")) - DefaultOptions.User = *Username; - else - DefaultOptions.User = std::nullopt; - } + if (!DefaultOptions.User) + DefaultOptions.User = llvm::sys::Process::GetEnv("USERNAME"); ClangTidyOptions OverrideOptions; if (Checks.getNumOccurrences() > 0) diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp index 7f134d923266..936b1ce3edab 100644 --- a/clang-tools-extra/clangd/TidyProvider.cpp +++ b/clang-tools-extra/clangd/TidyProvider.cpp @@ -21,6 +21,7 @@ #include "llvm/Support/Process.h" #include "llvm/Support/SourceMgr.h" #include +#include namespace clang { namespace clangd { @@ -136,7 +137,7 @@ public: } // namespace -static void mergeCheckList(llvm::Optional &Checks, +static void mergeCheckList(std::optional &Checks, llvm::StringRef List) { if (List.empty()) return; @@ -148,14 +149,13 @@ static void mergeCheckList(llvm::Optional &Checks, } TidyProviderRef provideEnvironment() { - static const llvm::Optional User = [] { + static const std::optional User = [] { std::optional Ret = llvm::sys::Process::GetEnv("USER"); #ifdef _WIN32 if (!Ret) - Ret = llvm::sys::Process::GetEnv("USERNAME"); + return llvm::sys::Process::GetEnv("USERNAME"); #endif - return Ret ? llvm::Optional(*Ret) - : llvm::Optional(); + return Ret; }(); if (User) diff --git a/clang/lib/APINotes/APINotesYAMLCompiler.cpp b/clang/lib/APINotes/APINotesYAMLCompiler.cpp index 1e6ccb59e068..42279b8668c6 100644 --- a/clang/lib/APINotes/APINotesYAMLCompiler.cpp +++ b/clang/lib/APINotes/APINotesYAMLCompiler.cpp @@ -21,6 +21,7 @@ #include "llvm/Support/VersionTuple.h" #include "llvm/Support/YAMLParser.h" #include "llvm/Support/YAMLTraits.h" +#include #include using namespace clang; using namespace api_notes; @@ -70,9 +71,9 @@ template <> struct ScalarEnumerationTraits { namespace { struct Param { unsigned Position; - Optional NoEscape = false; - Optional Nullability; - Optional RetainCountConvention; + std::optional NoEscape = false; + std::optional Nullability; + std::optional RetainCountConvention; StringRef Type; }; @@ -151,10 +152,10 @@ struct Method { MethodKind Kind; ParamsSeq Params; NullabilitySeq Nullability; - Optional NullabilityOfRet; - Optional RetainCountConvention; + std::optional NullabilityOfRet; + std::optional RetainCountConvention; AvailabilityItem Availability; - Optional SwiftPrivate; + std::optional SwiftPrivate; StringRef SwiftName; FactoryAsInitKind FactoryAsInit = FactoryAsInitKind::Infer; bool DesignatedInit = false; @@ -202,12 +203,12 @@ template <> struct MappingTraits { namespace { struct Property { StringRef Name; - llvm::Optional Kind; - llvm::Optional Nullability; + std::optional Kind; + std::optional Nullability; AvailabilityItem Availability; - Optional SwiftPrivate; + std::optional SwiftPrivate; StringRef SwiftName; - Optional SwiftImportAsAccessors; + std::optional SwiftImportAsAccessors; StringRef Type; }; @@ -240,12 +241,12 @@ struct Class { StringRef Name; bool AuditedForNullability = false; AvailabilityItem Availability; - Optional SwiftPrivate; + std::optional SwiftPrivate; StringRef SwiftName; - Optional SwiftBridge; - Optional NSErrorDomain; - Optional SwiftImportAsNonGeneric; - Optional SwiftObjCMembers; + std::optional SwiftBridge; + std::optional NSErrorDomain; + std::optional SwiftImportAsNonGeneric; + std::optional SwiftObjCMembers; MethodsSeq Methods; PropertiesSeq Properties; }; @@ -282,10 +283,10 @@ struct Function { StringRef Name; ParamsSeq Params; NullabilitySeq Nullability; - Optional NullabilityOfRet; - Optional RetainCountConvention; + std::optional NullabilityOfRet; + std::optional RetainCountConvention; AvailabilityItem Availability; - Optional SwiftPrivate; + std::optional SwiftPrivate; StringRef SwiftName; StringRef Type; StringRef ResultType; @@ -319,9 +320,9 @@ template <> struct MappingTraits { namespace { struct GlobalVariable { StringRef Name; - llvm::Optional Nullability; + std::optional Nullability; AvailabilityItem Availability; - Optional SwiftPrivate; + std::optional SwiftPrivate; StringRef SwiftName; StringRef Type; }; @@ -352,7 +353,7 @@ namespace { struct EnumConstant { StringRef Name; AvailabilityItem Availability; - Optional SwiftPrivate; + std::optional SwiftPrivate; StringRef SwiftName; }; @@ -411,12 +412,12 @@ struct Tag { StringRef Name; AvailabilityItem Availability; StringRef SwiftName; - Optional SwiftPrivate; - Optional SwiftBridge; - Optional NSErrorDomain; - Optional EnumExtensibility; - Optional FlagEnum; - Optional EnumConvenienceKind; + std::optional SwiftPrivate; + std::optional SwiftBridge; + std::optional NSErrorDomain; + std::optional EnumExtensibility; + std::optional FlagEnum; + std::optional EnumConvenienceKind; }; typedef std::vector TagsSeq; @@ -457,10 +458,10 @@ struct Typedef { StringRef Name; AvailabilityItem Availability; StringRef SwiftName; - Optional SwiftPrivate; - Optional SwiftBridge; - Optional NSErrorDomain; - Optional SwiftType; + std::optional SwiftPrivate; + std::optional SwiftBridge; + std::optional NSErrorDomain; + std::optional SwiftType; }; typedef std::vector TypedefsSeq; @@ -549,7 +550,7 @@ struct Module { TopLevelItems TopLevel; VersionedSeq SwiftVersions; - llvm::Optional SwiftInferImportAsMember = {std::nullopt}; + std::optional SwiftInferImportAsMember = std::nullopt; #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void dump() /*const*/; diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h index 4c38cdd4a62b..39507570a1b2 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h @@ -13,12 +13,12 @@ #ifndef LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H #define LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H -#include "llvm/ADT/Optional.h" #include "llvm/IR/PassManager.h" #include "llvm/Pass.h" #include "llvm/Support/BlockFrequency.h" #include #include +#include namespace llvm { @@ -67,13 +67,13 @@ public: /// Returns the estimated profile count of \p BB. /// This computes the relative block frequency of \p BB and multiplies it by /// the enclosing function's count (if available) and returns the value. - Optional getBlockProfileCount(const BasicBlock *BB, - bool AllowSynthetic = false) const; + std::optional + getBlockProfileCount(const BasicBlock *BB, bool AllowSynthetic = false) const; /// Returns the estimated profile count of \p Freq. /// This uses the frequency \p Freq and multiplies it by /// the enclosing function's count (if available) and returns the value. - Optional getProfileCountFromFreq(uint64_t Freq) const; + std::optional getProfileCountFromFreq(uint64_t Freq) const; /// Returns true if \p BB is an irreducible loop header /// block. Otherwise false. diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h index 0e9cac076902..68d9d1bcf18c 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -18,7 +18,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -523,12 +522,12 @@ public: Scaled64 getFloatingBlockFreq(const BlockNode &Node) const; BlockFrequency getBlockFreq(const BlockNode &Node) const; - Optional getBlockProfileCount(const Function &F, - const BlockNode &Node, - bool AllowSynthetic = false) const; - Optional getProfileCountFromFreq(const Function &F, - uint64_t Freq, - bool AllowSynthetic = false) const; + std::optional + getBlockProfileCount(const Function &F, const BlockNode &Node, + bool AllowSynthetic = false) const; + std::optional + getProfileCountFromFreq(const Function &F, uint64_t Freq, + bool AllowSynthetic = false) const; bool isIrrLoopHeader(const BlockNode &Node); void setBlockFreq(const BlockNode &Node, uint64_t Freq); @@ -1021,16 +1020,16 @@ public: return BlockFrequencyInfoImplBase::getBlockFreq(getNode(BB)); } - Optional getBlockProfileCount(const Function &F, - const BlockT *BB, - bool AllowSynthetic = false) const { + std::optional + getBlockProfileCount(const Function &F, const BlockT *BB, + bool AllowSynthetic = false) const { return BlockFrequencyInfoImplBase::getBlockProfileCount(F, getNode(BB), AllowSynthetic); } - Optional getProfileCountFromFreq(const Function &F, - uint64_t Freq, - bool AllowSynthetic = false) const { + std::optional + getProfileCountFromFreq(const Function &F, uint64_t Freq, + bool AllowSynthetic = false) const { return BlockFrequencyInfoImplBase::getProfileCountFromFreq(F, Freq, AllowSynthetic); } @@ -1730,7 +1729,7 @@ raw_ostream &BlockFrequencyInfoImpl::print(raw_ostream &OS) const { OS << " - " << bfi_detail::getBlockName(&BB) << ": float = "; getFloatingBlockFreq(&BB).print(OS, 5) << ", int = " << getBlockFreq(&BB).getFrequency(); - if (Optional ProfileCount = + if (std::optional ProfileCount = BlockFrequencyInfoImplBase::getBlockProfileCount( F->getFunction(), getNode(&BB))) OS << ", count = " << ProfileCount.value(); diff --git a/llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h b/llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h index ff706e91f3c4..8aaeaf299102 100644 --- a/llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h +++ b/llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h @@ -14,11 +14,11 @@ #ifndef LLVM_ANALYSIS_OPTIMIZATIONREMARKEMITTER_H #define LLVM_ANALYSIS_OPTIMIZATIONREMARKEMITTER_H -#include "llvm/ADT/Optional.h" #include "llvm/Analysis/BlockFrequencyInfo.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/PassManager.h" #include "llvm/Pass.h" +#include namespace llvm { class Function; @@ -116,7 +116,7 @@ private: /// Compute hotness from IR value (currently assumed to be a block) if PGO is /// available. - Optional computeHotness(const Value *V); + std::optional computeHotness(const Value *V); /// Similar but use value from \p OptDiag and update hotness there. void computeHotness(DiagnosticInfoIROptimization &OptDiag); diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h index f67dfa1bc24f..9cf8fe3254a5 100644 --- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h +++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h @@ -98,9 +98,9 @@ public: } /// Returns the profile count for \p CallInst. - Optional getProfileCount(const CallBase &CallInst, - BlockFrequencyInfo *BFI, - bool AllowSynthetic = false) const; + std::optional getProfileCount(const CallBase &CallInst, + BlockFrequencyInfo *BFI, + bool AllowSynthetic = false) const; /// Returns true if module \c M has partial-profile sample profile. bool hasPartialSampleProfile() const; /// Returns true if the working set size of the code is considered huge. diff --git a/llvm/include/llvm/CodeGen/MBFIWrapper.h b/llvm/include/llvm/CodeGen/MBFIWrapper.h index 59506bb13ec6..714ecc5d4334 100644 --- a/llvm/include/llvm/CodeGen/MBFIWrapper.h +++ b/llvm/include/llvm/CodeGen/MBFIWrapper.h @@ -15,9 +15,9 @@ #define LLVM_CODEGEN_MBFIWRAPPER_H #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/Optional.h" #include "llvm/Support/BlockFrequency.h" #include "llvm/Support/raw_ostream.h" +#include namespace llvm { @@ -30,7 +30,8 @@ class MBFIWrapper { BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const; void setBlockFreq(const MachineBasicBlock *MBB, BlockFrequency F); - Optional getBlockProfileCount(const MachineBasicBlock *MBB) const; + std::optional + getBlockProfileCount(const MachineBasicBlock *MBB) const; raw_ostream &printBlockFreq(raw_ostream &OS, const MachineBasicBlock *MBB) const; diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h index cb18030f7223..ba6b64d0a848 100644 --- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h +++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h @@ -14,7 +14,6 @@ #ifndef LLVM_CODEGEN_MIRYAMLMAPPING_H #define LLVM_CODEGEN_MIRYAMLMAPPING_H -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/TargetFrameLowering.h" @@ -23,6 +22,7 @@ #include "llvm/Support/raw_ostream.h" #include #include +#include #include #include @@ -249,7 +249,7 @@ struct MachineStackObject { TargetStackID::Value StackID; StringValue CalleeSavedRegister; bool CalleeSavedRestored = true; - Optional LocalOffset; + std::optional LocalOffset; StringValue DebugVar; StringValue DebugExpr; StringValue DebugLoc; @@ -291,7 +291,8 @@ template <> struct MappingTraits { StringValue()); // Don't print it out when it's empty. YamlIO.mapOptional("callee-saved-restored", Object.CalleeSavedRestored, true); - YamlIO.mapOptional("local-offset", Object.LocalOffset, Optional()); + YamlIO.mapOptional("local-offset", Object.LocalOffset, + std::optional()); YamlIO.mapOptional("debug-info-variable", Object.DebugVar, StringValue()); // Don't print it out when it's empty. YamlIO.mapOptional("debug-info-expression", Object.DebugExpr, @@ -708,7 +709,7 @@ struct MachineFunction { bool TracksDebugUserValues = false; std::vector VirtualRegisters; std::vector LiveIns; - Optional> CalleeSavedRegisters; + std::optional> CalleeSavedRegisters; // TODO: Serialize the various register masks. // Frame information MachineFrameInfo FrameInfo; @@ -749,7 +750,7 @@ template <> struct MappingTraits { YamlIO.mapOptional("liveins", MF.LiveIns, std::vector()); YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters, - Optional>()); + std::optional>()); YamlIO.mapOptional("frameInfo", MF.FrameInfo, MachineFrameInfo()); YamlIO.mapOptional("fixedStack", MF.FixedStackObjects, std::vector()); diff --git a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h index 6c442d3d07bd..2290d26c0827 100644 --- a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h +++ b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h @@ -13,11 +13,11 @@ #ifndef LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H #define LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H -#include "llvm/ADT/Optional.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/Support/BlockFrequency.h" #include #include +#include namespace llvm { @@ -69,8 +69,9 @@ public: return getBlockFreq(MBB).getFrequency() * (1.0f / getEntryFreq()); } - Optional getBlockProfileCount(const MachineBasicBlock *MBB) const; - Optional getProfileCountFromFreq(uint64_t Freq) const; + std::optional + getBlockProfileCount(const MachineBasicBlock *MBB) const; + std::optional getProfileCountFromFreq(uint64_t Freq) const; bool isIrrLoopHeader(const MachineBasicBlock *MBB) const; diff --git a/llvm/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h b/llvm/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h index cb0998984dfb..2b177e6763d3 100644 --- a/llvm/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h +++ b/llvm/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h @@ -18,6 +18,7 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/Function.h" +#include namespace llvm { class MachineBasicBlock; @@ -201,7 +202,7 @@ private: /// Compute hotness from IR value (currently assumed to be a block) if PGO is /// available. - Optional computeHotness(const MachineBasicBlock &MBB); + std::optional computeHotness(const MachineBasicBlock &MBB); /// Similar but use value from \p OptDiag and update hotness there. void computeHotness(DiagnosticInfoMIROptimization &Remark); diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h index 1ebc4d47e096..6e2d7870a3cf 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h +++ b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h @@ -347,7 +347,7 @@ public: TypeIndex ReferentType; uint32_t Attrs = 0; - Optional MemberInfo; + std::optional MemberInfo; void setAttrs(PointerKind PK, PointerMode PM, PointerOptions PO, uint8_t Size) { diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h index f3abce37b167..628445fe9fb2 100644 --- a/llvm/include/llvm/IR/DiagnosticInfo.h +++ b/llvm/include/llvm/IR/DiagnosticInfo.h @@ -479,8 +479,8 @@ public: StringRef getPassName() const { return PassName; } StringRef getRemarkName() const { return RemarkName; } std::string getMsg() const; - Optional getHotness() const { return Hotness; } - void setHotness(Optional H) { Hotness = H; } + std::optional getHotness() const { return Hotness; } + void setHotness(std::optional H) { Hotness = H; } bool isVerbose() const { return IsVerbose; } @@ -521,7 +521,7 @@ protected: /// If profile information is available, this is the number of times the /// corresponding code was executed in a profile instrumentation run. - Optional Hotness; + std::optional Hotness; /// Arguments collected via the streaming interface. SmallVector Args; diff --git a/llvm/include/llvm/InterfaceStub/IFSHandler.h b/llvm/include/llvm/InterfaceStub/IFSHandler.h index bfa5692811d7..09687bfb9e44 100644 --- a/llvm/include/llvm/InterfaceStub/IFSHandler.h +++ b/llvm/include/llvm/InterfaceStub/IFSHandler.h @@ -19,6 +19,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/VersionTuple.h" #include +#include #include #include @@ -41,10 +42,10 @@ Expected> readIFSFromBuffer(StringRef Buf); Error writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub); /// Override the target platform inforation in the text stub. -Error overrideIFSTarget(IFSStub &Stub, Optional OverrideArch, - Optional OverrideEndianness, - Optional OverrideBitWidth, - Optional OverrideTriple); +Error overrideIFSTarget(IFSStub &Stub, std::optional OverrideArch, + std::optional OverrideEndianness, + std::optional OverrideBitWidth, + std::optional OverrideTriple); /// Validate the target platform inforation in the text stub. Error validateIFSTarget(IFSStub &Stub, bool ParseTriple); diff --git a/llvm/include/llvm/InterfaceStub/IFSStub.h b/llvm/include/llvm/InterfaceStub/IFSStub.h index 0f935cd478d5..119669106733 100644 --- a/llvm/include/llvm/InterfaceStub/IFSStub.h +++ b/llvm/include/llvm/InterfaceStub/IFSStub.h @@ -14,8 +14,8 @@ #ifndef LLVM_INTERFACESTUB_IFSSTUB_H #define LLVM_INTERFACESTUB_IFSSTUB_H -#include "llvm/ADT/Optional.h" #include "llvm/Support/VersionTuple.h" +#include #include namespace llvm { @@ -53,21 +53,21 @@ struct IFSSymbol { IFSSymbol() = default; explicit IFSSymbol(std::string SymbolName) : Name(std::move(SymbolName)) {} std::string Name; - Optional Size; + std::optional Size; IFSSymbolType Type; bool Undefined; bool Weak; - Optional Warning; + std::optional Warning; bool operator<(const IFSSymbol &RHS) const { return Name < RHS.Name; } }; struct IFSTarget { - Optional Triple; - Optional ObjectFormat; - Optional Arch; - Optional ArchString; - Optional Endianness; - Optional BitWidth; + std::optional Triple; + std::optional ObjectFormat; + std::optional Arch; + std::optional ArchString; + std::optional Endianness; + std::optional BitWidth; bool empty(); }; @@ -89,7 +89,7 @@ inline bool operator!=(const IFSTarget &Lhs, const IFSTarget &Rhs) { struct IFSStub { // TODO: Add support for symbol versioning. VersionTuple IfsVersion; - Optional SoName; + std::optional SoName; IFSTarget Target; std::vector NeededLibs; std::vector Symbols; diff --git a/llvm/include/llvm/ObjectYAML/ArchiveYAML.h b/llvm/include/llvm/ObjectYAML/ArchiveYAML.h index 8d05feedcc62..c83c7ee56f1f 100644 --- a/llvm/include/llvm/ObjectYAML/ArchiveYAML.h +++ b/llvm/include/llvm/ObjectYAML/ArchiveYAML.h @@ -17,6 +17,7 @@ #include "llvm/Support/YAMLTraits.h" #include "llvm/ObjectYAML/YAML.h" #include "llvm/ADT/MapVector.h" +#include namespace llvm { namespace ArchYAML { @@ -44,13 +45,13 @@ struct Archive { MapVector Fields; - Optional Content; - Optional PaddingByte; + std::optional Content; + std::optional PaddingByte; }; StringRef Magic; - Optional> Members; - Optional Content; + std::optional> Members; + std::optional Content; }; } // end namespace ArchYAML diff --git a/llvm/include/llvm/ObjectYAML/COFFYAML.h b/llvm/include/llvm/ObjectYAML/COFFYAML.h index eec5af928f6d..b8b17e9e32d4 100644 --- a/llvm/include/llvm/ObjectYAML/COFFYAML.h +++ b/llvm/include/llvm/ObjectYAML/COFFYAML.h @@ -21,6 +21,7 @@ #include "llvm/ObjectYAML/CodeViewYAMLTypes.h" #include "llvm/ObjectYAML/YAML.h" #include +#include #include namespace llvm { @@ -63,7 +64,7 @@ struct Relocation { // specified), allowing disambiguating between multiple symbols with the // same name or crafting intentionally broken files for testing. StringRef SymbolName; - Optional SymbolTableIndex; + std::optional SymbolTableIndex; }; struct Section { @@ -73,7 +74,7 @@ struct Section { std::vector DebugS; std::vector DebugT; std::vector DebugP; - Optional DebugH; + std::optional DebugH; std::vector Relocations; StringRef Name; @@ -84,12 +85,12 @@ struct Symbol { COFF::symbol Header; COFF::SymbolBaseType SimpleType = COFF::IMAGE_SYM_TYPE_NULL; COFF::SymbolComplexType ComplexType = COFF::IMAGE_SYM_DTYPE_NULL; - Optional FunctionDefinition; - Optional bfAndefSymbol; - Optional WeakExternal; + std::optional FunctionDefinition; + std::optional bfAndefSymbol; + std::optional WeakExternal; StringRef File; - Optional SectionDefinition; - Optional CLRToken; + std::optional SectionDefinition; + std::optional CLRToken; StringRef Name; Symbol(); @@ -97,11 +98,12 @@ struct Symbol { struct PEHeader { COFF::PE32Header Header; - Optional DataDirectories[COFF::NUM_DATA_DIRECTORIES]; + std::optional + DataDirectories[COFF::NUM_DATA_DIRECTORIES]; }; struct Object { - Optional OptionalHeader; + std::optional OptionalHeader; COFF::header Header; std::vector
Sections; std::vector Symbols; diff --git a/llvm/include/llvm/ObjectYAML/DWARFYAML.h b/llvm/include/llvm/ObjectYAML/DWARFYAML.h index 856cea9a1535..a70ddf3a180a 100644 --- a/llvm/include/llvm/ObjectYAML/DWARFYAML.h +++ b/llvm/include/llvm/ObjectYAML/DWARFYAML.h @@ -21,6 +21,7 @@ #include "llvm/ObjectYAML/YAML.h" #include "llvm/Support/YAMLTraits.h" #include +#include #include #include @@ -34,14 +35,14 @@ struct AttributeAbbrev { }; struct Abbrev { - Optional Code; + std::optional Code; llvm::dwarf::Tag Tag; llvm::dwarf::Constants Children; std::vector Attributes; }; struct AbbrevTable { - Optional ID; + std::optional ID; std::vector Table; }; @@ -52,10 +53,10 @@ struct ARangeDescriptor { struct ARange { dwarf::DwarfFormat Format; - Optional Length; + std::optional Length; uint16_t Version; yaml::Hex64 CuOffset; - Optional AddrSize; + std::optional AddrSize; yaml::Hex8 SegSize; std::vector Descriptors; }; @@ -69,8 +70,8 @@ struct RangeEntry { /// Class that describes a single range list inside the .debug_ranges section. struct Ranges { - Optional Offset; - Optional AddrSize; + std::optional Offset; + std::optional AddrSize; std::vector Entries; }; @@ -108,12 +109,12 @@ struct DWARFContext { struct Unit { dwarf::DwarfFormat Format; - Optional Length; + std::optional Length; uint16_t Version; - Optional AddrSize; + std::optional AddrSize; llvm::dwarf::UnitType Type; // Added in DWARF 5 - Optional AbbrevTableID; - Optional AbbrOffset; + std::optional AbbrevTableID; + std::optional AbbrOffset; std::vector Entries; }; @@ -126,7 +127,7 @@ struct File { struct LineTableOpcode { dwarf::LineNumberOps Opcode; - Optional ExtLen; + std::optional ExtLen; dwarf::LineNumberExtendedOps SubOpcode; uint64_t Data; int64_t SData; @@ -137,16 +138,16 @@ struct LineTableOpcode { struct LineTable { dwarf::DwarfFormat Format; - Optional Length; + std::optional Length; uint16_t Version; - Optional PrologueLength; + std::optional PrologueLength; uint8_t MinInstLength; uint8_t MaxOpsPerInst; uint8_t DefaultIsStmt; uint8_t LineBase; uint8_t LineRange; - Optional OpcodeBase; - Optional> StandardOpcodeLengths; + std::optional OpcodeBase; + std::optional> StandardOpcodeLengths; std::vector IncludeDirs; std::vector Files; std::vector Opcodes; @@ -159,16 +160,16 @@ struct SegAddrPair { struct AddrTableEntry { dwarf::DwarfFormat Format; - Optional Length; + std::optional Length; yaml::Hex16 Version; - Optional AddrSize; + std::optional AddrSize; yaml::Hex8 SegSelectorSize; std::vector SegAddrPairs; }; struct StringOffsetsTable { dwarf::DwarfFormat Format; - Optional Length; + std::optional Length; yaml::Hex16 Version; yaml::Hex16 Padding; std::vector Offsets; @@ -187,23 +188,23 @@ struct RnglistEntry { struct LoclistEntry { dwarf::LoclistEntries Operator; std::vector Values; - Optional DescriptionsLength; + std::optional DescriptionsLength; std::vector Descriptions; }; template struct ListEntries { - Optional> Entries; - Optional Content; + std::optional> Entries; + std::optional Content; }; template struct ListTable { dwarf::DwarfFormat Format; - Optional Length; + std::optional Length; yaml::Hex16 Version; - Optional AddrSize; + std::optional AddrSize; yaml::Hex8 SegSelectorSize; - Optional OffsetEntryCount; - Optional> Offsets; + std::optional OffsetEntryCount; + std::optional> Offsets; std::vector> Lists; }; @@ -211,22 +212,22 @@ struct Data { bool IsLittleEndian; bool Is64BitAddrSize; std::vector DebugAbbrev; - Optional> DebugStrings; - Optional> DebugStrOffsets; - Optional> DebugAranges; - Optional> DebugRanges; - Optional> DebugAddr; - Optional PubNames; - Optional PubTypes; + std::optional> DebugStrings; + std::optional> DebugStrOffsets; + std::optional> DebugAranges; + std::optional> DebugRanges; + std::optional> DebugAddr; + std::optional PubNames; + std::optional PubTypes; - Optional GNUPubNames; - Optional GNUPubTypes; + std::optional GNUPubNames; + std::optional GNUPubTypes; std::vector CompileUnits; std::vector DebugLines; - Optional>> DebugRnglists; - Optional>> DebugLoclists; + std::optional>> DebugRnglists; + std::optional>> DebugLoclists; bool isEmpty() const; diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h index 49602aa5eda1..55c61ff96b7c 100644 --- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h +++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h @@ -20,6 +20,7 @@ #include "llvm/ObjectYAML/YAML.h" #include "llvm/Support/YAMLTraits.h" #include +#include #include #include @@ -37,21 +38,21 @@ struct VersionTuple { struct FileHeader { std::vector Hash; VersionTuple Version; - Optional FileSize; + std::optional FileSize; uint32_t PartCount; - Optional> PartOffsets; + std::optional> PartOffsets; }; struct DXILProgram { uint8_t MajorVersion; uint8_t MinorVersion; uint16_t ShaderKind; - Optional Size; + std::optional Size; uint16_t DXILMajorVersion; uint16_t DXILMinorVersion; - Optional DXILOffset; - Optional DXILSize; - Optional> DXIL; + std::optional DXILOffset; + std::optional DXILSize; + std::optional> DXIL; }; #define SHADER_FLAG(Num, Val, Str) bool Val = false; @@ -75,9 +76,9 @@ struct Part { Part(std::string N, uint32_t S) : Name(N), Size(S) {} std::string Name; uint32_t Size; - Optional Program; - Optional Flags; - Optional Hash; + std::optional Program; + std::optional Flags; + std::optional Hash; }; struct Object { diff --git a/llvm/include/llvm/ObjectYAML/ELFYAML.h b/llvm/include/llvm/ObjectYAML/ELFYAML.h index ddd5dd9cf3c9..cc77971c61cb 100644 --- a/llvm/include/llvm/ObjectYAML/ELFYAML.h +++ b/llvm/include/llvm/ObjectYAML/ELFYAML.h @@ -23,6 +23,7 @@ #include "llvm/Support/YAMLTraits.h" #include #include +#include #include namespace llvm { @@ -115,18 +116,18 @@ struct FileHeader { ELF_ELFOSABI OSABI; llvm::yaml::Hex8 ABIVersion; ELF_ET Type; - Optional Machine; + std::optional Machine; ELF_EF Flags; llvm::yaml::Hex64 Entry; - Optional SectionHeaderStringTable; + std::optional SectionHeaderStringTable; - Optional EPhOff; - Optional EPhEntSize; - Optional EPhNum; - Optional EShEntSize; - Optional EShOff; - Optional EShNum; - Optional EShStrNdx; + std::optional EPhOff; + std::optional EPhEntSize; + std::optional EPhNum; + std::optional EShEntSize; + std::optional EShOff; + std::optional EShNum; + std::optional EShStrNdx; }; struct SectionHeader { @@ -136,14 +137,14 @@ struct SectionHeader { struct Symbol { StringRef Name; ELF_STT Type; - Optional Section; - Optional Index; + std::optional Section; + std::optional Index; ELF_STB Binding; - Optional Value; - Optional Size; - Optional Other; + std::optional Value; + std::optional Size; + std::optional Other; - Optional StName; + std::optional StName; }; struct SectionOrType { @@ -164,8 +165,8 @@ struct BBAddrMapEntry { uint8_t Version; llvm::yaml::Hex8 Feature; llvm::yaml::Hex64 Address; - Optional NumBlocks; - Optional> BBEntries; + std::optional NumBlocks; + std::optional> BBEntries; }; struct StackSizeEntry { @@ -211,7 +212,7 @@ struct Chunk { ChunkKind Kind; StringRef Name; - Optional Offset; + std::optional Offset; // Usually chunks are not created implicitly, but rather loaded from YAML. // This flag is used to signal whether this is the case or not. @@ -223,14 +224,14 @@ struct Chunk { struct Section : public Chunk { ELF_SHT Type; - Optional Flags; - Optional Address; - Optional Link; + std::optional Flags; + std::optional Address; + std::optional Link; llvm::yaml::Hex64 AddressAlign; - Optional EntSize; + std::optional EntSize; - Optional Content; - Optional Size; + std::optional Content; + std::optional Size; // Holds the original section index. unsigned OriginalSecNdx; @@ -252,35 +253,35 @@ struct Section : public Chunk { // useful for creating invalid objects. // This can be used to override the sh_addralign field. - Optional ShAddrAlign; + std::optional ShAddrAlign; // This can be used to override the offset stored in the sh_name field. // It does not affect the name stored in the string table. - Optional ShName; + std::optional ShName; // This can be used to override the sh_offset field. It does not place the // section data at the offset specified. - Optional ShOffset; + std::optional ShOffset; // This can be used to override the sh_size field. It does not affect the // content written. - Optional ShSize; + std::optional ShSize; // This can be used to override the sh_flags field. - Optional ShFlags; + std::optional ShFlags; // This can be used to override the sh_type field. It is useful when we // want to use specific YAML keys for a section of a particular type to // describe the content, but still want to have a different final type // for the section. - Optional ShType; + std::optional ShType; }; // Fill is a block of data which is placed outside of sections. It is // not present in the sections header table, but it might affect the output file // size and program headers produced. struct Fill : Chunk { - Optional Pattern; + std::optional Pattern; llvm::yaml::Hex64 Size; Fill() : Chunk(ChunkKind::Fill, /*Implicit=*/false) {} @@ -296,9 +297,9 @@ struct SectionHeaderTable : Chunk { return S->Kind == ChunkKind::SectionHeaderTable; } - Optional> Sections; - Optional> Excluded; - Optional NoHeaders; + std::optional> Sections; + std::optional> Excluded; + std::optional NoHeaders; size_t getNumHeaders(size_t SectionsNum) const { if (IsImplicit || isDefault()) @@ -314,7 +315,7 @@ struct SectionHeaderTable : Chunk { }; struct BBAddrMapSection : Section { - Optional> Entries; + std::optional> Entries; BBAddrMapSection() : Section(ChunkKind::BBAddrMap) {} @@ -328,7 +329,7 @@ struct BBAddrMapSection : Section { }; struct StackSizesSection : Section { - Optional> Entries; + std::optional> Entries; StackSizesSection() : Section(ChunkKind::StackSizes) {} @@ -346,7 +347,7 @@ struct StackSizesSection : Section { }; struct DynamicSection : Section { - Optional> Entries; + std::optional> Entries; DynamicSection() : Section(ChunkKind::Dynamic) {} @@ -358,7 +359,7 @@ struct DynamicSection : Section { }; struct RawContentSection : Section { - Optional Info; + std::optional Info; RawContentSection() : Section(ChunkKind::RawContent) {} @@ -367,7 +368,7 @@ struct RawContentSection : Section { } // Is used when a content is read as an array of bytes. - Optional> ContentBuf; + std::optional> ContentBuf; }; struct NoBitsSection : Section { @@ -377,7 +378,7 @@ struct NoBitsSection : Section { }; struct NoteSection : Section { - Optional> Notes; + std::optional> Notes; NoteSection() : Section(ChunkKind::Note) {} @@ -389,8 +390,8 @@ struct NoteSection : Section { }; struct HashSection : Section { - Optional> Bucket; - Optional> Chain; + std::optional> Bucket; + std::optional> Chain; std::vector> getEntries() const override { return {{"Bucket", Bucket.has_value()}, {"Chain", Chain.has_value()}}; @@ -398,8 +399,8 @@ struct HashSection : Section { // The following members are used to override section fields. // This is useful for creating invalid objects. - Optional NBucket; - Optional NChain; + std::optional NBucket; + std::optional NChain; HashSection() : Section(ChunkKind::Hash) {} @@ -410,7 +411,7 @@ struct GnuHashHeader { // The number of hash buckets. // Not used when dumping the object, but can be used to override // the real number of buckets when emiting an object from a YAML document. - Optional NBuckets; + std::optional NBuckets; // Index of the first symbol in the dynamic symbol table // included in the hash table. @@ -420,17 +421,17 @@ struct GnuHashHeader { // Not used when dumping the object, but can be used to override the real // number of words in the Bloom filter when emiting an object from a YAML // document. - Optional MaskWords; + std::optional MaskWords; // A shift constant used by the Bloom filter. llvm::yaml::Hex32 Shift2; }; struct GnuHashSection : Section { - Optional Header; - Optional> BloomFilter; - Optional> HashBuckets; - Optional> HashValues; + std::optional Header; + std::optional> BloomFilter; + std::optional> HashBuckets; + std::optional> HashValues; GnuHashSection() : Section(ChunkKind::GnuHash) {} @@ -458,8 +459,8 @@ struct VerneedEntry { }; struct VerneedSection : Section { - Optional> VerneedV; - Optional Info; + std::optional> VerneedV; + std::optional Info; VerneedSection() : Section(ChunkKind::Verneed) {} @@ -473,7 +474,7 @@ struct VerneedSection : Section { }; struct AddrsigSection : Section { - Optional> Symbols; + std::optional> Symbols; AddrsigSection() : Section(ChunkKind::Addrsig) {} @@ -490,7 +491,7 @@ struct LinkerOption { }; struct LinkerOptionsSection : Section { - Optional> Options; + std::optional> Options; LinkerOptionsSection() : Section(ChunkKind::LinkerOptions) {} @@ -504,7 +505,7 @@ struct LinkerOptionsSection : Section { }; struct DependentLibrariesSection : Section { - Optional> Libs; + std::optional> Libs; DependentLibrariesSection() : Section(ChunkKind::DependentLibraries) {} @@ -524,7 +525,7 @@ struct CallGraphEntryWeight { }; struct CallGraphProfileSection : Section { - Optional> Entries; + std::optional> Entries; CallGraphProfileSection() : Section(ChunkKind::CallGraphProfile) {} @@ -538,7 +539,7 @@ struct CallGraphProfileSection : Section { }; struct SymverSection : Section { - Optional> Entries; + std::optional> Entries; SymverSection() : Section(ChunkKind::Symver) {} @@ -550,16 +551,16 @@ struct SymverSection : Section { }; struct VerdefEntry { - Optional Version; - Optional Flags; - Optional VersionNdx; - Optional Hash; + std::optional Version; + std::optional Flags; + std::optional VersionNdx; + std::optional Hash; std::vector VerNames; }; struct VerdefSection : Section { - Optional> Entries; - Optional Info; + std::optional> Entries; + std::optional Info; VerdefSection() : Section(ChunkKind::Verdef) {} @@ -573,8 +574,8 @@ struct VerdefSection : Section { struct GroupSection : Section { // Members of a group contain a flag and a list of section indices // that are part of the group. - Optional> Members; - Optional Signature; /* Info */ + std::optional> Members; + std::optional Signature; /* Info */ GroupSection() : Section(ChunkKind::Group) {} @@ -589,11 +590,11 @@ struct Relocation { llvm::yaml::Hex64 Offset; YAMLIntUInt Addend; ELF_REL Type; - Optional Symbol; + std::optional Symbol; }; struct RelocationSection : Section { - Optional> Relocations; + std::optional> Relocations; StringRef RelocatableSec; /* Info */ RelocationSection() : Section(ChunkKind::Relocation) {} @@ -608,7 +609,7 @@ struct RelocationSection : Section { }; struct RelrSection : Section { - Optional> Entries; + std::optional> Entries; RelrSection() : Section(ChunkKind::Relr) {} @@ -622,7 +623,7 @@ struct RelrSection : Section { }; struct SymtabShndxSection : Section { - Optional> Entries; + std::optional> Entries; SymtabShndxSection() : Section(ChunkKind::SymtabShndxSection) {} @@ -641,7 +642,7 @@ struct ARMIndexTableEntry { }; struct ARMIndexTableSection : Section { - Optional> Entries; + std::optional> Entries; ARMIndexTableSection() : Section(ChunkKind::ARMIndexTable) {} @@ -680,12 +681,12 @@ struct ProgramHeader { ELF_PF Flags; llvm::yaml::Hex64 VAddr; llvm::yaml::Hex64 PAddr; - Optional Align; - Optional FileSize; - Optional MemSize; - Optional Offset; - Optional FirstSec; - Optional LastSec; + std::optional Align; + std::optional FileSize; + std::optional MemSize; + std::optional Offset; + std::optional FirstSec; + std::optional LastSec; // This vector contains all chunks from [FirstSec, LastSec]. std::vector Chunks; @@ -703,9 +704,9 @@ struct Object { // cleaner and nicer if we read them from the YAML as a separate // top-level key, which automatically ensures that invariants like there // being a single SHT_SYMTAB section are upheld. - Optional> Symbols; - Optional> DynamicSymbols; - Optional DWARF; + std::optional> Symbols; + std::optional> DynamicSymbols; + std::optional DWARF; std::vector
getSections() { std::vector
Ret; diff --git a/llvm/include/llvm/ObjectYAML/MachOYAML.h b/llvm/include/llvm/ObjectYAML/MachOYAML.h index 7d35766cc242..ccb81f5702d0 100644 --- a/llvm/include/llvm/ObjectYAML/MachOYAML.h +++ b/llvm/include/llvm/ObjectYAML/MachOYAML.h @@ -21,6 +21,7 @@ #include "llvm/ObjectYAML/YAML.h" #include "llvm/Support/YAMLTraits.h" #include +#include #include #include @@ -54,7 +55,7 @@ struct Section { llvm::yaml::Hex32 reserved1; llvm::yaml::Hex32 reserved2; llvm::yaml::Hex32 reserved3; - Optional content; + std::optional content; std::vector relocations; }; @@ -141,7 +142,7 @@ struct Object { std::vector LoadCommands; std::vector
Sections; LinkEditData LinkEdit; - Optional RawLinkEditSegment; + std::optional RawLinkEditSegment; DWARFYAML::Data DWARF; }; diff --git a/llvm/include/llvm/ObjectYAML/OffloadYAML.h b/llvm/include/llvm/ObjectYAML/OffloadYAML.h index fc7a8cc7e78e..95d64c6eca18 100644 --- a/llvm/include/llvm/ObjectYAML/OffloadYAML.h +++ b/llvm/include/llvm/ObjectYAML/OffloadYAML.h @@ -19,6 +19,7 @@ #include "llvm/Object/OffloadBinary.h" #include "llvm/ObjectYAML/YAML.h" #include "llvm/Support/YAMLTraits.h" +#include namespace llvm { namespace OffloadYAML { @@ -30,17 +31,17 @@ struct Binary { }; struct Member { - Optional ImageKind; - Optional OffloadKind; - Optional Flags; - Optional> StringEntries; - Optional Content; + std::optional ImageKind; + std::optional OffloadKind; + std::optional Flags; + std::optional> StringEntries; + std::optional Content; }; - Optional Version; - Optional Size; - Optional EntryOffset; - Optional EntrySize; + std::optional Version; + std::optional Size; + std::optional EntryOffset; + std::optional EntrySize; std::vector Members; }; diff --git a/llvm/include/llvm/ObjectYAML/XCOFFYAML.h b/llvm/include/llvm/ObjectYAML/XCOFFYAML.h index 39bc334e1a89..f1e821fe5fa3 100644 --- a/llvm/include/llvm/ObjectYAML/XCOFFYAML.h +++ b/llvm/include/llvm/ObjectYAML/XCOFFYAML.h @@ -14,6 +14,7 @@ #include "llvm/BinaryFormat/XCOFF.h" #include "llvm/ObjectYAML/YAML.h" +#include #include namespace llvm { @@ -30,35 +31,35 @@ struct FileHeader { }; struct AuxiliaryHeader { - Optional Magic; - Optional Version; - Optional TextStartAddr; - Optional DataStartAddr; - Optional TOCAnchorAddr; - Optional SecNumOfEntryPoint; - Optional SecNumOfText; - Optional SecNumOfData; - Optional SecNumOfTOC; - Optional SecNumOfLoader; - Optional SecNumOfBSS; - Optional MaxAlignOfText; - Optional MaxAlignOfData; - Optional ModuleType; - Optional CpuFlag; - Optional CpuType; - Optional TextPageSize; - Optional DataPageSize; - Optional StackPageSize; - Optional FlagAndTDataAlignment; - Optional TextSize; - Optional InitDataSize; - Optional BssDataSize; - Optional EntryPointAddr; - Optional MaxStackSize; - Optional MaxDataSize; - Optional SecNumOfTData; - Optional SecNumOfTBSS; - Optional Flag; + std::optional Magic; + std::optional Version; + std::optional TextStartAddr; + std::optional DataStartAddr; + std::optional TOCAnchorAddr; + std::optional SecNumOfEntryPoint; + std::optional SecNumOfText; + std::optional SecNumOfData; + std::optional SecNumOfTOC; + std::optional SecNumOfLoader; + std::optional SecNumOfBSS; + std::optional MaxAlignOfText; + std::optional MaxAlignOfData; + std::optional ModuleType; + std::optional CpuFlag; + std::optional CpuType; + std::optional TextPageSize; + std::optional DataPageSize; + std::optional StackPageSize; + std::optional FlagAndTDataAlignment; + std::optional TextSize; + std::optional InitDataSize; + std::optional BssDataSize; + std::optional EntryPointAddr; + std::optional MaxStackSize; + std::optional MaxDataSize; + std::optional SecNumOfTData; + std::optional SecNumOfTBSS; + std::optional Flag; }; struct Relocation { @@ -100,8 +101,8 @@ struct AuxSymbolEnt { }; struct FileAuxEnt : AuxSymbolEnt { - Optional FileNameOrString; - Optional FileStringType; + std::optional FileNameOrString; + std::optional FileStringType; FileAuxEnt() : AuxSymbolEnt(AuxSymbolType::AUX_FILE) {} static bool classof(const AuxSymbolEnt *S) { @@ -111,17 +112,17 @@ struct FileAuxEnt : AuxSymbolEnt { struct CsectAuxEnt : AuxSymbolEnt { // Only for XCOFF32. - Optional SectionOrLength; - Optional StabInfoIndex; - Optional StabSectNum; + std::optional SectionOrLength; + std::optional StabInfoIndex; + std::optional StabSectNum; // Only for XCOFF64. - Optional SectionOrLengthLo; - Optional SectionOrLengthHi; + std::optional SectionOrLengthLo; + std::optional SectionOrLengthHi; // Common fields for both XCOFF32 and XCOFF64. - Optional ParameterHashIndex; - Optional TypeChkSectNum; - Optional SymbolAlignmentAndType; - Optional StorageMappingClass; + std::optional ParameterHashIndex; + std::optional TypeChkSectNum; + std::optional SymbolAlignmentAndType; + std::optional StorageMappingClass; CsectAuxEnt() : AuxSymbolEnt(AuxSymbolType::AUX_CSECT) {} static bool classof(const AuxSymbolEnt *S) { @@ -130,10 +131,10 @@ struct CsectAuxEnt : AuxSymbolEnt { }; struct FunctionAuxEnt : AuxSymbolEnt { - Optional OffsetToExceptionTbl; // Only for XCOFF32. - Optional PtrToLineNum; - Optional SizeOfFunction; - Optional SymIdxOfNextBeyond; + std::optional OffsetToExceptionTbl; // Only for XCOFF32. + std::optional PtrToLineNum; + std::optional SizeOfFunction; + std::optional SymIdxOfNextBeyond; FunctionAuxEnt() : AuxSymbolEnt(AuxSymbolType::AUX_FCN) {} static bool classof(const AuxSymbolEnt *S) { @@ -142,9 +143,9 @@ struct FunctionAuxEnt : AuxSymbolEnt { }; struct ExcpetionAuxEnt : AuxSymbolEnt { - Optional OffsetToExceptionTbl; - Optional SizeOfFunction; - Optional SymIdxOfNextBeyond; + std::optional OffsetToExceptionTbl; + std::optional SizeOfFunction; + std::optional SymIdxOfNextBeyond; ExcpetionAuxEnt() : AuxSymbolEnt(AuxSymbolType::AUX_EXCEPT) {} static bool classof(const AuxSymbolEnt *S) { @@ -154,10 +155,10 @@ struct ExcpetionAuxEnt : AuxSymbolEnt { struct BlockAuxEnt : AuxSymbolEnt { // Only for XCOFF32. - Optional LineNumHi; - Optional LineNumLo; + std::optional LineNumHi; + std::optional LineNumLo; // Only for XCOFF64. - Optional LineNum; + std::optional LineNum; BlockAuxEnt() : AuxSymbolEnt(AuxSymbolType::AUX_SYM) {} static bool classof(const AuxSymbolEnt *S) { @@ -166,8 +167,8 @@ struct BlockAuxEnt : AuxSymbolEnt { }; struct SectAuxEntForDWARF : AuxSymbolEnt { - Optional LengthOfSectionPortion; - Optional NumberOfRelocEnt; + std::optional LengthOfSectionPortion; + std::optional NumberOfRelocEnt; SectAuxEntForDWARF() : AuxSymbolEnt(AuxSymbolType::AUX_SECT) {} static bool classof(const AuxSymbolEnt *S) { @@ -176,9 +177,9 @@ struct SectAuxEntForDWARF : AuxSymbolEnt { }; struct SectAuxEntForStat : AuxSymbolEnt { - Optional SectionLength; - Optional NumberOfRelocEnt; - Optional NumberOfLineNum; + std::optional SectionLength; + std::optional NumberOfRelocEnt; + std::optional NumberOfLineNum; SectAuxEntForStat() : AuxSymbolEnt(AuxSymbolType::AUX_STAT) {} static bool classof(const AuxSymbolEnt *S) { @@ -189,25 +190,25 @@ struct SectAuxEntForStat : AuxSymbolEnt { struct Symbol { StringRef SymbolName; llvm::yaml::Hex64 Value; // Symbol value; storage class-dependent. - Optional SectionName; - Optional SectionIndex; + std::optional SectionName; + std::optional SectionIndex; llvm::yaml::Hex16 Type; XCOFF::StorageClass StorageClass; - Optional NumberOfAuxEntries; + std::optional NumberOfAuxEntries; std::vector> AuxEntries; }; struct StringTable { - Optional ContentSize; // The total size of the string table. - Optional Length; // The value of the length field for the first + std::optional ContentSize; // The total size of the string table. + std::optional Length; // The value of the length field for the first // 4 bytes of the table. - Optional> Strings; - Optional RawContent; + std::optional> Strings; + std::optional RawContent; }; struct Object { FileHeader Header; - Optional AuxHeader; + std::optional AuxHeader; std::vector
Sections; std::vector Symbols; StringTable StrTbl; diff --git a/llvm/include/llvm/ProfileData/InstrProfCorrelator.h b/llvm/include/llvm/ProfileData/InstrProfCorrelator.h index 0efd4ea65bfd..3238a90c1747 100644 --- a/llvm/include/llvm/ProfileData/InstrProfCorrelator.h +++ b/llvm/include/llvm/ProfileData/InstrProfCorrelator.h @@ -17,6 +17,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/YAMLTraits.h" +#include #include namespace llvm { @@ -83,12 +84,12 @@ protected: struct Probe { std::string FunctionName; - Optional LinkageName; + std::optional LinkageName; yaml::Hex64 CFGHash; yaml::Hex64 CounterOffset; uint32_t NumCounters; - Optional FilePath; - Optional LineNumber; + std::optional FilePath; + std::optional LineNumber; }; struct CorrelationData { diff --git a/llvm/include/llvm/Remarks/BitstreamRemarkSerializer.h b/llvm/include/llvm/Remarks/BitstreamRemarkSerializer.h index a997fba481fd..f3c2c0dbb9d3 100644 --- a/llvm/include/llvm/Remarks/BitstreamRemarkSerializer.h +++ b/llvm/include/llvm/Remarks/BitstreamRemarkSerializer.h @@ -17,6 +17,7 @@ #include "llvm/Bitstream/BitstreamWriter.h" #include "llvm/Remarks/BitstreamRemarkContainer.h" #include "llvm/Remarks/RemarkSerializer.h" +#include namespace llvm { namespace remarks { @@ -107,7 +108,7 @@ struct BitstreamRemarkSerializerHelper { void emitMetaBlock(uint64_t ContainerVersion, Optional RemarkVersion, Optional StrTab = std::nullopt, - Optional Filename = std::nullopt); + std::optional Filename = std::nullopt); /// Emit a remark block. The string table is required. void emitRemarkBlock(const Remark &Remark, StringTable &StrTab); @@ -146,9 +147,9 @@ struct BitstreamRemarkSerializer : public RemarkSerializer { /// The metadata serializer associated to this remark serializer. Based on the /// container type of the current serializer, the container type of the /// metadata serializer will change. - std::unique_ptr - metaSerializer(raw_ostream &OS, - Optional ExternalFilename = std::nullopt) override; + std::unique_ptr metaSerializer( + raw_ostream &OS, + std::optional ExternalFilename = std::nullopt) override; static bool classof(const RemarkSerializer *S) { return S->SerializerFormat == Format::Bitstream; @@ -167,13 +168,13 @@ struct BitstreamMetaSerializer : public MetaSerializer { BitstreamRemarkSerializerHelper *Helper = nullptr; Optional StrTab; - Optional ExternalFilename; + std::optional ExternalFilename; /// Create a new meta serializer based on \p ContainerType. BitstreamMetaSerializer(raw_ostream &OS, BitstreamRemarkContainerType ContainerType, Optional StrTab = std::nullopt, - Optional ExternalFilename = std::nullopt) + std::optional ExternalFilename = std::nullopt) : MetaSerializer(OS), TmpHelper(std::nullopt), Helper(nullptr), StrTab(StrTab), ExternalFilename(ExternalFilename) { TmpHelper.emplace(ContainerType); @@ -184,7 +185,7 @@ struct BitstreamMetaSerializer : public MetaSerializer { BitstreamMetaSerializer(raw_ostream &OS, BitstreamRemarkSerializerHelper &Helper, Optional StrTab = std::nullopt, - Optional ExternalFilename = std::nullopt) + std::optional ExternalFilename = std::nullopt) : MetaSerializer(OS), TmpHelper(std::nullopt), Helper(&Helper), StrTab(StrTab), ExternalFilename(ExternalFilename) {} diff --git a/llvm/include/llvm/Remarks/Remark.h b/llvm/include/llvm/Remarks/Remark.h index 160e8dc8db70..e1f9d33f0b57 100644 --- a/llvm/include/llvm/Remarks/Remark.h +++ b/llvm/include/llvm/Remarks/Remark.h @@ -18,6 +18,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/CBindingWrapping.h" +#include #include namespace llvm { @@ -44,7 +45,7 @@ struct Argument { // FIXME: We might want to be able to store other types than strings here. StringRef Val; // If set, the debug location corresponding to the value. - Optional Loc; + std::optional Loc; }; // Create wrappers for C Binding types (see CBindingWrapping.h). @@ -80,11 +81,11 @@ struct Remark { StringRef FunctionName; /// The location in the source file of the remark. - Optional Loc; + std::optional Loc; /// If profile information is available, this is the number of times the /// corresponding code was executed in a profile instrumentation run. - Optional Hotness; + std::optional Hotness; /// Arguments collected via the streaming interface. SmallVector Args; @@ -112,7 +113,7 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Remark, LLVMRemarkEntryRef) /// Comparison operators for Remark objects and dependent objects. template -bool operator<(const Optional &LHS, const Optional &RHS) { +bool operator<(const std::optional &LHS, const std::optional &RHS) { // Sorting based on optionals should result in all `None` entries to appear // before the valid entries. For example, remarks with no debug location will // appear first. diff --git a/llvm/include/llvm/Remarks/RemarkSerializer.h b/llvm/include/llvm/Remarks/RemarkSerializer.h index 1ca45300b4ee..f73135f4fbd3 100644 --- a/llvm/include/llvm/Remarks/RemarkSerializer.h +++ b/llvm/include/llvm/Remarks/RemarkSerializer.h @@ -15,6 +15,7 @@ #include "llvm/Remarks/RemarkFormat.h" #include "llvm/Remarks/RemarkStringTable.h" +#include namespace llvm { @@ -47,7 +48,7 @@ struct RemarkSerializer { SerializerMode Mode; /// The string table containing all the unique strings used in the output. /// The table can be serialized to be consumed after the compilation. - Optional StrTab; + std::optional StrTab; RemarkSerializer(Format SerializerFormat, raw_ostream &OS, SerializerMode Mode) @@ -60,7 +61,7 @@ struct RemarkSerializer { /// Return the corresponding metadata serializer. virtual std::unique_ptr metaSerializer(raw_ostream &OS, - Optional ExternalFilename = std::nullopt) = 0; + std::optional ExternalFilename = std::nullopt) = 0; }; /// This is the base class for a remark metadata serializer. diff --git a/llvm/include/llvm/Remarks/YAMLRemarkSerializer.h b/llvm/include/llvm/Remarks/YAMLRemarkSerializer.h index 14e14a7ec632..d2a1db5791ae 100644 --- a/llvm/include/llvm/Remarks/YAMLRemarkSerializer.h +++ b/llvm/include/llvm/Remarks/YAMLRemarkSerializer.h @@ -15,6 +15,7 @@ #include "llvm/Remarks/RemarkSerializer.h" #include "llvm/Support/YAMLTraits.h" +#include namespace llvm { namespace remarks { @@ -35,12 +36,12 @@ struct YAMLRemarkSerializer : public RemarkSerializer { yaml::Output YAMLOutput; YAMLRemarkSerializer(raw_ostream &OS, SerializerMode Mode, - Optional StrTab = std::nullopt); + std::optional StrTab = std::nullopt); void emit(const Remark &Remark) override; - std::unique_ptr - metaSerializer(raw_ostream &OS, - Optional ExternalFilename = std::nullopt) override; + std::unique_ptr metaSerializer( + raw_ostream &OS, + std::optional ExternalFilename = std::nullopt) override; static bool classof(const RemarkSerializer *S) { return S->SerializerFormat == Format::YAML; @@ -49,13 +50,13 @@ struct YAMLRemarkSerializer : public RemarkSerializer { protected: YAMLRemarkSerializer(Format SerializerFormat, raw_ostream &OS, SerializerMode Mode, - Optional StrTab = std::nullopt); + std::optional StrTab = std::nullopt); }; struct YAMLMetaSerializer : public MetaSerializer { - Optional ExternalFilename; + std::optional ExternalFilename; - YAMLMetaSerializer(raw_ostream &OS, Optional ExternalFilename) + YAMLMetaSerializer(raw_ostream &OS, std::optional ExternalFilename) : MetaSerializer(OS), ExternalFilename(ExternalFilename) {} void emit() override; @@ -81,9 +82,9 @@ struct YAMLStrTabRemarkSerializer : public YAMLRemarkSerializer { /// Override to emit the metadata if necessary. void emit(const Remark &Remark) override; - std::unique_ptr - metaSerializer(raw_ostream &OS, - Optional ExternalFilename = std::nullopt) override; + std::unique_ptr metaSerializer( + raw_ostream &OS, + std::optional ExternalFilename = std::nullopt) override; static bool classof(const RemarkSerializer *S) { return S->SerializerFormat == Format::YAMLStrTab; @@ -95,7 +96,7 @@ struct YAMLStrTabMetaSerializer : public YAMLMetaSerializer { const StringTable &StrTab; YAMLStrTabMetaSerializer(raw_ostream &OS, - Optional ExternalFilename, + std::optional ExternalFilename, const StringTable &StrTab) : YAMLMetaSerializer(OS, ExternalFilename), StrTab(StrTab) {} diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h index cb0588a7203b..4eff55f07ed7 100644 --- a/llvm/include/llvm/Support/YAMLTraits.h +++ b/llvm/include/llvm/Support/YAMLTraits.h @@ -10,7 +10,6 @@ #define LLVM_SUPPORT_YAMLTRAITS_H #include "llvm/ADT/BitVector.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" @@ -27,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -904,9 +904,10 @@ public: } template - void mapOptionalWithContext(const char *Key, Optional &Val, Context &Ctx) { - this->processKeyWithDefault(Key, Val, Optional(), /*Required=*/false, - Ctx); + void mapOptionalWithContext(const char *Key, std::optional &Val, + Context &Ctx) { + this->processKeyWithDefault(Key, Val, std::optional(), + /*Required=*/false, Ctx); } template @@ -926,9 +927,9 @@ public: private: template - void processKeyWithDefault(const char *Key, Optional &Val, - const Optional &DefaultValue, bool Required, - Context &Ctx); + void processKeyWithDefault(const char *Key, std::optional &Val, + const std::optional &DefaultValue, + bool Required, Context &Ctx); template void processKeyWithDefault(const char *Key, T &Val, const T &DefaultValue, @@ -1665,10 +1666,10 @@ private: }; template -void IO::processKeyWithDefault(const char *Key, Optional &Val, - const Optional &DefaultValue, bool Required, - Context &Ctx) { - assert(!DefaultValue && "Optional shouldn't have a value!"); +void IO::processKeyWithDefault(const char *Key, std::optional &Val, + const std::optional &DefaultValue, + bool Required, Context &Ctx) { + assert(!DefaultValue && "std::optional shouldn't have a value!"); void *SaveInfo; bool UseDefault = true; const bool sameAsDefault = outputting() && !Val; @@ -1677,13 +1678,14 @@ void IO::processKeyWithDefault(const char *Key, Optional &Val, if (Val && this->preflightKey(Key, Required, sameAsDefault, UseDefault, SaveInfo)) { - // When reading an Optional key from a YAML description, we allow the - // special "" value, which can be used to specify that no value was - // requested, i.e. the DefaultValue will be assigned. The DefaultValue is - // usually None. + // When reading an std::optional key from a YAML description, we allow + // the special "" value, which can be used to specify that no value + // was requested, i.e. the DefaultValue will be assigned. The DefaultValue + // is usually None. bool IsNone = false; if (!outputting()) - if (const auto *Node = dyn_cast(((Input *)this)->getCurrentNode())) + if (const auto *Node = + dyn_cast(((Input *)this)->getCurrentNode())) // We use rtrim to ignore possible white spaces that might exist when a // comment is present on the same line. IsNone = Node->getRawValue().rtrim(' ') == ""; diff --git a/llvm/lib/Analysis/BlockFrequencyInfo.cpp b/llvm/lib/Analysis/BlockFrequencyInfo.cpp index c21c46b2f40c..923b24e4d25b 100644 --- a/llvm/lib/Analysis/BlockFrequencyInfo.cpp +++ b/llvm/lib/Analysis/BlockFrequencyInfo.cpp @@ -26,6 +26,7 @@ #include "llvm/Support/GraphWriter.h" #include "llvm/Support/raw_ostream.h" #include +#include #include using namespace llvm; @@ -204,7 +205,7 @@ BlockFrequency BlockFrequencyInfo::getBlockFreq(const BasicBlock *BB) const { return BFI ? BFI->getBlockFreq(BB) : 0; } -Optional +std::optional BlockFrequencyInfo::getBlockProfileCount(const BasicBlock *BB, bool AllowSynthetic) const { if (!BFI) @@ -213,7 +214,7 @@ BlockFrequencyInfo::getBlockProfileCount(const BasicBlock *BB, return BFI->getBlockProfileCount(*getFunction(), BB, AllowSynthetic); } -Optional +std::optional BlockFrequencyInfo::getProfileCountFromFreq(uint64_t Freq) const { if (!BFI) return std::nullopt; diff --git a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp index be4a602076b2..ab0930ff7636 100644 --- a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp +++ b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -585,7 +586,7 @@ BlockFrequencyInfoImplBase::getBlockFreq(const BlockNode &Node) const { return Freqs[Node.Index].Integer; } -Optional +std::optional BlockFrequencyInfoImplBase::getBlockProfileCount(const Function &F, const BlockNode &Node, bool AllowSynthetic) const { @@ -593,7 +594,7 @@ BlockFrequencyInfoImplBase::getBlockProfileCount(const Function &F, AllowSynthetic); } -Optional +std::optional BlockFrequencyInfoImplBase::getProfileCountFromFreq(const Function &F, uint64_t Freq, bool AllowSynthetic) const { diff --git a/llvm/lib/Analysis/OptimizationRemarkEmitter.cpp b/llvm/lib/Analysis/OptimizationRemarkEmitter.cpp index d4d13b0b22ff..95d55ea44dbf 100644 --- a/llvm/lib/Analysis/OptimizationRemarkEmitter.cpp +++ b/llvm/lib/Analysis/OptimizationRemarkEmitter.cpp @@ -20,6 +20,7 @@ #include "llvm/IR/Dominators.h" #include "llvm/IR/LLVMContext.h" #include "llvm/InitializePasses.h" +#include using namespace llvm; @@ -60,7 +61,8 @@ bool OptimizationRemarkEmitter::invalidate( return false; } -Optional OptimizationRemarkEmitter::computeHotness(const Value *V) { +std::optional +OptimizationRemarkEmitter::computeHotness(const Value *V) { if (!BFI) return std::nullopt; diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp index f48698a0e54f..ea77b40b9a7c 100644 --- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp +++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp @@ -20,6 +20,7 @@ #include "llvm/InitializePasses.h" #include "llvm/ProfileData/ProfileCommon.h" #include "llvm/Support/CommandLine.h" +#include using namespace llvm; // Knobs for profile summary based thresholds. @@ -75,7 +76,7 @@ void ProfileSummaryInfo::refresh() { computeThresholds(); } -Optional ProfileSummaryInfo::getProfileCount( +std::optional ProfileSummaryInfo::getProfileCount( const CallBase &Call, BlockFrequencyInfo *BFI, bool AllowSynthetic) const { assert((isa(Call) || isa(Call)) && "We can only get profile count for call/invoke instruction."); diff --git a/llvm/lib/CodeGen/MBFIWrapper.cpp b/llvm/lib/CodeGen/MBFIWrapper.cpp index efebb18c9908..5b388be27839 100644 --- a/llvm/lib/CodeGen/MBFIWrapper.cpp +++ b/llvm/lib/CodeGen/MBFIWrapper.cpp @@ -11,9 +11,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ADT/Optional.h" #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" #include "llvm/CodeGen/MBFIWrapper.h" +#include using namespace llvm; @@ -31,7 +31,7 @@ void MBFIWrapper::setBlockFreq(const MachineBasicBlock *MBB, MergedBBFreq[MBB] = F; } -Optional +std::optional MBFIWrapper::getBlockProfileCount(const MachineBasicBlock *MBB) const { auto I = MergedBBFreq.find(MBB); diff --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp index afe0786bc1ec..86dd3e92e230 100644 --- a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp +++ b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp @@ -23,6 +23,7 @@ #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/GraphWriter.h" +#include #include using namespace llvm; @@ -231,7 +232,7 @@ MachineBlockFrequencyInfo::getBlockFreq(const MachineBasicBlock *MBB) const { return MBFI ? MBFI->getBlockFreq(MBB) : 0; } -Optional MachineBlockFrequencyInfo::getBlockProfileCount( +std::optional MachineBlockFrequencyInfo::getBlockProfileCount( const MachineBasicBlock *MBB) const { if (!MBFI) return std::nullopt; @@ -240,7 +241,7 @@ Optional MachineBlockFrequencyInfo::getBlockProfileCount( return MBFI->getBlockProfileCount(F, MBB); } -Optional +std::optional MachineBlockFrequencyInfo::getProfileCountFromFreq(uint64_t Freq) const { if (!MBFI) return std::nullopt; diff --git a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp index 29caf7204c42..5d8139b3ee64 100644 --- a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp +++ b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp @@ -35,6 +35,7 @@ #include "llvm/IR/Function.h" #include "llvm/InitializePasses.h" #include "llvm/Support/CommandLine.h" +#include using namespace llvm; @@ -157,7 +158,7 @@ setDescendantEHBlocksCold(SmallVectorImpl &EHBlocks, static bool isColdBlock(const MachineBasicBlock &MBB, const MachineBlockFrequencyInfo *MBFI, ProfileSummaryInfo *PSI) { - Optional Count = MBFI->getBlockProfileCount(&MBB); + std::optional Count = MBFI->getBlockProfileCount(&MBB); if (!Count) return true; diff --git a/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp b/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp index 4dda1c4fbf52..1c31eba909e7 100644 --- a/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp +++ b/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp @@ -18,6 +18,7 @@ #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/LLVMContext.h" #include "llvm/InitializePasses.h" +#include using namespace llvm; @@ -30,7 +31,7 @@ DiagnosticInfoMIROptimization::MachineArgument::MachineArgument( /*SkipDebugLoc=*/true); } -Optional +std::optional MachineOptimizationRemarkEmitter::computeHotness(const MachineBasicBlock &MBB) { if (!MBFI) return std::nullopt; diff --git a/llvm/lib/IR/LLVMRemarkStreamer.cpp b/llvm/lib/IR/LLVMRemarkStreamer.cpp index 023894d09495..8fbc33328de8 100644 --- a/llvm/lib/IR/LLVMRemarkStreamer.cpp +++ b/llvm/lib/IR/LLVMRemarkStreamer.cpp @@ -18,6 +18,7 @@ #include "llvm/Remarks/RemarkStreamer.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/ToolOutputFile.h" +#include using namespace llvm; @@ -45,7 +46,7 @@ static remarks::Type toRemarkType(enum DiagnosticKind Kind) { } /// DiagnosticLocation -> remarks::RemarkLocation. -static Optional +static std::optional toRemarkLocation(const DiagnosticLocation &DL) { if (!DL.isValid()) return std::nullopt; diff --git a/llvm/lib/InterfaceStub/IFSHandler.cpp b/llvm/lib/InterfaceStub/IFSHandler.cpp index 4edaeb74d6a7..c8e9c11bc3a6 100644 --- a/llvm/lib/InterfaceStub/IFSHandler.cpp +++ b/llvm/lib/InterfaceStub/IFSHandler.cpp @@ -18,6 +18,7 @@ #include "llvm/Support/LineIterator.h" #include "llvm/Support/YAMLTraits.h" #include +#include using namespace llvm; using namespace llvm::ifs; @@ -216,10 +217,11 @@ Error ifs::writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub) { return Error::success(); } -Error ifs::overrideIFSTarget(IFSStub &Stub, Optional OverrideArch, - Optional OverrideEndianness, - Optional OverrideBitWidth, - Optional OverrideTriple) { +Error ifs::overrideIFSTarget( + IFSStub &Stub, std::optional OverrideArch, + std::optional OverrideEndianness, + std::optional OverrideBitWidth, + std::optional OverrideTriple) { std::error_code OverrideEC(1, std::generic_category()); if (OverrideArch) { if (Stub.Target.Arch && Stub.Target.Arch.value() != OverrideArch.value()) { diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp index f6e716b5a875..a57da9b3287d 100644 --- a/llvm/lib/ObjectYAML/COFFEmitter.cpp +++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp @@ -25,6 +25,7 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" +#include #include using namespace llvm; @@ -454,7 +455,7 @@ static bool writeCOFF(COFFParser &CP, raw_ostream &OS) { } for (uint32_t I = 0; I < CP.Obj.OptionalHeader->Header.NumberOfRvaAndSize; ++I) { - const Optional *DataDirectories = + const std::optional *DataDirectories = CP.Obj.OptionalHeader->DataDirectories; uint32_t NumDataDir = std::size(CP.Obj.OptionalHeader->DataDirectories); if (I >= NumDataDir || !DataDirectories[I]) { diff --git a/llvm/lib/ObjectYAML/DWARFEmitter.cpp b/llvm/lib/ObjectYAML/DWARFEmitter.cpp index c0e2cdd54f07..f25c016e9aa3 100644 --- a/llvm/lib/ObjectYAML/DWARFEmitter.cpp +++ b/llvm/lib/ObjectYAML/DWARFEmitter.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -552,7 +553,7 @@ static void writeLineTableOpcode(const DWARFYAML::LineTableOpcode &Op, } static std::vector -getStandardOpcodeLengths(uint16_t Version, Optional OpcodeBase) { +getStandardOpcodeLengths(uint16_t Version, std::optional OpcodeBase) { // If the opcode_base field isn't specified, we returns the // standard_opcode_lengths array according to the version by default. std::vector StandardOpcodeLengths{0, 1, 1, 1, 1, 0, diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index 88d430f89312..53fee6af0c14 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -31,6 +31,7 @@ #include "llvm/Support/WithColor.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include using namespace llvm; @@ -314,7 +315,7 @@ template class ELFState { BumpPtrAllocator StringAlloc; uint64_t alignToOffset(ContiguousBlobAccumulator &CBA, uint64_t Align, - llvm::Optional Offset); + std::optional Offset); uint64_t getSectionNameOffset(StringRef Name); @@ -715,8 +716,8 @@ uint64_t ELFState::getSectionNameOffset(StringRef Name) { } static uint64_t writeContent(ContiguousBlobAccumulator &CBA, - const Optional &Content, - const Optional &Size) { + const std::optional &Content, + const std::optional &Size) { size_t ContentSize = 0; if (Content) { CBA.writeAsBinary(*Content); @@ -1453,7 +1454,7 @@ void ELFState::writeSectionContent( template uint64_t ELFState::alignToOffset(ContiguousBlobAccumulator &CBA, uint64_t Align, - llvm::Optional Offset) { + std::optional Offset) { uint64_t CurrentOffset = CBA.getOffset(); uint64_t AlignedOffset; diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index 504a6837a1a1..5513ce460dbc 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -23,6 +23,7 @@ #include "llvm/Support/WithColor.h" #include #include +#include namespace llvm { @@ -1160,7 +1161,7 @@ namespace { struct NormalizedOther { NormalizedOther(IO &IO) : YamlIO(IO) {} - NormalizedOther(IO &IO, Optional Original) : YamlIO(IO) { + NormalizedOther(IO &IO, std::optional Original) : YamlIO(IO) { assert(Original && "This constructor is only used for outputting YAML and " "assumes a non-empty Original"); std::vector Ret; @@ -1200,7 +1201,7 @@ struct NormalizedOther { return 0; } - Optional denormalize(IO &) { + std::optional denormalize(IO &) { if (!Other) return std::nullopt; uint8_t Ret = 0; @@ -1248,7 +1249,7 @@ struct NormalizedOther { } IO &YamlIO; - Optional> Other; + std::optional> Other; std::string UnknownFlagsHolder; }; @@ -1298,11 +1299,11 @@ void MappingTraits::mapping(IO &IO, ELFYAML::Symbol &Symbol) { // Symbol's Other field is a bit special. It is usually a field that // represents st_other and holds the symbol visibility. However, on some - // platforms, it can contain bit fields and regular values, or even sometimes a - // crazy mix of them (see comments for NormalizedOther). Because of this, we + // platforms, it can contain bit fields and regular values, or even sometimes + // a crazy mix of them (see comments for NormalizedOther). Because of this, we // need special handling. - MappingNormalization> Keys(IO, - Symbol.Other); + MappingNormalization> Keys( + IO, Symbol.Other); IO.mapOptional("Other", Keys->Other); } diff --git a/llvm/lib/ProfileData/InstrProfCorrelator.cpp b/llvm/lib/ProfileData/InstrProfCorrelator.cpp index 38ae5d8f821c..a727ff7cf6ef 100644 --- a/llvm/lib/ProfileData/InstrProfCorrelator.cpp +++ b/llvm/lib/ProfileData/InstrProfCorrelator.cpp @@ -16,6 +16,7 @@ #include "llvm/DebugInfo/DWARF/DWARFUnit.h" #include "llvm/Object/MachO.h" #include "llvm/Support/Debug.h" +#include #define DEBUG_TYPE "correlator" diff --git a/llvm/lib/Remarks/BitstreamRemarkSerializer.cpp b/llvm/lib/Remarks/BitstreamRemarkSerializer.cpp index 91aaef11dffe..542896765d82 100644 --- a/llvm/lib/Remarks/BitstreamRemarkSerializer.cpp +++ b/llvm/lib/Remarks/BitstreamRemarkSerializer.cpp @@ -13,6 +13,7 @@ #include "llvm/Remarks/BitstreamRemarkSerializer.h" #include "llvm/Remarks/Remark.h" +#include using namespace llvm; using namespace llvm::remarks; @@ -232,7 +233,7 @@ void BitstreamRemarkSerializerHelper::setupBlockInfo() { void BitstreamRemarkSerializerHelper::emitMetaBlock( uint64_t ContainerVersion, Optional RemarkVersion, - Optional StrTab, Optional Filename) { + Optional StrTab, std::optional Filename) { // Emit the meta block Bitstream.EnterSubblock(META_BLOCK_ID, 3); @@ -277,7 +278,7 @@ void BitstreamRemarkSerializerHelper::emitRemarkBlock(const Remark &Remark, R.push_back(StrTab.add(Remark.FunctionName).first); Bitstream.EmitRecordWithAbbrev(RecordRemarkHeaderAbbrevID, R); - if (const Optional &Loc = Remark.Loc) { + if (const std::optional &Loc = Remark.Loc) { R.clear(); R.push_back(RECORD_REMARK_DEBUG_LOC); R.push_back(StrTab.add(Loc->SourceFilePath).first); @@ -286,7 +287,7 @@ void BitstreamRemarkSerializerHelper::emitRemarkBlock(const Remark &Remark, Bitstream.EmitRecordWithAbbrev(RecordRemarkDebugLocAbbrevID, R); } - if (Optional Hotness = Remark.Hotness) { + if (std::optional Hotness = Remark.Hotness) { R.clear(); R.push_back(RECORD_REMARK_HOTNESS); R.push_back(*Hotness); @@ -366,7 +367,7 @@ void BitstreamRemarkSerializer::emit(const Remark &Remark) { } std::unique_ptr BitstreamRemarkSerializer::metaSerializer( - raw_ostream &OS, Optional ExternalFilename) { + raw_ostream &OS, std::optional ExternalFilename) { assert(Helper.ContainerType != BitstreamRemarkContainerType::SeparateRemarksMeta); bool IsStandalone = diff --git a/llvm/lib/Remarks/Remark.cpp b/llvm/lib/Remarks/Remark.cpp index e6b7de1a2cf5..a038f81874d1 100644 --- a/llvm/lib/Remarks/Remark.cpp +++ b/llvm/lib/Remarks/Remark.cpp @@ -13,6 +13,7 @@ #include "llvm/Remarks/Remark.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/raw_ostream.h" +#include using namespace llvm; using namespace llvm::remarks; @@ -60,7 +61,7 @@ extern "C" LLVMRemarkStringRef LLVMRemarkArgGetValue(LLVMRemarkArgRef Arg) { extern "C" LLVMRemarkDebugLocRef LLVMRemarkArgGetDebugLoc(LLVMRemarkArgRef Arg) { - if (const Optional &Loc = unwrap(Arg)->Loc) + if (const std::optional &Loc = unwrap(Arg)->Loc) return wrap(&*Loc); return nullptr; } @@ -91,13 +92,13 @@ LLVMRemarkEntryGetFunctionName(LLVMRemarkEntryRef Remark) { extern "C" LLVMRemarkDebugLocRef LLVMRemarkEntryGetDebugLoc(LLVMRemarkEntryRef Remark) { - if (const Optional &Loc = unwrap(Remark)->Loc) + if (const std::optional &Loc = unwrap(Remark)->Loc) return wrap(&*Loc); return nullptr; } extern "C" uint64_t LLVMRemarkEntryGetHotness(LLVMRemarkEntryRef Remark) { - if (const Optional &Hotness = unwrap(Remark)->Hotness) + if (const std::optional &Hotness = unwrap(Remark)->Hotness) return *Hotness; return 0; } diff --git a/llvm/lib/Remarks/YAMLRemarkParser.cpp b/llvm/lib/Remarks/YAMLRemarkParser.cpp index 6372e541104c..265371c0839a 100644 --- a/llvm/lib/Remarks/YAMLRemarkParser.cpp +++ b/llvm/lib/Remarks/YAMLRemarkParser.cpp @@ -367,7 +367,7 @@ Expected YAMLRemarkParser::parseArg(yaml::Node &Node) { std::optional KeyStr; std::optional ValueStr; - Optional Loc; + std::optional Loc; for (yaml::KeyValueNode &ArgEntry : *ArgMap) { Expected MaybeKey = parseKey(ArgEntry); diff --git a/llvm/lib/Remarks/YAMLRemarkSerializer.cpp b/llvm/lib/Remarks/YAMLRemarkSerializer.cpp index 513c7efeb442..68285c3dde1b 100644 --- a/llvm/lib/Remarks/YAMLRemarkSerializer.cpp +++ b/llvm/lib/Remarks/YAMLRemarkSerializer.cpp @@ -23,8 +23,8 @@ using namespace llvm::remarks; // unsigned or a StringRef). template static void mapRemarkHeader(yaml::IO &io, T PassName, T RemarkName, - Optional RL, T FunctionName, - Optional Hotness, + std::optional RL, T FunctionName, + std::optional Hotness, ArrayRef Args) { io.mapRequired("Pass", PassName); io.mapRequired("Name", RemarkName); @@ -158,12 +158,12 @@ template <> struct MappingTraits { LLVM_YAML_IS_SEQUENCE_VECTOR(Argument) YAMLRemarkSerializer::YAMLRemarkSerializer(raw_ostream &OS, SerializerMode Mode, - Optional StrTabIn) + std::optional StrTabIn) : YAMLRemarkSerializer(Format::YAML, OS, Mode, std::move(StrTabIn)) {} YAMLRemarkSerializer::YAMLRemarkSerializer(Format SerializerFormat, raw_ostream &OS, SerializerMode Mode, - Optional StrTabIn) + std::optional StrTabIn) : RemarkSerializer(SerializerFormat, OS, Mode), YAMLOutput(OS, reinterpret_cast(this)) { StrTab = std::move(StrTabIn); @@ -176,9 +176,8 @@ void YAMLRemarkSerializer::emit(const Remark &Remark) { YAMLOutput << R; } -std::unique_ptr -YAMLRemarkSerializer::metaSerializer(raw_ostream &OS, - Optional ExternalFilename) { +std::unique_ptr YAMLRemarkSerializer::metaSerializer( + raw_ostream &OS, std::optional ExternalFilename) { return std::make_unique(OS, ExternalFilename); } @@ -197,7 +196,7 @@ void YAMLStrTabRemarkSerializer::emit(const Remark &Remark) { } std::unique_ptr YAMLStrTabRemarkSerializer::metaSerializer( - raw_ostream &OS, Optional ExternalFilename) { + raw_ostream &OS, std::optional ExternalFilename) { assert(StrTab); return std::make_unique(OS, ExternalFilename, *StrTab); diff --git a/llvm/lib/Support/AMDGPUMetadata.cpp b/llvm/lib/Support/AMDGPUMetadata.cpp index 3d6325134d75..e24cbde38795 100644 --- a/llvm/lib/Support/AMDGPUMetadata.cpp +++ b/llvm/lib/Support/AMDGPUMetadata.cpp @@ -14,6 +14,7 @@ #include "llvm/Support/AMDGPUMetadata.h" #include "llvm/Support/YAMLTraits.h" +#include using namespace llvm::AMDGPU; using namespace llvm::AMDGPU::HSAMD; @@ -112,7 +113,7 @@ struct MappingTraits { YIO.mapRequired(Kernel::Arg::Key::ValueKind, MD.mValueKind); // Removed. Accepted for parsing compatibility, but not emitted. - Optional Unused; + std::optional Unused; YIO.mapOptional(Kernel::Arg::Key::ValueType, Unused); YIO.mapOptional(Kernel::Arg::Key::PointeeAlign, MD.mPointeeAlign, diff --git a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h index fad00e13d31c..164c9576b944 100644 --- a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h +++ b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h @@ -23,6 +23,7 @@ #include "llvm/IR/Function.h" #include "llvm/MC/MCLinkerOptimizationHint.h" #include +#include namespace llvm { @@ -132,7 +133,7 @@ class AArch64FunctionInfo final : public MachineFunctionInfo { /// redzone, and no value otherwise. /// Initialized during frame lowering, unless the function has the noredzone /// attribute, in which case it is set to false at construction. - Optional HasRedZone; + std::optional HasRedZone; /// ForwardedMustTailRegParms - A list of virtual and physical registers /// that must be forwarded to every musttail call. @@ -334,7 +335,7 @@ public: return NumLocalDynamicTLSAccesses; } - Optional hasRedZone() const { return HasRedZone; } + std::optional hasRedZone() const { return HasRedZone; } void setHasRedZone(bool s) { HasRedZone = s; } int getVarArgsStackIndex() const { return VarArgsStackIndex; } @@ -458,7 +459,7 @@ private: namespace yaml { struct AArch64FunctionInfo final : public yaml::MachineFunctionInfo { - Optional HasRedZone; + std::optional HasRedZone; AArch64FunctionInfo() = default; AArch64FunctionInfo(const llvm::AArch64FunctionInfo &MFI); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 7a9d37c1bbb8..6a57078a055b 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -1485,7 +1485,7 @@ bool GCNTargetMachine::parseMachineFunctionInfo( MFI->reserveWWMRegister(ParsedReg); } - auto parseAndCheckArgument = [&](const Optional &A, + auto parseAndCheckArgument = [&](const std::optional &A, const TargetRegisterClass &RC, ArgDescriptor &Arg, unsigned UserSGPRs, unsigned SystemSGPRs) { diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp index 7f76da65aacf..26a62317a5e5 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp @@ -22,6 +22,7 @@ #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/Function.h" #include +#include #include #define MAX_LANES 64 @@ -537,12 +538,12 @@ static yaml::StringValue regToString(Register Reg, return Dest; } -static Optional +static std::optional convertArgumentInfo(const AMDGPUFunctionArgInfo &ArgInfo, const TargetRegisterInfo &TRI) { yaml::SIArgumentInfo AI; - auto convertArg = [&](Optional &A, + auto convertArg = [&](std::optional &A, const ArgDescriptor &Arg) { if (!Arg) return false; diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h index 9ad440b0aad4..70a6009e4f5d 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h +++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h @@ -22,6 +22,7 @@ #include "llvm/CodeGen/MIRYamlMapping.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/Support/raw_ostream.h" +#include namespace llvm { @@ -90,7 +91,7 @@ struct SIArgument { StringValue RegisterName; unsigned StackOffset; }; - Optional Mask; + std::optional Mask; // Default constructor, which creates a stack argument. SIArgument() : IsRegister(false), StackOffset(0) {} @@ -153,27 +154,27 @@ template <> struct MappingTraits { }; struct SIArgumentInfo { - Optional PrivateSegmentBuffer; - Optional DispatchPtr; - Optional QueuePtr; - Optional KernargSegmentPtr; - Optional DispatchID; - Optional FlatScratchInit; - Optional PrivateSegmentSize; + std::optional PrivateSegmentBuffer; + std::optional DispatchPtr; + std::optional QueuePtr; + std::optional KernargSegmentPtr; + std::optional DispatchID; + std::optional FlatScratchInit; + std::optional PrivateSegmentSize; - Optional WorkGroupIDX; - Optional WorkGroupIDY; - Optional WorkGroupIDZ; - Optional WorkGroupInfo; - Optional LDSKernelId; - Optional PrivateSegmentWaveByteOffset; + std::optional WorkGroupIDX; + std::optional WorkGroupIDY; + std::optional WorkGroupIDZ; + std::optional WorkGroupInfo; + std::optional LDSKernelId; + std::optional PrivateSegmentWaveByteOffset; - Optional ImplicitArgPtr; - Optional ImplicitBufferPtr; + std::optional ImplicitArgPtr; + std::optional ImplicitBufferPtr; - Optional WorkItemIDX; - Optional WorkItemIDY; - Optional WorkItemIDZ; + std::optional WorkItemIDX; + std::optional WorkItemIDY; + std::optional WorkItemIDZ; }; template <> struct MappingTraits { @@ -270,9 +271,9 @@ struct SIMachineFunctionInfo final : public yaml::MachineFunctionInfo { unsigned BytesInStackArgArea = 0; bool ReturnsVoid = true; - Optional ArgInfo; + std::optional ArgInfo; SIMode Mode; - Optional ScavengeFI; + std::optional ScavengeFI; StringValue VGPRForAGPRCopy; SIMachineFunctionInfo() = default; diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp index 27107f46ed92..1c630e9ee424 100644 --- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp +++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp @@ -18,6 +18,7 @@ #include "llvm/InitializePasses.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/Transforms/Instrumentation.h" +#include using namespace llvm; @@ -73,7 +74,7 @@ static bool runCGProfilePass( continue; TargetTransformInfo &TTI = GetTTI(F); for (auto &BB : F) { - Optional BBCount = BFI.getBlockProfileCount(&BB); + std::optional BBCount = BFI.getBlockProfileCount(&BB); if (!BBCount) continue; for (auto &I : BB) { diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index 4d4674b859fe..451a0f3de7be 100644 --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -38,6 +38,7 @@ #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/ValueMapper.h" +#include #include #include @@ -1707,7 +1708,7 @@ void CHR::transformScopes(CHRScope *Scope, DenseSet &TrivialPHIs) { BasicBlock *EntryBlock = FirstRegion->getEntry(); Region *LastRegion = Scope->RegInfos[Scope->RegInfos.size() - 1].R; BasicBlock *ExitBlock = LastRegion->getExit(); - Optional ProfileCount = BFI.getBlockProfileCount(EntryBlock); + std::optional ProfileCount = BFI.getBlockProfileCount(EntryBlock); if (ExitBlock) { // Insert a trivial phi at the exit block (where the CHR hot path and the diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp index 79b6cb2c80a2..2464cd879bdd 100644 --- a/llvm/tools/dsymutil/DebugMap.cpp +++ b/llvm/tools/dsymutil/DebugMap.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,8 @@ DebugMapObject::DebugMapObject(StringRef ObjectFilename, uint8_t Type) : Filename(std::string(ObjectFilename)), Timestamp(Timestamp), Type(Type) {} -bool DebugMapObject::addSymbol(StringRef Name, Optional ObjectAddress, +bool DebugMapObject::addSymbol(StringRef Name, + std::optional ObjectAddress, uint64_t LinkedAddress, uint32_t Size) { auto InsertResult = Symbols.insert( std::make_pair(Name, SymbolMapping(ObjectAddress, LinkedAddress, Size))); @@ -277,7 +279,7 @@ MappingTraits::YamlDMO::denormalize(IO &IO) { dsymutil::DebugMapObject Res(Path, sys::toTimePoint(Timestamp), MachO::N_OSO); for (auto &Entry : Entries) { auto &Mapping = Entry.second; - Optional ObjAddress; + std::optional ObjAddress; if (Mapping.ObjectAddress) ObjAddress = *Mapping.ObjectAddress; auto AddressIt = SymbolAddresses.find(Entry.first); diff --git a/llvm/tools/dsymutil/DebugMap.h b/llvm/tools/dsymutil/DebugMap.h index e4fbaa81174b..4854f41beb54 100644 --- a/llvm/tools/dsymutil/DebugMap.h +++ b/llvm/tools/dsymutil/DebugMap.h @@ -22,7 +22,6 @@ #define LLVM_TOOLS_DSYMUTIL_DEBUGMAP_H #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" @@ -35,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -135,11 +135,11 @@ public: class DebugMapObject { public: struct SymbolMapping { - Optional ObjectAddress; + std::optional ObjectAddress; yaml::Hex64 BinaryAddress; yaml::Hex32 Size; - SymbolMapping(Optional ObjectAddr, uint64_t BinaryAddress, + SymbolMapping(std::optional ObjectAddr, uint64_t BinaryAddress, uint32_t Size) : BinaryAddress(BinaryAddress), Size(Size) { if (ObjectAddr) @@ -156,7 +156,7 @@ public: /// Adds a symbol mapping to this DebugMapObject. /// \returns false if the symbol was already registered. The request /// is discarded in this case. - bool addSymbol(StringRef SymName, Optional ObjectAddress, + bool addSymbol(StringRef SymName, std::optional ObjectAddress, uint64_t LinkedAddress, uint32_t Size); /// Lookup a symbol mapping. diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp index 26aeb3902348..2f391c54e8ca 100644 --- a/llvm/tools/dsymutil/MachODebugMapParser.cpp +++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp @@ -9,12 +9,12 @@ #include "BinaryHolder.h" #include "DebugMap.h" #include "MachOUtils.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallSet.h" #include "llvm/Object/MachO.h" #include "llvm/Support/Path.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" +#include #include namespace { @@ -59,10 +59,10 @@ private: std::vector CommonSymbols; /// Map of the currently processed object file symbol addresses. - StringMap> CurrentObjectAddresses; + StringMap> CurrentObjectAddresses; /// Lazily computed map of symbols aliased to the processed object file. - StringMap> CurrentObjectAliasMap; + StringMap> CurrentObjectAliasMap; /// If CurrentObjectAliasMap has been computed for a given address. SmallSet SeenAliasValues; diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp index d70442216324..89b495b10227 100644 --- a/llvm/tools/llvm-ifs/llvm-ifs.cpp +++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp @@ -84,14 +84,14 @@ public: struct DriverConfig { std::vector InputFilePaths; - Optional InputFormat; - Optional OutputFormat; + std::optional InputFormat; + std::optional OutputFormat; std::optional HintIfsTarget; - Optional OptTargetTriple; - Optional OverrideArch; - Optional OverrideBitWidth; - Optional OverrideEndianness; + std::optional OptTargetTriple; + std::optional OverrideArch; + std::optional OverrideBitWidth; + std::optional OverrideEndianness; bool StripIfsArch = false; bool StripIfsBitwidth = false; @@ -130,7 +130,7 @@ static std::string getTypeName(IFSSymbolType Type) { } static Expected> -readInputFile(Optional &InputFormat, StringRef FilePath) { +readInputFile(std::optional &InputFormat, StringRef FilePath) { // Read in file. ErrorOr> BufOrError = MemoryBuffer::getFileOrSTDIN(FilePath, /*IsText=*/true); @@ -306,7 +306,7 @@ static DriverConfig parseArgs(int argc, char *const *argv) { for (const opt::Arg *A : Args.filtered(OPT_INPUT)) Config.InputFilePaths.push_back(A->getValue()); if (const opt::Arg *A = Args.getLastArg(OPT_input_format_EQ)) { - Config.InputFormat = StringSwitch>(A->getValue()) + Config.InputFormat = StringSwitch>(A->getValue()) .Case("IFS", FileFormat::IFS) .Case("ELF", FileFormat::ELF) .Default(std::nullopt); @@ -319,7 +319,7 @@ static DriverConfig parseArgs(int argc, char *const *argv) { " option: Cannot find option named '" + OptionName + "'!"); }; if (const opt::Arg *A = Args.getLastArg(OPT_output_format_EQ)) { - Config.OutputFormat = StringSwitch>(A->getValue()) + Config.OutputFormat = StringSwitch>(A->getValue()) .Case("IFS", FileFormat::IFS) .Case("ELF", FileFormat::ELF) .Case("TBD", FileFormat::TBD) @@ -341,7 +341,7 @@ static DriverConfig parseArgs(int argc, char *const *argv) { } if (const opt::Arg *A = Args.getLastArg(OPT_endianness_EQ)) { Config.OverrideEndianness = - StringSwitch>(A->getValue()) + StringSwitch>(A->getValue()) .Case("little", IFSEndiannessType::Little) .Case("big", IFSEndiannessType::Big) .Default(std::nullopt); diff --git a/llvm/tools/llvm-opt-report/OptReport.cpp b/llvm/tools/llvm-opt-report/OptReport.cpp index e0388632ba55..cc7e60ba1378 100644 --- a/llvm/tools/llvm-opt-report/OptReport.cpp +++ b/llvm/tools/llvm-opt-report/OptReport.cpp @@ -32,6 +32,7 @@ #include "llvm/Support/raw_ostream.h" #include #include +#include #include using namespace llvm; @@ -208,7 +209,7 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) { Arg.Val.getAsInteger(10, UnrollCount); } - const Optional &Loc = Remark.Loc; + const std::optional &Loc = Remark.Loc; if (!Loc) continue; diff --git a/llvm/tools/llvm-pdbutil/PdbYaml.h b/llvm/tools/llvm-pdbutil/PdbYaml.h index c335eef2f1c5..4382e91e2097 100644 --- a/llvm/tools/llvm-pdbutil/PdbYaml.h +++ b/llvm/tools/llvm-pdbutil/PdbYaml.h @@ -11,7 +11,6 @@ #include "OutputStyle.h" -#include "llvm/ADT/Optional.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/MSF/MSFCommon.h" @@ -24,6 +23,7 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/YAMLTraits.h" +#include #include namespace llvm { @@ -67,7 +67,7 @@ struct PdbDbiModuleInfo { StringRef Mod; std::vector SourceFiles; std::vector Subsections; - Optional Modi; + std::optional Modi; }; struct PdbDbiStream { @@ -94,16 +94,16 @@ struct PdbPublicsStream { struct PdbObject { explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {} - Optional Headers; - Optional> StreamSizes; - Optional> StreamMap; - Optional PdbStream; - Optional DbiStream; - Optional TpiStream; - Optional IpiStream; - Optional PublicsStream; + std::optional Headers; + std::optional> StreamSizes; + std::optional> StreamMap; + std::optional PdbStream; + std::optional DbiStream; + std::optional TpiStream; + std::optional IpiStream; + std::optional PublicsStream; - Optional> StringTable; + std::optional> StringTable; BumpPtrAllocator &Allocator; }; diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp index 347fb3dbf023..1147e97cc062 100644 --- a/llvm/tools/obj2yaml/dwarf2yaml.cpp +++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp @@ -18,6 +18,7 @@ #include "llvm/ObjectYAML/DWARFYAML.h" #include +#include using namespace llvm; @@ -165,7 +166,7 @@ Error dumpDebugRanges(DWARFContext &DCtx, DWARFYAML::Data &Y) { return ErrorSuccess(); } -static Optional +static std::optional dumpPubSection(const DWARFContext &DCtx, const DWARFSection &Section, bool IsGNUStyle) { DWARFYAML::PubSection Y; diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp index f64e479d51a7..0c4e841c4746 100644 --- a/llvm/tools/obj2yaml/elf2yaml.cpp +++ b/llvm/tools/obj2yaml/elf2yaml.cpp @@ -54,11 +54,11 @@ class ELFDumper { Expected> dumpProgramHeaders(ArrayRef> Sections); - Optional + std::optional dumpDWARFSections(std::vector> &Sections); Error dumpSymbols(const Elf_Shdr *Symtab, - Optional> &Symbols); + std::optional> &Symbols); Error dumpSymbol(const Elf_Sym *Sym, const Elf_Shdr *SymTab, StringRef StrTable, ELFYAML::Symbol &S); Expected>> dumpSections(); @@ -102,7 +102,7 @@ class ELFDumper { dumpPlaceholderSection(const Elf_Shdr *Shdr); bool shouldPrintSection(const ELFYAML::Section &S, const Elf_Shdr &SHdr, - Optional DWARF); + std::optional DWARF); public: ELFDumper(const object::ELFFile &O, std::unique_ptr DCtx); @@ -183,7 +183,7 @@ ELFDumper::getUniquedSymbolName(const Elf_Sym *Sym, StringRef StrTable, template bool ELFDumper::shouldPrintSection(const ELFYAML::Section &S, const Elf_Shdr &SHdr, - Optional DWARF) { + std::optional DWARF) { // We only print the SHT_NULL section at index 0 when it // has at least one non-null field, because yaml2obj // normally creates the zero section at index 0 implicitly. @@ -511,7 +511,7 @@ ELFDumper::dumpProgramHeaders( } template -Optional ELFDumper::dumpDWARFSections( +std::optional ELFDumper::dumpDWARFSections( std::vector> &Sections) { DWARFYAML::Data DWARF; for (std::unique_ptr &C : Sections) { @@ -674,7 +674,8 @@ ELFDumper::dumpSections() { template Error ELFDumper::dumpSymbols( - const Elf_Shdr *Symtab, Optional> &Symbols) { + const Elf_Shdr *Symtab, + std::optional> &Symbols) { if (!Symtab) return Error::success(); diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp index 37aa3a96601d..ba1f54d2ecf7 100644 --- a/llvm/tools/yaml2obj/yaml2obj.cpp +++ b/llvm/tools/yaml2obj/yaml2obj.cpp @@ -60,8 +60,8 @@ cl::opt OutputFilename("o", cl::desc("Output filename"), cl::Prefix, cl::cat(Cat)); } // namespace -static Optional preprocess(StringRef Buf, - yaml::ErrorHandler ErrHandler) { +static std::optional preprocess(StringRef Buf, + yaml::ErrorHandler ErrHandler) { DenseMap Defines; for (StringRef Define : D) { StringRef Macro, Definition; @@ -134,7 +134,8 @@ int main(int argc, char **argv) { if (!Buf) return 1; - Optional Buffer = preprocess(Buf.get()->getBuffer(), ErrHandler); + std::optional Buffer = + preprocess(Buf.get()->getBuffer(), ErrHandler); if (!Buffer) return 1; diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp index bede0513a551..f9b83895c371 100644 --- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp +++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/YAMLTraits.h" +#include using namespace mlir; @@ -52,7 +53,7 @@ struct LinalgYAMLContext { struct LinalgOpMetadata { std::string name; std::string cppClassName; - Optional doc; + std::optional doc; SmallVector implements; SmallVector defines; }; @@ -76,11 +77,11 @@ enum class LinalgOperandDefKind { struct LinalgOperandDef { std::string name; LinalgOperandDefKind kind; - Optional typeVar; - Optional shapeMap; - Optional indexAttrMap; - Optional> defaultIndices; - Optional defaultFn; + std::optional typeVar; + std::optional shapeMap; + std::optional indexAttrMap; + std::optional> defaultIndices; + std::optional defaultFn; }; enum class LinalgIteratorTypeDef { @@ -89,7 +90,7 @@ enum class LinalgIteratorTypeDef { }; struct LinalgIndexingMapsConfig { - Optional> staticIndexingMaps; + std::optional> staticIndexingMaps; }; struct ScalarExpression; @@ -98,19 +99,19 @@ enum class ScalarFnKind { Unary, Binary, Type }; struct ScalarFn { ScalarFnKind kind; - Optional fnName; - Optional attrName; - Optional typeVar; + std::optional fnName; + std::optional attrName; + std::optional typeVar; // NOTE: This must be of arity 1, but to break the self-referential cycle, // we use a heap allocated vector. std::vector operands; }; struct ScalarExpression { - Optional arg; - Optional constant; - Optional index; - Optional scalarFn; + std::optional arg; + std::optional constant; + std::optional index; + std::optional scalarFn; }; struct ScalarAssign { @@ -126,8 +127,8 @@ struct LinalgStructuredOpConfig { }; struct LinalgOpConfig { - Optional metadata; - Optional structuredOp; + std::optional metadata; + std::optional structuredOp; }; } // namespace