LinuxKernelTidyModule.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //===--- LinuxKernelTidyModule.cpp - clang-tidy----------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "../ClangTidy.h"
  9. #include "../ClangTidyModule.h"
  10. #include "../ClangTidyModuleRegistry.h"
  11. #include "MustCheckErrsCheck.h"
  12. namespace clang::tidy {
  13. namespace linuxkernel {
  14. /// This module is for checks specific to the Linux kernel.
  15. class LinuxKernelModule : public ClangTidyModule {
  16. public:
  17. void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
  18. CheckFactories.registerCheck<MustCheckErrsCheck>(
  19. "linuxkernel-must-check-errs");
  20. }
  21. };
  22. // Register the LinuxKernelTidyModule using this statically initialized
  23. // variable.
  24. static ClangTidyModuleRegistry::Add<LinuxKernelModule>
  25. X("linux-module", "Adds checks specific to the Linux kernel.");
  26. } // namespace linuxkernel
  27. // This anchor is used to force the linker to link in the generated object file
  28. // and thus register the LinuxKernelModule.
  29. volatile int LinuxKernelModuleAnchorSource = 0;
  30. } // namespace clang::tidy