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 "CloexecSocketCheck.h" 24 #include "ComparisonInTempFailureRetryCheck.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<CloexecDupCheck>("android-cloexec-dup"); 40 CheckFactories.registerCheck<CloexecEpollCreate1Check>( 41 "android-cloexec-epoll-create1"); 42 CheckFactories.registerCheck<CloexecEpollCreateCheck>( 43 "android-cloexec-epoll-create"); 44 CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen"); 45 CheckFactories.registerCheck<CloexecInotifyInit1Check>( 46 "android-cloexec-inotify-init1"); 47 CheckFactories.registerCheck<CloexecInotifyInitCheck>( 48 "android-cloexec-inotify-init"); 49 CheckFactories.registerCheck<CloexecMemfdCreateCheck>( 50 "android-cloexec-memfd-create"); 51 CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open"); 52 CheckFactories.registerCheck<CloexecSocketCheck>("android-cloexec-socket"); 53 CheckFactories.registerCheck<ComparisonInTempFailureRetryCheck>( 54 "android-comparison-in-temp-failure-retry"); 55 } 56 }; 57 58 // Register the AndroidTidyModule using this statically initialized variable. 59 static ClangTidyModuleRegistry::Add<AndroidModule> 60 X("android-module", "Adds Android platform checks."); 61 62 } // namespace android 63 64 // This anchor is used to force the linker to link in the generated object file 65 // and thus register the AndroidModule. 66 volatile int AndroidModuleAnchorSource = 0; 67 68 } // namespace tidy 69 } // namespace clang 70