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