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);
46 Finder->addMatcher(ompExecutableDirective(
47 unless(isStandaloneDirective()),
48 hasStructuredBlock(stmt().bind(
"structured-block")))
54 const auto *Directive =
55 Result.Nodes.getNodeAs<OMPExecutableDirective>(
"directive");
56 assert(Directive &&
"Expected to match some OpenMP Executable directive.");
57 const auto *StructuredBlock =
58 Result.Nodes.getNodeAs<Stmt>(
"structured-block");
59 assert(StructuredBlock &&
"Expected to get some OpenMP Structured Block.");
68 diag(StructuredBlock->getBeginLoc(),
69 "an exception thrown inside of the OpenMP '%0' region is not caught in "
71 << getOpenMPDirectiveName(Directive->getDirectiveKind());