| 1 | //===--- AndroidTidyModule.cpp - clang-tidy--------------------------------===// |
|---|---|
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 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" |
| 27 | |
| 28 | using namespace clang::ast_matchers; |
| 29 | |
| 30 | namespace clang::tidy { |
| 31 | namespace android { |
| 32 | |
| 33 | /// This module is for Android specific checks. |
| 34 | class AndroidModule : public ClangTidyModule { |
| 35 | public: |
| 36 | void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { |
| 37 | CheckFactories.registerCheck<CloexecAccept4Check>( |
| 38 | CheckName: "android-cloexec-accept4"); |
| 39 | CheckFactories.registerCheck<CloexecAcceptCheck>(CheckName: "android-cloexec-accept"); |
| 40 | CheckFactories.registerCheck<CloexecCreatCheck>(CheckName: "android-cloexec-creat"); |
| 41 | CheckFactories.registerCheck<CloexecDupCheck>(CheckName: "android-cloexec-dup"); |
| 42 | CheckFactories.registerCheck<CloexecEpollCreate1Check>( |
| 43 | CheckName: "android-cloexec-epoll-create1"); |
| 44 | CheckFactories.registerCheck<CloexecEpollCreateCheck>( |
| 45 | CheckName: "android-cloexec-epoll-create"); |
| 46 | CheckFactories.registerCheck<CloexecFopenCheck>(CheckName: "android-cloexec-fopen"); |
| 47 | CheckFactories.registerCheck<CloexecInotifyInit1Check>( |
| 48 | CheckName: "android-cloexec-inotify-init1"); |
| 49 | CheckFactories.registerCheck<CloexecInotifyInitCheck>( |
| 50 | CheckName: "android-cloexec-inotify-init"); |
| 51 | CheckFactories.registerCheck<CloexecMemfdCreateCheck>( |
| 52 | CheckName: "android-cloexec-memfd-create"); |
| 53 | CheckFactories.registerCheck<CloexecOpenCheck>(CheckName: "android-cloexec-open"); |
| 54 | CheckFactories.registerCheck<CloexecPipeCheck>(CheckName: "android-cloexec-pipe"); |
| 55 | CheckFactories.registerCheck<CloexecPipe2Check>(CheckName: "android-cloexec-pipe2"); |
| 56 | CheckFactories.registerCheck<CloexecSocketCheck>(CheckName: "android-cloexec-socket"); |
| 57 | CheckFactories.registerCheck<ComparisonInTempFailureRetryCheck>( |
| 58 | CheckName: "android-comparison-in-temp-failure-retry"); |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | // Register the AndroidTidyModule using this statically initialized variable. |
| 63 | static ClangTidyModuleRegistry::Add<AndroidModule> |
| 64 | X("android-module", "Adds Android platform checks."); |
| 65 | |
| 66 | } // namespace android |
| 67 | |
| 68 | // This anchor is used to force the linker to link in the generated object file |
| 69 | // and thus register the AndroidModule. |
| 70 | volatile int AndroidModuleAnchorSource = 0; // NOLINT(misc-use-internal-linkage) |
| 71 | |
| 72 | } // namespace clang::tidy |
| 73 |
