clang-tools 3.8.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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/AssignOperatorSignatureCheck.h"
14 #include "ProBoundsArrayToPointerDecayCheck.h"
15 #include "ProBoundsConstantArrayIndexCheck.h"
16 #include "ProBoundsPointerArithmeticCheck.h"
17 #include "ProTypeConstCastCheck.h"
18 #include "ProTypeCstyleCastCheck.h"
19 #include "ProTypeReinterpretCastCheck.h"
20 #include "ProTypeStaticCastDowncastCheck.h"
21 #include "ProTypeUnionAccessCheck.h"
22 #include "ProTypeVarargCheck.h"
23
24 namespace clang {
25 namespace tidy {
26 namespace cppcoreguidelines {
27
28 /// A module containing checks of the C++ Core Guidelines
29 class CppCoreGuidelinesModule : public ClangTidyModule {
30 public:
31 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
32 CheckFactories.registerCheck<ProBoundsArrayToPointerDecayCheck>(
33 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
34 CheckFactories.registerCheck<ProBoundsConstantArrayIndexCheck>(
35 "cppcoreguidelines-pro-bounds-constant-array-index");
36 CheckFactories.registerCheck<ProBoundsPointerArithmeticCheck>(
37 "cppcoreguidelines-pro-bounds-pointer-arithmetic");
38 CheckFactories.registerCheck<ProTypeConstCastCheck>(
39 "cppcoreguidelines-pro-type-const-cast");
40 CheckFactories.registerCheck<ProTypeCstyleCastCheck>(
41 "cppcoreguidelines-pro-type-cstyle-cast");
42 CheckFactories.registerCheck<ProTypeReinterpretCastCheck>(
43 "cppcoreguidelines-pro-type-reinterpret-cast");
44 CheckFactories.registerCheck<ProTypeStaticCastDowncastCheck>(
45 "cppcoreguidelines-pro-type-static-cast-downcast");
46 CheckFactories.registerCheck<ProTypeUnionAccessCheck>(
47 "cppcoreguidelines-pro-type-union-access");
48 CheckFactories.registerCheck<ProTypeVarargCheck>(
49 "cppcoreguidelines-pro-type-vararg");
50 CheckFactories.registerCheck<misc::AssignOperatorSignatureCheck>(
51 "cppcoreguidelines-c-copy-assignment-signature");
52 }
53 };
54
55 // Register the LLVMTidyModule using this statically initialized variable.
56 static ClangTidyModuleRegistry::Add<CppCoreGuidelinesModule>
57 X("cppcoreguidelines-module", "Adds checks for the C++ Core Guidelines.");
58
59 } // namespace cppcoreguidelines
60
61 // This anchor is used to force the linker to link in the generated object file
62 // and thus register the CppCoreGuidelinesModule.
63 volatile int CppCoreGuidelinesModuleAnchorSource = 0;
64
65 } // namespace tidy
66 } // namespace clang
ProBoundsConstantArrayIndexCheck.h
clang::tidy::ProTypeStaticCastDowncastCheck
Checks for usages of static_cast, where a base class is downcasted to a derived class.
Definition: ProTypeStaticCastDowncastCheck.h:22
clang::tidy::ProTypeReinterpretCastCheck
Flags all occurrences of reinterpret_cast.
Definition: ProTypeReinterpretCastCheck.h:22
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:58
clang::tidy::cppcoreguidelines::CppCoreGuidelinesModule
A module containing checks of the C++ Core Guidelines.
Definition: CppCoreGuidelinesTidyModule.cpp:29
clang::tidy::ProTypeCstyleCastCheck
This check flags all use of C-style casts that perform a static_cast downcast, const_cast, or reinterpret_cast.
Definition: ProTypeCstyleCastCheck.h:23
clang::tidy::cppcoreguidelines::X
static ClangTidyModuleRegistry::Add< CppCoreGuidelinesModule > X("cppcoreguidelines-module","Adds checks for the C++ Core Guidelines.")
clang::tidy::ProTypeConstCastCheck
This check flags all instances of const_cast.
Definition: ProTypeConstCastCheck.h:22
clang::tidy::ProBoundsArrayToPointerDecayCheck
This check flags all array to pointer decays.
Definition: ProBoundsArrayToPointerDecayCheck.h:22
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
ProTypeUnionAccessCheck.h
ProTypeStaticCastDowncastCheck.h
clang::tidy::misc::AssignOperatorSignatureCheck
Finds declarations of assign operators with the wrong return and/or argument types.
Definition: AssignOperatorSignatureCheck.h:25
clang::tidy::CppCoreGuidelinesModuleAnchorSource
volatile int CppCoreGuidelinesModuleAnchorSource
Definition: CppCoreGuidelinesTidyModule.cpp:63
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:83
clang::tidy::ProBoundsPointerArithmeticCheck
Flags all kinds of pointer arithmetic that have result of pointer type, i.e.
Definition: ProBoundsPointerArithmeticCheck.h:23
ProTypeCstyleCastCheck.h
clang::tidy::ProBoundsConstantArrayIndexCheck
This checks that all array subscriptions on static arrays and std::arrays have a constant index and a...
Definition: ProBoundsConstantArrayIndexCheck.h:24
ProBoundsArrayToPointerDecayCheck.h
ProTypeReinterpretCastCheck.h
ProTypeVarargCheck.h
clang::tidy::ProTypeUnionAccessCheck
This check flags all access to members of unions.
Definition: ProTypeUnionAccessCheck.h:23
clang::tidy::cppcoreguidelines::CppCoreGuidelinesModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: CppCoreGuidelinesTidyModule.cpp:31
clang::tidy::ProTypeVarargCheck
This check flags all calls to c-style variadic functions and all use of va_arg.
Definition: ProTypeVarargCheck.h:23
ProBoundsPointerArithmeticCheck.h
ProTypeConstCastCheck.h