From 80c4b7357ab25261090be95509b1b13ded56b968 Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Mon, 6 Nov 2023 16:51:58 +0100 Subject: [PATCH] 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. --- swift/extractor/translators/TypeTranslator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/swift/extractor/translators/TypeTranslator.cpp b/swift/extractor/translators/TypeTranslator.cpp index 4bbebfab5881..a4ecfe73afdb 100644 --- a/swift/extractor/translators/TypeTranslator.cpp +++ b/swift/extractor/translators/TypeTranslator.cpp @@ -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) {