aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectBreakpoint.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2023-05-01 20:34:51 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2023-05-01 21:08:23 -0700
commitfdbe7c7faa547b16bf6da0fedbb7234b6ee3adef (patch)
treede943ecab10dba4e794771be711ba6d2633f2fd6 /lldb/source/Commands/CommandObjectBreakpoint.cpp
parent65365cff3b4ca62d20a6e4588375a48b4f386b69 (diff)
downloadllvm-fdbe7c7faa547b16bf6da0fedbb7234b6ee3adef.zip
llvm-fdbe7c7faa547b16bf6da0fedbb7234b6ee3adef.tar.gz
llvm-fdbe7c7faa547b16bf6da0fedbb7234b6ee3adef.tar.bz2
[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.
Diffstat (limited to 'lldb/source/Commands/CommandObjectBreakpoint.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp6
1 files changed, 4 insertions, 2 deletions
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(),