Author: Jonas Devlieghere Date: 2023-05-04T22:10:28-07:00 New Revision: ab73a9c1a77cc9502f07ff8a9d1fd9dadccd702f
URL: https://github.com/llvm/llvm-project/commit/ab73a9c1a77cc9502f07ff8a9d1fd9dadccd702f DIFF: https://github.com/llvm/llvm-project/commit/ab73a9c1a77cc9502f07ff8a9d1fd9dadccd702f.diff LOG: [lldb] Eliminate {Get,Set}PropertyAtIndexAsFileSpec (NFC) This patch is a continuation of 6f8b33f6dfd0 and eliminates the {Get,Set}PropertyAtIndexAsFileSpec functions. Added: Modified: lldb/include/lldb/Interpreter/OptionValue.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/source/Core/ModuleList.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionValue.cpp lldb/source/Interpreter/OptionValueProperties.cpp lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Target/Platform.cpp lldb/source/Target/Process.cpp lldb/source/Target/Target.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h index eef7d67eb034c..41dc6c4405937 100644 --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -13,6 +13,7 @@ #include "lldb/Utility/Cloneable.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-private-enumerations.h" @@ -269,9 +270,9 @@ class OptionValue { bool SetEnumerationValue(int64_t value); - FileSpec GetFileSpecValue() const; + std::optional<FileSpec> GetFileSpecValue() const; - bool SetFileSpecValue(const FileSpec &file_spec); + bool SetFileSpecValue(FileSpec file_spec); FileSpecList GetFileSpecListValue() const; @@ -334,6 +335,8 @@ class OptionValue { return GetCharValue(); if constexpr (std::is_same_v<T, lldb::Format>) return GetFormatValue(); + if constexpr (std::is_same_v<T, FileSpec>) + return GetFileSpecValue(); if constexpr (std::is_same_v<T, lldb::LanguageType>) return GetLanguageValue(); if constexpr (std::is_same_v<T, llvm::StringRef>) @@ -362,6 +365,8 @@ class OptionValue { bool SetValueAs(lldb::LanguageType v) { return SetLanguageValue(v); } + bool SetValueAs(FileSpec v) { return SetFileSpecValue(v); } + template <typename T, std::enable_if_t<std::is_enum_v<T>, bool> = true> bool SetValueAs(T t) { return SetEnumerationValue(t); diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index 617fedc7d13ee..004ed55e3b119 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -134,13 +134,6 @@ class OptionValueProperties OptionValueFileSpec *GetPropertyAtIndexAsOptionValueFileSpec( uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; - FileSpec - GetPropertyAtIndexAsFileSpec(uint32_t idx, - const ExecutionContext *exe_ctx = nullptr) const; - - bool SetPropertyAtIndexAsFileSpec(uint32_t idx, const FileSpec &file_spec, - const ExecutionContext *exe_ctx = nullptr); - OptionValuePathMappings *GetPropertyAtIndexAsOptionValuePathMappings( uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 39caa21b21b5c..256b4afa7bd6c 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -112,25 +112,23 @@ bool ModuleListProperties::GetEnableBackgroundLookup() const { } FileSpec ModuleListProperties::GetClangModulesCachePath() const { - return m_collection_sp - ->GetPropertyAtIndexAsOptionValueFileSpec(ePropertyClangModulesCachePath) - ->GetCurrentValue(); + const uint32_t idx = ePropertyClangModulesCachePath; + return GetPropertyAtIndexAs<FileSpec>(idx, {}); } bool ModuleListProperties::SetClangModulesCachePath(const FileSpec &path) { - return m_collection_sp->SetPropertyAtIndexAsFileSpec( - ePropertyClangModulesCachePath, path); + const uint32_t idx = ePropertyClangModulesCachePath; + return SetPropertyAtIndex(idx, path); } FileSpec ModuleListProperties::GetLLDBIndexCachePath() const { - return m_collection_sp - ->GetPropertyAtIndexAsOptionValueFileSpec(ePropertyLLDBIndexCachePath) - ->GetCurrentValue(); + const uint32_t idx = ePropertyLLDBIndexCachePath; + return GetPropertyAtIndexAs<FileSpec>(idx, {}); } bool ModuleListProperties::SetLLDBIndexCachePath(const FileSpec &path) { - return m_collection_sp->SetPropertyAtIndexAsFileSpec( - ePropertyLLDBIndexCachePath, path); + const uint32_t idx = ePropertyLLDBIndexCachePath; + return SetPropertyAtIndex(idx, path); } bool ModuleListProperties::GetEnableLLDBIndexCache() const { diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index bb855665e76e9..735f18dd5004b 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -185,7 +185,7 @@ void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) { FileSpec CommandInterpreter::GetSaveSessionDirectory() const { const uint32_t idx = ePropertySaveSessionDirectory; - return m_collection_sp->GetPropertyAtIndexAsFileSpec(idx); + return GetPropertyAtIndexAs<FileSpec>(idx, {}); } void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) { diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp index 218a473db5e6b..dd293047695a9 100644 --- a/lldb/source/Interpreter/OptionValue.cpp +++ b/lldb/source/Interpreter/OptionValue.cpp @@ -296,14 +296,14 @@ bool OptionValue::SetEnumerationValue(int64_t value) { return false; } -FileSpec OptionValue::GetFileSpecValue() const { +std::optional<FileSpec> OptionValue::GetFileSpecValue() const { const OptionValueFileSpec *option_value = GetAsFileSpec(); if (option_value) return option_value->GetCurrentValue(); - return FileSpec(); + return {}; } -bool OptionValue::SetFileSpecValue(const FileSpec &file_spec) { +bool OptionValue::SetFileSpecValue(FileSpec file_spec) { OptionValueFileSpec *option_value = GetAsFileSpec(); if (option_value) { option_value->SetCurrentValue(file_spec, false); diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp index fdf5500d53c69..dafe398f9c8eb 100644 --- a/lldb/source/Interpreter/OptionValueProperties.cpp +++ b/lldb/source/Interpreter/OptionValueProperties.cpp @@ -287,29 +287,6 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpec( return nullptr; } -FileSpec OptionValueProperties::GetPropertyAtIndexAsFileSpec( - uint32_t idx, const ExecutionContext *exe_ctx) const { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->GetFileSpecValue(); - } - return FileSpec(); -} - -bool OptionValueProperties::SetPropertyAtIndexAsFileSpec( - uint32_t idx, const FileSpec &new_file_spec, - const ExecutionContext *exe_ctx) { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->SetFileSpecValue(new_file_spec); - } - return false; -} - OptionValueSInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueSInt64( uint32_t idx, const ExecutionContext *exe_ctx) const { const Property *property = GetPropertyAtIndex(idx, exe_ctx); diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp index b374719992c01..6e94ab51354c7 100644 --- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp +++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp @@ -45,7 +45,7 @@ class PluginProperties : public Properties { } FileSpec GetEmulatorPath() { - return m_collection_sp->GetPropertyAtIndexAsFileSpec(ePropertyEmulatorPath); + return GetPropertyAtIndexAs<FileSpec>(ePropertyEmulatorPath, {}); } Args GetEmulatorArgs() { diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index f3754f8c238c9..272cd4be3c671 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -153,7 +153,7 @@ class PluginProperties : public Properties { FileSpec GetTargetDefinitionFile() const { const uint32_t idx = ePropertyTargetDefinitionFile; - return m_collection_sp->GetPropertyAtIndexAsFileSpec(idx); + return GetPropertyAtIndexAs<FileSpec>(idx, {}); } bool GetUseSVR4() const { diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 92c06dde12a92..f81f2353d867f 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -108,13 +108,12 @@ bool PlatformProperties::SetUseModuleCache(bool use_module_cache) { } FileSpec PlatformProperties::GetModuleCacheDirectory() const { - return m_collection_sp->GetPropertyAtIndexAsFileSpec( - ePropertyModuleCacheDirectory); + return GetPropertyAtIndexAs<FileSpec>(ePropertyModuleCacheDirectory, {}); } bool PlatformProperties::SetModuleCacheDirectory(const FileSpec &dir_spec) { - return m_collection_sp->SetPropertyAtIndexAsFileSpec( - ePropertyModuleCacheDirectory, dir_spec); + return m_collection_sp->SetPropertyAtIndex(ePropertyModuleCacheDirectory, + dir_spec); } void PlatformProperties::SetDefaultModuleCacheDirectory( diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index f53cadf28f783..0f7c15a75bbf4 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -214,7 +214,7 @@ void ProcessProperties::SetExtraStartupCommands(const Args &args) { FileSpec ProcessProperties::GetPythonOSPluginPath() const { const uint32_t idx = ePropertyPythonOSPluginPath; - return m_collection_sp->GetPropertyAtIndexAsFileSpec(idx); + return GetPropertyAtIndexAs<FileSpec>(idx, {}); } uint32_t ProcessProperties::GetVirtualAddressableBits() const { @@ -229,7 +229,7 @@ void ProcessProperties::SetVirtualAddressableBits(uint32_t bits) { } void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) { const uint32_t idx = ePropertyPythonOSPluginPath; - m_collection_sp->SetPropertyAtIndexAsFileSpec(idx, file); + SetPropertyAtIndex(idx, file); } bool ProcessProperties::GetIgnoreBreakpointsInExpressions() const { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 7a61fa966a9f6..1290281d8c274 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -4452,7 +4452,7 @@ bool TargetProperties::GetEnableNotifyAboutFixIts() const { FileSpec TargetProperties::GetSaveJITObjectsDir() const { const uint32_t idx = ePropertySaveObjectsDir; - return m_collection_sp->GetPropertyAtIndexAsFileSpec(idx); + return GetPropertyAtIndexAs<FileSpec>(idx, {}); } void TargetProperties::CheckJITObjectsDir() { @@ -4529,7 +4529,7 @@ uint32_t TargetProperties::GetMaximumMemReadSize() const { FileSpec TargetProperties::GetStandardInputPath() const { const uint32_t idx = ePropertyInputPath; - return m_collection_sp->GetPropertyAtIndexAsFileSpec(idx); + return GetPropertyAtIndexAs<FileSpec>(idx, {}); } void TargetProperties::SetStandardInputPath(llvm::StringRef path) { @@ -4539,7 +4539,7 @@ void TargetProperties::SetStandardInputPath(llvm::StringRef path) { FileSpec TargetProperties::GetStandardOutputPath() const { const uint32_t idx = ePropertyOutputPath; - return m_collection_sp->GetPropertyAtIndexAsFileSpec(idx); + return GetPropertyAtIndexAs<FileSpec>(idx, {}); } void TargetProperties::SetStandardOutputPath(llvm::StringRef path) { @@ -4549,7 +4549,7 @@ void TargetProperties::SetStandardOutputPath(llvm::StringRef path) { FileSpec TargetProperties::GetStandardErrorPath() const { const uint32_t idx = ePropertyErrorPath; - return m_collection_sp->GetPropertyAtIndexAsFileSpec(idx); + return GetPropertyAtIndexAs<FileSpec>(idx, {}); } void TargetProperties::SetStandardErrorPath(llvm::StringRef path) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits