10#include "clang/AST/ASTContext.h"
11#include "clang/AST/OpenMPClause.h"
12#include "clang/AST/Stmt.h"
13#include "clang/AST/StmtOpenMP.h"
14#include "clang/ASTMatchers/ASTMatchFinder.h"
15#include "clang/ASTMatchers/ASTMatchers.h"
16#include "clang/ASTMatchers/ASTMatchersMacros.h"
25 RawIgnoredExceptions(Options.get(
"IgnoredExceptions",
"")) {
26 llvm::SmallVector<StringRef, 8> FunctionsThatShouldNotThrowVec,
29 llvm::StringSet<> IgnoredExceptions;
30 StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec,
",", -1,
false);
31 llvm::transform(IgnoredExceptionsVec, IgnoredExceptionsVec.begin(),
32 [](StringRef S) { return S.trim(); });
33 IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
34 IgnoredExceptionsVec.end());
40 Options.
store(Opts,
"IgnoredExceptions", RawIgnoredExceptions);
44 Finder->addMatcher(ompExecutableDirective(
45 unless(isStandaloneDirective()),
46 hasStructuredBlock(stmt().bind(
"structured-block")))
53 Result.Nodes.getNodeAs<OMPExecutableDirective>(
"directive");
54 assert(
Directive &&
"Expected to match some OpenMP Executable directive.");
55 const auto *StructuredBlock =
56 Result.Nodes.getNodeAs<Stmt>(
"structured-block");
57 assert(StructuredBlock &&
"Expected to get some OpenMP Structured Block.");
66 diag(StructuredBlock->getBeginLoc(),
67 "an exception thrown inside of the OpenMP '%0' region is not caught in "
69 << getOpenMPDirectiveName(
Directive->getDirectiveKind());
llvm::SmallString< 256U > Name
const MacroDirective * Directive
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, StringRef Value) const
Stores an option with the check-local name LocalName with string value Value to Options.
Base class for all clang-tidy checks.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
ExceptionEscapeCheck(StringRef Name, ClangTidyContext *Context)
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
State getBehaviour() const
void ignoreBadAlloc(bool ShallIgnore)
void ignoreExceptions(llvm::StringSet<> ExceptionNames)
@ Throwing
The function can definitely throw given an AST.
ExceptionInfo analyze(const FunctionDecl *Func)
llvm::StringMap< ClangTidyValue > OptionMap