2

I have a fairly large project with lots & large headers that are included. Running clang-tidy on a single source file takes 10+ minutes. In contrast to that clang-tidy findings in clangd show up almost immediately.

I expect clangd to be faster due to caching, multithreading, but not <1 second vs 10 minutes.

Are there e.g. any expensive rules that are disabled for clangd usage or is some accuracy sacrified for performance?

pJunger
  • 41
  • 6
  • 1
    There are a [small handful](https://searchfox.org/llvm/rev/cb7bda2ace81226c5b33165411dd0316f93fa57e/clang-tools-extra/clangd/TidyProvider.cpp#199-227) of checks which clangd disables. Is it possible that it's one of these that slows down `clang-tidy` for you? (You can check by disabling them in your `.clang-tidy` file and seeing if that speeds things up.) – HighCommander4 Jul 05 '23 at 06:28
  • 1
    I've tried disabling those checks, but it didn't change much. I've found out that -llvm-header-guard & -modernize-macro-to-enum cannot be enabled because they are 'broken' due to a performance optmization in clangd. Maybe there are other shortcuts that clangd takes (or this one has large effects) that could account for this difference. – pJunger Jul 05 '23 at 13:24
  • 1
    Ah, I think I have an idea: clangd skips parsing the bodies of functions defined in included header files (because those are not essential for the purpose of providing editor functionality in the main file). This probably results in a significant speedup, though it does mean that any clang-tidy diagnostics inside those function bodies will be missed. – HighCommander4 Jul 05 '23 at 16:22

0 Answers0