aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/hicpp
diff options
context:
space:
mode:
authorJonas Toth <jonas.toth@gmail.com>2018-01-17 10:27:41 +0000
committerJonas Toth <jonas.toth@gmail.com>2018-01-17 10:27:41 +0000
commit161cd8299add8fd9a3e1027dca212eb56878d235 (patch)
tree9ef9b69144b423aec1619ea8858f4425f50dbc3c /clang-tidy/hicpp
parent500154a54983fd306b241da1805a830ecc7b7602 (diff)
[clang-tidy] implement check for goto
The usage of `goto` is discourage in C++ since forever. This check implements a warning for every `goto`. Even though there are (rare) valid use cases for `goto`, better high level constructs should be used. `goto` is used sometimes in C programs to free resources at the end of functions in the case of errors. This pattern is better implemented with RAII in C++. Reviewers: aaron.ballman, alexfh, hokein Reviewed By: aaron.ballman Subscribers: lebedev.ri, jbcoe, Eugene.Zelenko, klimek, nemanjai, mgorny, xazax.hun, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D41815 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@322626 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/hicpp')
-rw-r--r--clang-tidy/hicpp/HICPPTidyModule.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tidy/hicpp/HICPPTidyModule.cpp
index 0bb25836..89a1adaf 100644
--- a/clang-tidy/hicpp/HICPPTidyModule.cpp
+++ b/clang-tidy/hicpp/HICPPTidyModule.cpp
@@ -11,6 +11,7 @@
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "../bugprone/UseAfterMoveCheck.h"
+#include "../cppcoreguidelines/AvoidGotoCheck.h"
#include "../cppcoreguidelines/NoMallocCheck.h"
#include "../cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h"
#include "../cppcoreguidelines/ProTypeMemberInitCheck.h"
@@ -45,6 +46,8 @@ namespace hicpp {
class HICPPModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+ CheckFactories.registerCheck<cppcoreguidelines::AvoidGotoCheck>(
+ "hicpp-avoid-goto");
CheckFactories.registerCheck<readability::BracesAroundStatementsCheck>(
"hicpp-braces-around-statements");
CheckFactories.registerCheck<modernize::DeprecatedHeadersCheck>(