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
66 lines
2.3 KiB
C++
66 lines
2.3 KiB
C++
// REQUIRES: plugins
|
|
// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext | FileCheck --check-prefix=CHECK-LIST %s
|
|
// CHECK-LIST: Enabled checks:
|
|
// CHECK-LIST-NEXT: mytest1
|
|
// CHECK-LIST-NEXT: mytest2
|
|
// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s
|
|
// CHECK: 3 warnings generated.
|
|
// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2]
|
|
|
|
#include "clang-tidy/ClangTidy.h"
|
|
#include "clang-tidy/ClangTidyCheck.h"
|
|
#include "clang-tidy/ClangTidyModule.h"
|
|
#include "clang/AST/ASTContext.h"
|
|
#include "clang/ASTMatchers/ASTMatchFinder.h"
|
|
|
|
using namespace clang;
|
|
using namespace clang::tidy;
|
|
using namespace clang::ast_matchers;
|
|
|
|
namespace {
|
|
class MyTestCheck : public ClangTidyCheck {
|
|
|
|
public:
|
|
MyTestCheck(StringRef Name, ClangTidyContext *Context)
|
|
: ClangTidyCheck(Name, Context) {}
|
|
|
|
void registerMatchers(ast_matchers::MatchFinder *Finder) override {
|
|
Finder->addMatcher(translationUnitDecl().bind("tu"), this);
|
|
}
|
|
|
|
void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
|
|
auto S = Result.Nodes.getNodeAs<TranslationUnitDecl>("tu");
|
|
if (S)
|
|
diag("mytest success");
|
|
}
|
|
|
|
private:
|
|
};
|
|
|
|
class CTTestModule : public ClangTidyModule {
|
|
public:
|
|
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
|
|
CheckFactories.registerCheck<MyTestCheck>("mytest1");
|
|
CheckFactories.registerCheck<MyTestCheck>("mytest2");
|
|
// intentionally collide with an existing test name, overriding it
|
|
CheckFactories.registerCheck<MyTestCheck>("misc-definitions-in-headers");
|
|
}
|
|
};
|
|
} // namespace
|
|
|
|
namespace tidy1 {
|
|
// Register the CTTestTidyModule using this statically initialized variable.
|
|
static ClangTidyModuleRegistry::Add<::CTTestModule>
|
|
X("mytest-module", "Adds my checks.");
|
|
} // namespace tidy1
|
|
|
|
namespace tidy2 {
|
|
// intentionally collide with an existing test group name, merging with it
|
|
static ClangTidyModuleRegistry::Add<::CTTestModule>
|
|
X("misc-module", "Adds miscellaneous lint checks.");
|
|
} // namespace tidy2
|
|
|
|
// This anchor is used to force the linker to link in the generated object file
|
|
// and thus register the CTTestModule.
|
|
volatile int CTTestModuleAnchorSource = 0;
|