Skip to content

Commit 010321d

Browse files
committed
[lldb] Add list of types known to use @_originallyDefinedIn
Types defined wit @_originallyDefinedIn have a different mangled name emitted in the debug information and in the reflection metadata. Add a map of known common types that use this feature so we can find reflection metadata for them. rdar://106506535
1 parent cee7200 commit 010321d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3244,12 +3244,22 @@ SwiftLanguageRuntimeImpl::GetTypeRef(CompilerType type,
32443244

32453245
// Demangle the mangled name.
32463246
swift::Demangle::Demangler dem;
3247-
ConstString mangled_name = type.GetMangledTypeName();
3247+
llvm::StringRef mangled_name = type.GetMangledTypeName().GetStringRef();
32483248
auto ts = type.GetTypeSystem().dyn_cast_or_null<TypeSystemSwift>();
32493249
if (!ts)
32503250
return nullptr;
3251+
3252+
// List of commonly used types known to have been been annotated with
3253+
// @_originallyDefinedIn to a different module.
3254+
static llvm::StringMap<llvm::StringRef> known_types_with_redefined_modules = {
3255+
{"$s14CoreFoundation7CGFloatVD", "$s12CoreGraphics7CGFloatVD"}};
3256+
3257+
auto it = known_types_with_redefined_modules.find(mangled_name);
3258+
if (it != known_types_with_redefined_modules.end())
3259+
mangled_name = it->second;
3260+
32513261
swift::Demangle::NodePointer node =
3252-
module_holder->GetCanonicalDemangleTree(dem, mangled_name.GetStringRef());
3262+
module_holder->GetCanonicalDemangleTree(dem, mangled_name);
32533263
if (!node)
32543264
return nullptr;
32553265

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4148,8 +4148,6 @@ bool TypeSystemSwiftTypeRef::ShouldSkipValidation(opaque_compiler_type_t type) {
41484148
if (mangled_name == "$sSo6CGSizeVD")
41494149
return true;
41504150

4151-
if (mangled_name == "$s14CoreFoundation7CGFloatVD")
4152-
return true;
41534151
// We skip validation when dealing with a builtin type since builtins are
41544152
// considered type aliases by Swift, which we're deviating from since
41554153
// SwiftASTContext reconstructs Builtin types as TypeAliases pointing to the

0 commit comments

Comments
 (0)