[11/16] ir: Fix forgetting canonicalizing some function types

Message ID 875y4mf5bq.fsf@redhat.com
State New
Headers
Series Fixing various issues found while working on PR30309 |

Commit Message

Dodji Seketeli Sept. 7, 2023, 2:03 p.m. UTC
  Hello,

It appears some function types are not canonicalized. Fixed thus.

	* src/abg-ir.cc (maybe_adjust_canonical_type): Once a missing
	member function has been copied from it's destination to the
	freshly canonicalized type, make sure the type of the member
	function is canonicalized as well.
	(copy_member_function): Bind the lifetime of the new function type
	to the lifetime of the current translation unit.

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

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 93d79b33..2bbb1a49 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -15006,7 +15006,11 @@  maybe_adjust_canonical_type(const type_base_sptr& canonical,
 		  // class doesn't have that member function.  Let's
 		  // copy that member function to the canonical class
 		  // then.
-		  copy_member_function (canonical_class, *i);
+		  {
+		    method_decl_sptr method =
+		      copy_member_function (canonical_class, *i);
+		    canonicalize(method->get_type());
+		  }
 	      }
 	}
     }
@@ -22873,7 +22877,7 @@  copy_member_function(const class_or_union_sptr& t, const method_decl* method)
 					    old_type->get_is_const(),
 					    old_type->get_size_in_bits(),
 					    old_type->get_alignment_in_bits()));
-  keep_type_alive(new_type);
+  t->get_translation_unit()->bind_function_type_life_time(new_type);
 
   method_decl_sptr
     new_method(new method_decl(method->get_name(),