[clangd] More precisely enable clang warnings through ClangTidy options
authorSam McCall <sam.mccall@gmail.com>
Fri, 29 Apr 2022 15:47:20 +0000 (17:47 +0200)
committerSam McCall <sam.mccall@gmail.com>
Fri, 29 Apr 2022 20:24:34 +0000 (22:24 +0200)
commit5227be8b6aa0edb2edb0b76e1039a7dd5641c80a
treed9ba58aba7749bc8cfc2771eacc6146ef3efe291
parentc428a3d2a09e2d144911290920b1fa59953d7898
[clangd] More precisely enable clang warnings through ClangTidy options

clang-tidy's behavior is to add the -W flags, and then map all clang diagnostics
to "clang-diagnostic-foo" pseudo-check-names, then use Checks to filter those.

Previous to this patch, we were handling -W flags but not filtering the
diagnostics, assuming both sets of information encoded the same thing.

However this intersection is nontrivial when diagnostic group hierarchy is
involved. e.g. -Wunused + clang-diagnostic-unused-function should not enable
unused label warnings.

This patch more closely emulates clang-tidy's behavior, while not going to
the extreme of generating tidy check names for all clang diagnostics and
filtering them with regexes.

Differential Revision: https://reviews.llvm.org/D124679
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang/include/clang/Basic/DiagnosticIDs.h
clang/lib/Basic/DiagnosticIDs.cpp