[Lldb-commits] [lldb] 3ebb336 - [lldb] Complete OptionValue cleanup (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Sun May 14 20:19:08 PDT 2023


Author: Jonas Devlieghere
Date: 2023-05-14T20:18:47-07:00
New Revision: 3ebb33632a1509450fdbc1fb6a21107a0a513072

URL: https://github.com/llvm/llvm-project/commit/3ebb33632a1509450fdbc1fb6a21107a0a513072
DIFF: https://github.com/llvm/llvm-project/commit/3ebb33632a1509450fdbc1fb6a21107a0a513072.diff

LOG: [lldb] Complete OptionValue cleanup (NFC)

Make the `Get.*Value` and `Set.*Value` function private and migrate the
last remaining call sites to the new overloaded/templated functions.

Added: 
    

Modified: 
    lldb/include/lldb/Core/Debugger.h
    lldb/include/lldb/Interpreter/OptionValue.h
    lldb/source/Commands/CommandObjectBreakpoint.cpp
    lldb/source/Commands/CommandObjectMemory.cpp
    lldb/source/Commands/CommandObjectRegister.cpp
    lldb/source/Core/Debugger.cpp
    lldb/source/Core/Disassembler.cpp
    lldb/source/Interpreter/OptionValue.cpp
    lldb/source/Interpreter/OptionValueArgs.cpp
    lldb/source/Interpreter/OptionValueArray.cpp
    lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
    lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
    lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
    lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
    lldb/source/Target/Process.cpp
    lldb/unittests/Interpreter/TestOptionValue.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h
index f05d8d4e6b231..54f7d5c0edb4a 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -285,7 +285,7 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
 
   uint64_t GetTerminalWidth() const;
 
-  bool SetTerminalWidth(uint32_t term_width);
+  bool SetTerminalWidth(uint64_t term_width);
 
   llvm::StringRef GetPrompt() const;
 
@@ -351,7 +351,7 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
 
   uint64_t GetTabSize() const;
 
-  bool SetTabSize(uint32_t tab_size);
+  bool SetTabSize(uint64_t tab_size);
 
   lldb::DWIMPrintVerbosity GetDWIMPrintVerbosity() const;
 

diff  --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h
index 730ec65dd054b..9e65c802b3706 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -17,6 +17,8 @@
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/FileSpecList.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StringList.h"
+#include "lldb/Utility/UUID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-private-enumerations.h"
 #include "lldb/lldb-private-interfaces.h"
@@ -260,58 +262,8 @@ class OptionValue {
 
   const OptionValueFormatEntity *GetAsFormatEntity() const;
 
-  std::optional<bool> GetBooleanValue() const;
-
-  bool SetBooleanValue(bool new_value);
-
-  std::optional<char> GetCharValue() const;
-
-  char SetCharValue(char new_value);
-
-  std::optional<int64_t> GetEnumerationValue() const;
-
-  bool SetEnumerationValue(int64_t value);
-
-  std::optional<FileSpec> GetFileSpecValue() const;
-
-  bool SetFileSpecValue(FileSpec file_spec);
-
   bool AppendFileSpecValue(FileSpec file_spec);
 
-  std::optional<FileSpecList> GetFileSpecListValue() const;
-
-  std::optional<lldb::Format> GetFormatValue() const;
-
-  bool SetFormatValue(lldb::Format new_value);
-
-  std::optional<lldb::LanguageType> GetLanguageValue() const;
-
-  bool SetLanguageValue(lldb::LanguageType new_language);
-
-  const FormatEntity::Entry *GetFormatEntity() const;
-
-  const RegularExpression *GetRegexValue() const;
-
-  std::optional<int64_t> GetSInt64Value() const;
-
-  bool SetSInt64Value(int64_t new_value);
-
-  std::optional<llvm::StringRef> GetStringValue() const;
-
-  bool SetStringValue(llvm::StringRef new_value);
-
-  std::optional<uint64_t> GetUInt64Value() const;
-
-  bool SetUInt64Value(uint64_t new_value);
-
-  UUID GetUUIDValue() const;
-
-  bool SetUUIDValue(const UUID &uuid);
-
-  std::optional<ArchSpec> GetArchSpecValue() const;
-
-  bool SetArchSpecValue(ArchSpec arch_spec);
-
   bool OptionWasSet() const { return m_value_was_set; }
 
   void SetOptionWasSet() { m_value_was_set = true; }
@@ -373,10 +325,20 @@ class OptionValue {
 
   bool SetValueAs(bool v) { return SetBooleanValue(v); }
 
+  bool SetValueAs(char v) { return SetCharValue(v); }
+
+  bool SetValueAs(uint64_t v) { return SetUInt64Value(v); }
+
+  bool SetValueAs(int64_t v) { return SetSInt64Value(v); }
+
+  bool SetValueAs(UUID v) { return SetUUIDValue(v); }
+
   bool SetValueAs(llvm::StringRef v) { return SetStringValue(v); }
 
   bool SetValueAs(lldb::LanguageType v) { return SetLanguageValue(v); }
 
+  bool SetValueAs(lldb::Format v) { return SetFormatValue(v); }
+
   bool SetValueAs(FileSpec v) { return SetFileSpecValue(v); }
 
   bool SetValueAs(ArchSpec v) { return SetArchSpecValue(v); }
@@ -401,6 +363,44 @@ class OptionValue {
                                 // set from the command line or as a setting,
                                 // versus if we just have the default value that
                                 // was already populated in the option value.
+private:
+  std::optional<ArchSpec> GetArchSpecValue() const;
+  bool SetArchSpecValue(ArchSpec arch_spec);
+
+  std::optional<bool> GetBooleanValue() const;
+  bool SetBooleanValue(bool new_value);
+
+  std::optional<char> GetCharValue() const;
+  bool SetCharValue(char new_value);
+
+  std::optional<int64_t> GetEnumerationValue() const;
+  bool SetEnumerationValue(int64_t value);
+
+  std::optional<FileSpec> GetFileSpecValue() const;
+  bool SetFileSpecValue(FileSpec file_spec);
+
+  std::optional<FileSpecList> GetFileSpecListValue() const;
+
+  std::optional<int64_t> GetSInt64Value() const;
+  bool SetSInt64Value(int64_t new_value);
+
+  std::optional<uint64_t> GetUInt64Value() const;
+  bool SetUInt64Value(uint64_t new_value);
+
+  std::optional<lldb::Format> GetFormatValue() const;
+  bool SetFormatValue(lldb::Format new_value);
+
+  std::optional<lldb::LanguageType> GetLanguageValue() const;
+  bool SetLanguageValue(lldb::LanguageType new_language);
+
+  std::optional<llvm::StringRef> GetStringValue() const;
+  bool SetStringValue(llvm::StringRef new_value);
+
+  std::optional<UUID> GetUUIDValue() const;
+  bool SetUUIDValue(const UUID &uuid);
+
+  const FormatEntity::Entry *GetFormatEntity() const;
+  const RegularExpression *GetRegexValue() const;
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 3debbb3b576e6..30d2434981016 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -1740,7 +1740,7 @@ class CommandObjectBreakpointNameConfigure : public CommandObjectParsed {
     BreakpointSP bp_sp;
     if (m_bp_id.m_breakpoint.OptionWasSet()) {
       lldb::break_id_t bp_id =
-          m_bp_id.m_breakpoint.GetUInt64Value().value_or(0);
+          m_bp_id.m_breakpoint.GetValueAs<uint64_t>().value_or(0);
       bp_sp = target.GetBreakpointByID(bp_id);
       if (!bp_sp) {
         result.AppendErrorWithFormatv("Could not find specified breakpoint {0}",
@@ -1756,8 +1756,10 @@ class CommandObjectBreakpointNameConfigure : public CommandObjectParsed {
       if (!bp_name)
         continue;
       if (m_bp_id.m_help_string.OptionWasSet())
-        bp_name->SetHelp(
-            m_bp_id.m_help_string.GetStringValue().value_or("").str().c_str());
+        bp_name->SetHelp(m_bp_id.m_help_string.GetValueAs<llvm::StringRef>()
+                             .value_or("")
+                             .str()
+                             .c_str());
 
       if (bp_sp)
         target.ConfigureBreakpointName(*bp_name, bp_sp->GetOptions(),

diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index a8896f8c1fea6..ba5aad3d4ad55 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -1048,7 +1048,7 @@ class CommandObjectMemoryFind : public CommandObjectParsed {
 
     if (m_memory_options.m_string.OptionWasSet()) {
       llvm::StringRef str =
-          m_memory_options.m_string.GetStringValue().value_or("");
+          m_memory_options.m_string.GetValueAs<llvm::StringRef>().value_or("");
       if (str.empty()) {
         result.AppendError("search string must have non-zero length.");
         return false;
@@ -1059,8 +1059,9 @@ class CommandObjectMemoryFind : public CommandObjectParsed {
       ValueObjectSP result_sp;
       if ((eExpressionCompleted ==
            process->GetTarget().EvaluateExpression(
-               m_memory_options.m_expr.GetStringValue().value_or(""), frame,
-               result_sp)) &&
+               m_memory_options.m_expr.GetValueAs<llvm::StringRef>().value_or(
+                   ""),
+               frame, result_sp)) &&
           result_sp) {
         uint64_t value = result_sp->GetValueAsUnsigned(0);
         std::optional<uint64_t> size =

diff  --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp
index 80813cda04b8b..7c1155b7ba381 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -171,8 +171,9 @@ class CommandObjectRegisterRead : public CommandObjectParsed {
       const size_t set_array_size = m_command_options.set_indexes.GetSize();
       if (set_array_size > 0) {
         for (size_t i = 0; i < set_array_size; ++i) {
-          set_idx = m_command_options.set_indexes[i]->GetUInt64Value().value_or(
-              UINT32_MAX);
+          set_idx =
+              m_command_options.set_indexes[i]->GetValueAs<uint64_t>().value_or(
+                  UINT32_MAX);
           if (set_idx < reg_ctx->GetRegisterSetCount()) {
             if (!DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) {
               if (errno)

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index e39879953820f..1d92f2f52c2f7 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -349,7 +349,7 @@ uint64_t Debugger::GetTerminalWidth() const {
       idx, g_debugger_properties[idx].default_uint_value);
 }
 
-bool Debugger::SetTerminalWidth(uint32_t term_width) {
+bool Debugger::SetTerminalWidth(uint64_t term_width) {
   if (auto handler_sp = m_io_handler_stack.Top())
     handler_sp->TerminalSizeChanged();
 
@@ -544,7 +544,7 @@ uint64_t Debugger::GetTabSize() const {
       idx, g_debugger_properties[idx].default_uint_value);
 }
 
-bool Debugger::SetTabSize(uint32_t tab_size) {
+bool Debugger::SetTabSize(uint64_t tab_size) {
   const uint32_t idx = ePropertyTabSize;
   return SetPropertyAtIndex(idx, tab_size);
 }

diff  --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index db91dc59ddfac..bc9bf4f45f932 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -908,7 +908,7 @@ bool Instruction::TestEmulation(Stream *out_stream, const char *file_name) {
     return false;
   }
 
-  SetDescription(value_sp->GetStringValue().value_or(""));
+  SetDescription(value_sp->GetValueAs<llvm::StringRef>().value_or(""));
 
   value_sp = data_dictionary->GetValueForKey(triple_key);
   if (!value_sp) {
@@ -918,7 +918,8 @@ bool Instruction::TestEmulation(Stream *out_stream, const char *file_name) {
   }
 
   ArchSpec arch;
-  arch.SetTriple(llvm::Triple(value_sp->GetStringValue().value_or("")));
+  arch.SetTriple(
+      llvm::Triple(value_sp->GetValueAs<llvm::StringRef>().value_or("")));
 
   bool success = false;
   std::unique_ptr<EmulateInstruction> insn_emulator_up(

diff  --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp
index d29f86db82353..7fa34c55d0f4c 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -272,7 +272,7 @@ std::optional<char> OptionValue::GetCharValue() const {
   return {};
 }
 
-char OptionValue::SetCharValue(char new_value) {
+bool OptionValue::SetCharValue(char new_value) {
   OptionValueChar *option_value = GetAsChar();
   if (option_value) {
     option_value->SetCurrentValue(new_value);
@@ -415,11 +415,10 @@ bool OptionValue::SetUInt64Value(uint64_t new_value) {
   return false;
 }
 
-UUID OptionValue::GetUUIDValue() const {
-  const OptionValueUUID *option_value = GetAsUUID();
-  if (option_value)
+std::optional<UUID> OptionValue::GetUUIDValue() const {
+  if (const OptionValueUUID *option_value = GetAsUUID())
     return option_value->GetCurrentValue();
-  return UUID();
+  return {};
 }
 
 bool OptionValue::SetUUIDValue(const UUID &uuid) {

diff  --git a/lldb/source/Interpreter/OptionValueArgs.cpp b/lldb/source/Interpreter/OptionValueArgs.cpp
index e9f73e631dfd1..963651640539e 100644
--- a/lldb/source/Interpreter/OptionValueArgs.cpp
+++ b/lldb/source/Interpreter/OptionValueArgs.cpp
@@ -16,6 +16,6 @@ using namespace lldb_private;
 size_t OptionValueArgs::GetArgs(Args &args) const {
   args.Clear();
   for (const auto &value : m_values)
-    args.AppendArgument(value->GetStringValue().value_or(""));
+    args.AppendArgument(value->GetValueAs<llvm::StringRef>().value_or(""));
   return args.GetArgumentCount();
 }

diff  --git a/lldb/source/Interpreter/OptionValueArray.cpp b/lldb/source/Interpreter/OptionValueArray.cpp
index 796b6529b6c88..08b5f86202d32 100644
--- a/lldb/source/Interpreter/OptionValueArray.cpp
+++ b/lldb/source/Interpreter/OptionValueArray.cpp
@@ -153,7 +153,7 @@ size_t OptionValueArray::GetArgs(Args &args) const {
   args.Clear();
   const uint32_t size = m_values.size();
   for (uint32_t i = 0; i < size; ++i) {
-    std::optional<llvm::StringRef> string_value = m_values[i]->GetStringValue();
+    auto string_value = m_values[i]->GetValueAs<llvm::StringRef>();
     if (string_value)
       args.AppendArgument(*string_value);
   }

diff  --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index a8cc86c3715ae..7c79f2abe47e6 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -14364,7 +14364,7 @@ bool EmulateInstructionARM::TestEmulation(Stream *out_stream, ArchSpec &arch,
     out_stream->Printf("TestEmulation: Error reading opcode from test file.\n");
     return false;
   }
-  test_opcode = value_sp->GetUInt64Value().value_or(0);
+  test_opcode = value_sp->GetValueAs<uint64_t>().value_or(0);
 
   if (arch.GetTriple().getArch() == llvm::Triple::thumb ||
       arch.IsAlwaysThumbInstructions()) {

diff  --git a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
index fd7875599d887..c11d4c68c1d41 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -267,7 +267,7 @@ bool EmulationStateARM::LoadRegistersStateFromDictionary(
     OptionValueSP value_sp = reg_dict->GetValueForKey(sstr.GetString());
     if (value_sp.get() == nullptr)
       return false;
-    uint64_t reg_value = value_sp->GetUInt64Value().value_or(0);
+    uint64_t reg_value = value_sp->GetValueAs<uint64_t>().value_or(0);
     StorePseudoRegisterValue(first_reg + i, reg_value);
   }
 
@@ -296,7 +296,7 @@ bool EmulationStateARM::LoadStateFromDictionary(
     if (value_sp.get() == nullptr)
       return false;
     else
-      start_address = value_sp->GetUInt64Value().value_or(0);
+      start_address = value_sp->GetValueAs<uint64_t>().value_or(0);
 
     value_sp = mem_dict->GetValueForKey(data_key);
     OptionValueArray *mem_array = value_sp->GetAsArray();
@@ -310,7 +310,7 @@ bool EmulationStateARM::LoadStateFromDictionary(
       value_sp = mem_array->GetValueAtIndex(i);
       if (value_sp.get() == nullptr)
         return false;
-      uint64_t value = value_sp->GetUInt64Value().value_or(0);
+      uint64_t value = value_sp->GetValueAs<uint64_t>().value_or(0);
       StoreToPseudoAddress(address, value);
       address = address + 4;
     }
@@ -330,7 +330,8 @@ bool EmulationStateARM::LoadStateFromDictionary(
   value_sp = reg_dict->GetValueForKey(cpsr_name);
   if (value_sp.get() == nullptr)
     return false;
-  StorePseudoRegisterValue(dwarf_cpsr, value_sp->GetUInt64Value().value_or(0));
+  StorePseudoRegisterValue(dwarf_cpsr,
+                           value_sp->GetValueAs<uint64_t>().value_or(0));
 
   // Load s/d Registers
   // To prevent you giving both types in a state and overwriting

diff  --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 905226d67c2b5..30ff0e5f3ef6a 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -318,8 +318,8 @@ size_t ObjectFilePECOFF::GetModuleSpecifications(
   llvm::Triple::EnvironmentType env;
   if (module_env_option)
     env =
-        (llvm::Triple::EnvironmentType)module_env_option->GetEnumerationValue()
-            .value_or(0);
+        module_env_option->GetValueAs<llvm::Triple::EnvironmentType>().value_or(
+            static_cast<llvm::Triple::EnvironmentType>(0));
   else
     env = GetGlobalPluginProperties().ABI();
 

diff  --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 7f984233f0c26..9267a1a2a6765 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -887,7 +887,7 @@ class CommandObjectProcessKDPPacketSend : public CommandObjectParsed {
           "the --command option must be set to a valid command byte");
     } else {
       const uint64_t command_byte =
-          m_command_byte.GetOptionValue().GetUInt64Value().value_or(0);
+          m_command_byte.GetOptionValue().GetValueAs<uint64_t>().value_or(0);
       if (command_byte > 0 && command_byte <= UINT8_MAX) {
         ProcessKDP *process =
             (ProcessKDP *)m_interpreter.GetExecutionContext().GetProcessPtr();

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 0f7c15a75bbf4..9e9b1da948f70 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -225,7 +225,7 @@ uint32_t ProcessProperties::GetVirtualAddressableBits() const {
 
 void ProcessProperties::SetVirtualAddressableBits(uint32_t bits) {
   const uint32_t idx = ePropertyVirtualAddressableBits;
-  SetPropertyAtIndex(idx, bits);
+  SetPropertyAtIndex(idx, static_cast<uint64_t>(bits));
 }
 void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) {
   const uint32_t idx = ePropertyPythonOSPluginPath;
@@ -483,10 +483,10 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
   OptionValueSP value_sp =
       m_collection_sp->GetPropertyAtIndex(ePropertyMemCacheLineSize)
           ->GetValue();
-  uint32_t platform_cache_line_size =
+  uint64_t platform_cache_line_size =
       target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize();
   if (!value_sp->OptionWasSet() && platform_cache_line_size != 0)
-    value_sp->SetUInt64Value(platform_cache_line_size);
+    value_sp->SetValueAs(platform_cache_line_size);
 
   RegisterAssertFrameRecognizer(this);
 }

diff  --git a/lldb/unittests/Interpreter/TestOptionValue.cpp b/lldb/unittests/Interpreter/TestOptionValue.cpp
index 64adcff243fd9..7753d3d968b03 100644
--- a/lldb/unittests/Interpreter/TestOptionValue.cpp
+++ b/lldb/unittests/Interpreter/TestOptionValue.cpp
@@ -41,11 +41,11 @@ TEST(OptionValueString, DeepCopy) {
   ASSERT_TRUE(copy_sp);
   ASSERT_EQ(copy_sp->GetParent().get(), nullptr);
   ASSERT_TRUE(copy_sp->OptionWasSet());
-  ASSERT_EQ(copy_sp->GetStringValue(), "ab");
+  ASSERT_EQ(copy_sp->GetValueAs<llvm::StringRef>(), "ab");
 
   // Trigger the callback.
   copy_sp->SetValueFromString("c", eVarSetOperationAppend);
-  ASSERT_EQ(copy_sp->GetStringValue(), "abc");
+  ASSERT_EQ(copy_sp->GetValueAs<llvm::StringRef>(), "abc");
 }
 
 // Test an aggregate class.
@@ -67,15 +67,15 @@ TEST(OptionValueArgs, DeepCopy) {
   auto *args_copy_ptr = copy_sp->GetAsArgs();
   ASSERT_EQ(args_copy_ptr->GetSize(), 2U);
   ASSERT_EQ((*args_copy_ptr)[0]->GetParent(), copy_sp);
-  ASSERT_EQ((*args_copy_ptr)[0]->GetStringValue(), "A");
+  ASSERT_EQ((*args_copy_ptr)[0]->GetValueAs<llvm::StringRef>(), "A");
   ASSERT_EQ((*args_copy_ptr)[1]->GetParent(), copy_sp);
-  ASSERT_EQ((*args_copy_ptr)[1]->GetStringValue(), "B");
+  ASSERT_EQ((*args_copy_ptr)[1]->GetValueAs<llvm::StringRef>(), "B");
 
   // Trigger the callback.
   copy_sp->SetValueFromString("C", eVarSetOperationAppend);
   ASSERT_TRUE(args_copy_ptr);
   ASSERT_EQ(args_copy_ptr->GetSize(), 3U);
-  ASSERT_EQ((*args_copy_ptr)[2]->GetStringValue(), "C");
+  ASSERT_EQ((*args_copy_ptr)[2]->GetValueAs<llvm::StringRef>(), "C");
 }
 
 class TestProperties : public OptionValueProperties {
@@ -149,12 +149,12 @@ TEST(TestProperties, DeepCopy) {
   auto value_ptr = dict_copy_ptr->GetValueForKey("A");
   ASSERT_TRUE(value_ptr);
   ASSERT_EQ(value_ptr->GetParent().get(), dict_copy_ptr);
-  ASSERT_EQ(value_ptr->GetUInt64Value(), 1U);
+  ASSERT_EQ(value_ptr->GetValueAs<uint64_t>(), 1U);
 
   value_ptr = dict_copy_ptr->GetValueForKey("B");
   ASSERT_TRUE(value_ptr);
   ASSERT_EQ(value_ptr->GetParent().get(), dict_copy_ptr);
-  ASSERT_EQ(value_ptr->GetUInt64Value(), 2U);
+  ASSERT_EQ(value_ptr->GetValueAs<uint64_t>(), 2U);
 
   // Test the second child.
   auto file_list_copy_ptr = props_copy_ptr->GetFileList();


        


More information about the lldb-commits mailing list