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