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

via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 18 16:59:19 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Augusto Noronha (augusto2112)

<details>
<summary>Changes</summary>

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).

---
Full diff: https://github.com/llvm/llvm-project/pull/113006.diff


4 Files Affected:

- (modified) lldb/include/lldb/Symbol/CompilerType.h (+2) 
- (modified) lldb/include/lldb/Symbol/TypeSystem.h (+4) 
- (modified) lldb/source/Symbol/CompilerType.cpp (+8) 
- (modified) lldb/source/Symbol/TypeSystem.cpp (+4) 


``````````diff
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();
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/113006


More information about the lldb-commits mailing list