Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix references to typedefs of anonymous struct/union/enum on clang 15 and earlier #218

Merged
merged 2 commits into from
Nov 18, 2023

Conversation

jnikula
Copy link
Owner

@jnikula jnikula commented Nov 18, 2023

Fix for #201

Copy link
Collaborator

@BrunoMSantos BrunoMSantos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Small typo in the 1st commit message though: "[...],but should also cleaned up later."

Clang 15 and earlier have None for the cursor.spelling of typedefs of
anonymous structs/unions/enums. Clang 16 and later return the name of
the typedef. We address this in decl_name to get the Docstring right
across Clang versions, but the name filtering in Docstring._match() uses
name. This results in us being unable to reference typedefs of anonymous
entities with Clang 15 and earlier.

Fix it up by returning decl_name as name from Doccursor if
cursor.spelling is None.

In the long run, we should unify on just name. The decl_name was always
a workaround when we did the fixups in parser.py. With Doccursor, we
should be able to further clean that up, but for the time being, close
the known issue with the minimal fix.

It's probably theoretical, but in the case *both* name and decl_name
were None, we'd end up in infinite recursion if decl_name used self.name
instead of self._cc.spelling. It's a bit of a wart, but should also be
cleaned up later.

Fixes #201
This used to fail with clang 15 and earlier.
@jnikula jnikula merged commit 6d69892 into master Nov 18, 2023
5 checks passed
@jnikula jnikula deleted the anon-ref branch November 18, 2023 17:50
@jnikula
Copy link
Owner Author

jnikula commented Nov 18, 2023

Looks good. Small typo in the 1st commit message though: "[...],but should also cleaned up later."

Thanks, fixed & merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants