Index: clang-tools-extra/clang-tidy/CMakeLists.txt =================================================================== --- clang-tools-extra/clang-tidy/CMakeLists.txt +++ clang-tools-extra/clang-tidy/CMakeLists.txt @@ -37,6 +37,8 @@ ) endif() +# Checks. +# If you add a check, also add it to ClangTidyForceLinker.h in this directory. add_subdirectory(android) add_subdirectory(abseil) add_subdirectory(boost) @@ -57,9 +59,38 @@ add_subdirectory(objc) add_subdirectory(openmp) add_subdirectory(performance) -add_subdirectory(plugin) add_subdirectory(portability) add_subdirectory(readability) +add_subdirectory(zircon) +set(ALL_CLANG_TIDY_CHECKS + clangTidyAndroidModule + clangTidyAbseilModule + clangTidyBoostModule + clangTidyBugproneModule + clangTidyCERTModule + clangTidyCppCoreGuidelinesModule + clangTidyDarwinModule + clangTidyFuchsiaModule + clangTidyGoogleModule + clangTidyHICPPModule + clangTidyLinuxKernelModule + clangTidyLLVMModule + clangTidyMiscModule + clangTidyModernizeModule + clangTidyObjCModule + clangTidyOpenMPModule + clangTidyPerformanceModule + clangTidyPortabilityModule + clangTidyReadabilityModule + clangTidyZirconModule + ) +if(CLANG_ENABLE_STATIC_ANALYZER) + list(APPEND ALL_CLANG_TIDY_CHECKS clangTidyMPIModule) +endif() +set(ALL_CLANG_TIDY_CHECKS ${ALL_CLANG_TIDY_CHECKS} PARENT_SCOPE) + +# Other subtargets. These may reference ALL_CLANG_TIDY_CHECKS +# and must be below its definition. +add_subdirectory(plugin) add_subdirectory(tool) add_subdirectory(utils) -add_subdirectory(zircon) Index: clang-tools-extra/clang-tidy/ClangTidyForceLinker.h =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyForceLinker.h +++ clang-tools-extra/clang-tidy/ClangTidyForceLinker.h @@ -80,7 +80,8 @@ static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination = ModernizeModuleAnchorSource; -#if CLANG_ENABLE_STATIC_ANALYZER +#if CLANG_ENABLE_STATIC_ANALYZER && \ + !defined(CLANG_TIDY_DISABLE_STATIC_ANALYZER_CHECKS) // This anchor is used to force the linker to link the MPIModule. extern volatile int MPIModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination = Index: clang-tools-extra/clang-tidy/plugin/CMakeLists.txt =================================================================== --- clang-tools-extra/clang-tidy/plugin/CMakeLists.txt +++ clang-tools-extra/clang-tidy/plugin/CMakeLists.txt @@ -8,31 +8,6 @@ clangFrontend clangSema clangTidy - clangTidyAbseilModule - clangTidyAndroidModule - clangTidyBoostModule - clangTidyBugproneModule - clangTidyCERTModule - clangTidyCppCoreGuidelinesModule - clangTidyDarwinModule - clangTidyFuchsiaModule - clangTidyGoogleModule - clangTidyHICPPModule - clangTidyLinuxKernelModule - clangTidyLLVMModule - clangTidyMiscModule - clangTidyModernizeModule - clangTidyObjCModule - clangTidyOpenMPModule - clangTidyPerformanceModule - clangTidyPortabilityModule - clangTidyReadabilityModule - clangTidyZirconModule clangTooling + ${ALL_CLANG_TIDY_CHECKS} ) - -if(CLANG_ENABLE_STATIC_ANALYZER) - target_link_libraries(clangTidyPlugin PRIVATE - clangTidyMPIModule - ) -endif() Index: clang-tools-extra/clang-tidy/tool/CMakeLists.txt =================================================================== --- clang-tools-extra/clang-tidy/tool/CMakeLists.txt +++ clang-tools-extra/clang-tidy/tool/CMakeLists.txt @@ -17,35 +17,11 @@ clangASTMatchers clangBasic clangTidy - clangTidyAndroidModule - clangTidyAbseilModule - clangTidyBoostModule - clangTidyBugproneModule - clangTidyCERTModule - clangTidyCppCoreGuidelinesModule - clangTidyDarwinModule - clangTidyFuchsiaModule - clangTidyGoogleModule - clangTidyHICPPModule - clangTidyLinuxKernelModule - clangTidyLLVMModule - clangTidyMiscModule - clangTidyModernizeModule - clangTidyObjCModule - clangTidyOpenMPModule - clangTidyPerformanceModule - clangTidyPortabilityModule - clangTidyReadabilityModule - clangTidyZirconModule clangTooling clangToolingCore + ${ALL_CLANG_TIDY_CHECKS} ) -if(CLANG_ENABLE_STATIC_ANALYZER) - target_link_libraries(clang-tidy PRIVATE - clangTidyMPIModule - ) -endif() install(PROGRAMS clang-tidy-diff.py DESTINATION share/clang Index: clang-tools-extra/clangd/CMakeLists.txt =================================================================== --- clang-tools-extra/clangd/CMakeLists.txt +++ clang-tools-extra/clangd/CMakeLists.txt @@ -117,26 +117,6 @@ clangSema clangSerialization clangTidy - clangTidyAndroidModule - clangTidyAbseilModule - clangTidyBoostModule - clangTidyBugproneModule - clangTidyCERTModule - clangTidyCppCoreGuidelinesModule - clangTidyDarwinModule - clangTidyFuchsiaModule - clangTidyGoogleModule - clangTidyHICPPModule - clangTidyLinuxKernelModule - clangTidyLLVMModule - clangTidyMiscModule - clangTidyModernizeModule - clangTidyObjCModule - clangTidyOpenMPModule - clangTidyPerformanceModule - clangTidyPortabilityModule - clangTidyReadabilityModule - clangTidyZirconModule clangTooling clangToolingCore clangToolingInclusions @@ -144,6 +124,7 @@ clangToolingSyntax ${LLVM_PTHREAD_LIB} ${CLANGD_ATOMIC_LIB} + ${ALL_CLANG_TIDY_CHECKS} ) add_subdirectory(refactor/tweaks) Index: clang-tools-extra/clangd/ParsedAST.cpp =================================================================== --- clang-tools-extra/clangd/ParsedAST.cpp +++ clang-tools-extra/clangd/ParsedAST.cpp @@ -49,6 +49,11 @@ #include #include +// Force the linker to link in Clang-tidy modules. +// clangd doesn't support the static analyzer. +#define CLANG_TIDY_DISABLE_STATIC_ANALYZER_CHECKS +#include "../clang-tidy/ClangTidyForceLinker.h" + namespace clang { namespace clangd { namespace { @@ -521,32 +526,4 @@ } } // namespace clangd -namespace tidy { -// Force the linker to link in Clang-tidy modules. -#define LINK_TIDY_MODULE(X) \ - extern volatile int X##ModuleAnchorSource; \ - static int LLVM_ATTRIBUTE_UNUSED X##ModuleAnchorDestination = \ - X##ModuleAnchorSource -LINK_TIDY_MODULE(Abseil); -LINK_TIDY_MODULE(Android); -LINK_TIDY_MODULE(Boost); -LINK_TIDY_MODULE(Bugprone); -LINK_TIDY_MODULE(CERT); -LINK_TIDY_MODULE(CppCoreGuidelines); -LINK_TIDY_MODULE(Fuchsia); -LINK_TIDY_MODULE(Google); -LINK_TIDY_MODULE(HICPP); -LINK_TIDY_MODULE(LinuxKernel); -LINK_TIDY_MODULE(LLVM); -LINK_TIDY_MODULE(Misc); -LINK_TIDY_MODULE(Modernize); -// LINK_TIDY_MODULE(MPI); // clangd doesn't support static analyzer. -LINK_TIDY_MODULE(ObjC); -LINK_TIDY_MODULE(OpenMP); -LINK_TIDY_MODULE(Performance); -LINK_TIDY_MODULE(Portability); -LINK_TIDY_MODULE(Readability); -LINK_TIDY_MODULE(Zircon); -#undef LINK_TIDY_MODULE -} // namespace tidy } // namespace clang