[3/4] reader: Avoid empty return type node for a function type IR

Message ID 20240817120026.459568-3-dodji@redhat.com
State New
Headers
Series [1/4] ir: Improve legibility of set_member_function_is_virtual |

Commit Message

Dodji Seketeli Aug. 17, 2024, noon UTC
  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 <dodji@redhat.com>
---
 src/abg-reader.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
  

Patch

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);