Skip to content

Commit 914c743

Browse files
Merge pull request #10067 from adrian-prantl/144882382
[lldb] Only apply the indirect enum heuristic for enums.
2 parents 1b4e578 + 7e128aa commit 914c743

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,9 +1171,9 @@ llvm::Expected<CompilerType> SwiftLanguageRuntime::GetChildCompilerTypeAtIndex(
11711171
auto get_from_field_info =
11721172
[&](const swift::reflection::FieldInfo &field,
11731173
std::optional<TypeSystemSwift::TupleElement> tuple,
1174-
bool hide_existentials) -> CompilerType {
1174+
bool hide_existentials, bool is_enum) -> CompilerType {
11751175
bool is_indirect_enum =
1176-
!field.Offset && field.TR &&
1176+
is_enum && !field.Offset && field.TR &&
11771177
llvm::isa<swift::reflection::BuiltinTypeRef>(field.TR) &&
11781178
llvm::isa<swift::reflection::ReferenceTypeInfo>(field.TI) &&
11791179
llvm::cast<swift::reflection::ReferenceTypeInfo>(field.TI)
@@ -1258,7 +1258,9 @@ llvm::Expected<CompilerType> SwiftLanguageRuntime::GetChildCompilerTypeAtIndex(
12581258
return llvm::createStringError(llvm::Twine("index") + llvm::Twine(idx) +
12591259
"is out of bounds (" +
12601260
llvm::Twine(fields.size()) + ")");
1261-
return get_from_field_info(fields[idx - 3], tuple, false);
1261+
return get_from_field_info(fields[idx - 3], tuple,
1262+
/*hide_existentials=*/false,
1263+
/*is_enum=*/false);
12621264
}
12631265
if (rti->getRecordKind() ==
12641266
swift::reflection::RecordKind::ClassExistential) {
@@ -1281,7 +1283,8 @@ llvm::Expected<CompilerType> SwiftLanguageRuntime::GetChildCompilerTypeAtIndex(
12811283
return llvm::createStringError(llvm::Twine("index") + llvm::Twine(idx) +
12821284
"is out of bounds (" +
12831285
llvm::Twine(fields.size()) + ")");
1284-
return get_from_field_info(fields[idx], tuple, true);
1286+
return get_from_field_info(fields[idx], tuple, /*hide_existentials=*/true,
1287+
/*is_enum=*/false);
12851288
}
12861289
// Enums.
12871290
if (auto *eti = llvm::dyn_cast_or_null<swift::reflection::EnumTypeInfo>(ti)) {
@@ -1291,7 +1294,8 @@ llvm::Expected<CompilerType> SwiftLanguageRuntime::GetChildCompilerTypeAtIndex(
12911294
if (!enum_case.TR)
12921295
continue;
12931296
if (i++ == idx)
1294-
return get_from_field_info(enum_case, {}, true);
1297+
return get_from_field_info(enum_case, {}, /*hide_existentials=*/true,
1298+
/*is_enum=*/true);
12951299
}
12961300
return llvm::createStringError(
12971301
llvm::inconvertibleErrorCode(),
@@ -1414,7 +1418,9 @@ llvm::Expected<CompilerType> SwiftLanguageRuntime::GetChildCompilerTypeAtIndex(
14141418
auto fields = rti->getFields();
14151419
if (idx < fields.size()) {
14161420
std::optional<TypeSystemSwift::TupleElement> tuple;
1417-
return get_from_field_info(fields[idx], tuple, true);
1421+
return get_from_field_info(fields[idx], tuple,
1422+
/*hide_existentials=*/true,
1423+
/*is_enum=*/false);
14181424
}
14191425
}
14201426
return llvm::createStringError(llvm::Twine("index") + llvm::Twine(idx) +
@@ -1461,7 +1467,8 @@ llvm::Expected<CompilerType> SwiftLanguageRuntime::GetChildCompilerTypeAtIndex(
14611467
return llvm::createStringError("no record type info");
14621468
for (auto &field : object->getFields())
14631469
if (i++ == idx)
1464-
return get_from_field_info(field, {}, true);
1470+
return get_from_field_info(field, {}, /*hide_existentials=*/true,
1471+
/*is_enum=*/false);
14651472

14661473
return llvm::createStringError(llvm::Twine("index") + llvm::Twine(idx) +
14671474
"is out of bounds (" + llvm::Twine(i - 1) +

0 commit comments

Comments
 (0)