public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/4] ir: Improve legibility of set_member_function_is_virtual
@ 2024-08-17 12:00 Dodji Seketeli
  2024-08-17 12:00 ` [PATCH 2/4] ir: Don't cache internal name of non-canonicalized function types Dodji Seketeli
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dodji Seketeli @ 2024-08-17 12:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji

	* src/abg-ir.cc (set_member_function_is_virtual): Remove
	useless white space and use clearer helper function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-ir.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 542f9060..bc23254a 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -6730,8 +6730,7 @@ set_member_function_is_virtual(const function_decl_sptr& fn, bool is_virtual)
   if (fn)
     {
       set_member_function_is_virtual(*fn, is_virtual);
-      fixup_virtual_member_function
-	(dynamic_pointer_cast<method_decl>(fn));
+      fixup_virtual_member_function(is_method_decl(fn));
     }
 }
 
-- 
2.43.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/4] ir: Don't cache internal name of non-canonicalized function types
  2024-08-17 12:00 [PATCH 1/4] ir: Improve legibility of set_member_function_is_virtual Dodji Seketeli
@ 2024-08-17 12:00 ` Dodji Seketeli
  2024-08-17 12:00 ` [PATCH 3/4] reader: Avoid empty return type node for a function type IR Dodji Seketeli
  2024-08-17 12:00 ` [PATCH 4/4] ir: Handle ptr to fn type member with empty void return type Dodji Seketeli
  2 siblings, 0 replies; 4+ messages in thread
From: Dodji Seketeli @ 2024-08-17 12:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji

When a function type is not yet canonicalized, do not cache its name,
otherwise, the name can capture the state of the function in a too
early state.

	* src/abg-ir.cc (function_type::get_cached_name): Do not cache
	internal name for non-canonicalized function types.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-ir.cc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index bc23254a..873f3750 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -21633,9 +21633,8 @@ function_type::get_cached_name(bool internal) const
 	}
       else
 	{
-	  if (priv_->temp_internal_cached_name_.empty())
-	    priv_->temp_internal_cached_name_ =
-	      get_function_type_name(this, /*internal=*/true);
+	  priv_->temp_internal_cached_name_ =
+	    get_function_type_name(this, /*internal=*/true);
 	  return priv_->temp_internal_cached_name_;
 	}
     }
-- 
2.43.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/4] reader: Avoid empty return type node for a function type IR
  2024-08-17 12:00 [PATCH 1/4] ir: Improve legibility of set_member_function_is_virtual Dodji Seketeli
  2024-08-17 12:00 ` [PATCH 2/4] ir: Don't cache internal name of non-canonicalized function types Dodji Seketeli
@ 2024-08-17 12:00 ` Dodji Seketeli
  2024-08-17 12:00 ` [PATCH 4/4] ir: Handle ptr to fn type member with empty void return type Dodji Seketeli
  2 siblings, 0 replies; 4+ messages in thread
From: Dodji Seketeli @ 2024-08-17 12:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji

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

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 4/4] ir: Handle ptr to fn type member with empty void return type
  2024-08-17 12:00 [PATCH 1/4] ir: Improve legibility of set_member_function_is_virtual Dodji Seketeli
  2024-08-17 12:00 ` [PATCH 2/4] ir: Don't cache internal name of non-canonicalized function types Dodji Seketeli
  2024-08-17 12:00 ` [PATCH 3/4] reader: Avoid empty return type node for a function type IR Dodji Seketeli
@ 2024-08-17 12:00 ` Dodji Seketeli
  2 siblings, 0 replies; 4+ messages in thread
From: Dodji Seketeli @ 2024-08-17 12:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji

If a pointer to member type points to a function type that has an
empty return type, sometimes that can lead to a crash.  This patch
considers that the empty return type is a void type.

	* src/abg-ir.cc (add_outer_ptr_to_mbr_type_expr): If the function
	type has no return type, consider it as void type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-ir.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 873f3750..f189cb09 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -28903,6 +28903,7 @@ add_outer_ptr_to_mbr_type_expr(const ptr_to_mbr_type* p,
     return "";
 
   std::ostringstream left, right, inner;
+  type_base_sptr void_type = p->get_environment().get_void_type();
   string containing_type_name = get_type_name(p->get_containing_type(),
 					      qualified, internal);
   type_base_sptr mbr_type = p->get_member_type();
@@ -28913,6 +28914,8 @@ add_outer_ptr_to_mbr_type_expr(const ptr_to_mbr_type* p,
       stream_pretty_representation_of_fn_parms(*fn_type, right,
 					       qualified, internal);
       type_base_sptr return_type = fn_type->get_return_type();
+      if (!return_type)
+	return_type = void_type;
       if (is_npaf_type(return_type)
 	  || !(is_pointer_to_function_type(return_type)
 	       || is_pointer_to_array_type(return_type)
-- 
2.43.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-17 12:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-17 12:00 [PATCH 1/4] ir: Improve legibility of set_member_function_is_virtual Dodji Seketeli
2024-08-17 12:00 ` [PATCH 2/4] ir: Don't cache internal name of non-canonicalized function types Dodji Seketeli
2024-08-17 12:00 ` [PATCH 3/4] reader: Avoid empty return type node for a function type IR Dodji Seketeli
2024-08-17 12:00 ` [PATCH 4/4] ir: Handle ptr to fn type member with empty void return type Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).