Skip to content

Commit 252f8ad

Browse files
Merge pull request #1509 from adrian-prantl/getcanonical-next
Implement TypeSystemSwiftTypeRef::getCanonicalType() (NFC) #1507
2 parents 9ce07f1 + 11fb556 commit 252f8ad

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
@@ -179,6 +179,8 @@ class TypeSystemSwift : public TypeSystem {
179179
}
180180
lldb::LanguageType
181181
GetMinimumLanguage(lldb::opaque_compiler_type_t type) override {
182+
assert(type && "CompilerType::GetMinimumLanguage() is not supposed to "
183+
"forward calls with NULL types ");
182184
return lldb::eLanguageTypeSwift;
183185
}
184186
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
@@ -1500,7 +1500,15 @@ TypeSystemSwiftTypeRef::GetArrayElementType(opaque_compiler_type_t type,
15001500
}
15011501
CompilerType
15021502
TypeSystemSwiftTypeRef::GetCanonicalType(opaque_compiler_type_t type) {
1503-
return m_swift_ast_context->GetCanonicalType(ReconstructType(type));
1503+
auto impl = [&]() {
1504+
using namespace swift::Demangle;
1505+
Demangler Dem;
1506+
NodePointer canonical =
1507+
GetCanonicalDemangleTree(GetModule(), Dem, AsMangledName(type));
1508+
ConstString mangled(mangleNode(canonical));
1509+
return GetTypeFromMangledTypename(mangled);
1510+
};
1511+
VALIDATE_AND_RETURN(impl, GetCanonicalType, type, (ReconstructType(type)));
15041512
}
15051513
int TypeSystemSwiftTypeRef::GetFunctionArgumentCount(
15061514
opaque_compiler_type_t type) {

0 commit comments

Comments
 (0)