clang-tools 8.0.0

ExceptionEscapeCheck.h
Go to the documentation of this file.
1 //===--- ExceptionEscapeCheck.h - clang-tidy---------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTION_ESCAPE_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTION_ESCAPE_H
12
13 #include "../ClangTidy.h"
14
15 #include "llvm/ADT/StringSet.h"
16
17 namespace clang {
18 namespace tidy {
19 namespace bugprone {
20
21 /// Finds functions which should not throw exceptions: Destructors, move
22 /// constructors, move assignment operators, the main() function,
23 /// swap() functions, functions marked with throw() or noexcept and functions
24 /// given as option to the checker.
25 ///
26 /// For the user-facing documentation see:
27 /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-exception-escape.html
28 class ExceptionEscapeCheck : public ClangTidyCheck {
29 public:
30 ExceptionEscapeCheck(StringRef Name, ClangTidyContext *Context);
31 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
32 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
33 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
34
35 private:
36 std::string RawFunctionsThatShouldNotThrow;
37 std::string RawIgnoredExceptions;
38
39 llvm::StringSet<> FunctionsThatShouldNotThrow;
40 llvm::StringSet<> IgnoredExceptions;
41 };
42
43 } // namespace bugprone
44 } // namespace tidy
45 } // namespace clang
46
47 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EXCEPTION_ESCAPE_H
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
clang::tidy::bugprone::ExceptionEscapeCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: ExceptionEscapeCheck.cpp:203
clang::tidy::bugprone::ExceptionEscapeCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition: ExceptionEscapeCheck.cpp:182
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition: ClangTidyOptions.h:98
Result
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
Definition: ClangdServer.cpp:60
clang::tidy::bugprone::ExceptionEscapeCheck
Finds functions which should not throw exceptions: Destructors, move constructors, move assignment operators, the main() function, swap() functions, functions marked with throw() or noexcept and functions given as option to the checker.
Definition: ExceptionEscapeCheck.h:28
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:100
clang::tidy::bugprone::ExceptionEscapeCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: ExceptionEscapeCheck.cpp:188
clang::tidy::bugprone::ExceptionEscapeCheck::ExceptionEscapeCheck
ExceptionEscapeCheck(StringRef Name, ClangTidyContext *Context)
Definition: ExceptionEscapeCheck.cpp:166