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" 24 ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef
Name,
27 RawIgnoredExceptions(Options.get(
"IgnoredExceptions",
"")) {
28 llvm::SmallVector<StringRef, 8> FunctionsThatShouldNotThrowVec,
31 llvm::StringSet<> IgnoredExceptions;
32 StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec,
",", -1,
false);
33 llvm::transform(IgnoredExceptionsVec, IgnoredExceptionsVec.begin(),
34 [](StringRef S) {
return S.trim(); });
35 IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
36 IgnoredExceptionsVec.end());
42 Options.
store(Opts,
"IgnoredExceptions", RawIgnoredExceptions);
54 Finder->addMatcher(ompExecutableDirective(
55 unless(isStandaloneDirective()),
56 hasStructuredBlock(stmt().bind(
"structured-block")))
62 const auto *Directive =
63 Result.Nodes.getNodeAs<OMPExecutableDirective>(
"directive");
64 assert(Directive &&
"Expected to match some OpenMP Executable directive.");
65 const auto *StructuredBlock =
66 Result.Nodes.getNodeAs<Stmt>(
"structured-block");
67 assert(StructuredBlock &&
"Expected to get some OpenMP Structured Block.");
76 diag(StructuredBlock->getBeginLoc(),
77 "an exception thrown inside of the OpenMP '%0' region is not caught in " 79 << getOpenMPDirectiveName(Directive->getDirectiveKind());
Base class for all clang-tidy checks.
const LangOptions & getLangOpts() const
Returns the language options from the context.
State getBehaviour() const
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
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.
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
The function can definitly throw given an AST.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
ExceptionInfo analyze(const FunctionDecl *Func)
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void ignoreBadAlloc(bool ShallIgnore)
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void ignoreExceptions(llvm::StringSet<> ExceptionNames)