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 "CloexecCreatCheck.h" 14 #include "CloexecDupCheck.h" 15 #include "CloexecFopenCheck.h" 16 #include "CloexecInotifyInitCheck.h" 17 #include "CloexecMemfdCreateCheck.h" 18 #include "CloexecOpenCheck.h" 19 #include "CloexecSocketCheck.h" 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 { 31 CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat"); 32 CheckFactories.registerCheck<CloexecDupCheck>("android-cloexec-dup"); 33 CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen"); 34 CheckFactories.registerCheck<CloexecInotifyInitCheck>( 35 "android-cloexec-inotify-init"); 36 CheckFactories.registerCheck<CloexecMemfdCreateCheck>( 37 "android-cloexec-memfd-create"); 38 CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open"); 39 CheckFactories.registerCheck<CloexecSocketCheck>("android-cloexec-socket"); 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 55