clang-tools 10.0.0

LinuxKernelTidyModule.cpp
Go to the documentation of this file.
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
9 #include "../ClangTidy.h"
10 #include "../ClangTidyModule.h"
11 #include "../ClangTidyModuleRegistry.h"
12 #include "MustCheckErrsCheck.h"
13
14 namespace clang {
15 namespace tidy {
16 namespace linuxkernel {
17
18 /// This module is for checks specific to the Linux kernel.
19 class LinuxKernelModule : public ClangTidyModule {
20 public:
21 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
22 CheckFactories.registerCheck<MustCheckErrsCheck>(
23 "linuxkernel-must-check-errs");
24 }
25 };
26 // Register the LinuxKernelTidyModule using this statically initialized
27 // variable.
28 static ClangTidyModuleRegistry::Add<LinuxKernelModule>
29 X("linux-module", "Adds checks specific to the Linux kernel.");
30 } // namespace linuxkernel
31
32 // This anchor is used to force the linker to link in the generated object file
33 // and thus register the LinuxKernelModule.
34 volatile int LinuxKernelModuleAnchorSource = 0;
35
36 } // namespace tidy
37 } // namespace clang
clang::tidy::LinuxKernelModuleAnchorSource
volatile int LinuxKernelModuleAnchorSource
Definition: LinuxKernelTidyModule.cpp:34
clang::tidy::linuxkernel::LinuxKernelModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: LinuxKernelTidyModule.cpp:21
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:58
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
clang::tidy::linuxkernel::X
static ClangTidyModuleRegistry::Add< LinuxKernelModule > X("linux-module", "Adds checks specific to the Linux kernel.")
MustCheckErrsCheck.h
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:80
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::linuxkernel::MustCheckErrsCheck
Checks Linux kernel code to see if it uses the results from the functions in linux/err.h.
Definition: MustCheckErrsCheck.h:31
clang::tidy::linuxkernel::LinuxKernelModule
This module is for checks specific to the Linux kernel.
Definition: LinuxKernelTidyModule.cpp:19