xref: /llvm-project/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidGotoCheck.h (revision 4718da506091a37ca4863d979bc541e359b79b10)
1f22f3489SJonas Toth //===--- AvoidGotoCheck.h - clang-tidy---------------------------*- C++ -*-===//
2f22f3489SJonas Toth //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f22f3489SJonas Toth //
7f22f3489SJonas Toth //===----------------------------------------------------------------------===//
8f22f3489SJonas Toth 
9f22f3489SJonas Toth #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDGOTOCHECK_H
10f22f3489SJonas Toth #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDGOTOCHECK_H
11f22f3489SJonas Toth 
12860aefd0SNathan James #include "../ClangTidyCheck.h"
13f22f3489SJonas Toth 
14*4718da50SCarlos Galvez namespace clang::tidy::cppcoreguidelines {
15f22f3489SJonas Toth 
16f22f3489SJonas Toth /// The usage of ``goto`` for control flow is error prone and should be replaced
17f22f3489SJonas Toth /// with looping constructs. Only forward jumps in nested loops are accepted.
18f22f3489SJonas Toth //
19f22f3489SJonas Toth /// For the user-facing documentation see:
206e566bc5SRichard /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-goto.html
21f22f3489SJonas Toth class AvoidGotoCheck : public ClangTidyCheck {
22f22f3489SJonas Toth public:
AvoidGotoCheck(StringRef Name,ClangTidyContext * Context)23f22f3489SJonas Toth   AvoidGotoCheck(StringRef Name, ClangTidyContext *Context)
24f22f3489SJonas Toth       : ClangTidyCheck(Name, Context) {}
isLanguageVersionSupported(const LangOptions & LangOpts)25e40a742aSNathan James   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
26e40a742aSNathan James     return LangOpts.CPlusPlus;
27e40a742aSNathan James   }
28f22f3489SJonas Toth   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
29f22f3489SJonas Toth   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
30f22f3489SJonas Toth };
31f22f3489SJonas Toth 
32*4718da50SCarlos Galvez } // namespace clang::tidy::cppcoreguidelines
33f22f3489SJonas Toth 
34f22f3489SJonas Toth #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDGOTOCHECK_H
35