[lldb] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
This commit is contained in:
Kazu Hirata 2022-12-04 16:51:25 -08:00
parent 5fa43db46e
commit 343523d040
134 changed files with 400 additions and 396 deletions

View File

@ -205,7 +205,7 @@ protected:
void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list,
bool skip_prologue, llvm::StringRef log_ident,
uint32_t line = 0,
llvm::Optional<uint16_t> column = llvm::None);
llvm::Optional<uint16_t> column = std::nullopt);
void SetSCMatchesByLine(SearchFilter &, SymbolContextList &, bool,
const char *) = delete;

View File

@ -24,7 +24,7 @@ public:
BreakpointResolverFileLine(
const lldb::BreakpointSP &bkpt, lldb::addr_t offset, bool skip_prologue,
const SourceLocationSpec &location_spec,
llvm::Optional<llvm::StringRef> removed_prefix_opt = llvm::None);
llvm::Optional<llvm::StringRef> removed_prefix_opt = std::nullopt);
static BreakpointResolver *
CreateFromStructuredData(const lldb::BreakpointSP &bkpt,

View File

@ -107,13 +107,13 @@ private:
/// it is out of date.
struct CacheSignature {
/// UUID of object file or module.
llvm::Optional<UUID> m_uuid = llvm::None;
llvm::Optional<UUID> m_uuid = std::nullopt;
/// Modification time of file on disk.
llvm::Optional<std::time_t> m_mod_time = llvm::None;
llvm::Optional<std::time_t> m_mod_time = std::nullopt;
/// If this describes a .o file with a BSD archive, the BSD archive's
/// modification time will be in m_mod_time, and the .o file's modification
/// time will be in this m_obj_mod_time.
llvm::Optional<std::time_t> m_obj_mod_time = llvm::None;
llvm::Optional<std::time_t> m_obj_mod_time = std::nullopt;
CacheSignature() = default;
@ -124,9 +124,9 @@ struct CacheSignature {
CacheSignature(lldb_private::ObjectFile *objfile);
void Clear() {
m_uuid = llvm::None;
m_mod_time = llvm::None;
m_obj_mod_time = llvm::None;
m_uuid = std::nullopt;
m_mod_time = std::nullopt;
m_obj_mod_time = std::nullopt;
}
/// Return true only if the CacheSignature is valid.

View File

@ -402,7 +402,7 @@ public:
/// ensure the given warning is only broadcast once.
static void
ReportWarning(std::string message,
llvm::Optional<lldb::user_id_t> debugger_id = llvm::None,
llvm::Optional<lldb::user_id_t> debugger_id = std::nullopt,
std::once_flag *once = nullptr);
/// Report error events.
@ -424,7 +424,7 @@ public:
/// ensure the given error is only broadcast once.
static void
ReportError(std::string message,
llvm::Optional<lldb::user_id_t> debugger_id = llvm::None,
llvm::Optional<lldb::user_id_t> debugger_id = std::nullopt,
std::once_flag *once = nullptr);
/// Report info events.
@ -444,7 +444,7 @@ public:
/// ensure the given info is only logged once.
static void
ReportInfo(std::string message,
llvm::Optional<lldb::user_id_t> debugger_id = llvm::None,
llvm::Optional<lldb::user_id_t> debugger_id = std::nullopt,
std::once_flag *once = nullptr);
static void ReportSymbolChange(const ModuleSpec &module_spec);

View File

@ -47,7 +47,7 @@ public:
/// Whether to look for an exact match.
///
explicit SourceLocationSpec(FileSpec file_spec, uint32_t line,
llvm::Optional<uint16_t> column = llvm::None,
llvm::Optional<uint16_t> column = std::nullopt,
bool check_inlines = false,
bool exact_match = false);

View File

@ -437,10 +437,10 @@ private:
class SerialPort : public NativeFile {
public:
struct Options {
llvm::Optional<unsigned int> BaudRate = llvm::None;
llvm::Optional<Terminal::Parity> Parity = llvm::None;
llvm::Optional<Terminal::ParityCheck> ParityCheck = llvm::None;
llvm::Optional<unsigned int> StopBits = llvm::None;
llvm::Optional<unsigned int> BaudRate = std::nullopt;
llvm::Optional<Terminal::Parity> Parity = std::nullopt;
llvm::Optional<Terminal::ParityCheck> ParityCheck = std::nullopt;
llvm::Optional<unsigned int> StopBits = std::nullopt;
};
// Obtain Options corresponding to the passed URL query string

View File

@ -627,7 +627,7 @@ public:
/// \return \b true if the session transcript was successfully written to
/// disk, \b false otherwise.
bool SaveTranscript(CommandReturnObject &result,
llvm::Optional<std::string> output_file = llvm::None);
llvm::Optional<std::string> output_file = std::nullopt);
FileSpec GetCurrentSourceDir();

View File

@ -279,7 +279,7 @@ public:
/// If the string is empty, the command won't be allow repeating.
virtual llvm::Optional<std::string>
GetRepeatCommand(Args &current_command_args, uint32_t index) {
return llvm::None;
return std::nullopt;
}
bool HasOverrideCallback() const {

View File

@ -63,7 +63,7 @@ public:
virtual bool IsAlive() { return true; }
virtual llvm::Optional<std::string> GetScriptedThreadPluginName() {
return llvm::None;
return std::nullopt;
}
virtual StructuredData::DictionarySP GetMetadata() { return {}; }
@ -86,11 +86,11 @@ public:
virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }
virtual llvm::Optional<std::string> GetName() { return llvm::None; }
virtual llvm::Optional<std::string> GetName() { return std::nullopt; }
virtual lldb::StateType GetState() { return lldb::eStateInvalid; }
virtual llvm::Optional<std::string> GetQueue() { return llvm::None; }
virtual llvm::Optional<std::string> GetQueue() { return std::nullopt; }
virtual StructuredData::DictionarySP GetStopReason() { return {}; }
@ -99,7 +99,7 @@ public:
virtual StructuredData::DictionarySP GetRegisterInfo() { return {}; }
virtual llvm::Optional<std::string> GetRegisterContext() {
return llvm::None;
return std::nullopt;
}
virtual StructuredData::ArraySP GetExtendedInfo() { return {}; }

View File

@ -572,7 +572,7 @@ private:
/// \return The found type system or an error.
llvm::Expected<lldb::TypeSystemSP> GetTypeSystemForLanguage(
lldb::LanguageType language,
llvm::Optional<CreateCallback> create_callback = llvm::None);
llvm::Optional<CreateCallback> create_callback = std::nullopt);
};
} // namespace lldb_private

View File

@ -151,7 +151,7 @@ public:
virtual bool IsAllowedRuntimeValue(ConstString name) { return false; }
virtual llvm::Optional<CompilerType> GetRuntimeType(CompilerType base_type) {
return llvm::None;
return std::nullopt;
}
void ModulesDidLoad(const ModuleList &module_list) override {}

View File

@ -232,11 +232,11 @@ public:
virtual bool GetRemoteOSVersion() { return false; }
virtual llvm::Optional<std::string> GetRemoteOSBuildString() {
return llvm::None;
return std::nullopt;
}
virtual llvm::Optional<std::string> GetRemoteOSKernelDescription() {
return llvm::None;
return std::nullopt;
}
// Remote Platform subclasses need to override this function

View File

@ -455,7 +455,7 @@ private:
lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
Timeout<std::micro> m_timeout = default_timeout;
Timeout<std::micro> m_one_thread_timeout = llvm::None;
Timeout<std::micro> m_one_thread_timeout = std::nullopt;
lldb::ExpressionCancelCallback m_cancel_callback = nullptr;
void *m_cancel_callback_baton = nullptr;
// If m_pound_line_file is not empty and m_pound_line_line is non-zero, use

View File

@ -39,10 +39,10 @@ struct TraceDumperOptions {
/// For each instruction, print the instruction kind.
bool show_control_flow_kind = false;
/// Optional custom id to start traversing from.
llvm::Optional<uint64_t> id = llvm::None;
llvm::Optional<uint64_t> id = std::nullopt;
/// Optional number of instructions to skip from the starting position
/// of the cursor.
llvm::Optional<size_t> skip = llvm::None;
llvm::Optional<size_t> skip = std::nullopt;
};
/// Class used to dump the instructions of a \a TraceCursor using its current

View File

@ -112,7 +112,7 @@ public:
ConstString GetFlavor() const override { return GetFlavorString(); }
bool WaitForEventReceived(const Timeout<std::micro> &timeout = llvm::None) {
bool WaitForEventReceived(const Timeout<std::micro> &timeout = std::nullopt) {
return m_predicate.WaitForValueEqualTo(true, timeout);
}

View File

@ -127,7 +127,7 @@ public:
}
if (m_condition.wait_for(lock, *timeout, RealCond))
return m_value;
return llvm::None;
return std::nullopt;
}
/// Wait for \a m_value to be equal to \a value.
///
@ -152,9 +152,9 @@ public:
/// true if the \a m_value is equal to \a value, false otherwise (timeout
/// occurred).
bool WaitForValueEqualTo(T value,
const Timeout<std::micro> &timeout = llvm::None) {
const Timeout<std::micro> &timeout = std::nullopt) {
return WaitFor([&value](T current) { return value == current; }, timeout) !=
llvm::None;
std::nullopt;
}
/// Wait for \a m_value to not be equal to \a value.
@ -180,7 +180,7 @@ public:
/// m_value if m_value != value, None otherwise (timeout occurred).
llvm::Optional<T>
WaitForValueNotEqualTo(T value,
const Timeout<std::micro> &timeout = llvm::None) {
const Timeout<std::micro> &timeout = std::nullopt) {
return WaitFor([&value](T current) { return value != current; }, timeout);
}

View File

@ -41,7 +41,7 @@ public:
template <typename Ratio2,
typename = typename EnableIf<int64_t, Ratio2>::type>
Timeout(const Timeout<Ratio2> &other)
: Base(other ? Base(Dur<Ratio>(*other)) : llvm::None) {}
: Base(other ? Base(Dur<Ratio>(*other)) : std::nullopt) {}
template <typename Rep2, typename Ratio2,
typename = typename EnableIf<Rep2, Ratio2>::type>

View File

@ -45,7 +45,7 @@ public:
m_backend(backend) {
m_auto_repeat_command =
auto_repeat_command == nullptr
? llvm::None
? std::nullopt
: llvm::Optional<std::string>(auto_repeat_command);
// We don't know whether any given command coming from this interface takes
// arguments or not so here we're just disabling the basic args check.
@ -62,7 +62,7 @@ public:
llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
uint32_t index) override {
if (!m_auto_repeat_command)
return llvm::None;
return std::nullopt;
else
return m_auto_repeat_command;
}

View File

