@@ -1042,6 +1042,7 @@ static bool ContainsGenericTypeParameter(swift::Demangle::NodePointer node) {
1042
1042
static uint32_t collectTypeInfo (SwiftASTContext *module_holder,
1043
1043
swift::Demangle::Demangler &dem,
1044
1044
swift::Demangle::NodePointer node,
1045
+ bool &unresolved_typealias,
1045
1046
bool generic_walk = false ) {
1046
1047
LLDB_SCOPED_TIMER ();
1047
1048
if (!node)
@@ -1073,7 +1074,8 @@ static uint32_t collectTypeInfo(SwiftASTContext *module_holder,
1073
1074
if ((type_class & eTypeClassBuiltin)) {
1074
1075
swift_flags &= ~eTypeIsStructUnion;
1075
1076
swift_flags |= collectTypeInfo (
1076
- module_holder, dem, GetClangTypeNode (clang_type, dem, module_holder));
1077
+ module_holder, dem, GetClangTypeNode (clang_type, dem, module_holder),
1078
+ unresolved_typealias);
1077
1079
return ;
1078
1080
}
1079
1081
};
@@ -1253,6 +1255,11 @@ static uint32_t collectTypeInfo(SwiftASTContext *module_holder,
1253
1255
collect_clang_type (clang_type);
1254
1256
return swift_flags;
1255
1257
}
1258
+ if (!node_clangtype.first ) {
1259
+ // If this is a typealias defined in the expression evaluator,
1260
+ // then we don't have debug info to resolve it from.
1261
+ unresolved_typealias = true ;
1262
+ }
1256
1263
swift_flags |= collectTypeInfo (module_holder, dem, node_clangtype.first ,
1257
1264
generic_walk);
1258
1265
return swift_flags;
@@ -1267,7 +1274,8 @@ static uint32_t collectTypeInfo(SwiftASTContext *module_holder,
1267
1274
1268
1275
// Visit the child nodes.
1269
1276
for (unsigned i = 0 ; i < node->getNumChildren (); ++i)
1270
- swift_flags |= collectTypeInfo (module_holder, dem, node->getChild (i), generic_walk);
1277
+ swift_flags |= collectTypeInfo (module_holder, dem, node->getChild (i),
1278
+ unresolved_typealias, generic_walk);
1271
1279
1272
1280
return swift_flags;
1273
1281
}
@@ -2058,7 +2066,16 @@ uint32_t TypeSystemSwiftTypeRef::GetTypeInfo(
2058
2066
using namespace swift ::Demangle;
2059
2067
Demangler dem;
2060
2068
NodePointer node = dem.demangleSymbol (AsMangledName (type));
2061
- return collectTypeInfo (m_swift_ast_context, dem, node);
2069
+ bool unresolved_typealias = false ;
2070
+ uint32_t flags =
2071
+ collectTypeInfo (m_swift_ast_context, dem, node, unresolved_typealias);
2072
+ if (unresolved_typealias) {
2073
+ // If this is a typealias defined in the expression evaluator,
2074
+ // then we don't have debug info to resolve it from.
2075
+ return m_swift_ast_context->GetTypeInfo (ReconstructType (type),
2076
+ pointee_or_element_clang_type);
2077
+ }
2078
+ return flags;
2062
2079
};
2063
2080
2064
2081
VALIDATE_AND_RETURN (impl, GetTypeInfo, type, (ReconstructType (type), nullptr ),
@@ -3202,6 +3219,16 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue(
3202
3219
ReconstructType (type), s, format, data, data_offset, data_byte_size,
3203
3220
bitfield_bit_size, bitfield_bit_offset, exe_scope, is_base_class);
3204
3221
}
3222
+ case Node::Kind::TypeAlias:
3223
+ case Node::Kind::BoundGenericTypeAlias: {
3224
+ // This means we have an unresolved type alias that even
3225
+ // SwiftASTContext couldn't resolve. This happens for ObjC
3226
+ // typedefs such as CFString in the REPL. More investigation is
3227
+ // needed.
3228
+ return m_swift_ast_context->DumpTypeValue (
3229
+ ReconstructType (type), s, format, data, data_offset, data_byte_size,
3230
+ bitfield_bit_size, bitfield_bit_offset, exe_scope, is_base_class);
3231
+ }
3205
3232
default :
3206
3233
assert (false && " Unhandled node kind" );
3207
3234
LLDB_LOGF (GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES),
@@ -3470,16 +3497,23 @@ TypeSystemSwiftTypeRef::GetGenericArgumentType(opaque_compiler_type_t type,
3470
3497
(ReconstructType (type), idx));
3471
3498
}
3472
3499
#ifndef NDEBUG
3473
- bool TypeSystemSwiftTypeRef::ShouldSkipValidation (opaque_compiler_type_t type) { \
3474
- // NSNotificationName is a typedef to a NSString in clang type, but it's a
3500
+ bool TypeSystemSwiftTypeRef::ShouldSkipValidation (opaque_compiler_type_t type) {
3501
+ auto mangled_name = GetMangledTypeName (type);
3502
+ // NSNotificationName is a typedef to a NSString in clang type, but it's a
3475
3503
// struct in SwiftASTContext. Skip validation in this case.
3504
+ if (mangled_name == " $sSo18NSNotificationNameaD" )
3505
+ return true ;
3506
+
3476
3507
// $s10Foundation12NotificationV4NameaD is a typealias to NSNotificationName,
3477
3508
// so we skip validation in that casse as well.
3478
- auto mangled_name = GetMangledTypeName (type);
3479
- if (mangled_name == " $sSo18NSNotificationNameaD" ||
3480
- mangled_name == " $s10Foundation12NotificationV4NameaD" ||
3481
- mangled_name == " $sSo9NSDecimalaD" )
3482
- return true ;
3509
+ if (mangled_name == " $s10Foundation12NotificationV4NameaD" )
3510
+ return true ;
3511
+ if (mangled_name == " $sSo9NSDecimalaD" )
3512
+ return true ;
3513
+ // Reconstruct($sSo11CFStringRefaD) returns a non-typealias type, breaking
3514
+ // isTypedef().
3515
+ if (mangled_name == " $sSo11CFStringRefaD" )
3516
+ return true ;
3483
3517
3484
3518
// We skip validation when dealing with a builtin type since builtins are
3485
3519
// considered type aliases by Swift, which we're deviating from since
0 commit comments