[Lldb-commits] [lldb] ef73ea6 - [lldb][NFCI] Change return type of Language::GetInstanceVariableName

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Mon May 22 10:22:31 PDT 2023


Author: Alex Langford
Date: 2023-05-22T10:16:20-07:00
New Revision: ef73ea6cf691f08459dd33116ace45c946d05b54

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

LOG: [lldb][NFCI] Change return type of Language::GetInstanceVariableName

I don't think this needs to be a ConstString.

Differential Revision: https://reviews.llvm.org/D150709

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/SymbolContext.h
    lldb/include/lldb/Target/Language.h
    lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
    lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
    lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
    lldb/source/Symbol/SymbolContext.cpp
    lldb/source/Target/StackFrame.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h
index 68bef70f3bcfe..b0f5ffead2a16 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -250,8 +250,8 @@ class SymbolContext {
   /// For C++ the name is "this", for Objective-C the name is "self".
   ///
   /// \return
-  ///     Returns a string for the name of the instance variable.
-  ConstString GetInstanceVariableName();
+  ///     Returns a StringRef for the name of the instance variable.
+  llvm::StringRef GetInstanceVariableName();
 
   /// Sorts the types in TypeMap according to SymbolContext to TypeList
   ///

diff  --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h
index 59ea17bcefb26..bbb3e7c0cc8d1 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -326,7 +326,7 @@ class Language : public PluginInterface {
     return ConstString();
   }
 
-  virtual ConstString GetInstanceVariableName() { return {}; }
+  virtual llvm::StringRef GetInstanceVariableName() { return {}; }
 
 protected:
   // Classes that inherit from Language can see and modify these

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index a3e78c39044aa..7712a60b77959 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -165,7 +165,7 @@ class CPlusPlusLanguage : public Language {
   ConstString FindBestAlternateFunctionMangledName(
       const Mangled mangled, const SymbolContext &sym_ctx) const override;
 
-  ConstString GetInstanceVariableName() override { return ConstString("this"); }
+  llvm::StringRef GetInstanceVariableName() override { return "this"; }
 
   // PluginInterface protocol
   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }

diff  --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index c37fd3d2257bb..3b74e79254936 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -191,7 +191,7 @@ class ObjCLanguage : public Language {
       return false;
   }
 
-  ConstString GetInstanceVariableName() override { return ConstString("self"); }
+  llvm::StringRef GetInstanceVariableName() override { return "self"; }
 
   // PluginInterface protocol
   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }

diff  --git a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
index 5fb256db46481..b7c71b5dbb1c9 100644
--- a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
@@ -40,7 +40,7 @@ class ObjCPlusPlusLanguage : public Language {
 
   static lldb_private::Language *CreateInstance(lldb::LanguageType language);
 
-  ConstString GetInstanceVariableName() override { return ConstString("self"); }
+  llvm::StringRef GetInstanceVariableName() override { return "self"; }
 
   static llvm::StringRef GetPluginNameStatic() { return "objcplusplus"; }
 

diff  --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp
index f2d88b6dc46be..63968ec2d1506 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -541,7 +541,7 @@ Block *SymbolContext::GetFunctionBlock() {
   return nullptr;
 }
 
-ConstString SymbolContext::GetInstanceVariableName() {
+llvm::StringRef SymbolContext::GetInstanceVariableName() {
   LanguageType lang_type = eLanguageTypeUnknown;
 
   if (Block *function_block = GetFunctionBlock())

diff  --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index f828539057cbf..7ba84b1c5c149 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -567,8 +567,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
     // Check for direct ivars access which helps us with implicit access to
     // ivars using "this" or "self".
     GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock);
-    if (auto instance_var_name = m_sc.GetInstanceVariableName()) {
-      var_sp = variable_list->FindVariable(instance_var_name);
+    llvm::StringRef instance_var_name = m_sc.GetInstanceVariableName();
+    if (!instance_var_name.empty()) {
+      var_sp = variable_list->FindVariable(ConstString(instance_var_name));
       if (var_sp) {
         separator_idx = 0;
         if (Type *var_type = var_sp->GetType())


        


More information about the lldb-commits mailing list