xref: /llvm-project/clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp (revision 7651e66cdfd24425f0fcaadf3cc892a47e6cb37e)
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 "CloexecDupCheck.h"
15 #include "CloexecFopenCheck.h"
16 #include "CloexecInotifyInit1Check.h"
17 #include "CloexecInotifyInitCheck.h"
18 #include "CloexecMemfdCreateCheck.h"
19 #include "CloexecOpenCheck.h"
20 #include "CloexecSocketCheck.h"
21 
22 using namespace clang::ast_matchers;
23 
24 namespace clang {
25 namespace tidy {
26 namespace android {
27 
28 /// This module is for Android specific checks.
29 class AndroidModule : public ClangTidyModule {
30 public:
31   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
32     CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat");
33     CheckFactories.registerCheck<CloexecDupCheck>("android-cloexec-dup");
34     CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen");
35     CheckFactories.registerCheck<CloexecInotifyInitCheck>(
36         "android-cloexec-inotify-init");
37     CheckFactories.registerCheck<CloexecInotifyInit1Check>(
38         "android-cloexec-inotify-init1");
39     CheckFactories.registerCheck<CloexecMemfdCreateCheck>(
40         "android-cloexec-memfd-create");
41     CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open");
42     CheckFactories.registerCheck<CloexecSocketCheck>("android-cloexec-socket");
43   }
44 };
45 
46 // Register the AndroidTidyModule using this statically initialized variable.
47 static ClangTidyModuleRegistry::Add<AndroidModule>
48     X("android-module", "Adds Android platform checks.");
49 
50 } // namespace android
51 
52 // This anchor is used to force the linker to link in the generated object file
53 // and thus register the AndroidModule.
54 volatile int AndroidModuleAnchorSource = 0;
55 
56 } // namespace tidy
57 } // namespace clang
58