harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3990b7f01d35e6e6cf88a353f0fe2cfdd3e94d04
parent c0625069db5e482cea9f83f94cde1010c6feb0b6
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Mon, 28 Mar 2022 22:52:46 +0200

rename tagged_subset_compat parameters

This function merely checks whether a tagged union is a subset of
another tagged union and it is sometimes used with `from` as the
destination and `to` as the source of a cast, which is confusing.

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>

Diffstat:
Msrc/types.c | 24++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/types.c b/src/types.c @@ -678,28 +678,28 @@ promote_const(const struct type *a, const struct type *b) { } bool -tagged_subset_compat(const struct type *to, const struct type *from) +tagged_subset_compat(const struct type *superset, const struct type *subset) { // Note: this implementation depends on the invariant that tagged union // member types are sorted by their type ID. - to = type_dealias(to), from = type_dealias(from); - if (to->storage != STORAGE_TAGGED || from->storage != STORAGE_TAGGED) { + superset = type_dealias(superset), subset = type_dealias(subset); + if (superset->storage != STORAGE_TAGGED || subset->storage != STORAGE_TAGGED) { return false; } - const struct type_tagged_union *to_tu = &to->tagged, - *from_tu = &from->tagged; - while (from_tu && to_tu) { - while (to_tu) { - if (to_tu->type->id == from_tu->type->id) { - from_tu = from_tu->next; - to_tu = to_tu->next; + const struct type_tagged_union *superset_tu = &superset->tagged, + *subset_tu = &subset->tagged; + while (subset_tu && superset_tu) { + while (superset_tu) { + if (superset_tu->type->id == subset_tu->type->id) { + subset_tu = subset_tu->next; + superset_tu = superset_tu->next; break; } - to_tu = to_tu->next; + superset_tu = superset_tu->next; } } - return !from_tu; + return !subset_tu; } static bool