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