RFR: 7903647: typedef of function pointers generates a redundant class
Jorn Vernee
jvernee at openjdk.org
Fri Jan 26 13:30:47 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.
Marked as reviewed by jvernee (Committer).
-------------
PR Review: https://git.openjdk.org/jextract/pull/196#pullrequestreview-1845751005
More information about the jextract-dev
mailing list