Skip to content
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
20 changes: 10 additions & 10 deletions Sources/ComputeCxx/Comparison/LayoutDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,23 +1145,25 @@ bool Builder::visit_case(const swift::metadata &type, const swift::field_record
};
enum_item.cases.push_back(std::move(enum_case));

bool result;

_enum_case_depth += 1;
EnumItem::Case *prev_enum_case = _current_enum_case;
_current_enum_case = &enum_item.cases.back();

if (field.isIndirectCase() && _current_comparison_mode == 0) {
add_field(sizeof(void *));
result = true;
} else {
const auto *mangled_type_name = field.MangledTypeName.get();
const auto *field_type =
mangled_type_name != nullptr ? type.mangled_type_name_ref(mangled_type_name, false, nullptr) : nullptr;
if (field_type == nullptr) {
// bail out if we can't get a type for the enum case payload
// bail out if we can't get a type for the enum case payload. The enum item and its cases are destroyed, so
// return without touching them again.
items.pop_back();
result = false;

_enum_case_depth -= 1;
_current_enum_case = prev_enum_case;

return false;
} else if (field.isIndirectCase()) {
if (auto field_size = field_type->vw_size()) {
IndirectItem item = {
Expand All @@ -1171,7 +1173,6 @@ bool Builder::visit_case(const swift::metadata &type, const swift::field_record
};
_current_enum_case->children.push_back(item);
}
result = true;
} else {
IAGComparisonMode prev_comparison_mode = _current_comparison_mode;
_current_comparison_mode = mode_for_type(&type, _current_comparison_mode);
Expand All @@ -1180,6 +1181,7 @@ bool Builder::visit_case(const swift::metadata &type, const swift::field_record

// same as visit_element
auto &items = get_items();
auto num_items = items.size();
size_t prev_offset = -1;
size_t prev_size = 0;
if (auto *data_item = items.size() > 0 ? std::get_if<DataItem>(&items.back()) : nullptr) {
Expand All @@ -1189,7 +1191,7 @@ bool Builder::visit_case(const swift::metadata &type, const swift::field_record

if (!field_type->visit(*this)) {
RevertItemsInfo info = {
items.size(),
num_items,
{
prev_offset,
prev_size,
Expand All @@ -1209,8 +1211,6 @@ bool Builder::visit_case(const swift::metadata &type, const swift::field_record
}

_current_comparison_mode = prev_comparison_mode;

result = true;
}
}

Expand All @@ -1221,7 +1221,7 @@ bool Builder::visit_case(const swift::metadata &type, const swift::field_record
_enum_case_depth -= 1;
_current_enum_case = prev_enum_case;

return result;
return true;
}

bool Builder::visit_existential(const swift::existential_type_metadata &type) {
Expand Down
Loading