}
auto CalculateAddressOfSymbolInDwarfSegment =
- [&]() -> llvm::Optional<int64_t> {
+ [&]() -> std::optional<int64_t> {
auto Symbol = It->getSymbol();
auto SymbolAbsoluteAddress = Symbol->getAddress();
if (!SymbolAbsoluteAddress)
bool ShouldSubtractDwarfVM = false;
// For the second symbol there are two possibilities.
- llvm::Optional<int64_t> SecondSymbolAddress;
+ std::optional<int64_t> SecondSymbolAddress;
auto Sym = It->getSymbol();
if (Sym != MO->symbol_end()) {
Expected<StringRef> SymbolName = Sym->getName();
std::map<std::string, std::string> ObjectPrefixMap;
/// The Resources directory in the .dSYM bundle.
- Optional<std::string> ResourceDir;
+ std::optional<std::string> ResourceDir;
/// Symbol map translator.
SymbolMapTranslator Translator;
namespace {
struct OutputLocation {
- OutputLocation(std::string DWARFFile, Optional<std::string> ResourceDir = {})
+ OutputLocation(std::string DWARFFile,
+ std::optional<std::string> ResourceDir = {})
: DWARFFile(DWARFFile), ResourceDir(ResourceDir) {}
/// This method is a workaround for older compilers.
- Optional<std::string> getResourceDir() const { return ResourceDir; }
+ std::optional<std::string> getResourceDir() const { return ResourceDir; }
std::string DWARFFile;
- Optional<std::string> ResourceDir;
+ std::optional<std::string> ResourceDir;
};
} // namespace
bool isEquivalentFile(StringRef FilePath1, StringRef FilePath2);
/// Retrieve a file status with a cache.
- Optional<sys::fs::file_status> getFileStatus(StringRef FilePath);
+ std::optional<sys::fs::file_status> getFileStatus(StringRef FilePath);
/// Return a memory buffer for the given source file.
ErrorOr<const MemoryBuffer &> getSourceFile(StringRef SourceFile);
std::optional<std::pair<std::string, std::string>> PathRemapping;
/// File status cache used when finding the same file.
- StringMap<Optional<sys::fs::file_status>> FileStatusCache;
+ StringMap<std::optional<sys::fs::file_status>> FileStatusCache;
/// The architecture the coverage mapping data targets.
std::vector<StringRef> CoverageArches;
}
}
-Optional<sys::fs::file_status>
+std::optional<sys::fs::file_status>
CodeCoverageTool::getFileStatus(StringRef FilePath) {
auto It = FileStatusCache.try_emplace(FilePath);
auto &CachedStatus = It.first->getValue();
// returns true if specified address range is inside address ranges
// of executable sections.
bool isInsideExecutableSectionsAddressRange(uint64_t LowPC,
- Optional<uint64_t> HighPC) {
+ std::optional<uint64_t> HighPC) {
std::optional<AddressRange> Range =
TextAddressRanges.getRangeThatContains(LowPC);
return Range.has_value();
}
- uint64_t isBFDDeadAddressRange(uint64_t LowPC, Optional<uint64_t> HighPC,
+ uint64_t isBFDDeadAddressRange(uint64_t LowPC, std::optional<uint64_t> HighPC,
uint16_t Version) {
if (LowPC == 0)
return true;
return !isInsideExecutableSectionsAddressRange(LowPC, HighPC);
}
- uint64_t isMAXPCDeadAddressRange(uint64_t LowPC, Optional<uint64_t> HighPC,
+ uint64_t isMAXPCDeadAddressRange(uint64_t LowPC,
+ std::optional<uint64_t> HighPC,
uint16_t Version, uint8_t AddressByteSize) {
if (Version <= 4 && HighPC) {
if (LowPC == (dwarf::computeTombstoneAddress(AddressByteSize) - 1))
return false;
}
- bool isDeadAddressRange(uint64_t LowPC, Optional<uint64_t> HighPC,
+ bool isDeadAddressRange(uint64_t LowPC, std::optional<uint64_t> HighPC,
uint16_t Version, TombstoneKind Tombstone,
uint8_t AddressByteSize) {
switch (Tombstone) {
return RegName;
}
- Optional<unsigned> getRegNo(StringRef RegName) {
+ std::optional<unsigned> getRegNo(StringRef RegName) {
auto Iter = RegNameToRegNo.find(RegName);
if (Iter != RegNameToRegNo.end())
return Iter->second;
String.split(Pieces, "=0x", /* MaxSplit */ -1,
/* KeepEmpty */ false);
YamlContext &Context = getTypedContext(Ctx);
- Optional<unsigned> RegNo;
+ std::optional<unsigned> RegNo;
if (Pieces.size() == 2 && (RegNo = Context.getRegNo(Pieces[0]))) {
RV.Register = *RegNo;
const unsigned BitsNeeded = APInt::getBitsNeeded(Pieces[1], kRadix);
// The index of this Variable in Instruction.Variables and its associated
// Value in InstructionBuilder.VariableValues.
- Optional<uint8_t> Index;
+ std::optional<uint8_t> Index;
};
// MCOperandInfo can only represents Explicit operands. This object gives a
const MCOperandInfo &getExplicitOperandInfo() const;
// Please use the accessors above and not the following fields.
- Optional<uint8_t> Index;
+ std::optional<uint8_t> Index;
bool IsDef = false;
const RegisterAliasingTracker *Tracker = nullptr; // Set for Register Op.
const MCOperandInfo *Info = nullptr; // Set for Explicit Op.
- Optional<uint8_t> TiedToIndex; // Set for Reg&Explicit Op.
+ std::optional<uint8_t> TiedToIndex; // Set for Reg&Explicit Op.
const MCPhysReg *ImplicitReg = nullptr; // Set for Implicit Op.
- Optional<uint8_t> VariableIndex; // Set for Explicit Op.
+ std::optional<uint8_t> VariableIndex; // Set for Explicit Op.
};
/// A cache of BitVector to reuse between Instructions.
///
/// \returns A valid image base address if we are able to extract one.
template <class ELFT>
-static llvm::Optional<uint64_t>
+static std::optional<uint64_t>
getImageBaseAddress(const object::ELFFile<ELFT> &ELFFile) {
auto PhdrRangeOrErr = ELFFile.program_headers();
if (!PhdrRangeOrErr) {
/// \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<uint64_t>
+static std::optional<uint64_t>
getImageBaseAddress(const object::MachOObjectFile *MachO) {
for (const auto &Command : MachO->load_commands()) {
if (Command.C.cmd == MachO::LC_SEGMENT) {
/// \param Obj An object file we will search.
///
/// \returns A valid image base address if we are able to extract one.
-static llvm::Optional<uint64_t> getImageBaseAddress(object::ObjectFile &Obj) {
+static std::optional<uint64_t> getImageBaseAddress(object::ObjectFile &Obj) {
if (const auto *MachO = dyn_cast<object::MachOObjectFile>(&Obj))
return getImageBaseAddress(MachO);
else if (const auto *ELFObj = dyn_cast<object::ELF32LEObjectFile>(&Obj))
static Expected<std::string> searchForFile(const Twine &FileName) {
auto FindLib =
- [FileName](ArrayRef<std::string> SearchDirs) -> Optional<std::string> {
+ [FileName](
+ ArrayRef<std::string> SearchDirs) -> std::optional<std::string> {
for (StringRef Dir : SearchDirs) {
SmallString<128> Path;
sys::path::append(Path, Dir, FileName);
return std::nullopt;
};
- Optional<std::string> Found = FindLib(LibrarySearchDirs);
+ std::optional<std::string> Found = FindLib(LibrarySearchDirs);
if (!Found)
Found = FindLib(StandardSearchDirs);
if (Found)
struct InstructionInfoViewData {
unsigned NumMicroOpcodes = 0;
unsigned Latency = 0;
- Optional<double> RThroughput = 0.0;
+ std::optional<double> RThroughput = 0.0;
bool mayLoad = false;
bool mayStore = false;
bool hasUnmodeledSideEffects = false;
outs() << format(" %02x", NType);
}
-static Optional<std::string> demangle(StringRef Name) {
+static std::optional<std::string> demangle(StringRef Name) {
std::string Demangled;
if (nonMicrosoftDemangle(Name.str().c_str(), Demangled))
return Demangled;
return std::nullopt;
}
-static Optional<std::string> demangleXCOFF(StringRef Name) {
+static std::optional<std::string> demangleXCOFF(StringRef Name) {
if (Name.empty() || Name[0] != '.')
return demangle(Name);
Name = Name.drop_front();
- Optional<std::string> DemangledName = demangle(Name);
+ std::optional<std::string> DemangledName = demangle(Name);
if (DemangledName)
return "." + *DemangledName;
return std::nullopt;
}
-static Optional<std::string> demangleMachO(StringRef Name) {
+static std::optional<std::string> demangleMachO(StringRef Name) {
if (!Name.empty() && Name[0] == '_')
Name = Name.drop_front();
return demangle(Name);
std::string Name = S.Name;
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj);
if (Demangle) {
- function_ref<Optional<std::string>(StringRef)> Fn = ::demangle;
+ function_ref<std::optional<std::string>(StringRef)> Fn = ::demangle;
if (Obj.isXCOFF())
Fn = demangleXCOFF;
if (Obj.isMachO())
Fn = demangleMachO;
- if (Optional<std::string> Opt = Fn(S.Name))
+ if (std::optional<std::string> Opt = Fn(S.Name))
Name = *Opt;
}
return llvm::is_contained(Layout.DirectoryBlocks, pdbBlockIndex());
}
-Optional<uint32_t> ExplainOutputStyle::getPdbBlockStreamIndex() const {
+std::optional<uint32_t> ExplainOutputStyle::getPdbBlockStreamIndex() const {
const auto &Layout = File.pdb().getMsfLayout();
for (const auto &Entry : enumerate(Layout.StreamMap)) {
if (!llvm::is_contained(Entry.value(), pdbBlockIndex()))
bool isPdbFpmBlock() const;
bool isPdbBlockMapBlock() const;
bool isPdbStreamDirectoryBlock() const;
- Optional<uint32_t> getPdbBlockStreamIndex() const;
+ std::optional<uint32_t> getPdbBlockStreamIndex() const;
void explainPdbSuperBlockOffset();
void explainPdbFpmBlockOffset();
StreamPurpose Purpose;
uint32_t StreamIndex;
std::string Name;
- Optional<uint32_t> ModuleIndex;
+ std::optional<uint32_t> ModuleIndex;
};
void discoverStreamPurposes(PDBFile &File,
cl::OptionCategory Types("Type Options");
cl::OptionCategory ModuleCategory("Module Options");
-llvm::Optional<NumberRange> DumpBlockRange;
-llvm::Optional<NumberRange> DumpByteRange;
+std::optional<NumberRange> DumpBlockRange;
+std::optional<NumberRange> DumpByteRange;
cl::opt<std::string> DumpBlockRangeOpt(
"block-range", cl::value_desc("start[-end]"),
}
static bool parseRange(StringRef Str,
- Optional<opts::bytes::NumberRange> &Parsed) {
+ std::optional<opts::bytes::NumberRange> &Parsed) {
if (Str.empty())
return true;
namespace bytes {
struct NumberRange {
uint64_t Min;
- llvm::Optional<uint64_t> Max;
+ std::optional<uint64_t> Max;
};
-extern llvm::Optional<NumberRange> DumpBlockRange;
-extern llvm::Optional<NumberRange> DumpByteRange;
+extern std::optional<NumberRange> DumpBlockRange;
+extern std::optional<NumberRange> DumpByteRange;
extern llvm::cl::list<std::string> DumpStreamData;
extern llvm::cl::opt<bool> NameMap;
extern llvm::cl::opt<bool> Fpm;
std::unique_ptr<PerfReaderBase>
PerfReaderBase::create(ProfiledBinary *Binary, PerfInputFile &PerfInput,
- Optional<uint32_t> PIDFilter) {
+ std::optional<uint32_t> PIDFilter) {
std::unique_ptr<PerfReaderBase> PerfReader;
if (PerfInput.Format == PerfFormat::UnsymbolizedProfile) {
return PerfReader;
}
-PerfInputFile PerfScriptReader::convertPerfDataToTrace(
- ProfiledBinary *Binary, PerfInputFile &File, Optional<uint32_t> PIDFilter) {
+PerfInputFile
+PerfScriptReader::convertPerfDataToTrace(ProfiledBinary *Binary,
+ PerfInputFile &File,
+ std::optional<uint32_t> PIDFilter) {
StringRef PerfData = File.InputFile;
// Run perf script to retrieve PIDs matching binary we're interested in.
auto PerfExecutable = sys::Process::FindInEnvPath("PATH", "perf");
Binary->setBaseAddress(Binary->getPreferredBaseAddress());
};
virtual ~PerfReaderBase() = default;
- static std::unique_ptr<PerfReaderBase> create(ProfiledBinary *Binary,
- PerfInputFile &PerfInput,
- Optional<uint32_t> PIDFilter);
+ static std::unique_ptr<PerfReaderBase>
+ create(ProfiledBinary *Binary, PerfInputFile &PerfInput,
+ std::optional<uint32_t> PIDFilter);
// Entry of the reader to parse multiple perf traces
virtual void parsePerfTraces() = 0;
class PerfScriptReader : public PerfReaderBase {
public:
PerfScriptReader(ProfiledBinary *B, StringRef PerfTrace,
- Optional<uint32_t> PID)
+ std::optional<uint32_t> 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<uint32_t> PIDFilter);
+ static PerfInputFile
+ convertPerfDataToTrace(ProfiledBinary *Binary, PerfInputFile &File,
+ std::optional<uint32_t> PIDFilter);
// Extract perf script type by peaking at the input
static PerfContent checkPerfScriptType(StringRef FileName);
// Keep track of all invalid return addresses
std::set<uint64_t> InvalidReturnAddresses;
// PID for the process of interest
- Optional<uint32_t> PIDFilter;
+ std::optional<uint32_t> PIDFilter;
};
/*
class LBRPerfReader : public PerfScriptReader {
public:
LBRPerfReader(ProfiledBinary *Binary, StringRef PerfTrace,
- Optional<uint32_t> PID)
+ std::optional<uint32_t> PID)
: PerfScriptReader(Binary, PerfTrace, PID){};
// Parse the LBR only sample.
void parseSample(TraceStream &TraceIt, uint64_t Count) override;
class HybridPerfReader : public PerfScriptReader {
public:
HybridPerfReader(ProfiledBinary *Binary, StringRef PerfTrace,
- Optional<uint32_t> PID)
+ std::optional<uint32_t> PID)
: PerfScriptReader(Binary, PerfTrace, PID){};
// Parse the hybrid sample including the call and LBR line
void parseSample(TraceStream &TraceIt, uint64_t Count) override;
return I.first->second;
}
- Optional<SampleContextFrame> getInlineLeafFrameLoc(uint64_t Address) {
+ std::optional<SampleContextFrame> getInlineLeafFrameLoc(uint64_t Address) {
const auto &Stack = getCachedFrameLocationStack(Address);
if (Stack.empty())
return {};
Generator->generateProfile();
Generator->write();
} else {
- Optional<uint32_t> PIDFilter;
+ std::optional<uint32_t> PIDFilter;
if (ProcessId.getNumOccurrences())
PIDFilter = ProcessId;
PerfInputFile PerfFile = getPerfInputFile();
uint32_t Characteristics;
uint32_t VersionInfo;
- Optional<uint32_t> Style;
- Optional<uint32_t> ExStyle;
+ std::optional<uint32_t> Style;
+ std::optional<uint32_t> ExStyle;
StringRef Caption;
struct FontInfo {
uint32_t Size;
bool IsItalic;
uint32_t Charset;
};
- Optional<FontInfo> Font;
+ std::optional<FontInfo> Font;
IntOrString Class;
ObjectInfo()
using BundleKey = std::pair<uint16_t, uint16_t>;
// Each bundle is in fact an array of 16 strings.
struct Bundle {
- std::array<Optional<std::vector<StringRef>>, 16> Data;
+ std::array<std::optional<std::vector<StringRef>>, 16> Data;
ObjectInfo DeclTimeInfo;
uint16_t MemoryFlags;
Bundle(const ObjectInfo &Info, uint16_t Flags)
RETURN_IF_ERROR(consumeType(Kind::Comma));
IntOrString Class;
- Optional<IntWithNotMask> Style;
+ std::optional<IntWithNotMask> Style;
if (ClassUpper == "CONTROL") {
// CONTROL text, id, class, style, x, y, width, height [, exstyle] [, helpID]
ASSIGN_OR_RETURN(ClassStr, readString());
}
}
- Optional<uint32_t> ExStyle;
+ std::optional<uint32_t> ExStyle;
if (consumeOptionalType(Kind::Comma)) {
ASSIGN_OR_RETURN(Val, readInt());
ExStyle = *Val;
}
- Optional<uint32_t> HelpID;
+ std::optional<uint32_t> HelpID;
if (consumeOptionalType(Kind::Comma)) {
ASSIGN_OR_RETURN(Val, readInt());
HelpID = *Val;
StringRef Type;
IntOrString Title;
uint32_t ID, X, Y, Width, Height;
- Optional<IntWithNotMask> Style;
- Optional<uint32_t> ExtStyle, HelpID;
+ std::optional<IntWithNotMask> Style;
+ std::optional<uint32_t> ExtStyle, HelpID;
IntOrString Class;
// Control classes as described in DLGITEMTEMPLATEEX documentation.
Control(StringRef CtlType, IntOrString CtlTitle, uint32_t CtlID,
uint32_t PosX, uint32_t PosY, uint32_t ItemWidth, uint32_t ItemHeight,
- Optional<IntWithNotMask> ItemStyle, Optional<uint32_t> ExtItemStyle,
- Optional<uint32_t> CtlHelpID, IntOrString CtlClass)
+ std::optional<IntWithNotMask> ItemStyle,
+ std::optional<uint32_t> ExtItemStyle,
+ std::optional<uint32_t> 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) {}
/// \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<unsigned>
+std::optional<unsigned>
getPositionInModule(const Instruction *I,
const DenseMap<Instruction *, unsigned> &LLVMInstNum) {
assert(I && "Instruction is nullptr!");
// For each file there is a list of the range where the similarity
// exists.
for (const IRSimilarityCandidate &C : G) {
- Optional<unsigned> Start =
+ std::optional<unsigned> Start =
getPositionInModule((*C.front()).Inst, LLVMInstNum);
- Optional<unsigned> End =
+ std::optional<unsigned> End =
getPositionInModule((*C.back()).Inst, LLVMInstNum);
assert(Start &&
RecursionStatus &operator--();
bool isRecursive() const;
};
- Optional<llvm::DenseMap<int32_t, RecursionStatus>> RecursionDepth;
+ std::optional<llvm::DenseMap<int32_t, RecursionStatus>> RecursionDepth;
};
typedef llvm::DenseMap<uint32_t, FunctionStack> PerThreadFunctionStackMap;