clang-tools  4.0.0
CppCoreGuidelinesTidyModule.cpp
Go to the documentation of this file.
1 //===--- CppCoreGuidelinesModule.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 "../misc/UnconventionalAssignOperatorCheck.h"
15 #include "NoMallocCheck.h"
19 #include "ProTypeConstCastCheck.h"
20 #include "ProTypeCstyleCastCheck.h"
21 #include "ProTypeMemberInitCheck.h"
25 #include "ProTypeVarargCheck.h"
26 #include "SlicingCheck.h"
28 
29 namespace clang {
30 namespace tidy {
31 namespace cppcoreguidelines {
32 
33 /// A module containing checks of the C++ Core Guidelines
35 public:
36  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
38  "cppcoreguidelines-interfaces-global-init");
39  CheckFactories.registerCheck<NoMallocCheck>("cppcoreguidelines-no-malloc");
41  "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
43  "cppcoreguidelines-pro-bounds-constant-array-index");
45  "cppcoreguidelines-pro-bounds-pointer-arithmetic");
46  CheckFactories.registerCheck<ProTypeConstCastCheck>(
47  "cppcoreguidelines-pro-type-const-cast");
48  CheckFactories.registerCheck<ProTypeCstyleCastCheck>(
49  "cppcoreguidelines-pro-type-cstyle-cast");
50  CheckFactories.registerCheck<ProTypeMemberInitCheck>(
51  "cppcoreguidelines-pro-type-member-init");
53  "cppcoreguidelines-pro-type-reinterpret-cast");
55  "cppcoreguidelines-pro-type-static-cast-downcast");
56  CheckFactories.registerCheck<ProTypeUnionAccessCheck>(
57  "cppcoreguidelines-pro-type-union-access");
58  CheckFactories.registerCheck<ProTypeVarargCheck>(
59  "cppcoreguidelines-pro-type-vararg");
61  "cppcoreguidelines-special-member-functions");
62  CheckFactories.registerCheck<SlicingCheck>("cppcoreguidelines-slicing");
64  "cppcoreguidelines-c-copy-assignment-signature");
65  }
66 };
67 
68 // Register the LLVMTidyModule using this statically initialized variable.
69 static ClangTidyModuleRegistry::Add<CppCoreGuidelinesModule>
70  X("cppcoreguidelines-module", "Adds checks for the C++ Core Guidelines.");
71 
72 } // namespace cppcoreguidelines
73 
74 // This anchor is used to force the linker to link in the generated object file
75 // and thus register the CppCoreGuidelinesModule.
77 
78 } // namespace tidy
79 } // namespace clang
Flags possible initialization order issues of static variables.
Checks for classes where some, but not all, of the special member functions are defined.
This check flags all access to members of unions.
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
A module containing checks of the C++ Core Guidelines.
This checker is concerned with C-style memory management and suggest modern alternatives to it...
Definition: NoMallocCheck.h:28
static ClangTidyModuleRegistry::Add< CppCoreGuidelinesModule > X("cppcoreguidelines-module","Adds checks for the C++ Core Guidelines.")
A collection of ClangTidyCheckFactory instances.
This check flags all instances of const_cast.
Flags slicing (incomplete copying of an object's state) of member variables or vtable.
Definition: SlicingCheck.h:28
volatile int CppCoreGuidelinesModuleAnchorSource
This check flags all use of C-style casts that perform a static_cast downcast, const_cast, or reinterpret_cast.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Finds declarations of assignment operators with the wrong return and/or argument types and definition...
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Checks for usages of static_cast, where a base class is downcasted to a derived class.
This check flags all calls to c-style variadic functions and all use of va_arg.
This checks that all array subscriptions on static arrays and std::arrays have a constant index and a...
Flags all kinds of pointer arithmetic that have result of pointer type, i.e.