I am using clangd and clang-tidy with coc in neovim. I just upgraded my clang and now I'm getting warnings for my config.yaml
Diagnostics:
ClangTidy:
Add: [
# ...
]
Remove: [
# ...
cert-msc24-c, # alias for bugprone-unsafe-functions
# ~~~~~~~~~~~~
# ^ Latency of clang-tidy check 'cert-msc24-c' is not known. It will only run if ClangTidy.FastCheckFilter is Loose or None (clangd-config)
# ...
]
CheckOptions:
modernize-use-auto.MinTypeNameLength: 10
# ...
However I can't figure out where to put this ClangTidy.FastCheckFilter
option.
When I put it in CheckOptions, I get no feedback, the warnings don't go away:
Diagnostics:
ClangTidy:
Add: [
# ...
]
Remove: [
# ...
]
CheckOptions:
ClangTidy.FastCheckFilter: None
modernize-use-auto.MinTypeNameLength: 10
# ...
When I put it in the root, I get a warning
Unknown Config key 'ClangTidy' (clangd-config)
ClangTidy:
FastCheckFilter: None
Diagnostics:
# ...
And when I place it into Diagnostics/ClangTidy, I get an error
Property FastCheckFilter is not allowed. (yaml-schema: clangtidy options)
Diagnostics:
ClangTidy:
FastCheckFilter: None
# ...
In no case do the warnings for
Latency of clang-tidy check 'cert-msc24-c' is not known. It will only run if ClangTidy.FastCheckFilter is Loose or None (clangd-config)
and others go away.
I tried finding how to use FastCheckFilter
by searching for the term, but google shows only a single hit for a doxygen comment for a struct in clang, which also doesn't tell me how to use it.
The configuration documentation also doesn't list that option.
Edit
I looked at the source code and found this snippet
/// Controls how clang-tidy will run over the code base.
///
/// The settings are merged with any settings found in .clang-tidy
/// configuration files with these ones taking precedence.
struct ClangTidyBlock {
std::vector<Located<std::string>> Add;
/// List of checks to disable.
/// Takes precedence over Add. To enable all llvm checks except include
/// order:
/// Add: llvm-*
/// Remove: llvm-include-order
std::vector<Located<std::string>> Remove;
/// A Key-Value pair list of options to pass to clang-tidy checks
/// These take precedence over options specified in clang-tidy
/// configuration files. Example:
/// CheckOptions:
/// readability-braces-around-statements.ShortStatementLines: 2
std::vector<std::pair<Located<std::string>, Located<std::string>>>
CheckOptions;
/// Whether to run checks that may slow down clangd.
/// Strict: Run only checks measured to be fast. (Default)
/// This excludes recently-added checks we have not timed yet.
/// Loose: Run checks unless they are known to be slow.
/// None: Run checks regardless of their speed.
std::optional<Located<std::string>> FastCheckFilter;
};
It seems that the placement in
Diagnostics:
ClangTidy:
FastCheckFilter: None
# ...
is the correct one. I guess my coc-yaml
plugin doesn't know about the new fields. I also added the new InlayHints.BlockEnd
field, which it doesn't like. But that one actually works.
But I still get the warnings from the clangd-config
linter for the unknown speed.
The warning "Latency of clang-tidy check ... is not known." was added to the repo on 2023-10-20 as part of work on Issue 1337. As of 2023-11-07, the most recent released version is Clang+LLVM-17.0.4, which does not have this change in it. Thus, I think you must be using an unreleased version.
Based on how the change was made in
clangd/ConfigFragment.h
, theFastCheckFilter
key is supposed to be a child ofClangTidy
, itself a child ofDiagnostics
. However, the associated YAML schema has evidently not been updated (in another project; see HighCommander4's answer), so the key is rejected when in its proper place. At this moment, there is only one test of this feature (unittests/ReplayPreambleTests.cpp
), and it bypasses YAML parsing. So, as far as I can tell, the warning cannot be suppressed in the bleeding-edge version.I don't see any already-filed issues on this topic, so you could file one.