Skip to content

[pull] swift/release/5.4 from apple:swift/release/5.4 #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -550,6 +550,8 @@ static void AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
auto *stack_frame = stack_frame_sp.get();
imported_self_type = swift_runtime->BindGenericTypeParameters(
*stack_frame, imported_self_type);
if (!imported_self_type)
return;

{
auto *swift_type_system = llvm::dyn_cast_or_null<TypeSystemSwift>(
@@ -561,6 +563,8 @@ static void AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
// extend the referent:
imported_self_type = swift_type_system->GetReferentType(
imported_self_type.GetOpaqueQualType());
if (!imported_self_type)
return;
}

{
@@ -573,6 +577,8 @@ static void AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
// and we have to grab the instance type:
imported_self_type = swift_type_system->GetInstanceType(
imported_self_type.GetOpaqueQualType());
if (!imported_self_type)
return;
}

Flags imported_self_type_flags(imported_self_type.GetTypeInfo());
29 changes: 14 additions & 15 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp
Original file line number Diff line number Diff line change
@@ -2176,12 +2176,12 @@ CompilerType TypeSystemSwiftTypeRef::GetFieldAtIndex(
static swift::Demangle::NodePointer
GetClangTypeTypeNode(TypeSystemSwiftTypeRef &ts,
swift::Demangle::Demangler &dem, CompilerType clang_type,
SwiftASTContext *swift_ast_context) {
SwiftASTContext *module_holder) {
assert(llvm::isa<TypeSystemClang>(clang_type.GetTypeSystem()) &&
"expected a clang type");
using namespace swift::Demangle;
NodePointer type = dem.createNode(Node::Kind::Type);
type->addChild(GetClangTypeNode(clang_type, dem, swift_ast_context), dem);
type->addChild(GetClangTypeNode(clang_type, dem, module_holder), dem);
return type;
}

@@ -2342,20 +2342,19 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
llvm::StringRef suffix(ast_child_name);
if (suffix.consume_front("__ObjC."))
ast_child_name = suffix.str();
assert((llvm::StringRef(child_name).contains('.') ||
Equivalent(child_name, ast_child_name)));
assert((Equivalent(llvm::Optional<uint64_t>(child_byte_size),
llvm::Optional<uint64_t>(ast_child_byte_size)) ||
ast_language_flags));
assert(Equivalent(llvm::Optional<uint64_t>(child_byte_offset),
llvm::Optional<uint64_t>(ast_child_byte_offset)));
assert(
(llvm::StringRef(child_name).contains('.') ||
Equivalent(child_name, ast_child_name)) &&
(Equivalent(llvm::Optional<uint64_t>(child_byte_size),
llvm::Optional<uint64_t>(ast_child_byte_size)) ||
ast_language_flags) &&
Equivalent(llvm::Optional<uint64_t>(child_byte_offset),
llvm::Optional<uint64_t>(ast_child_byte_offset)) &&
Equivalent(child_bitfield_bit_offset, ast_child_bitfield_bit_offset) &&
Equivalent(child_bitfield_bit_size, ast_child_bitfield_bit_size) &&
Equivalent(child_is_base_class, ast_child_is_base_class) &&
Equivalent(child_is_deref_of_parent, ast_child_is_deref_of_parent) &&
Equivalent(language_flags, ast_language_flags) &&
"TypeSystemSwiftTypeRef diverges from SwiftASTContext");
Equivalent(child_bitfield_bit_offset, ast_child_bitfield_bit_offset));
assert(Equivalent(child_bitfield_bit_size, ast_child_bitfield_bit_size));
assert(Equivalent(child_is_base_class, ast_child_is_base_class));
assert(Equivalent(child_is_deref_of_parent, ast_child_is_deref_of_parent));
assert(Equivalent(language_flags, ast_language_flags));
});
#endif
VALIDATE_AND_RETURN(
12 changes: 6 additions & 6 deletions lldb/source/Target/SwiftLanguageRuntimeDynamicTypeResolution.cpp
Original file line number Diff line number Diff line change
@@ -1485,6 +1485,11 @@ bool SwiftLanguageRuntimeImpl::ForEachSuperClassType(
auto *reflection_ctx = GetReflectionContext();
if (!reflection_ctx)
return false;
CompilerType instance_type = instance.GetCompilerType();
auto *ts =
llvm::dyn_cast_or_null<TypeSystemSwift>(instance_type.GetTypeSystem());
if (!ts)
return false;

lldb::addr_t pointer = instance.GetPointerValue();
// Maybe this belongs into GetPointerValue, but on the other hand it
@@ -1494,7 +1499,7 @@ bool SwiftLanguageRuntimeImpl::ForEachSuperClassType(
// libReflection cannot tell up how many bits to strip from
// multi-payload enum values.
auto addr_deref =
FixupPointerValue(pointer, instance.GetCompilerType());
FixupPointerValue(pointer, instance_type);
pointer = addr_deref.first;
if (addr_deref.second) {
// This is a reference storage object.
@@ -1504,11 +1509,6 @@ bool SwiftLanguageRuntimeImpl::ForEachSuperClassType(
return false;
}

auto *ts = llvm::dyn_cast_or_null<TypeSystemSwiftTypeRef>(
instance.GetCompilerType().GetTypeSystem());
if (!ts)
return false;

auto md_ptr = reflection_ctx->readMetadataFromInstance(pointer);
if (!md_ptr)
return false;