Skip to content

[lldb] SwiftUserExpression avoid call to ImportType (NFCi) #10376

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 1 commit into from
Mar 30, 2025
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
Expand Up @@ -336,7 +336,7 @@ static llvm::Error AddVariableInfo(
should_not_bind_generic_types &&
(variable_sp->GetType()->GetForwardCompilerType().GetTypeInfo() &
lldb::eTypeIsPack);

bool is_meaningless_without_dynamic_resolution = false;
// If we're not binding the generic types, we need to set the self type as an
// opaque pointer type. This is necessary because we don't bind the generic
// parameters, and we can't have a type with unbound generics in a non-generic
Expand All @@ -349,8 +349,13 @@ static llvm::Error AddVariableInfo(
CompilerType var_type = SwiftExpressionParser::ResolveVariable(
variable_sp, stack_frame_sp, runtime, use_dynamic, bind_generic_types);

Status error;
target_type = ast_context.ImportType(var_type, error);
is_meaningless_without_dynamic_resolution =
var_type.IsMeaninglessWithoutDynamicResolution();

// ImportType would only return a TypeRef type anyway, so it's
// faster to leave the type in its original context for faster
// type alias resolution.
target_type = var_type;
}

// If the import failed, give up.
Expand All @@ -376,8 +381,7 @@ static llvm::Error AddVariableInfo(
// If we couldn't fully realize the type, then we aren't going
// to get very far making a local out of it, so discard it here.
Log *log = GetLog(LLDBLog::Types | LLDBLog::Expressions);
if (!is_unbound_pack && ts->IsMeaninglessWithoutDynamicResolution(
target_type.GetOpaqueQualType())) {
if (is_meaningless_without_dynamic_resolution) {
if (log)
log->Printf("Discarding local %s because we couldn't fully realize it, "
"our best attempt was: %s.",
Expand Down