Modifies clang_Cursor_getNumTemplateArguments() and friends to work on Struct, Class and ClassTemplatePartialSpecialization decls as well as functions
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hello again, this generalizes the template argument functionality to operate on cursor kinds other than functions.
I could use some help creating a test for this. On my previous patch I was able to just copy/paste and modify an existing test, but from a quick scan of the current tests I can't see how I'd modify one of them to test this functionality.
Mostly nits from me (FWIW, we use auto when the type is explicitly spelled out in the initialization and we don't usually use else after an unconditional return as a matter of coding style.) In terms of the test coverage, I would probably make a new test modeled after https://github.com/llvm/llvm-project/blob/main/clang/test/Index/cxx14-lambdas.cpp.
clang/include/clang-c/Index.h | ||
---|---|---|
3594–3596 | Since we're in the area already... | |
clang/tools/libclang/CXCursor.cpp | ||
1357 | CXCursor_StructDecl is interesting -- does that only get used in C or will it also show up in C++? If it's C-only, we can drop that bit. | |
1372–1373 | ||
1379–1388 | ||
1404 | Same question here about struct decl as above. | |
1410–1417 | ||
1439–1455 |
I ended up modifying c-index-test to print out the template arguments in the same way it does for FunctionDecl, which ends up working all cases in the existing test suite. The only other thing I added was a specific case in index-templates.cpp to check whether it catches StructDecl too (it does).
clang/tools/libclang/CXCursor.cpp | ||
---|---|---|
1357 | It does. I added a case to index-templates.cpp that tests for this. |
LGTM! I can fix up the minor nit with the release note formatting when I land on your behalf.
clang/docs/ReleaseNotes.rst | ||
---|---|---|
429–430 |