CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
63 lines
2.0 KiB
C++
63 lines
2.0 KiB
C++
#include "../ClangTidy.h"
|
|
#include "../ClangTidyModule.h"
|
|
#include "../ClangTidyOptions.h"
|
|
#include "QueryCheck.h"
|
|
#include "llvm/ADT/SmallSet.h"
|
|
#include "llvm/ADT/SmallString.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include <cassert>
|
|
#include <memory>
|
|
|
|
namespace clang::tidy {
|
|
namespace custom {
|
|
|
|
// We need to register the checks more flexibly than builtin modules. The checks
|
|
// will changed dynamically when switching to different source file.
|
|
static void registerCustomChecks(const ClangTidyOptions &Options,
|
|
ClangTidyCheckFactories &Factories) {
|
|
static llvm::SmallSet<SmallString<32>, 8> CustomCheckNames{};
|
|
if (!Options.CustomChecks.has_value() || Options.CustomChecks->empty())
|
|
return;
|
|
for (const SmallString<32> &Name : CustomCheckNames)
|
|
Factories.eraseCheck(Name);
|
|
for (const ClangTidyOptions::CustomCheckValue &V :
|
|
Options.CustomChecks.value()) {
|
|
SmallString<32> Name = StringRef{"custom-" + V.Name};
|
|
Factories.registerCheckFactory(
|
|
// add custom- prefix to avoid conflicts with builtin checks
|
|
Name, [&V](StringRef Name, ClangTidyContext *Context) {
|
|
return std::make_unique<custom::QueryCheck>(Name, V, Context);
|
|
});
|
|
CustomCheckNames.insert(std::move(Name));
|
|
}
|
|
}
|
|
|
|
namespace {
|
|
|
|
struct CustomChecksRegisterInitializer {
|
|
CustomChecksRegisterInitializer() noexcept {
|
|
RegisterCustomChecks = &custom::registerCustomChecks;
|
|
}
|
|
};
|
|
|
|
class CustomModule : public ClangTidyModule {
|
|
public:
|
|
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
static CustomChecksRegisterInitializer Init{};
|
|
|
|
} // namespace custom
|
|
|
|
// Register the CustomTidyModule using this statically initialized variable.
|
|
static ClangTidyModuleRegistry::Add<custom::CustomModule>
|
|
X("custom-module", "Adds custom query lint checks.");
|
|
|
|
// This anchor is used to force the linker to link in the generated object file
|
|
// and thus register the AlteraModule.
|
|
volatile int CustomModuleAnchorSource = 0; // NOLINT (misc-use-internal-linkage)
|
|
|
|
} // namespace clang::tidy
|