Page MenuHomePhabricator

[clang][Index] Introduce a TemplateParm SymbolKind

Authored by kadircet on Jan 30 2020, 5:15 AM.



Currently template parameters has symbolkind Unknown. This patch
introduces a new kind TemplateParm for templatetemplate, templatetype and
nontypetemplate parameters.

Also adds tests in clangd hover feature.

Diff Detail

Unit TestsFailed

790 mslibc++.std/containers/sequences/array/
Command: ['/usr/bin/clang++', '-o', '/dev/null', '-x', 'c++', '/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/std/containers/sequences/array/array.creation/', '-c', '-v', '-ftemplate-depth=270', '-fsyntax-only', '-Xclang', '-verify', '-Xclang', '-verify-ignore-unexpected=note', '-ferror-limit=1024', '-Werror=thread-safety', '-std=c++2a', '-include', '/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/support/nasty_macros.h', '-nostdinc++', '-I/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/include', '-I/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/projects/libcxx/include/c++build', '-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-I/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/support', '-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/std/input.output/filesystems/Inputs/static_test_env"', '-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/projects/libcxx/test/filesystem/Output/dynamic_env"', '-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="/usr/bin/python /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/libcxx/test/support/"', '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', '-Wall', '-Wextra', '-Werror', '-Wuser-defined-warnings', '-Wshadow', '-Wno-unused-command-line-argument', '-Wno-attributes', '-Wno-pessimizing-move', '-Wno-c++11-extensions', '-Wno-user-defined-literals', '-Wno-noexcept-type', '-Wsign-compare', '-Wunused-variable', '-Wunused-parameter', '-Wunreachable-code', '-Wno-error=user-defined-warnings', '-c'] Exit Code: 1 Standard Error:

Event Timeline

kadircet created this revision.Jan 30 2020, 5:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2020, 5:15 AM

Unit tests: fail. 62337 tests passed, 1 failed and 838 were skipped.

failed: libc++.std/containers/sequences/array/array_creation/

clang-tidy: pass.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

Libclang changes need tests I think.


this seems kind of dubious, maybe worth a comment?
(If we had the decl here we'd distinguish between type and non-type, right?)


I do think we're going to want to have HI.Type = "typename" here, maybe with some special-case in the rendering.

(Especially with concepts where the TTP can be constrained as Integral or something)

Fine to leave for now but FIXME somewhere?


As far as hover goes, calling this "template parameter" and making int/class the "type" is cute and fits well.

But I worry we're not exposing enough info here and at the libclang level (and I guess Index) we should be distinguishing the 3 cases. WDYT?

kadircet updated this revision to Diff 243091.Feb 6 2020, 11:59 PM
kadircet marked 2 inline comments as done.
  • As discussed offline, do not expose new symbol kinds to libclang
  • Set types for templateparms in HoverInfo.
kadircet marked an inline comment as done.Feb 7 2020, 12:05 AM
kadircet added inline comments.

we have all 3 of them now

hokein accepted this revision.Feb 14 2020, 12:39 AM
hokein added inline comments.

I think these two should belong to CompletionItemKind::TypeParameter?


nit: could we move these newly-added lines above the case Decl::ClassTemplatePartialSpecialization:. I think we usually put the llvm_unreachable cases at the end of switch statement..

This revision is now accepted and ready to land.Feb 14 2020, 12:39 AM
kadircet marked 3 inline comments as done.Feb 14 2020, 4:20 AM
kadircet added inline comments.

right, moved the ones below but forgot to move these :D thanks!


yes but this one is specially, there's also a default label below.

Also the unreachable ones are for making sure certain valid types don't arrive in here rather than checking for invalid types are passed.
We usually put the unreachable to the end if it is protecting against invalid usages, I believe.

kadircet updated this revision to Diff 244619.Feb 14 2020, 4:20 AM
kadircet marked an inline comment as done.
  • Address comments
This revision was automatically updated to reflect the committed changes.