clang-tools  5.0.0
AndroidTidyModule.cpp
Go to the documentation of this file.
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 "CloexecOpenCheck.h"
16 #include "CloexecSocketCheck.h"
17 
18 using namespace clang::ast_matchers;
19 
20 namespace clang {
21 namespace tidy {
22 namespace android {
23 
24 /// This module is for Android specific checks.
26 public:
27  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
28  CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat");
29  CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen");
30  CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open");
31  CheckFactories.registerCheck<CloexecSocketCheck>("android-cloexec-socket");
32  }
33 };
34 
35 // Register the AndroidTidyModule using this statically initialized variable.
36 static ClangTidyModuleRegistry::Add<AndroidModule>
37  X("android-module", "Adds Android platform checks.");
38 
39 } // namespace android
40 
41 // This anchor is used to force the linker to link in the generated object file
42 // and thus register the AndroidModule.
43 volatile int AndroidModuleAnchorSource = 0;
44 
45 } // namespace tidy
46 } // namespace clang
creat() is better to be replaced by open().
Finds code that opens file without using the O_CLOEXEC flag.
static clang::FrontendPluginRegistry::Add< clang::tidy::ClangTidyPluginAction > X("clang-tidy","clang-tidy")
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
volatile int AndroidModuleAnchorSource
A collection of ClangTidyCheckFactory instances.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
fopen() is suggested to include "e" in their mode string; like "re" would be better than "r"...
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
This module is for Android specific checks.
Finds code that uses socket() without using the SOCK_CLOEXEC flag.