From 2e1dbb2a6f081ed55cfdb69490242bbf49ca18ae Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Fri, 16 Aug 2024 14:48:39 +0200 Subject: [PATCH] reader: Avoid empty return type node for a function type IR Sometimes, the function type IR can have an empty node as return type, to represent void. This can wreak havoc on some part of the code that don't expect that. This patch uses a proper void type node for that instead. * src/abg-reader.cc (build_function_type): If the return type node is empty, use a void type node. Signed-off-by: Dodji Seketeli --- src/abg-reader.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 8c66d6b4..e9cc9f19 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -4515,11 +4515,16 @@ build_function_type(reader& rdr, if (xml_char_sptr s = xml::build_sptr(xmlGetProp(n, BAD_CAST("type-id")))) type_id = CHAR_STR(s); + type_base_sptr ret_type; if (!type_id.empty()) - fn_type->set_return_type(rdr.build_or_get_type_decl - (type_id, true)); + ret_type = rdr.build_or_get_type_decl (type_id, true); + if (!ret_type) + ret_type = return_type; + fn_type->set_return_type(ret_type); } } + if (!fn_type->get_return_type()) + fn_type->set_return_type(return_type); fn_type->set_parameters(parms);