Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

[SwiftExpressionParser] Remove a bunch of hacks in the handling of `s… #1789

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
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
50 changes: 0 additions & 50 deletions source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,19 +525,10 @@ AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
self_type = valobj_sp->GetCompilerType();
}

if (!self_type.IsValid()) {
if (Type *type = self_var_sp->GetType()) {
self_type = type->GetForwardCompilerType();
}
}

if (!self_type.IsValid() ||
!llvm::isa<SwiftASTContext>(self_type.GetTypeSystem()))
return;

// Import before getting the unbound version, because the unbound
// version may not be in the mangled name map.

CompilerType imported_self_type = ImportType(swift_ast_context, self_type);

if (!imported_self_type.IsValid())
Expand All @@ -550,52 +541,11 @@ AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
swift_runtime->DoArchetypeBindingForType(*stack_frame,
imported_self_type);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we overwrite imported_self_type, might be a good thing to assert that the archtetype binding succeeded (assert(imported_type_type.isValid());)


// This might be a referenced type, in which case we really want to
// extend the referent:
imported_self_type =
llvm::cast<SwiftASTContext>(imported_self_type.GetTypeSystem())
->GetReferentType(imported_self_type);

// If we are extending a generic class it's going to be a metatype,
// and we have to grab the instance type:
imported_self_type =
llvm::cast<SwiftASTContext>(imported_self_type.GetTypeSystem())
->GetInstanceType(imported_self_type.GetOpaqueQualType());

Flags imported_self_type_flags(imported_self_type.GetTypeInfo());

swift::Type object_type =
GetSwiftType(imported_self_type)->getWithoutSpecifierType();

if (object_type.getPointer() &&
(object_type.getPointer() != imported_self_type.GetOpaqueQualType()))
imported_self_type = CompilerType(imported_self_type.GetTypeSystem(),
object_type.getPointer());

// If 'self' is a weak storage type, it must be an optional. Look
// through it and unpack the argument of "optional".
if (swift::WeakStorageType *weak_storage_type =
GetSwiftType(imported_self_type)->getAs<swift::WeakStorageType>()) {
swift::Type referent_type = weak_storage_type->getReferentType();

swift::BoundGenericEnumType *optional_type =
referent_type->getAs<swift::BoundGenericEnumType>();

if (!optional_type)
return;

swift::Type first_arg_type = optional_type->getGenericArgs()[0];

swift::ClassType *self_class_type =
first_arg_type->getAs<swift::ClassType>();

if (!self_class_type)
return;

imported_self_type =
CompilerType(imported_self_type.GetTypeSystem(), self_class_type);
}

imported_self_type_flags.Reset(imported_self_type.GetTypeInfo());
if (imported_self_type_flags.AllClear(lldb::eTypeIsGenericTypeParam)) {
swift::ValueDecl *type_alias_decl = nullptr;
Expand Down