Skip to content

Commit 34fece8

Browse files
Merge pull request #1507 from adrian-prantl/getcanonical
Implement TypeSystemSwiftTypeRef::getCanonicalType() (NFC)
2 parents b05c88f + 918a34e commit 34fece8

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,13 +1037,12 @@ bool lldb_private::formatters::swift::SIMDVector_SummaryProvider(
10371037
// dynamic archetype (and hence its size). Everything follows naturally
10381038
// as the elements are laid out in a contigous buffer without padding.
10391039
CompilerType simd_type = valobj.GetCompilerType().GetCanonicalType();
1040-
void *type_buffer = reinterpret_cast<void *>(simd_type.GetOpaqueQualType());
10411040
llvm::Optional<uint64_t> opt_type_size = simd_type.GetByteSize(nullptr);
10421041
if (!opt_type_size)
10431042
return false;
10441043
uint64_t type_size = *opt_type_size;
10451044

1046-
auto swift_type = reinterpret_cast<::swift::TypeBase *>(type_buffer);
1045+
::swift::TypeBase *swift_type = GetSwiftType(simd_type).getPointer();
10471046
auto bound_type = dyn_cast<::swift::BoundGenericType>(swift_type);
10481047
if (!bound_type)
10491048
return false;

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class TypeSystemSwift : public TypeSystem {
170170
}
171171
lldb::LanguageType
172172
GetMinimumLanguage(lldb::opaque_compiler_type_t type) override {
173+
assert(type && "CompilerType::GetMinimumLanguage() is not supposed to "
174+
"forward calls with NULL types ");
173175
return lldb::eLanguageTypeSwift;
174176
}
175177
unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override {

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,15 @@ TypeSystemSwiftTypeRef::GetArrayElementType(opaque_compiler_type_t type,
15021502
}
15031503
CompilerType
15041504
TypeSystemSwiftTypeRef::GetCanonicalType(opaque_compiler_type_t type) {
1505-
return m_swift_ast_context->GetCanonicalType(ReconstructType(type));
1505+
auto impl = [&]() {
1506+
using namespace swift::Demangle;
1507+
Demangler Dem;
1508+
NodePointer canonical =
1509+
GetCanonicalDemangleTree(GetModule(), Dem, AsMangledName(type));
1510+
ConstString mangled(mangleNode(canonical));
1511+
return GetTypeFromMangledTypename(mangled);
1512+
};
1513+
VALIDATE_AND_RETURN(impl, GetCanonicalType, type, (ReconstructType(type)));
15061514
}
15071515
int TypeSystemSwiftTypeRef::GetFunctionArgumentCount(
15081516
opaque_compiler_type_t type) {

0 commit comments

Comments
 (0)