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

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Jan 26 12:42:55 UTC 2024


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.

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

Commit messages:
 - Improve test, by adding typedef uses
 - Initial push

Changes: https://git.openjdk.org/jextract/pull/196/files
 Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=196&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903647
  Stats: 116 lines in 4 files changed: 112 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jextract/pull/196.diff
  Fetch: git fetch https://git.openjdk.org/jextract.git pull/196/head:pull/196

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


More information about the jextract-dev mailing list