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

Any info on C++ class methods seems to be absent in a clangd index, while C functions are indexed properly #1234

Closed
Arech opened this issue Jul 30, 2022 Discussed in #1229 · 1 comment

Comments

@Arech
Copy link

Arech commented Jul 30, 2022

Hello dear maintainers of clangd.
This might be very well known to you, though I wasn't able to find mentions of it in docs and discussions/issues, - it seems that clangd-indexer create a database (binary/dex as well as yaml) where C-functions are properly described (signature, return types, possibly template arguments, etc), while C++ methods have only a name. Is it a bug or a feature? If it's the former, any change of fixing it soon?
Thanks!

Discussed in #1229

Originally posted by Arech July 27, 2022
Hi!
Thank you for this fantastically interesting project!
I'm trying to find if it's possible to use clangd as kind of a database about a code in my sample C++ project. I've stumbled upon an issue I brought to the title - it looks like my clangd doesn't have any information about C++ methods (besides their name) in the database, while it has all the info (arguments, return type) for C-style (global?) functions. Is it expected for clangd toolset v14.0.3 (the latest compiled with tools I've found), or I'm doing something wrong?

My approach is:

  1. generate compile_commands.json with
cmake -B %BUILD_DIR% -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1
  1. index with clangd-indexer.exe with
%LLVM_HOME%\clangd-indexer.exe --executor=all-TUs --enable-fs-discriminator --execute-concurrency=0
 --generate-merged-base-profiles --import-constants-with-refs --import-full-type-definitions
 --print-summary-global-ids --propagate-attrs --static-func-full-module-prefix
%BUILD_DIR%/compile_commands.json > %BUILD_DIR%/%INDEX_FILE%

(well, it seems that most of options doesn't affect the issue, since the output is the same if only --executor=all-TUs is specified - and without it I get a weird error, I don't know how to fix)

  1. run clangd-index-server.exe with
%LLVM_HOME%\clangd-index-server.exe --server-address=%SERVER_ADDR% --log=verbose --trace-file=%TRACE_FILE% --pretty
 --enable-fs-discriminator --generate-merged-base-profiles --import-constants-with-refs --import-full-type-definitions
 --print-summary-global-ids --propagate-attrs --static-func-full-module-prefix
%INDEX_FILE% %PROJ_ROOT%

(well, almost the same here, only options up to --pretty seems to affect anything and the rest, though are printed with --help-hidden doesn't seem to do anything helpful to the issue, - I'm leaving it here just to show what I've already tried)

  1. Explore FuzzyFindReply of the server using https://github.com/frabert/ClangQL (symbols -based table)

And what I get it is more-or-less complete information for C-style functions, like double std::log10(double), but I get only a symbol name and scope for C++ method, like std::vector::erase. Thought, each such symbol might have multiple entries, which I presume corresponds to a different function instantiation...

Also I verify the output by looking at the clangd-index-server log output, - there's indeed info for C-functions, but nothing for C++ methods, so it's likely not an issue of ClangQL...

Does such info exist in the clangd database at all? If yes, is it possible to fetch it and how exactly?

ADDED: reindexed into --format=yaml and unfortunately,no such info exist in the index file. C functions are fully specified, while C++ methods only have a name... Is it a bug, I presume?

Thank you!

@HighCommander4
Copy link

Linking to https://discourse.llvm.org/t/c-class-methods-info-in-clang-indexer-database/70764 where this has been discussed. I'm going to close this issue, any follow-up discussion can take place on Discourse or in #1229.

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

No branches or pull requests

2 participants