[Lldb-commits] [lldb] 3d84b74 - [lldb] Add GetMangledTypeName to TypeSystem/CompilerType (#113006)

via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 18 22:57:48 PDT 2024


Author: Augusto Noronha
Date: 2024-10-18T22:57:45-07:00
New Revision: 3d84b74cb3543428c35fc39e889684497286d482

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

LOG: [lldb] Add GetMangledTypeName to TypeSystem/CompilerType (#113006)

Swift types have mangled names, so there should be a way to read those
from the compiler type.

This patch upstreams these two changes from swiftlang/llvm-project
(which were added there since at least 2016).

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/CompilerType.h
    lldb/include/lldb/Symbol/TypeSystem.h
    lldb/source/Symbol/CompilerType.cpp
    lldb/source/Symbol/TypeSystem.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 70dacdcb7986fc..096a8f1ab68e8b 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -279,6 +279,8 @@ class CompilerType {
 
   ConstString GetDisplayTypeName() const;
 
+  ConstString GetMangledTypeName() const;
+
   uint32_t
   GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) const;
 

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138c..416445a60bd017 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -237,6 +237,10 @@ class TypeSystem : public PluginInterface,
 
   virtual ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) = 0;
 
+  // Defaults to GetTypeName(type).  Override if your language desires
+  // specialized behavior.
+  virtual ConstString GetMangledTypeName(lldb::opaque_compiler_type_t type);
+
   virtual uint32_t
   GetTypeInfo(lldb::opaque_compiler_type_t type,
               CompilerType *pointee_or_element_compiler_type) = 0;

diff  --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index f8da9ef7b7640d..e9e6e3bf2600ce 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -540,6 +540,14 @@ ConstString CompilerType::GetDisplayTypeName() const {
   return ConstString("<invalid>");
 }
 
+ConstString CompilerType::GetMangledTypeName() const {
+  if (IsValid()) {
+    if (auto type_system_sp = GetTypeSystem())
+      return type_system_sp->GetMangledTypeName(m_type);
+  }
+  return ConstString("<invalid>");
+}
+
 uint32_t CompilerType::GetTypeInfo(
     CompilerType *pointee_or_element_compiler_type) const {
   if (IsValid())

diff  --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp
index 931ce1b0203a93..f7d634ffa2dec5 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -157,6 +157,10 @@ bool TypeSystem::IsMeaninglessWithoutDynamicResolution(void *type) {
   return false;
 }
 
+ConstString TypeSystem::GetMangledTypeName(void *type) {
+  return GetTypeName(type, false);
+}
+
 ConstString TypeSystem::DeclGetMangledName(void *opaque_decl) {
   return ConstString();
 }


        


More information about the lldb-commits mailing list