Swlft: force canonical type computation before using the type

`getCanonicalType` will force computation of the canonical type.
Without canonical type computed. `getString` may cause crashes in
certain cases.
This commit is contained in:
Alex Denisov
2023-11-06 16:51:58 +01:00
parent 3f0be47c7b
commit 80c4b7357a

View File

@@ -163,8 +163,10 @@ void TypeTranslator::fillAnyGenericType(const swift::AnyGenericType& type,
}
void TypeTranslator::fillType(const swift::TypeBase& type, codeql::Type& entry) {
entry.name = type.getString();
// Preserve the order as getCanonicalType() forces computation of the canonical type
// without which getString may crash sometimes
entry.canonical_type = dispatcher.fetchLabel(type.getCanonicalType());
entry.name = type.getString();
}
void TypeTranslator::fillArchetypeType(const swift::ArchetypeType& type, ArchetypeType& entry) {