From fdbe7c7faa547b16bf6da0fedbb7234b6ee3adef Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 1 May 2023 20:34:51 -0700 Subject: [lldb] Refactor OptionValue to return a std::optional (NFC) Refactor OptionValue to return a std::optional instead of taking a fail value. This allows the caller to handle situations where there's no value, instead of being unable to distinguish between the absence of a value and the value happening the match the fail value. When a fail value is required, std::optional::value_or() provides the same functionality. --- lldb/source/Commands/CommandObjectBreakpoint.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lldb/source/Commands/CommandObjectBreakpoint.cpp') diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 8c31630..3debbb3 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -1739,7 +1739,8 @@ protected: // check the error: BreakpointSP bp_sp; if (m_bp_id.m_breakpoint.OptionWasSet()) { - lldb::break_id_t bp_id = m_bp_id.m_breakpoint.GetUInt64Value(); + lldb::break_id_t bp_id = + m_bp_id.m_breakpoint.GetUInt64Value().value_or(0); bp_sp = target.GetBreakpointByID(bp_id); if (!bp_sp) { result.AppendErrorWithFormatv("Could not find specified breakpoint {0}", @@ -1755,7 +1756,8 @@ protected: if (!bp_name) continue; if (m_bp_id.m_help_string.OptionWasSet()) - bp_name->SetHelp(m_bp_id.m_help_string.GetStringValue().str().c_str()); + bp_name->SetHelp( + m_bp_id.m_help_string.GetStringValue().value_or("").str().c_str()); if (bp_sp) target.ConfigureBreakpointName(*bp_name, bp_sp->GetOptions(), -- cgit v1.1