forked from OSchip/llvm-project
				
			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 llvm-svn: 373082
This commit is contained in:
		
							parent
							
								
									18f805a7ea
								
							
						
					
					
						commit
						d69fa737ff
					
				| 
						 | 
					@ -37,6 +37,8 @@ if(CLANG_ENABLE_STATIC_ANALYZER)
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Checks.
 | 
				
			||||||
 | 
					# If you add a check, also add it to ClangTidyForceLinker.h in this directory.
 | 
				
			||||||
add_subdirectory(android)
 | 
					add_subdirectory(android)
 | 
				
			||||||
add_subdirectory(abseil)
 | 
					add_subdirectory(abseil)
 | 
				
			||||||
add_subdirectory(boost)
 | 
					add_subdirectory(boost)
 | 
				
			||||||
| 
						 | 
					@ -57,9 +59,38 @@ endif()
 | 
				
			||||||
add_subdirectory(objc)
 | 
					add_subdirectory(objc)
 | 
				
			||||||
add_subdirectory(openmp)
 | 
					add_subdirectory(openmp)
 | 
				
			||||||
add_subdirectory(performance)
 | 
					add_subdirectory(performance)
 | 
				
			||||||
add_subdirectory(plugin)
 | 
					 | 
				
			||||||
add_subdirectory(portability)
 | 
					add_subdirectory(portability)
 | 
				
			||||||
add_subdirectory(readability)
 | 
					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(tool)
 | 
				
			||||||
add_subdirectory(utils)
 | 
					add_subdirectory(utils)
 | 
				
			||||||
add_subdirectory(zircon)
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,7 +80,8 @@ extern volatile int ModernizeModuleAnchorSource;
 | 
				
			||||||
static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
 | 
					static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
 | 
				
			||||||
    ModernizeModuleAnchorSource;
 | 
					    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.
 | 
					// This anchor is used to force the linker to link the MPIModule.
 | 
				
			||||||
extern volatile int MPIModuleAnchorSource;
 | 
					extern volatile int MPIModuleAnchorSource;
 | 
				
			||||||
