clang-tools 6.0.0

AndroidTidyModule.cpp
Go to the documentation of this file.
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 "CloexecAccept4Check.h"
14 #include "CloexecAcceptCheck.h"
15 #include "CloexecCreatCheck.h"
16 #include "CloexecEpollCreate1Check.h"
17 #include "CloexecEpollCreateCheck.h"
18 #include "CloexecDupCheck.h"
19 #include "CloexecFopenCheck.h"
20 #include "CloexecInotifyInit1Check.h"
21 #include "CloexecInotifyInitCheck.h"
22 #include "CloexecMemfdCreateCheck.h"
23 #include "CloexecOpenCheck.h"
24 #include "CloexecSocketCheck.h"
25
26 using namespace clang::ast_matchers;
27
28 namespace clang {
29 namespace tidy {
30 namespace android {
31
32 /// This module is for Android specific checks.
33 class AndroidModule : public ClangTidyModule {
34 public:
35 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
36 CheckFactories.registerCheck<CloexecAccept4Check>("android-cloexec-accept4");
37 CheckFactories.registerCheck<CloexecAcceptCheck>("android-cloexec-accept");
38 CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat");
39 CheckFactories.registerCheck<CloexecEpollCreate1Check>(
40 "android-cloexec-epoll-create1");
41 CheckFactories.registerCheck<CloexecEpollCreateCheck>(
42 "android-cloexec-epoll-create");
43 CheckFactories.registerCheck<CloexecDupCheck>("android-cloexec-dup");
44 CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen");
45 CheckFactories.registerCheck<CloexecInotifyInitCheck>(
46 "android-cloexec-inotify-init");
47 CheckFactories.registerCheck<CloexecInotifyInit1Check>(
48 "android-cloexec-inotify-init1");
49 CheckFactories.registerCheck<CloexecMemfdCreateCheck>(
50 "android-cloexec-memfd-create");
51 CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open");
52 CheckFactories.registerCheck<CloexecSocketCheck>("android-cloexec-socket");
53 }
54 };
55
56 // Register the AndroidTidyModule using this statically initialized variable.
57 static ClangTidyModuleRegistry::Add<AndroidModule>
58 X("android-module", "Adds Android platform checks.");
59
60 } // namespace android
61
62 // This anchor is used to force the linker to link in the generated object file
63 // and thus register the AndroidModule.
64 volatile int AndroidModuleAnchorSource = 0;
65
66 } // namespace tidy
67 } // namespace clang
clang::tidy::android::CloexecCreatCheck
creat() is better to be replaced by open().
Definition: CloexecCreatCheck.h:23
clang::ast_matchers
Definition: ClangTidyDiagnosticConsumer.h:27
clang::tidy::android::CloexecEpollCreateCheck
epoll_create() is better to be replaced by epoll_create1().
Definition: CloexecEpollCreateCheck.h:23
CloexecFopenCheck.h
clang::tidy::android::CloexecOpenCheck
Finds code that opens file without using the O_CLOEXEC flag.
Definition: CloexecOpenCheck.h:28
CloexecCreatCheck.h
CloexecDupCheck.h
CloexecOpenCheck.h
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
clang::tidy::AndroidModuleAnchorSource
volatile int AndroidModuleAnchorSource
Definition: AndroidTidyModule.cpp:64
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
clang::tidy::android::CloexecInotifyInitCheck
inotify_init() is better to be replaced by inotify_init1().
Definition: CloexecInotifyInitCheck.h:23
clang::tidy::android::CloexecEpollCreate1Check
Finds code that uses epoll_create1() without using the EPOLL_CLOEXEC flag.
Definition: CloexecEpollCreate1Check.h:23
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:84
CloexecAccept4Check.h
clang::tidy::android::CloexecFopenCheck
fopen() is suggested to include "e" in their mode string; like "re" would be better than "r"...
Definition: CloexecFopenCheck.h:26
clang::tidy::android::AndroidModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: AndroidTidyModule.cpp:35
CloexecAcceptCheck.h
clang::tidy::android::CloexecInotifyInit1Check
Finds code that uses inotify_init1() without using the IN_CLOEXEC flag.
Definition: CloexecInotifyInit1Check.h:23
X
static clang::FrontendPluginRegistry::Add< clang::tidy::ClangTidyPluginAction > X("clang-tidy", "clang-tidy")
CloexecInotifyInitCheck.h
CloexecMemfdCreateCheck.h
clang::tidy::android::CloexecAccept4Check
Finds code that uses accept4() without using the SOCK_CLOEXEC flag.
Definition: CloexecAccept4Check.h:23
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::android::CloexecAcceptCheck
accept() is better to be replaced by accept4().
Definition: CloexecAcceptCheck.h:23
clang::tidy::android::AndroidModule
This module is for Android specific checks.
Definition: AndroidTidyModule.cpp:33
CloexecSocketCheck.h
CloexecEpollCreateCheck.h
clang::tidy::android::CloexecSocketCheck
Finds code that uses socket() without using the SOCK_CLOEXEC flag.
Definition: CloexecSocketCheck.h:23
clang::tidy::android::CloexecMemfdCreateCheck
Finds code that uses memfd_create() without using the MFD_CLOEXEC flag.
Definition: CloexecMemfdCreateCheck.h:23
CloexecInotifyInit1Check.h
CloexecEpollCreate1Check.h
clang::tidy::android::CloexecDupCheck
dup() is better to be replaced by fcntl(), which has close-on-exec flag.
Definition: CloexecDupCheck.h:24