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