static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
 | 
					static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,31 +8,6 @@ add_clang_library(clangTidyPlugin
 | 
				
			||||||
  clangFrontend
 | 
					  clangFrontend
 | 
				
			||||||
  clangSema
 | 
					  clangSema
 | 
				
			||||||
  clangTidy
 | 
					  clangTidy
 | 
				
			||||||
  clangTidyAbseilModule
 | 
					 | 
				
			||||||
  clangTidyAndroidModule
 | 
					 | 
				
			||||||
  clangTidyBoostModule
 | 
					 | 
				
			||||||
  clangTidyBugproneModule
 | 
					 | 
				
			||||||
  clangTidyCERTModule
 | 
					 | 
				
			||||||
  clangTidyCppCoreGuidelinesModule
 | 
					 | 
				
			||||||
  clangTidyDarwinModule
 | 
					 | 
				
			||||||
  clangTidyFuchsiaModule
 | 
					 | 
				
			||||||
  clangTidyGoogleModule
 | 
					 | 
				
			||||||
  clangTidyHICPPModule
 | 
					 | 
				
			||||||
  clangTidyLinuxKernelModule
 | 
					 | 
				
			||||||
  clangTidyLLVMModule
 | 
					 | 
				
			||||||
  clangTidyMiscModule
 | 
					 | 
				
			||||||
  clangTidyModernizeModule
 | 
					 | 
				
			||||||
  clangTidyObjCModule
 | 
					 | 
				
			||||||
  clangTidyOpenMPModule
 | 
					 | 
				
			||||||
  clangTidyPerformanceModule
 | 
					 | 
				
			||||||
  clangTidyPortabilityModule
 | 
					 | 
				
			||||||
  clangTidyReadabilityModule
 | 
					 | 
				
			||||||
  clangTidyZirconModule
 | 
					 | 
				
			||||||
  clangTooling
 | 
					  clangTooling
 | 
				
			||||||
 | 
					  ${ALL_CLANG_TIDY_CHECKS}
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
 | 
					 | 
				
			||||||
if(CLANG_ENABLE_STATIC_ANALYZER)
 | 
					 | 
				
			||||||
  target_link_libraries(clangTidyPlugin PRIVATE
 | 
					 | 
				
			||||||
    clangTidyMPIModule
 | 
					 | 
				
			||||||
  )
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,35 +17,11 @@ target_link_libraries(clang-tidy
 | 
				
			||||||
  clangASTMatchers
 | 
					  clangASTMatchers
 | 
				
			||||||
  clangBasic
 | 
					  clangBasic
 | 
				
			||||||
  clangTidy
 | 
					  clangTidy
 | 
				
			||||||
  clangTidyAndroidModule
 | 
					 | 
				
			||||||
  clangTidyAbseilModule
 | 
					 | 
				
			||||||
  clangTidyBoostModule
 | 
					 | 
				
			||||||
  clangTidyBugproneModule
 | 
					 | 
				
			||||||
  clangTidyCERTModule
 | 
					 | 
				
			||||||
  clangTidyCppCoreGuidelinesModule
 | 
					 | 
				
			||||||
  clangTidyDarwinModule
 | 
					 | 
				
			||||||
  clangTidyFuchsiaModule
 | 
					 | 
				
			||||||
  clangTidyGoogleModule
 | 
					 | 
				
			||||||
  clangTidyHICPPModule
 | 
					 | 
				
			||||||
  clangTidyLinuxKernelModule
 | 
					 | 
				
			||||||
  clangTidyLLVMModule
 | 
					 | 
				
			||||||
  clangTidyMiscModule
 | 
					 | 
				
			||||||
  clangTidyModernizeModule
 | 
					 | 
				
			||||||
  clangTidyObjCModule
 | 
					 | 
				
			||||||
  clangTidyOpenMPModule
 | 
					 | 
				
			||||||
  clangTidyPerformanceModule
 | 
					 | 
				
			||||||
  clangTidyPortabilityModule
 | 
					 | 
				
			||||||
  clangTidyReadabilityModule
 | 
					 | 
				
			||||||
  clangTidyZirconModule
 | 
					 | 
				
			||||||
  clangTooling
 | 
					  clangTooling
 | 
				
			||||||
  clangToolingCore
 | 
					  clangToolingCore
 | 
				
			||||||
 | 
					  ${ALL_CLANG_TIDY_CHECKS}
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(CLANG_ENABLE_STATIC_ANALYZER)
 | 
					 | 
				
			||||||
  target_link_libraries(clang-tidy PRIVATE
 | 
					 | 
				
			||||||
    clangTidyMPIModule
 | 
					 | 
				
			||||||
  )
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
install(PROGRAMS clang-tidy-diff.py
 | 
					install(PROGRAMS clang-tidy-diff.py
 | 
				
			||||||
  DESTINATION share/clang
 | 
					  DESTINATION share/clang
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -117,26 +117,6 @@ add_clang_library(clangDaemon
 | 
				
			||||||
  clangSema
 | 
					  clangSema
 | 
				
			||||||
  clangSerialization
 | 
					  clangSerialization
 | 
				
			||||||
  clangTidy
 | 
					  clangTidy
 | 
				
			||||||
  clangTidyAndroidModule
 | 
					 | 
				
			||||||
  clangTidyAbseilModule
 | 
					 | 
				
			||||||
  clangTidyBoostModule
 | 
					 | 
				
			||||||
  clangTidyBugproneModule
 | 
					 | 
				
			||||||
  clangTidyCERTModule
 | 
					 | 
				
			||||||
  clangTidyCppCoreGuidelinesModule
 | 
					 | 
				
			||||||
  clangTidyDarwinModule
 | 
					 | 
				
			||||||
  clangTidyFuchsiaModule
 | 
					 | 
				
			||||||
  clangTidyGoogleModule
 | 
					 | 
				
			||||||
  clangTidyHICPPModule
 | 
					 | 
				
			||||||
  clangTidyLinuxKernelModule
 | 
					 | 
				
			||||||
  clangTidyLLVMModule
 | 
					 | 
				
			||||||
  clangTidyMiscModule
 | 
					 | 
				
			||||||
  clangTidyModernizeModule
 | 
					 | 
				
			||||||
  clangTidyObjCModule
 | 
					 | 
				
			||||||
  clangTidyOpenMPModule
 | 
					 | 
				
			||||||
  clangTidyPerformanceModule
 | 
					 | 
				
			||||||
  clangTidyPortabilityModule
 | 
					 | 
				
			||||||
  clangTidyReadabilityModule
 | 
					 | 
				
			||||||
  clangTidyZirconModule
 | 
					 | 
				
			||||||
  clangTooling
 | 
					  clangTooling
 | 
				
			||||||
  clangToolingCore
 | 
					  clangToolingCore
 | 
				
			||||||
  clangToolingInclusions
 | 
					  clangToolingInclusions
 | 
				
			||||||
| 
						 | 
					@ -144,6 +124,7 @@ add_clang_library(clangDaemon
 | 
				
			||||||
  clangToolingSyntax
 | 
					  clangToolingSyntax
 | 
				
			||||||
  ${LLVM_PTHREAD_LIB}
 | 
					  ${LLVM_PTHREAD_LIB}
 | 
				
			||||||
  ${CLANGD_ATOMIC_LIB}
 | 
					  ${CLANGD_ATOMIC_LIB}
 | 
				
			||||||
 | 
					  ${ALL_CLANG_TIDY_CHECKS}
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_subdirectory(refactor/tweaks)
 | 
					add_subdirectory(refactor/tweaks)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,6 +49,11 @@
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
#include <memory>
 | 
					#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 clang {
 | 
				
			||||||
namespace clangd {
 | 
					namespace clangd {
 | 
				
			||||||
namespace {
 | 
					namespace {
 | 
				
			||||||
| 
						 | 
					@ -521,32 +526,4 @@ buildAST(PathRef FileName, std::unique_ptr<CompilerInvocation> Invocation,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace clangd
 | 
					} // 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
 | 
					} // namespace clang
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue