Skip to content
Merged
Show file tree
Hide file tree
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
Expand Up @@ -489,7 +489,8 @@ GetPersistentState(Target *target, ExecutionContext &exe_ctx) {
static bool CanEvaluateExpressionWithoutBindingGenericParams(
const llvm::SmallVectorImpl<SwiftASTManipulator::VariableInfo> &variables,
const llvm::Optional<SwiftLanguageRuntime::GenericSignature> &generic_sig,
Block *block, StackFrame &stack_frame) {
SwiftASTContextForExpressions &scratch_ctx, Block *block,
StackFrame &stack_frame) {
// First, find the compiler type of self with the generic parameters not
// bound.
auto self_var = SwiftExpressionParser::FindSelfVariable(block);
Expand All @@ -514,11 +515,7 @@ static bool CanEvaluateExpressionWithoutBindingGenericParams(
if (!ts)
return false;

auto *swift_ast_ctx = ts->GetSwiftASTContext();
if (!swift_ast_ctx)
return false;

auto swift_type = swift_ast_ctx->GetSwiftType(self_type);
auto swift_type = scratch_ctx.GetSwiftType(self_type);
if (!swift_type)
return false;

Expand Down Expand Up @@ -614,7 +611,8 @@ SwiftUserExpression::GetTextAndSetExpressionParser(

if (m_options.GetBindGenericTypes() == lldb::eDontBind &&
!CanEvaluateExpressionWithoutBindingGenericParams(
local_variables, m_generic_signature, sc.block, *stack_frame.get())) {
local_variables, m_generic_signature, *m_swift_ast_ctx, sc.block,
*stack_frame.get())) {
diagnostic_manager.PutString(
eDiagnosticSeverityError,
"Could not evaluate the expression without binding generic types.");
Expand Down
13 changes: 2 additions & 11 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,10 @@ CompilerType SwiftASTContext::GetCompilerType(swift::TypeBase *swift_type) {
}

swift::Type SwiftASTContext::GetSwiftType(CompilerType compiler_type) {
if (compiler_type.GetTypeSystem().isa_and_nonnull<SwiftASTContext>())
if (compiler_type.GetTypeSystem().GetSharedPointer().get() == this)
return reinterpret_cast<swift::TypeBase *>(
compiler_type.GetOpaqueQualType());

// FIXME: Suboptimal performance, because the ConstString is looked up again.
if (auto ts = compiler_type.GetTypeSystem()
.dyn_cast_or_null<TypeSystemSwiftTypeRef>()) {
ConstString mangled_name(
reinterpret_cast<const char *>(compiler_type.GetOpaqueQualType()));
if (auto *swift_ast_context = ts->GetSwiftASTContext())
return swift_ast_context->ReconstructType(mangled_name);
}
return {};
return ReconstructType(compiler_type.GetMangledTypeName());
}

swift::Type SwiftASTContext::GetSwiftType(opaque_compiler_type_t opaque_type) {
Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,11 @@ class SwiftASTContext : public TypeSystemSwift {

CompilerType GetCompilerType(swift::TypeBase *swift_type);
CompilerType GetCompilerType(ConstString mangled_name);
/// Import compiler_type into this context and return the swift::Type.
swift::Type GetSwiftType(CompilerType compiler_type);
protected:
swift::Type GetSwiftType(lldb::opaque_compiler_type_t opaque_type);
public:
swift::CanType
GetCanonicalSwiftType(lldb::opaque_compiler_type_t opaque_type);

Expand Down