xref: /llvm-project/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h (revision 4718da506091a37ca4863d979bc541e359b79b10)
1a3274e54SAaron Ballman //===--- ExceptionBaseclassCheck.h - clang-tidy------------------*- C++ -*-===//
2a3274e54SAaron Ballman //
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
6a3274e54SAaron Ballman //
7a3274e54SAaron Ballman //===----------------------------------------------------------------------===//
8a3274e54SAaron Ballman 
9a3274e54SAaron Ballman #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTION_BASECLASS_H
10a3274e54SAaron Ballman #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTION_BASECLASS_H
11a3274e54SAaron Ballman 
12860aefd0SNathan James #include "../ClangTidyCheck.h"
13a3274e54SAaron Ballman 
14*4718da50SCarlos Galvez namespace clang::tidy::hicpp {
15a3274e54SAaron Ballman 
16a3274e54SAaron Ballman /// Check for thrown exceptions and enforce they are all derived from std::exception.
17a3274e54SAaron Ballman ///
18a3274e54SAaron Ballman /// For the user-facing documentation see:
19165d6933SNathan James /// http://clang.llvm.org/extra/clang-tidy/checks/hicpp/exception-baseclass.html
20a3274e54SAaron Ballman class ExceptionBaseclassCheck : public ClangTidyCheck {
21a3274e54SAaron Ballman public:
ExceptionBaseclassCheck(StringRef Name,ClangTidyContext * Context)22a3274e54SAaron Ballman   ExceptionBaseclassCheck(StringRef Name, ClangTidyContext *Context)
23a3274e54SAaron Ballman       : ClangTidyCheck(Name, Context) {}
isLanguageVersionSupported(const LangOptions & LangOpts)24e40a742aSNathan James   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
25e40a742aSNathan James     return LangOpts.CPlusPlus;
26e40a742aSNathan James   }
27a3274e54SAaron Ballman   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
28a3274e54SAaron Ballman   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
29a3274e54SAaron Ballman };
30a3274e54SAaron Ballman 
31*4718da50SCarlos Galvez } // namespace clang::tidy::hicpp
32a3274e54SAaron Ballman 
33a3274e54SAaron Ballman #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTION_BASECLASS_H
34