summaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/OptionValueArray.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/Interpreter/OptionValueArray.cpp
parent65365cff3b4ca62d20a6e4588375a48b4f386b69 (diff)
[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/Interpreter/OptionValueArray.cpp')
-rw-r--r--lldb/source/Interpreter/OptionValueArray.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lldb/source/Interpreter/OptionValueArray.cpp b/lldb/source/Interpreter/OptionValueArray.cpp
index 40357d5f4b06..afd1f90aafe8 100644
--- a/lldb/source/Interpreter/OptionValueArray.cpp
+++ b/lldb/source/Interpreter/OptionValueArray.cpp
@@ -155,9 +155,9 @@ size_t OptionValueArray::GetArgs(Args &args) const {
args.Clear();
const uint32_t size = m_values.size();
for (uint32_t i = 0; i < size; ++i) {
- llvm::StringRef string_value = m_values[i]->GetStringValue();
- if (!string_value.empty())
- args.AppendArgument(string_value);
+ std::optional<llvm::StringRef> string_value = m_values[i]->GetStringValue();
+ if (string_value)
+ args.AppendArgument(*string_value);
}
return args.GetArgumentCount();