From da2f5d0a410bd4188792980739ca49f4169b8bd4 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 14 Dec 2022 08:01:04 +0000 Subject: [PATCH] [tools] llvm::Optional => std::optional --- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp | 4 ++-- llvm/tools/dsymutil/LinkUtils.h | 2 +- llvm/tools/dsymutil/dsymutil.cpp | 7 ++++--- llvm/tools/llvm-cov/CodeCoverage.cpp | 6 +++--- llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp | 9 +++++---- llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp | 4 ++-- llvm/tools/llvm-exegesis/lib/MCInstrDescView.h | 8 ++++---- llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp | 6 +++--- .../llvm-libtool-darwin/llvm-libtool-darwin.cpp | 5 +++-- llvm/tools/llvm-mca/Views/InstructionInfoView.h | 2 +- llvm/tools/llvm-nm/llvm-nm.cpp | 12 ++++++------ llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp | 2 +- llvm/tools/llvm-pdbutil/ExplainOutputStyle.h | 2 +- llvm/tools/llvm-pdbutil/StreamUtil.h | 2 +- llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp | 6 +++--- llvm/tools/llvm-pdbutil/llvm-pdbutil.h | 6 +++--- llvm/tools/llvm-profgen/PerfReader.cpp | 8 +++++--- llvm/tools/llvm-profgen/PerfReader.h | 20 ++++++++++---------- llvm/tools/llvm-profgen/ProfiledBinary.h | 2 +- llvm/tools/llvm-profgen/llvm-profgen.cpp | 2 +- llvm/tools/llvm-rc/ResourceFileWriter.h | 8 ++++---- llvm/tools/llvm-rc/ResourceScriptParser.cpp | 6 +++--- llvm/tools/llvm-rc/ResourceScriptStmt.h | 9 +++++---- llvm/tools/llvm-sim/llvm-sim.cpp | 6 +++--- llvm/tools/llvm-xray/xray-account.h | 2 +- 25 files changed, 76 insertions(+), 70 deletions(-) diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp index 16e608b..14551b0 100644 --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp @@ -410,7 +410,7 @@ void DwarfLinkerForBinary::collectRelocationsToApplyToSwiftReflectionSections( } auto CalculateAddressOfSymbolInDwarfSegment = - [&]() -> llvm::Optional { + [&]() -> std::optional { auto Symbol = It->getSymbol(); auto SymbolAbsoluteAddress = Symbol->getAddress(); if (!SymbolAbsoluteAddress) @@ -446,7 +446,7 @@ void DwarfLinkerForBinary::collectRelocationsToApplyToSwiftReflectionSections( bool ShouldSubtractDwarfVM = false; // For the second symbol there are two possibilities. - llvm::Optional SecondSymbolAddress; + std::optional SecondSymbolAddress; auto Sym = It->getSymbol(); if (Sym != MO->symbol_end()) { Expected SymbolName = Sym->getName(); diff --git a/llvm/tools/dsymutil/LinkUtils.h b/llvm/tools/dsymutil/LinkUtils.h index da21d9b..f08d923 100644 --- a/llvm/tools/dsymutil/LinkUtils.h +++ b/llvm/tools/dsymutil/LinkUtils.h @@ -73,7 +73,7 @@ struct LinkOptions { std::map ObjectPrefixMap; /// The Resources directory in the .dSYM bundle. - Optional ResourceDir; + std::optional ResourceDir; /// Symbol map translator. SymbolMapTranslator Translator; diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp index 2a05321..5ed3b2b 100644 --- a/llvm/tools/dsymutil/dsymutil.cpp +++ b/llvm/tools/dsymutil/dsymutil.cpp @@ -485,12 +485,13 @@ static bool verifyOutput(StringRef OutputFile, StringRef Arch, bool Verbose) { namespace { struct OutputLocation { - OutputLocation(std::string DWARFFile, Optional ResourceDir = {}) + OutputLocation(std::string DWARFFile, + std::optional ResourceDir = {}) : DWARFFile(DWARFFile), ResourceDir(ResourceDir) {} /// This method is a workaround for older compilers. - Optional getResourceDir() const { return ResourceDir; } + std::optional getResourceDir() const { return ResourceDir; } std::string DWARFFile; - Optional ResourceDir; + std::optional ResourceDir; }; } // namespace diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index d2dfbc2..6010362 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -85,7 +85,7 @@ private: bool isEquivalentFile(StringRef FilePath1, StringRef FilePath2); /// Retrieve a file status with a cache. - Optional getFileStatus(StringRef FilePath); + std::optional getFileStatus(StringRef FilePath); /// Return a memory buffer for the given source file. ErrorOr getSourceFile(StringRef SourceFile); @@ -161,7 +161,7 @@ private: std::optional> PathRemapping; /// File status cache used when finding the same file. - StringMap> FileStatusCache; + StringMap> FileStatusCache; /// The architecture the coverage mapping data targets. std::vector CoverageArches; @@ -249,7 +249,7 @@ void CodeCoverageTool::collectPaths(const std::string &Path) { } } -Optional +std::optional CodeCoverageTool::getFileStatus(StringRef FilePath) { auto It = FileStatusCache.try_emplace(FilePath); auto &CachedStatus = It.first->getValue(); diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp index 4902f08..adf48cd 100644 --- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp +++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp @@ -166,7 +166,7 @@ protected: // returns true if specified address range is inside address ranges // of executable sections. bool isInsideExecutableSectionsAddressRange(uint64_t LowPC, - Optional HighPC) { + std::optional HighPC) { std::optional Range = TextAddressRanges.getRangeThatContains(LowPC); @@ -176,7 +176,7 @@ protected: return Range.has_value(); } - uint64_t isBFDDeadAddressRange(uint64_t LowPC, Optional HighPC, + uint64_t isBFDDeadAddressRange(uint64_t LowPC, std::optional HighPC, uint16_t Version) { if (LowPC == 0) return true; @@ -187,7 +187,8 @@ protected: return !isInsideExecutableSectionsAddressRange(LowPC, HighPC); } - uint64_t isMAXPCDeadAddressRange(uint64_t LowPC, Optional HighPC, + uint64_t isMAXPCDeadAddressRange(uint64_t LowPC, + std::optional HighPC, uint16_t Version, uint8_t AddressByteSize) { if (Version <= 4 && HighPC) { if (LowPC == (dwarf::computeTombstoneAddress(AddressByteSize) - 1)) @@ -202,7 +203,7 @@ protected: return false; } - bool isDeadAddressRange(uint64_t LowPC, Optional HighPC, + bool isDeadAddressRange(uint64_t LowPC, std::optional HighPC, uint16_t Version, TombstoneKind Tombstone, uint8_t AddressByteSize) { switch (Tombstone) { diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index 81adaf0..3972bb3 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -75,7 +75,7 @@ struct YamlContext { return RegName; } - Optional getRegNo(StringRef RegName) { + std::optional getRegNo(StringRef RegName) { auto Iter = RegNameToRegNo.find(RegName); if (Iter != RegNameToRegNo.end()) return Iter->second; @@ -242,7 +242,7 @@ template <> struct ScalarTraits { String.split(Pieces, "=0x", /* MaxSplit */ -1, /* KeepEmpty */ false); YamlContext &Context = getTypedContext(Ctx); - Optional RegNo; + std::optional RegNo; if (Pieces.size() == 2 && (RegNo = Context.getRegNo(Pieces[0]))) { RV.Register = *RegNo; const unsigned BitsNeeded = APInt::getBitsNeeded(Pieces[1], kRadix); diff --git a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.h b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.h index 8c7e0b2..8dd2c56 100644 --- a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.h +++ b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.h @@ -49,7 +49,7 @@ struct Variable { // The index of this Variable in Instruction.Variables and its associated // Value in InstructionBuilder.VariableValues. - Optional Index; + std::optional Index; }; // MCOperandInfo can only represents Explicit operands. This object gives a @@ -82,13 +82,13 @@ struct Operand { const MCOperandInfo &getExplicitOperandInfo() const; // Please use the accessors above and not the following fields. - Optional Index; + std::optional Index; bool IsDef = false; const RegisterAliasingTracker *Tracker = nullptr; // Set for Register Op. const MCOperandInfo *Info = nullptr; // Set for Explicit Op. - Optional TiedToIndex; // Set for Reg&Explicit Op. + std::optional TiedToIndex; // Set for Reg&Explicit Op. const MCPhysReg *ImplicitReg = nullptr; // Set for Implicit Op. - Optional VariableIndex; // Set for Explicit Op. + std::optional VariableIndex; // Set for Explicit Op. }; /// A cache of BitVector to reuse between Instructions. diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp index d409493..ac16ae8 100644 --- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp +++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp @@ -187,7 +187,7 @@ static bool filterArch(MachOObjectFile &Obj) { /// /// \returns A valid image base address if we are able to extract one. template -static llvm::Optional +static std::optional getImageBaseAddress(const object::ELFFile &ELFFile) { auto PhdrRangeOrErr = ELFFile.program_headers(); if (!PhdrRangeOrErr) { @@ -208,7 +208,7 @@ getImageBaseAddress(const object::ELFFile &ELFFile) { /// \param MachO A mach-o object file we will search. /// /// \returns A valid image base address if we are able to extract one. -static llvm::Optional +static std::optional getImageBaseAddress(const object::MachOObjectFile *MachO) { for (const auto &Command : MachO->load_commands()) { if (Command.C.cmd == MachO::LC_SEGMENT) { @@ -238,7 +238,7 @@ getImageBaseAddress(const object::MachOObjectFile *MachO) { /// \param Obj An object file we will search. /// /// \returns A valid image base address if we are able to extract one. -static llvm::Optional getImageBaseAddress(object::ObjectFile &Obj) { +static std::optional getImageBaseAddress(object::ObjectFile &Obj) { if (const auto *MachO = dyn_cast(&Obj)) return getImageBaseAddress(MachO); else if (const auto *ELFObj = dyn_cast(&Obj)) diff --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp index 9870bf2..3357afb 100644 --- a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp +++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp @@ -126,7 +126,8 @@ struct Config { static Expected searchForFile(const Twine &FileName) { auto FindLib = - [FileName](ArrayRef SearchDirs) -> Optional { + [FileName]( + ArrayRef SearchDirs) -> std::optional { for (StringRef Dir : SearchDirs) { SmallString<128> Path; sys::path::append(Path, Dir, FileName); @@ -139,7 +140,7 @@ static Expected searchForFile(const Twine &FileName) { return std::nullopt; }; - Optional Found = FindLib(LibrarySearchDirs); + std::optional Found = FindLib(LibrarySearchDirs); if (!Found) Found = FindLib(StandardSearchDirs); if (Found) diff --git a/llvm/tools/llvm-mca/Views/InstructionInfoView.h b/llvm/tools/llvm-mca/Views/InstructionInfoView.h index c35d316..bddd01a 100644 --- a/llvm/tools/llvm-mca/Views/InstructionInfoView.h +++ b/llvm/tools/llvm-mca/Views/InstructionInfoView.h @@ -61,7 +61,7 @@ class InstructionInfoView : public InstructionView { struct InstructionInfoViewData { unsigned NumMicroOpcodes = 0; unsigned Latency = 0; - Optional RThroughput = 0.0; + std::optional RThroughput = 0.0; bool mayLoad = false; bool mayStore = false; bool hasUnmodeledSideEffects = false; diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp index 0d30268..47644f0 100644 --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -647,25 +647,25 @@ static void darwinPrintStab(MachOObjectFile *MachO, const NMSymbol &S) { outs() << format(" %02x", NType); } -static Optional demangle(StringRef Name) { +static std::optional demangle(StringRef Name) { std::string Demangled; if (nonMicrosoftDemangle(Name.str().c_str(), Demangled)) return Demangled; return std::nullopt; } -static Optional demangleXCOFF(StringRef Name) { +static std::optional demangleXCOFF(StringRef Name) { if (Name.empty() || Name[0] != '.') return demangle(Name); Name = Name.drop_front(); - Optional DemangledName = demangle(Name); + std::optional DemangledName = demangle(Name); if (DemangledName) return "." + *DemangledName; return std::nullopt; } -static Optional demangleMachO(StringRef Name) { +static std::optional demangleMachO(StringRef Name) { if (!Name.empty() && Name[0] == '_') Name = Name.drop_front(); return demangle(Name); @@ -762,12 +762,12 @@ static void printSymbolList(SymbolicFile &Obj, std::string Name = S.Name; MachOObjectFile *MachO = dyn_cast(&Obj); if (Demangle) { - function_ref(StringRef)> Fn = ::demangle; + function_ref(StringRef)> Fn = ::demangle; if (Obj.isXCOFF()) Fn = demangleXCOFF; if (Obj.isMachO()) Fn = demangleMachO; - if (Optional Opt = Fn(S.Name)) + if (std::optional Opt = Fn(S.Name)) Name = *Opt; } diff --git a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp index ef9eb29..3e57e31 100644 --- a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp @@ -124,7 +124,7 @@ bool ExplainOutputStyle::isPdbStreamDirectoryBlock() const { return llvm::is_contained(Layout.DirectoryBlocks, pdbBlockIndex()); } -Optional ExplainOutputStyle::getPdbBlockStreamIndex() const { +std::optional ExplainOutputStyle::getPdbBlockStreamIndex() const { const auto &Layout = File.pdb().getMsfLayout(); for (const auto &Entry : enumerate(Layout.StreamMap)) { if (!llvm::is_contained(Entry.value(), pdbBlockIndex())) diff --git a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.h b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.h index e3d19f2..499f2a8 100644 --- a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.h +++ b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.h @@ -43,7 +43,7 @@ private: bool isPdbFpmBlock() const; bool isPdbBlockMapBlock() const; bool isPdbStreamDirectoryBlock() const; - Optional getPdbBlockStreamIndex() const; + std::optional getPdbBlockStreamIndex() const; void explainPdbSuperBlockOffset(); void explainPdbFpmBlockOffset(); diff --git a/llvm/tools/llvm-pdbutil/StreamUtil.h b/llvm/tools/llvm-pdbutil/StreamUtil.h index f810f7d..9d9c5f9a 100644 --- a/llvm/tools/llvm-pdbutil/StreamUtil.h +++ b/llvm/tools/llvm-pdbutil/StreamUtil.h @@ -52,7 +52,7 @@ private: StreamPurpose Purpose; uint32_t StreamIndex; std::string Name; - Optional ModuleIndex; + std::optional ModuleIndex; }; void discoverStreamPurposes(PDBFile &File, diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp index 214cc07..61cad15 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -377,8 +377,8 @@ cl::OptionCategory PdbBytes("PDB Stream Options"); cl::OptionCategory Types("Type Options"); cl::OptionCategory ModuleCategory("Module Options"); -llvm::Optional DumpBlockRange; -llvm::Optional DumpByteRange; +std::optional DumpBlockRange; +std::optional DumpByteRange; cl::opt DumpBlockRangeOpt( "block-range", cl::value_desc("start[-end]"), @@ -1422,7 +1422,7 @@ static void exportStream() { } static bool parseRange(StringRef Str, - Optional &Parsed) { + std::optional &Parsed) { if (Str.empty()) return true; diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h index 455fe5f..efda550 100644 --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h @@ -111,11 +111,11 @@ extern llvm::cl::opt ClassRecursionDepth; namespace bytes { struct NumberRange { uint64_t Min; - llvm::Optional Max; + std::optional Max; }; -extern llvm::Optional DumpBlockRange; -extern llvm::Optional DumpByteRange; +extern std::optional DumpBlockRange; +extern std::optional DumpByteRange; extern llvm::cl::list DumpStreamData; extern llvm::cl::opt NameMap; extern llvm::cl::opt Fpm; diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp index 14bc04b..86c0131 100644 --- a/llvm/tools/llvm-profgen/PerfReader.cpp +++ b/llvm/tools/llvm-profgen/PerfReader.cpp @@ -319,7 +319,7 @@ bool VirtualUnwinder::unwind(const PerfSample *Sample, uint64_t Repeat) { std::unique_ptr PerfReaderBase::create(ProfiledBinary *Binary, PerfInputFile &PerfInput, - Optional PIDFilter) { + std::optional PIDFilter) { std::unique_ptr PerfReader; if (PerfInput.Format == PerfFormat::UnsymbolizedProfile) { @@ -350,8 +350,10 @@ PerfReaderBase::create(ProfiledBinary *Binary, PerfInputFile &PerfInput, return PerfReader; } -PerfInputFile PerfScriptReader::convertPerfDataToTrace( - ProfiledBinary *Binary, PerfInputFile &File, Optional PIDFilter) { +PerfInputFile +PerfScriptReader::convertPerfDataToTrace(ProfiledBinary *Binary, + PerfInputFile &File, + std::optional PIDFilter) { StringRef PerfData = File.InputFile; // Run perf script to retrieve PIDs matching binary we're interested in. auto PerfExecutable = sys::Process::FindInEnvPath("PATH", "perf"); diff --git a/llvm/tools/llvm-profgen/PerfReader.h b/llvm/tools/llvm-profgen/PerfReader.h index 5accea0..14137e8 100644 --- a/llvm/tools/llvm-profgen/PerfReader.h +++ b/llvm/tools/llvm-profgen/PerfReader.h @@ -567,9 +567,9 @@ public: Binary->setBaseAddress(Binary->getPreferredBaseAddress()); }; virtual ~PerfReaderBase() = default; - static std::unique_ptr create(ProfiledBinary *Binary, - PerfInputFile &PerfInput, - Optional PIDFilter); + static std::unique_ptr + create(ProfiledBinary *Binary, PerfInputFile &PerfInput, + std::optional PIDFilter); // Entry of the reader to parse multiple perf traces virtual void parsePerfTraces() = 0; @@ -594,15 +594,15 @@ protected: class PerfScriptReader : public PerfReaderBase { public: PerfScriptReader(ProfiledBinary *B, StringRef PerfTrace, - Optional PID) + std::optional PID) : PerfReaderBase(B, PerfTrace), PIDFilter(PID){}; // Entry of the reader to parse multiple perf traces void parsePerfTraces() override; // Generate perf script from perf data - static PerfInputFile convertPerfDataToTrace(ProfiledBinary *Binary, - PerfInputFile &File, - Optional PIDFilter); + static PerfInputFile + convertPerfDataToTrace(ProfiledBinary *Binary, PerfInputFile &File, + std::optional PIDFilter); // Extract perf script type by peaking at the input static PerfContent checkPerfScriptType(StringRef FileName); @@ -663,7 +663,7 @@ protected: // Keep track of all invalid return addresses std::set InvalidReturnAddresses; // PID for the process of interest - Optional PIDFilter; + std::optional PIDFilter; }; /* @@ -675,7 +675,7 @@ protected: class LBRPerfReader : public PerfScriptReader { public: LBRPerfReader(ProfiledBinary *Binary, StringRef PerfTrace, - Optional PID) + std::optional PID) : PerfScriptReader(Binary, PerfTrace, PID){}; // Parse the LBR only sample. void parseSample(TraceStream &TraceIt, uint64_t Count) override; @@ -693,7 +693,7 @@ public: class HybridPerfReader : public PerfScriptReader { public: HybridPerfReader(ProfiledBinary *Binary, StringRef PerfTrace, - Optional PID) + std::optional PID) : PerfScriptReader(Binary, PerfTrace, PID){}; // Parse the hybrid sample including the call and LBR line void parseSample(TraceStream &TraceIt, uint64_t Count) override; diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.h b/llvm/tools/llvm-profgen/ProfiledBinary.h index 29206b1..61f9942 100644 --- a/llvm/tools/llvm-profgen/ProfiledBinary.h +++ b/llvm/tools/llvm-profgen/ProfiledBinary.h @@ -506,7 +506,7 @@ public: return I.first->second; } - Optional getInlineLeafFrameLoc(uint64_t Address) { + std::optional getInlineLeafFrameLoc(uint64_t Address) { const auto &Stack = getCachedFrameLocationStack(Address); if (Stack.empty()) return {}; diff --git a/llvm/tools/llvm-profgen/llvm-profgen.cpp b/llvm/tools/llvm-profgen/llvm-profgen.cpp index 7d83655..596882c 100644 --- a/llvm/tools/llvm-profgen/llvm-profgen.cpp +++ b/llvm/tools/llvm-profgen/llvm-profgen.cpp @@ -167,7 +167,7 @@ int main(int argc, const char *argv[]) { Generator->generateProfile(); Generator->write(); } else { - Optional PIDFilter; + std::optional PIDFilter; if (ProcessId.getNumOccurrences()) PIDFilter = ProcessId; PerfInputFile PerfFile = getPerfInputFile(); diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.h b/llvm/tools/llvm-rc/ResourceFileWriter.h index 0f3d593..7a92f84 100644 --- a/llvm/tools/llvm-rc/ResourceFileWriter.h +++ b/llvm/tools/llvm-rc/ResourceFileWriter.h @@ -79,8 +79,8 @@ public: uint32_t Characteristics; uint32_t VersionInfo; - Optional Style; - Optional ExStyle; + std::optional Style; + std::optional ExStyle; StringRef Caption; struct FontInfo { uint32_t Size; @@ -89,7 +89,7 @@ public: bool IsItalic; uint32_t Charset; }; - Optional Font; + std::optional Font; IntOrString Class; ObjectInfo() @@ -103,7 +103,7 @@ public: using BundleKey = std::pair; // Each bundle is in fact an array of 16 strings. struct Bundle { - std::array>, 16> Data; + std::array>, 16> Data; ObjectInfo DeclTimeInfo; uint16_t MemoryFlags; Bundle(const ObjectInfo &Info, uint16_t Flags) diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.cpp b/llvm/tools/llvm-rc/ResourceScriptParser.cpp index 7cb4d02..c1f00d3 100644 --- a/llvm/tools/llvm-rc/ResourceScriptParser.cpp +++ b/llvm/tools/llvm-rc/ResourceScriptParser.cpp @@ -554,7 +554,7 @@ Expected RCParser::parseControl() { RETURN_IF_ERROR(consumeType(Kind::Comma)); IntOrString Class; - Optional Style; + std::optional Style; if (ClassUpper == "CONTROL") { // CONTROL text, id, class, style, x, y, width, height [, exstyle] [, helpID] ASSIGN_OR_RETURN(ClassStr, readString()); @@ -577,12 +577,12 @@ Expected RCParser::parseControl() { } } - Optional ExStyle; + std::optional ExStyle; if (consumeOptionalType(Kind::Comma)) { ASSIGN_OR_RETURN(Val, readInt()); ExStyle = *Val; } - Optional HelpID; + std::optional HelpID; if (consumeOptionalType(Kind::Comma)) { ASSIGN_OR_RETURN(Val, readInt()); HelpID = *Val; diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.h b/llvm/tools/llvm-rc/ResourceScriptStmt.h index 4b659f0..71f6a9d 100644 --- a/llvm/tools/llvm-rc/ResourceScriptStmt.h +++ b/llvm/tools/llvm-rc/ResourceScriptStmt.h @@ -611,8 +611,8 @@ public: StringRef Type; IntOrString Title; uint32_t ID, X, Y, Width, Height; - Optional Style; - Optional ExtStyle, HelpID; + std::optional Style; + std::optional ExtStyle, HelpID; IntOrString Class; // Control classes as described in DLGITEMTEMPLATEEX documentation. @@ -636,8 +636,9 @@ public: Control(StringRef CtlType, IntOrString CtlTitle, uint32_t CtlID, uint32_t PosX, uint32_t PosY, uint32_t ItemWidth, uint32_t ItemHeight, - Optional ItemStyle, Optional ExtItemStyle, - Optional CtlHelpID, IntOrString CtlClass) + std::optional ItemStyle, + std::optional ExtItemStyle, + std::optional CtlHelpID, IntOrString CtlClass) : Type(CtlType), Title(CtlTitle), ID(CtlID), X(PosX), Y(PosY), Width(ItemWidth), Height(ItemHeight), Style(ItemStyle), ExtStyle(ExtItemStyle), HelpID(CtlHelpID), Class(CtlClass) {} diff --git a/llvm/tools/llvm-sim/llvm-sim.cpp b/llvm/tools/llvm-sim/llvm-sim.cpp index 7b61ad7..8995705 100644 --- a/llvm/tools/llvm-sim/llvm-sim.cpp +++ b/llvm/tools/llvm-sim/llvm-sim.cpp @@ -41,7 +41,7 @@ static cl::opt InputSourceFile(cl::Positional, /// \param LLVMInstNum - The mapping of Instructions to their location in the /// module represented by an unsigned integer. /// \returns The instruction number for \p I if it exists. -Optional +std::optional getPositionInModule(const Instruction *I, const DenseMap &LLVMInstNum) { assert(I && "Instruction is nullptr!"); @@ -80,9 +80,9 @@ exportToFile(const StringRef FilePath, // For each file there is a list of the range where the similarity // exists. for (const IRSimilarityCandidate &C : G) { - Optional Start = + std::optional Start = getPositionInModule((*C.front()).Inst, LLVMInstNum); - Optional End = + std::optional End = getPositionInModule((*C.back()).Inst, LLVMInstNum); assert(Start && diff --git a/llvm/tools/llvm-xray/xray-account.h b/llvm/tools/llvm-xray/xray-account.h index 371a9cc..38d3ec9 100644 --- a/llvm/tools/llvm-xray/xray-account.h +++ b/llvm/tools/llvm-xray/xray-account.h @@ -45,7 +45,7 @@ public: RecursionStatus &operator--(); bool isRecursive() const; }; - Optional> RecursionDepth; + std::optional> RecursionDepth; }; typedef llvm::DenseMap PerThreadFunctionStackMap; -- 2.7.4