@@ -53,10 +53,12 @@ LLVM_INSTANTIATE_REGISTRY(clang::tidy::ClangTidyModuleRegistry)
5353
5454namespace clang::tidy {
5555
56+ #if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
5657namespace custom {
57- extern void registerCustomChecks (const ClangTidyOptions &O,
58- ClangTidyCheckFactories &Factories);
58+ void (*RegisterCustomChecks) (const ClangTidyOptions &O,
59+ ClangTidyCheckFactories &Factories) = nullptr ;
5960} // namespace custom
61+ #endif
6062
6163namespace {
6264#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
@@ -348,8 +350,8 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
348350 : Context(Context), OverlayFS(std::move(OverlayFS)),
349351 CheckFactories(new ClangTidyCheckFactories) {
350352#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
351- if (Context.canExperimentalCustomChecks ())
352- custom::registerCustomChecks (Context.getOptions (), *CheckFactories);
353+ if (Context.canExperimentalCustomChecks () && custom::RegisterCustomChecks )
354+ custom::RegisterCustomChecks (Context.getOptions (), *CheckFactories);
353355#endif
354356 for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries ()) {
355357 std::unique_ptr<ClangTidyModule> Module = E.instantiate ();
@@ -421,8 +423,8 @@ ClangTidyASTConsumerFactory::createASTConsumer(
421423 if (WorkingDir)
422424 Context.setCurrentBuildDirectory (WorkingDir.get ());
423425#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
424- if (Context.canExperimentalCustomChecks ())
425- custom::registerCustomChecks (Context.getOptions (), *CheckFactories);
426+ if (Context.canExperimentalCustomChecks () && custom::RegisterCustomChecks )
427+ custom::RegisterCustomChecks (Context.getOptions (), *CheckFactories);
426428#endif
427429 std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
428430 CheckFactories->createChecksForLanguage (&Context);
@@ -688,8 +690,8 @@ ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
688690 AllowEnablingAnalyzerAlphaCheckers, false , ExperimentalCustomChecks);
689691 ClangTidyCheckFactories Factories;
690692#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
691- if (ExperimentalCustomChecks)
692- custom::registerCustomChecks (Context.getOptions (), Factories);
693+ if (ExperimentalCustomChecks && custom::RegisterCustomChecks )
694+ custom::RegisterCustomChecks (Context.getOptions (), Factories);
693695#endif
694696 for (const ClangTidyModuleRegistry::entry &Module :
695697 ClangTidyModuleRegistry::entries ()) {
0 commit comments