xref: /llvm-project/clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp (revision b7b28c6cfe04b8ca59dec0f2e2b9b7493c1c71d3)
1 //===--- LLVMLibcTidyModule.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 "CalleeNamespaceCheck.h"
13 #include "ImplementationInNamespaceCheck.h"
14 #include "InlineFunctionDeclCheck.h"
15 #include "RestrictSystemLibcHeadersCheck.h"
16 
17 namespace clang::tidy {
18 namespace llvm_libc {
19 
20 class LLVMLibcModule : public ClangTidyModule {
21 public:
addCheckFactories(ClangTidyCheckFactories & CheckFactories)22   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
23     CheckFactories.registerCheck<CalleeNamespaceCheck>(
24         "llvmlibc-callee-namespace");
25     CheckFactories.registerCheck<ImplementationInNamespaceCheck>(
26         "llvmlibc-implementation-in-namespace");
27     CheckFactories.registerCheck<InlineFunctionDeclCheck>(
28         "llvmlibc-inline-function-decl");
29     CheckFactories.registerCheck<RestrictSystemLibcHeadersCheck>(
30         "llvmlibc-restrict-system-libc-headers");
31   }
32 };
33 
34 // Register the LLVMLibcTidyModule using this statically initialized variable.
35 static ClangTidyModuleRegistry::Add<LLVMLibcModule>
36     X("llvmlibc-module", "Adds LLVM libc standards checks.");
37 
38 } // namespace llvm_libc
39 
40 // This anchor is used to force the linker to link in the generated object file
41 // and thus register the LLVMLibcModule.
42 volatile int LLVMLibcModuleAnchorSource = 0;
43 
44 } // namespace clang::tidy
45