Skip to content

Commit 296eea3

Browse files
committed
fix link issue
1 parent c292960 commit 296eea3

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ LLVM_INSTANTIATE_REGISTRY(clang::tidy::ClangTidyModuleRegistry)
5353

5454
namespace clang::tidy {
5555

56+
#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
5657
namespace 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

6163
namespace {
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()) {

clang-tools-extra/clang-tidy/ClangTidy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ void exportReplacements(StringRef MainFilePath,
127127
const std::vector<ClangTidyError> &Errors,
128128
raw_ostream &OS);
129129

130+
namespace custom {
131+
extern void (*RegisterCustomChecks)(const ClangTidyOptions &O,
132+
ClangTidyCheckFactories &Factories);
133+
} // namespace custom
130134
} // end namespace tidy
131135
} // end namespace clang
132136

clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ extern void registerCustomChecks(const ClangTidyOptions &Options,
3838
}
3939
}
4040

41+
struct CustomChecksRegisterInitializer {
42+
CustomChecksRegisterInitializer() noexcept {
43+
RegisterCustomChecks = &custom::registerCustomChecks;
44+
}
45+
};
46+
47+
static CustomChecksRegisterInitializer Init{};
48+
4149
} // namespace custom
4250

4351
// Register the CustomTidyModule using this statically initialized variable.

0 commit comments

Comments
 (0)