From cc2c732dd5f2c72414f6a6992551b9406a0ad969 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Sat, 29 Feb 2020 18:46:34 -0600 Subject: [PATCH] insert a new second rule for tagged union discovery 1. if the field name ends in "data" and there is a field with the same prefix ending in "type", the field ending in "type" is the tag. 2. if the field name ends in "_target" and the previous field has the same prefix and no suffix, the previous field is the tag. 3. if the field is not the last field in the structure, the next field is the tag. --- plugins/devel/check-structures-sanity.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/devel/check-structures-sanity.cpp b/plugins/devel/check-structures-sanity.cpp index 2045145d3..6dc4b7335 100644 --- a/plugins/devel/check-structures-sanity.cpp +++ b/plugins/devel/check-structures-sanity.cpp @@ -110,6 +110,10 @@ static const struct_field_info *find_union_tag(const struct_field_info *fields, } } } + else if (name.length() > 7 && name.substr(name.length() - 7) == "_target" && fields != union_field && (union_field - 1)->name == name.substr(0, name.length() - 7)) + { + tag_field = union_field - 1; + } if (tag_field->mode != struct_field_info::PRIMITIVE || !tag_field->type || @@ -165,6 +169,10 @@ static const struct_field_info *find_union_vector_tag_vector(const struct_field_ } } } + else if (name.length() > 7 && name.substr(name.length() - 7) == "_target" && fields != union_field && (union_field - 1)->name == name.substr(0, name.length() - 7)) + { + tag_field = union_field - 1; + } if (tag_field->mode != struct_field_info::CONTAINER || !tag_field->type ||