diff options
author | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2022-12-05 15:19:30 -0800 |
---|---|---|
committer | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2022-12-06 12:49:32 -0800 |
commit | c589730ad5286fc784b8aacf2f0214149603f312 (patch) | |
tree | 7ef2fd8ada8da288c13d257707715f3ba79a9274 /llvm/tools | |
parent | 48634b3b935fd0bb325c08fce6313fadcdcb6f86 (diff) | |
download | llvm-c589730ad5286fc784b8aacf2f0214149603f312.zip llvm-c589730ad5286fc784b8aacf2f0214149603f312.tar.gz llvm-c589730ad5286fc784b8aacf2f0214149603f312.tar.bz2 |
[YAML] Convert Optional to std::optional
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/dsymutil/DebugMap.cpp | 6 | ||||
-rw-r--r-- | llvm/tools/dsymutil/DebugMap.h | 8 | ||||
-rw-r--r-- | llvm/tools/dsymutil/MachODebugMapParser.cpp | 6 | ||||
-rw-r--r-- | llvm/tools/llvm-ifs/llvm-ifs.cpp | 20 | ||||
-rw-r--r-- | llvm/tools/llvm-opt-report/OptReport.cpp | 3 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbutil/PdbYaml.h | 22 | ||||
-rw-r--r-- | llvm/tools/obj2yaml/dwarf2yaml.cpp | 3 | ||||
-rw-r--r-- | llvm/tools/obj2yaml/elf2yaml.cpp | 13 | ||||
-rw-r--r-- | llvm/tools/yaml2obj/yaml2obj.cpp | 7 |
9 files changed, 47 insertions, 41 deletions
diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp index 79b6cb2..2464cd8 100644 --- a/llvm/tools/dsymutil/DebugMap.cpp +++ b/llvm/tools/dsymutil/DebugMap.cpp @@ -28,6 +28,7 @@ #include <cinttypes> #include <cstdint> #include <memory> +#include <optional> #include <string> #include <utility> #include <vector> @@ -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<uint64_t> ObjectAddress, +bool DebugMapObject::addSymbol(StringRef Name, + std::optional<uint64_t> ObjectAddress, uint64_t LinkedAddress, uint32_t Size) { auto InsertResult = Symbols.insert( std::make_pair(Name, SymbolMapping(ObjectAddress, LinkedAddress, Size))); @@ -277,7 +279,7 @@ MappingTraits<dsymutil::DebugMapObject>::YamlDMO::denormalize(IO &IO) { dsymutil::DebugMapObject Res(Path, sys::toTimePoint(Timestamp), MachO::N_OSO); for (auto &Entry : Entries) { auto &Mapping = Entry.second; - Optional<uint64_t> ObjAddress; + std::optional<uint64_t> 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 e4fbaa8..4854f41 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 <cstddef> #include <cstdint> #include <memory> +#include <optional> #include <string> #include <utility> #include <vector> @@ -135,11 +135,11 @@ public: class DebugMapObject { public: struct SymbolMapping { - Optional<yaml::Hex64> ObjectAddress; + std::optional<yaml::Hex64> ObjectAddress; yaml::Hex64 BinaryAddress; yaml::Hex32 Size; - SymbolMapping(Optional<uint64_t> ObjectAddr, uint64_t BinaryAddress, + SymbolMapping(std::optional<uint64_t> 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<uint64_t> ObjectAddress, + bool addSymbol(StringRef SymName, std::optional<uint64_t> 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 26aeb39..2f391c5 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 <optional> #include <vector> namespace { @@ -59,10 +59,10 @@ private: std::vector<std::string> CommonSymbols; /// Map of the currently processed object file symbol addresses. - StringMap<Optional<uint64_t>> CurrentObjectAddresses; + StringMap<std::optional<uint64_t>> CurrentObjectAddresses; /// Lazily computed map of symbols aliased to the processed object file. - StringMap<Optional<uint64_t>> CurrentObjectAliasMap; + StringMap<std::optional<uint64_t>> CurrentObjectAliasMap; /// If CurrentObjectAliasMap has been computed for a given address. SmallSet<uint64_t, 4> SeenAliasValues; diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp index d704422..89b495b 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<std::string> InputFilePaths; - Optional<FileFormat> InputFormat; - Optional<FileFormat> OutputFormat; + std::optional<FileFormat> InputFormat; + std::optional<FileFormat> OutputFormat; std::optional<std::string> HintIfsTarget; - Optional<std::string> OptTargetTriple; - Optional<IFSArch> OverrideArch; - Optional<IFSBitWidthType> OverrideBitWidth; - Optional<IFSEndiannessType> OverrideEndianness; + std::optional<std::string> OptTargetTriple; + std::optional<IFSArch> OverrideArch; + std::optional<IFSBitWidthType> OverrideBitWidth; + std::optional<IFSEndiannessType> OverrideEndianness; bool StripIfsArch = false; bool StripIfsBitwidth = false; @@ -130,7 +130,7 @@ static std::string getTypeName(IFSSymbolType Type) { } static Expected<std::unique_ptr<IFSStub>> -readInputFile(Optional<FileFormat> &InputFormat, StringRef FilePath) { +readInputFile(std::optional<FileFormat> &InputFormat, StringRef FilePath) { // Read in file. ErrorOr<std::unique_ptr<MemoryBuffer>> 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<Optional<FileFormat>>(A->getValue()) + Config.InputFormat = StringSwitch<std::optional<FileFormat>>(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<Optional<FileFormat>>(A->getValue()) + Config.OutputFormat = StringSwitch<std::optional<FileFormat>>(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<Optional<IFSEndiannessType>>(A->getValue()) + StringSwitch<std::optional<IFSEndiannessType>>(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 e038863..cc7e60b 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 <cstdlib> #include <map> +#include <optional> #include <set> using namespace llvm; @@ -208,7 +209,7 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) { Arg.Val.getAsInteger(10, UnrollCount); } - const Optional<remarks::RemarkLocation> &Loc = Remark.Loc; + const std::optional<remarks::RemarkLocation> &Loc = Remark.Loc; if (!Loc) continue; diff --git a/llvm/tools/llvm-pdbutil/PdbYaml.h b/llvm/tools/llvm-pdbutil/PdbYaml.h index c335eef..4382e91 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 <optional> #include <vector> namespace llvm { @@ -67,7 +67,7 @@ struct PdbDbiModuleInfo { StringRef Mod; std::vector<StringRef> SourceFiles; std::vector<CodeViewYAML::YAMLDebugSubsection> Subsections; - Optional<PdbModiStream> Modi; + std::optional<PdbModiStream> Modi; }; struct PdbDbiStream { @@ -94,16 +94,16 @@ struct PdbPublicsStream { struct PdbObject { explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {} - Optional<MSFHeaders> Headers; - Optional<std::vector<uint32_t>> StreamSizes; - Optional<std::vector<StreamBlockList>> StreamMap; - Optional<PdbInfoStream> PdbStream; - Optional<PdbDbiStream> DbiStream; - Optional<PdbTpiStream> TpiStream; - Optional<PdbTpiStream> IpiStream; - Optional<PdbPublicsStream> PublicsStream; + std::optional<MSFHeaders> Headers; + std::optional<std::vector<uint32_t>> StreamSizes; + std::optional<std::vector<StreamBlockList>> StreamMap; + std::optional<PdbInfoStream> PdbStream; + std::optional<PdbDbiStream> DbiStream; + std::optional<PdbTpiStream> TpiStream; + std::optional<PdbTpiStream> IpiStream; + std::optional<PdbPublicsStream> PublicsStream; - Optional<std::vector<StringRef>> StringTable; + std::optional<std::vector<StringRef>> StringTable; BumpPtrAllocator &Allocator; }; diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp index 347fb3d..1147e97 100644 --- a/llvm/tools/obj2yaml/dwarf2yaml.cpp +++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp @@ -18,6 +18,7 @@ #include "llvm/ObjectYAML/DWARFYAML.h" #include <algorithm> +#include <optional> using namespace llvm; @@ -165,7 +166,7 @@ Error dumpDebugRanges(DWARFContext &DCtx, DWARFYAML::Data &Y) { return ErrorSuccess(); } -static Optional<DWARFYAML::PubSection> +static std::optional<DWARFYAML::PubSection> 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 f64e479..0c4e841 100644 --- a/llvm/tools/obj2yaml/elf2yaml.cpp +++ b/llvm/tools/obj2yaml/elf2yaml.cpp @@ -54,11 +54,11 @@ class ELFDumper { Expected<std::vector<ELFYAML::ProgramHeader>> dumpProgramHeaders(ArrayRef<std::unique_ptr<ELFYAML::Chunk>> Sections); - Optional<DWARFYAML::Data> + std::optional<DWARFYAML::Data> dumpDWARFSections(std::vector<std::unique_ptr<ELFYAML::Chunk>> &Sections); Error dumpSymbols(const Elf_Shdr *Symtab, - Optional<std::vector<ELFYAML::Symbol>> &Symbols); + std::optional<std::vector<ELFYAML::Symbol>> &Symbols); Error dumpSymbol(const Elf_Sym *Sym, const Elf_Shdr *SymTab, StringRef StrTable, ELFYAML::Symbol &S); Expected<std::vector<std::unique_ptr<ELFYAML::Chunk>>> dumpSections(); @@ -102,7 +102,7 @@ class ELFDumper { dumpPlaceholderSection(const Elf_Shdr *Shdr); bool shouldPrintSection(const ELFYAML::Section &S, const Elf_Shdr &SHdr, - Optional<DWARFYAML::Data> DWARF); + std::optional<DWARFYAML::Data> DWARF); public: ELFDumper(const object::ELFFile<ELFT> &O, std::unique_ptr<DWARFContext> DCtx); @@ -183,7 +183,7 @@ ELFDumper<ELFT>::getUniquedSymbolName(const Elf_Sym *Sym, StringRef StrTable, template <class ELFT> bool ELFDumper<ELFT>::shouldPrintSection(const ELFYAML::Section &S, const Elf_Shdr &SHdr, - Optional<DWARFYAML::Data> DWARF) { + std::optional<DWARFYAML::Data> 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<ELFT>::dumpProgramHeaders( } template <class ELFT> -Optional<DWARFYAML::Data> ELFDumper<ELFT>::dumpDWARFSections( +std::optional<DWARFYAML::Data> ELFDumper<ELFT>::dumpDWARFSections( std::vector<std::unique_ptr<ELFYAML::Chunk>> &Sections) { DWARFYAML::Data DWARF; for (std::unique_ptr<ELFYAML::Chunk> &C : Sections) { @@ -674,7 +674,8 @@ ELFDumper<ELFT>::dumpSections() { template <class ELFT> Error ELFDumper<ELFT>::dumpSymbols( - const Elf_Shdr *Symtab, Optional<std::vector<ELFYAML::Symbol>> &Symbols) { + const Elf_Shdr *Symtab, + std::optional<std::vector<ELFYAML::Symbol>> &Symbols) { if (!Symtab) return Error::success(); diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp index 37aa3a9..ba1f54d 100644 --- a/llvm/tools/yaml2obj/yaml2obj.cpp +++ b/llvm/tools/yaml2obj/yaml2obj.cpp @@ -60,8 +60,8 @@ cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"), cl::Prefix, cl::cat(Cat)); } // namespace -static Optional<std::string> preprocess(StringRef Buf, - yaml::ErrorHandler ErrHandler) { +static std::optional<std::string> preprocess(StringRef Buf, + yaml::ErrorHandler ErrHandler) { DenseMap<StringRef, StringRef> Defines; for (StringRef Define : D) { StringRef Macro, Definition; @@ -134,7 +134,8 @@ int main(int argc, char **argv) { if (!Buf) return 1; - Optional<std::string> Buffer = preprocess(Buf.get()->getBuffer(), ErrHandler); + std::optional<std::string> Buffer = + preprocess(Buf.get()->getBuffer(), ErrHandler); if (!Buffer) return 1; |