[Lldb-commits] [lldb] 0f9c08f - [lldb] Migrate to GetPropertyAtIndexAs for LanguageType (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri May 5 14:44:05 PDT 2023


Author: Jonas Devlieghere
Date: 2023-05-05T14:43:58-07:00
New Revision: 0f9c08f1b2ba23d6c4a4e542d3d2c5adf479d31f

URL: https://github.com/llvm/llvm-project/commit/0f9c08f1b2ba23d6c4a4e542d3d2c5adf479d31f
DIFF: https://github.com/llvm/llvm-project/commit/0f9c08f1b2ba23d6c4a4e542d3d2c5adf479d31f.diff

LOG: [lldb] Migrate to GetPropertyAtIndexAs for LanguageType (NFC)

Use the templated GetPropertyAtIndexAs helper for LanguageType.

Added: 
    

Modified: 
    lldb/include/lldb/Interpreter/OptionValueProperties.h
    lldb/source/Core/Debugger.cpp
    lldb/source/Interpreter/OptionValueProperties.cpp
    lldb/source/Target/Target.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index 004ed55e3b119..f4e119cdd83d3 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -109,9 +109,6 @@ class OptionValueProperties
   OptionValueArch *GetPropertyAtIndexAsOptionValueArch(
       uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
 
-  OptionValueLanguage *GetPropertyAtIndexAsOptionValueLanguage(
-      uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const;
-
   bool
   GetPropertyAtIndexAsArgs(uint32_t idx, Args &args,
                            const ExecutionContext *exe_ctx = nullptr) const;

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 5eb2d1ff5c61d..fbfee28183dd0 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -335,11 +335,7 @@ bool Debugger::SetScriptLanguage(lldb::ScriptLanguage script_lang) {
 
 lldb::LanguageType Debugger::GetREPLLanguage() const {
   const uint32_t idx = ePropertyREPLLanguage;
-  OptionValueLanguage *value =
-      m_collection_sp->GetPropertyAtIndexAsOptionValueLanguage(idx);
-  if (value)
-    return value->GetCurrentValue();
-  return LanguageType();
+  return GetPropertyAtIndexAs<LanguageType>(idx, {});
 }
 
 bool Debugger::SetREPLLanguage(lldb::LanguageType repl_lang) {

diff  --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp
index dafe398f9c8eb..29dfe92860aeb 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -201,15 +201,6 @@ OptionValueArch *OptionValueProperties::GetPropertyAtIndexAsOptionValueArch(
   return nullptr;
 }
 
-OptionValueLanguage *
-OptionValueProperties::GetPropertyAtIndexAsOptionValueLanguage(
-    uint32_t idx, const ExecutionContext *exe_ctx) const {
-  const Property *property = GetPropertyAtIndex(idx, exe_ctx);
-  if (property)
-    return property->GetValue()->GetAsLanguage();
-  return nullptr;
-}
-
 bool OptionValueProperties::GetPropertyAtIndexAsArgs(
     uint32_t idx, Args &args, const ExecutionContext *exe_ctx) const {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 0910273421109..7df4af8dd0f26 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4549,12 +4549,8 @@ void TargetProperties::SetStandardErrorPath(llvm::StringRef path) {
 }
 
 LanguageType TargetProperties::GetLanguage() const {
-  OptionValueLanguage *value =
-      m_collection_sp->GetPropertyAtIndexAsOptionValueLanguage(
-          ePropertyLanguage);
-  if (value)
-    return value->GetCurrentValue();
-  return LanguageType();
+  const uint32_t idx = ePropertyLanguage;
+  return GetPropertyAtIndexAs<LanguageType>(idx, {});
 }
 
 llvm::StringRef TargetProperties::GetExpressionPrefixContents() {


        


More information about the lldb-commits mailing list