1 //===--- AndroidTidyModule.cpp - clang-tidy--------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "../ClangTidy.h"
10 #include "../ClangTidyModule.h"
11 #include "../ClangTidyModuleRegistry.h"
12 #include "CloexecAccept4Check.h"
13 #include "CloexecAcceptCheck.h"
14 #include "CloexecCreatCheck.h"
15 #include "CloexecDupCheck.h"
16 #include "CloexecEpollCreate1Check.h"
17 #include "CloexecEpollCreateCheck.h"
18 #include "CloexecFopenCheck.h"
19 #include "CloexecInotifyInit1Check.h"
20 #include "CloexecInotifyInitCheck.h"
21 #include "CloexecMemfdCreateCheck.h"
22 #include "CloexecOpenCheck.h"
23 #include "CloexecPipe2Check.h"
24 #include "CloexecPipeCheck.h"
25 #include "CloexecSocketCheck.h"
26 #include "ComparisonInTempFailureRetryCheck.h"
28 using namespace clang::ast_matchers
;
30 namespace clang::tidy
{
33 /// This module is for Android specific checks.
34 class AndroidModule
: public ClangTidyModule
{
36 void addCheckFactories(ClangTidyCheckFactories
&CheckFactories
) override
{
37 CheckFactories
.registerCheck
<CloexecAccept4Check
>("android-cloexec-accept4");
38 CheckFactories
.registerCheck
<CloexecAcceptCheck
>("android-cloexec-accept");
39 CheckFactories
.registerCheck
<CloexecCreatCheck
>("android-cloexec-creat");
40 CheckFactories
.registerCheck
<CloexecDupCheck
>("android-cloexec-dup");
41 CheckFactories
.registerCheck
<CloexecEpollCreate1Check
>(
42 "android-cloexec-epoll-create1");
43 CheckFactories
.registerCheck
<CloexecEpollCreateCheck
>(
44 "android-cloexec-epoll-create");
45 CheckFactories
.registerCheck
<CloexecFopenCheck
>("android-cloexec-fopen");
46 CheckFactories
.registerCheck
<CloexecInotifyInit1Check
>(
47 "android-cloexec-inotify-init1");
48 CheckFactories
.registerCheck
<CloexecInotifyInitCheck
>(
49 "android-cloexec-inotify-init");
50 CheckFactories
.registerCheck
<CloexecMemfdCreateCheck
>(
51 "android-cloexec-memfd-create");
52 CheckFactories
.registerCheck
<CloexecOpenCheck
>("android-cloexec-open");
53 CheckFactories
.registerCheck
<CloexecPipeCheck
>("android-cloexec-pipe");
54 CheckFactories
.registerCheck
<CloexecPipe2Check
>("android-cloexec-pipe2");
55 CheckFactories
.registerCheck
<CloexecSocketCheck
>("android-cloexec-socket");
56 CheckFactories
.registerCheck
<ComparisonInTempFailureRetryCheck
>(
57 "android-comparison-in-temp-failure-retry");
61 // Register the AndroidTidyModule using this statically initialized variable.
62 static ClangTidyModuleRegistry::Add
<AndroidModule
>
63 X("android-module", "Adds Android platform checks.");
65 } // namespace android
67 // This anchor is used to force the linker to link in the generated object file
68 // and thus register the AndroidModule.
69 volatile int AndroidModuleAnchorSource
= 0;
71 } // namespace clang::tidy