Skip to content

Commit 83a5869

Browse files
Merge pull request #1213 from adrian-prantl/63051847
Remove all API that take a CompilerType as an in-argument from TypeSystemSwift
2 parents cb3dbcb + 9f76d0e commit 83a5869

File tree

9 files changed

+591
-464
lines changed

9 files changed

+591
-464
lines changed

lldb/include/lldb/Symbol/SwiftASTContext.h

Lines changed: 266 additions & 198 deletions
Large diffs are not rendered by default.

lldb/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,9 +1138,11 @@ bool SwiftASTManipulator::AddExternalVariables(
11381138
variable.m_type.GetTypeSystem());
11391139

11401140
CompilerType referent_type;
1141-
11421141
if (swift_ast_ctx)
1143-
referent_type = swift_ast_ctx->GetReferentType(variable.m_type);
1142+
referent_type =
1143+
swift_ast_ctx->GetReferentType(variable.m_type.GetOpaqueQualType());
1144+
if (!referent_type)
1145+
continue;
11441146

11451147
// One tricky bit here is that this var may be an argument to the function
11461148
// whose context we are

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
531531
// extend the referent:
532532
imported_self_type =
533533
llvm::cast<TypeSystemSwift>(imported_self_type.GetTypeSystem())
534-
->GetReferentType(imported_self_type);
534+
->GetReferentType(imported_self_type.GetOpaqueQualType());
535535

536536
// If we are extending a generic class it's going to be a metatype,
537537
// and we have to grab the instance type:
@@ -553,7 +553,6 @@ AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
553553
if (swift::WeakStorageType *weak_storage_type =
554554
GetSwiftType(imported_self_type)->getAs<swift::WeakStorageType>()) {
555555
swift::Type referent_type = weak_storage_type->getReferentType();
556-
557556
swift::BoundGenericEnumType *optional_type =
558557
referent_type->getAs<swift::BoundGenericEnumType>();
559558

lldb/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,13 @@ void SwiftUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
244244
self_type = ToCompilerType(object_type.getPointer());
245245

246246
// Handle weak self.
247-
if (auto *ref_type = llvm::dyn_cast_or_null<swift::ReferenceStorageType>(
248-
GetSwiftType(self_type).getPointer())) {
249-
if (ref_type->getOwnership() == swift::ReferenceOwnership::Weak) {
250-
m_is_class = true;
251-
m_is_weak_self = true;
252-
}
247+
using Strategy = SwiftASTContext::NonTriviallyManagedReferenceStrategy;
248+
Strategy strategy;
249+
if (SwiftASTContext::IsNonTriviallyManagedReferenceType(self_type,
250+
strategy) &&
251+
strategy == Strategy::eWeak) {
252+
m_is_class = true;
253+
m_is_weak_self = true;
253254
}
254255

255256
if (Flags(self_type.GetTypeInfo())

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,8 @@ SwiftLanguage::GetHardcodedSynthetics() {
780780
TypeSystemSwift *swift_ast_ctx =
781781
llvm::dyn_cast_or_null<TypeSystemSwift>(
782782
type.GetTypeSystem());
783-
if (swift_ast_ctx &&
784-
swift_ast_ctx->IsImportedType(type, nullptr))
783+
if (swift_ast_ctx && swift_ast_ctx->IsImportedType(
784+
type.GetOpaqueQualType(), nullptr))
785785
is_imported = true;
786786
}
787787

lldb/source/Plugins/Language/Swift/SwiftOptionSet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ static clang::EnumDecl *GetAsEnumDecl(CompilerType swift_type) {
3939
return nullptr;
4040

4141
CompilerType clang_type;
42-
if (!swift_ast_ctx->IsImportedType(swift_type, &clang_type))
42+
if (!swift_ast_ctx->IsImportedType(swift_type.GetOpaqueQualType(),
43+
&clang_type))
4344
return nullptr;
4445

4546
if (!clang_type.IsValid())

0 commit comments

Comments
 (0)