[libclang] Visit function template instantiations#67928
Open
[libclang] Visit function template instantiations#67928
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
a0f10a6 to
d57843b
Compare
d57843b to
6e43193
Compare
Endilll
reviewed
Mar 14, 2026
Contributor
Endilll
left a comment
There was a problem hiding this comment.
CC @AaronBallman I guess this has fallen through the cracks after you added yourself as a reviewer.
| if (VisitAttributes(FD) || VisitFunctionDecl(FD)) | ||
| return true; | ||
|
|
||
| for (auto *Child : D->specializations()) |
Contributor
There was a problem hiding this comment.
I'm not sure if adding this to the existing API is a good idea
Contributor
There was a problem hiding this comment.
Agreed, I think visiting the specializations would come as a surprise to consumers of the API. We already have VisitClassTemplateSpecializationDecl (and similar for partial specializations), so I would expect this is already being visited anyway, right?
Contributor
It sure did, sorry about that @Danacus! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes
CursorVisitor::VisitFunctionTemplateDeclsuch that instantiations of the function template (e.g.template void foo<int>();) are visited as children of theFunctionTemplateDecl. This also applies to class methods.The use case for this I have in mind would be to add limited support for function templates in
rust-bindgen(see rust-lang/rust-bindgen#2650).Additionally, I have taken the liberty to add
CXCursor_CXXMethodto the list of cursors supported bygetTemplateArgument, since I found it a bit odd that this was not the case before.Please let me know if there is anything that needs to be changed, I'm happy to make changes if necessary.