clang-tools  3.9.0
CERTTidyModule.cpp
Go to the documentation of this file.
1 //===--- CERTTidyModule.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 "../google/UnnamedNamespaceInHeaderCheck.h"
14 #include "../misc/MoveConstructorInitCheck.h"
15 #include "../misc/NewDeleteOverloadsCheck.h"
16 #include "../misc/NonCopyableObjects.h"
17 #include "../misc/StaticAssertCheck.h"
18 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
19 #include "CommandProcessorCheck.h"
20 #include "FloatLoopCounter.h"
21 #include "SetLongJmpCheck.h"
23 #include "StrToNumCheck.h"
26 
27 namespace clang {
28 namespace tidy {
29 namespace cert {
30 
31 class CERTModule : public ClangTidyModule {
32 public:
33  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
34  // C++ checkers
35  // DCL
37  "cert-dcl50-cpp");
39  "cert-dcl54-cpp");
41  "cert-dcl59-cpp");
42  // OOP
44  "cert-oop11-cpp");
45  // ERR
46  CheckFactories.registerCheck<SetLongJmpCheck>(
47  "cert-err52-cpp");
49  "cert-err58-cpp");
51  "cert-err60-cpp");
53  "cert-err61-cpp");
54 
55  // C checkers
56  // DCL
57  CheckFactories.registerCheck<misc::StaticAssertCheck>(
58  "cert-dcl03-c");
59  // ENV
60  CheckFactories.registerCheck<CommandProcessorCheck>(
61  "cert-env33-c");
62  // FLP
63  CheckFactories.registerCheck<FloatLoopCounter>(
64  "cert-flp30-c");
65  // FIO
67  "cert-fio38-c");
68  // ERR
69  CheckFactories.registerCheck<StrToNumCheck>(
70  "cert-err34-c");
71  }
73  ClangTidyOptions Options;
74  Options.CheckOptions["cert-oop11-cpp.UseCERTSemantics"] = "1";
75  return Options;
76  }
77 };
78 
79 } // namespace cert
80 
81 // Register the MiscTidyModule using this statically initialized variable.
82 static ClangTidyModuleRegistry::Add<cert::CERTModule>
83 X("cert-module",
84  "Adds lint checks corresponding to CERT secure coding guidelines.");
85 
86 // This anchor is used to force the linker to link in the generated object file
87 // and thus register the CERTModule.
88 volatile int CERTModuleAnchorSource = 0;
89 
90 } // namespace tidy
91 } // namespace clang
static ClangTidyModuleRegistry::Add< cert::CERTModule > X("cert-module","Adds lint checks corresponding to CERT secure coding guidelines.")
checks for locations that do not throw by value
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
Contains options for clang-tidy.
Execution of a command processor can lead to security vulnerabilities, and is generally not required...
A collection of ClangTidyCheckFactory instances.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.
Guards against use of string conversion functions that do not have reasonable error handling for conv...
Definition: StrToNumCheck.h:24
Checks whether the constructor for a static or thread_local object will throw.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
The check flags dereferences and non-pointer declarations of objects that are not meant to be passed ...
Checks whether a thrown object is nothrow copy constructible.
Guards against use of setjmp/longjmp in C++ code.
volatile int CERTModuleAnchorSource
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
This check diagnoses when the loop induction expression of a for loop has floating-point type...
ClangTidyOptions getModuleOptions() override
Gets default options for checks defined in this module.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Guards against any C-style variadic function definitions (not declarations).