diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h index 41dc6c4405937..8735106c3d142 100644 --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -14,6 +14,7 @@ #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/FileSpecList.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-private-enumerations.h" @@ -274,7 +275,9 @@ class OptionValue { bool SetFileSpecValue(FileSpec file_spec); - FileSpecList GetFileSpecListValue() const; + bool AppendFileSpecValue(FileSpec file_spec); + + std::optional GetFileSpecListValue() const; std::optional GetFormatValue() const; @@ -337,6 +340,8 @@ class OptionValue { return GetFormatValue(); if constexpr (std::is_same_v) return GetFileSpecValue(); + if constexpr (std::is_same_v) + return GetFileSpecListValue(); if constexpr (std::is_same_v) return GetLanguageValue(); if constexpr (std::is_same_v) diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 256b4afa7bd6c..212b1186b4ef9 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -161,9 +161,7 @@ uint64_t ModuleListProperties::GetLLDBIndexCacheExpirationDays() { void ModuleListProperties::UpdateSymlinkMappings() { FileSpecList list = - m_collection_sp - ->GetPropertyAtIndexAsOptionValueFileSpecList(ePropertySymLinkPaths) - ->GetCurrentValue(); + GetPropertyAtIndexAs(ePropertySymLinkPaths, {}); llvm::sys::ScopedWriter lock(m_symlink_paths_mutex); const bool notify = false; m_symlink_paths.Clear(notify); diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp index dd293047695a9..b9da1f122ebee 100644 --- a/lldb/source/Interpreter/OptionValue.cpp +++ b/lldb/source/Interpreter/OptionValue.cpp @@ -312,11 +312,18 @@ bool OptionValue::SetFileSpecValue(FileSpec file_spec) { return false; } -FileSpecList OptionValue::GetFileSpecListValue() const { - const OptionValueFileSpecList *option_value = GetAsFileSpecList(); - if (option_value) +bool OptionValue::AppendFileSpecValue(FileSpec file_spec) { + if (OptionValueFileSpecList *option_value = GetAsFileSpecList()) { + option_value->AppendCurrentValue(file_spec); + return true; + } + return false; +} + +std::optional OptionValue::GetFileSpecListValue() const { + if (const OptionValueFileSpecList *option_value = GetAsFileSpecList()) return option_value->GetCurrentValue(); - return FileSpecList(); + return {}; } std::optional OptionValue::GetFormatValue() const { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp index a50d35b7d40ab..c29007fb9a340 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -201,10 +201,7 @@ class PlatformDarwinKernelProperties : public Properties { FileSpecList GetKextDirectories() const { const uint32_t idx = ePropertyKextDirectories; - const OptionValueFileSpecList *option_value = - m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(idx); - assert(option_value); - return option_value->GetCurrentValue(); + return GetPropertyAtIndexAs(idx, {}); } }; diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 1290281d8c274..0910273421109 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -4390,26 +4390,17 @@ void TargetProperties::AppendExecutableSearchPaths(const FileSpec &dir) { FileSpecList TargetProperties::GetExecutableSearchPaths() { const uint32_t idx = ePropertyExecutableSearchPaths; - const OptionValueFileSpecList *option_value = - m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(idx); - assert(option_value); - return option_value->GetCurrentValue(); + return GetPropertyAtIndexAs(idx, {}); } FileSpecList TargetProperties::GetDebugFileSearchPaths() { const uint32_t idx = ePropertyDebugFileSearchPaths; - const OptionValueFileSpecList *option_value = - m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(idx); - assert(option_value); - return option_value->GetCurrentValue(); + return GetPropertyAtIndexAs(idx, {}); } FileSpecList TargetProperties::GetClangModuleSearchPaths() { const uint32_t idx = ePropertyClangModuleSearchPaths; - const OptionValueFileSpecList *option_value = - m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(idx); - assert(option_value); - return option_value->GetCurrentValue(); + return GetPropertyAtIndexAs(idx, {}); } bool TargetProperties::GetEnableAutoImportClangModules() const { diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index a9c01e388b138..b5caf402b66fa 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -117,10 +117,7 @@ const RegularExpression *ThreadProperties::GetSymbolsToAvoidRegexp() { FileSpecList ThreadProperties::GetLibrariesToAvoid() const { const uint32_t idx = ePropertyStepAvoidLibraries; - const OptionValueFileSpecList *option_value = - m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(idx); - assert(option_value); - return option_value->GetCurrentValue(); + return GetPropertyAtIndexAs(idx, {}); } bool ThreadProperties::GetTraceEnabledState() const {