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 ompExecutableDirective(
25 isAllowedToContainClauseKind(llvm::omp::OMPC_default),
26 anyOf(unless(hasAnyClause(ompDefaultClause())),
28 ompDefaultClause(unless(isNoneKind())).bind(
"clause"))))
35 Result.Nodes.getNodeAs<OMPExecutableDirective>(
"directive");
36 assert(
Directive !=
nullptr &&
"Expected to match some directive.");
38 if (
const auto *Clause = Result.Nodes.getNodeAs<OMPDefaultClause>(
"clause")) {
40 "OpenMP directive '%0' specifies 'default(%1)' clause, consider using "
41 "'default(none)' clause instead")
42 << getOpenMPDirectiveName(
Directive->getDirectiveKind())
43 << getOpenMPSimpleClauseTypeName(Clause->getClauseKind(),
44 unsigned(Clause->getDefaultKind()));
45 diag(Clause->getBeginLoc(),
"existing 'default' clause specified here",
51 "OpenMP directive '%0' does not specify 'default' clause, consider "
52 "specifying 'default(none)' clause")
53 << getOpenMPDirectiveName(
Directive->getDirectiveKind());
const MacroDirective * Directive
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.