ir: Tighten type comparison optimization for Linux kernel binaries

types_defined_same_linux_kernel_corpus_public() performs an
optimization while comparing two types in the context of the Linux
kernel.  If two types of the same kind and name are defined in the
same corpus and in the same file, then they ought to be equal.

For two anonymous classes that have naming typedefs, the function
forgets to ensure that the naming typedefs have the same name.

I have no binary that exhibits the potential issue, but I stumbled
upon the problem while looking at something else that uncovered
the problem.  This change doesn't impact any of the binaries of the
regression suite at the moment, though.

Fixed thus.

	* src/abg-ir.cc (types_defined_same_linux_kernel_corpus_public):
	Ensure that anonymous classes with naming typedefs have identical
	typedef names.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2021-06-25 12:35:28 +02:00
parent d71518dbf0
commit 2d276b67ed

View File

@ -13161,6 +13161,16 @@ types_defined_same_linux_kernel_corpus_public(const type_base& t1,
|| (c2 && c2->get_is_anonymous() && !c2->get_naming_typedef()))
return false;
// Two anonymous classes with naming typedefs should have the same
// typedef name.
if (c1
&& c2
&& c1->get_is_anonymous() && c1->get_naming_typedef()
&& c2->get_is_anonymous() && c2->get_naming_typedef())
if (c1->get_naming_typedef()->get_name()
!= c2->get_naming_typedef()->get_name())
return false;
// Two anonymous enum types cannot be eligible to this optimization.
if (const enum_type_decl *e1 = is_enum_type(&t1))
if (const enum_type_decl *e2 = is_enum_type(&t2))