Skip to content

Commit 9aacf5c

Browse files
authored
Merge pull request #2982 from augusto2112/tss-typeref-deal-with-builtin-on-typedef
[lldb] Skip validation of TypeSystemSwiftTypeRef's typedef functions when dealing with a builtin type
2 parents ee9895c + ed0f9ae commit 9aacf5c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3157,6 +3157,18 @@ bool TypeSystemSwiftTypeRef::IsTypedefType(opaque_compiler_type_t type) {
31573157
return node && node->getKind() == Node::Kind::TypeAlias;
31583158
};
31593159

3160+
#ifndef NDEBUG
3161+
// We skip validation when dealing with a builtin type since builtins are
3162+
// considered type aliases by Swift, which we're deviating from since
3163+
// SwiftASTContext reconstructs Builtin types as TypeAliases pointing to the
3164+
// actual Builtin types, but mangled names always describe the underlying
3165+
// builtins directly.
3166+
using namespace swift::Demangle;
3167+
Demangler dem;
3168+
NodePointer node = GetDemangledType(dem, AsMangledName(type));
3169+
if (node && node->getKind() == Node::Kind::BuiltinTypeName)
3170+
return impl();
3171+
#endif
31603172
VALIDATE_AND_RETURN(impl, IsTypedefType, type, (ReconstructType(type)),
31613173
(ReconstructType(type)));
31623174
}
@@ -3177,7 +3189,18 @@ TypeSystemSwiftTypeRef::GetTypedefedType(opaque_compiler_type_t type) {
31773189
}
31783190
return std::get<CompilerType>(pair);
31793191
};
3180-
3192+
#ifndef NDEBUG
3193+
// We skip validation when dealing with a builtin type since builtins are
3194+
// considered type aliases by Swift, which we're deviating from since
3195+
// SwiftASTContext reconstructs Builtin types as TypeAliases pointing to the
3196+
// actual Builtin types, but mangled names always describe the underlying
3197+
// builtins directly.
3198+
using namespace swift::Demangle;
3199+
Demangler dem;
3200+
NodePointer node = GetDemangledType(dem, AsMangledName(type));
3201+
if (node && node->getKind() == Node::Kind::BuiltinTypeName)
3202+
return impl();
3203+
#endif
31813204
VALIDATE_AND_RETURN(impl, GetTypedefedType, type, (ReconstructType(type)),
31823205
(ReconstructType(type)));
31833206
}

0 commit comments

Comments
 (0)