@ -107,7 +107,7 @@ size_t SBCommunication::Read(void *dst, size_t dst_len, uint32_t timeout_usec,
size_t bytes_read = 0;
Timeout<std::micro> timeout = timeout_usec == UINT32_MAX
? Timeout<std::micro>(llvm::None)
? Timeout<std::micro>(std::nullopt)
: std::chrono::microseconds(timeout_usec);
if (m_opaque)
bytes_read = m_opaque->Read(dst, dst_len, timeout, status, nullptr);

View File

@ -94,7 +94,7 @@ uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
LLDB_INSTRUMENT_VA(this, timeout);
m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(std::nullopt)
: std::chrono::microseconds(timeout));
}
@ -110,7 +110,7 @@ void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
LLDB_INSTRUMENT_VA(this, timeout);
m_opaque_up->SetOneThreadTimeout(timeout == 0
? Timeout<std::micro>(llvm::None)
? Timeout<std::micro>(std::nullopt)
: std::chrono::microseconds(timeout));
}

View File

@ -132,7 +132,7 @@ bool SBListener::WaitForEvent(uint32_t timeout_secs, SBEvent &event) {
bool success = false;
if (m_opaque_sp) {
Timeout<std::micro> timeout(llvm::None);
Timeout<std::micro> timeout(std::nullopt);
if (timeout_secs != UINT32_MAX) {
assert(timeout_secs != 0); // Take this out after all calls with timeout
// set to zero have been removed....
@ -156,7 +156,7 @@ bool SBListener::WaitForEventForBroadcaster(uint32_t num_seconds,
LLDB_INSTRUMENT_VA(this, num_seconds, broadcaster, event);
if (m_opaque_sp && broadcaster.IsValid()) {
Timeout<std::micro> timeout(llvm::None);
Timeout<std::micro> timeout(std::nullopt);
if (num_seconds != UINT32_MAX)
timeout = std::chrono::seconds(num_seconds);
EventSP event_sp;
@ -176,7 +176,7 @@ bool SBListener::WaitForEventForBroadcasterWithType(
LLDB_INSTRUMENT_VA(this, num_seconds, broadcaster, event_type_mask, event);
if (m_opaque_sp && broadcaster.IsValid()) {
Timeout<std::micro> timeout(llvm::None);
Timeout<std::micro> timeout(std::nullopt);
if (num_seconds != UINT32_MAX)
timeout = std::chrono::seconds(num_seconds);
EventSP event_sp;

View File

@ -69,7 +69,7 @@ struct PlatformShellCommand {
std::string m_output;
int m_status = 0;
int m_signo = 0;
Timeout<std::ratio<1>> m_timeout = llvm::None;
Timeout<std::ratio<1>> m_timeout = std::nullopt;
};
// SBPlatformConnectOptions
SBPlatformConnectOptions::SBPlatformConnectOptions(const char *url)
@ -261,7 +261,7 @@ void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) {
LLDB_INSTRUMENT_VA(this, sec);
if (sec == UINT32_MAX)
m_opaque_ptr->m_timeout = llvm::None;
m_opaque_ptr->m_timeout = std::nullopt;
else
m_opaque_ptr->m_timeout = std::chrono::seconds(sec);
}

View File

@ -837,7 +837,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
const bool stop_other_threads = false;
// TODO: Handle SourceLocationSpec column information
SourceLocationSpec location_spec(
step_file_spec, line, /*column=*/llvm::None, /*check_inlines=*/true,
step_file_spec, line, /*column=*/std::nullopt, /*check_inlines=*/true,
/*exact_match=*/false);
SymbolContextList sc_list;

View File

@ -68,21 +68,21 @@ BreakpointID::ParseCanonicalReference(llvm::StringRef input) {
break_id_t loc_id = LLDB_INVALID_BREAK_ID;
if (input.empty())
return llvm::None;
return std::nullopt;
// If it doesn't start with an integer, it's not valid.
if (input.consumeInteger(0, bp_id))
return llvm::None;
return std::nullopt;
// period is optional, but if it exists, it must be followed by a number.
if (input.consume_front(".")) {
if (input.consumeInteger(0, loc_id))
return llvm::None;
return std::nullopt;
}
// And at the end, the entire string must have been consumed.
if (!input.empty())
return llvm::None;
return std::nullopt;
return BreakpointID(bp_id, loc_id);
}

View File

@ -210,7 +210,7 @@ void BreakpointResolverFileLine::DeduceSourceMapping(
return a;
}
}
return llvm::None;
return std::nullopt;
};
FileSpec request_file = m_location_spec.GetFileSpec();

View File

@ -109,7 +109,7 @@ Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback(
SymbolContextList sc_list;
// TODO: Handle SourceLocationSpec column information
SourceLocationSpec location_spec(cu_file_spec, line_matches[i],
/*column=*/llvm::None,
/*column=*/std::nullopt,
/*check_inlines=*/false, m_exact_match);
cu->ResolveSymbolContext(location_spec, eSymbolContextEverything, sc_list);
// Find all the function names:

View File

@ -374,7 +374,7 @@ CommandObjectExpression::GetEvalOptions(const Target &target) {
if (m_command_options.timeout > 0)
options.SetTimeout(std::chrono::microseconds(m_command_options.timeout));
else
options.SetTimeout(llvm::None);
options.SetTimeout(std::nullopt);
return options;
}
@ -540,7 +540,7 @@ GetExprOptions(ExecutionContext &ctx,
if (command_options.timeout > 0)
expr_options.SetTimeout(std::chrono::microseconds(command_options.timeout));
else
expr_options.SetTimeout(llvm::None);
expr_options.SetTimeout(std::nullopt);
return expr_options;
}

View File

@ -295,11 +295,11 @@ CommandObjectMultiword::GetRepeatCommand(Args &current_command_args,
uint32_t index) {
index++;
if (current_command_args.GetArgumentCount() <= index)
return llvm::None;
return std::nullopt;
CommandObject *sub_command_object =
GetSubcommandObject(current_command_args[index].ref());
if (sub_command_object == nullptr)
return llvm::None;
return std::nullopt;
return sub_command_object->GetRepeatCommand(current_command_args, index);
}
@ -426,7 +426,7 @@ CommandObjectProxy::GetRepeatCommand(Args &current_command_args,
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->GetRepeatCommand(current_command_args, index);
return llvm::None;
return std::nullopt;
}
llvm::StringRef CommandObjectProxy::GetUnsupportedError() {

View File

@ -147,21 +147,21 @@ public:
if (arg_string.equals("-c") || count_opt.startswith(arg_string)) {
idx++;
if (idx == num_entries)
return llvm::None;
return std::nullopt;
count_idx = idx;
if (copy_args[idx].ref().getAsInteger(0, count_val))
return llvm::None;
return std::nullopt;
} else if (arg_string.equals("-s") || start_opt.startswith(arg_string)) {
idx++;
if (idx == num_entries)
return llvm::None;
return std::nullopt;
start_idx = idx;
if (copy_args[idx].ref().getAsInteger(0, start_val))
return llvm::None;
return std::nullopt;
}
}
if (count_idx == 0)
return llvm::None;
return std::nullopt;
std::string new_start_val = llvm::formatv("{0}", start_val + count_val);
if (start_idx == 0) {
@ -172,7 +172,7 @@ public:
}
std::string repeat_command;
if (!copy_args.GetQuotedCommandString(repeat_command))
return llvm::None;
return std::nullopt;
return repeat_command;
}
@ -2149,7 +2149,7 @@ public:
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_dumper_options = {};
m_output_file = llvm::None;
m_output_file = std::nullopt;
}
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@ -2321,7 +2321,7 @@ public:
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_count = kDefaultCount;
m_continue = false;
m_output_file = llvm::None;
m_output_file = std::nullopt;
m_dumper_options = {};
}

View File

@ -1083,7 +1083,7 @@ protected:
options.SetUnwindOnError(true);
options.SetKeepInMemory(false);
options.SetTryAllThreads(true);
options.SetTimeout(llvm::None);
options.SetTimeout(std::nullopt);
ExpressionResults expr_result =
target->EvaluateExpression(expr, frame, valobj_sp, options);

View File

@ -1732,7 +1732,7 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
bool done = false;
while (!done) {
EventSP event_sp;
if (listener_sp->GetEvent(event_sp, llvm::None)) {
if (listener_sp->GetEvent(event_sp, std::nullopt)) {
if (event_sp) {
Broadcaster *broadcaster = event_sp->GetBroadcaster();
if (broadcaster) {
@ -1827,7 +1827,7 @@ bool Debugger::StartEventHandlerThread() {
// event, we just need to wait an infinite amount of time for it (nullptr
// timeout as the first parameter)
lldb::EventSP event_sp;
listener_sp->GetEvent(event_sp, llvm::None);
listener_sp->GetEvent(event_sp, std::nullopt);
}
return m_event_handler_thread.IsJoinable();
}

View File

@ -54,7 +54,7 @@ static llvm::Optional<llvm::APInt> GetAPInt(const DataExtractor &data,
lldb::offset_t *offset_ptr,
lldb::offset_t byte_size) {
if (byte_size == 0)
return llvm::None;
return std::nullopt;
llvm::SmallVector<uint64_t, 2> uint64_array;
lldb::offset_t bytes_left = byte_size;
@ -92,7 +92,7 @@ static llvm::Optional<llvm::APInt> GetAPInt(const DataExtractor &data,
*offset_ptr += byte_size;
return llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
}
return llvm::None;
return std::nullopt;
}
static lldb::offset_t DumpAPInt(Stream *s, const DataExtractor &data,
@ -244,21 +244,21 @@ GetMemoryTags(lldb::addr_t addr, size_t length,
assert(addr != LLDB_INVALID_ADDRESS);
if (!exe_scope)
return llvm::None;
return std::nullopt;
TargetSP target_sp = exe_scope->CalculateTarget();
if (!target_sp)
return llvm::None;
return std::nullopt;
ProcessSP process_sp = target_sp->CalculateProcess();
if (!process_sp)
return llvm::None;
return std::nullopt;
llvm::Expected<const MemoryTagManager *> tag_manager_or_err =
process_sp->GetMemoryTagManager();
if (!tag_manager_or_err) {
llvm::consumeError(tag_manager_or_err.takeError());
return llvm::None;
return std::nullopt;
}
MemoryRegionInfos memory_regions;
@ -272,10 +272,10 @@ GetMemoryTags(lldb::addr_t addr, size_t length,
// for an error.
if (!tagged_ranges_or_err) {
llvm::consumeError(tagged_ranges_or_err.takeError());
return llvm::None;
return std::nullopt;
}
if (tagged_ranges_or_err->empty())
return llvm::None;
return std::nullopt;
MemoryTagMap memory_tag_map(*tag_manager_or_err);
for (const MemoryTagManager::TagRange &range : *tagged_ranges_or_err) {
@ -289,7 +289,7 @@ GetMemoryTags(lldb::addr_t addr, size_t length,
}
if (memory_tag_map.Empty())
return llvm::None;
return std::nullopt;
return memory_tag_map;
}

View File

@ -330,7 +330,7 @@ void IOHandlerEditline::TerminalSizeChanged() {
static Optional<std::string> SplitLine(std::string &line_buffer) {
size_t pos = line_buffer.find('\n');
if (pos == std::string::npos)
return None;
return std::nullopt;
std::string line =
std::string(StringRef(line_buffer.c_str(), pos).rtrim("\n\r"));
line_buffer = line_buffer.substr(pos + 1);
@ -341,7 +341,7 @@ static Optional<std::string> SplitLine(std::string &line_buffer) {
// it as a line anyway.
static Optional<std::string> SplitLineEOF(std::string &line_buffer) {
if (llvm::all_of(line_buffer, llvm::isSpace))
return None;
return std::nullopt;
std::string line = std::move(line_buffer);
line_buffer.clear();
return line;

View File

@ -596,7 +596,7 @@ uint32_t Module::ResolveSymbolContextsForFileSpec(
if (SymbolFile *symbols = GetSymbolFile()) {
// TODO: Handle SourceLocationSpec column information
SourceLocationSpec location_spec(file_spec, line, /*column=*/llvm::None,
SourceLocationSpec location_spec(file_spec, line, /*column=*/std::nullopt,
check_inlines, /*exact_match=*/false);
symbols->ResolveSymbolContext(location_spec, resolve_scope, sc_list);
@ -937,7 +937,7 @@ void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
SearchFilterByModule filter(target_sp, m_file);
// TODO: Handle SourceLocationSpec column information
SourceLocationSpec location_spec(file, line, /*column=*/llvm::None,
SourceLocationSpec location_spec(file, line, /*column=*/std::nullopt,
/*check_inlines=*/true,
/*exact_match=*/false);
AddressResolverFileLine resolver(location_spec);

View File

@ -69,13 +69,13 @@ std::string SourceLocationSpec::GetString() const {
llvm::Optional<uint32_t> SourceLocationSpec::GetLine() const {
uint32_t line = m_declaration.GetLine();
if (line == 0 || line == LLDB_INVALID_LINE_NUMBER)
return llvm::None;
return std::nullopt;
return line;
}
llvm::Optional<uint16_t> SourceLocationSpec::GetColumn() const {
uint16_t column = m_declaration.GetColumn();
if (column == LLDB_INVALID_COLUMN_NUMBER)
return llvm::None;
return std::nullopt;
return column;
}

View File

@ -362,7 +362,7 @@ void ThreadedCommunication::SynchronizeWithReadThread() {
// Wait for the synchronization event.
EventSP event_sp;
listener_sp->GetEvent(event_sp, llvm::None);
listener_sp->GetEvent(event_sp, std::nullopt);
}
void ThreadedCommunication::SetConnection(

View File

@ -704,7 +704,7 @@ public:
llvm::Optional<lldb::addr_t> Resolve(SymbolContextList &sc_list) {
if (sc_list.IsEmpty())
return llvm::None;
return std::nullopt;
lldb::addr_t load_address = LLDB_INVALID_ADDRESS;
@ -758,7 +758,7 @@ public:
if (m_symbol_was_missing_weak)
return 0;
return llvm::None;
return std::nullopt;
}
lldb::addr_t GetBestInternalLoadAddress() const {

View File

@ -582,12 +582,12 @@ int Editline::GetCharacter(EditLineGetCharType *c) {
// interrupted.
m_output_mutex.unlock();
int read_count =
m_input_connection.Read(&ch, 1, llvm::None, status, nullptr);
m_input_connection.Read(&ch, 1, std::nullopt, status, nullptr);
m_output_mutex.lock();
if (m_editor_status == EditorStatus::Interrupted) {
while (read_count > 0 && status == lldb::eConnectionStatusSuccess)
read_count =
m_input_connection.Read(&ch, 1, llvm::None, status, nullptr);
m_input_connection.Read(&ch, 1, std::nullopt, status, nullptr);
lldbassert(status == lldb::eConnectionStatusInterrupted);
return 0;
}

View File

@ -783,7 +783,7 @@ SerialPort::OptionsFromURL(llvm::StringRef urlqs) {
.Case("odd", Terminal::Parity::Odd)
.Case("mark", Terminal::Parity::Mark)
.Case("space", Terminal::Parity::Space)
.Default(llvm::None);
.Default(std::nullopt);
if (!serial_options.Parity)
return llvm::createStringError(
llvm::inconvertibleErrorCode(),
@ -798,7 +798,7 @@ SerialPort::OptionsFromURL(llvm::StringRef urlqs) {
// "mark" mode is not currently supported as it requires special
// input processing
// .Case("mark", Terminal::ParityCheck::Mark)
.Default(llvm::None);
.Default(std::nullopt);
if (!serial_options.ParityCheck)
return llvm::createStringError(
llvm::inconvertibleErrorCode(),

View File

@ -113,7 +113,7 @@ HostInfoBase::ParseArchitectureKind(llvm::StringRef kind) {
.Case(LLDB_ARCH_DEFAULT, eArchKindDefault)
.Case(LLDB_ARCH_DEFAULT_32BIT, eArchKind32)
.Case(LLDB_ARCH_DEFAULT_64BIT, eArchKind64)
.Default(llvm::None);
.Default(std::nullopt);
}
FileSpec HostInfoBase::GetShlibDir() {

View File

@ -70,7 +70,7 @@ llvm::Optional<WaitStatus> NativeProcessProtocol::GetExitStatus() {
if (m_state == lldb::eStateExited)
return m_exit_status;
return llvm::None;
return std::nullopt;
}
bool NativeProcessProtocol::SetExitStatus(WaitStatus status,
@ -136,7 +136,7 @@ NativeProcessProtocol::GetHardwareDebugSupportInfo() const {
const_cast<NativeProcessProtocol *>(this)->GetThreadAtIndex(0));
if (!thread) {
LLDB_LOG(log, "failed to find a thread to grab a NativeRegisterContext!");
return llvm::None;
return std::nullopt;
}
NativeRegisterContext &reg_ctx = thread->GetRegisterContext();
@ -245,7 +245,7 @@ Status NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr,
// Exit here if target does not have required hardware breakpoint capability.
auto hw_debug_cap = GetHardwareDebugSupportInfo();
if (hw_debug_cap == llvm::None || hw_debug_cap->first == 0 ||
if (hw_debug_cap == std::nullopt || hw_debug_cap->first == 0 ||
hw_debug_cap->first <= m_hw_breakpoints_map.size())
return Status("Target does not have required no of hardware breakpoints");

View File

@ -264,7 +264,7 @@ static llvm::Optional<speed_t> baudRateToConst(unsigned int baud_rate) {
return B4000000;
#endif
default:
return llvm::None;
return std::nullopt;
}
}
#endif

View File

@ -324,6 +324,6 @@ llvm::Optional<lldb::pid_t> lldb_private::getPIDForTID(lldb::pid_t tid) {
if (!GetStatusInfo(tid, process_info, state, tracerpid, tgid) ||
tgid == LLDB_INVALID_PROCESS_ID)
return llvm::None;
return std::nullopt;
return tgid;
}

View File

@ -71,7 +71,7 @@ llvm::Optional<std::string> HostInfoLinux::GetOSBuildString() {
::memset(&un, 0, sizeof(utsname));
if (uname(&un) < 0)
return llvm::None;
return std::nullopt;
return std::string(un.release);
}

View File

@ -41,7 +41,7 @@ bool HostInfoPosix::GetHostname(std::string &s) {
llvm::Optional<std::string> HostInfoPosix::GetOSKernelDescription() {
struct utsname un;
if (uname(&un) < 0)
return llvm::None;
return std::nullopt;
return std::string(un.version);
}
@ -85,13 +85,13 @@ static llvm::Optional<PasswdEntry> GetPassword(id_t uid) {
return PasswdEntry{user_info_ptr->pw_name, user_info_ptr->pw_shell};
}
#endif
return llvm::None;
return std::nullopt;
}
llvm::Optional<std::string> PosixUserIDResolver::DoGetUserName(id_t uid) {
if (llvm::Optional<PasswdEntry> password = GetPassword(uid))
return password->username;
return llvm::None;
return std::nullopt;
}
llvm::Optional<std::string> PosixUserIDResolver::DoGetGroupName(id_t gid) {
@ -113,7 +113,7 @@ llvm::Optional<std::string> PosixUserIDResolver::DoGetGroupName(id_t gid) {
return std::string(group_info_ptr->gr_name);
}
#endif
return llvm::None;
return std::nullopt;
}
static llvm::ManagedStatic<PosixUserIDResolver> g_user_id_resolver;

View File

@ -27,14 +27,14 @@ llvm::Optional<llvm::StringRef>
CommandHistory::FindString(llvm::StringRef input_str) const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (input_str.size() < 2)
return llvm::None;
return std::nullopt;
if (input_str[0] != g_repeat_char)
return llvm::None;
return std::nullopt;
if (input_str[1] == g_repeat_char) {
if (m_history.empty())
return llvm::None;
return std::nullopt;
return llvm::StringRef(m_history.back());
}
@ -43,15 +43,15 @@ CommandHistory::FindString(llvm::StringRef input_str) const {
size_t idx = 0;
if (input_str.front() == '-') {
if (input_str.drop_front(1).getAsInteger(0, idx))
return llvm::None;
return std::nullopt;
if (idx >= m_history.size())
return llvm::None;
return std::nullopt;
idx = m_history.size() - idx;
} else {
if (input_str.getAsInteger(0, idx))
return llvm::None;
return std::nullopt;
if (idx >= m_history.size())
return llvm::None;
return std::nullopt;
}
return llvm::StringRef(m_history[idx]);

View File

@ -1764,7 +1764,7 @@ Status CommandInterpreter::PreprocessCommand(std::string &command) {
options.SetIgnoreBreakpoints(true);
options.SetKeepInMemory(false);
options.SetTryAllThreads(true);
options.SetTimeout(llvm::None);
options.SetTimeout(std::nullopt);
ExpressionResults expr_result =
target.EvaluateExpression(expr_str.c_str(), exe_ctx.GetFramePtr(),
@ -2113,14 +2113,14 @@ void CommandInterpreter::HandleCompletion(CompletionRequest &request) {
llvm::Optional<std::string>
CommandInterpreter::GetAutoSuggestionForCommand(llvm::StringRef line) {
if (line.empty())
return llvm::None;
return std::nullopt;
const size_t s = m_command_history.GetSize();
for (int i = s - 1; i >= 0; --i) {
llvm::StringRef entry = m_command_history.GetStringAtIndex(i);
if (entry.consume_front(line))
return entry.str();
}
return llvm::None;
return std::nullopt;
}
void CommandInterpreter::UpdatePrompt(llvm::StringRef new_prompt) {
@ -3192,7 +3192,7 @@ bool CommandInterpreter::IOHandlerInterrupt(IOHandler &io_handler) {
bool CommandInterpreter::SaveTranscript(
CommandReturnObject &result, llvm::Optional<std::string> output_file) {
if (output_file == llvm::None || output_file->empty()) {
if (output_file == std::nullopt || output_file->empty()) {
std::string now = llvm::to_string(std::chrono::system_clock::now());
std::replace(now.begin(), now.end(), ' ', '_');
const std::string file_name = "lldb_session_" + now + ".log";

View File

@ -91,7 +91,7 @@ llvm::Optional<MemoryRegionInfo>
ScriptInterpreter::GetOpaqueTypeFromSBMemoryRegionInfo(
const lldb::SBMemoryRegionInfo &mem_region) const {
if (!mem_region.m_opaque_up)
return llvm::None;
return std::nullopt;
return *mem_region.m_opaque_up.get();
}

View File

@ -266,7 +266,7 @@ InstructionLengthDecode(const uint8_t *inst_bytes, int bytes_len,
// in `src/pt_ild.c`
while (!prefix_done) {
if (op_idx >= bytes_len)
return llvm::None;
return std::nullopt;
ret.primary_opcode = inst_bytes[op_idx];
switch (ret.primary_opcode) {

View File

@ -921,9 +921,9 @@ private:
// We also filter some internal lldb identifiers here. The user
// shouldn't see these.
if (llvm::StringRef(ToInsert).startswith("$__lldb_"))
return llvm::None;
return std::nullopt;
if (ToInsert.empty())
return llvm::None;
return std::nullopt;
// Merge the suggested Token into the existing command line to comply
// with the kind of result the lldb API expects.
std::string CompletionSuggestion =

View File

@ -74,14 +74,14 @@ ClangPersistentVariables::GetCompilerTypeFromPersistentDecl(
PersistentDecl p = m_persistent_decls.lookup(type_name.GetCString());
if (p.m_decl == nullptr)
return llvm::None;
return std::nullopt;
if (clang::TypeDecl *tdecl = llvm::dyn_cast<clang::TypeDecl>(p.m_decl)) {
opaque_compiler_type_t t = static_cast<opaque_compiler_type_t>(
const_cast<clang::Type *>(tdecl->getTypeForDecl()));
return CompilerType(p.m_context, t);
}
return llvm::None;
return std::nullopt;
}
void ClangPersistentVariables::RegisterPersistentDecl(ConstString name,

View File

@ -50,10 +50,10 @@ getTargetIncludePaths(const llvm::Triple &triple) {
static llvm::Optional<llvm::StringRef>
guessIncludePath(llvm::StringRef path_to_file, llvm::StringRef pattern) {
if (pattern.empty())
return llvm::None;
return std::nullopt;
size_t pos = path_to_file.find(pattern);
if (pos == llvm::StringRef::npos)
return llvm::None;
return std::nullopt;
return path_to_file.substr(0, pos + pattern.size());
}

View File

@ -186,21 +186,21 @@ llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
// If we don't have a template to instiantiate, then there is nothing to do.
auto td = dyn_cast<ClassTemplateSpecializationDecl>(d);
if (!td)
return llvm::None;
return std::nullopt;
// We only care about templates in the std namespace.
if (!td->getDeclContext()->isStdNamespace())
return llvm::None;
return std::nullopt;
// We have a list of supported template names.
if (!m_supported_templates.contains(td->getName()))
return llvm::None;
return std::nullopt;
// Early check if we even support instantiating this template. We do this
// before we import anything into the target AST.
auto &foreign_args = td->getTemplateInstantiationArgs();
if (!templateArgsAreSupported(foreign_args.asArray()))
return llvm::None;
return std::nullopt;
// Find the local DeclContext that corresponds to the DeclContext of our
// decl we want to import.
@ -211,7 +211,7 @@ llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
"Got error while searching equal local DeclContext for decl "
"'{1}':\n{0}",
td->getName());
return llvm::None;
return std::nullopt;
}
// Look up the template in our local context.
@ -224,7 +224,7 @@ llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
break;
}
if (!new_class_template)
return llvm::None;
return std::nullopt;
// Import the foreign template arguments.
llvm::SmallVector<TemplateArgument, 4> imported_args;
@ -236,7 +236,7 @@ llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
llvm::Expected<QualType> type = m_importer->Import(arg.getAsType());
if (!type) {
LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
return llvm::None;
return std::nullopt;
}
imported_args.push_back(TemplateArgument(*type));
break;
@ -247,7 +247,7 @@ llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
m_importer->Import(arg.getIntegralType());
if (!type) {
LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
return llvm::None;
return std::nullopt;
}
imported_args.push_back(
TemplateArgument(d->getASTContext(), integral, *type));

View File

@ -39,7 +39,7 @@ static llvm::Optional<std::tuple<Ts...>> zipOpt(llvm::Optional<Ts> &&...ts) {
return llvm::Optional<std::tuple<Ts...>>(
std::make_tuple(std::move(*ts)...));
else
return llvm::None;
return std::nullopt;
}
// The funct3 is the type of compare in B<CMP> instructions.
@ -134,7 +134,7 @@ llvm::Optional<uint64_t> Rs::Read(EmulateInstructionRISCV &emulator) {
RegisterValue value;
return emulator.ReadRegister(eRegisterKindLLDB, lldbReg, value)
? llvm::Optional<uint64_t>(value.GetAsUInt64())
: llvm::None;
: std::nullopt;
}
llvm::Optional<int32_t> Rs::ReadI32(EmulateInstructionRISCV &emulator) {
@ -157,7 +157,7 @@ llvm::Optional<llvm::APFloat> Rs::ReadAPFloat(EmulateInstructionRISCV &emulator,
uint32_t lldbReg = FPREncodingToLLDB(rs);
RegisterValue value;
if (!emulator.ReadRegister(eRegisterKindLLDB, lldbReg, value))
return llvm::None;
return std::nullopt;
uint64_t bits = value.GetAsUInt64();
llvm::APInt api(64, bits, false);
return llvm::APFloat(isDouble ? llvm::APFloat(api.bitsToDouble())
@ -251,9 +251,9 @@ static std::enable_if_t<is_amo_add<I> || is_amo_bit_op<I> || is_amo_swap<I> ||
AtomicAddr(EmulateInstructionRISCV &emulator, I inst, unsigned int align) {
return inst.rs1.Read(emulator)
.transform([&](uint64_t rs1) {
return rs1 % align == 0 ? llvm::Optional<uint64_t>(rs1) : llvm::None;
return rs1 % align == 0 ? llvm::Optional<uint64_t>(rs1) : std::nullopt;
})
.value_or(llvm::None);
.value_or(std::nullopt);
}
template <typename I, typename T>
@ -575,7 +575,7 @@ llvm::Optional<DecodeResult> EmulateInstructionRISCV::Decode(uint32_t inst) {
}
LLDB_LOGF(log, "EmulateInstructionRISCV::%s: inst(0x%x) was unsupported",
__FUNCTION__, inst);
return llvm::None;
return std::nullopt;
}
class Executor {
@ -1467,7 +1467,7 @@ llvm::Optional<DecodeResult>
EmulateInstructionRISCV::ReadInstructionAt(lldb::addr_t addr) {
return ReadMem<uint32_t>(addr)
.transform([&](uint32_t inst) { return Decode(inst); })
.value_or(llvm::None);
.value_or(std::nullopt);
}
bool EmulateInstructionRISCV::ReadInstruction() {
@ -1490,7 +1490,7 @@ llvm::Optional<lldb::addr_t> EmulateInstructionRISCV::ReadPC() {
bool success = false;
auto addr = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC,
LLDB_INVALID_ADDRESS, &success);
return success ? llvm::Optional<lldb::addr_t>(addr) : llvm::None;
return success ? llvm::Optional<lldb::addr_t>(addr) : std::nullopt;
}
bool EmulateInstructionRISCV::WritePC(lldb::addr_t pc) {

View File

@ -23,7 +23,7 @@ namespace tok = clang::tok;
Optional<ParsedFunction> CPlusPlusNameParser::ParseAsFunctionDefinition() {
m_next_token_index = 0;
Optional<ParsedFunction> result(None);
Optional<ParsedFunction> result(std::nullopt);
// Try to parse the name as function without a return type specified e.g.
// main(int, char*[])
@ -44,7 +44,7 @@ Optional<ParsedFunction> CPlusPlusNameParser::ParseAsFunctionDefinition() {
// e.g. int main(int, char*[])
result = ParseFunctionImpl(true);
if (HasMoreTokens())
return None;
return std::nullopt;
return result;
}
@ -52,9 +52,9 @@ Optional<ParsedName> CPlusPlusNameParser::ParseAsFullName() {
m_next_token_index = 0;
Optional<ParsedNameRanges> name_ranges = ParseFullNameImpl();
if (!name_ranges)
return None;
return std::nullopt;
if (HasMoreTokens())
return None;
return std::nullopt;
ParsedName result;
result.basename = GetTextForRange(name_ranges.value().basename_range);
result.context = GetTextForRange(name_ranges.value().context_range);
@ -111,7 +111,7 @@ CPlusPlusNameParser::ParseFunctionImpl(bool expect_return_type) {
size_t return_start = GetCurrentPosition();
// Consume return type if it's expected.
if (!ConsumeToken(tok::kw_auto) && !ConsumeTypename())
return None;
return std::nullopt;
size_t return_end = GetCurrentPosition();
result.return_type = GetTextForRange(Range(return_start, return_end));
@ -119,12 +119,12 @@ CPlusPlusNameParser::ParseFunctionImpl(bool expect_return_type) {
auto maybe_name = ParseFullNameImpl();
if (!maybe_name) {
return None;
return std::nullopt;
}
size_t argument_start = GetCurrentPosition();
if (!ConsumeArguments()) {
return None;
return std::nullopt;
}
size_t qualifiers_start = GetCurrentPosition();
@ -155,7 +155,7 @@ CPlusPlusNameParser::ParseFuncPtr(bool expect_return_type) {
if (expect_return_type) {
// Consume return type.
if (!ConsumeTypename())
return None;
return std::nullopt;
}
// Step 2:
@ -165,9 +165,9 @@ CPlusPlusNameParser::ParseFuncPtr(bool expect_return_type) {
// Leaves us with:
// (*func(long))(int))(float)
if (!ConsumeToken(tok::l_paren))
return None;
return std::nullopt;
if (!ConsumePtrsAndRefs())
return None;
return std::nullopt;
// Step 3:
//
@ -214,7 +214,7 @@ CPlusPlusNameParser::ParseFuncPtr(bool expect_return_type) {
return maybe_inner_function_ptr_name;
}
return None;
return std::nullopt;
}
bool CPlusPlusNameParser::ConsumeArguments() {
@ -721,7 +721,7 @@ CPlusPlusNameParser::ParseFullNameImpl() {
start_position.Remove();
return result;
} else {
return None;
return std::nullopt;
}
}

View File

@ -423,18 +423,18 @@ ObjCLanguageRuntime::GetRuntimeType(CompilerType base_type) {
else if (TypeSystemClang::IsObjCObjectOrInterfaceType(base_type))
class_type = base_type;
else
return llvm::None;
return std::nullopt;
if (!class_type)
return llvm::None;
return std::nullopt;
ConstString class_name(class_type.GetTypeName());
if (!class_name)
return llvm::None;
return std::nullopt;
TypeSP complete_objc_class_type_sp = LookupInCompleteClassCache(class_name);
if (!complete_objc_class_type_sp)
return llvm::None;
return std::nullopt;
CompilerType complete_class(
complete_objc_class_type_sp->GetFullCompilerType());
@ -445,5 +445,5 @@ ObjCLanguageRuntime::GetRuntimeType(CompilerType base_type) {
return complete_class;
}
return llvm::None;
return std::nullopt;
}

View File

@ -135,7 +135,7 @@ static llvm::Optional<mach_header> ParseMachOHeader(DataExtractor &data) {
static bool
ParseFileset(DataExtractor &data, mach_header header,
std::vector<ObjectContainerMachOFileset::Entry> &entries,
llvm::Optional<lldb::addr_t> load_addr = llvm::None) {
llvm::Optional<lldb::addr_t> load_addr = std::nullopt) {
lldb::offset_t offset = MachHeaderSizeFromMagic(header.magic);
lldb::offset_t slide = 0;
for (uint32_t i = 0; i < header.ncmds; ++i) {

View File

@ -147,7 +147,7 @@ llvm::Optional<Record::Kind> Record::classify(llvm::StringRef Line) {
case Token::Win:
return Record::StackWin;
default:
return llvm::None;
return std::nullopt;
}
case Token::Inline:
return Record::Inline;
@ -164,7 +164,7 @@ llvm::Optional<Record::Kind> Record::classify(llvm::StringRef Line) {
case Token::Init:
case Token::Win:
// These should never appear at the start of a valid record.
return llvm::None;
return std::nullopt;
}
llvm_unreachable("Fully covered switch above!");
}
@ -172,21 +172,21 @@ llvm::Optional<Record::Kind> Record::classify(llvm::StringRef Line) {
llvm::Optional<ModuleRecord> ModuleRecord::parse(llvm::StringRef Line) {
// MODULE Linux x86_64 E5894855C35DCCCCCCCCCCCCCCCCCCCC0 a.out
if (consume<Token>(Line) != Token::Module)
return llvm::None;
return std::nullopt;
llvm::Triple::OSType OS = consume<llvm::Triple::OSType>(Line);
if (OS == llvm::Triple::UnknownOS)
return llvm::None;
return std::nullopt;
llvm::Triple::ArchType Arch = consume<llvm::Triple::ArchType>(Line);
if (Arch == llvm::Triple::UnknownArch)
return llvm::None;
return std::nullopt;
llvm::StringRef Str;
std::tie(Str, Line) = getToken(Line);
UUID ID = parseModuleId(OS, Str);
if (!ID)
return llvm::None;
return std::nullopt;
return ModuleRecord(OS, Arch, std::move(ID));
}
@ -201,10 +201,10 @@ llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
llvm::Optional<InfoRecord> InfoRecord::parse(llvm::StringRef Line) {
// INFO CODE_ID 554889E55DC3CCCCCCCCCCCCCCCCCCCC [a.exe]
if (consume<Token>(Line) != Token::Info)
return llvm::None;
return std::nullopt;
if (consume<Token>(Line) != Token::CodeID)
return llvm::None;
return std::nullopt;
llvm::StringRef Str;
std::tie(Str, Line) = getToken(Line);
@ -213,7 +213,7 @@ llvm::Optional<InfoRecord> InfoRecord::parse(llvm::StringRef Line) {
UUID ID;
if (Line.trim().empty()) {
if (Str.empty() || !ID.SetFromStringRef(Str))
return llvm::None;
return std::nullopt;
}
return InfoRecord(std::move(ID));
}
@ -228,17 +228,17 @@ static llvm::Optional<T> parseNumberName(llvm::StringRef Line,
Token TokenType) {
// TOKEN number name
if (consume<Token>(Line) != TokenType)
return llvm::None;
return std::nullopt;
llvm::StringRef Str;
size_t Number;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, Number))
return llvm::None;
return std::nullopt;
llvm::StringRef Name = Line.trim();
if (Name.empty())
return llvm::None;
return std::nullopt;
return T(Number, Name);
}
@ -310,7 +310,7 @@ llvm::Optional<FuncRecord> FuncRecord::parse(llvm::StringRef Line) {
if (parsePublicOrFunc(Line, Multiple, Address, &Size, ParamSize, Name))
return FuncRecord(Multiple, Address, Size, ParamSize, Name);
return llvm::None;
return std::nullopt;
}
bool breakpad::operator==(const FuncRecord &L, const FuncRecord &R) {
@ -328,12 +328,12 @@ llvm::Optional<InlineRecord> InlineRecord::parse(llvm::StringRef Line) {
// INLINE inline_nest_level call_site_line call_site_file_num origin_num
// [address size]+
if (consume<Token>(Line) != Token::Inline)
return llvm::None;
return std::nullopt;
llvm::SmallVector<llvm::StringRef> Tokens;
SplitString(Line, Tokens, " ");
if (Tokens.size() < 6 || Tokens.size() % 2 == 1)
return llvm::None;
return std::nullopt;
size_t InlineNestLevel;
uint32_t CallSiteLineNum;
@ -343,17 +343,17 @@ llvm::Optional<InlineRecord> InlineRecord::parse(llvm::StringRef Line) {
to_integer(Tokens[1], CallSiteLineNum) &&
to_integer(Tokens[2], CallSiteFileNum) &&
to_integer(Tokens[3], OriginNum)))
return llvm::None;
return std::nullopt;
InlineRecord Record = InlineRecord(InlineNestLevel, CallSiteLineNum,
CallSiteFileNum, OriginNum);
for (size_t i = 4; i < Tokens.size(); i += 2) {
lldb::addr_t Address;
if (!to_integer(Tokens[i], Address, 16))
return llvm::None;
return std::nullopt;
lldb::addr_t Size;
if (!to_integer(Tokens[i + 1].trim(), Size, 16))
return llvm::None;
return std::nullopt;
Record.Ranges.emplace_back(Address, Size);
}
return Record;
@ -381,22 +381,22 @@ llvm::Optional<LineRecord> LineRecord::parse(llvm::StringRef Line) {
llvm::StringRef Str;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, Address, 16))
return llvm::None;
return std::nullopt;
lldb::addr_t Size;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, Size, 16))
return llvm::None;
return std::nullopt;
uint32_t LineNum;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, LineNum))
return llvm::None;
return std::nullopt;
size_t FileNum;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, FileNum))
return llvm::None;
return std::nullopt;
return LineRecord(Address, Size, LineNum, FileNum);
}
@ -419,7 +419,7 @@ llvm::Optional<PublicRecord> PublicRecord::parse(llvm::StringRef Line) {
if (parsePublicOrFunc(Line, Multiple, Address, nullptr, ParamSize, Name))
return PublicRecord(Multiple, Address, ParamSize, Name);
return llvm::None;
return std::nullopt;
}
bool breakpad::operator==(const PublicRecord &L, const PublicRecord &R) {
@ -440,9 +440,9 @@ llvm::Optional<StackCFIRecord> StackCFIRecord::parse(llvm::StringRef Line) {
// No token in exprN ends with a colon.
if (consume<Token>(Line) != Token::Stack)
return llvm::None;
return std::nullopt;
if (consume<Token>(Line) != Token::CFI)
return llvm::None;
return std::nullopt;
llvm::StringRef Str;
std::tie(Str, Line) = getToken(Line);
@ -453,14 +453,14 @@ llvm::Optional<StackCFIRecord> StackCFIRecord::parse(llvm::StringRef Line) {
lldb::addr_t Address;
if (!to_integer(Str, Address, 16))
return llvm::None;
return std::nullopt;
llvm::Optional<lldb::addr_t> Size;
if (IsInitRecord) {
Size.emplace();
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, *Size, 16))
return llvm::None;
return std::nullopt;
}
return StackCFIRecord(Address, Size, Line.trim());
@ -488,26 +488,26 @@ llvm::Optional<StackWinRecord> StackWinRecord::parse(llvm::StringRef Line) {
// program_string_OR_allocates_base_pointer
if (consume<Token>(Line) != Token::Stack)
return llvm::None;
return std::nullopt;
if (consume<Token>(Line) != Token::Win)
return llvm::None;
return std::nullopt;
llvm::StringRef Str;
uint8_t Type;
std::tie(Str, Line) = getToken(Line);
// Right now we only support the "FrameData" frame type.
if (!to_integer(Str, Type) || FrameType(Type) != FrameType::FrameData)
return llvm::None;
return std::nullopt;
lldb::addr_t RVA;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, RVA, 16))
return llvm::None;
return std::nullopt;
lldb::addr_t CodeSize;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, CodeSize, 16))
return llvm::None;
return std::nullopt;
// Skip fields which we aren't using right now.
std::tie(Str, Line) = getToken(Line); // prologue_size
@ -516,27 +516,27 @@ llvm::Optional<StackWinRecord> StackWinRecord::parse(llvm::StringRef Line) {
lldb::addr_t ParameterSize;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, ParameterSize, 16))
return llvm::None;
return std::nullopt;
lldb::addr_t SavedRegisterSize;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, SavedRegisterSize, 16))
return llvm::None;
return std::nullopt;
lldb::addr_t LocalSize;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, LocalSize, 16))
return llvm::None;
return std::nullopt;
std::tie(Str, Line) = getToken(Line); // max_stack_size
uint8_t HasProgramString;
std::tie(Str, Line) = getToken(Line);
if (!to_integer(Str, HasProgramString))
return llvm::None;
return std::nullopt;
// FrameData records should always have a program string.
if (!HasProgramString)
return llvm::None;
return std::nullopt;
return StackWinRecord(RVA, CodeSize, ParameterSize, SavedRegisterSize,
LocalSize, Line.trim());

View File

@ -31,7 +31,7 @@ llvm::Optional<Header> Header::parse(llvm::StringRef text) {
std::tie(line, text) = text.split('\n');
auto Module = ModuleRecord::parse(line);
if (!Module)
return llvm::None;
return std::nullopt;
llvm::Triple triple;
triple.setArch(Module->Arch);

View File

@ -822,7 +822,7 @@ UUID ObjectFileELF::GetUUID() {
llvm::Optional<FileSpec> ObjectFileELF::GetDebugLink() {
if (m_gnu_debuglink_file.empty())
return llvm::None;
return std::nullopt;
return FileSpec(m_gnu_debuglink_file);
}
@ -1770,13 +1770,13 @@ public:
if (H.p_memsz == 0) {
LLDB_LOG(Log, "Ignoring zero-sized {0} segment. Corrupt object file?",
SegmentName);
return llvm::None;
return std::nullopt;
}
if (Segments.overlaps(H.p_vaddr, H.p_vaddr + H.p_memsz)) {
LLDB_LOG(Log, "Ignoring overlapping {0} segment. Corrupt object file?",
SegmentName);
return llvm::None;
return std::nullopt;
}
return VMRange(H.p_vaddr, H.p_memsz);
}
@ -1801,7 +1801,7 @@ public:
if (Range.GetByteSize() > 0 &&
Sections.overlaps(Range.GetRangeBase(), Range.GetRangeEnd())) {
LLDB_LOG(Log, "Ignoring overlapping section. Corrupt object file?");
return llvm::None;
return std::nullopt;
}
if (Segment)
Range.Slide(-Segment->GetFileAddress());

View File

@ -1092,7 +1092,7 @@ llvm::Optional<FileSpec> ObjectFilePECOFF::GetDebugLink() {
uint32_t gnu_debuglink_crc;
if (GetDebugLinkContents(*m_binary, gnu_debuglink_file, gnu_debuglink_crc))
return FileSpec(gnu_debuglink_file);
return llvm::None;
return std::nullopt;
}
uint32_t ObjectFilePECOFF::ParseDependentModules() {

View File

@ -57,18 +57,18 @@ GetWasmString(llvm::DataExtractor &data, llvm::DataExtractor::Cursor &c) {
uint64_t len = data.getULEB128(c);
if (!c) {
consumeError(c.takeError());
return llvm::None;
return std::nullopt;
}
if (len >= (uint64_t(1) << 32)) {
return llvm::None;
return std::nullopt;
}
llvm::SmallVector<uint8_t, 32> str_storage;
data.getU8(c, str_storage, len);
if (!c) {
consumeError(c.takeError());
return llvm::None;
return std::nullopt;
}
llvm::StringRef str = toStringRef(makeArrayRef(str_storage));
@ -427,7 +427,7 @@ llvm::Optional<FileSpec> ObjectFileWasm::GetExternalDebugInfoFileSpec() {
return FileSpec(symbols_url->GetStringRef());
}
}
return llvm::None;
return std::nullopt;
}
void ObjectFileWasm::Dump(Stream *s) {

View File

@ -153,14 +153,14 @@ bool PlatformRemoteGDBServer::GetRemoteOSVersion() {
llvm::Optional<std::string> PlatformRemoteGDBServer::GetRemoteOSBuildString() {
if (!m_gdb_client_up)
return llvm::None;
return std::nullopt;
return m_gdb_client_up->GetOSBuildString();
}
llvm::Optional<std::string>
PlatformRemoteGDBServer::GetRemoteOSKernelDescription() {
if (!m_gdb_client_up)
return llvm::None;
return std::nullopt;
return m_gdb_client_up->GetOSKernelDescription();
}
@ -288,7 +288,7 @@ PlatformRemoteGDBServer::DoGetUserName(UserIDResolver::id_t uid) {
std::string name;
if (m_gdb_client_up && m_gdb_client_up->GetUserName(uid, name))
return std::move(name);
return llvm::None;
return std::nullopt;
}
llvm::Optional<std::string>
@ -296,7 +296,7 @@ PlatformRemoteGDBServer::DoGetGroupName(UserIDResolver::id_t gid) {
std::string name;
if (m_gdb_client_up && m_gdb_client_up->GetGroupName(gid, name))
return std::move(name);
return llvm::None;
return std::nullopt;
}
uint32_t PlatformRemoteGDBServer::FindProcesses(

View File

@ -73,7 +73,7 @@ static Optional<int> GetCGroupFileDescriptor(lldb::pid_t pid) {
std::ifstream ifile;
ifile.open(formatv("/proc/{0}/cgroup", pid));
if (!ifile)
return None;
return std::nullopt;
std::string line;
while (std::getline(ifile, line)) {
@ -82,7 +82,7 @@ static Optional<int> GetCGroupFileDescriptor(lldb::pid_t pid) {
std::string slice = line.substr(line.find_first_of("/"));
if (slice.empty())
return None;
return std::nullopt;
std::string cgroup_file = formatv("/sys/fs/cgroup/{0}", slice);
// This cgroup should for the duration of the target, so we don't need to
// invoke close ourselves.
@ -92,7 +92,7 @@ static Optional<int> GetCGroupFileDescriptor(lldb::pid_t pid) {
return fd;
}
}
return None;
return std::nullopt;
}
Error IntelPTCollector::TraceStart(const TraceIntelPTStartRequest &request) {

View File

@ -51,7 +51,7 @@ IntelPTMultiCoreTrace::StartOnAllCores(const TraceIntelPTStartRequest &request,
for (cpu_id_t cpu_id : *cpu_ids) {
Expected<IntelPTSingleBufferTrace> core_trace =
IntelPTSingleBufferTrace::Start(request, /*tid=*/None, cpu_id,
IntelPTSingleBufferTrace::Start(request, /*tid=*/std::nullopt, cpu_id,
/*disabled=*/true, cgroup_fd);
if (!core_trace)
return IncludePerfEventParanoidMessageInError(core_trace.takeError());
@ -149,7 +149,7 @@ Expected<Optional<std::vector<uint8_t>>>
IntelPTMultiCoreTrace::TryGetBinaryData(
const TraceGetBinaryDataRequest &request) {
if (!request.cpu_id)
return None;
return std::nullopt;
auto it = m_traces_per_core.find(*request.cpu_id);
if (it == m_traces_per_core.end())
return createStringError(
@ -160,5 +160,5 @@ IntelPTMultiCoreTrace::TryGetBinaryData(
return it->second.first.GetIptTrace();
if (request.kind == IntelPTDataKinds::kPerfContextSwitchTrace)
return it->second.second.GetReadOnlyDataBuffer();
return None;
return std::nullopt;
}

View File

@ -43,7 +43,7 @@ public:
static llvm::Expected<std::unique_ptr<IntelPTMultiCoreTrace>>
StartOnAllCores(const TraceIntelPTStartRequest &request,
NativeProcessProtocol &process,
llvm::Optional<int> cgroup_fd = llvm::None);
llvm::Optional<int> cgroup_fd = std::nullopt);
/// Execute the provided callback on each core that is being traced.
///

View File

@ -52,8 +52,8 @@ public:
static llvm::Expected<IntelPTSingleBufferTrace>
Start(const TraceIntelPTStartRequest &request,
llvm::Optional<lldb::tid_t> tid,
llvm::Optional<lldb::cpu_id_t> cpu_id = llvm::None,
bool disabled = false, llvm::Optional<int> cgroup_fd = llvm::None);
llvm::Optional<lldb::cpu_id_t> cpu_id = std::nullopt,
bool disabled = false, llvm::Optional<int> cgroup_fd = std::nullopt);
/// \return
/// The bytes requested by a jLLDBTraceGetBinaryData packet that was routed

View File

@ -76,12 +76,12 @@ llvm::Expected<llvm::Optional<std::vector<uint8_t>>>
IntelPTThreadTraceCollection::TryGetBinaryData(
const TraceGetBinaryDataRequest &request) {
if (!request.tid)
return None;
return std::nullopt;
if (request.kind != IntelPTDataKinds::kIptTrace)
return None;
return std::nullopt;
if (!TracesThread(*request.tid))
return None;
return std::nullopt;
if (Expected<IntelPTSingleBufferTrace &> trace =
GetTracedThread(*request.tid))

View File

@ -1877,13 +1877,13 @@ static llvm::Optional<WaitStatus> HandlePid(::pid_t pid) {
-1, ::waitpid, pid, &status, __WALL | __WNOTHREAD | WNOHANG);
if (wait_pid == 0)
return llvm::None;
return std::nullopt;
if (wait_pid == -1) {
Status error(errno, eErrorTypePOSIX);
LLDB_LOG(log, "waitpid({0}, &status, _) failed: {1}", pid,
error);
return llvm::None;
return std::nullopt;
}
assert(wait_pid == pid);

View File

@ -53,7 +53,7 @@ public:
};
/// Return architecture-specific data needed to make inferior syscalls, if
/// they are supported.
virtual llvm::Optional<SyscallData> GetSyscallData() { return llvm::None; }
virtual llvm::Optional<SyscallData> GetSyscallData() { return std::nullopt; }
struct MmapData {
// Syscall numbers can be found (e.g.) in /usr/include/asm/unistd.h for the
@ -63,7 +63,7 @@ public:
};
/// Return the architecture-specific data needed to make mmap syscalls, if
/// they are supported.
virtual llvm::Optional<MmapData> GetMmapData() { return llvm::None; }
virtual llvm::Optional<MmapData> GetMmapData() { return std::nullopt; }
struct MemoryTaggingDetails {
/// Object with tag handling utilities. If the function below returns

View File

@ -366,8 +366,8 @@ lldb_private::process_linux::CreateContextSwitchTracePerfEvent(
if (parent_perf_event)
group_fd = parent_perf_event->GetFd();
if (Expected<PerfEvent> perf_event =
PerfEvent::Init(attr, /*pid=*/None, cpu_id, group_fd, /*flags=*/0)) {
if (Expected<PerfEvent> perf_event = PerfEvent::Init(
attr, /*pid=*/std::nullopt, cpu_id, group_fd, /*flags=*/0)) {
if (Error mmap_err = perf_event->MmapMetadataAndBuffers(
data_buffer_numpages, 0, /*data_buffer_write=*/false)) {
return std::move(mmap_err);

View File

@ -126,7 +126,7 @@ public:
/// all threads and processes are monitored.
static llvm::Expected<PerfEvent>
Init(perf_event_attr &attr, llvm::Optional<lldb::pid_t> pid,
llvm::Optional<lldb::cpu_id_t> core = llvm::None);
llvm::Optional<lldb::cpu_id_t> core = std::nullopt);
/// Mmap the metadata page and the data and aux buffers of the perf event and
/// expose them through \a PerfEvent::GetMetadataPage() , \a

View File

@ -17,7 +17,7 @@ NativeProcessELF::GetAuxValue(enum AuxVector::EntryType type) {
if (m_aux_vector == nullptr) {
auto buffer_or_error = GetAuxvData();
if (!buffer_or_error)
return llvm::None;
return std::nullopt;
DataExtractor auxv_data(buffer_or_error.get()->getBufferStart(),
buffer_or_error.get()->getBufferSize(),
GetByteOrder(), GetAddressByteSize());

View File

@ -34,7 +34,7 @@ AuxVector::GetAuxValue(enum EntryType entry_type) const {
auto it = m_auxv_entries.find(static_cast<uint64_t>(entry_type));
if (it != m_auxv_entries.end())
return it->second;
return llvm::None;
return std::nullopt;
}
void AuxVector::DumpToLog(lldb_private::Log *log) const {

View File

@ -50,12 +50,12 @@ GetPtrauthInstructionInfo(Target &target, const ArchSpec &arch,
DisassemblerSP disassembler_sp = Disassembler::DisassembleRange(
arch, plugin_name, flavor, target, range_bounds, prefer_file_cache);
if (!disassembler_sp)
return llvm::None;
return std::nullopt;
InstructionList &insn_list = disassembler_sp->GetInstructionList();
InstructionSP insn = insn_list.GetInstructionAtIndex(0);
if (!insn)
return llvm::None;
return std::nullopt;
return PtrauthInstructionInfo{insn->IsAuthenticated(), insn->IsLoad(),
insn->DoesBranch()};

View File

@ -22,7 +22,7 @@ getNoteType(const llvm::Triple &Triple,
continue;
return Entry.Note;
}
return llvm::None;
return std::nullopt;
}
DataExtractor lldb_private::getRegset(llvm::ArrayRef<CoreNote> Notes,

View File

@ -947,7 +947,7 @@ llvm::Optional<std::string> GDBRemoteCommunicationClient::GetOSBuildString() {
if (!m_os_build.empty())
return m_os_build;
}
return llvm::None;
return std::nullopt;
}
llvm::Optional<std::string>
@ -956,7 +956,7 @@ GDBRemoteCommunicationClient::GetOSKernelDescription() {
if (!m_os_kernel.empty())
return m_os_kernel;
}
return llvm::None;
return std::nullopt;
}
bool GDBRemoteCommunicationClient::GetHostname(std::string &s) {
@ -2706,7 +2706,7 @@ GDBRemoteCommunicationClient::SendSetCurrentThreadPacket(uint64_t tid,
if (response.IsUnsupportedResponse() && IsConnected())
return {{1, 1}};
}
return llvm::None;
return std::nullopt;
}
bool GDBRemoteCommunicationClient::SetCurrentThread(uint64_t tid,
@ -3082,20 +3082,20 @@ GDBRemoteCommunicationClient::FStat(lldb::user_id_t fd) {
if (SendPacketAndWaitForResponse(stream.GetString(), response) ==
PacketResult::Success) {
if (response.GetChar() != 'F')
return llvm::None;
return std::nullopt;
int64_t size = response.GetS64(-1, 16);
if (size > 0 && response.GetChar() == ';') {
std::string buffer;
if (response.GetEscapedBinaryData(buffer)) {
GDBRemoteFStatData out;
if (buffer.size() != sizeof(out))
return llvm::None;
return std::nullopt;
memcpy(&out, buffer.data(), sizeof(out));
return out;
}
}
}
return llvm::None;
return std::nullopt;
}
llvm::Optional<GDBRemoteFStatData>
@ -3103,7 +3103,7 @@ GDBRemoteCommunicationClient::Stat(const lldb_private::FileSpec &file_spec) {
Status error;
lldb::user_id_t fd = OpenFile(file_spec, File::eOpenOptionReadOnly, 0, error);
if (fd == UINT64_MAX)
return llvm::None;
return std::nullopt;
llvm::Optional<GDBRemoteFStatData> st = FStat(fd);
CloseFile(fd, error);
return st;
@ -3710,9 +3710,9 @@ llvm::Optional<QOffsets> GDBRemoteCommunicationClient::GetQOffsets() {
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse("qOffsets", response) !=
PacketResult::Success)
return llvm::None;
return std::nullopt;
if (!response.IsNormalResponse())
return llvm::None;
return std::nullopt;
QOffsets result;
llvm::StringRef ref = response.GetStringRef();
@ -3727,9 +3727,9 @@ llvm::Optional<QOffsets> GDBRemoteCommunicationClient::GetQOffsets() {
if (ref.consume_front("Text=")) {
result.segments = false;
if (!GetOffset())
return llvm::None;
return std::nullopt;
if (!ref.consume_front(";Data=") || !GetOffset())
return llvm::None;
return std::nullopt;
if (ref.empty())
return result;
if (ref.consume_front(";Bss=") && GetOffset() && ref.empty())
@ -3737,13 +3737,13 @@ llvm::Optional<QOffsets> GDBRemoteCommunicationClient::GetQOffsets() {
} else if (ref.consume_front("TextSeg=")) {
result.segments = true;
if (!GetOffset())
return llvm::None;
return std::nullopt;
if (ref.empty())
return result;
if (ref.consume_front(";DataSeg=") && GetOffset() && ref.empty())
return result;
}
return llvm::None;
return std::nullopt;
}
bool GDBRemoteCommunicationClient::GetModuleInfo(
@ -3816,30 +3816,30 @@ static llvm::Optional<ModuleSpec>
ParseModuleSpec(StructuredData::Dictionary *dict) {
ModuleSpec result;
if (!dict)
return llvm::None;
return std::nullopt;
llvm::StringRef string;
uint64_t integer;
if (!dict->GetValueForKeyAsString("uuid", string))
return llvm::None;
return std::nullopt;
if (!result.GetUUID().SetFromStringRef(string))
return llvm::None;
return std::nullopt;
if (!dict->GetValueForKeyAsInteger("file_offset", integer))
return llvm::None;
return std::nullopt;
result.SetObjectOffset(integer);
if (!dict->GetValueForKeyAsInteger("file_size", integer))
return llvm::None;
return std::nullopt;
result.SetObjectSize(integer);
if (!dict->GetValueForKeyAsString("triple", string))
return llvm::None;
return std::nullopt;
result.GetArchitecture().SetTriple(string);
if (!dict->GetValueForKeyAsString("file_path", string))
return llvm::None;
return std::nullopt;
result.GetFileSpec() = FileSpec(string, result.GetArchitecture().GetTriple());
return result;
@ -3851,7 +3851,7 @@ GDBRemoteCommunicationClient::GetModulesInfo(
namespace json = llvm::json;
if (!m_supports_jModulesInfo)
return llvm::None;
return std::nullopt;
json::Array module_array;
for (const FileSpec &module_file_spec : module_file_specs) {
@ -3874,21 +3874,21 @@ GDBRemoteCommunicationClient::GetModulesInfo(
if (SendPacketAndWaitForResponse(payload.GetString(), response) !=
PacketResult::Success ||
response.IsErrorResponse())
return llvm::None;
return std::nullopt;
if (response.IsUnsupportedResponse()) {
m_supports_jModulesInfo = false;
return llvm::None;
return std::nullopt;
}
StructuredData::ObjectSP response_object_sp =
StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!response_object_sp)
return llvm::None;
return std::nullopt;
StructuredData::Array *response_array = response_object_sp->GetAsArray();
if (!response_array)
return llvm::None;
return std::nullopt;
std::vector<ModuleSpec> result;
for (size_t i = 0; i < response_array->GetSize(); ++i) {

View File

@ -655,7 +655,7 @@ GetRegistersAsJSON(NativeThreadProtocol &thread) {
reg_ctx.GetExpeditedRegisters(ExpeditedRegs::Minimal);
#endif
if (expedited_regs.empty())
return llvm::None;
return std::nullopt;
for (auto &reg_num : expedited_regs) {
const RegisterInfo *const reg_info_p =
@ -3658,7 +3658,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qWatchpointSupportInfo(
auto hw_debug_cap = m_current_process->GetHardwareDebugSupportInfo();
StreamGDBRemote response;
if (hw_debug_cap == llvm::None)
if (hw_debug_cap == std::nullopt)
response.Printf("num:0;");
else
response.Printf("num:%d;", hw_debug_cap->second);

View File

@ -3448,7 +3448,7 @@ thread_result_t ProcessGDBRemote::AsyncThread() {
") listener.WaitForEvent (NULL, event_sp)...",
__FUNCTION__, GetID());
if (m_async_listener_sp->GetEvent(event_sp, llvm::None)) {
if (m_async_listener_sp->GetEvent(event_sp, std::nullopt)) {
const uint32_t event_type = event_sp->GetType();
if (event_sp->BroadcasterIs(&m_async_broadcaster)) {
LLDB_LOGF(log,

View File

@ -224,7 +224,7 @@ llvm::Optional<LinuxProcStatus> MinidumpParser::GetLinuxProcStatus() {
llvm::ArrayRef<uint8_t> data = GetStream(StreamType::LinuxProcStatus);
if (data.size() == 0)
return llvm::None;
return std::nullopt;
return LinuxProcStatus::Parse(data);
}
@ -240,7 +240,7 @@ llvm::Optional<lldb::pid_t> MinidumpParser::GetPid() {
return proc_status->GetPid();
}
return llvm::None;
return std::nullopt;
}
llvm::ArrayRef<minidump::Module> MinidumpParser::GetModuleList() {
@ -442,14 +442,14 @@ MinidumpParser::FindMemoryRange(lldb::addr_t addr) {
const size_t range_size = loc_desc.DataSize;
if (loc_desc.RVA + loc_desc.DataSize > GetData().size())
return llvm::None;
return std::nullopt;
if (range_start <= addr && addr < range_start + range_size) {
auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc);
if (!ExpectedSlice) {
LLDB_LOG_ERROR(log, ExpectedSlice.takeError(),
"Failed to get memory slice: {0}");
return llvm::None;
return std::nullopt;
}
return minidump::Range(range_start, *ExpectedSlice);
}
@ -468,14 +468,14 @@ MinidumpParser::FindMemoryRange(lldb::addr_t addr) {
MinidumpMemoryDescriptor64::ParseMemory64List(data64);
if (memory64_list.empty())
return llvm::None;
return std::nullopt;
for (const auto &memory_desc64 : memory64_list) {
const lldb::addr_t range_start = memory_desc64.start_of_memory_range;
const size_t range_size = memory_desc64.data_size;
if (base_rva + range_size > GetData().size())
return llvm::None;
return std::nullopt;
if (range_start <= addr && addr < range_start + range_size) {
return minidump::Range(range_start,
@ -485,7 +485,7 @@ MinidumpParser::FindMemoryRange(lldb::addr_t addr) {
}
}
return llvm::None;
return std::nullopt;
}
llvm::ArrayRef<uint8_t> MinidumpParser::GetMemory(lldb::addr_t addr,

View File

@ -29,7 +29,7 @@ llvm::Optional<lldb::pid_t> MinidumpMiscInfo::GetPid() const {
if (flags1 & pid_flag)
return llvm::Optional<lldb::pid_t>(process_id);
return llvm::None;
return std::nullopt;
}
// Linux Proc Status
@ -52,7 +52,7 @@ LinuxProcStatus::Parse(llvm::ArrayRef<uint8_t> &data) {
}
}
return llvm::None;
return std::nullopt;
}
lldb::pid_t LinuxProcStatus::GetPid() const { return pid; }

View File

@ -495,7 +495,7 @@ void SymbolFileBreakpad::AddSymbols(Symtab &symtab) {
for (llvm::StringRef line : lines(Record::Public)) {
if (auto record = PublicRecord::parse(line))
add_symbol(record->Address, llvm::None, record->Name);
add_symbol(record->Address, std::nullopt, record->Name);
else
LLDB_LOG(log, "Failed to parse: {0}. Skipping record.", line);
}
@ -528,7 +528,7 @@ GetRule(llvm::StringRef &unwind_rules) {
llvm::StringRef lhs, rest;
std::tie(lhs, rest) = getToken(unwind_rules);
if (!lhs.consume_back(":"))
return llvm::None;
return std::nullopt;
// Seek forward to the next register: expression pair
llvm::StringRef::size_type pos = rest.find(": ");
@ -541,7 +541,7 @@ GetRule(llvm::StringRef &unwind_rules) {
// Go back one token to find the end of the current rule.
pos = rest.rfind(' ', pos);
if (pos == llvm::StringRef::npos)
return llvm::None;
return std::nullopt;
llvm::StringRef rhs = rest.take_front(pos);
unwind_rules = rest.drop_front(pos);

View File

@ -95,7 +95,7 @@ public:
llvm::Optional<ArrayInfo> GetDynamicArrayInfoForUID(
lldb::user_id_t type_uid,
const lldb_private::ExecutionContext *exe_ctx) override {
return llvm::None;
return std::nullopt;
}
bool CompleteType(CompilerType &compiler_type) override { return false; }

View File

@ -36,11 +36,11 @@ llvm::Optional<DIERef> DIERef::Decode(const DataExtractor &data,
// it will return 0
dw_offset_t die_offset = data.GetU32(offset_ptr);
if (die_offset == 0)
return llvm::None;
return std::nullopt;
if (dwo_num_valid)
return DIERef(dwo_num, section, die_offset);
else
return DIERef(llvm::None, section, die_offset);
return DIERef(std::nullopt, section, die_offset);
}
void DIERef::Encode(DataEncoder &encoder) const {

View File

@ -37,7 +37,7 @@ public:
llvm::Optional<uint32_t> dwo_num() const {
if (m_dwo_num_valid)
return m_dwo_num;
return llvm::None;
return std::nullopt;
}
Section section() const { return static_cast<Section>(m_section); }

View File

@ -23,7 +23,7 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die,
const ExecutionContext *exe_ctx) {
SymbolFile::ArrayInfo array_info;
if (!parent_die)
return llvm::None;
return std::nullopt;
for (DWARFDIE die : parent_die.children()) {
const dw_tag_t tag = die.Tag();

View File

@ -1273,7 +1273,7 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
}
}
return std::make_shared<Type>(
die.GetID(), dwarf, attrs.name, llvm::None, nullptr, LLDB_INVALID_UID,
die.GetID(), dwarf, attrs.name, std::nullopt, nullptr, LLDB_INVALID_UID,
Type::eEncodingIsUID, &attrs.decl, clang_type, Type::ResolveState::Full);
}

View File

@ -20,7 +20,7 @@ using namespace lldb_private;
llvm::Optional<DIERef> DWARFBaseDIE::GetDIERef() const {
if (!IsValid())
return llvm::None;
return std::nullopt;
return DIERef(m_cu->GetSymbolFileDWARF().GetDwoNum(), m_cu->GetDebugSection(),
m_die->GetOffset());
@ -57,7 +57,7 @@ llvm::Optional<uint64_t>
DWARFBaseDIE::GetAttributeValueAsOptionalUnsigned(const dw_attr_t attr) const {
if (IsValid())
return m_die->GetAttributeValueAsOptionalUnsigned(GetCU(), attr);
return llvm::None;
return std::nullopt;
}
uint64_t DWARFBaseDIE::GetAttributeValueAsAddress(const dw_attr_t attr,

View File

@ -41,12 +41,12 @@ DWARFContext::LoadOrGetSection(llvm::Optional<SectionType> main_section_type,
}
const DWARFDataExtractor &DWARFContext::getOrLoadCuIndexData() {
return LoadOrGetSection(llvm::None, eSectionTypeDWARFDebugCuIndex,
return LoadOrGetSection(std::nullopt, eSectionTypeDWARFDebugCuIndex,
m_data_debug_cu_index);
}
const DWARFDataExtractor &DWARFContext::getOrLoadTuIndexData() {
return LoadOrGetSection(llvm::None, eSectionTypeDWARFDebugTuIndex,
return LoadOrGetSection(std::nullopt, eSectionTypeDWARFDebugTuIndex,
m_data_debug_tu_index);
}
@ -56,12 +56,12 @@ const DWARFDataExtractor &DWARFContext::getOrLoadAbbrevData() {
}
const DWARFDataExtractor &DWARFContext::getOrLoadArangesData() {
return LoadOrGetSection(eSectionTypeDWARFDebugAranges, llvm::None,
return LoadOrGetSection(eSectionTypeDWARFDebugAranges, std::nullopt,
m_data_debug_aranges);
}
const DWARFDataExtractor &DWARFContext::getOrLoadAddrData() {
return LoadOrGetSection(eSectionTypeDWARFDebugAddr, llvm::None,
return LoadOrGetSection(eSectionTypeDWARFDebugAddr, std::nullopt,
m_data_debug_addr);
}
@ -71,12 +71,12 @@ const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() {
}
const DWARFDataExtractor &DWARFContext::getOrLoadLineData() {
return LoadOrGetSection(eSectionTypeDWARFDebugLine, llvm::None,
return LoadOrGetSection(eSectionTypeDWARFDebugLine, std::nullopt,
m_data_debug_line);
}
const DWARFDataExtractor &DWARFContext::getOrLoadLineStrData() {
return LoadOrGetSection(eSectionTypeDWARFDebugLineStr, llvm::None,
return LoadOrGetSection(eSectionTypeDWARFDebugLineStr, std::nullopt,
m_data_debug_line_str);
}
@ -92,12 +92,12 @@ const DWARFDataExtractor &DWARFContext::getOrLoadLocListsData() {
}
const DWARFDataExtractor &DWARFContext::getOrLoadMacroData() {
return LoadOrGetSection(eSectionTypeDWARFDebugMacro, llvm::None,
return LoadOrGetSection(eSectionTypeDWARFDebugMacro, std::nullopt,
m_data_debug_macro);
}
const DWARFDataExtractor &DWARFContext::getOrLoadRangesData() {
return LoadOrGetSection(eSectionTypeDWARFDebugRanges, llvm::None,
return LoadOrGetSection(eSectionTypeDWARFDebugRanges, std::nullopt,
m_data_debug_ranges);
}

View File

@ -555,7 +555,7 @@ DWARFDebugInfoEntry::GetAttributeValueAsOptionalUnsigned(
if (GetAttributeValue(cu, attr, form_value, nullptr,
check_specification_or_abstract_origin))
return form_value.Unsigned();
return llvm::None;
return std::nullopt;
}
// GetAttributeValueAsReference

View File

@ -193,7 +193,7 @@ DWARFFormValue::GetFixedSize(dw_form_t form, const DWARFUnit *u) {
return g_form_sizes[form].size;
if (form == DW_FORM_addr && u)
return u->GetAddressByteSize();
return llvm::None;
return std::nullopt;
}
llvm::Optional<uint8_t> DWARFFormValue::GetFixedSize() const {

View File

@ -241,12 +241,12 @@ public:
llvm::Optional<uint64_t> GetLoclistOffset(uint32_t Index) {
if (!m_loclist_table_header)
return llvm::None;
return std::nullopt;
std::optional<uint64_t> Offset = m_loclist_table_header->getOffsetEntry(
m_dwarf.GetDWARFContext().getOrLoadLocListsData().GetAsLLVM(), Index);
if (!Offset)
return llvm::None;
return std::nullopt;
return *Offset + m_loclists_base;
}

View File

@ -45,18 +45,18 @@ llvm::Optional<DIERef>
DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) {
std::optional<uint64_t> cu_offset = entry.getCUOffset();
if (!cu_offset)
return llvm::None;
return std::nullopt;
DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *cu_offset);
if (!cu)
return llvm::None;
return std::nullopt;
cu = &cu->GetNonSkeletonUnit();
if (std::optional<uint64_t> die_offset = entry.getDIEUnitOffset())
return DIERef(cu->GetSymbolFileDWARF().GetDwoNum(),
DIERef::Section::DebugInfo, cu->GetOffset() + *die_offset);
return llvm::None;
return std::nullopt;
}
bool DebugNamesDWARFIndex::ProcessEntry(

View File

@ -65,7 +65,7 @@ public:
DIEInfo(dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h);
explicit operator DIERef() const {
return DIERef(llvm::None, DIERef::Section::DebugInfo, die_offset);
return DIERef(std::nullopt, DIERef::Section::DebugInfo, die_offset);
}
};

View File

@ -798,7 +798,7 @@ llvm::Optional<uint32_t> SymbolFileDWARF::GetDWARFUnitIndex(uint32_t cu_idx) {
if (m_lldb_cu_to_dwarf_unit.empty())
return cu_idx;
if (cu_idx >= m_lldb_cu_to_dwarf_unit.size())
return llvm::None;
return std::nullopt;
return m_lldb_cu_to_dwarf_unit[cu_idx];
}
@ -1422,11 +1422,11 @@ SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) {
SymbolFileDWARF *dwarf = debug_map->GetSymbolFileByOSOIndex(
debug_map->GetOSOIndexFromUserID(uid));
return DecodedUID{
*dwarf, {llvm::None, DIERef::Section::DebugInfo, dw_offset_t(uid)}};
*dwarf, {std::nullopt, DIERef::Section::DebugInfo, dw_offset_t(uid)}};
}
dw_offset_t die_offset = uid;
if (die_offset == DW_INVALID_OFFSET)
return llvm::None;
return std::nullopt;
DIERef::Section section =
uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo;
@ -1507,7 +1507,7 @@ SymbolFileDWARF::GetDynamicArrayInfoForUID(
if (DWARFDIE type_die = GetDIE(type_uid))
return DWARFASTParser::ParseChildArrayInfo(type_die, exe_ctx);
else
return llvm::None;
return std::nullopt;
}
Type *SymbolFileDWARF::ResolveTypeUID(const DIERef &die_ref) {

View File

@ -278,7 +278,7 @@ public:
GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
const DWARFDebugInfoEntry &cu_die);
virtual llvm::Optional<uint32_t> GetDwoNum() { return llvm::None; }
virtual llvm::Optional<uint32_t> GetDwoNum() { return std::nullopt; }
/// If this is a DWARF object with a single CU, return its DW_AT_dwo_id.
llvm::Optional<uint64_t> GetDWOId();

View File

@ -784,7 +784,7 @@ SymbolFileDWARFDebugMap::GetDynamicArrayInfoForUID(
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
if (oso_dwarf)
return oso_dwarf->GetDynamicArrayInfoForUID(type_uid, exe_ctx);
return llvm::None;
return std::nullopt;
}
bool SymbolFileDWARFDebugMap::CompleteType(CompilerType &compiler_type) {

View File

@ -165,7 +165,7 @@ static DWARFExpression MakeRegisterBasedLocationExpressionInternal(
DWARFExpression lldb_private::npdb::MakeEnregisteredLocationExpression(
llvm::codeview::RegisterId reg, lldb::ModuleSP module) {
return MakeRegisterBasedLocationExpressionInternal(reg, llvm::None, module);
return MakeRegisterBasedLocationExpressionInternal(reg, std::nullopt, module);
}
DWARFExpression lldb_private::npdb::MakeRegRelLocationExpression(
@ -275,7 +275,7 @@ lldb_private::npdb::MakeEnregisteredLocationExpressionForComposite(
}
MemberValLocation loc = offset_loc.second;
llvm::Optional<int32_t> offset =
loc.is_at_reg ? llvm::None
loc.is_at_reg ? std::nullopt
: llvm::Optional<int32_t>(loc.reg_offset);
if (!MakeRegisterBasedLocationExpressionInternal(
stream, (RegisterId)loc.reg_id, register_kind, offset,

View File

@ -150,7 +150,7 @@ TranslateCallingConvention(llvm::codeview::CallingConvention conv) {
case CC::NearVector:
return clang::CallingConv::CC_X86VectorCall;
default:
return llvm::None;
return std::nullopt;
}
}
@ -284,19 +284,19 @@ llvm::Optional<CompilerDecl> PdbAstBuilder::GetOrCreateDeclForUid(PdbSymUid uid)
case PdbSymUidKind::Type: {
clang::QualType qt = GetOrCreateType(uid.asTypeSym());
if (qt.isNull())
return llvm::None;
return std::nullopt;
if (auto *tag = qt->getAsTagDecl()) {
result = tag;
break;
}
return llvm::None;
return std::nullopt;
}
default:
return llvm::None;
return std::nullopt;
}
if (!result)
return llvm::None;
return std::nullopt;
m_uid_to_decl[toOpaqueUid(uid)] = result;
return ToCompilerDecl(*result);
}

View File

@ -80,7 +80,7 @@ PdbIndex::GetModuleIndexForAddr(uint16_t segment, uint32_t offset) const {
llvm::Optional<uint16_t> PdbIndex::GetModuleIndexForVa(lldb::addr_t va) const {
auto iter = m_va_to_modi.find(va);
if (iter == m_va_to_modi.end())
return llvm::None;
return std::nullopt;
return iter.value();
}

Some files were not shown because too many files have changed in this diff Show More