| Yan Wang | 3620620 | 2017-06-23 21:37:29 +0000 | [diff] [blame] | 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" |
| Yan Wang | 0b97414 | 2017-06-29 17:40:57 +0000 | [diff] [blame] | 13 | #include "CloexecCreatCheck.h" |
| Chih-Hung Hsieh | 56650e7 | 2017-08-14 17:04:16 +0000 | [diff] [blame] | 14 | #include "CloexecDupCheck.h" |
| Yan Wang | 2434025 | 2017-06-29 17:42:23 +0000 | [diff] [blame] | 15 | #include "CloexecFopenCheck.h" |
| Chih-Hung Hsieh | 2e6f9a1 | 2017-08-14 17:25:41 +0000 | [diff] [blame^] | 16 | #include "CloexecInotifyInitCheck.h" |
| Yan Wang | b21739f | 2017-08-10 22:09:22 +0000 | [diff] [blame] | 17 | #include "CloexecMemfdCreateCheck.h" |
| Yan Wang | 600a613 | 2017-06-29 19:13:29 +0000 | [diff] [blame] | 18 | #include "CloexecOpenCheck.h" |
| Yan Wang | b38045d | 2017-07-12 17:43:36 +0000 | [diff] [blame] | 19 | #include "CloexecSocketCheck.h" |
| Yan Wang | 3620620 | 2017-06-23 21:37:29 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace clang::ast_matchers; |
| 22 | |
| 23 | namespace clang { |
| 24 | namespace tidy { |
| 25 | namespace android { |
| 26 | |
| 27 | /// This module is for Android specific checks. |
| 28 | class AndroidModule : public ClangTidyModule { |
| 29 | public: |
| 30 | void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { |
| Yan Wang | 0b97414 | 2017-06-29 17:40:57 +0000 | [diff] [blame] | 31 | CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat"); |
| Chih-Hung Hsieh | 56650e7 | 2017-08-14 17:04:16 +0000 | [diff] [blame] | 32 | CheckFactories.registerCheck<CloexecDupCheck>("android-cloexec-dup"); |
| Yan Wang | 2434025 | 2017-06-29 17:42:23 +0000 | [diff] [blame] | 33 | CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen"); |
| Chih-Hung Hsieh | 2e6f9a1 | 2017-08-14 17:25:41 +0000 | [diff] [blame^] | 34 | CheckFactories.registerCheck<CloexecInotifyInitCheck>( |
| 35 | "android-cloexec-inotify-init"); |
| Yan Wang | b21739f | 2017-08-10 22:09:22 +0000 | [diff] [blame] | 36 | CheckFactories.registerCheck<CloexecMemfdCreateCheck>( |
| 37 | "android-cloexec-memfd-create"); |
| Yan Wang | 600a613 | 2017-06-29 19:13:29 +0000 | [diff] [blame] | 38 | CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open"); |
| Yan Wang | b38045d | 2017-07-12 17:43:36 +0000 | [diff] [blame] | 39 | CheckFactories.registerCheck<CloexecSocketCheck>("android-cloexec-socket"); |
| Yan Wang | 3620620 | 2017-06-23 21:37:29 +0000 | [diff] [blame] | 40 | } |
| 41 | }; |
| 42 | |
| 43 | // Register the AndroidTidyModule using this statically initialized variable. |
| 44 | static ClangTidyModuleRegistry::Add<AndroidModule> |
| 45 | X("android-module", "Adds Android platform checks."); |
| 46 | |
| 47 | } // namespace android |
| 48 | |
| 49 | // This anchor is used to force the linker to link in the generated object file |
| 50 | // and thus register the AndroidModule. |
| 51 | volatile int AndroidModuleAnchorSource = 0; |
| 52 | |
| 53 | } // namespace tidy |
| 54 | } // namespace clang |