diff --git a/llvm/include/llvm/ProfileData/InstrProfCorrelator.h b/llvm/include/llvm/ProfileData/InstrProfCorrelator.h index 3238a90c1747cf..2e26a21e8839ba 100644 --- a/llvm/include/llvm/ProfileData/InstrProfCorrelator.h +++ b/llvm/include/llvm/ProfileData/InstrProfCorrelator.h @@ -42,7 +42,7 @@ class InstrProfCorrelator { virtual Error dumpYaml(raw_ostream &OS) = 0; /// Return the number of ProfileData elements. - llvm::Optional getDataSize() const; + std::optional getDataSize() const; /// Return a pointer to the names string that this class constructs. const char *getNamesPointer() const { return Names.c_str(); } @@ -166,7 +166,7 @@ class DwarfInstrProfCorrelator : public InstrProfCorrelatorImpl { std::unique_ptr DICtx; /// Return the address of the object that the provided DIE symbolizes. - llvm::Optional getLocation(const DWARFDie &Die) const; + std::optional getLocation(const DWARFDie &Die) const; /// Returns true if the provided DIE symbolizes an instrumentation probe /// symbol. diff --git a/llvm/include/llvm/ProfileData/SampleProfReader.h b/llvm/include/llvm/ProfileData/SampleProfReader.h index ba64e151153553..57e8c8c74e4ecb 100644 --- a/llvm/include/llvm/ProfileData/SampleProfReader.h +++ b/llvm/include/llvm/ProfileData/SampleProfReader.h @@ -225,7 +225,6 @@ #ifndef LLVM_PROFILEDATA_SAMPLEPROFREADER_H #define LLVM_PROFILEDATA_SAMPLEPROFREADER_H -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/DiagnosticInfo.h" @@ -241,6 +240,7 @@ #include #include #include +#include #include #include #include @@ -295,7 +295,7 @@ class SampleProfileReaderItaniumRemapper { /// Return the equivalent name in the profile for \p FunctionName if /// it exists. - Optional lookUpNameInProfile(StringRef FunctionName); + std::optional lookUpNameInProfile(StringRef FunctionName); private: // The buffer holding the content read from remapping file. diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index cad368d557ebdf..12fbac99ee4136 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -14,7 +14,6 @@ #include "llvm/ProfileData/Coverage/CoverageMapping.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -676,7 +675,8 @@ static SmallBitVector gatherFileIDs(StringRef SourceFile, } /// Return the ID of the file where the definition of the function is located. -static Optional findMainViewFileID(const FunctionRecord &Function) { +static std::optional +findMainViewFileID(const FunctionRecord &Function) { SmallBitVector IsNotExpandedFile(Function.Filenames.size(), true); for (const auto &CR : Function.CountedRegions) if (CR.Kind == CounterMappingRegion::ExpansionRegion) @@ -690,9 +690,9 @@ static Optional findMainViewFileID(const FunctionRecord &Function) { /// Check if SourceFile is the file that contains the definition of /// the Function. Return the ID of the file in that case or std::nullopt /// otherwise. -static Optional findMainViewFileID(StringRef SourceFile, - const FunctionRecord &Function) { - Optional I = findMainViewFileID(Function); +static std::optional +findMainViewFileID(StringRef SourceFile, const FunctionRecord &Function) { + std::optional I = findMainViewFileID(Function); if (I && SourceFile == Function.Filenames[*I]) return I; return std::nullopt; diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp index 9d63b5e4acfb31..16f864bb6d6669 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp @@ -517,11 +517,11 @@ struct CovMapFuncRecordReader { // // Prior to Version4, \p OutOfLineMappingBuf points to a sequence of coverage // mappings associated with the function records. It is unused in Version4. - virtual Error readFunctionRecords(const char *FuncRecBuf, - const char *FuncRecBufEnd, - Optional OutOfLineFileRange, - const char *OutOfLineMappingBuf, - const char *OutOfLineMappingBufEnd) = 0; + virtual Error + readFunctionRecords(const char *FuncRecBuf, const char *FuncRecBufEnd, + std::optional OutOfLineFileRange, + const char *OutOfLineMappingBuf, + const char *OutOfLineMappingBufEnd) = 0; template static Expected> @@ -695,7 +695,7 @@ class VersionedCovMapFuncRecordReader : public CovMapFuncRecordReader { } Error readFunctionRecords(const char *FuncRecBuf, const char *FuncRecBufEnd, - Optional OutOfLineFileRange, + std::optional OutOfLineFileRange, const char *OutOfLineMappingBuf, const char *OutOfLineMappingBufEnd) override { auto CFR = reinterpret_cast(FuncRecBuf); @@ -710,7 +710,7 @@ class VersionedCovMapFuncRecordReader : public CovMapFuncRecordReader { return make_error(coveragemap_error::malformed); // Look up the set of filenames associated with this function record. - Optional FileRange; + std::optional FileRange; if (Version < CovMapVersion::Version4) { FileRange = OutOfLineFileRange; } else { diff --git a/llvm/lib/ProfileData/InstrProfCorrelator.cpp b/llvm/lib/ProfileData/InstrProfCorrelator.cpp index 6bab3c41b9ca1c..c822d81f8bef16 100644 --- a/llvm/lib/ProfileData/InstrProfCorrelator.cpp +++ b/llvm/lib/ProfileData/InstrProfCorrelator.cpp @@ -94,7 +94,7 @@ InstrProfCorrelator::get(std::unique_ptr Buffer) { instrprof_error::unable_to_correlate_profile, "not an object file"); } -Optional InstrProfCorrelator::getDataSize() const { +std::optional InstrProfCorrelator::getDataSize() const { if (auto *C = dyn_cast>(this)) { return C->getDataSize(); } else if (auto *C = dyn_cast>(this)) { @@ -217,7 +217,7 @@ void InstrProfCorrelatorImpl::addProbe(StringRef FunctionName, } template -llvm::Optional +std::optional DwarfInstrProfCorrelator::getLocation(const DWARFDie &Die) const { auto Locations = Die.getLocations(dwarf::DW_AT_location); if (!Locations) { @@ -266,7 +266,7 @@ void DwarfInstrProfCorrelator::correlateProfileDataImpl( return; std::optional FunctionName; std::optional CFGHash; - Optional CounterPtr = getLocation(Die); + std::optional CounterPtr = getLocation(Die); auto FnDie = Die.getParent(); auto FunctionPtr = dwarf::toAddress(FnDie.find(dwarf::DW_AT_low_pc)); std::optional NumCounters; diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp index 5d8f321b1a24e2..25b13e043aea87 100644 --- a/llvm/lib/ProfileData/SampleProfReader.cpp +++ b/llvm/lib/ProfileData/SampleProfReader.cpp @@ -1820,7 +1820,7 @@ void SampleProfileReaderItaniumRemapper::applyRemapping(LLVMContext &Ctx) { RemappingApplied = true; } -Optional +std::optional SampleProfileReaderItaniumRemapper::lookUpNameInProfile(StringRef Fname) { if (auto Key = Remappings->lookup(Fname)) return NameMap.lookup(Key);