Integrated: 7903647: typedef of function pointers generates a redundant class

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Jan 26 13:38:57 UTC 2024


On Fri, 26 Jan 2024 12:37:19 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This PR fixes few more issues with typedefs.
> 
> The first issue is that function pointer typedefs generate two classes. The first is generated when we go in OutpoutFactory::visitTypedef (as expected). The second class is generated when we look at the parameters of a function that declares a parameter whose type is the function pointer typedef.
> 
> The second issue is that when a typedef for an anon struct is typedeffed again, we end up skipping the second typedef, as the underlying type of the typedef is - again- an anoymous struct.
> 
> The solution to the first issue is to tweak `Utils::getAsFunctionPointer` not to process typedef types. After looking at all usages of this method, it dawned on me that this is actually the behavior that we want: when processing nested types, we only want to emit stuff for declarations that are truly "inline", and not for typedefs of other declarations.
> 
> The solution to the second issue is to make the skipping logic for anon struct more nuanced, so that we only skip anon declarations that are _nested_ in the very typedef being processed.
> 
> I've added a test for both conditions, as existing tests were not enough to cover these discrepancies.

This pull request has now been integrated.

Changeset: 7a4c7f87
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/jextract/commit/7a4c7f87d43ca007a4e0a5494ee2a3221629c2df
Stats:     116 lines in 4 files changed: 112 ins; 0 del; 4 mod

7903647: typedef of function pointers generates a redundant class

Reviewed-by: jvernee

-------------

PR: https://git.openjdk.org/jextract/pull/196


More information about the jextract-dev mailing list