19#include "llvm/Support/Casting.h"
28 case OpenACCDirectiveKind::Invalid:
32 case OpenACCDirectiveKind::Parallel:
33 case OpenACCDirectiveKind::Serial:
34 case OpenACCDirectiveKind::Kernels:
36 return S.
Diag(StartLoc, diag::err_acc_construct_appertainment) << K;
47 case OpenACCClauseKind::Default:
48 switch (DirectiveKind) {
49 case OpenACCDirectiveKind::Parallel:
50 case OpenACCDirectiveKind::Serial:
51 case OpenACCDirectiveKind::Kernels:
52 case OpenACCDirectiveKind::ParallelLoop:
53 case OpenACCDirectiveKind::SerialLoop:
54 case OpenACCDirectiveKind::KernelsLoop:
55 case OpenACCDirectiveKind::Data:
60 case OpenACCClauseKind::If:
61 switch (DirectiveKind) {
62 case OpenACCDirectiveKind::Parallel:
63 case OpenACCDirectiveKind::Serial:
64 case OpenACCDirectiveKind::Kernels:
65 case OpenACCDirectiveKind::Data:
66 case OpenACCDirectiveKind::EnterData:
67 case OpenACCDirectiveKind::ExitData:
68 case OpenACCDirectiveKind::HostData:
69 case OpenACCDirectiveKind::Init:
70 case OpenACCDirectiveKind::Shutdown:
71 case OpenACCDirectiveKind::Set:
72 case OpenACCDirectiveKind::Update:
73 case OpenACCDirectiveKind::Wait:
74 case OpenACCDirectiveKind::ParallelLoop:
75 case OpenACCDirectiveKind::SerialLoop:
76 case OpenACCDirectiveKind::KernelsLoop:
81 case OpenACCClauseKind::Self:
82 switch (DirectiveKind) {
83 case OpenACCDirectiveKind::Parallel:
84 case OpenACCDirectiveKind::Serial:
85 case OpenACCDirectiveKind::Kernels:
86 case OpenACCDirectiveKind::Update:
87 case OpenACCDirectiveKind::ParallelLoop:
88 case OpenACCDirectiveKind::SerialLoop:
89 case OpenACCDirectiveKind::KernelsLoop:
94 case OpenACCClauseKind::NumGangs:
95 case OpenACCClauseKind::NumWorkers:
96 case OpenACCClauseKind::VectorLength:
97 switch (DirectiveKind) {
98 case OpenACCDirectiveKind::Parallel:
99 case OpenACCDirectiveKind::Kernels:
100 case OpenACCDirectiveKind::ParallelLoop:
101 case OpenACCDirectiveKind::KernelsLoop:
106 case OpenACCClauseKind::Private:
107 switch (DirectiveKind) {
108 case OpenACCDirectiveKind::Parallel:
109 case OpenACCDirectiveKind::Serial:
110 case OpenACCDirectiveKind::Loop:
111 case OpenACCDirectiveKind::ParallelLoop:
112 case OpenACCDirectiveKind::SerialLoop:
113 case OpenACCDirectiveKind::KernelsLoop:
122 llvm_unreachable(
"Invalid clause kind");
125bool checkAlreadyHasClauseOfKind(
128 const auto *Itr = llvm::find_if(ExistingClauses, [&](
const OpenACCClause *
C) {
131 if (Itr != ExistingClauses.end()) {
132 S.
Diag(Clause.
getBeginLoc(), diag::err_acc_duplicate_clause_disallowed)
134 S.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here);
174 if (checkAlreadyHasClauseOfKind(*
this, ExistingClauses, Clause))
192 if (checkAlreadyHasClauseOfKind(*
this, ExistingClauses, Clause))
203 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCSelfClause>);
204 if (Itr != ExistingClauses.end()) {
206 Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here);
228 if (checkAlreadyHasClauseOfKind(*
this, ExistingClauses, Clause))
236 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCIfClause>);
237 if (Itr != ExistingClauses.end()) {
239 Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here);
256 if (checkAlreadyHasClauseOfKind(*
this, ExistingClauses, Clause))
290 if (checkAlreadyHasClauseOfKind(*
this, ExistingClauses, Clause))
294 "Invalid number of expressions for NumWorkers");
309 if (checkAlreadyHasClauseOfKind(*
this, ExistingClauses, Clause))
313 "Invalid number of expressions for VectorLength");
358 Diag(StartLoc, diag::warn_acc_construct_unimplemented) << K;
371 "Only one of directive or clause kind should be provided");
381 : ICEConvertDiagnoser(
false,
384 DirectiveKind(DK), ClauseKind(CK), IntExpr(IntExpr) {}
393 if (ClauseKind != OpenACCClauseKind::Invalid)
394 return S.
Diag(Loc, diag::err_acc_int_expr_requires_integer) <<
395 0 << ClauseKind <<
T;
397 return S.
Diag(Loc, diag::err_acc_int_expr_requires_integer) <<
398 1 << DirectiveKind <<
T;
403 return S.
Diag(Loc, diag::err_acc_int_expr_incomplete_class_type)
410 return S.
Diag(Loc, diag::err_acc_int_expr_explicit_conversion)
423 return S.
Diag(Loc, diag::err_acc_int_expr_multiple_conversions) <<
T;
435 llvm_unreachable(
"conversion functions are permitted");
437 } IntExprDiagnoser(DK, CK, IntExpr);
440 Loc, IntExpr, IntExprDiagnoser);
444 IntExpr = IntExprResult.
get();
460 while (isa<ArraySectionExpr, ArraySubscriptExpr>(CurVarExpr)) {
461 if (
auto *SubScrpt = dyn_cast<ArraySubscriptExpr>(CurVarExpr))
469 if (
const auto *DRE = dyn_cast<DeclRefExpr>(CurVarExpr)) {
470 if (isa<VarDecl, NonTypeTemplateParmDecl>(
471 DRE->getDecl()->getCanonicalDecl()))
476 if (
const auto *ME = dyn_cast<MemberExpr>(CurVarExpr)) {
477 if (isa<FieldDecl>(ME->getMemberDecl()->getCanonicalDecl()))
482 if (isa<CXXThisExpr>(CurVarExpr))
487 if (isa<DependentScopeDeclRefExpr, CXXDependentScopeMemberExpr>(CurVarExpr))
492 if (isa<RecoveryExpr>(CurVarExpr))
516 return diagnoseConstructAppertainment(*
this, K, StartLoc,
true);
537 llvm_unreachable(
"Unhandled case in directive handling?");
544 llvm_unreachable(
"Unimplemented associated statement application");
559 llvm_unreachable(
"Invalid associated statement application");
564 return diagnoseConstructAppertainment(*
this, K, StartLoc,
false);
Defines some OpenACC-specific enums and functions.
This file declares semantic analysis for OpenACC constructs and clauses.
This file defines OpenACC AST classes for statement-level contructs.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CanQualType ArraySectionTy
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Represents a C++ conversion function within a class.
SourceLocation getLocation() const
This represents one expression.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
This is the base type for all OpenACC Clauses.
static OpenACCComputeConstruct * Create(const ASTContext &C, OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A (possibly-)qualified type.
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ASTContext & getASTContext() const
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
ArrayRef< Expr * > getIntExprs()
OpenACCDirectiveKind getDirectiveKind() const
SourceLocation getEndLoc() const
OpenACCClauseKind getClauseKind() const
const Expr * getConditionExpr() const
SourceLocation getLParenLoc() const
SourceLocation getBeginLoc() const
ArrayRef< Expr * > getVarList()
OpenACCDefaultClauseKind getDefaultClauseKind() const
ExprResult ActOnVar(Expr *VarExpr)
Called when encountering a 'var' for OpenACC, ensures it is actually a declaration reference to a var...
ExprResult ActOnIntExpr(OpenACCDirectiveKind DK, OpenACCClauseKind CK, SourceLocation Loc, Expr *IntExpr)
Called when encountering an 'int-expr' for OpenACC, and manages conversions and diagnostics to 'int'.
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
OpenACCClause * ActOnClause(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCParsedClause &Clause)
Called after parsing an OpenACC Clause so that it can be checked.
bool ActOnStartDeclDirective(OpenACCDirectiveKind K, SourceLocation StartLoc)
Called after the directive, including its clauses, have been parsed and parsing has consumed the 'ann...
bool ActOnStartStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc)
Called after the directive, including its clauses, have been parsed and parsing has consumed the 'ann...
DeclGroupRef ActOnEndDeclDirective()
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnConstruct(OpenACCDirectiveKind K, SourceLocation StartLoc)
Called after the construct has been parsed, but clauses haven't been parsed.
StmtResult ActOnAssociatedStmt(OpenACCDirectiveKind K, StmtResult AssocStmt)
Called when we encounter an associated statement for our construct, this should check legality of the...
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
Sema - This implements semantic analysis and AST building for C.
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
Encodes a location in the source.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isEnumeralType() const
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ Default
'default' clause, allowed on parallel, serial, kernel (and compound) constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
bool isOpenACCComputeDirectiveKind(OpenACCDirectiveKind K)
@ OK_Ordinary
An ordinary object is located at an address in memory.
@ Invalid
Not a valid option.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const FunctionProtoType * T