23bool checkValidAfterDeviceType(
42 case OpenACCClauseKind::Async:
43 case OpenACCClauseKind::Wait:
44 case OpenACCClauseKind::NumGangs:
45 case OpenACCClauseKind::NumWorkers:
46 case OpenACCClauseKind::VectorLength:
51 }
else if (NewClause.getDirectiveKind() == OpenACCDirectiveKind::Loop) {
56 case OpenACCClauseKind::Collapse:
57 case OpenACCClauseKind::Gang:
58 case OpenACCClauseKind::Worker:
59 case OpenACCClauseKind::Vector:
60 case OpenACCClauseKind::Seq:
61 case OpenACCClauseKind::Independent:
62 case OpenACCClauseKind::Auto:
63 case OpenACCClauseKind::Tile:
71 case OpenACCClauseKind::Async:
72 case OpenACCClauseKind::Wait:
73 case OpenACCClauseKind::NumGangs:
74 case OpenACCClauseKind::NumWorkers:
75 case OpenACCClauseKind::VectorLength:
76 case OpenACCClauseKind::Collapse:
77 case OpenACCClauseKind::Gang:
78 case OpenACCClauseKind::Worker:
79 case OpenACCClauseKind::Vector:
80 case OpenACCClauseKind::Seq:
81 case OpenACCClauseKind::Independent:
82 case OpenACCClauseKind::Auto:
83 case OpenACCClauseKind::Tile:
88 }
else if (NewClause.getDirectiveKind() == OpenACCDirectiveKind::Data) {
92 case OpenACCClauseKind::Async:
93 case OpenACCClauseKind::Wait:
98 }
else if (NewClause.getDirectiveKind() == OpenACCDirectiveKind::Set ||
99 NewClause.getDirectiveKind() == OpenACCDirectiveKind::Init ||
100 NewClause.getDirectiveKind() == OpenACCDirectiveKind::Shutdown) {
103 }
else if (NewClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
107 case OpenACCClauseKind::Async:
108 case OpenACCClauseKind::Wait:
113 }
else if (NewClause.getDirectiveKind() == OpenACCDirectiveKind::Routine) {
117 case OpenACCClauseKind::Gang:
118 case OpenACCClauseKind::Worker:
119 case OpenACCClauseKind::Vector:
120 case OpenACCClauseKind::Seq:
121 case OpenACCClauseKind::Bind:
127 S.
Diag(NewClause.
getBeginLoc(), diag::err_acc_clause_after_device_type)
129 << NewClause.getDirectiveKind();
131 diag::note_acc_active_applies_clause_here)
132 << diag::ACCDeviceTypeApp::Active << DeviceTypeClause.
getClauseKind();
140 while (isa<LinkageSpecDecl>(DC))
146class SemaOpenACCClauseVisitor {
163 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCSeqClause>);
165 if (Itr != ExistingClauses.end()) {
166 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_cannot_combine)
169 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
170 << (*Itr)->getClauseKind();
190 return CurMods ^ Bit;
193 if ((Mods | ValidKinds) == ValidKinds)
196 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::Always);
197 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::AlwaysIn);
198 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::AlwaysOut);
199 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::Readonly);
200 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::Zero);
201 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::Capture);
207 bool IsStructuredDataOrCompute =
214 llvm_unreachable(
"Only for copy, copyin, copyout, create");
215 case OpenACCClauseKind::Copy:
216 case OpenACCClauseKind::PCopy:
217 case OpenACCClauseKind::PresentOrCopy:
219 return Check(OpenACCModifierKind::Always | OpenACCModifierKind::AlwaysIn |
220 OpenACCModifierKind::AlwaysOut |
221 OpenACCModifierKind::Capture);
222 case OpenACCClauseKind::CopyIn:
223 case OpenACCClauseKind::PCopyIn:
224 case OpenACCClauseKind::PresentOrCopyIn:
226 return Check(OpenACCModifierKind::Always | OpenACCModifierKind::AlwaysIn |
227 OpenACCModifierKind::Readonly |
228 (IsStructuredDataOrCompute ? OpenACCModifierKind::Capture
229 : OpenACCModifierKind::Invalid));
230 case OpenACCClauseKind::CopyOut:
231 case OpenACCClauseKind::PCopyOut:
232 case OpenACCClauseKind::PresentOrCopyOut:
234 return Check(OpenACCModifierKind::Always |
235 OpenACCModifierKind::AlwaysOut | OpenACCModifierKind::Zero |
236 (IsStructuredDataOrCompute ? OpenACCModifierKind::Capture
237 : OpenACCModifierKind::Invalid));
238 case OpenACCClauseKind::Create:
239 case OpenACCClauseKind::PCreate:
240 case OpenACCClauseKind::PresentOrCreate:
242 return Check(OpenACCModifierKind::Zero |
243 (IsStructuredDataOrCompute ? OpenACCModifierKind::Capture
244 : OpenACCModifierKind::Invalid));
246 llvm_unreachable(
"didn't return from switch above?");
251 template <
typename Pred>
253 CheckValidRoutineNewClauseHelper(Pred HasPredicate,
258 auto *FirstDeviceType =
259 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCDeviceTypeClause>);
261 if (FirstDeviceType == ExistingClauses.end()) {
264 auto *ExistingProhibitedClause =
265 llvm::find_if(ExistingClauses, HasPredicate);
267 if (ExistingProhibitedClause == ExistingClauses.end())
270 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_cannot_combine)
272 << (*ExistingProhibitedClause)->getClauseKind()
274 SemaRef.
Diag((*ExistingProhibitedClause)->getBeginLoc(),
275 diag::note_acc_previous_clause_here)
276 << (*ExistingProhibitedClause)->getClauseKind();
284 auto *BeforeDeviceType =
285 std::find_if(ExistingClauses.begin(), FirstDeviceType, HasPredicate);
288 if (BeforeDeviceType != FirstDeviceType) {
291 diag::err_acc_clause_routine_cannot_combine_before_device_type)
292 << Clause.
getClauseKind() << (*BeforeDeviceType)->getClauseKind();
293 SemaRef.
Diag((*BeforeDeviceType)->getBeginLoc(),
294 diag::note_acc_previous_clause_here)
295 << (*BeforeDeviceType)->getClauseKind();
296 SemaRef.
Diag((*FirstDeviceType)->getBeginLoc(),
297 diag::note_acc_active_applies_clause_here)
298 << diag::ACCDeviceTypeApp::Active
299 << (*FirstDeviceType)->getClauseKind();
303 auto LastDeviceTypeItr =
304 std::find_if(ExistingClauses.rbegin(), ExistingClauses.rend(),
305 llvm::IsaPred<OpenACCDeviceTypeClause>);
309 assert(LastDeviceTypeItr != ExistingClauses.rend());
313 auto *LastDeviceType = LastDeviceTypeItr.base() - 1;
315 auto *ExistingProhibitedSinceLastDevice =
316 std::find_if(LastDeviceType, ExistingClauses.end(), HasPredicate);
319 if (ExistingProhibitedSinceLastDevice == ExistingClauses.end())
323 diag::err_acc_clause_routine_cannot_combine_same_device_type)
325 << (*ExistingProhibitedSinceLastDevice)->getClauseKind();
326 SemaRef.
Diag((*ExistingProhibitedSinceLastDevice)->getBeginLoc(),
327 diag::note_acc_previous_clause_here)
328 << (*ExistingProhibitedSinceLastDevice)->getClauseKind();
329 SemaRef.
Diag((*LastDeviceType)->getBeginLoc(),
330 diag::note_acc_active_applies_clause_here)
331 << diag::ACCDeviceTypeApp::Active << (*LastDeviceType)->getClauseKind();
337 bool CheckValidRoutineGangWorkerVectorSeqNewClause(
348 return CheckValidRoutineNewClauseHelper(ProhibitedPred, Clause);
360 auto HasBindPred = llvm::IsaPred<OpenACCBindClause>;
361 return CheckValidRoutineNewClauseHelper(HasBindPred, Clause);
368 template <
typename TheClauseTy>
370 auto LastDeviceTypeItr =
371 std::find_if(ExistingClauses.rbegin(), ExistingClauses.rend(),
372 llvm::IsaPred<OpenACCDeviceTypeClause>);
374 auto LastSinceDevTy =
375 std::find_if(ExistingClauses.rbegin(), LastDeviceTypeItr,
376 llvm::IsaPred<TheClauseTy>);
380 if (LastSinceDevTy != LastDeviceTypeItr) {
382 diag::err_acc_clause_since_last_device_type)
384 << (LastDeviceTypeItr != ExistingClauses.rend());
386 SemaRef.
Diag((*LastSinceDevTy)->getBeginLoc(),
387 diag::note_acc_previous_clause_here)
388 << (*LastSinceDevTy)->getClauseKind();
391 if (LastDeviceTypeItr != ExistingClauses.rend())
392 SemaRef.
Diag((*LastDeviceTypeItr)->getBeginLoc(),
393 diag::note_acc_active_applies_clause_here)
394 << diag::ACCDeviceTypeApp::Active
395 << (*LastDeviceTypeItr)->getClauseKind();
402 if (LastDeviceTypeItr == ExistingClauses.rend())
407 const auto &ActiveDeviceTypeClause =
408 cast<OpenACCDeviceTypeClause>(**LastDeviceTypeItr);
410 auto PrevDeviceTypeItr = LastDeviceTypeItr;
411 auto CurDevTypeItr = LastDeviceTypeItr;
413 while ((CurDevTypeItr = std::find_if(
414 std::next(PrevDeviceTypeItr), ExistingClauses.rend(),
415 llvm::IsaPred<OpenACCDeviceTypeClause>)) !=
416 ExistingClauses.rend()) {
420 auto CurClauseKindItr = std::find_if(PrevDeviceTypeItr, CurDevTypeItr,
421 llvm::IsaPred<TheClauseTy>);
425 if (CurClauseKindItr == CurDevTypeItr) {
426 PrevDeviceTypeItr = CurDevTypeItr;
433 const auto &CurDeviceTypeClause =
434 cast<OpenACCDeviceTypeClause>(**CurDevTypeItr);
437 ActiveDeviceTypeClause.getArchitectures()) {
439 CurDeviceTypeClause.getArchitectures()) {
443 if (
arg.getIdentifierInfo() == prevArg.getIdentifierInfo() ||
444 (
arg.getIdentifierInfo() && prevArg.getIdentifierInfo() &&
445 StringRef{arg.getIdentifierInfo()->getName()}.equals_insensitive(
446 prevArg.getIdentifierInfo()->getName()))) {
448 diag::err_acc_clause_conflicts_prev_dev_type)
450 << (
arg.getIdentifierInfo() ?
arg.getIdentifierInfo()->getName()
453 SemaRef.
Diag(ActiveDeviceTypeClause.getBeginLoc(),
454 diag::note_acc_active_applies_clause_here)
455 << diag::ACCDeviceTypeApp::Active
456 << ActiveDeviceTypeClause.getClauseKind();
458 SemaRef.
Diag((*CurClauseKindItr)->getBeginLoc(),
459 diag::note_acc_previous_clause_here)
460 << (*CurClauseKindItr)->getClauseKind();
462 SemaRef.
Diag(CurDeviceTypeClause.getBeginLoc(),
463 diag::note_acc_active_applies_clause_here)
464 << diag::ACCDeviceTypeApp::Applies
465 << CurDeviceTypeClause.getClauseKind();
471 PrevDeviceTypeItr = CurDevTypeItr;
479 : SemaRef(S), Ctx(S.getASTContext()), ExistingClauses(ExistingClauses) {}
490 if (CheckValidRoutineGangWorkerVectorSeqNewClause(Clause) ||
491 CheckValidRoutineBindNewClause(Clause))
495 case OpenACCClauseKind::Shortloop:
496 llvm_unreachable(
"Shortloop shouldn't be generated in clang");
497 case OpenACCClauseKind::Invalid:
499#define VISIT_CLAUSE(CLAUSE_NAME) \
500 case OpenACCClauseKind::CLAUSE_NAME: \
501 return Visit##CLAUSE_NAME##Clause(Clause);
502#define CLAUSE_ALIAS(ALIAS, CLAUSE_NAME, DEPRECATED) \
503 case OpenACCClauseKind::ALIAS: \
505 SemaRef.Diag(Clause.getBeginLoc(), diag::warn_acc_deprecated_alias_name) \
506 << Clause.getClauseKind() << OpenACCClauseKind::CLAUSE_NAME; \
507 return Visit##CLAUSE_NAME##Clause(Clause);
508#include "clang/Basic/OpenACCClauses.def"
510 llvm_unreachable(
"Invalid clause kind");
513#define VISIT_CLAUSE(CLAUSE_NAME) \
514 OpenACCClause *Visit##CLAUSE_NAME##Clause( \
515 SemaOpenACC::OpenACCParsedClause &Clause);
516#include "clang/Basic/OpenACCClauses.def"
533 if (DisallowSinceLastDeviceType<OpenACCTileClause>(Clause))
545 NewSizeExprs.push_back(Res.
get());
563 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCSelfClause>);
564 if (Itr != ExistingClauses.end()) {
566 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
567 << (*Itr)->getClauseKind();
587 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCIfClause>);
588 if (Itr != ExistingClauses.end()) {
590 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
591 << (*Itr)->getClauseKind();
601 if (DisallowSinceLastDeviceType<OpenACCNumGangsClause>(Clause))
628 auto *GangClauseItr =
629 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
630 auto *ReductionClauseItr =
631 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
633 if (GangClauseItr != ExistingClauses.end() &&
634 ReductionClauseItr != ExistingClauses.end()) {
636 diag::err_acc_gang_reduction_numgangs_conflict)
637 << OpenACCClauseKind::Reduction << OpenACCClauseKind::Gang
639 SemaRef.
Diag((*ReductionClauseItr)->getBeginLoc(),
640 diag::note_acc_previous_clause_here)
641 << (*ReductionClauseItr)->getClauseKind();
642 SemaRef.
Diag((*GangClauseItr)->getBeginLoc(),
643 diag::note_acc_previous_clause_here)
644 << (*GangClauseItr)->getClauseKind();
656 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
658 if (
Parallel != ExistingClauses.end()) {
660 diag::err_acc_reduction_num_gangs_conflict)
663 SemaRef.
Diag((*Parallel)->getBeginLoc(),
664 diag::note_acc_previous_clause_here)
665 << (*Parallel)->getClauseKind();
674 auto GangClauses = llvm::make_filter_range(
675 ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
677 for (
auto *GC : GangClauses) {
678 if (cast<OpenACCGangClause>(GC)->hasExprOfKind(OpenACCGangKind::Num)) {
680 diag::err_acc_num_arg_conflict_reverse)
681 << OpenACCClauseKind::NumGangs << OpenACCClauseKind::Gang
683 SemaRef.
Diag(GC->getBeginLoc(), diag::note_acc_previous_clause_here)
684 << GC->getClauseKind();
695OpenACCClause *SemaOpenACCClauseVisitor::VisitNumWorkersClause(
698 if (DisallowSinceLastDeviceType<OpenACCNumWorkersClause>(Clause))
705 auto WorkerClauses = llvm::make_filter_range(
706 ExistingClauses, llvm::IsaPred<OpenACCWorkerClause>);
708 for (
auto *WC : WorkerClauses) {
709 if (cast<OpenACCWorkerClause>(WC)->hasIntExpr()) {
711 diag::err_acc_num_arg_conflict_reverse)
712 << OpenACCClauseKind::NumWorkers << OpenACCClauseKind::Worker
714 SemaRef.
Diag(WC->getBeginLoc(), diag::note_acc_previous_clause_here)
715 << WC->getClauseKind();
722 "Invalid number of expressions for NumWorkers");
728OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorLengthClause(
731 if (DisallowSinceLastDeviceType<OpenACCVectorLengthClause>(Clause))
738 auto VectorClauses = llvm::make_filter_range(
739 ExistingClauses, llvm::IsaPred<OpenACCVectorClause>);
741 for (
auto *VC : VectorClauses) {
742 if (cast<OpenACCVectorClause>(VC)->hasIntExpr()) {
744 diag::err_acc_num_arg_conflict_reverse)
745 << OpenACCClauseKind::VectorLength << OpenACCClauseKind::Vector
747 SemaRef.
Diag(VC->getBeginLoc(), diag::note_acc_previous_clause_here)
748 << VC->getClauseKind();
755 "Invalid number of expressions for NumWorkers");
763 if (DisallowSinceLastDeviceType<OpenACCAsyncClause>(Clause))
767 "Invalid number of expressions for Async");
774OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceNumClause(
777 "Invalid number of expressions for device_num");
783OpenACCClause *SemaOpenACCClauseVisitor::VisitDefaultAsyncClause(
786 "Invalid number of expressions for default_async");
802 InitRecipes.push_back(
810OpenACCClause *SemaOpenACCClauseVisitor::VisitFirstPrivateClause(
820 InitRecipes.push_back(
904 OpenACCModifierKind::Invalid);
911OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceResidentClause(
985 llvm::erase_if(VarList, [&](
Expr *
E) {
999 llvm::erase_if(VarList, [&](
Expr *
E) {
1018OpenACCClause *SemaOpenACCClauseVisitor::VisitUseDeviceClause(
1027OpenACCClause *SemaOpenACCClauseVisitor::VisitDevicePtrClause(
1032 llvm::erase_if(VarList, [&](
Expr *
E) {
1054OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceTypeClause(
1066 diag::err_acc_device_type_multiple_archs)
1075 const std::array<llvm::StringLiteral, 6> ValidValues{
1076 "default",
"nvidia",
"acc_device_nvidia",
"radeon",
"host",
"multicore"};
1080 std::string ValidValuesString =
1081 "'default', 'nvidia', 'acc_device_nvidia', 'radeon', 'host', 'multicore'";
1089 bool Diagnosed =
false;
1092 if (!
Arch.getIdentifierInfo())
1094 return llvm::find_if(ValidValues, [&](StringRef RHS) {
1095 return Arch.getIdentifierInfo()->
getName().equals_insensitive(RHS);
1096 }) == ValidValues.end();
1100 Diagnosed = SemaRef.
Diag(
Arch.getLoc(), diag::err_acc_invalid_default_type)
1102 << ValidValuesString;
1109 llvm::for_each(llvm::make_filter_range(Architectures, FilterPred), Diagnose);
1111 llvm::erase_if(Architectures, FilterPred);
1131OpenACCClause *SemaOpenACCClauseVisitor::VisitIndependentClause(
1139 if (isa<OpenACCAsteriskSizeExpr>(
E))
1141 return S.ActOnIntExpr(OpenACCDirectiveKind::Invalid, OpenACCClauseKind::Gang,
1146 return DK == OpenACCDirectiveKind::Loop &&
1147 AssocKind == OpenACCDirectiveKind::Invalid;
1151 return DK == OpenACCDirectiveKind::Loop &&
1152 AssocKind != OpenACCDirectiveKind::Invalid;
1159 << GK << CK << IsOrphanLoop(DK, AssocKind) << DK
1160 << HasAssocKind(DK, AssocKind) << AssocKind;
1167 << TagKind << CK << IsOrphanLoop(DK, AssocKind) << DK
1168 << HasAssocKind(DK, AssocKind) << AssocKind;
1182 ExprResult Res = S.ActOnIntExpr(OpenACCDirectiveKind::Invalid,
1191 std::optional<llvm::APSInt> ICE =
1194 if (!ICE || *ICE <= 0 || ICE > 3) {
1196 << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue();
1208 case OpenACCGangKind::Static:
1209 return CheckGangStaticExpr(S,
E);
1210 case OpenACCGangKind::Num:
1214 return DiagIntArgInvalid(S,
E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1215 case OpenACCGangKind::Dim:
1216 return CheckGangDimExpr(S,
E);
1218 llvm_unreachable(
"Unknown gang kind in gang parallel check");
1230 case OpenACCGangKind::Dim:
1231 return DiagIntArgInvalid(S,
E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1232 case OpenACCGangKind::Num: {
1244 : S.getActiveComputeConstructInfo().Clauses;
1247 llvm::find_if(Collection, llvm::IsaPred<OpenACCNumGangsClause>);
1249 if (Itr != Collection.end()) {
1251 <<
"num" << OpenACCClauseKind::Gang << DK
1252 << HasAssocKind(DK, AssocKind) << AssocKind
1253 << OpenACCClauseKind::NumGangs;
1255 S.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1256 << (*Itr)->getClauseKind();
1261 case OpenACCGangKind::Static:
1262 return CheckGangStaticExpr(S,
E);
1264 llvm_unreachable(
"Unknown gang kind in gang kernels check");
1273 case OpenACCGangKind::Dim:
1274 case OpenACCGangKind::Num:
1275 return DiagIntArgInvalid(S,
E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1276 case OpenACCGangKind::Static:
1277 return CheckGangStaticExpr(S,
E);
1279 llvm_unreachable(
"Unknown gang kind in gang serial check");
1287 case OpenACCGangKind::Num:
1288 case OpenACCGangKind::Static:
1289 return DiagIntArgInvalid(S,
E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1290 case OpenACCGangKind::Dim:
1291 return CheckGangDimExpr(S,
E);
1293 llvm_unreachable(
"Unknown gang kind in gang serial check");
1298 if (DiagGangWorkerVectorSeqConflict(Clause))
1306 llvm_unreachable(
"Invalid directive kind for this clause");
1307 case OpenACCDirectiveKind::Loop:
1309 case OpenACCDirectiveKind::Invalid:
1310 case OpenACCDirectiveKind::Parallel:
1311 case OpenACCDirectiveKind::ParallelLoop:
1314 case OpenACCDirectiveKind::Serial:
1315 case OpenACCDirectiveKind::SerialLoop:
1318 DiagIntArgInvalid(SemaRef, IntExpr,
"length", OpenACCClauseKind::Vector,
1323 case OpenACCDirectiveKind::Kernels:
1324 case OpenACCDirectiveKind::KernelsLoop: {
1327 llvm::IsaPred<OpenACCVectorLengthClause>);
1330 <<
"length" << OpenACCClauseKind::Vector
1335 << OpenACCClauseKind::VectorLength;
1336 SemaRef.
Diag((*Itr)->getBeginLoc(),
1337 diag::note_acc_previous_clause_here)
1338 << (*Itr)->getClauseKind();
1345 llvm_unreachable(
"Non compute construct in active compute construct");
1348 case OpenACCDirectiveKind::KernelsLoop: {
1349 const auto *Itr = llvm::find_if(ExistingClauses,
1350 llvm::IsaPred<OpenACCVectorLengthClause>);
1351 if (Itr != ExistingClauses.end()) {
1353 <<
"length" << OpenACCClauseKind::Vector
1358 << OpenACCClauseKind::VectorLength;
1359 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1360 << (*Itr)->getClauseKind();
1366 case OpenACCDirectiveKind::SerialLoop:
1367 case OpenACCDirectiveKind::Routine:
1368 DiagIntArgInvalid(SemaRef, IntExpr,
"length", OpenACCClauseKind::Vector,
1373 case OpenACCDirectiveKind::ParallelLoop:
1375 case OpenACCDirectiveKind::Invalid:
1391 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1392 << OpenACCClauseKind::Vector << OpenACCClauseKind::Vector
1395 diag::note_acc_previous_clause_here)
1408 if (DiagGangWorkerVectorSeqConflict(Clause))
1417 llvm_unreachable(
"Invalid directive kind for this clause");
1418 case OpenACCDirectiveKind::Invalid:
1426 case OpenACCDirectiveKind::Loop:
1428 case OpenACCDirectiveKind::Invalid:
1429 case OpenACCDirectiveKind::ParallelLoop:
1430 case OpenACCDirectiveKind::SerialLoop:
1431 case OpenACCDirectiveKind::Parallel:
1432 case OpenACCDirectiveKind::Serial:
1433 DiagIntArgInvalid(SemaRef, IntExpr, OpenACCGangKind::Num,
1438 case OpenACCDirectiveKind::KernelsLoop:
1439 case OpenACCDirectiveKind::Kernels: {
1442 llvm::IsaPred<OpenACCNumWorkersClause>);
1449 << OpenACCClauseKind::NumWorkers;
1450 SemaRef.
Diag((*Itr)->getBeginLoc(),
1451 diag::note_acc_previous_clause_here)
1452 << (*Itr)->getClauseKind();
1459 llvm_unreachable(
"Non compute construct in active compute construct");
1462 case OpenACCDirectiveKind::ParallelLoop:
1463 case OpenACCDirectiveKind::SerialLoop:
1464 case OpenACCDirectiveKind::Routine:
1465 DiagIntArgInvalid(SemaRef, IntExpr, OpenACCGangKind::Num,
1470 case OpenACCDirectiveKind::KernelsLoop: {
1471 const auto *Itr = llvm::find_if(ExistingClauses,
1472 llvm::IsaPred<OpenACCNumWorkersClause>);
1473 if (Itr != ExistingClauses.end()) {
1479 << OpenACCClauseKind::NumWorkers;
1480 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1481 << (*Itr)->getClauseKind();
1496 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1497 << OpenACCClauseKind::Worker << OpenACCClauseKind::Worker
1500 diag::note_acc_previous_clause_here)
1511 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1512 << OpenACCClauseKind::Worker << OpenACCClauseKind::Vector
1515 diag::note_acc_previous_clause_here)
1529 if (DiagGangWorkerVectorSeqConflict(Clause))
1537 OpenACCDirectiveKind::Invalid) ||
1540 auto ActiveComputeConstructContainer =
1544 auto *NumGangsClauseItr = llvm::find_if(
1545 ActiveComputeConstructContainer, llvm::IsaPred<OpenACCNumGangsClause>);
1547 if (NumGangsClauseItr != ActiveComputeConstructContainer.end() &&
1548 cast<OpenACCNumGangsClause>(*NumGangsClauseItr)->getIntExprs().size() >
1550 auto *ReductionClauseItr =
1551 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
1553 if (ReductionClauseItr != ExistingClauses.end()) {
1555 diag::err_acc_gang_reduction_numgangs_conflict)
1556 << OpenACCClauseKind::Gang << OpenACCClauseKind::Reduction
1559 SemaRef.
Diag((*ReductionClauseItr)->getBeginLoc(),
1560 diag::note_acc_previous_clause_here)
1561 << (*ReductionClauseItr)->getClauseKind();
1562 SemaRef.
Diag((*NumGangsClauseItr)->getBeginLoc(),
1563 diag::note_acc_previous_clause_here)
1564 << (*NumGangsClauseItr)->getClauseKind();
1577 for (
unsigned I = 0; I < Clause.
getIntExprs().size(); ++I) {
1588 if (ExistingElemLoc[
static_cast<unsigned>(GK)].isValid()) {
1590 <<
static_cast<unsigned>(GK);
1591 SemaRef.
Diag(ExistingElemLoc[
static_cast<unsigned>(GK)],
1592 diag::note_acc_previous_expr_here);
1596 ExistingElemLoc[
static_cast<unsigned>(GK)] = ER.
get()->
getBeginLoc();
1597 GangKinds.push_back(GK);
1598 IntExprs.push_back(ER.
get());
1609 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1610 << OpenACCClauseKind::Gang << OpenACCClauseKind::Gang
1614 diag::note_acc_previous_clause_here)
1625 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1626 << OpenACCClauseKind::Gang << OpenACCClauseKind::Worker
1629 diag::note_acc_previous_clause_here)
1640 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1641 << OpenACCClauseKind::Gang << OpenACCClauseKind::Vector
1644 diag::note_acc_previous_clause_here)
1652 GangKinds, IntExprs, Clause.
getEndLoc());
1655OpenACCClause *SemaOpenACCClauseVisitor::VisitFinalizeClause(
1663OpenACCClause *SemaOpenACCClauseVisitor::VisitIfPresentClause(
1678 const auto *Itr = llvm::find_if(
1681 if (Itr != ExistingClauses.end()) {
1682 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_cannot_combine)
1685 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1686 << (*Itr)->getClauseKind();
1695OpenACCClause *SemaOpenACCClauseVisitor::VisitReductionClause(
1702 OpenACCDirectiveKind::Invalid) ||
1705 auto ActiveComputeConstructContainer =
1709 auto *NumGangsClauseItr = llvm::find_if(
1710 ActiveComputeConstructContainer, llvm::IsaPred<OpenACCNumGangsClause>);
1712 if (NumGangsClauseItr != ActiveComputeConstructContainer.end() &&
1713 cast<OpenACCNumGangsClause>(*NumGangsClauseItr)->getIntExprs().size() >
1715 auto *GangClauseItr =
1716 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
1718 if (GangClauseItr != ExistingClauses.end()) {
1720 diag::err_acc_gang_reduction_numgangs_conflict)
1721 << OpenACCClauseKind::Reduction << OpenACCClauseKind::Gang
1724 SemaRef.
Diag((*GangClauseItr)->getBeginLoc(),
1725 diag::note_acc_previous_clause_here)
1726 << (*GangClauseItr)->getClauseKind();
1727 SemaRef.
Diag((*NumGangsClauseItr)->getBeginLoc(),
1728 diag::note_acc_previous_clause_here)
1729 << (*NumGangsClauseItr)->getClauseKind();
1757 auto NumGangsClauses = llvm::make_filter_range(
1758 ExistingClauses, llvm::IsaPred<OpenACCNumGangsClause>);
1760 for (
auto *NGC : NumGangsClauses) {
1762 cast<OpenACCNumGangsClause>(NGC)->getIntExprs().size();
1766 diag::err_acc_reduction_num_gangs_conflict)
1769 SemaRef.
Diag(NGC->getBeginLoc(), diag::note_acc_previous_clause_here)
1770 << NGC->getClauseKind();
1784 ValidVars.push_back(Res.
get());
1791 Recipes.push_back({InitRecipe});
1802OpenACCClause *SemaOpenACCClauseVisitor::VisitCollapseClause(
1805 if (DisallowSinceLastDeviceType<OpenACCCollapseClause>(Clause))
1821 if (std::holds_alternative<StringLiteral *>(Clause.
getBindDetails()))
1832bool areVarsEqual(
Expr *VarExpr1,
Expr *VarExpr2) {
1844 if (isa<ArraySectionExpr>(VarExpr1)) {
1845 auto *Expr2AS = dyn_cast<ArraySectionExpr>(VarExpr2);
1849 auto *Expr1AS = cast<ArraySectionExpr>(VarExpr1);
1851 if (!areVarsEqual(Expr1AS->getBase(), Expr2AS->getBase()))
1859 if (isa<ArraySubscriptExpr>(VarExpr1)) {
1860 auto *Expr2AS = dyn_cast<ArraySubscriptExpr>(VarExpr2);
1864 auto *Expr1AS = cast<ArraySubscriptExpr>(VarExpr1);
1866 if (!areVarsEqual(Expr1AS->getBase(), Expr2AS->getBase()))
1876 if (isa<DeclRefExpr>(VarExpr1)) {
1877 auto *Expr2DRE = dyn_cast<DeclRefExpr>(VarExpr2);
1881 auto *Expr1DRE = cast<DeclRefExpr>(VarExpr1);
1883 return Expr1DRE->getDecl()->getMostRecentDecl() ==
1884 Expr2DRE->getDecl()->getMostRecentDecl();
1887 llvm_unreachable(
"Unknown variable type encountered");
1908 if (
const auto *DevTypeClause = llvm::find_if(
1909 ExistingClauses, llvm::IsaPred<OpenACCDeviceTypeClause>);
1910 DevTypeClause != ExistingClauses.end()) {
1911 if (checkValidAfterDeviceType(
1912 *
this, *cast<OpenACCDeviceTypeClause>(*DevTypeClause), Clause))
1916 SemaOpenACCClauseVisitor Visitor{*
this, ExistingClauses};
1919 "Created wrong clause?");
1946 if (
auto *ASE = dyn_cast<ArraySectionExpr>(VarExpr)) {
1950 << diag::OACCReductionArray::Section << BaseType;
1951 Notes.push_back({ASE->getBeginLoc(), PD});
1954 }
else if (
auto *SubExpr = dyn_cast<ArraySubscriptExpr>(VarExpr)) {
1958 PDiag(diag::note_acc_reduction_array)
1959 << diag::OACCReductionArray::Subscript
1960 << SubExpr->getBase()->IgnoreParenImpCasts()->getType();
1961 Notes.push_back({SubExpr->getBeginLoc(), PD});
1962 }
else if (
auto *AT =
getASTContext().getAsArrayType(CurType)) {
1967 << diag::OACCReductionArray::ArrayTy << CurType;
1968 Notes.push_back({VarLoc, PD});
1971 auto IsValidMemberOfComposite = [](
QualType Ty) {
1972 return !Ty->isAnyComplexType() &&
1973 (Ty->isDependentType() ||
1974 (Ty->isScalarType() && !Ty->isPointerType()));
1980 for (
auto [
Loc, PD] : Notes)
1983 Diag(VarLoc, diag::note_acc_reduction_type_summary);
1987 if (IsValidMemberOfComposite(CurType)) {
1990 if (!RD->isStruct() && !RD->isClass()) {
1991 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1992 << RD << diag::OACCReductionTy::NotClassStruct);
1996 if (!RD->isCompleteDefinition()) {
1997 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1998 << RD << diag::OACCReductionTy::NotComplete);
2002 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD);
2003 CXXRD && !CXXRD->isAggregate()) {
2004 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
2005 << CXXRD << diag::OACCReductionTy::NotAgg);
2010 if (!IsValidMemberOfComposite(FD->getType())) {
2012 PDiag(diag::note_acc_reduction_member_of_composite)
2013 << FD->getName() << RD->getName();
2014 Notes.push_back({FD->getBeginLoc(), PD});
2016 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
2018 << diag::OACCReductionTy::MemberNotScalar);
2023 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
2024 << CurType << diag::OACCReductionTy::NotScalar);
2032 if (RClause->getReductionOp() == ReductionOp)
2035 for (
Expr *OldVarExpr : RClause->getVarList()) {
2036 if (OldVarExpr->isInstantiationDependent())
2039 if (areVarsEqual(VarExpr, OldVarExpr)) {
2041 << ReductionOp << RClause->getReductionOp();
2042 Diag(OldVarExpr->getExprLoc(), diag::note_acc_previous_clause_here)
2043 << RClause->getClauseKind();
2059 "size argument non integer?");
2063 isa<OpenACCAsteriskSizeExpr>(SizeExpr))
2066 std::optional<llvm::APSInt> ICE =
2071 if (!ICE || *ICE <= 0) {
2073 << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue();
2087 "Loop argument non integer?");
2093 std::optional<llvm::APSInt> ICE =
2099 if (!ICE || *ICE <= 0) {
2101 << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue();
2119 return CheckGangParallelExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2122 return CheckGangSerialExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2125 return CheckGangKernelsExpr(*
this, ExistingClauses, DK,
2126 ActiveComputeConstructInfo.Kind, GK,
E);
2128 return CheckGangRoutineExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2131 switch (ActiveComputeConstructInfo.Kind) {
2135 return CheckGangParallelExpr(*
this, DK, ActiveComputeConstructInfo.Kind,
2139 return CheckGangSerialExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2143 return CheckGangKernelsExpr(*
this, ExistingClauses, DK,
2144 ActiveComputeConstructInfo.Kind, GK,
E);
2146 llvm_unreachable(
"Non compute construct in active compute construct?");
2155 llvm_unreachable(
"Invalid directive kind for a Gang clause");
2157 llvm_unreachable(
"Compute construct directive not handled?");
2171 const auto *ReductionItr =
2172 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
2174 if (ReductionItr != ExistingClauses.end()) {
2175 const auto GangZip = llvm::zip_equal(GangKinds, IntExprs);
2176 const auto GangItr = llvm::find_if(GangZip, [](
const auto &Tuple) {
2180 if (GangItr != GangZip.end()) {
2181 const Expr *DimExpr = std::get<1>(*GangItr);
2184 isa<ConstantExpr>(DimExpr)) &&
2185 "Improperly formed gang argument");
2186 if (
const auto *DimVal = dyn_cast<ConstantExpr>(DimExpr);
2187 DimVal && DimVal->getResultAsAPSInt() > 1) {
2188 Diag(DimVal->getBeginLoc(), diag::err_acc_gang_reduction_conflict)
2190 Diag((*ReductionItr)->getBeginLoc(),
2191 diag::note_acc_previous_clause_here)
2192 << (*ReductionItr)->getClauseKind();
2200 GangKinds, IntExprs, EndLoc);
2214 const auto GangClauses = llvm::make_filter_range(
2215 ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
2217 for (
auto *GC : GangClauses) {
2218 const auto *GangClause = cast<OpenACCGangClause>(GC);
2219 for (
unsigned I = 0; I < GangClause->getNumExprs(); ++I) {
2220 std::pair<OpenACCGangKind, const Expr *> EPair = GangClause->getExpr(I);
2224 if (
const auto *DimVal = dyn_cast<ConstantExpr>(EPair.second);
2225 DimVal && DimVal->getResultAsAPSInt() > 1) {
2226 Diag(BeginLoc, diag::err_acc_gang_reduction_conflict)
2227 << 1 << DirectiveKind;
2228 Diag(GangClause->getBeginLoc(), diag::note_acc_previous_clause_here)
2229 << GangClause->getClauseKind();
2237 getASTContext(), BeginLoc, LParenLoc, ReductionOp, Vars, Recipes, EndLoc);
2247 if (isa<NamespaceDecl, TranslationUnitDecl>(DC))
2252 for (
Expr *VarExpr : VarExprs) {
2253 if (isa<DependentScopeDeclRefExpr, CXXDependentScopeMemberExpr>(VarExpr)) {
2254 NewVarList.push_back(VarExpr);
2262 if (isa<MemberExpr>(VarExpr)) {
2263 NewVarList.push_back(VarExpr);
2267 const auto *DRE = cast<DeclRefExpr>(VarExpr);
2268 const VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl());
2271 Diag(VarExpr->getBeginLoc(), diag::err_acc_link_not_extern);
2273 NewVarList.push_back(VarExpr);
2288 bool IsSpecialClause =
2299 if (!IsSpecialClause && isa<NamespaceDecl, TranslationUnitDecl>(DC)) {
2300 return Diag(Clause.
getBeginLoc(), diag::err_acc_declare_clause_at_global)
2307 if (isa<DependentScopeDeclRefExpr, CXXDependentScopeMemberExpr>(VarExpr)) {
2310 }
else if (
const auto *MemExpr = dyn_cast<MemberExpr>(VarExpr)) {
2312 cast<FieldDecl>(MemExpr->getMemberDecl()->getCanonicalDecl());
2315 if (removeLinkageSpecDC(
2317 Diag(MemExpr->getBeginLoc(), diag::err_acc_declare_same_scope)
2323 const Expr *VarExprTemp = VarExpr;
2325 while (
const auto *ASE = dyn_cast<ArraySectionExpr>(VarExprTemp))
2328 const auto *DRE = cast<DeclRefExpr>(VarExprTemp);
2329 if (
const auto *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
2339 if (removeLinkageSpecDC(
2340 Var->getLexicalDeclContext()->getPrimaryContext()) != DC) {
2341 Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_same_scope)
2349 if (!IsSpecialClause && Var->hasExternalStorage()) {
2350 Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_extern)
2361 auto [Itr, Inserted] = DeclareVarReferences.try_emplace(CurDecl);
2363 Diag(VarExpr->getBeginLoc(), diag::err_acc_multiple_references)
2365 Diag(Itr->second, diag::note_acc_previous_reference);
2368 Itr->second = VarExpr->getBeginLoc();
2372 FilteredVarList.push_back(VarExpr);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines some OpenACC-specific enums and functions.
This file declares semantic analysis for OpenACC constructs and clauses.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Represents a ValueDecl that came out of a declarator.
This represents one expression.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a member of a struct/union/class.
A simple pair of identifier info and location.
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCBindClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, const IdentifierInfo *ID, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
OpenACCClauseKind getClauseKind() const
SourceLocation getBeginLoc() const
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceResidentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCFirstPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCGangClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< OpenACCGangKind > GangKinds, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCLinkClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNoHostClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, 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 OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< VarDecl * > InitRecipes, SourceLocation EndLoc)
static OpenACCReductionClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCReductionOperator Operator, ArrayRef< Expr * > VarList, ArrayRef< OpenACCReductionRecipe > Recipes, SourceLocation EndLoc)
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A (possibly-)qualified type.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ASTContext & getASTContext() const
DeclContext * getCurContext() const
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
void setVarListDetails(ArrayRef< Expr * > VarList, OpenACCModifierKind ModKind)
ArrayRef< Expr * > getIntExprs()
ArrayRef< Expr * > getQueueIdExprs() const
OpenACCDirectiveKind getDirectiveKind() const
ArrayRef< OpenACCGangKind > getGangKinds() const
OpenACCReductionOperator getReductionOp() const
SourceLocation getEndLoc() const
OpenACCClauseKind getClauseKind() const
const Expr * getConditionExpr() const
SourceLocation getLParenLoc() const
ArrayRef< DeviceTypeArgument > getDeviceTypeArchitectures() const
std::variant< std::monostate, clang::StringLiteral *, IdentifierInfo * > getBindDetails() const
SourceLocation getBeginLoc() const
SourceLocation getQueuesLoc() const
OpenACCModifierKind getModifierList() const
Expr * getDevNumExpr() const
ArrayRef< Expr * > getVarList()
unsigned getNumIntExprs() const
Expr * getLoopCount() const
OpenACCDefaultClauseKind getDefaultClauseKind() const
bool CheckDeclareClause(SemaOpenACC::OpenACCParsedClause &Clause, OpenACCModifierKind Mods)
ComputeConstructInfo & getActiveComputeConstructInfo()
OpenACCClause * CheckReductionClause(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCDirectiveKind DirectiveKind, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCReductionOperator ReductionOp, ArrayRef< Expr * > Vars, ArrayRef< OpenACCReductionRecipe > Recipes, SourceLocation EndLoc)
SourceLocation LoopWorkerClauseLoc
If there is a current 'active' loop construct with a 'worker' clause on it (on any sort of construct)...
OpenACCClause * ActOnClause(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCParsedClause &Clause)
Called after parsing an OpenACC Clause so that it can be checked.
bool DiagnoseAllowedOnceClauses(OpenACCDirectiveKind DK, OpenACCClauseKind CK, SourceLocation ClauseLoc, ArrayRef< const OpenACCClause * > Clauses)
bool DiagnoseExclusiveClauses(OpenACCDirectiveKind DK, OpenACCClauseKind CK, SourceLocation ClauseLoc, ArrayRef< const OpenACCClause * > Clauses)
bool CheckVarIsPointerType(OpenACCClauseKind ClauseKind, Expr *VarExpr)
Called to check the 'var' type is a variable of pointer type, necessary for 'deviceptr' and 'attach' ...
struct clang::SemaOpenACC::LoopGangOnKernelTy LoopGangClauseOnKernel
ExprResult CheckReductionVar(OpenACCDirectiveKind DirectiveKind, OpenACCReductionOperator ReductionOp, Expr *VarExpr)
Called while semantically analyzing the reduction clause, ensuring the var is the correct kind of ref...
llvm::SmallVector< Expr * > CheckLinkClauseVarList(ArrayRef< Expr * > VarExpr)
ExprResult CheckCollapseLoopCount(Expr *LoopCount)
Checks the loop depth value for a collapse clause.
SourceLocation LoopVectorClauseLoc
If there is a current 'active' loop construct with a 'vector' clause on it (on any sort of construct)...
ExprResult CheckGangExpr(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCDirectiveKind DK, OpenACCGangKind GK, Expr *E)
OpenACCClause * CheckGangClause(OpenACCDirectiveKind DirKind, ArrayRef< const OpenACCClause * > ExistingClauses, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< OpenACCGangKind > GangKinds, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
std::pair< VarDecl *, VarDecl * > CreateInitRecipe(OpenACCClauseKind CK, const Expr *VarExpr)
ExprResult CheckTileSizeExpr(Expr *SizeExpr)
Checks a single size expr for a tile clause.
ASTContext & getASTContext() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getBeginLoc() const LLVM_READONLY
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Represents a variable declaration or definition.
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
StringRef getName(const HeaderType T)
The JSON file list parser is used to communicate input to InstallAPI.
bool isOpenACCComputeDirectiveKind(OpenACCDirectiveKind K)
bool isOpenACCCombinedDirectiveKind(OpenACCDirectiveKind K)
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Link
'link' clause, allowed on 'declare' construct.
@ DeviceResident
'device_resident' clause, allowed on the 'declare' construct.
@ CopyIn
'copyin' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Result
The result type of a method or function.
bool isOpenACCModifierBitSet(OpenACCModifierKind List, OpenACCModifierKind Bit)
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
OpenACCDirectiveKind DirKind