Skip to content

Commit 3d84b74

Browse files
authored
[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).
1 parent d37bc32 commit 3d84b74

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

lldb/include/lldb/Symbol/CompilerType.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ class CompilerType {
279279

280280
ConstString GetDisplayTypeName() const;
281281

282+
ConstString GetMangledTypeName() const;
283+
282284
uint32_t
283285
GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) const;
284286

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ class TypeSystem : public PluginInterface,
237237

238238
virtual ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) = 0;
239239

240+
// Defaults to GetTypeName(type). Override if your language desires
241+
// specialized behavior.
242+
virtual ConstString GetMangledTypeName(lldb::opaque_compiler_type_t type);
243+
240244
virtual uint32_t
241245
GetTypeInfo(lldb::opaque_compiler_type_t type,
242246
CompilerType *pointee_or_element_compiler_type) = 0;

lldb/source/Symbol/CompilerType.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,14 @@ ConstString CompilerType::GetDisplayTypeName() const {
540540
return ConstString("<invalid>");
541541
}
542542

543+
ConstString CompilerType::GetMangledTypeName() const {
544+
if (IsValid()) {
545+
if (auto type_system_sp = GetTypeSystem())
546+
return type_system_sp->GetMangledTypeName(m_type);
547+
}
548+
return ConstString("<invalid>");
549+
}
550+
543551
uint32_t CompilerType::GetTypeInfo(
544552
CompilerType *pointee_or_element_compiler_type) const {
545553
if (IsValid())

lldb/source/Symbol/TypeSystem.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ bool TypeSystem::IsMeaninglessWithoutDynamicResolution(void *type) {
157157
return false;
158158
}
159159

160+
ConstString TypeSystem::GetMangledTypeName(void *type) {
161+
return GetTypeName(type, false);
162+
}
163+
160164
ConstString TypeSystem::DeclGetMangledName(void *opaque_decl) {
161165
return ConstString();
162166
}

0 commit comments

Comments
 (0)