[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang-tools-extra / clang-tidy / bugprone / ExceptionEscapeCheck.h
blob5468c94b258deb9f9b19d953f51d47b57822916b
1 //===--- ExceptionEscapeCheck.h - clang-tidy --------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTION_ESCAPE_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTION_ESCAPE_H
12 #include "../ClangTidyCheck.h"
13 #include "../utils/ExceptionAnalyzer.h"
14 #include "llvm/ADT/StringSet.h"
16 namespace clang {
17 namespace tidy {
18 namespace bugprone {
20 /// Finds functions which should not throw exceptions: Destructors, move
21 /// constructors, move assignment operators, the main() function,
22 /// swap() functions, functions marked with throw() or noexcept and functions
23 /// given as option to the checker.
24 ///
25 /// For the user-facing documentation see:
26 /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/exception-escape.html
27 class ExceptionEscapeCheck : public ClangTidyCheck {
28 public:
29 ExceptionEscapeCheck(StringRef Name, ClangTidyContext *Context);
30 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
31 return LangOpts.CPlusPlus && LangOpts.CXXExceptions;
33 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
34 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
35 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
37 private:
38 std::string RawFunctionsThatShouldNotThrow;
39 std::string RawIgnoredExceptions;
41 llvm::StringSet<> FunctionsThatShouldNotThrow;
42 utils::ExceptionAnalyzer Tracer;
45 } // namespace bugprone
46 } // namespace tidy
47 } // namespace clang
49 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTION_ESCAPE_H