xref: /llvm-project/clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp (revision 600a6133ad65fa5f0ef9d5aad4b353e2bc32cedc)
1 //===--- AndroidTidyModule.cpp - clang-tidy--------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "../ClangTidy.h"
11 #include "../ClangTidyModule.h"
12 #include "../ClangTidyModuleRegistry.h"
13 #include "CloexecCreatCheck.h"
14 #include "CloexecFopenCheck.h"
15 #include "CloexecOpenCheck.h"
16 
17 using namespace clang::ast_matchers;
18 
19 namespace clang {
20 namespace tidy {
21 namespace android {
22 
23 /// This module is for Android specific checks.
24 class AndroidModule : public ClangTidyModule {
25 public:
26   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
27     CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat");
28     CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen");
29     CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open");
30   }
31 };
32 
33 // Register the AndroidTidyModule using this statically initialized variable.
34 static ClangTidyModuleRegistry::Add<AndroidModule>
35     X("android-module", "Adds Android platform checks.");
36 
37 } // namespace android
38 
39 // This anchor is used to force the linker to link in the generated object file
40 // and thus register the AndroidModule.
41 volatile int AndroidModuleAnchorSource = 0;
42 
43 } // namespace tidy
44 } // namespace clang
45