1 //===--- ExceptionEscapeCheck.h - clang-tidy --------------------*- C++ -*-===//
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
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"
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.
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
{
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
;
38 std::string RawFunctionsThatShouldNotThrow
;
39 std::string RawIgnoredExceptions
;
41 llvm::StringSet
<> FunctionsThatShouldNotThrow
;
42 utils::ExceptionAnalyzer Tracer
;
45 } // namespace bugprone
49 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTION_ESCAPE_H