aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/CommandInterpreter.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2023-05-01 21:04:24 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2023-05-01 21:46:32 -0700
commit9c48aa68f455a63fc5e20e196d3c3e8822bfa6af (patch)
tree00e435408f19ee5db36ca242536247370f7f1d0e /lldb/source/Interpreter/CommandInterpreter.cpp
parent3b8bc83527910dc36c4d415256c43a84d213f322 (diff)
downloadllvm-9c48aa68f455a63fc5e20e196d3c3e8822bfa6af.zip
llvm-9c48aa68f455a63fc5e20e196d3c3e8822bfa6af.tar.gz
llvm-9c48aa68f455a63fc5e20e196d3c3e8822bfa6af.tar.bz2
[lldb] Refactor OptionValueProperties to return a std::optional (NFC)
Similar to fdbe7c7faa54, refactor OptionValueProperties 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/Interpreter/CommandInterpreter.cpp')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index ba61884..7e08653 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -146,14 +146,14 @@ CommandInterpreter::CommandInterpreter(Debugger &debugger,
bool CommandInterpreter::GetExpandRegexAliases() const {
const uint32_t idx = ePropertyExpandRegexAliases;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
bool CommandInterpreter::GetPromptOnQuit() const {
const uint32_t idx = ePropertyPromptOnQuit;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
void CommandInterpreter::SetPromptOnQuit(bool enable) {
@@ -163,8 +163,8 @@ void CommandInterpreter::SetPromptOnQuit(bool enable) {
bool CommandInterpreter::GetSaveSessionOnQuit() const {
const uint32_t idx = ePropertySaveSessionOnQuit;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
void CommandInterpreter::SetSaveSessionOnQuit(bool enable) {
@@ -174,8 +174,8 @@ void CommandInterpreter::SetSaveSessionOnQuit(bool enable) {
bool CommandInterpreter::GetOpenTranscriptInEditor() const {
const uint32_t idx = ePropertyOpenTranscriptInEditor;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) {
@@ -195,8 +195,8 @@ void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) {
bool CommandInterpreter::GetEchoCommands() const {
const uint32_t idx = ePropertyEchoCommands;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
void CommandInterpreter::SetEchoCommands(bool enable) {
@@ -206,8 +206,8 @@ void CommandInterpreter::SetEchoCommands(bool enable) {
bool CommandInterpreter::GetEchoCommentCommands() const {
const uint32_t idx = ePropertyEchoCommentCommands;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
void CommandInterpreter::SetEchoCommentCommands(bool enable) {
@@ -246,26 +246,26 @@ void CommandInterpreter::ResolveCommand(const char *command_line,
bool CommandInterpreter::GetStopCmdSourceOnError() const {
const uint32_t idx = ePropertyStopCmdSourceOnError;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
bool CommandInterpreter::GetSpaceReplPrompts() const {
const uint32_t idx = ePropertySpaceReplPrompts;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
bool CommandInterpreter::GetRepeatPreviousCommand() const {
const uint32_t idx = ePropertyRepeatPreviousCommand;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
bool CommandInterpreter::GetRequireCommandOverwrite() const {
const uint32_t idx = ePropertyRequireCommandOverwrite;
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx)
+ .value_or(g_interpreter_properties[idx].default_uint_value != 0);
}
void CommandInterpreter::Initialize() {