[clang-tools-extra] r373082 - clang-tidy: Don't repeat list of all checks in three places.
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 27 05:56:14 PDT 2019
Author: nico
Date: Fri Sep 27 05:56:14 2019
New Revision: 373082
URL: http://llvm.org/viewvc/llvm-project?rev=373082&view=rev
Log:
clang-tidy: Don't repeat list of all checks in three places.
Instead, put all checks in a cmake variable and reference this.
Also, make clangd use the the ClangTidyForceLinker.h header instead
of duplicating the list of modules -- the duplicate copy was missing
the new "darwin" checker added in r373065.
Differential Revision: https://reviews.llvm.org/D68132
Modified:
clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/ParsedAST.cpp
Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=373082&r1=373081&r2=373082&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Fri Sep 27 05:56:14 2019
@@ -37,6 +37,8 @@ if(CLANG_ENABLE_STATIC_ANALYZER)
)
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 @@ endif()
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)
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h?rev=373082&r1=373081&r2=373082&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h Fri Sep 27 05:56:14 2019
@@ -80,7 +80,8 @@ extern volatile int ModernizeModuleAncho
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 =
Modified: clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt?rev=373082&r1=373081&r2=373082&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt Fri Sep 27 05:56:14 2019
@@ -8,31 +8,6 @@ add_clang_library(clangTidyPlugin
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()
Modified: clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt?rev=373082&r1=373081&r2=373082&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt Fri Sep 27 05:56:14 2019
@@ -17,35 +17,11 @@ target_link_libraries(clang-tidy
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
Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=373082&r1=373081&r2=373082&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri Sep 27 05:56:14 2019
@@ -117,26 +117,6 @@ add_clang_library(clangDaemon
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 @@ add_clang_library(clangDaemon
clangToolingSyntax
${LLVM_PTHREAD_LIB}
${CLANGD_ATOMIC_LIB}
+ ${ALL_CLANG_TIDY_CHECKS}
)
add_subdirectory(refactor/tweaks)
Modified: clang-tools-extra/trunk/clangd/ParsedAST.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ParsedAST.cpp?rev=373082&r1=373081&r2=373082&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ParsedAST.cpp (original)
+++ clang-tools-extra/trunk/clangd/ParsedAST.cpp Fri Sep 27 05:56:14 2019
@@ -49,6 +49,11 @@
#include <algorithm>
#include <memory>
+// 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 @@ buildAST(PathRef FileName, std::unique_p
}
} // 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
More information about the cfe-commits
mailing list