@@ -53,10 +53,12 @@ LLVM_INSTANTIATE_REGISTRY(clang::tidy::ClangTidyModuleRegistry)
53
53
54
54
namespace clang::tidy {
55
55
56
+ #if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
56
57
namespace custom {
57
- extern void registerCustomChecks (const ClangTidyOptions &O,
58
- ClangTidyCheckFactories &Factories);
58
+ void (*RegisterCustomChecks) (const ClangTidyOptions &O,
59
+ ClangTidyCheckFactories &Factories) = nullptr ;
59
60
} // namespace custom
61
+ #endif
60
62
61
63
namespace {
62
64
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
@@ -348,8 +350,8 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
348
350
: Context(Context), OverlayFS(std::move(OverlayFS)),
349
351
CheckFactories(new ClangTidyCheckFactories) {
350
352
#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);
353
355
#endif
354
356
for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries ()) {
355
357
std::unique_ptr<ClangTidyModule> Module = E.instantiate ();
@@ -421,8 +423,8 @@ ClangTidyASTConsumerFactory::createASTConsumer(
421
423
if (WorkingDir)
422
424
Context.setCurrentBuildDirectory (WorkingDir.get ());
423
425
#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);
426
428
#endif
427
429
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
428
430
CheckFactories->createChecksForLanguage (&Context);
@@ -688,8 +690,8 @@ ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
688
690
AllowEnablingAnalyzerAlphaCheckers, false , ExperimentalCustomChecks);
689
691
ClangTidyCheckFactories Factories;
690
692
#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);
693
695
#endif
694
696
for (const ClangTidyModuleRegistry::entry &Module :
695
697
ClangTidyModuleRegistry::entries ()) {
0 commit comments