blob: 316d228a7b02e15d7f73096ba27592cd3f23ab44 [file] [log] [blame]
Yan Wang36206202017-06-23 21:37:29 +00001//===--- 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"
Yan Wang0b974142017-06-29 17:40:57 +000013#include "CloexecCreatCheck.h"
Chih-Hung Hsieh56650e72017-08-14 17:04:16 +000014#include "CloexecDupCheck.h"
Yan Wang24340252017-06-29 17:42:23 +000015#include "CloexecFopenCheck.h"
Chih-Hung Hsieh2e6f9a12017-08-14 17:25:41 +000016#include "CloexecInotifyInitCheck.h"
Yan Wangb21739f2017-08-10 22:09:22 +000017#include "CloexecMemfdCreateCheck.h"
Yan Wang600a6132017-06-29 19:13:29 +000018#include "CloexecOpenCheck.h"
Yan Wangb38045d2017-07-12 17:43:36 +000019#include "CloexecSocketCheck.h"
Yan Wang36206202017-06-23 21:37:29 +000020
21using namespace clang::ast_matchers;
22
23namespace clang {
24namespace tidy {
25namespace android {
26
27/// This module is for Android specific checks.
28class AndroidModule : public ClangTidyModule {
29public:
30 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
Yan Wang0b974142017-06-29 17:40:57 +000031 CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat");
Chih-Hung Hsieh56650e72017-08-14 17:04:16 +000032 CheckFactories.registerCheck<CloexecDupCheck>("android-cloexec-dup");
Yan Wang24340252017-06-29 17:42:23 +000033 CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen");
Chih-Hung Hsieh2e6f9a12017-08-14 17:25:41 +000034 CheckFactories.registerCheck<CloexecInotifyInitCheck>(
35 "android-cloexec-inotify-init");
Yan Wangb21739f2017-08-10 22:09:22 +000036 CheckFactories.registerCheck<CloexecMemfdCreateCheck>(
37 "android-cloexec-memfd-create");
Yan Wang600a6132017-06-29 19:13:29 +000038 CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open");
Yan Wangb38045d2017-07-12 17:43:36 +000039 CheckFactories.registerCheck<CloexecSocketCheck>("android-cloexec-socket");
Yan Wang36206202017-06-23 21:37:29 +000040 }
41};
42
43// Register the AndroidTidyModule using this statically initialized variable.
44static 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.
51volatile int AndroidModuleAnchorSource = 0;
52
53} // namespace tidy
54} // namespace clang