[Lldb-commits] [lldb] 6f8b33f - [lldb] Use templates to simplify {Get, Set}PropertyAtIndex (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu May 4 16:42:52 PDT 2023


Author: Jonas Devlieghere
Date: 2023-05-04T16:42:46-07:00
New Revision: 6f8b33f6dfd0a0f8d2522b6c832bd6298ae2f3f3

URL: https://github.com/llvm/llvm-project/commit/6f8b33f6dfd0a0f8d2522b6c832bd6298ae2f3f3
DIFF: https://github.com/llvm/llvm-project/commit/6f8b33f6dfd0a0f8d2522b6c832bd6298ae2f3f3.diff

LOG: [lldb] Use templates to simplify {Get,Set}PropertyAtIndex (NFC)

Use templates to simplify {Get,Set}PropertyAtIndex. It has always
bothered me how cumbersome those calls are when adding new properties.
After this patch, SetPropertyAtIndex infers the type from its arguments
and GetPropertyAtIndex required a single template argument for the
return value. As an added benefit, this enables us to remove a bunch of
wrappers from UserSettingsController and OptionValueProperties.

Differential revision: https://reviews.llvm.org/D149774

Added: 
    

Modified: 
    lldb/include/lldb/Core/Debugger.h
    lldb/include/lldb/Core/UserSettingsController.h
    lldb/include/lldb/Interpreter/OptionValue.h
    lldb/include/lldb/Interpreter/OptionValueProperties.h
    lldb/source/Core/CoreProperties.td
    lldb/source/Core/Debugger.cpp
    lldb/source/Core/ModuleList.cpp
    lldb/source/Interpreter/CommandInterpreter.cpp
    lldb/source/Interpreter/OptionValueProperties.cpp
    lldb/source/Interpreter/Property.cpp
    lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
    lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
    lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
    lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
    lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
    lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/source/Target/Platform.cpp
    lldb/source/Target/Process.cpp
    lldb/source/Target/Target.cpp
    lldb/source/Target/Thread.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h
index a7487e159e2c7..f05d8d4e6b231 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -269,7 +269,7 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
 
   const FormatEntity::Entry *GetFrameFormatUnique() const;
 
-  uint32_t GetStopDisassemblyMaxSize() const;
+  uint64_t GetStopDisassemblyMaxSize() const;
 
   const FormatEntity::Entry *GetThreadFormat() const;
 
@@ -283,7 +283,7 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
 
   bool SetREPLLanguage(lldb::LanguageType repl_lang);
 
-  uint32_t GetTerminalWidth() const;
+  uint64_t GetTerminalWidth() const;
 
   bool SetTerminalWidth(uint32_t term_width);
 
@@ -329,11 +329,11 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
 
   llvm::StringRef GetStopShowColumnAnsiSuffix() const;
 
-  uint32_t GetStopSourceLineCount(bool before) const;
+  uint64_t GetStopSourceLineCount(bool before) const;
 
   StopDisassemblyType GetStopDisassemblyDisplay() const;
 
-  uint32_t GetDisassemblyLineCount() const;
+  uint64_t GetDisassemblyLineCount() const;
 
   llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const;
 
@@ -349,7 +349,7 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
 
   bool SetPrintDecls(bool b);
 
-  uint32_t GetTabSize() const;
+  uint64_t GetTabSize() const;
 
   bool SetTabSize(uint32_t tab_size);
 

diff  --git a/lldb/include/lldb/Core/UserSettingsController.h b/lldb/include/lldb/Core/UserSettingsController.h
index 19b080d125a35..f320057ef120d 100644
--- a/lldb/include/lldb/Core/UserSettingsController.h
+++ b/lldb/include/lldb/Core/UserSettingsController.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_CORE_USERSETTINGSCONTROLLER_H
 #define LLDB_CORE_USERSETTINGSCONTROLLER_H
 
+#include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private-enumerations.h"
@@ -82,6 +83,27 @@ class Properties {
 
   static bool IsSettingExperimental(llvm::StringRef setting);
 
+  template <typename T>
+  T GetPropertyAtIndexAs(uint32_t idx, T default_value,
+                         const ExecutionContext *exe_ctx = nullptr) const {
+    return m_collection_sp->GetPropertyAtIndexAs<T>(idx, exe_ctx)
+        .value_or(default_value);
+  }
+
+  template <typename T, typename U = typename std::remove_pointer<T>::type,
+            std::enable_if_t<std::is_pointer_v<T>, bool> = true>
+  const U *
+  GetPropertyAtIndexAs(uint32_t idx,
+                       const ExecutionContext *exe_ctx = nullptr) const {
+    return m_collection_sp->GetPropertyAtIndexAs<T>(idx, exe_ctx);
+  }
+
+  template <typename T>
+  bool SetPropertyAtIndex(uint32_t idx, T t,
+                          const ExecutionContext *exe_ctx = nullptr) const {
+    return m_collection_sp->SetPropertyAtIndex<T>(idx, t, exe_ctx);
+  }
+
 protected:
   lldb::OptionValuePropertiesSP m_collection_sp;
 };

diff  --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h
index 7d6ab6c3f6f5e..eef7d67eb034c 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -322,6 +322,51 @@ class OptionValue {
       m_callback();
   }
 
+  template <typename T, std::enable_if_t<!std::is_pointer_v<T>, bool> = true>
+  std::optional<T> GetValueAs() const {
+    if constexpr (std::is_same_v<T, uint64_t>)
+      return GetUInt64Value();
+    if constexpr (std::is_same_v<T, int64_t>)
+      return GetSInt64Value();
+    if constexpr (std::is_same_v<T, bool>)
+      return GetBooleanValue();
+    if constexpr (std::is_same_v<T, char>)
+      return GetCharValue();
+    if constexpr (std::is_same_v<T, lldb::Format>)
+      return GetFormatValue();
+    if constexpr (std::is_same_v<T, lldb::LanguageType>)
+      return GetLanguageValue();
+    if constexpr (std::is_same_v<T, llvm::StringRef>)
+      return GetStringValue();
+    if constexpr (std::is_enum_v<T>)
+      if (std::optional<int64_t> value = GetEnumerationValue())
+        return static_cast<T>(*value);
+    return {};
+  }
+
+  template <typename T,
+            typename U = typename std::remove_const<
+                typename std::remove_pointer<T>::type>::type,
+            std::enable_if_t<std::is_pointer_v<T>, bool> = true>
+  T GetValueAs() const {
+    if constexpr (std::is_same_v<U, FormatEntity::Entry>)
+      return GetFormatEntity();
+    if constexpr (std::is_same_v<U, RegularExpression>)
+      return GetRegexValue();
+    return {};
+  }
+
+  bool SetValueAs(bool v) { return SetBooleanValue(v); }
+
+  bool SetValueAs(llvm::StringRef v) { return SetStringValue(v); }
+
+  bool SetValueAs(lldb::LanguageType v) { return SetLanguageValue(v); }
+
+  template <typename T, std::enable_if_t<std::is_enum_v<T>, bool> = true>
+  bool SetValueAs(T t) {
+    return SetEnumerationValue(t);
+  }
+
 protected:
   using TopmostBase = OptionValue;
 

diff  --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index 4782d7eff947b..3251a5ed5e2e2 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -122,57 +122,15 @@ class OptionValueProperties
   bool SetPropertyAtIndexFromArgs(uint32_t idx, const Args &args,
                                   const ExecutionContext *exe_ctx = nullptr);
 
-  std::optional<bool>
-  GetPropertyAtIndexAsBoolean(uint32_t idx,
-                              const ExecutionContext *exe_ctx = nullptr) const;
-
-  bool SetPropertyAtIndexAsBoolean(uint32_t idx, bool new_value,
-                                   const ExecutionContext *exe_ctx = nullptr);
-
   OptionValueDictionary *GetPropertyAtIndexAsOptionValueDictionary(
       uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
-  std::optional<int64_t> GetPropertyAtIndexAsEnumeration(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
-
-  bool
-  SetPropertyAtIndexAsEnumeration(uint32_t idx, int64_t new_value,
-                                  const ExecutionContext *exe_ctx = nullptr);
-
-  const FormatEntity::Entry *
-  GetPropertyAtIndexAsFormatEntity(uint32_t idx,
-                                   const ExecutionContext *exe_ctx = nullptr);
-
-  const RegularExpression *GetPropertyAtIndexAsOptionValueRegex(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
-
   OptionValueSInt64 *GetPropertyAtIndexAsOptionValueSInt64(
       uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
   OptionValueUInt64 *GetPropertyAtIndexAsOptionValueUInt64(
       uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
-  std::optional<int64_t>
-  GetPropertyAtIndexAsSInt64(uint32_t idx,
-                             const ExecutionContext *exe_ctx = nullptr) const;
-
-  bool SetPropertyAtIndexAsSInt64(uint32_t idx, int64_t new_value,
-                                  const ExecutionContext *exe_ctx = nullptr);
-
-  std::optional<uint64_t>
-  GetPropertyAtIndexAsUInt64(uint32_t idx,
-                             const ExecutionContext *exe_ctx = nullptr) const;
-
-  bool SetPropertyAtIndexAsUInt64(uint32_t idx, uint64_t new_value,
-                                  const ExecutionContext *exe_ctx = nullptr);
-
-  std::optional<llvm::StringRef>
-  GetPropertyAtIndexAsString(uint32_t idx,
-                             const ExecutionContext *exe_ctx = nullptr) const;
-
-  bool SetPropertyAtIndexAsString(uint32_t idx, llvm::StringRef new_value,
-                                  const ExecutionContext *exe_ctx = nullptr);
-
   OptionValueString *GetPropertyAtIndexAsOptionValueString(
       uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
@@ -201,6 +159,31 @@ class OptionValueProperties
   void SetValueChangedCallback(uint32_t property_idx,
                                std::function<void()> callback);
 
+  template <typename T>
+  auto GetPropertyAtIndexAs(uint32_t idx,
+                            const ExecutionContext *exe_ctx = nullptr) const {
+    if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) {
+      if (OptionValue *value = property->GetValue().get())
+        return value->GetValueAs<T>();
+    }
+    if constexpr (std::is_pointer_v<T>)
+      return T{nullptr};
+    else
+      return std::optional<T>{std::nullopt};
+  }
+
+  template <typename T>
+  bool SetPropertyAtIndex(uint32_t idx, T t,
+                          const ExecutionContext *exe_ctx = nullptr) const {
+    if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) {
+      if (OptionValue *value = property->GetValue().get()) {
+        value->SetValueAs(t);
+        return true;
+      }
+    }
+    return false;
+  }
+
 protected:
   Property *ProtectedGetPropertyAtIndex(uint32_t idx) {
     assert(idx < m_properties.size() && "invalid property index");

diff  --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td
index ccee2a64fcbae..4287cb1fff029 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -74,7 +74,7 @@ let Definition = "debugger" in {
     Global,
     DefaultEnumValue<"eLanguageTypeUnknown">,
     Desc<"The language to use for the REPL.">;
-  def StopDisassemblyCount: Property<"stop-disassembly-count", "SInt64">,
+  def StopDisassemblyCount: Property<"stop-disassembly-count", "UInt64">,
     Global,
     DefaultUnsignedValue<4>,
     Desc<"The number of disassembly lines to show when displaying a stopped context.">;
@@ -87,11 +87,11 @@ let Definition = "debugger" in {
     Global,
     DefaultUnsignedValue<32000>,
     Desc<"The size limit to use when disassembling large functions (default: 32KB).">;
-  def StopLineCountAfter: Property<"stop-line-count-after", "SInt64">,
+  def StopLineCountAfter: Property<"stop-line-count-after", "UInt64">,
     Global,
     DefaultUnsignedValue<3>,
     Desc<"The number of sources lines to display that come after the current source line when displaying a stopped context.">;
-  def StopLineCountBefore: Property<"stop-line-count-before", "SInt64">,
+  def StopLineCountBefore: Property<"stop-line-count-before", "UInt64">,
     Global,
     DefaultUnsignedValue<3>,
     Desc<"The number of sources lines to display that come before the current source line when displaying a stopped context.">;

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index ff249bc1952f4..5eb2d1ff5c61d 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -262,47 +262,47 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
 }
 
 bool Debugger::GetAutoConfirm() const {
-  const uint32_t idx = ePropertyAutoConfirm;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  constexpr uint32_t idx = ePropertyAutoConfirm;
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const {
-  const uint32_t idx = ePropertyDisassemblyFormat;
-  return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx);
+  constexpr uint32_t idx = ePropertyDisassemblyFormat;
+  return GetPropertyAtIndexAs<const FormatEntity::Entry *>(idx);
 }
 
 const FormatEntity::Entry *Debugger::GetFrameFormat() const {
-  const uint32_t idx = ePropertyFrameFormat;
-  return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx);
+  constexpr uint32_t idx = ePropertyFrameFormat;
+  return GetPropertyAtIndexAs<const FormatEntity::Entry *>(idx);
 }
 
 const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const {
-  const uint32_t idx = ePropertyFrameFormatUnique;
-  return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx);
+  constexpr uint32_t idx = ePropertyFrameFormatUnique;
+  return GetPropertyAtIndexAs<const FormatEntity::Entry *>(idx);
 }
 
-uint32_t Debugger::GetStopDisassemblyMaxSize() const {
-  const uint32_t idx = ePropertyStopDisassemblyMaxSize;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_debugger_properties[idx].default_uint_value);
+uint64_t Debugger::GetStopDisassemblyMaxSize() const {
+  constexpr uint32_t idx = ePropertyStopDisassemblyMaxSize;
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_debugger_properties[idx].default_uint_value);
 }
 
 bool Debugger::GetNotifyVoid() const {
-  const uint32_t idx = ePropertyNotiftVoid;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  constexpr uint32_t idx = ePropertyNotiftVoid;
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 llvm::StringRef Debugger::GetPrompt() const {
-  const uint32_t idx = ePropertyPrompt;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  constexpr uint32_t idx = ePropertyPrompt;
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
 void Debugger::SetPrompt(llvm::StringRef p) {
-  const uint32_t idx = ePropertyPrompt;
-  m_collection_sp->SetPropertyAtIndexAsString(idx, p);
+  constexpr uint32_t idx = ePropertyPrompt;
+  SetPropertyAtIndex(idx, p);
   llvm::StringRef new_prompt = GetPrompt();
   std::string str =
       lldb_private::ansi::FormatAnsiTerminalCodes(new_prompt, GetUseColor());
@@ -312,25 +312,25 @@ void Debugger::SetPrompt(llvm::StringRef p) {
 }
 
 const FormatEntity::Entry *Debugger::GetThreadFormat() const {
-  const uint32_t idx = ePropertyThreadFormat;
-  return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx);
+  constexpr uint32_t idx = ePropertyThreadFormat;
+  return GetPropertyAtIndexAs<const FormatEntity::Entry *>(idx);
 }
 
 const FormatEntity::Entry *Debugger::GetThreadStopFormat() const {
-  const uint32_t idx = ePropertyThreadStopFormat;
-  return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx);
+  constexpr uint32_t idx = ePropertyThreadStopFormat;
+  return GetPropertyAtIndexAs<const FormatEntity::Entry *>(idx);
 }
 
 lldb::ScriptLanguage Debugger::GetScriptLanguage() const {
   const uint32_t idx = ePropertyScriptLanguage;
-  return (lldb::ScriptLanguage)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_debugger_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<lldb::ScriptLanguage>(
+      idx, static_cast<lldb::ScriptLanguage>(
+               g_debugger_properties[idx].default_uint_value));
 }
 
 bool Debugger::SetScriptLanguage(lldb::ScriptLanguage script_lang) {
   const uint32_t idx = ePropertyScriptLanguage;
-  return m_collection_sp->SetPropertyAtIndexAsEnumeration(idx, script_lang);
+  return SetPropertyAtIndex(idx, script_lang);
 }
 
 lldb::LanguageType Debugger::GetREPLLanguage() const {
@@ -344,13 +344,13 @@ lldb::LanguageType Debugger::GetREPLLanguage() const {
 
 bool Debugger::SetREPLLanguage(lldb::LanguageType repl_lang) {
   const uint32_t idx = ePropertyREPLLanguage;
-  return m_collection_sp->SetPropertyAtIndexAsLanguage(idx, repl_lang);
+  return SetPropertyAtIndex(idx, repl_lang);
 }
 
-uint32_t Debugger::GetTerminalWidth() const {
+uint64_t Debugger::GetTerminalWidth() const {
   const uint32_t idx = ePropertyTerminalWidth;
-  return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or(
-      g_debugger_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<int64_t>(
+      idx, g_debugger_properties[idx].default_uint_value);
 }
 
 bool Debugger::SetTerminalWidth(uint32_t term_width) {
@@ -358,94 +358,94 @@ bool Debugger::SetTerminalWidth(uint32_t term_width) {
     handler_sp->TerminalSizeChanged();
 
   const uint32_t idx = ePropertyTerminalWidth;
-  return m_collection_sp->SetPropertyAtIndexAsSInt64(idx, term_width);
+  return SetPropertyAtIndex(idx, term_width);
 }
 
 bool Debugger::GetUseExternalEditor() const {
   const uint32_t idx = ePropertyUseExternalEditor;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 bool Debugger::SetUseExternalEditor(bool b) {
   const uint32_t idx = ePropertyUseExternalEditor;
-  return m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  return SetPropertyAtIndex(idx, b);
 }
 
 llvm::StringRef Debugger::GetExternalEditor() const {
   const uint32_t idx = ePropertyExternalEditor;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
 bool Debugger::SetExternalEditor(llvm::StringRef editor) {
   const uint32_t idx = ePropertyExternalEditor;
-  return m_collection_sp->SetPropertyAtIndexAsString(idx, editor);
+  return SetPropertyAtIndex(idx, editor);
 }
 
 bool Debugger::GetUseColor() const {
   const uint32_t idx = ePropertyUseColor;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 bool Debugger::SetUseColor(bool b) {
   const uint32_t idx = ePropertyUseColor;
-  bool ret = m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  bool ret = SetPropertyAtIndex(idx, b);
   SetPrompt(GetPrompt());
   return ret;
 }
 
 bool Debugger::GetShowProgress() const {
   const uint32_t idx = ePropertyShowProgress;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 bool Debugger::SetShowProgress(bool show_progress) {
   const uint32_t idx = ePropertyShowProgress;
-  return m_collection_sp->SetPropertyAtIndexAsBoolean(idx, show_progress);
+  return SetPropertyAtIndex(idx, show_progress);
 }
 
 llvm::StringRef Debugger::GetShowProgressAnsiPrefix() const {
   const uint32_t idx = ePropertyShowProgressAnsiPrefix;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
 llvm::StringRef Debugger::GetShowProgressAnsiSuffix() const {
   const uint32_t idx = ePropertyShowProgressAnsiSuffix;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
 bool Debugger::GetUseAutosuggestion() const {
   const uint32_t idx = ePropertyShowAutosuggestion;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 llvm::StringRef Debugger::GetAutosuggestionAnsiPrefix() const {
   const uint32_t idx = ePropertyShowAutosuggestionAnsiPrefix;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
 llvm::StringRef Debugger::GetAutosuggestionAnsiSuffix() const {
   const uint32_t idx = ePropertyShowAutosuggestionAnsiSuffix;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
 bool Debugger::GetUseSourceCache() const {
   const uint32_t idx = ePropertyUseSourceCache;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 bool Debugger::SetUseSourceCache(bool b) {
   const uint32_t idx = ePropertyUseSourceCache;
-  bool ret = m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  bool ret = SetPropertyAtIndex(idx, b);
   if (!ret) {
     m_source_file_cache.Clear();
   }
@@ -453,111 +453,111 @@ bool Debugger::SetUseSourceCache(bool b) {
 }
 bool Debugger::GetHighlightSource() const {
   const uint32_t idx = ePropertyHighlightSource;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 StopShowColumn Debugger::GetStopShowColumn() const {
   const uint32_t idx = ePropertyStopShowColumn;
-  return (lldb::StopShowColumn)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_debugger_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<lldb::StopShowColumn>(
+      idx, static_cast<lldb::StopShowColumn>(
+               g_debugger_properties[idx].default_uint_value));
 }
 
 llvm::StringRef Debugger::GetStopShowColumnAnsiPrefix() const {
   const uint32_t idx = ePropertyStopShowColumnAnsiPrefix;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
 llvm::StringRef Debugger::GetStopShowColumnAnsiSuffix() const {
   const uint32_t idx = ePropertyStopShowColumnAnsiSuffix;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
 llvm::StringRef Debugger::GetStopShowLineMarkerAnsiPrefix() const {
   const uint32_t idx = ePropertyStopShowLineMarkerAnsiPrefix;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
 llvm::StringRef Debugger::GetStopShowLineMarkerAnsiSuffix() const {
   const uint32_t idx = ePropertyStopShowLineMarkerAnsiSuffix;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_debugger_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_debugger_properties[idx].default_cstr_value);
 }
 
-uint32_t Debugger::GetStopSourceLineCount(bool before) const {
+uint64_t Debugger::GetStopSourceLineCount(bool before) const {
   const uint32_t idx =
       before ? ePropertyStopLineCountBefore : ePropertyStopLineCountAfter;
-  return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or(
-      g_debugger_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_debugger_properties[idx].default_uint_value);
 }
 
 Debugger::StopDisassemblyType Debugger::GetStopDisassemblyDisplay() const {
   const uint32_t idx = ePropertyStopDisassemblyDisplay;
-  return (Debugger::StopDisassemblyType)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_debugger_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<Debugger::StopDisassemblyType>(
+      idx, static_cast<Debugger::StopDisassemblyType>(
+               g_debugger_properties[idx].default_uint_value));
 }
 
-uint32_t Debugger::GetDisassemblyLineCount() const {
+uint64_t Debugger::GetDisassemblyLineCount() const {
   const uint32_t idx = ePropertyStopDisassemblyCount;
-  return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or(
-      g_debugger_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_debugger_properties[idx].default_uint_value);
 }
 
 bool Debugger::GetAutoOneLineSummaries() const {
   const uint32_t idx = ePropertyAutoOneLineSummaries;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 bool Debugger::GetEscapeNonPrintables() const {
   const uint32_t idx = ePropertyEscapeNonPrintables;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 bool Debugger::GetAutoIndent() const {
   const uint32_t idx = ePropertyAutoIndent;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 bool Debugger::SetAutoIndent(bool b) {
   const uint32_t idx = ePropertyAutoIndent;
-  return m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  return SetPropertyAtIndex(idx, b);
 }
 
 bool Debugger::GetPrintDecls() const {
   const uint32_t idx = ePropertyPrintDecls;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_debugger_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
 bool Debugger::SetPrintDecls(bool b) {
   const uint32_t idx = ePropertyPrintDecls;
-  return m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  return SetPropertyAtIndex(idx, b);
 }
 
-uint32_t Debugger::GetTabSize() const {
+uint64_t Debugger::GetTabSize() const {
   const uint32_t idx = ePropertyTabSize;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_debugger_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_debugger_properties[idx].default_uint_value);
 }
 
 bool Debugger::SetTabSize(uint32_t tab_size) {
   const uint32_t idx = ePropertyTabSize;
-  return m_collection_sp->SetPropertyAtIndexAsUInt64(idx, tab_size);
+  return SetPropertyAtIndex(idx, tab_size);
 }
 
 lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() const {
   const uint32_t idx = ePropertyDWIMPrintVerbosity;
-  return (lldb::DWIMPrintVerbosity)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_debugger_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<lldb::DWIMPrintVerbosity>(
+      idx, static_cast<lldb::DWIMPrintVerbosity>(
+               g_debugger_properties[idx].default_uint_value));
 }
 
 #pragma mark Debugger
@@ -815,6 +815,21 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
   // Initialize the debugger properties as early as possible as other parts of
   // LLDB will start querying them during construction.
   m_collection_sp->Initialize(g_debugger_properties);
+  m_collection_sp->AppendProperty(
+      ConstString("target"), "Settings specify to debugging targets.", true,
+      Target::GetGlobalProperties().GetValueProperties());
+  m_collection_sp->AppendProperty(
+      ConstString("platform"), "Platform settings.", true,
+      Platform::GetGlobalPlatformProperties().GetValueProperties());
+  m_collection_sp->AppendProperty(
+      ConstString("symbols"), "Symbol lookup and cache settings.", true,
+      ModuleList::GetGlobalModuleListProperties().GetValueProperties());
+  if (m_command_interpreter_up) {
+    m_collection_sp->AppendProperty(
+        ConstString("interpreter"),
+        "Settings specify to the debugger's command interpreter.", true,
+        m_command_interpreter_up->GetValueProperties());
+  }
   if (log_callback)
     m_callback_handler_sp =
         std::make_shared<CallbackLogHandler>(log_callback, baton);
@@ -836,21 +851,6 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
   }
   assert(m_dummy_target_sp.get() && "Couldn't construct dummy target?");
 
-  m_collection_sp->AppendProperty(
-      ConstString("target"), "Settings specify to debugging targets.", true,
-      Target::GetGlobalProperties().GetValueProperties());
-  m_collection_sp->AppendProperty(
-      ConstString("platform"), "Platform settings.", true,
-      Platform::GetGlobalPlatformProperties().GetValueProperties());
-  m_collection_sp->AppendProperty(
-      ConstString("symbols"), "Symbol lookup and cache settings.", true,
-      ModuleList::GetGlobalModuleListProperties().GetValueProperties());
-  if (m_command_interpreter_up) {
-    m_collection_sp->AppendProperty(
-        ConstString("interpreter"),
-        "Settings specify to the debugger's command interpreter.", true,
-        m_command_interpreter_up->GetValueProperties());
-  }
   OptionValueSInt64 *term_width =
       m_collection_sp->GetPropertyAtIndexAsOptionValueSInt64(
           ePropertyTerminalWidth);

diff  --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index ee3c2b88bab75..5ed5bd49cbe0d 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -97,19 +97,18 @@ ModuleListProperties::ModuleListProperties() {
 
 bool ModuleListProperties::GetEnableExternalLookup() const {
   const uint32_t idx = ePropertyEnableExternalLookup;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_modulelist_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_modulelist_properties[idx].default_uint_value != 0);
 }
 
 bool ModuleListProperties::SetEnableExternalLookup(bool new_value) {
-  return m_collection_sp->SetPropertyAtIndexAsBoolean(
-      ePropertyEnableExternalLookup, new_value);
+  return SetPropertyAtIndex(ePropertyEnableExternalLookup, new_value);
 }
 
 bool ModuleListProperties::GetEnableBackgroundLookup() const {
   const uint32_t idx = ePropertyEnableBackgroundLookup;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_modulelist_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_modulelist_properties[idx].default_uint_value != 0);
 }
 
 FileSpec ModuleListProperties::GetClangModulesCachePath() const {
@@ -136,31 +135,30 @@ bool ModuleListProperties::SetLLDBIndexCachePath(const FileSpec &path) {
 
 bool ModuleListProperties::GetEnableLLDBIndexCache() const {
   const uint32_t idx = ePropertyEnableLLDBIndexCache;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_modulelist_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_modulelist_properties[idx].default_uint_value != 0);
 }
 
 bool ModuleListProperties::SetEnableLLDBIndexCache(bool new_value) {
-  return m_collection_sp->SetPropertyAtIndexAsBoolean(
-      ePropertyEnableLLDBIndexCache, new_value);
+  return SetPropertyAtIndex(ePropertyEnableLLDBIndexCache, new_value);
 }
 
 uint64_t ModuleListProperties::GetLLDBIndexCacheMaxByteSize() {
   const uint32_t idx = ePropertyLLDBIndexCacheMaxByteSize;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_modulelist_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_modulelist_properties[idx].default_uint_value);
 }
 
 uint64_t ModuleListProperties::GetLLDBIndexCacheMaxPercent() {
   const uint32_t idx = ePropertyLLDBIndexCacheMaxPercent;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_modulelist_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_modulelist_properties[idx].default_uint_value);
 }
 
 uint64_t ModuleListProperties::GetLLDBIndexCacheExpirationDays() {
   const uint32_t idx = ePropertyLLDBIndexCacheExpirationDays;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_modulelist_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_modulelist_properties[idx].default_uint_value);
 }
 
 void ModuleListProperties::UpdateSymlinkMappings() {
@@ -186,8 +184,8 @@ PathMappingList ModuleListProperties::GetSymlinkMappings() const {
 
 bool ModuleListProperties::GetLoadSymbolOnDemand() {
   const uint32_t idx = ePropertyLoadSymbolOnDemand;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_modulelist_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_modulelist_properties[idx].default_uint_value != 0);
 }
 
 ModuleList::ModuleList() : m_modules(), m_modules_mutex() {}

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index b251dfe245ffd..bb855665e76e9 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -146,41 +146,41 @@ CommandInterpreter::CommandInterpreter(Debugger &debugger,
 
 bool CommandInterpreter::GetExpandRegexAliases() const {
   const uint32_t idx = ePropertyExpandRegexAliases;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 bool CommandInterpreter::GetPromptOnQuit() const {
   const uint32_t idx = ePropertyPromptOnQuit;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 void CommandInterpreter::SetPromptOnQuit(bool enable) {
   const uint32_t idx = ePropertyPromptOnQuit;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable);
+  SetPropertyAtIndex(idx, enable);
 }
 
 bool CommandInterpreter::GetSaveSessionOnQuit() const {
   const uint32_t idx = ePropertySaveSessionOnQuit;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 void CommandInterpreter::SetSaveSessionOnQuit(bool enable) {
   const uint32_t idx = ePropertySaveSessionOnQuit;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable);
+  SetPropertyAtIndex(idx, enable);
 }
 
 bool CommandInterpreter::GetOpenTranscriptInEditor() const {
   const uint32_t idx = ePropertyOpenTranscriptInEditor;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) {
   const uint32_t idx = ePropertyOpenTranscriptInEditor;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable);
+  SetPropertyAtIndex(idx, enable);
 }
 
 FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
@@ -190,29 +190,29 @@ FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
 
 void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) {
   const uint32_t idx = ePropertySaveSessionDirectory;
-  m_collection_sp->SetPropertyAtIndexAsString(idx, path);
+  SetPropertyAtIndex(idx, path);
 }
 
 bool CommandInterpreter::GetEchoCommands() const {
   const uint32_t idx = ePropertyEchoCommands;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 void CommandInterpreter::SetEchoCommands(bool enable) {
   const uint32_t idx = ePropertyEchoCommands;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable);
+  SetPropertyAtIndex(idx, enable);
 }
 
 bool CommandInterpreter::GetEchoCommentCommands() const {
   const uint32_t idx = ePropertyEchoCommentCommands;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 void CommandInterpreter::SetEchoCommentCommands(bool enable) {
   const uint32_t idx = ePropertyEchoCommentCommands;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable);
+  SetPropertyAtIndex(idx, enable);
 }
 
 void CommandInterpreter::AllowExitCodeOnQuit(bool allow) {
@@ -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(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 bool CommandInterpreter::GetSpaceReplPrompts() const {
   const uint32_t idx = ePropertySpaceReplPrompts;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 bool CommandInterpreter::GetRepeatPreviousCommand() const {
   const uint32_t idx = ePropertyRepeatPreviousCommand;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 bool CommandInterpreter::GetRequireCommandOverwrite() const {
   const uint32_t idx = ePropertyRequireCommandOverwrite;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_interpreter_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
 void CommandInterpreter::Initialize() {

diff  --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp
index 20d613af94817..53f3c3a808446 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -277,28 +277,6 @@ bool OptionValueProperties::SetPropertyAtIndexFromArgs(
   return false;
 }
 
-std::optional<bool> OptionValueProperties::GetPropertyAtIndexAsBoolean(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
-  if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) {
-    if (OptionValue *value = property->GetValue().get())
-      return value->GetBooleanValue();
-  }
-  return {};
-}
-
-bool OptionValueProperties::SetPropertyAtIndexAsBoolean(
-    uint32_t idx, bool new_value, const ExecutionContext *exe_ctx) {
-  const Property *property = GetPropertyAtIndex(idx, exe_ctx);
-  if (property) {
-    OptionValue *value = property->GetValue().get();
-    if (value) {
-      value->SetBooleanValue(new_value);
-      return true;
-    }
-  }
-  return false;
-}
-
 OptionValueDictionary *
 OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary(
     uint32_t idx, const ExecutionContext *exe_ctx) const {
@@ -308,38 +286,6 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary(
   return nullptr;
 }
 
-std::optional<int64_t> OptionValueProperties::GetPropertyAtIndexAsEnumeration(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
-  if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) {
-    if (OptionValue *value = property->GetValue().get())
-      return value->GetEnumerationValue();
-  }
-  return {};
-}
-
-bool OptionValueProperties::SetPropertyAtIndexAsEnumeration(
-    uint32_t idx, int64_t new_value, const ExecutionContext *exe_ctx) {
-  const Property *property = GetPropertyAtIndex(idx, exe_ctx);
-  if (property) {
-    OptionValue *value = property->GetValue().get();
-    if (value)
-      return value->SetEnumerationValue(new_value);
-  }
-  return false;
-}
-
-const FormatEntity::Entry *
-OptionValueProperties::GetPropertyAtIndexAsFormatEntity(
-    uint32_t idx, const ExecutionContext *exe_ctx) {
-  const Property *property = GetPropertyAtIndex(idx, exe_ctx);
-  if (property) {
-    OptionValue *value = property->GetValue().get();
-    if (value)
-      return value->GetFormatEntity();
-  }
-  return nullptr;
-}
-
 OptionValueFileSpec *
 OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpec(
     uint32_t idx, const ExecutionContext *exe_ctx) const {
@@ -375,18 +321,6 @@ bool OptionValueProperties::SetPropertyAtIndexAsFileSpec(
   return false;
 }
 
-const RegularExpression *
-OptionValueProperties::GetPropertyAtIndexAsOptionValueRegex(
-    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->GetRegexValue();
-  }
-  return nullptr;
-}
-
 OptionValueSInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueSInt64(
     uint32_t idx, const ExecutionContext *exe_ctx) const {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);
@@ -409,47 +343,6 @@ OptionValueUInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueUInt64(
   return nullptr;
 }
 
-std::optional<int64_t> OptionValueProperties::GetPropertyAtIndexAsSInt64(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
-  if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) {
-    if (OptionValue *value = property->GetValue().get())
-      return value->GetSInt64Value();
-  }
-  return {};
-}
-
-bool OptionValueProperties::SetPropertyAtIndexAsSInt64(
-    uint32_t idx, int64_t new_value, const ExecutionContext *exe_ctx) {
-  const Property *property = GetPropertyAtIndex(idx, exe_ctx);
-  if (property) {
-    OptionValue *value = property->GetValue().get();
-    if (value)
-      return value->SetSInt64Value(new_value);
-  }
-  return false;
-}
-
-std::optional<llvm::StringRef>
-OptionValueProperties::GetPropertyAtIndexAsString(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
-  if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) {
-    if (OptionValue *value = property->GetValue().get())
-      return value->GetStringValue();
-  }
-  return {};
-}
-
-bool OptionValueProperties::SetPropertyAtIndexAsString(
-    uint32_t idx, llvm::StringRef new_value, const ExecutionContext *exe_ctx) {
-  const Property *property = GetPropertyAtIndex(idx, exe_ctx);
-  if (property) {
-    OptionValue *value = property->GetValue().get();
-    if (value)
-      return value->SetStringValue(new_value);
-  }
-  return false;
-}
-
 OptionValueString *OptionValueProperties::GetPropertyAtIndexAsOptionValueString(
     uint32_t idx, const ExecutionContext *exe_ctx) const {
   OptionValueSP value_sp(GetPropertyValueAtIndex(idx, exe_ctx));
@@ -458,26 +351,6 @@ OptionValueString *OptionValueProperties::GetPropertyAtIndexAsOptionValueString(
   return nullptr;
 }
 
-std::optional<uint64_t> OptionValueProperties::GetPropertyAtIndexAsUInt64(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
-  if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) {
-    if (OptionValue *value = property->GetValue().get())
-      return value->GetUInt64Value();
-  }
-  return {};
-}
-
-bool OptionValueProperties::SetPropertyAtIndexAsUInt64(
-    uint32_t idx, uint64_t new_value, const ExecutionContext *exe_ctx) {
-  const Property *property = GetPropertyAtIndex(idx, exe_ctx);
-  if (property) {
-    OptionValue *value = property->GetValue().get();
-    if (value)
-      return value->SetUInt64Value(new_value);
-  }
-  return false;
-}
-
 void OptionValueProperties::Clear() {
   const size_t num_properties = m_properties.size();
   for (size_t i = 0; i < num_properties; ++i)

diff  --git a/lldb/source/Interpreter/Property.cpp b/lldb/source/Interpreter/Property.cpp
index 681596224d31a..56e45363be89a 100644
--- a/lldb/source/Interpreter/Property.cpp
+++ b/lldb/source/Interpreter/Property.cpp
@@ -226,6 +226,7 @@ Property::Property(const PropertyDefinition &definition)
     }
     break;
   }
+  assert(m_value_sp && "invalid property definition");
 }
 
 Property::Property(llvm::StringRef name, llvm::StringRef desc, bool is_global,

diff  --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index be0ccd390b7f9..846fdbbaa4aba 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -113,15 +113,17 @@ class DynamicLoaderDarwinKernelProperties : public Properties {
 
   bool GetLoadKexts() const {
     const uint32_t idx = ePropertyLoadKexts;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
+    return GetPropertyAtIndexAs<bool>(
+        idx,
         g_dynamicloaderdarwinkernel_properties[idx].default_uint_value != 0);
   }
 
   KASLRScanType GetScanType() const {
     const uint32_t idx = ePropertyScanType;
-    return (KASLRScanType)m_collection_sp->GetPropertyAtIndexAsEnumeration(idx)
-        .value_or(
-            g_dynamicloaderdarwinkernel_properties[idx].default_uint_value);
+    return GetPropertyAtIndexAs<KASLRScanType>(
+        idx,
+        static_cast<KASLRScanType>(
+            g_dynamicloaderdarwinkernel_properties[idx].default_uint_value));
   }
 };
 

diff  --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
index e9eddd023ba52..b78f45cf1efdf 100644
--- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -99,10 +99,10 @@ class PluginProperties : public Properties {
   }
 
   EnableJITLoaderGDB GetEnable() const {
-    return (EnableJITLoaderGDB)m_collection_sp
-        ->GetPropertyAtIndexAsEnumeration(ePropertyEnable)
-        .value_or(
-            g_jitloadergdb_properties[ePropertyEnable].default_uint_value);
+    return GetPropertyAtIndexAs<EnableJITLoaderGDB>(
+        ePropertyEnable,
+        static_cast<EnableJITLoaderGDB>(
+            g_jitloadergdb_properties[ePropertyEnable].default_uint_value));
   }
 };
 } // namespace

diff  --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 97f40aef769b4..1c166c03e1f7a 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -90,9 +90,8 @@ class PluginProperties : public Properties {
   }
 
   llvm::Triple::EnvironmentType ABI() const {
-    return (llvm::Triple::EnvironmentType)m_collection_sp
-        ->GetPropertyAtIndexAsEnumeration(ePropertyABI)
-        .value_or(llvm::Triple::UnknownEnvironment);
+    return GetPropertyAtIndexAs<llvm::Triple::EnvironmentType>(
+        ePropertyABI, llvm::Triple::UnknownEnvironment);
   }
 
   OptionValueDictionary *ModuleABIMap() const {

diff  --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
index 5510baaab3ac0..b374719992c01 100644
--- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
+++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
@@ -41,8 +41,7 @@ class PluginProperties : public Properties {
   }
 
   llvm::StringRef GetArchitecture() {
-    return m_collection_sp->GetPropertyAtIndexAsString(ePropertyArchitecture)
-        .value_or("");
+    return GetPropertyAtIndexAs<llvm::StringRef>(ePropertyArchitecture, "");
   }
 
   FileSpec GetEmulatorPath() {

diff  --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 3ac059a05122e..7f984233f0c26 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -78,8 +78,8 @@ class PluginProperties : public Properties {
 
   uint64_t GetPacketTimeout() {
     const uint32_t idx = ePropertyKDPPacketTimeout;
-    return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-        g_processkdp_properties[idx].default_uint_value);
+    return GetPropertyAtIndexAs<uint64_t>(
+        idx, g_processkdp_properties[idx].default_uint_value);
   }
 };
 

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 7047ae62d07c6..f3754f8c238c9 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -142,13 +142,13 @@ class PluginProperties : public Properties {
 
   uint64_t GetPacketTimeout() {
     const uint32_t idx = ePropertyPacketTimeout;
-    return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-        g_processgdbremote_properties[idx].default_uint_value);
+    return GetPropertyAtIndexAs<uint64_t>(
+        idx, g_processgdbremote_properties[idx].default_uint_value);
   }
 
   bool SetPacketTimeout(uint64_t timeout) {
     const uint32_t idx = ePropertyPacketTimeout;
-    return m_collection_sp->SetPropertyAtIndexAsUInt64(idx, timeout);
+    return SetPropertyAtIndex(idx, timeout);
   }
 
   FileSpec GetTargetDefinitionFile() const {
@@ -158,13 +158,13 @@ class PluginProperties : public Properties {
 
   bool GetUseSVR4() const {
     const uint32_t idx = ePropertyUseSVR4;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-        g_processgdbremote_properties[idx].default_uint_value != 0);
+    return GetPropertyAtIndexAs<bool>(
+        idx, g_processgdbremote_properties[idx].default_uint_value != 0);
   }
 
   bool GetUseGPacketForReading() const {
     const uint32_t idx = ePropertyUseGPacketForReading;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(true);
+    return GetPropertyAtIndexAs<bool>(idx, true);
   }
 };
 

diff  --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index 53c89bd5f618b..deebf0700f947 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -131,14 +131,14 @@ class StructuredDataDarwinLogProperties : public Properties {
 
   bool GetEnableOnStartup() const {
     const uint32_t idx = ePropertyEnableOnStartup;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-        g_darwinlog_properties[idx].default_uint_value != 0);
+    return GetPropertyAtIndexAs<bool>(
+        idx, g_darwinlog_properties[idx].default_uint_value != 0);
   }
 
   llvm::StringRef GetAutoEnableOptions() const {
     const uint32_t idx = ePropertyAutoEnableOptions;
-    return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-        g_darwinlog_properties[idx].default_cstr_value);
+    return GetPropertyAtIndexAs<llvm::StringRef>(
+        idx, g_darwinlog_properties[idx].default_cstr_value);
   }
 
   const char *GetLoggingModuleName() const { return "libsystem_trace.dylib"; }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index ff3abd6fb9021..674977cd7b59a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -125,8 +125,7 @@ class PluginProperties : public Properties {
   }
 
   bool IgnoreFileIndexes() const {
-    return m_collection_sp->GetPropertyAtIndexAsBoolean(ePropertyIgnoreIndexes)
-        .value_or(false);
+    return GetPropertyAtIndexAs<bool>(ePropertyIgnoreIndexes, false);
   }
 };
 

diff  --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index eb1fea96c97c1..92c06dde12a92 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -99,13 +99,12 @@ PlatformProperties::PlatformProperties() {
 
 bool PlatformProperties::GetUseModuleCache() const {
   const auto idx = ePropertyUseModuleCache;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_platform_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_platform_properties[idx].default_uint_value != 0);
 }
 
 bool PlatformProperties::SetUseModuleCache(bool use_module_cache) {
-  return m_collection_sp->SetPropertyAtIndexAsBoolean(ePropertyUseModuleCache,
-                                                      use_module_cache);
+  return SetPropertyAtIndex(ePropertyUseModuleCache, use_module_cache);
 }
 
 FileSpec PlatformProperties::GetModuleCacheDirectory() const {

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2e7e8e6721bd6..f53cadf28f783 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -190,14 +190,14 @@ ProcessProperties::~ProcessProperties() = default;
 
 bool ProcessProperties::GetDisableMemoryCache() const {
   const uint32_t idx = ePropertyDisableMemCache;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 uint64_t ProcessProperties::GetMemoryCacheLineSize() const {
   const uint32_t idx = ePropertyMemCacheLineSize;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_process_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_process_properties[idx].default_uint_value);
 }
 
 Args ProcessProperties::GetExtraStartupCommands() const {
@@ -219,13 +219,13 @@ FileSpec ProcessProperties::GetPythonOSPluginPath() const {
 
 uint32_t ProcessProperties::GetVirtualAddressableBits() const {
   const uint32_t idx = ePropertyVirtualAddressableBits;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_process_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_process_properties[idx].default_uint_value);
 }
 
 void ProcessProperties::SetVirtualAddressableBits(uint32_t bits) {
   const uint32_t idx = ePropertyVirtualAddressableBits;
-  m_collection_sp->SetPropertyAtIndexAsUInt64(idx, bits);
+  SetPropertyAtIndex(idx, bits);
 }
 void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) {
   const uint32_t idx = ePropertyPythonOSPluginPath;
@@ -234,96 +234,96 @@ void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) {
 
 bool ProcessProperties::GetIgnoreBreakpointsInExpressions() const {
   const uint32_t idx = ePropertyIgnoreBreakpointsInExpressions;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 void ProcessProperties::SetIgnoreBreakpointsInExpressions(bool ignore) {
   const uint32_t idx = ePropertyIgnoreBreakpointsInExpressions;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, ignore);
+  SetPropertyAtIndex(idx, ignore);
 }
 
 bool ProcessProperties::GetUnwindOnErrorInExpressions() const {
   const uint32_t idx = ePropertyUnwindOnErrorInExpressions;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 void ProcessProperties::SetUnwindOnErrorInExpressions(bool ignore) {
   const uint32_t idx = ePropertyUnwindOnErrorInExpressions;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, ignore);
+  SetPropertyAtIndex(idx, ignore);
 }
 
 bool ProcessProperties::GetStopOnSharedLibraryEvents() const {
   const uint32_t idx = ePropertyStopOnSharedLibraryEvents;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 void ProcessProperties::SetStopOnSharedLibraryEvents(bool stop) {
   const uint32_t idx = ePropertyStopOnSharedLibraryEvents;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, stop);
+  SetPropertyAtIndex(idx, stop);
 }
 
 bool ProcessProperties::GetDisableLangRuntimeUnwindPlans() const {
   const uint32_t idx = ePropertyDisableLangRuntimeUnwindPlans;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 void ProcessProperties::SetDisableLangRuntimeUnwindPlans(bool disable) {
   const uint32_t idx = ePropertyDisableLangRuntimeUnwindPlans;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, disable);
+  SetPropertyAtIndex(idx, disable);
   m_process->Flush();
 }
 
 bool ProcessProperties::GetDetachKeepsStopped() const {
   const uint32_t idx = ePropertyDetachKeepsStopped;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 void ProcessProperties::SetDetachKeepsStopped(bool stop) {
   const uint32_t idx = ePropertyDetachKeepsStopped;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, stop);
+  SetPropertyAtIndex(idx, stop);
 }
 
 bool ProcessProperties::GetWarningsOptimization() const {
   const uint32_t idx = ePropertyWarningOptimization;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 bool ProcessProperties::GetWarningsUnsupportedLanguage() const {
   const uint32_t idx = ePropertyWarningUnsupportedLanguage;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 bool ProcessProperties::GetStopOnExec() const {
   const uint32_t idx = ePropertyStopOnExec;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 std::chrono::seconds ProcessProperties::GetUtilityExpressionTimeout() const {
   const uint32_t idx = ePropertyUtilityExpressionTimeout;
-  uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_process_properties[idx].default_uint_value);
+  uint64_t value = GetPropertyAtIndexAs<uint64_t>(
+      idx, g_process_properties[idx].default_uint_value);
   return std::chrono::seconds(value);
 }
 
 std::chrono::seconds ProcessProperties::GetInterruptTimeout() const {
   const uint32_t idx = ePropertyInterruptTimeout;
-  uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_process_properties[idx].default_uint_value);
+  uint64_t value = GetPropertyAtIndexAs<uint64_t>(
+      idx, g_process_properties[idx].default_uint_value);
   return std::chrono::seconds(value);
 }
 
 bool ProcessProperties::GetSteppingRunsAllThreads() const {
   const uint32_t idx = ePropertySteppingRunsAllThreads;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_process_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_process_properties[idx].default_uint_value != 0);
 }
 
 bool ProcessProperties::GetOSPluginReportsAllThreads() const {
@@ -336,7 +336,7 @@ bool ProcessProperties::GetOSPluginReportsAllThreads() const {
     return fail_value;
 
   return exp_values
-      ->GetPropertyAtIndexAsBoolean(ePropertyOSPluginReportsAllThreads)
+      ->GetPropertyAtIndexAs<bool>(ePropertyOSPluginReportsAllThreads)
       .value_or(fail_value);
 }
 
@@ -346,14 +346,15 @@ void ProcessProperties::SetOSPluginReportsAllThreads(bool does_report) {
   OptionValueProperties *exp_values =
       exp_property->GetValue()->GetAsProperties();
   if (exp_values)
-    exp_values->SetPropertyAtIndexAsBoolean(ePropertyOSPluginReportsAllThreads,
-                                            does_report);
+    exp_values->SetPropertyAtIndex(ePropertyOSPluginReportsAllThreads,
+                                   does_report);
 }
 
 FollowForkMode ProcessProperties::GetFollowForkMode() const {
   const uint32_t idx = ePropertyFollowForkMode;
-  return (FollowForkMode)m_collection_sp->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_process_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<FollowForkMode>(
+      idx, static_cast<FollowForkMode>(
+               g_process_properties[idx].default_uint_value));
 }
 
 ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 74ab4ea373d84..7a61fa966a9f6 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4136,7 +4136,7 @@ bool TargetProperties::GetInjectLocalVariables(
       exp_property->GetValue()->GetAsProperties();
   if (exp_values)
     return exp_values
-        ->GetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, exe_ctx)
+        ->GetPropertyAtIndexAs<bool>(ePropertyInjectLocalVars, exe_ctx)
         .value_or(true);
   else
     return true;
@@ -4149,8 +4149,7 @@ void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
   OptionValueProperties *exp_values =
       exp_property->GetValue()->GetAsProperties();
   if (exp_values)
-    exp_values->SetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, true,
-                                            exe_ctx);
+    exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx);
 }
 
 ArchSpec TargetProperties::GetDefaultArchitecture() const {
@@ -4170,75 +4169,75 @@ void TargetProperties::SetDefaultArchitecture(const ArchSpec &arch) {
 
 bool TargetProperties::GetMoveToNearestCode() const {
   const uint32_t idx = ePropertyMoveToNearestCode;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 lldb::DynamicValueType TargetProperties::GetPreferDynamicValue() const {
   const uint32_t idx = ePropertyPreferDynamic;
-  return (lldb::DynamicValueType)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<lldb::DynamicValueType>(
+      idx, static_cast<lldb::DynamicValueType>(
+               g_target_properties[idx].default_uint_value));
 }
 
 bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) {
   const uint32_t idx = ePropertyPreferDynamic;
-  return m_collection_sp->SetPropertyAtIndexAsEnumeration(idx, d);
+  return SetPropertyAtIndex(idx, d);
 }
 
 bool TargetProperties::GetPreloadSymbols() const {
   const uint32_t idx = ePropertyPreloadSymbols;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::SetPreloadSymbols(bool b) {
   const uint32_t idx = ePropertyPreloadSymbols;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  SetPropertyAtIndex(idx, b);
 }
 
 bool TargetProperties::GetDisableASLR() const {
   const uint32_t idx = ePropertyDisableASLR;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::SetDisableASLR(bool b) {
   const uint32_t idx = ePropertyDisableASLR;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  SetPropertyAtIndex(idx, b);
 }
 
 bool TargetProperties::GetInheritTCC() const {
   const uint32_t idx = ePropertyInheritTCC;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::SetInheritTCC(bool b) {
   const uint32_t idx = ePropertyInheritTCC;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  SetPropertyAtIndex(idx, b);
 }
 
 bool TargetProperties::GetDetachOnError() const {
   const uint32_t idx = ePropertyDetachOnError;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::SetDetachOnError(bool b) {
   const uint32_t idx = ePropertyDetachOnError;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  SetPropertyAtIndex(idx, b);
 }
 
 bool TargetProperties::GetDisableSTDIO() const {
   const uint32_t idx = ePropertyDisableSTDIO;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::SetDisableSTDIO(bool b) {
   const uint32_t idx = ePropertyDisableSTDIO;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  SetPropertyAtIndex(idx, b);
 }
 
 const char *TargetProperties::GetDisassemblyFlavor() const {
@@ -4246,28 +4245,30 @@ const char *TargetProperties::GetDisassemblyFlavor() const {
   const char *return_value;
 
   x86DisassemblyFlavor flavor_value =
-      (x86DisassemblyFlavor)m_collection_sp
-          ->GetPropertyAtIndexAsEnumeration(idx)
-          .value_or(g_target_properties[idx].default_uint_value);
+      GetPropertyAtIndexAs<x86DisassemblyFlavor>(
+          idx, static_cast<x86DisassemblyFlavor>(
+                   g_target_properties[idx].default_uint_value));
+
   return_value = g_x86_dis_flavor_value_types[flavor_value].string_value;
   return return_value;
 }
 
 InlineStrategy TargetProperties::GetInlineStrategy() const {
   const uint32_t idx = ePropertyInlineStrategy;
-  return (InlineStrategy)m_collection_sp->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<InlineStrategy>(
+      idx,
+      static_cast<InlineStrategy>(g_target_properties[idx].default_uint_value));
 }
 
 llvm::StringRef TargetProperties::GetArg0() const {
   const uint32_t idx = ePropertyArg0;
-  return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or(
-      g_target_properties[idx].default_cstr_value);
+  return GetPropertyAtIndexAs<llvm::StringRef>(
+      idx, g_target_properties[idx].default_cstr_value);
 }
 
 void TargetProperties::SetArg0(llvm::StringRef arg) {
   const uint32_t idx = ePropertyArg0;
-  m_collection_sp->SetPropertyAtIndexAsString(idx, arg);
+  SetPropertyAtIndex(idx, arg);
   m_launch_info.SetArg0(arg);
 }
 
@@ -4286,10 +4287,9 @@ Environment TargetProperties::ComputeEnvironment() const {
   Environment env;
 
   if (m_target &&
-      m_collection_sp->GetPropertyAtIndexAsBoolean(ePropertyInheritEnv)
-          .value_or(
-              g_target_properties[ePropertyInheritEnv].default_uint_value !=
-              0)) {
+      GetPropertyAtIndexAs<bool>(
+          ePropertyInheritEnv,
+          g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) {
     if (auto platform_sp = m_target->GetPlatform()) {
       Environment platform_env = platform_sp->GetEnvironment();
       for (const auto &KV : platform_env)
@@ -4321,10 +4321,9 @@ Environment TargetProperties::GetInheritedEnvironment() const {
   if (m_target == nullptr)
     return environment;
 
-  if (!m_collection_sp->GetPropertyAtIndexAsBoolean(ePropertyInheritEnv)
-           .value_or(
-               g_target_properties[ePropertyInheritEnv].default_uint_value !=
-               0))
+  if (!GetPropertyAtIndexAs<bool>(
+          ePropertyInheritEnv,
+          g_target_properties[ePropertyInheritEnv].default_uint_value != 0))
     return environment;
 
   PlatformSP platform_sp = m_target->GetPlatform();
@@ -4363,8 +4362,8 @@ void TargetProperties::SetEnvironment(Environment env) {
 
 bool TargetProperties::GetSkipPrologue() const {
   const uint32_t idx = ePropertySkipPrologue;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 PathMappingList &TargetProperties::GetSourcePathMap() const {
@@ -4377,8 +4376,8 @@ PathMappingList &TargetProperties::GetSourcePathMap() const {
 
 bool TargetProperties::GetAutoSourceMapRelative() const {
   const uint32_t idx = ePropertyAutoSourceMapRelative;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::AppendExecutableSearchPaths(const FileSpec &dir) {
@@ -4415,39 +4414,40 @@ FileSpecList TargetProperties::GetClangModuleSearchPaths() {
 
 bool TargetProperties::GetEnableAutoImportClangModules() const {
   const uint32_t idx = ePropertyAutoImportClangModules;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 ImportStdModule TargetProperties::GetImportStdModule() const {
   const uint32_t idx = ePropertyImportStdModule;
-  return (ImportStdModule)m_collection_sp->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<ImportStdModule>(
+      idx, static_cast<ImportStdModule>(
+               g_target_properties[idx].default_uint_value));
 }
 
 DynamicClassInfoHelper TargetProperties::GetDynamicClassInfoHelper() const {
   const uint32_t idx = ePropertyDynamicClassInfoHelper;
-  return (DynamicClassInfoHelper)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<DynamicClassInfoHelper>(
+      idx, static_cast<DynamicClassInfoHelper>(
+               g_target_properties[idx].default_uint_value));
 }
 
 bool TargetProperties::GetEnableAutoApplyFixIts() const {
   const uint32_t idx = ePropertyAutoApplyFixIts;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 uint64_t TargetProperties::GetNumberOfRetriesWithFixits() const {
   const uint32_t idx = ePropertyRetriesWithFixIts;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_target_properties[idx].default_uint_value);
 }
 
 bool TargetProperties::GetEnableNotifyAboutFixIts() const {
   const uint32_t idx = ePropertyNotifyAboutFixIts;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 FileSpec TargetProperties::GetSaveJITObjectsDir() const {
@@ -4490,20 +4490,20 @@ void TargetProperties::CheckJITObjectsDir() {
 
 bool TargetProperties::GetEnableSyntheticValue() const {
   const uint32_t idx = ePropertyEnableSynthetic;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const {
   const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_target_properties[idx].default_uint_value);
 }
 
 uint32_t TargetProperties::GetMaximumNumberOfChildrenToDisplay() const {
   const uint32_t idx = ePropertyMaxChildrenCount;
-  return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or(
-      g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<int64_t>(
+      idx, g_target_properties[idx].default_uint_value);
 }
 
 std::pair<uint32_t, bool>
@@ -4517,14 +4517,14 @@ TargetProperties::GetMaximumDepthOfChildrenToDisplay() const {
 
 uint32_t TargetProperties::GetMaximumSizeOfStringSummary() const {
   const uint32_t idx = ePropertyMaxSummaryLength;
-  return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or(
-      g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_target_properties[idx].default_uint_value);
 }
 
 uint32_t TargetProperties::GetMaximumMemReadSize() const {
   const uint32_t idx = ePropertyMaxMemReadSize;
-  return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or(
-      g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_target_properties[idx].default_uint_value);
 }
 
 FileSpec TargetProperties::GetStandardInputPath() const {
@@ -4534,7 +4534,7 @@ FileSpec TargetProperties::GetStandardInputPath() const {
 
 void TargetProperties::SetStandardInputPath(llvm::StringRef path) {
   const uint32_t idx = ePropertyInputPath;
-  m_collection_sp->SetPropertyAtIndexAsString(idx, path);
+  SetPropertyAtIndex(idx, path);
 }
 
 FileSpec TargetProperties::GetStandardOutputPath() const {
@@ -4544,7 +4544,7 @@ FileSpec TargetProperties::GetStandardOutputPath() const {
 
 void TargetProperties::SetStandardOutputPath(llvm::StringRef path) {
   const uint32_t idx = ePropertyOutputPath;
-  m_collection_sp->SetPropertyAtIndexAsString(idx, path);
+  SetPropertyAtIndex(idx, path);
 }
 
 FileSpec TargetProperties::GetStandardErrorPath() const {
@@ -4554,7 +4554,7 @@ FileSpec TargetProperties::GetStandardErrorPath() const {
 
 void TargetProperties::SetStandardErrorPath(llvm::StringRef path) {
   const uint32_t idx = ePropertyErrorPath;
-  m_collection_sp->SetPropertyAtIndexAsString(idx, path);
+  SetPropertyAtIndex(idx, path);
 }
 
 LanguageType TargetProperties::GetLanguage() const {
@@ -4582,78 +4582,78 @@ llvm::StringRef TargetProperties::GetExpressionPrefixContents() {
 
 uint64_t TargetProperties::GetExprErrorLimit() const {
   const uint32_t idx = ePropertyExprErrorLimit;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_target_properties[idx].default_uint_value);
 }
 
 uint64_t TargetProperties::GetExprAllocAddress() const {
   const uint32_t idx = ePropertyExprAllocAddress;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_target_properties[idx].default_uint_value);
 }
 
 uint64_t TargetProperties::GetExprAllocSize() const {
   const uint32_t idx = ePropertyExprAllocSize;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_target_properties[idx].default_uint_value);
 }
 
 uint64_t TargetProperties::GetExprAllocAlign() const {
   const uint32_t idx = ePropertyExprAllocAlign;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_target_properties[idx].default_uint_value);
 }
 
 bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() {
   const uint32_t idx = ePropertyBreakpointUseAvoidList;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 bool TargetProperties::GetUseHexImmediates() const {
   const uint32_t idx = ePropertyUseHexImmediates;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 bool TargetProperties::GetUseFastStepping() const {
   const uint32_t idx = ePropertyUseFastStepping;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 bool TargetProperties::GetDisplayExpressionsInCrashlogs() const {
   const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 LoadScriptFromSymFile TargetProperties::GetLoadScriptFromSymbolFile() const {
   const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
-  return (LoadScriptFromSymFile)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<LoadScriptFromSymFile>(
+      idx, static_cast<LoadScriptFromSymFile>(
+               g_target_properties[idx].default_uint_value));
 }
 
 LoadCWDlldbinitFile TargetProperties::GetLoadCWDlldbinitFile() const {
   const uint32_t idx = ePropertyLoadCWDlldbinitFile;
-  return (LoadCWDlldbinitFile)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<LoadCWDlldbinitFile>(
+      idx, static_cast<LoadCWDlldbinitFile>(
+               g_target_properties[idx].default_uint_value));
 }
 
 Disassembler::HexImmediateStyle TargetProperties::GetHexImmediateStyle() const {
   const uint32_t idx = ePropertyHexImmediateStyle;
-  return (Disassembler::HexImmediateStyle)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<Disassembler::HexImmediateStyle>(
+      idx, static_cast<Disassembler::HexImmediateStyle>(
+               g_target_properties[idx].default_uint_value));
 }
 
 MemoryModuleLoadLevel TargetProperties::GetMemoryModuleLoadLevel() const {
   const uint32_t idx = ePropertyMemoryModuleLoadLevel;
-  return (MemoryModuleLoadLevel)m_collection_sp
-      ->GetPropertyAtIndexAsEnumeration(idx)
-      .value_or(g_target_properties[idx].default_uint_value);
+  return GetPropertyAtIndexAs<MemoryModuleLoadLevel>(
+      idx, static_cast<MemoryModuleLoadLevel>(
+               g_target_properties[idx].default_uint_value));
 }
 
 bool TargetProperties::GetUserSpecifiedTrapHandlerNames(Args &args) const {
@@ -4668,24 +4668,24 @@ void TargetProperties::SetUserSpecifiedTrapHandlerNames(const Args &args) {
 
 bool TargetProperties::GetDisplayRuntimeSupportValues() const {
   const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::SetDisplayRuntimeSupportValues(bool b) {
   const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  SetPropertyAtIndex(idx, b);
 }
 
 bool TargetProperties::GetDisplayRecognizedArguments() const {
   const uint32_t idx = ePropertyDisplayRecognizedArguments;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::SetDisplayRecognizedArguments(bool b) {
   const uint32_t idx = ePropertyDisplayRecognizedArguments;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  SetPropertyAtIndex(idx, b);
 }
 
 const ProcessLaunchInfo &TargetProperties::GetProcessLaunchInfo() const {
@@ -4722,19 +4722,19 @@ void TargetProperties::SetProcessLaunchInfo(
 
 bool TargetProperties::GetRequireHardwareBreakpoints() const {
   const uint32_t idx = ePropertyRequireHardwareBreakpoints;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::SetRequireHardwareBreakpoints(bool b) {
   const uint32_t idx = ePropertyRequireHardwareBreakpoints;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b);
+  m_collection_sp->SetPropertyAtIndex(idx, b);
 }
 
 bool TargetProperties::GetAutoInstallMainExecutable() const {
   const uint32_t idx = ePropertyAutoInstallMainExecutable;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::Arg0ValueChangedCallback() {
@@ -4796,13 +4796,13 @@ void TargetProperties::DisableSTDIOValueChangedCallback() {
 
 bool TargetProperties::GetDebugUtilityExpression() const {
   const uint32_t idx = ePropertyDebugUtilityExpression;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_target_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_target_properties[idx].default_uint_value != 0);
 }
 
 void TargetProperties::SetDebugUtilityExpression(bool debug) {
   const uint32_t idx = ePropertyDebugUtilityExpression;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(idx, debug);
+  SetPropertyAtIndex(idx, debug);
 }
 
 // Target::TargetEventData

diff  --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 2b3e8ba5ae079..a9c01e388b138 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -112,7 +112,7 @@ ThreadProperties::~ThreadProperties() = default;
 
 const RegularExpression *ThreadProperties::GetSymbolsToAvoidRegexp() {
   const uint32_t idx = ePropertyStepAvoidRegex;
-  return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(idx);
+  return GetPropertyAtIndexAs<const RegularExpression *>(idx);
 }
 
 FileSpecList ThreadProperties::GetLibrariesToAvoid() const {
@@ -125,26 +125,26 @@ FileSpecList ThreadProperties::GetLibrariesToAvoid() const {
 
 bool ThreadProperties::GetTraceEnabledState() const {
   const uint32_t idx = ePropertyEnableThreadTrace;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_thread_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_thread_properties[idx].default_uint_value != 0);
 }
 
 bool ThreadProperties::GetStepInAvoidsNoDebug() const {
   const uint32_t idx = ePropertyStepInAvoidsNoDebug;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_thread_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_thread_properties[idx].default_uint_value != 0);
 }
 
 bool ThreadProperties::GetStepOutAvoidsNoDebug() const {
   const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
-  return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(
-      g_thread_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<bool>(
+      idx, g_thread_properties[idx].default_uint_value != 0);
 }
 
 uint64_t ThreadProperties::GetMaxBacktraceDepth() const {
   const uint32_t idx = ePropertyMaxBacktraceDepth;
-  return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or(
-      g_thread_properties[idx].default_uint_value != 0);
+  return GetPropertyAtIndexAs<uint64_t>(
+      idx, g_thread_properties[idx].default_uint_value);
 }
 
 // Thread Event Data


        


More information about the lldb-commits mailing list