26#include "llvm/ADT/SmallBitVector.h"
27#include "llvm/ADT/StringSwitch.h"
28#include "llvm/Frontend/OpenMP/DirectiveNameParser.h"
29#include "llvm/Frontend/OpenMP/OMPAssume.h"
30#include "llvm/Frontend/OpenMP/OMPContext.h"
34using namespace llvm::omp;
41class DeclDirectiveListParserHelper final {
42 SmallVector<Expr *, 4> Identifiers;
49 void operator()(CXXScopeSpec &SS, DeclarationNameInfo NameInfo) {
50 ExprResult Res = P->getActions().OpenMP().ActOnOpenMPIdExpression(
51 P->getCurScope(), SS, NameInfo, Kind);
53 Identifiers.push_back(Res.
get());
55 llvm::ArrayRef<Expr *> getIdentifiers()
const {
return Identifiers; }
64 auto [D, VR] = getOpenMPDirectiveKindAndVersions(Name);
66 if (D == Directive::OMPD_ordered_blockassoc)
67 D = Directive::OMPD_ordered_standalone;
68 assert(D == Kind &&
"Directive kind mismatch");
72 P.
Diag(Loc, diag::warn_omp_future_directive_spelling) << Name;
78 static const DirectiveNameParser DirParser;
80 const DirectiveNameParser::State *S = DirParser.initial();
83 if (
Tok.isAnnotation())
89 S = DirParser.consume(S, Concat);
93 while (!
Tok.isAnnotation()) {
96 if (!
Tok.isAnnotation()) {
98 S = DirParser.consume(S, TS);
106 assert(S &&
"Should have exited early");
115 bool WithOperator =
false;
116 if (
Tok.is(tok::kw_operator)) {
121 switch (
Tok.getKind()) {
146 case tok::identifier:
151 P.
Diag(
Tok.getLocation(), diag::err_omp_expected_reduction_identifier);
152 P.
SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
158 return OOK ==
OO_None ? DeclNames.getIdentifier(
Tok.getIdentifierInfo())
159 : DeclNames.getCXXOperatorName(OOK);
164 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
167 if (T.expectAndConsume(
168 diag::err_expected_lparen_after,
169 getOpenMPDirectiveName(OMPD_declare_reduction, OMPVersion).data())) {
175 if (Name.
isEmpty() && Tok.is(tok::annot_pragma_openmp_end))
179 bool IsCorrect = !ExpectAndConsume(tok::colon);
181 if (!IsCorrect && Tok.is(tok::annot_pragma_openmp_end))
184 IsCorrect = IsCorrect && !Name.
isEmpty();
186 if (Tok.is(tok::colon) || Tok.is(tok::annot_pragma_openmp_end)) {
187 Diag(Tok.getLocation(), diag::err_expected_type);
191 if (!IsCorrect && Tok.is(tok::annot_pragma_openmp_end))
194 SmallVector<std::pair<QualType, SourceLocation>, 8> ReductionTypes;
201 QualType ReductionType = Actions.OpenMP().ActOnOpenMPDeclareReductionType(
202 Range.getBegin(), TR);
203 if (!ReductionType.
isNull()) {
204 ReductionTypes.push_back(
205 std::make_pair(ReductionType,
Range.getBegin()));
208 SkipUntil(tok::comma, tok::colon, tok::annot_pragma_openmp_end,
212 if (Tok.is(tok::colon) || Tok.is(tok::annot_pragma_openmp_end))
216 if (ExpectAndConsume(tok::comma)) {
218 if (Tok.is(tok::annot_pragma_openmp_end)) {
219 Diag(Tok.getLocation(), diag::err_expected_type);
223 }
while (Tok.isNot(tok::annot_pragma_openmp_end));
225 if (ReductionTypes.empty()) {
230 if (!IsCorrect && Tok.is(tok::annot_pragma_openmp_end))
234 if (ExpectAndConsume(tok::colon))
237 if (Tok.is(tok::annot_pragma_openmp_end)) {
238 Diag(Tok.getLocation(), diag::err_expected_expression);
243 Actions.OpenMP().ActOnOpenMPDeclareReductionDirectiveStart(
244 getCurScope(), Actions.getCurLexicalContext(), Name, ReductionTypes,
249 unsigned I = 0, E = ReductionTypes.size();
250 for (Decl *D : DRD.get()) {
251 TentativeParsingAction TPA(*
this);
256 Actions.OpenMP().ActOnOpenMPDeclareReductionCombinerStart(
getCurScope(), D);
257 ExprResult CombinerResult = Actions.ActOnFinishFullExpr(
259 Actions.OpenMP().ActOnOpenMPDeclareReductionCombinerEnd(
260 D, CombinerResult.
get());
262 if (CombinerResult.
isInvalid() && Tok.isNot(tok::r_paren) &&
263 Tok.isNot(tok::annot_pragma_openmp_end)) {
268 IsCorrect = !T.consumeClose() && IsCorrect && CombinerResult.
isUsable();
270 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
272 if (Tok.is(tok::identifier) &&
273 Tok.getIdentifierInfo()->isStr(
"initializer")) {
276 Diag(Tok.getLocation(), diag::err_expected) <<
"'initializer'";
283 tok::annot_pragma_openmp_end);
285 !T.expectAndConsume(diag::err_expected_lparen_after,
"initializer") &&
287 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
292 VarDecl *OmpPrivParm =
293 Actions.OpenMP().ActOnOpenMPDeclareReductionInitializerStart(
296 if (Tok.is(tok::identifier) &&
297 Tok.getIdentifierInfo()->isStr(
"omp_priv")) {
299 ParseOpenMPReductionInitializerForDecl(OmpPrivParm);
301 InitializerResult = Actions.ActOnFinishFullExpr(
305 Actions.OpenMP().ActOnOpenMPDeclareReductionInitializerEnd(
306 D, InitializerResult.
get(), OmpPrivParm);
307 if (InitializerResult.
isInvalid() && Tok.isNot(tok::r_paren) &&
308 Tok.isNot(tok::annot_pragma_openmp_end)) {
314 !T.consumeClose() && IsCorrect && !InitializerResult.
isInvalid();
326 return Actions.OpenMP().ActOnOpenMPDeclareReductionDirectiveEnd(
330void Parser::ParseOpenMPReductionInitializerForDecl(
VarDecl *OmpPrivParm) {
333 if (isTokenEqualOrEqualTypo()) {
336 if (Tok.is(tok::code_completion)) {
338 Actions.CodeCompletion().CodeCompleteInitializer(
getCurScope(),
340 Actions.FinalizeDeclaration(OmpPrivParm);
344 PreferredType.enterVariableInit(Tok.getLocation(), OmpPrivParm);
347 if (
Init.isInvalid()) {
349 Actions.ActOnInitializerError(OmpPrivParm);
351 Actions.AddInitializerToDecl(OmpPrivParm,
Init.get(),
354 }
else if (Tok.is(tok::l_paren)) {
361 SourceLocation LParLoc = T.getOpenLocation();
362 auto RunSignatureHelp = [
this, OmpPrivParm, LParLoc, &Exprs]() {
363 QualType PreferredType =
364 Actions.CodeCompletion().ProduceConstructorSignatureHelp(
366 OmpPrivParm->
getLocation(), Exprs, LParLoc,
false);
367 CalledSignatureHelp =
true;
368 return PreferredType;
370 if (ParseExpressionList(Exprs, [&] {
371 PreferredType.enterFunctionArgument(Tok.getLocation(),
374 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
376 Actions.ActOnInitializerError(OmpPrivParm);
380 SourceLocation RLoc = Tok.getLocation();
381 if (!T.consumeClose())
382 RLoc = T.getCloseLocation();
385 Actions.ActOnParenListExpr(T.getOpenLocation(), RLoc, Exprs);
386 Actions.AddInitializerToDecl(OmpPrivParm,
Initializer.get(),
391 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
395 if (
Init.isInvalid()) {
396 Actions.ActOnInitializerError(OmpPrivParm);
398 Actions.AddInitializerToDecl(OmpPrivParm,
Init.get(),
402 Actions.ActOnUninitializedDecl(OmpPrivParm);
408 bool IsCorrect =
true;
409 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
412 if (T.expectAndConsume(
413 diag::err_expected_lparen_after,
414 getOpenMPDirectiveName(OMPD_declare_mapper, OMPVersion).data())) {
420 auto &DeclNames = Actions.getASTContext().DeclarationNames;
421 DeclarationName MapperId;
422 if (PP.LookAhead(0).is(tok::colon)) {
423 if (Tok.isNot(tok::identifier) && Tok.isNot(tok::kw_default)) {
424 Diag(Tok.getLocation(), diag::err_omp_mapper_illegal_identifier);
427 MapperId = DeclNames.getIdentifier(Tok.getIdentifierInfo());
431 ExpectAndConsume(tok::colon);
435 DeclNames.getIdentifier(&Actions.getASTContext().Idents.get(
"default"));
438 if (!IsCorrect && Tok.is(tok::annot_pragma_openmp_end))
442 DeclarationName VName;
447 MapperType = Actions.OpenMP().ActOnOpenMPDeclareMapperType(
Range.getBegin(),
457 IsCorrect &= !T.consumeClose();
465 DeclarationNameInfo DirName;
466 SourceLocation Loc = Tok.getLocation();
469 ParseScope OMPDirectiveScope(
this, ScopeFlags);
470 Actions.OpenMP().StartOpenMPDSABlock(OMPD_declare_mapper, DirName,
475 Actions.OpenMP().ActOnOpenMPDeclareMapperDirectiveVarDecl(
479 SmallVector<OMPClause *, 6> Clauses;
480 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
483 : getOpenMPClauseKind(PP.getSpelling(Tok));
484 Actions.OpenMP().StartOpenMPClause(CKind);
486 ParseOpenMPClause(OMPD_declare_mapper, CKind, Clauses.empty());
488 Clauses.push_back(Clause);
492 if (Tok.is(tok::comma))
494 Actions.OpenMP().EndOpenMPClause();
496 if (Clauses.empty()) {
497 Diag(Tok, diag::err_omp_expected_clause)
498 << getOpenMPDirectiveName(OMPD_declare_mapper, OMPVersion);
507 DeclGroupPtrTy DG = Actions.OpenMP().ActOnOpenMPDeclareMapperDirective(
508 OuterScope, Actions.getCurLexicalContext(), MapperId, MapperType,
509 Range.getBegin(), VName, AS, MapperVarRef.
get(), Clauses);
511 Actions.OpenMP().EndOpenMPDSABlock(
nullptr);
512 OMPDirectiveScope.Exit();
523 Parser::DeclSpecContext DSC = Parser::DeclSpecContext::DSC_type_specifier;
524 DeclSpec DS(AttrFactory);
525 ParseSpecifierQualifierList(DS, AS, DSC);
530 ParseDeclarator(DeclaratorInfo);
531 Range = DeclaratorInfo.getSourceRange();
532 if (DeclaratorInfo.getIdentifier() ==
nullptr) {
533 Diag(Tok.getLocation(), diag::err_omp_mapper_expected_declarator);
536 Name = Actions.GetNameForDeclarator(DeclaratorInfo).getName();
538 return Actions.OpenMP().ActOnOpenMPDeclareMapperVarDecl(
getCurScope(),
550 Actions.OpenMP().getOMPTraitInfoForSurroundingScope();
553 if (parseOMPDeclareVariantMatchClause(Loc, TI, ParentTI)) {
557 (void)ConsumeAnnotationToken();
562 skipUntilPragmaOpenMPEnd(OMPD_begin_declare_variant);
566 VariantMatchInfo VMI;
570 Loc](StringRef ISATrait) {
573 Diag(Loc, diag::warn_unknown_declare_variant_isa_trait) << ISATrait;
576 ASTCtx, std::move(DiagUnknownTrait),
579 Actions.OpenMP().getOpenMPDeviceNum());
581 if (isVariantApplicableInContext(VMI, OMPCtx,
583 Actions.OpenMP().ActOnOpenMPBeginDeclareVariant(Loc, TI);
588 unsigned Nesting = 1;
592 DKLoc = Tok.getLocation();
594 if (DK == OMPD_end_declare_variant)
596 else if (DK == OMPD_begin_declare_variant)
598 if (!Nesting || isEofOrEom())
603 parseOMPEndDirective(OMPD_begin_declare_variant, OMPD_end_declare_variant, DK,
614class FNContextRAII final {
618 bool HasFunScope =
false;
619 FNContextRAII() =
delete;
620 FNContextRAII(
const FNContextRAII &) =
delete;
621 FNContextRAII &operator=(
const FNContextRAII &) =
delete;
625 Decl *D = *Ptr.get().begin();
668 bool IsError =
false;
669 while (
Tok.isNot(tok::annot_pragma_openmp_end)) {
670 if (
Tok.isNot(tok::identifier))
672 OMPDeclareSimdDeclAttr::BranchStateTy Out;
674 StringRef ClauseName = II->
getName();
676 if (OMPDeclareSimdDeclAttr::ConvertStrToBranchStateTy(ClauseName, Out)) {
677 if (BS != OMPDeclareSimdDeclAttr::BS_Undefined && BS != Out) {
678 P.
Diag(
Tok, diag::err_omp_declare_simd_inbranch_notinbranch)
680 << OMPDeclareSimdDeclAttr::ConvertBranchStateTyToStr(BS) << BSRange;
686 }
else if (ClauseName ==
"simdlen") {
688 llvm::omp::Version OMPVersion =
690 P.
Diag(
Tok, diag::err_omp_more_one_clause)
691 << getOpenMPDirectiveName(OMPD_declare_simd, OMPVersion)
702 if (CKind == OMPC_uniform || CKind == OMPC_aligned ||
703 CKind == OMPC_linear) {
706 if (CKind == OMPC_aligned) {
708 }
else if (CKind == OMPC_linear) {
709 Data.ExtraModifier = OMPC_LINEAR_val;
716 getOpenMPClauseKind(ClauseName), *Vars,
Data,
719 if (CKind == OMPC_aligned) {
720 Alignments.append(Aligneds.size() - Alignments.size(),
721 Data.DepModOrTailExpr);
722 }
else if (CKind == OMPC_linear) {
723 assert(0 <=
Data.ExtraModifier &&
725 "Unexpected linear modifier.");
728 Data.ExtraModifierLoc))
729 Data.ExtraModifier = OMPC_LINEAR_val;
730 LinModifiers.append(Linears.size() - LinModifiers.size(),
732 Steps.append(Linears.size() - Steps.size(),
Data.DepModOrTailExpr);
739 if (
Tok.is(tok::comma))
748 PP.EnterToken(Tok,
true);
749 PP.EnterTokenStream(Toks,
true,
755 FNContextRAII FnContext(*
this, Ptr);
756 OMPDeclareSimdDeclAttr::BranchStateTy BS =
757 OMPDeclareSimdDeclAttr::BS_Undefined;
759 SmallVector<Expr *, 4> Uniforms;
760 SmallVector<Expr *, 4> Aligneds;
761 SmallVector<Expr *, 4> Alignments;
762 SmallVector<Expr *, 4> Linears;
763 SmallVector<unsigned, 4> LinModifiers;
764 SmallVector<Expr *, 4> Steps;
767 Alignments, Linears, LinModifiers, Steps);
768 skipUntilPragmaOpenMPEnd(OMPD_declare_simd);
770 SourceLocation EndLoc = ConsumeAnnotationToken();
773 return Actions.OpenMP().ActOnOpenMPDeclareSimdDirective(
774 Ptr, BS, Simdlen.
get(), Uniforms, Aligneds, Alignments, Linears,
775 LinModifiers, Steps, SourceRange(Loc, EndLoc));
782 CONTEXT_SELECTOR_SET_LVL = 0,
783 CONTEXT_SELECTOR_LVL = 1,
784 CONTEXT_TRAIT_LVL = 2,
787static StringRef stringLiteralParser(
Parser &P) {
794 if (
Tok.
is(tok::identifier) ||
Tok.
is(tok::kw_for)) {
802 return stringLiteralParser(P);
805 diag::warn_omp_declare_variant_string_literal_or_identifier)
810static bool checkForDuplicates(
Parser &P, StringRef Name,
812 llvm::StringMap<SourceLocation> &Seen,
814 auto Res = Seen.try_emplace(Name, NameLoc);
820 P.
Diag(NameLoc, diag::warn_omp_declare_variant_ctx_mutiple_use)
822 P.
Diag(Res.first->getValue(), diag::note_omp_declare_variant_ctx_used_here)
828void Parser::parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
829 llvm::omp::TraitSet
Set,
831 llvm::StringMap<SourceLocation> &Seen) {
832 TIProperty.
Kind = TraitProperty::invalid;
834 SourceLocation NameLoc = Tok.getLocation();
836 if (Selector == llvm::omp::TraitSelector::target_device_device_num) {
838 TIProperty.
Kind = getOpenMPContextTraitPropertyKind(
Set, Selector, Name);
840 if (DeviceNumExprResult.
isUsable()) {
841 Expr *DeviceNumExpr = DeviceNumExprResult.
get();
842 Actions.OpenMP().ActOnOpenMPDeviceNum(DeviceNumExpr);
846 Name = getNameFromIdOrString(*
this, Tok, CONTEXT_TRAIT_LVL);
848 Diag(Tok.getLocation(), diag::note_omp_declare_variant_ctx_options)
849 << CONTEXT_TRAIT_LVL << listOpenMPContextTraitProperties(
Set, Selector);
854 TIProperty.
Kind = getOpenMPContextTraitPropertyKind(
Set, Selector, Name);
855 if (TIProperty.
Kind != TraitProperty::invalid) {
856 if (checkForDuplicates(*
this, Name, NameLoc, Seen, CONTEXT_TRAIT_LVL))
857 TIProperty.
Kind = TraitProperty::invalid;
863 Diag(NameLoc, diag::warn_omp_declare_variant_ctx_not_a_property)
864 << Name << getOpenMPContextTraitSelectorName(Selector)
865 << getOpenMPContextTraitSetName(
Set);
867 TraitSet SetForName = getOpenMPContextTraitSetKind(Name);
868 if (SetForName != TraitSet::invalid) {
869 Diag(NameLoc, diag::note_omp_declare_variant_ctx_is_a)
870 << Name << CONTEXT_SELECTOR_SET_LVL << CONTEXT_TRAIT_LVL;
871 Diag(NameLoc, diag::note_omp_declare_variant_ctx_try)
872 << Name <<
"<selector-name>"
873 <<
"(<property-name>)";
876 TraitSelector SelectorForName =
877 getOpenMPContextTraitSelectorKind(Name, SetForName);
878 if (SelectorForName != TraitSelector::invalid) {
879 Diag(NameLoc, diag::note_omp_declare_variant_ctx_is_a)
880 << Name << CONTEXT_SELECTOR_LVL << CONTEXT_TRAIT_LVL;
881 bool AllowsTraitScore =
false;
882 bool RequiresProperty =
false;
883 isValidTraitSelectorForTraitSet(
884 SelectorForName, getOpenMPContextTraitSetForSelector(SelectorForName),
885 AllowsTraitScore, RequiresProperty);
886 Diag(NameLoc, diag::note_omp_declare_variant_ctx_try)
887 << getOpenMPContextTraitSetName(
888 getOpenMPContextTraitSetForSelector(SelectorForName))
889 << Name << (RequiresProperty ?
"(<property-name>)" :
"");
892 for (
const auto &PotentialSet :
893 {TraitSet::construct, TraitSet::user, TraitSet::implementation,
894 TraitSet::device, TraitSet::target_device}) {
895 TraitProperty PropertyForName =
896 getOpenMPContextTraitPropertyKind(PotentialSet, Selector, Name);
897 if (PropertyForName == TraitProperty::invalid)
899 Diag(NameLoc, diag::note_omp_declare_variant_ctx_try)
900 << getOpenMPContextTraitSetName(
901 getOpenMPContextTraitSetForProperty(PropertyForName))
902 << getOpenMPContextTraitSelectorName(
903 getOpenMPContextTraitSelectorForProperty(PropertyForName))
904 << (
"(" + Name +
")").str();
907 Diag(NameLoc, diag::note_omp_declare_variant_ctx_options)
908 << CONTEXT_TRAIT_LVL << listOpenMPContextTraitProperties(
Set, Selector);
914 llvm::StringMap<SourceLocation> &Seen) {
915 assert(TISelector.
Kind ==
916 llvm::omp::TraitSelector::implementation_extension &&
917 "Only for extension properties, e.g., "
918 "`implementation={extension(PROPERTY)}`");
919 if (TIProperty.
Kind == TraitProperty::invalid)
922 if (TIProperty.
Kind ==
923 TraitProperty::implementation_extension_disable_implicit_base)
926 if (TIProperty.
Kind ==
927 TraitProperty::implementation_extension_allow_templates)
930 if (TIProperty.
Kind ==
931 TraitProperty::implementation_extension_bind_to_declaration)
936 llvm::omp::TraitProperty::implementation_extension_match_all ||
938 llvm::omp::TraitProperty::implementation_extension_match_any ||
940 llvm::omp::TraitProperty::implementation_extension_match_none);
943 if (IsMatchExtension(TIProperty)) {
945 if (IsMatchExtension(SeenProp)) {
946 P.
Diag(Loc, diag::err_omp_variant_ctx_second_match_extension);
947 StringRef SeenName = llvm::omp::getOpenMPContextTraitPropertyName(
950 P.
Diag(SeenLoc, diag::note_omp_declare_variant_ctx_used_here)
951 << CONTEXT_TRAIT_LVL << SeenName;
957 llvm_unreachable(
"Unknown extension property!");
960void Parser::parseOMPContextProperty(OMPTraitSelector &TISelector,
961 llvm::omp::TraitSet
Set,
962 llvm::StringMap<SourceLocation> &Seen) {
963 assert(TISelector.
Kind != TraitSelector::user_condition &&
964 "User conditions are special properties not handled here!");
966 SourceLocation PropertyLoc = Tok.getLocation();
967 OMPTraitProperty TIProperty;
968 parseOMPTraitPropertyKind(TIProperty,
Set, TISelector.
Kind, Seen);
970 if (TISelector.
Kind == llvm::omp::TraitSelector::implementation_extension)
973 TIProperty.
Kind = TraitProperty::invalid;
976 if (TIProperty.
Kind == TraitProperty::invalid) {
977 if (PropertyLoc != Tok.getLocation())
978 Diag(Tok.getLocation(), diag::note_omp_declare_variant_ctx_continue_here)
979 << CONTEXT_TRAIT_LVL;
983 if (isValidTraitPropertyForTraitSetAndSelector(TIProperty.
Kind,
992 Diag(PropertyLoc, diag::warn_omp_ctx_incompatible_property_for_selector)
993 << getOpenMPContextTraitPropertyName(TIProperty.
Kind,
995 << getOpenMPContextTraitSelectorName(TISelector.
Kind)
996 << getOpenMPContextTraitSetName(
Set);
997 Diag(PropertyLoc, diag::note_omp_ctx_compatible_set_and_selector_for_property)
998 << getOpenMPContextTraitPropertyName(TIProperty.
Kind,
1000 << getOpenMPContextTraitSelectorName(
1001 getOpenMPContextTraitSelectorForProperty(TIProperty.
Kind))
1002 << getOpenMPContextTraitSetName(
1003 getOpenMPContextTraitSetForProperty(TIProperty.
Kind));
1004 Diag(Tok.getLocation(), diag::note_omp_declare_variant_ctx_continue_here)
1005 << CONTEXT_TRAIT_LVL;
1008void Parser::parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
1009 llvm::omp::TraitSet
Set,
1010 llvm::StringMap<SourceLocation> &Seen) {
1011 TISelector.
Kind = TraitSelector::invalid;
1013 SourceLocation NameLoc = Tok.getLocation();
1014 StringRef Name = getNameFromIdOrString(*
this, Tok, CONTEXT_SELECTOR_LVL);
1016 Diag(Tok.getLocation(), diag::note_omp_declare_variant_ctx_options)
1017 << CONTEXT_SELECTOR_LVL << listOpenMPContextTraitSelectors(
Set);
1021 TISelector.
Kind = getOpenMPContextTraitSelectorKind(Name,
Set);
1022 if (TISelector.
Kind != TraitSelector::invalid) {
1023 if (checkForDuplicates(*
this, Name, NameLoc, Seen, CONTEXT_SELECTOR_LVL))
1024 TISelector.
Kind = TraitSelector::invalid;
1029 Diag(NameLoc, diag::warn_omp_declare_variant_ctx_not_a_selector)
1030 << Name << getOpenMPContextTraitSetName(
Set);
1032 TraitSet SetForName = getOpenMPContextTraitSetKind(Name);
1033 if (SetForName != TraitSet::invalid) {
1034 Diag(NameLoc, diag::note_omp_declare_variant_ctx_is_a)
1035 << Name << CONTEXT_SELECTOR_SET_LVL << CONTEXT_SELECTOR_LVL;
1036 Diag(NameLoc, diag::note_omp_declare_variant_ctx_try)
1037 << Name <<
"<selector-name>"
1038 <<
"<property-name>";
1041 for (
const auto &PotentialSet :
1042 {TraitSet::construct, TraitSet::user, TraitSet::implementation,
1043 TraitSet::device, TraitSet::target_device}) {
1044 TraitProperty PropertyForName = getOpenMPContextTraitPropertyKind(
1045 PotentialSet, TraitSelector::invalid, Name);
1046 if (PropertyForName == TraitProperty::invalid)
1048 Diag(NameLoc, diag::note_omp_declare_variant_ctx_is_a)
1049 << Name << CONTEXT_TRAIT_LVL << CONTEXT_SELECTOR_LVL;
1050 Diag(NameLoc, diag::note_omp_declare_variant_ctx_try)
1051 << getOpenMPContextTraitSetName(
1052 getOpenMPContextTraitSetForProperty(PropertyForName))
1053 << getOpenMPContextTraitSelectorName(
1054 getOpenMPContextTraitSelectorForProperty(PropertyForName))
1055 << (
"(" + Name +
")").str();
1058 Diag(NameLoc, diag::note_omp_declare_variant_ctx_options)
1059 << CONTEXT_SELECTOR_LVL << listOpenMPContextTraitSelectors(
Set);
1066 StringRef SelectorName =
1068 if (SelectorName !=
"score")
1079 <<
"score expression";
1083void Parser::parseOMPContextSelector(
1084 OMPTraitSelector &TISelector, llvm::omp::TraitSet
Set,
1085 llvm::StringMap<SourceLocation> &SeenSelectors) {
1086 unsigned short OuterPC = ParenCount;
1091 auto FinishSelector = [OuterPC,
this]() ->
void {
1094 while (!
SkipUntil({tok::r_brace, tok::r_paren, tok::comma,
1095 tok::annot_pragma_openmp_end},
1098 if (Tok.is(tok::r_paren) && OuterPC > ParenCount)
1099 (void)ConsumeParen();
1100 if (OuterPC <= ParenCount) {
1104 if (!Tok.is(tok::comma) && !Tok.is(tok::r_paren)) {
1110 Diag(Tok.getLocation(), diag::note_omp_declare_variant_ctx_continue_here)
1111 << CONTEXT_SELECTOR_LVL;
1114 SourceLocation SelectorLoc = Tok.getLocation();
1115 parseOMPTraitSelectorKind(TISelector,
Set, SeenSelectors);
1116 if (TISelector.
Kind == TraitSelector::invalid)
1117 return FinishSelector();
1119 bool AllowsTraitScore =
false;
1120 bool RequiresProperty =
false;
1121 if (!isValidTraitSelectorForTraitSet(TISelector.
Kind,
Set, AllowsTraitScore,
1122 RequiresProperty)) {
1123 Diag(SelectorLoc, diag::warn_omp_ctx_incompatible_selector_for_set)
1124 << getOpenMPContextTraitSelectorName(TISelector.
Kind)
1125 << getOpenMPContextTraitSetName(
Set);
1126 Diag(SelectorLoc, diag::note_omp_ctx_compatible_set_for_selector)
1127 << getOpenMPContextTraitSelectorName(TISelector.
Kind)
1128 << getOpenMPContextTraitSetName(
1129 getOpenMPContextTraitSetForSelector(TISelector.
Kind))
1130 << RequiresProperty;
1131 return FinishSelector();
1134 if (!RequiresProperty) {
1136 {getOpenMPContextTraitPropertyForSelector(TISelector.
Kind),
1137 getOpenMPContextTraitSelectorName(TISelector.
Kind)});
1141 if (!Tok.is(tok::l_paren)) {
1142 Diag(SelectorLoc, diag::warn_omp_ctx_selector_without_properties)
1143 << getOpenMPContextTraitSelectorName(TISelector.
Kind)
1144 << getOpenMPContextTraitSetName(
Set);
1145 return FinishSelector();
1148 if (TISelector.
Kind == TraitSelector::user_condition) {
1149 SourceLocation RLoc;
1152 return FinishSelector();
1155 {TraitProperty::user_condition_unknown,
"<condition>"});
1160 tok::annot_pragma_openmp_end);
1162 (void)BDT.consumeOpen();
1164 SourceLocation ScoreLoc = Tok.getLocation();
1167 if (!AllowsTraitScore && !Score.
isUnset()) {
1169 Diag(ScoreLoc, diag::warn_omp_ctx_incompatible_score_for_property)
1170 << getOpenMPContextTraitSelectorName(TISelector.
Kind)
1171 << getOpenMPContextTraitSetName(
Set) << Score.
get();
1173 Diag(ScoreLoc, diag::warn_omp_ctx_incompatible_score_for_property)
1174 << getOpenMPContextTraitSelectorName(TISelector.
Kind)
1175 << getOpenMPContextTraitSetName(
Set) <<
"<invalid>";
1183 llvm::StringMap<SourceLocation> SeenProperties;
1185 parseOMPContextProperty(TISelector,
Set, SeenProperties);
1192void Parser::parseOMPTraitSetKind(OMPTraitSet &TISet,
1193 llvm::StringMap<SourceLocation> &Seen) {
1194 TISet.
Kind = TraitSet::invalid;
1196 SourceLocation NameLoc = Tok.getLocation();
1197 StringRef Name = getNameFromIdOrString(*
this, Tok, CONTEXT_SELECTOR_SET_LVL);
1199 Diag(Tok.getLocation(), diag::note_omp_declare_variant_ctx_options)
1200 << CONTEXT_SELECTOR_SET_LVL << listOpenMPContextTraitSets();
1204 TISet.
Kind = getOpenMPContextTraitSetKind(Name);
1205 if (TISet.
Kind != TraitSet::invalid) {
1206 if (checkForDuplicates(*
this, Name, NameLoc, Seen,
1207 CONTEXT_SELECTOR_SET_LVL))
1208 TISet.
Kind = TraitSet::invalid;
1213 Diag(NameLoc, diag::warn_omp_declare_variant_ctx_not_a_set) << Name;
1215 TraitSelector SelectorForName =
1216 getOpenMPContextTraitSelectorKind(Name, TISet.
Kind);
1217 if (SelectorForName != TraitSelector::invalid) {
1218 Diag(NameLoc, diag::note_omp_declare_variant_ctx_is_a)
1219 << Name << CONTEXT_SELECTOR_LVL << CONTEXT_SELECTOR_SET_LVL;
1220 bool AllowsTraitScore =
false;
1221 bool RequiresProperty =
false;
1222 isValidTraitSelectorForTraitSet(
1223 SelectorForName, getOpenMPContextTraitSetForSelector(SelectorForName),
1224 AllowsTraitScore, RequiresProperty);
1225 Diag(NameLoc, diag::note_omp_declare_variant_ctx_try)
1226 << getOpenMPContextTraitSetName(
1227 getOpenMPContextTraitSetForSelector(SelectorForName))
1228 << Name << (RequiresProperty ?
"(<property-name>)" :
"");
1231 for (
const auto &PotentialSet :
1232 {TraitSet::construct, TraitSet::user, TraitSet::implementation,
1233 TraitSet::device, TraitSet::target_device}) {
1234 TraitProperty PropertyForName = getOpenMPContextTraitPropertyKind(
1235 PotentialSet, TraitSelector::invalid, Name);
1236 if (PropertyForName == TraitProperty::invalid)
1238 Diag(NameLoc, diag::note_omp_declare_variant_ctx_is_a)
1239 << Name << CONTEXT_TRAIT_LVL << CONTEXT_SELECTOR_SET_LVL;
1240 Diag(NameLoc, diag::note_omp_declare_variant_ctx_try)
1241 << getOpenMPContextTraitSetName(
1242 getOpenMPContextTraitSetForProperty(PropertyForName))
1243 << getOpenMPContextTraitSelectorName(
1244 getOpenMPContextTraitSelectorForProperty(PropertyForName))
1245 << (
"(" + Name +
")").str();
1248 Diag(NameLoc, diag::note_omp_declare_variant_ctx_options)
1249 << CONTEXT_SELECTOR_SET_LVL << listOpenMPContextTraitSets();
1252void Parser::parseOMPContextSelectorSet(
1253 OMPTraitSet &TISet, llvm::StringMap<SourceLocation> &SeenSets) {
1254 auto OuterBC = BraceCount;
1259 auto FinishSelectorSet = [
this, OuterBC]() ->
void {
1262 while (!
SkipUntil({tok::comma, tok::r_brace, tok::r_paren,
1263 tok::annot_pragma_openmp_end},
1266 if (Tok.is(tok::r_brace) && OuterBC > BraceCount)
1267 (void)ConsumeBrace();
1268 if (OuterBC <= BraceCount) {
1272 if (!Tok.is(tok::comma) && !Tok.is(tok::r_brace)) {
1278 Diag(Tok.getLocation(), diag::note_omp_declare_variant_ctx_continue_here)
1279 << CONTEXT_SELECTOR_SET_LVL;
1282 parseOMPTraitSetKind(TISet, SeenSets);
1283 if (TISet.
Kind == TraitSet::invalid)
1284 return FinishSelectorSet();
1288 Diag(Tok.getLocation(), diag::warn_omp_declare_variant_expected)
1290 << (
"context set name \"" + getOpenMPContextTraitSetName(TISet.
Kind) +
1294 if (Tok.is(tok::l_brace)) {
1295 (void)ConsumeBrace();
1297 Diag(Tok.getLocation(), diag::warn_omp_declare_variant_expected)
1299 << (
"'=' that follows the context set name \"" +
1300 getOpenMPContextTraitSetName(TISet.
Kind) +
"\"")
1304 llvm::StringMap<SourceLocation> SeenSelectors;
1306 OMPTraitSelector TISelector;
1307 parseOMPContextSelector(TISelector, TISet.
Kind, SeenSelectors);
1308 if (TISelector.
Kind != TraitSelector::invalid &&
1314 if (Tok.is(tok::r_brace)) {
1315 (void)ConsumeBrace();
1317 Diag(Tok.getLocation(), diag::warn_omp_declare_variant_expected)
1319 << (
"context selectors for the context set \"" +
1320 getOpenMPContextTraitSetName(TISet.
Kind) +
"\"")
1325bool Parser::parseOMPContextSelectors(
SourceLocation Loc, OMPTraitInfo &TI) {
1326 llvm::StringMap<SourceLocation> SeenSets;
1329 parseOMPContextSelectorSet(TISet, SeenSets);
1330 if (TISet.
Kind != TraitSet::invalid && !TISet.
Selectors.empty())
1331 TI.
Sets.push_back(TISet);
1340 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
1341 PP.EnterToken(Tok,
true);
1342 PP.EnterTokenStream(Toks,
true,
1348 FNContextRAII FnContext(*
this, Ptr);
1350 SourceLocation RLoc;
1360 getOpenMPDirectiveName(OMPD_declare_variant, OMPVersion), RLoc,
1363 if (!AssociatedFunction.
isUsable()) {
1364 if (!Tok.is(tok::annot_pragma_openmp_end))
1368 (void)ConsumeAnnotationToken();
1372 OMPTraitInfo *ParentTI =
1373 Actions.OpenMP().getOMPTraitInfoForSurroundingScope();
1374 ASTContext &ASTCtx = Actions.getASTContext();
1376 SmallVector<OMPAdjustArgsDescriptor *, 3> AdjustArgs;
1377 SmallVector<OMPInteropInfo, 3> AppendArgs;
1378 SourceLocation AdjustArgsLoc, AppendArgsLoc;
1381 if (Tok.is(tok::annot_pragma_openmp_end)) {
1382 Diag(Tok.getLocation(), diag::err_omp_declare_variant_wrong_clause)
1386 bool IsError =
false;
1387 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
1390 : getOpenMPClauseKind(PP.getSpelling(Tok));
1391 if (!isAllowedClauseForDirective(OMPD_declare_variant, CKind, OMPVersion)) {
1392 Diag(Tok.getLocation(), diag::err_omp_declare_variant_wrong_clause)
1393 << (OMPVersion < 51 ? 0 : 1);
1399 IsError = parseOMPDeclareVariantMatchClause(Loc, TI, ParentTI);
1401 case OMPC_adjust_args: {
1402 AdjustArgsLoc = Tok.getLocation();
1404 SemaOpenMP::OpenMPVarListDataTy
Data;
1405 SmallVector<Expr *> Vars;
1406 SmallVector<OMPAdjustArgsItem, 4> Items;
1410 for (Expr *E : Vars) {
1411 OMPAdjustArgsItem Item;
1413 Items.push_back(Item);
1419 if (
Data.NeedDevicePtrModifierLoc.isValid())
1421 Data.NeedDevicePtrModifier);
1422 OMPAdjustArgsDescriptor *Desc =
1423 Actions.OpenMP().ActOnOpenMPAdjustArgsClause(
1424 AdjustOp, NeedDevicePtrModifier, Items, AdjustArgsLoc);
1426 AdjustArgs.push_back(Desc);
1432 case OMPC_append_args:
1433 if (!AppendArgs.empty()) {
1434 Diag(AppendArgsLoc, diag::err_omp_more_one_clause)
1435 << getOpenMPDirectiveName(OMPD_declare_variant, OMPVersion)
1436 << getOpenMPClauseName(CKind) << 0;
1440 AppendArgsLoc = Tok.getLocation();
1442 IsError = parseOpenMPAppendArgs(AppendArgs);
1446 llvm_unreachable(
"Unexpected clause for declare variant.");
1453 (void)ConsumeAnnotationToken();
1457 if (Tok.is(tok::comma))
1461 std::optional<std::pair<FunctionDecl *, Expr *>> DeclVarData =
1462 Actions.OpenMP().checkOpenMPDeclareVariantFunction(
1463 Ptr, AssociatedFunction.
get(), TI, AppendArgs.size(),
1464 SourceRange(Loc, Tok.getLocation()));
1466 if (DeclVarData && !TI.
Sets.empty())
1467 Actions.OpenMP().ActOnOpenMPDeclareVariantDirective(
1468 DeclVarData->first, DeclVarData->second, TI, AdjustArgs, AppendArgs,
1469 AdjustArgsLoc, AppendArgsLoc, SourceRange(Loc, Tok.getLocation()));
1472 (void)ConsumeAnnotationToken();
1475bool Parser::parseOpenMPAppendArgs(
1477 bool HasError =
false;
1480 if (T.expectAndConsume(diag::err_expected_lparen_after,
1481 getOpenMPClauseName(OMPC_append_args).data()))
1486 while (Tok.is(tok::identifier) && Tok.getIdentifierInfo()->isStr(
"interop")) {
1489 tok::annot_pragma_openmp_end);
1490 if (IT.expectAndConsume(diag::err_expected_lparen_after,
"interop"))
1493 OMPInteropInfo InteropInfo;
1494 if (ParseOMPInteropInfo(InteropInfo, OMPC_append_args))
1497 InteropInfos.push_back(InteropInfo);
1500 if (Tok.is(tok::comma))
1503 if (!HasError && InteropInfos.empty()) {
1505 Diag(Tok.getLocation(), diag::err_omp_unexpected_append_op);
1506 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
1509 HasError = T.consumeClose() || HasError;
1513bool Parser::parseOMPDeclareVariantMatchClause(
SourceLocation Loc,
1515 OMPTraitInfo *ParentTI) {
1519 : getOpenMPClauseKind(PP.getSpelling(Tok));
1520 if (CKind != OMPC_match) {
1521 Diag(Tok.getLocation(), diag::err_omp_declare_variant_wrong_clause)
1528 if (T.expectAndConsume(diag::err_expected_lparen_after,
1529 getOpenMPClauseName(OMPC_match).data()))
1533 parseOMPContextSelectors(Loc, TI);
1536 (void)T.consumeClose();
1546 for (
const OMPTraitSet &ParentSet : ParentTI->
Sets) {
1547 bool MergedSet =
false;
1548 for (OMPTraitSet &
Set : TI.
Sets) {
1549 if (
Set.Kind != ParentSet.
Kind)
1552 for (
const OMPTraitSelector &ParentSelector : ParentSet.
Selectors) {
1553 bool MergedSelector =
false;
1554 for (OMPTraitSelector &Selector :
Set.Selectors) {
1555 if (Selector.
Kind != ParentSelector.
Kind)
1557 MergedSelector =
true;
1558 for (
const OMPTraitProperty &ParentProperty :
1560 bool MergedProperty =
false;
1574 if (Selector.
Kind == llvm::omp::TraitSelector::user_condition) {
1575 Diag(Loc, diag::err_omp_declare_variant_nested_user_condition);
1578 Diag(Loc, diag::err_omp_declare_variant_duplicate_nested_trait)
1579 << getOpenMPContextTraitPropertyName(
1581 << getOpenMPContextTraitSelectorName(ParentSelector.
Kind)
1582 << getOpenMPContextTraitSetName(ParentSet.
Kind);
1585 if (!MergedProperty)
1586 Selector.
Properties.push_back(ParentProperty);
1589 if (!MergedSelector)
1590 Set.Selectors.push_back(ParentSelector);
1594 TI.
Sets.push_back(ParentSet);
1603 std::bitset<llvm::omp::Clause_enumSize + 1> SeenClauses;
1604 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
1607 : getOpenMPClauseKind(PP.getSpelling(Tok));
1608 if (DKind == OMPD_depobj && CKind == OMPC_update)
1609 CKind = OMPC_update_depend_objects;
1610 Actions.OpenMP().StartOpenMPClause(CKind);
1612 ParseOpenMPClause(DKind, CKind, !SeenClauses[
unsigned(CKind)]);
1613 SkipUntil(tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
1615 SeenClauses[
unsigned(CKind)] =
true;
1616 if (Clause !=
nullptr)
1617 Clauses.push_back(Clause);
1618 if (Tok.is(tok::annot_pragma_openmp_end)) {
1619 Actions.OpenMP().EndOpenMPClause();
1623 if (Tok.is(tok::comma))
1625 Actions.OpenMP().EndOpenMPClause();
1631 SmallVector<std::string, 4> Assumptions;
1632 bool SkippedClauses =
false;
1634 auto SkipBraces = [&](llvm::StringRef Spelling,
bool IssueNote) {
1636 tok::annot_pragma_openmp_end);
1637 if (T.expectAndConsume(diag::err_expected_lparen_after, Spelling.data()))
1640 if (IssueNote && T.getCloseLocation().isValid())
1641 Diag(T.getCloseLocation(),
1642 diag::note_omp_assumption_clause_continue_here);
1648 auto MatchACMClause = [&](StringRef RawString) {
1649 llvm::StringSwitch<int> SS(RawString);
1650 unsigned ACMIdx = 0;
1651 for (
const AssumptionClauseMappingInfo &ACMI : AssumptionClauseMappings) {
1652 if (ACMI.StartsWith)
1653 SS.StartsWith(ACMI.Identifier, ACMIdx++);
1655 SS.Case(ACMI.Identifier, ACMIdx++);
1657 return SS.Default(-1);
1660 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
1661 IdentifierInfo *II =
nullptr;
1662 SourceLocation StartLoc = Tok.getLocation();
1664 if (Tok.isAnyIdentifier()) {
1665 II = Tok.getIdentifierInfo();
1666 Idx = MatchACMClause(II->
getName());
1670 bool NextIsLPar = Tok.is(tok::l_paren);
1673 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
1674 Diag(StartLoc, diag::warn_omp_unknown_assumption_clause_missing_id)
1675 << llvm::omp::getOpenMPDirectiveName(DKind, OMPVersion)
1676 << llvm::omp::getAllAssumeClauseOptions() << NextIsLPar;
1678 SkipBraces(II ? II->
getName() :
"",
true);
1679 SkippedClauses =
true;
1682 const AssumptionClauseMappingInfo &ACMI = AssumptionClauseMappings[Idx];
1683 if (ACMI.HasDirectiveList || ACMI.HasExpression) {
1686 SkippedClauses =
true;
1687 SkipBraces(II->
getName(),
false);
1692 Diag(Tok.getLocation(),
1693 diag::warn_omp_unknown_assumption_clause_without_args)
1695 SkipBraces(II->
getName(),
true);
1698 assert(II &&
"Expected an identifier clause!");
1699 std::string Assumption = II->
getName().str();
1700 if (ACMI.StartsWith)
1701 Assumption =
"ompx_" + Assumption.substr(ACMI.Identifier.size());
1703 Assumption =
"omp_" + Assumption;
1704 Assumptions.push_back(Assumption);
1707 Actions.OpenMP().ActOnOpenMPAssumesDirective(Loc, DKind, Assumptions,
1712 if (Actions.OpenMP().isInOpenMPAssumeScope())
1713 Actions.OpenMP().ActOnOpenMPEndAssumesDirective();
1715 Diag(Loc, diag::err_expected_begin_assumes);
1729struct SimpleClauseData {
1732 SourceLocation LOpen;
1733 SourceLocation TypeLoc;
1734 SourceLocation RLoc;
1735 SimpleClauseData(
unsigned Type, SourceLocation Loc, SourceLocation LOpen,
1736 SourceLocation TypeLoc, SourceLocation RLoc)
1737 :
Type(
Type), Loc(Loc), LOpen(LOpen), TypeLoc(TypeLoc), RLoc(RLoc) {}
1741static std::optional<SimpleClauseData>
1748 if (T.expectAndConsume(diag::err_expected_lparen_after,
1749 getOpenMPClauseName(Kind).data()))
1750 return std::nullopt;
1756 if (
Tok.isNot(tok::r_paren) &&
Tok.isNot(tok::comma) &&
1757 Tok.isNot(tok::annot_pragma_openmp_end))
1762 if (!T.consumeClose())
1763 RLoc = T.getCloseLocation();
1765 return SimpleClauseData(
Type, Loc, LOpen,
TypeLoc, RLoc);
1768void Parser::ParseOMPDeclareTargetClauses(
1770 SourceLocation DeviceTypeLoc;
1771 bool RequiresToLinkLocalOrIndirectClause =
false;
1772 bool HasToLinkLocalOrIndirectClause =
false;
1773 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
1774 OMPDeclareTargetDeclAttr::MapTypeTy MT = OMPDeclareTargetDeclAttr::MT_To;
1775 bool HasIdentifier = Tok.is(tok::identifier);
1776 if (HasIdentifier) {
1778 RequiresToLinkLocalOrIndirectClause =
true;
1779 IdentifierInfo *II = Tok.getIdentifierInfo();
1780 StringRef ClauseName = II->
getName();
1781 bool IsDeviceTypeClause =
1783 getOpenMPClauseKind(ClauseName) == OMPC_device_type;
1785 bool IsIndirectClause =
getLangOpts().OpenMP >= 51 &&
1786 getOpenMPClauseKind(ClauseName) == OMPC_indirect;
1788 if (DTCI.
Indirect && IsIndirectClause) {
1789 llvm::omp::Version OMPVersion =
1790 Actions.getLangOpts().getOpenMPVersion();
1791 Diag(Tok, diag::err_omp_more_one_clause)
1792 << getOpenMPDirectiveName(OMPD_declare_target, OMPVersion)
1793 << getOpenMPClauseName(OMPC_indirect) << 0;
1796 bool IsToEnterLinkOrLocalClause =
1797 OMPDeclareTargetDeclAttr::ConvertStrToMapTypeTy(ClauseName, MT);
1798 assert((!IsDeviceTypeClause || !IsToEnterLinkOrLocalClause) &&
1803 if (
getLangOpts().OpenMP >= 52 && ClauseName ==
"to") {
1804 Diag(Tok, diag::err_omp_declare_target_unexpected_to_clause);
1807 if (
getLangOpts().OpenMP <= 51 && ClauseName ==
"enter") {
1808 Diag(Tok, diag::err_omp_declare_target_unexpected_enter_clause);
1813 if (
getLangOpts().OpenMP < 60 && ClauseName ==
"local") {
1815 ? diag::err_omp_declare_target_unexpected_clause_52
1816 : diag::err_omp_declare_target_unexpected_clause)
1824 if (!IsDeviceTypeClause && !IsIndirectClause &&
1825 DTCI.
Kind == OMPD_begin_declare_target) {
1827 ? diag::err_omp_declare_target_unexpected_clause_52
1828 : diag::err_omp_declare_target_unexpected_clause)
1829 << ClauseName << (
getLangOpts().OpenMP >= 51 ? 3 : 0);
1833 if (!IsDeviceTypeClause && !IsToEnterLinkOrLocalClause &&
1834 !IsIndirectClause) {
1836 ? diag::err_omp_declare_target_unexpected_clause_52
1837 : diag::err_omp_declare_target_unexpected_clause)
1846 if (IsToEnterLinkOrLocalClause || IsIndirectClause)
1847 HasToLinkLocalOrIndirectClause =
true;
1849 if (IsIndirectClause) {
1850 if (!ParseOpenMPIndirectClause(DTCI,
false))
1855 if (IsDeviceTypeClause) {
1856 std::optional<SimpleClauseData> DevTypeData =
1859 if (DeviceTypeLoc.
isValid()) {
1861 Diag(DevTypeData->Loc,
1862 diag::warn_omp_more_one_device_type_clause);
1866 case OMPC_DEVICE_TYPE_any:
1867 DTCI.
DT = OMPDeclareTargetDeclAttr::DT_Any;
1869 case OMPC_DEVICE_TYPE_host:
1870 DTCI.
DT = OMPDeclareTargetDeclAttr::DT_Host;
1872 case OMPC_DEVICE_TYPE_nohost:
1873 DTCI.
DT = OMPDeclareTargetDeclAttr::DT_NoHost;
1876 llvm_unreachable(
"Unexpected device_type");
1878 DeviceTypeLoc = DevTypeData->Loc;
1885 if (DTCI.
Kind == OMPD_declare_target || HasIdentifier) {
1886 auto &&
Callback = [
this, MT, &DTCI](CXXScopeSpec &SS,
1887 DeclarationNameInfo NameInfo) {
1888 NamedDecl *ND = Actions.OpenMP().lookupOpenMPDeclareTargetName(
1892 SemaOpenMP::DeclareTargetContextInfo::MapInfo MI{MT, NameInfo.
getLoc()};
1895 Diag(NameInfo.
getLoc(), diag::err_omp_declare_target_multiple)
1898 if (ParseOpenMPSimpleVarList(OMPD_declare_target,
Callback,
1903 if (Tok.is(tok::l_paren)) {
1905 diag::err_omp_begin_declare_target_unexpected_implicit_to_clause);
1908 if (!HasIdentifier && Tok.isNot(tok::annot_pragma_openmp_end)) {
1911 ? diag::err_omp_declare_target_wrong_clause_after_implicit_enter
1912 : diag::err_omp_declare_target_wrong_clause_after_implicit_to);
1917 if (Tok.is(tok::comma))
1921 if (DTCI.
Indirect && DTCI.
DT != OMPDeclareTargetDeclAttr::DT_Any)
1922 Diag(DeviceTypeLoc, diag::err_omp_declare_target_indirect_device_type);
1925 if (DTCI.
Kind == OMPD_declare_target && RequiresToLinkLocalOrIndirectClause &&
1926 !HasToLinkLocalOrIndirectClause)
1927 Diag(DTCI.
Loc, diag::err_omp_declare_target_missing_required_clause)
1939 if (Tok.is(tok::annot_pragma_openmp_end))
1942 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
1943 Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
1944 << getOpenMPDirectiveName(DKind, OMPVersion);
1945 while (Tok.isNot(tok::annot_pragma_openmp_end))
1954 bool SkipUntilOpenMPEnd) {
1955 int DiagSelection = ExpectedKind == OMPD_end_declare_target ? 0 : 1;
1957 if (FoundKind == ExpectedKind) {
1959 skipUntilPragmaOpenMPEnd(ExpectedKind);
1963 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
1964 Diag(FoundLoc, diag::err_expected_end_declare_target_or_variant)
1966 Diag(BeginLoc, diag::note_matching)
1967 << (
"'#pragma omp " + getOpenMPDirectiveName(BeginKind, OMPVersion) +
"'")
1969 if (SkipUntilOpenMPEnd)
1976 parseOMPEndDirective(BeginDKind, OMPD_end_declare_target, EndDKind, DKLoc,
1980 if (Tok.is(tok::annot_pragma_openmp_end))
1981 ConsumeAnnotationToken();
1987 assert(Tok.isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp) &&
1988 "Not an OpenMP directive!");
1991 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
1996 TentativeParsingAction TPA(*
this);
1997 Loc = ConsumeAnnotationToken();
1999 if (DKind == OMPD_declare_reduction || DKind == OMPD_declare_mapper) {
2004 Toks.push_back(Tok);
2005 while (Cnt && Tok.isNot(tok::eof)) {
2007 if (Tok.isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp))
2009 else if (Tok.is(tok::annot_pragma_openmp_end))
2011 Toks.push_back(Tok);
2016 auto *LP =
new LateParsedPragma(
this, AS);
2018 getCurrentClass().LateParsedDeclarations.push_back(LP);
2023 Loc = ConsumeAnnotationToken();
2028 case OMPD_threadprivate: {
2030 DeclDirectiveListParserHelper Helper(
this, DKind);
2031 if (!ParseOpenMPSimpleVarList(DKind, Helper,
2033 skipUntilPragmaOpenMPEnd(DKind);
2035 ConsumeAnnotationToken();
2036 return Actions.OpenMP().ActOnOpenMPThreadprivateDirective(
2037 Loc, Helper.getIdentifiers());
2041 case OMPD_groupprivate: {
2043 DeclDirectiveListParserHelper Helper(
this, DKind);
2044 if (!ParseOpenMPSimpleVarList(DKind, Helper,
2046 skipUntilPragmaOpenMPEnd(DKind);
2048 ConsumeAnnotationToken();
2049 return Actions.OpenMP().ActOnOpenMPGroupPrivateDirective(
2050 Loc, Helper.getIdentifiers());
2054 case OMPD_allocate: {
2056 DeclDirectiveListParserHelper Helper(
this, DKind);
2057 if (!ParseOpenMPSimpleVarList(DKind, Helper,
2059 SmallVector<OMPClause *, 1> Clauses;
2060 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
2061 std::bitset<llvm::omp::Clause_enumSize + 1> SeenClauses;
2062 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
2064 Tok.isAnnotation() ? OMPC_unknown
2065 : getOpenMPClauseKind(PP.getSpelling(Tok));
2066 Actions.OpenMP().StartOpenMPClause(CKind);
2067 OMPClause *Clause = ParseOpenMPClause(OMPD_allocate, CKind,
2068 !SeenClauses[
unsigned(CKind)]);
2069 SkipUntil(tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
2071 SeenClauses[
unsigned(CKind)] =
true;
2072 if (Clause !=
nullptr)
2073 Clauses.push_back(Clause);
2074 if (Tok.is(tok::annot_pragma_openmp_end)) {
2075 Actions.OpenMP().EndOpenMPClause();
2079 if (Tok.is(tok::comma))
2081 Actions.OpenMP().EndOpenMPClause();
2083 skipUntilPragmaOpenMPEnd(DKind);
2086 ConsumeAnnotationToken();
2087 return Actions.OpenMP().ActOnOpenMPAllocateDirective(
2088 Loc, Helper.getIdentifiers(), Clauses);
2092 case OMPD_requires: {
2094 SmallVector<OMPClause *, 5> Clauses;
2095 llvm::SmallBitVector SeenClauses(llvm::omp::Clause_enumSize + 1);
2096 if (Tok.is(tok::annot_pragma_openmp_end)) {
2097 Diag(Tok, diag::err_omp_expected_clause)
2098 << getOpenMPDirectiveName(OMPD_requires, OMPVersion);
2101 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
2104 : getOpenMPClauseKind(PP.getSpelling(Tok));
2105 Actions.OpenMP().StartOpenMPClause(CKind);
2106 OMPClause *Clause = ParseOpenMPClause(OMPD_requires, CKind,
2107 !SeenClauses[
unsigned(CKind)]);
2108 SkipUntil(tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
2110 SeenClauses[
unsigned(CKind)] =
true;
2111 if (Clause !=
nullptr)
2112 Clauses.push_back(Clause);
2113 if (Tok.is(tok::annot_pragma_openmp_end)) {
2114 Actions.OpenMP().EndOpenMPClause();
2118 if (Tok.is(tok::comma))
2120 Actions.OpenMP().EndOpenMPClause();
2123 if (Clauses.empty()) {
2124 Diag(Tok, diag::err_omp_expected_clause)
2125 << getOpenMPDirectiveName(OMPD_requires, OMPVersion);
2126 ConsumeAnnotationToken();
2129 ConsumeAnnotationToken();
2130 return Actions.OpenMP().ActOnOpenMPRequiresDirective(StartLoc, Clauses);
2133 SmallVector<OMPClause *, 1> Clauses;
2135 ParseOpenMPClauses(DKind, Clauses, StartLoc);
2136 Actions.OpenMP().ActOnOpenMPErrorDirective(Clauses, StartLoc,
2142 case OMPD_begin_assumes:
2145 case OMPD_end_assumes:
2148 case OMPD_declare_reduction:
2150 if (
DeclGroupPtrTy Res = ParseOpenMPDeclareReductionDirective(AS)) {
2151 skipUntilPragmaOpenMPEnd(OMPD_declare_reduction);
2153 ConsumeAnnotationToken();
2157 case OMPD_declare_mapper: {
2159 if (
DeclGroupPtrTy Res = ParseOpenMPDeclareMapperDirective(AS)) {
2161 ConsumeAnnotationToken();
2166 case OMPD_begin_declare_variant: {
2171 ConsumeAnnotationToken();
2175 case OMPD_end_declare_variant: {
2177 if (Actions.OpenMP().isInOpenMPDeclareVariantScope())
2178 Actions.OpenMP().ActOnOpenMPEndDeclareVariant();
2180 Diag(Loc, diag::err_expected_begin_declare_variant);
2182 ConsumeAnnotationToken();
2185 case OMPD_declare_variant:
2186 case OMPD_declare_simd: {
2192 Toks.push_back(Tok);
2194 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
2195 Toks.push_back(Tok);
2198 Toks.push_back(Tok);
2202 if (Tok.isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp)) {
2203 Ptr = ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs, Delayed,
2205 }
else if (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
2209 ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
2210 MaybeParseCXX11Attributes(Attrs);
2211 ParsingDeclSpec PDS(*
this);
2212 Ptr = ParseExternalDeclaration(Attrs, EmptyDeclSpecAttrs, &PDS);
2215 ParseCXXClassMemberDeclarationWithPragmas(AS, Attrs, TagType, Tag);
2219 Diag(Loc, diag::err_omp_decl_in_declare_simd_variant)
2220 << (DKind == OMPD_declare_simd ? 0 : 1);
2224 DeclGroupRef DG =
Ptr.get();
2225 SourceManager &SM = PP.getSourceManager();
2226 if (llvm::none_of(DG, [&](
const Decl *D) {
2229 Diag(Loc, diag::err_omp_decl_in_declare_simd_variant)
2230 << (DKind == OMPD_declare_simd ? 0 : 1);
2234 if (DKind == OMPD_declare_simd)
2235 return ParseOMPDeclareSimdClauses(Ptr, Toks, Loc);
2236 assert(DKind == OMPD_declare_variant &&
2237 "Expected declare variant directive only");
2238 ParseOMPDeclareVariantClauses(Ptr, Toks, Loc);
2241 case OMPD_begin_declare_target:
2242 case OMPD_declare_target: {
2244 bool HasClauses = Tok.isNot(tok::annot_pragma_openmp_end);
2245 SemaOpenMP::DeclareTargetContextInfo DTCI(DKind, DTLoc);
2246 if (DKind == OMPD_declare_target && !HasClauses &&
2248 Diag(DTLoc, diag::warn_omp_deprecated_declare_target_delimited_form);
2250 ParseOMPDeclareTargetClauses(DTCI);
2251 bool HasImplicitMappings = DKind == OMPD_begin_declare_target ||
2258 if (HasImplicitMappings) {
2259 Actions.OpenMP().ActOnStartOpenMPDeclareTargetContext(DTCI);
2263 Actions.OpenMP().ActOnFinishedOpenMPDeclareTargetContext(DTCI);
2264 llvm::SmallVector<Decl *, 4> Decls;
2266 Decls.push_back(It.first);
2267 return Actions.BuildDeclaratorGroup(Decls);
2269 case OMPD_end_declare_target: {
2270 if (!Actions.OpenMP().isInOpenMPDeclareTargetContext()) {
2271 Diag(Tok, diag::err_omp_unexpected_directive)
2272 << 1 << getOpenMPDirectiveName(DKind, OMPVersion);
2275 const SemaOpenMP::DeclareTargetContextInfo &DTCI =
2276 Actions.OpenMP().ActOnOpenMPEndDeclareTargetDirective();
2277 ParseOMPEndDeclareTargetDirective(DTCI.
Kind, DKind, DTCI.
Loc);
2281 Diag(Tok, diag::err_omp_unexpected_directive)
2282 << 1 << getOpenMPDirectiveName(DKind, OMPVersion);
2286 Diag(Tok, diag::err_omp_unknown_directive);
2289 switch (getDirectiveCategory(DKind)) {
2290 case Category::Executable:
2291 case Category::Meta:
2292 case Category::Subsidiary:
2293 case Category::Utility:
2294 Diag(Tok, diag::err_omp_unexpected_directive)
2295 << 1 << getOpenMPDirectiveName(DKind, OMPVersion);
2297 case Category::Declarative:
2298 case Category::Informational:
2302 while (Tok.isNot(tok::annot_pragma_openmp_end))
2308StmtResult Parser::ParseOpenMPExecutableDirective(
2310 bool ReadDirectiveWithinMetadirective) {
2312 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
2314 bool HasAssociatedStatement =
true;
2315 Association Assoc = getDirectiveAssociation(DKind);
2319 if (DKind != OMPD_ordered_standalone && DKind != OMPD_section &&
2320 (Assoc == Association::None || Assoc == Association::Separating)) {
2321 if ((StmtCtx & ParsedStmtContext::AllowStandaloneOpenMPDirectives) ==
2322 ParsedStmtContext()) {
2323 Diag(Tok, diag::err_omp_immediate_directive)
2324 << getOpenMPDirectiveName(DKind, OMPVersion) << 0;
2325 if (DKind == OMPD_error) {
2326 SkipUntil(tok::annot_pragma_openmp_end);
2330 HasAssociatedStatement =
false;
2333 SourceLocation EndLoc;
2334 SmallVector<OMPClause *, 5> Clauses;
2335 llvm::SmallBitVector SeenClauses(llvm::omp::Clause_enumSize + 1);
2336 DeclarationNameInfo DirName;
2343 bool ImplicitClauseAllowed =
false;
2344 if (DKind == OMPD_flush || DKind == OMPD_depobj) {
2346 ImplicitClauseAllowed =
true;
2350 if (DKind == OMPD_critical) {
2352 tok::annot_pragma_openmp_end);
2353 if (!T.consumeOpen()) {
2354 if (Tok.isAnyIdentifier()) {
2356 DeclarationNameInfo(Tok.getIdentifierInfo(), Tok.getLocation());
2359 Diag(Tok, diag::err_omp_expected_identifier_for_critical);
2363 }
else if (DKind == OMPD_cancellation_point || DKind == OMPD_cancel) {
2365 if (Tok.isNot(tok::annot_pragma_openmp_end))
2373 ParseScope OMPDirectiveScope(
this, ScopeFlags);
2374 Actions.OpenMP().StartOpenMPDSABlock(DKind, DirName, Actions.getCurScope(),
2377 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
2380 if (ReadDirectiveWithinMetadirective && Tok.is(tok::r_paren)) {
2381 while (Tok.isNot(tok::annot_pragma_openmp_end))
2385 bool HasImplicitClause =
false;
2386 if (ImplicitClauseAllowed && Tok.is(tok::l_paren)) {
2387 HasImplicitClause =
true;
2390 PP.EnterToken(Tok,
true);
2391 PP.EnterToken(ImplicitTok,
true);
2396 : getOpenMPClauseKind(PP.getSpelling(Tok));
2397 if (DKind == OMPD_depobj && CKind == OMPC_update)
2398 CKind = OMPC_update_depend_objects;
2400 if (HasImplicitClause) {
2401 assert(CKind == OMPC_unknown &&
"Must be unknown implicit clause.");
2402 if (DKind == OMPD_flush) {
2405 assert(DKind == OMPD_depobj &&
"Expected flush or depobj directives.");
2406 CKind = OMPC_depobj;
2410 ImplicitClauseAllowed =
false;
2411 Actions.OpenMP().StartOpenMPClause(CKind);
2412 HasImplicitClause =
false;
2413 SourceLocation ClauseLoc = Tok.getLocation();
2416 ParseOpenMPClause(DKind, CKind, !SeenClauses[
unsigned(CKind)]);
2417 SeenClauses[
unsigned(CKind)] =
true;
2419 Clauses.push_back(Clause);
2422 if (Tok.is(tok::comma))
2424 Actions.OpenMP().EndOpenMPClause();
2428 if (Tok.getLocation() == ClauseLoc) {
2429 skipUntilPragmaOpenMPEnd(DKind);
2434 EndLoc = Tok.getLocation();
2436 ConsumeAnnotationToken();
2438 assert(DKind != OMPD_ordered_blockassoc &&
2439 "Wrong kind for ordered directive");
2440 if (DKind == OMPD_ordered_standalone) {
2443 for (
auto CK : {OMPC_depend, OMPC_doacross}) {
2444 if (SeenClauses[
unsigned(CK)]) {
2445 if ((StmtCtx & ParsedStmtContext::AllowStandaloneOpenMPDirectives) ==
2446 ParsedStmtContext()) {
2447 Diag(Loc, diag::err_omp_immediate_directive)
2448 << getOpenMPDirectiveName(DKind, OMPVersion) << 1
2449 << getOpenMPClauseName(CK);
2451 HasAssociatedStatement =
false;
2455 if (HasAssociatedStatement)
2456 DKind = OMPD_ordered_blockassoc;
2459 if ((DKind == OMPD_tile || DKind == OMPD_stripe) &&
2460 !SeenClauses[
unsigned(OMPC_sizes)]) {
2461 Diag(Loc, diag::err_omp_required_clause)
2462 << getOpenMPDirectiveName(DKind, OMPVersion) <<
"sizes";
2464 if (DKind == OMPD_split && !SeenClauses[
unsigned(OMPC_counts)]) {
2465 Diag(Loc, diag::err_omp_required_clause)
2466 << getOpenMPDirectiveName(DKind, OMPVersion) <<
"counts";
2470 if (HasAssociatedStatement) {
2472 Actions.OpenMP().ActOnOpenMPRegionStart(DKind,
getCurScope());
2478 Sema::CompoundScopeRAII Scope(Actions);
2479 AssociatedStmt = ParseStatement();
2484 Actions.OpenMP().ActOnOpenMPLoopnest(AssociatedStmt.get());
2487 Actions.OpenMP().ActOnOpenMPRegionEnd(AssociatedStmt, Clauses);
2488 }
else if (DKind == OMPD_target_update || DKind == OMPD_target_enter_data ||
2489 DKind == OMPD_target_exit_data) {
2490 Actions.OpenMP().ActOnOpenMPRegionStart(DKind,
getCurScope());
2491 AssociatedStmt = (Sema::CompoundScopeRAII(Actions),
2492 Actions.ActOnCompoundStmt(Loc, Loc, {},
2495 Actions.OpenMP().ActOnOpenMPRegionEnd(AssociatedStmt, Clauses);
2499 DKind, DirName, CancelRegion, Clauses, AssociatedStmt.get(), Loc, EndLoc);
2502 Actions.OpenMP().EndOpenMPDSABlock(
Directive.get());
2503 OMPDirectiveScope.Exit();
2508StmtResult Parser::ParseOpenMPInformationalDirective(
2510 bool ReadDirectiveWithinMetadirective) {
2512 "Unexpected directive category");
2514 bool HasAssociatedStatement =
true;
2516 SmallVector<OMPClause *, 5> Clauses;
2517 llvm::SmallBitVector SeenClauses(llvm::omp::Clause_enumSize + 1);
2518 DeclarationNameInfo DirName;
2521 ParseScope OMPDirectiveScope(
this, ScopeFlags);
2523 Actions.OpenMP().StartOpenMPDSABlock(DKind, DirName, Actions.getCurScope(),
2526 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
2527 if (ReadDirectiveWithinMetadirective && Tok.is(tok::r_paren)) {
2528 while (Tok.isNot(tok::annot_pragma_openmp_end))
2535 : getOpenMPClauseKind(PP.getSpelling(Tok));
2536 Actions.OpenMP().StartOpenMPClause(CKind);
2538 ParseOpenMPClause(DKind, CKind, !SeenClauses[
unsigned(CKind)]);
2539 SeenClauses[
unsigned(CKind)] =
true;
2541 Clauses.push_back(Clause);
2543 if (Tok.is(tok::comma))
2545 Actions.OpenMP().EndOpenMPClause();
2548 SourceLocation EndLoc = Tok.getLocation();
2549 ConsumeAnnotationToken();
2552 if (HasAssociatedStatement) {
2553 Actions.OpenMP().ActOnOpenMPRegionStart(DKind,
getCurScope());
2556 Sema::CompoundScopeRAII Scope(Actions);
2557 AssociatedStmt = ParseStatement();
2560 Actions.OpenMP().ActOnOpenMPRegionEnd(AssociatedStmt, Clauses);
2564 DKind, DirName, Clauses, AssociatedStmt.get(), Loc, EndLoc);
2566 Actions.OpenMP().EndOpenMPDSABlock(
Directive.get());
2567 OMPDirectiveScope.Exit();
2572StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
2573 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective) {
2574 if (!ReadDirectiveWithinMetadirective)
2575 assert(Tok.isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp) &&
2576 "Not an OpenMP directive!");
2579 SourceLocation Loc = ReadDirectiveWithinMetadirective
2581 : ConsumeAnnotationToken();
2582 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
2584 if (ReadDirectiveWithinMetadirective && DKind == OMPD_unknown) {
2585 Diag(Tok, diag::err_omp_unknown_directive);
2591 bool IsExecutable = [&]() {
2592 if (DKind == OMPD_error)
2594 auto Res = getDirectiveCategory(DKind);
2595 return Res == Category::Executable || Res == Category::Subsidiary;
2599 Directive = ParseOpenMPExecutableDirective(
2600 StmtCtx, DKind, Loc, ReadDirectiveWithinMetadirective);
2601 assert(!
Directive.isUnset() &&
"Executable directive remained unprocessed");
2610 if (ReadDirectiveWithinMetadirective && Tok.is(tok::r_paren))
2611 while (Tok.isNot(tok::annot_pragma_openmp_end))
2614 skipUntilPragmaOpenMPEnd(DKind);
2615 if (Tok.is(tok::annot_pragma_openmp_end))
2616 ConsumeAnnotationToken();
2619 case OMPD_metadirective: {
2621 SmallVector<VariantMatchInfo, 4> VMIs;
2622 SmallVector<OMPTraitInfo *, 4> TraitInfos;
2627 TentativeParsingAction TPA(*
this);
2628 ASTContext &ASTContext = Actions.getASTContext();
2631 tok::annot_pragma_openmp_end);
2632 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
2635 : getOpenMPClauseKind(PP.getSpelling(Tok));
2637 if (CKind == OMPC_unknown) {
2638 Diag(Tok, diag::err_omp_expected_clause) <<
"metadirective";
2640 SkipUntil(tok::annot_pragma_openmp_end);
2643 if (
getLangOpts().OpenMP < 52 && CKind == OMPC_otherwise)
2644 Diag(Tok, diag::err_omp_unexpected_clause)
2645 << getOpenMPClauseName(CKind) <<
"metadirective";
2646 if (CKind == OMPC_default &&
getLangOpts().OpenMP >= 52)
2647 Diag(Tok, diag::warn_omp_default_deprecated);
2652 if (T.expectAndConsume(diag::err_expected_lparen_after,
2653 getOpenMPClauseName(CKind).data())) {
2655 SkipUntil(tok::annot_pragma_openmp_end);
2659 OMPTraitInfo &TI = Actions.getASTContext().getNewOMPTraitInfo();
2660 if (CKind == OMPC_when) {
2662 parseOMPContextSelectors(Loc, TI);
2663 if (TI.
Sets.size() == 0) {
2664 Diag(Tok, diag::err_omp_expected_context_selector) <<
"when clause";
2670 if (Tok.is(tok::colon))
2673 Diag(Tok, diag::err_omp_expected_colon) <<
"when clause";
2681 while (Tok.isNot(tok::r_paren) || paren != 0) {
2682 if (Tok.is(tok::l_paren))
2684 if (Tok.is(tok::r_paren))
2686 if (Tok.is(tok::annot_pragma_openmp_end)) {
2687 Diag(Tok, diag::err_omp_expected_punc)
2688 << getOpenMPClauseName(CKind) << 0;
2695 if (Tok.is(tok::r_paren))
2698 VariantMatchInfo VMI;
2701 VMIs.push_back(VMI);
2702 TraitInfos.push_back(&TI);
2705 SourceLocation EndLoc = Tok.getLocation();
2710 [
this, Loc](StringRef ISATrait) {
2713 Diag(Loc, diag::warn_unknown_declare_variant_isa_trait) << ISATrait;
2715 TargetOMPContext OMPCtx(ASTContext, std::move(DiagUnknownTrait),
2717 ArrayRef<llvm::omp::TraitProperty>(),
2718 Actions.OpenMP().getOpenMPDeviceNum());
2721 int BestIdx = getBestVariantMatchForContext(VMIs, OMPCtx);
2725 bool HasNonConstUserCondition =
2726 llvm::any_of(TraitInfos, [&](OMPTraitInfo *TI) {
2732 if (HasNonConstUserCondition &&
2733 getLangOpts().OpenMPMetadirectiveRuntimeSelection) {
2737 unsigned NumClauses = TraitInfos.size();
2738 bool HasOtherwise = llvm::any_of(
2739 TraitInfos, [](
const OMPTraitInfo *TI) {
return TI->
Sets.empty(); });
2740 unsigned NumVariants = NumClauses + (HasOtherwise ? 0 : 1);
2746 SmallVector<Stmt *, 4> Variants;
2747 bool HasError =
false;
2748 for (
unsigned I : llvm::seq<unsigned>(NumVariants)) {
2749 bool HasDirective =
false;
2750 if (I < NumClauses) {
2754 if (CKind == OMPC_when) {
2760 HasDirective = Tok.isNot(tok::r_paren) &&
2761 Tok.isNot(tok::annot_pragma_openmp_end);
2764 std::optional<TentativeParsingAction> VariantTPA;
2765 if (I + 1 < NumVariants)
2766 VariantTPA.emplace(*
this,
true);
2770 Variant = ParseOpenMPDeclarativeOrExecutableDirective(
2774 while (Tok.isNot(tok::annot_pragma_openmp_end))
2776 ConsumeAnnotationToken();
2779 if (!Variant.isInvalid() && !Variant.isUsable()) {
2781 Variant = ParseStatement();
2785 if (
auto *D = dyn_cast_or_null<OMPExecutableDirective>(Variant.get());
2786 D && !D->hasAssociatedStmt()) {
2787 Diag(Loc, diag::err_omp_metadirective_standalone_variant);
2792 VariantTPA->Revert();
2796 if (Variant.isInvalid())
2799 Variants.push_back(Variant.get());
2803 return Actions.OpenMP().ActOnOpenMPMetaDirective(Loc, EndLoc, TraitInfos,
2812 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
2814 if (Idx++ != BestIdx) {
2819 while (Tok.isNot(tok::r_paren) || paren != 0) {
2820 if (Tok.is(tok::l_paren))
2822 if (Tok.is(tok::r_paren))
2827 if (Tok.is(tok::r_paren))
2834 : getOpenMPClauseKind(PP.getSpelling(Tok));
2841 if (CKind == OMPC_when) {
2842 OMPTraitInfo &TI = Actions.getASTContext().getNewOMPTraitInfo();
2844 parseOMPContextSelectors(Loc, TI);
2852 if (Tok.is(tok::r_paren)) {
2853 SkipUntil(tok::annot_pragma_openmp_end);
2858 Directive = ParseOpenMPDeclarativeOrExecutableDirective(
2866 if (BestIdx == -1 && Idx > 0) {
2867 assert(Tok.is(tok::annot_pragma_openmp_end) &&
2868 "Expecting the end of the pragma here");
2869 ConsumeAnnotationToken();
2874 case OMPD_threadprivate: {
2876 if ((StmtCtx & ParsedStmtContext::AllowStandaloneOpenMPDirectives) ==
2877 ParsedStmtContext()) {
2878 Diag(Tok, diag::err_omp_immediate_directive)
2879 << getOpenMPDirectiveName(DKind, OMPVersion) << 0;
2882 DeclDirectiveListParserHelper Helper(
this, DKind);
2883 if (!ParseOpenMPSimpleVarList(DKind, Helper,
2885 skipUntilPragmaOpenMPEnd(DKind);
2886 DeclGroupPtrTy Res = Actions.OpenMP().ActOnOpenMPThreadprivateDirective(
2887 Loc, Helper.getIdentifiers());
2888 Directive = Actions.ActOnDeclStmt(Res, Loc, Tok.getLocation());
2890 SkipUntil(tok::annot_pragma_openmp_end);
2893 case OMPD_groupprivate: {
2894 if ((StmtCtx & ParsedStmtContext::AllowStandaloneOpenMPDirectives) ==
2895 ParsedStmtContext()) {
2896 Diag(Tok, diag::err_omp_immediate_directive)
2897 << getOpenMPDirectiveName(DKind, OMPVersion) << 0;
2900 DeclDirectiveListParserHelper Helper(
this, DKind);
2901 if (!ParseOpenMPSimpleVarList(DKind, Helper,
2903 skipUntilPragmaOpenMPEnd(DKind);
2904 DeclGroupPtrTy Res = Actions.OpenMP().ActOnOpenMPGroupPrivateDirective(
2905 Loc, Helper.getIdentifiers());
2906 Directive = Actions.ActOnDeclStmt(Res, Loc, Tok.getLocation());
2908 SkipUntil(tok::annot_pragma_openmp_end);
2911 case OMPD_allocate: {
2913 if ((StmtCtx & ParsedStmtContext::AllowStandaloneOpenMPDirectives) ==
2914 ParsedStmtContext()) {
2915 Diag(Tok, diag::err_omp_immediate_directive)
2916 << getOpenMPDirectiveName(DKind, OMPVersion) << 0;
2919 DeclDirectiveListParserHelper Helper(
this, DKind);
2920 if (!ParseOpenMPSimpleVarList(DKind, Helper,
2922 SmallVector<OMPClause *, 1> Clauses;
2923 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
2924 llvm::SmallBitVector SeenClauses(llvm::omp::Clause_enumSize + 1);
2925 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
2927 Tok.isAnnotation() ? OMPC_unknown
2928 : getOpenMPClauseKind(PP.getSpelling(Tok));
2929 Actions.OpenMP().StartOpenMPClause(CKind);
2930 OMPClause *Clause = ParseOpenMPClause(OMPD_allocate, CKind,
2931 !SeenClauses[
unsigned(CKind)]);
2932 SkipUntil(tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
2934 SeenClauses[
unsigned(CKind)] =
true;
2935 if (Clause !=
nullptr)
2936 Clauses.push_back(Clause);
2937 if (Tok.is(tok::annot_pragma_openmp_end)) {
2938 Actions.OpenMP().EndOpenMPClause();
2942 if (Tok.is(tok::comma))
2944 Actions.OpenMP().EndOpenMPClause();
2946 skipUntilPragmaOpenMPEnd(DKind);
2948 DeclGroupPtrTy Res = Actions.OpenMP().ActOnOpenMPAllocateDirective(
2949 Loc, Helper.getIdentifiers(), Clauses);
2950 Directive = Actions.ActOnDeclStmt(Res, Loc, Tok.getLocation());
2952 SkipUntil(tok::annot_pragma_openmp_end);
2955 case OMPD_declare_reduction:
2958 ParseOpenMPDeclareReductionDirective(
AS_none)) {
2959 skipUntilPragmaOpenMPEnd(OMPD_declare_reduction);
2961 Directive = Actions.ActOnDeclStmt(Res, Loc, Tok.getLocation());
2963 SkipUntil(tok::annot_pragma_openmp_end);
2966 case OMPD_declare_mapper: {
2969 ParseOpenMPDeclareMapperDirective(
AS_none)) {
2971 ConsumeAnnotationToken();
2972 Directive = Actions.ActOnDeclStmt(Res, Loc, Tok.getLocation());
2974 SkipUntil(tok::annot_pragma_openmp_end);
2978 case OMPD_declare_target: {
2980 bool HasClauses = Tok.isNot(tok::annot_pragma_openmp_end);
2981 SemaOpenMP::DeclareTargetContextInfo DTCI(DKind, DTLoc);
2983 ParseOMPDeclareTargetClauses(DTCI);
2984 bool HasImplicitMappings =
2987 if (HasImplicitMappings) {
2988 Diag(Tok, diag::err_omp_unexpected_directive)
2989 << 1 << getOpenMPDirectiveName(DKind, OMPVersion);
2990 SkipUntil(tok::annot_pragma_openmp_end);
2997 Actions.OpenMP().ActOnFinishedOpenMPDeclareTargetContext(DTCI);
3000 case OMPD_begin_declare_variant: {
3005 ConsumeAnnotationToken();
3009 case OMPD_end_declare_variant: {
3011 if (Actions.OpenMP().isInOpenMPDeclareVariantScope())
3012 Actions.OpenMP().ActOnOpenMPEndDeclareVariant();
3014 Diag(Loc, diag::err_expected_begin_declare_variant);
3015 ConsumeAnnotationToken();
3018 case OMPD_declare_simd:
3019 case OMPD_begin_declare_target:
3020 case OMPD_end_declare_target:
3022 case OMPD_declare_variant:
3023 Diag(Tok, diag::err_omp_unexpected_directive)
3024 << 1 << getOpenMPDirectiveName(DKind, OMPVersion);
3025 SkipUntil(tok::annot_pragma_openmp_end);
3029 Directive = ParseOpenMPInformationalDirective(
3030 StmtCtx, DKind, Loc, ReadDirectiveWithinMetadirective);
3032 "Informational directive remains unprocessed");
3037 Diag(Tok, diag::err_omp_unknown_directive);
3038 SkipUntil(tok::annot_pragma_openmp_end);
3044bool Parser::ParseOpenMPSimpleVarList(
3048 bool AllowScopeSpecifier) {
3049 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
3052 if (T.expectAndConsume(diag::err_expected_lparen_after,
3053 getOpenMPDirectiveName(Kind, OMPVersion).data()))
3055 bool IsCorrect =
true;
3056 bool NoIdentIsFound =
true;
3059 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::annot_pragma_openmp_end)) {
3063 Token PrevTok = Tok;
3064 NoIdentIsFound =
false;
3067 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3070 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
3073 false,
false,
false,
3074 false,
false,
nullptr, Name)) {
3076 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
3078 }
else if (Tok.isNot(tok::comma) && Tok.isNot(tok::r_paren) &&
3079 Tok.isNot(tok::annot_pragma_openmp_end)) {
3081 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
3085 << SourceRange(PrevTok.
getLocation(), PrevTokLocation);
3087 Callback(SS, Actions.GetNameFromUnqualifiedId(Name));
3090 if (Tok.is(tok::comma)) {
3095 if (NoIdentIsFound) {
3096 Diag(Tok, diag::err_expected) << tok::identifier;
3101 IsCorrect = !T.consumeClose() && IsCorrect;
3106OMPClause *Parser::ParseOpenMPSizesClause() {
3107 SourceLocation ClauseNameLoc, OpenLoc, CloseLoc;
3108 SmallVector<Expr *, 4> ValExprs;
3109 if (ParseOpenMPExprListClause(OMPC_sizes, ClauseNameLoc, OpenLoc, CloseLoc,
3113 return Actions.OpenMP().ActOnOpenMPSizesClause(ValExprs, ClauseNameLoc,
3117OMPClause *Parser::ParseOpenMPCountsClause() {
3118 SourceLocation ClauseNameLoc, OpenLoc, CloseLoc;
3119 SmallVector<Expr *, 4> ValExprs;
3120 std::optional<unsigned> FillIdx;
3121 unsigned FillCount = 0;
3122 SourceLocation FillLoc;
3124 assert(getOpenMPClauseName(OMPC_counts) == PP.getSpelling(Tok) &&
3125 "Expected parsing to start at clause name");
3129 if (T.consumeOpen()) {
3130 Diag(Tok, diag::err_expected) << tok::l_paren;
3135 if (Tok.is(tok::identifier) &&
3136 Tok.getIdentifierInfo()->getName() ==
"omp_fill") {
3138 FillIdx = ValExprs.size();
3140 FillLoc = Tok.getLocation();
3142 ValExprs.push_back(
nullptr);
3149 ValExprs.push_back(Val.
get());
3153 if (T.consumeClose())
3155 OpenLoc = T.getOpenLocation();
3156 CloseLoc = T.getCloseLocation();
3158 return Actions.OpenMP().ActOnOpenMPCountsClause(
3159 ValExprs, ClauseNameLoc, OpenLoc, CloseLoc, FillIdx, FillLoc, FillCount);
3162OMPClause *Parser::ParseOpenMPLoopRangeClause() {
3164 SourceLocation FirstLoc, CountLoc;
3167 if (T.consumeOpen()) {
3168 Diag(Tok, diag::err_expected) << tok::l_paren;
3172 FirstLoc = Tok.getLocation();
3179 ExpectAndConsume(tok::comma);
3181 CountLoc = Tok.getLocation();
3190 return Actions.OpenMP().ActOnOpenMPLoopRangeClause(
3191 FirstVal.
get(), CountVal.
get(), ClauseNameLoc, T.getOpenLocation(),
3192 FirstLoc, CountLoc, T.getCloseLocation());
3195OMPClause *Parser::ParseOpenMPPermutationClause() {
3196 SourceLocation ClauseNameLoc, OpenLoc, CloseLoc;
3197 SmallVector<Expr *> ArgExprs;
3198 if (ParseOpenMPExprListClause(OMPC_permutation, ClauseNameLoc, OpenLoc,
3203 return Actions.OpenMP().ActOnOpenMPPermutationClause(ArgExprs, ClauseNameLoc,
3208 SourceLocation Loc = Tok.getLocation();
3213 if (T.expectAndConsume(diag::err_expected_lparen_after,
"uses_allocator"))
3215 SmallVector<SemaOpenMP::UsesAllocatorsData, 4>
Data;
3218 if (
getLangOpts().OpenMP >= 52 && Tok.is(tok::identifier) &&
3219 Tok.getIdentifierInfo()->getName() ==
"traits") {
3221 SemaOpenMP::UsesAllocatorsData &D =
Data.emplace_back();
3227 tok::annot_pragma_openmp_end);
3228 TraitParens.consumeOpen();
3231 TraitParens.consumeClose();
3235 {tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end},
3241 if (Tok.isNot(tok::colon)) {
3242 Diag(Tok, diag::err_expected) << tok::colon;
3244 {tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end},
3253 ? ParseCXXIdExpression()
3254 : tryParseCXXIdExpression(SS,
false);
3258 {tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end},
3265 D.
LParenLoc = TraitParens.getOpenLocation();
3266 D.
RParenLoc = TraitParens.getCloseLocation();
3269 if (Tok.is(tok::comma)) {
3271 Diag(Tok.getLocation(), diag::err_omp_allocator_comma_separator)
3274 }
else if (Tok.is(tok::semi)) {
3284 getLangOpts().CPlusPlus
3285 ? ParseCXXIdExpression()
3286 : tryParseCXXIdExpression(SS,
false);
3288 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
3295 BalancedDelimiterTracker T(*this, tok::l_paren,
3296 tok::annot_pragma_openmp_end);
3298 ExprResult AllocatorTraits =
3299 getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression();
3301 if (AllocatorTraits.isInvalid()) {
3302 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
3311 if (getLangOpts().OpenMP >= 52) {
3312 Diag(Loc, diag::err_omp_deprecate_old_syntax)
3313 <<
"allocator(expr)"
3314 <<
"uses_allocators"
3315 <<
"traits(expr): alloc";
3319 Diag(
Tok, diag::err_omp_expected_punc) <<
"uses_allocators" << 0;
3321 if (
Tok.
is(tok::comma))
3323 }
while (
Tok.
isNot(tok::r_paren) &&
Tok.
isNot(tok::annot_pragma_openmp_end));
3326 Loc, T.getOpenLocation(), T.getCloseLocation(),
Data);
3331 OMPClauseKind = CKind;
3332 OMPClause *Clause =
nullptr;
3333 bool ErrorFound =
false;
3334 bool WrongDirective =
false;
3335 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
3338 if (!isAllowedClauseForDirective(D,
C, OMPVersion)) {
3339 Diag(Tok, diag::err_omp_unexpected_clause)
3340 << getOpenMPClauseName(
C) << getOpenMPDirectiveName(D, OMPVersion);
3342 WrongDirective =
true;
3346 if (CKind != OMPC_unknown) {
3348 assert(DKind != OMPD_ordered_blockassoc &&
3349 "Wrong kind for ordered directive");
3350 if (DKind == OMPD_ordered_standalone) {
3353 if (!isAllowedClauseForDirective(DKind, CKind, OMPVersion))
3354 CheckClauseValid(OMPD_ordered_blockassoc, CKind);
3356 CheckClauseValid(DKind, CKind);
3367 case OMPC_grainsize:
3368 case OMPC_num_tasks:
3370 case OMPC_allocator:
3373 case OMPC_novariants:
3374 case OMPC_nocontext:
3380 case OMPC_ompx_dyn_cgroup_mem:
3381 case OMPC_dyn_groupprivate:
3382 case OMPC_transparent:
3411 Diag(Tok, diag::err_omp_more_one_clause)
3412 << getOpenMPDirectiveName(DKind, OMPVersion)
3413 << getOpenMPClauseName(CKind) << 0;
3417 if (CKind == OMPC_transparent && PP.LookAhead(0).isNot(tok::l_paren)) {
3419 SourceLocation LLoc = Tok.getLocation();
3420 if (!WrongDirective)
3421 Clause = Actions.OpenMP().ActOnOpenMPTransparentClause(
nullptr, LLoc,
3425 if ((CKind == OMPC_ordered || CKind == OMPC_partial) &&
3426 PP.LookAhead(0).isNot(tok::l_paren))
3427 Clause = ParseOpenMPClause(CKind, WrongDirective);
3428 else if (CKind == OMPC_grainsize || CKind == OMPC_num_tasks ||
3429 CKind == OMPC_dyn_groupprivate)
3430 Clause = ParseOpenMPSingleExprWithArgClause(DKind, CKind, WrongDirective);
3432 Clause = ParseOpenMPSingleExprClause(CKind, WrongDirective);
3434 case OMPC_threadset:
3436 case OMPC_proc_bind:
3437 case OMPC_atomic_default_mem_order:
3455 Diag(Tok, diag::err_omp_more_one_clause)
3456 << getOpenMPDirectiveName(DKind, OMPVersion)
3457 << getOpenMPClauseName(CKind) << 0;
3461 Clause = ParseOpenMPSimpleClause(CKind, WrongDirective);
3465 case OMPC_dist_schedule:
3466 case OMPC_defaultmap:
3477 if ((
getLangOpts().OpenMP < 50 || CKind != OMPC_defaultmap) &&
3478 (CKind != OMPC_order ||
getLangOpts().OpenMP >= 51) && !FirstClause) {
3479 Diag(Tok, diag::err_omp_more_one_clause)
3480 << getOpenMPDirectiveName(DKind, OMPVersion)
3481 << getOpenMPClauseName(CKind) << 0;
3486 Clause = ParseOpenMPSingleExprWithArgClause(DKind, CKind, WrongDirective);
3489 Clause = ParseOpenMPSingleExprClause(CKind, WrongDirective);
3493 case OMPC_mergeable:
3507 case OMPC_unified_address:
3508 case OMPC_unified_shared_memory:
3509 case OMPC_reverse_offload:
3510 case OMPC_dynamic_allocators:
3519 Diag(Tok, diag::err_omp_more_one_clause)
3520 << getOpenMPDirectiveName(DKind, OMPVersion)
3521 << getOpenMPClauseName(CKind) << 0;
3525 if (CKind == OMPC_nowait && PP.LookAhead(0).is(tok::l_paren) &&
3527 Clause = ParseOpenMPSingleExprClause(CKind, WrongDirective);
3529 Clause = ParseOpenMPClause(CKind, WrongDirective);
3531 case OMPC_self_maps:
3534 Diag(Tok, diag::err_omp_expected_clause)
3535 << getOpenMPDirectiveName(OMPD_requires, OMPVersion);
3539 Diag(Tok, diag::err_omp_more_one_clause)
3540 << getOpenMPDirectiveName(DKind, OMPVersion)
3541 << getOpenMPClauseName(CKind) << 0;
3544 Clause = ParseOpenMPClause(CKind, WrongDirective);
3548 Diag(Tok, diag::err_omp_more_one_clause)
3549 << getOpenMPDirectiveName(DKind, OMPVersion)
3550 << getOpenMPClauseName(CKind) << 0;
3553 Clause = ParseOpenMPClause(CKind, WrongDirective);
3555 case OMPC_update_depend_objects:
3557 Diag(Tok, diag::err_omp_more_one_clause)
3558 << getOpenMPDirectiveName(DKind, OMPVersion)
3559 << getOpenMPClauseName(CKind) << 0;
3563 Clause = ParseOpenMPSimpleClause(CKind, WrongDirective);
3565 case OMPC_num_teams:
3566 case OMPC_thread_limit:
3567 case OMPC_num_threads:
3569 Diag(Tok, diag::err_omp_more_one_clause)
3570 << getOpenMPDirectiveName(DKind, OMPVersion)
3571 << getOpenMPClauseName(CKind) << 0;
3576 case OMPC_firstprivate:
3577 case OMPC_lastprivate:
3579 case OMPC_reduction:
3580 case OMPC_task_reduction:
3581 case OMPC_in_reduction:
3585 case OMPC_copyprivate:
3591 case OMPC_use_device_ptr:
3592 case OMPC_use_device_addr:
3593 case OMPC_is_device_ptr:
3594 case OMPC_has_device_addr:
3596 case OMPC_nontemporal:
3597 case OMPC_inclusive:
3598 case OMPC_exclusive:
3602 if (
getLangOpts().OpenMP >= 52 && DKind == OMPD_ordered_standalone &&
3603 CKind == OMPC_depend)
3604 Diag(Tok, diag::warn_omp_depend_in_ordered_deprecated);
3605 Clause = ParseOpenMPVarListClause(DKind, CKind, WrongDirective);
3609 Diag(Tok, diag::err_omp_more_one_clause)
3610 << getOpenMPDirectiveName(DKind, OMPVersion)
3611 << getOpenMPClauseName(CKind) << 0;
3615 Clause = ParseOpenMPSizesClause();
3617 case OMPC_permutation:
3619 Diag(Tok, diag::err_omp_more_one_clause)
3620 << getOpenMPDirectiveName(DKind, OMPVersion)
3621 << getOpenMPClauseName(CKind) << 0;
3624 Clause = ParseOpenMPPermutationClause();
3628 Diag(Tok, diag::err_omp_more_one_clause)
3629 << getOpenMPDirectiveName(DKind, OMPVersion)
3630 << getOpenMPClauseName(CKind) << 0;
3633 Clause = ParseOpenMPCountsClause();
3635 case OMPC_uses_allocators:
3636 Clause = ParseOpenMPUsesAllocatorClause(DKind);
3639 if (DKind != OMPD_interop) {
3641 Diag(Tok, diag::err_omp_more_one_clause)
3642 << getOpenMPDirectiveName(DKind, OMPVersion)
3643 << getOpenMPClauseName(CKind) << 0;
3646 Clause = ParseOpenMPClause(CKind, WrongDirective);
3652 Clause = ParseOpenMPInteropClause(CKind, WrongDirective);
3654 case OMPC_device_type:
3656 skipUntilPragmaOpenMPEnd(DKind);
3658 case OMPC_threadprivate:
3659 case OMPC_groupprivate:
3662 if (!WrongDirective)
3663 Diag(Tok, diag::err_omp_unexpected_clause)
3664 << getOpenMPClauseName(CKind)
3665 << getOpenMPDirectiveName(DKind, OMPVersion);
3669 case OMPC_contains: {
3671 SourceLocation LLoc = Tok.getLocation();
3672 SourceLocation RLoc;
3673 llvm::SmallVector<OpenMPDirectiveKind, 4> DKVec;
3678 if (DK == OMPD_unknown) {
3679 skipUntilPragmaOpenMPEnd(OMPD_assume);
3680 Diag(Tok, diag::err_omp_unexpected_clause)
3681 << getOpenMPClauseName(CKind)
3682 << getOpenMPDirectiveName(DKind, OMPVersion);
3686 DKVec.push_back(DK);
3689 Diag(Tok, diag::err_omp_unexpected_clause)
3690 << getOpenMPClauseName(CKind)
3691 << getOpenMPDirectiveName(DKind, OMPVersion);
3694 RLoc = Tok.getLocation();
3696 if (!WrongDirective)
3697 Clause = Actions.OpenMP().ActOnOpenMPDirectivePresenceClause(
3698 CKind, DKVec, Loc, LLoc, RLoc);
3701 case OMPC_no_openmp:
3702 case OMPC_no_openmp_routines:
3703 case OMPC_no_openmp_constructs:
3704 case OMPC_no_parallelism: {
3706 Diag(Tok, diag::err_omp_more_one_clause)
3707 << getOpenMPDirectiveName(DKind, OMPVersion)
3708 << getOpenMPClauseName(CKind) << 0;
3712 if (!WrongDirective)
3713 Clause = Actions.OpenMP().ActOnOpenMPNullaryAssumptionClause(
3714 CKind, Loc, Tok.getLocation());
3717 case OMPC_ompx_attribute:
3718 Clause = ParseOpenMPOMPXAttributesClause(WrongDirective);
3720 case OMPC_ompx_bare:
3721 if (DKind == llvm::omp::Directive::OMPD_target) {
3726 Diag(Tok, diag::err_omp_unexpected_clause)
3727 << getOpenMPClauseName(CKind)
3728 << getOpenMPDirectiveName(DKind, OMPVersion);
3730 WrongDirective =
true;
3733 Diag(Tok, diag::note_ompx_bare_clause)
3734 << getOpenMPClauseName(CKind) <<
"target teams";
3735 if (!ErrorFound && !
getLangOpts().OpenMPExtensions) {
3736 Diag(Tok, diag::err_omp_unexpected_clause_extension_only)
3737 << getOpenMPClauseName(CKind)
3738 << getOpenMPDirectiveName(DKind, OMPVersion);
3741 Clause = ParseOpenMPClause(CKind, WrongDirective);
3743 case OMPC_looprange:
3744 Clause = ParseOpenMPLoopRangeClause();
3749 return ErrorFound ?
nullptr : Clause;
3757 bool IsAddressOfOperand) {
3759 if (T.expectAndConsume(diag::err_expected_lparen_after, ClauseName.data()))
3767 Val = Actions.ActOnFinishFullExpr(Val.
get(), ELoc,
false);
3770 RLoc = Tok.getLocation();
3771 if (!T.consumeClose())
3772 RLoc = T.getCloseLocation();
3794bool Parser::ParseOpenMPIndirectClause(
3799 if (
Tok.isNot(tok::l_paren)) {
3818 if (
Ret.isInvalid())
3821 Ret = Actions.VerifyIntegerConstantExpression(Val.
get(), &
Result,
3823 if (
Ret.isInvalid())
3831ExprResult Parser::ParseOMPInteropFrSelector() {
3834 tok::annot_pragma_openmp_end);
3835 if (FT.expectAndConsume(diag::err_expected_lparen_after,
"fr")) {
3837 {tok::comma, tok::r_brace, tok::r_paren, tok::annot_pragma_openmp_end},
3841 SourceLocation Loc = Tok.getLocation();
3844 Arg = Actions.ActOnFinishFullExpr(Arg.
get(), Loc,
false);
3852 tok::annot_pragma_openmp_end);
3853 if (AT.expectAndConsume(diag::err_expected_lparen_after,
"attr")) {
3855 {tok::comma, tok::r_brace, tok::r_paren, tok::annot_pragma_openmp_end},
3859 bool HasError =
false;
3862 if (Tok.is(tok::r_paren)) {
3863 Diag(Tok, diag::err_omp_interop_attr_not_string);
3866 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::r_brace) &&
3867 Tok.isNot(tok::annot_pragma_openmp_end)) {
3868 if (Tok.is(tok::string_literal)) {
3871 Attrs.push_back(S.
get());
3876 Diag(Tok, diag::err_omp_interop_attr_not_string);
3879 if (Tok.is(tok::comma))
3889 bool HasError =
false;
3890 bool IsTarget =
false;
3891 bool IsTargetSync =
false;
3893 while (Tok.is(tok::identifier)) {
3895 bool PreferTypeAllowed = (
Kind == OMPC_init ||
Kind == OMPC_append_args) &&
3896 InteropInfo.
Prefs.empty() && !IsTarget &&
3898 if (Tok.getIdentifierInfo()->isStr(
"target")) {
3903 Diag(Tok, diag::warn_omp_more_one_interop_type) <<
"target";
3906 }
else if (Tok.getIdentifierInfo()->isStr(
"targetsync")) {
3908 Diag(Tok, diag::warn_omp_more_one_interop_type) <<
"targetsync";
3909 IsTargetSync =
true;
3911 }
else if (Tok.getIdentifierInfo()->isStr(
"prefer_type") &&
3912 PreferTypeAllowed) {
3913 if (Kind == OMPC_append_args &&
getLangOpts().OpenMP < 60) {
3914 Diag(Tok, diag::err_omp_append_args_prefer_type_60);
3919 tok::annot_pragma_openmp_end);
3920 if (PT.expectAndConsume(diag::err_expected_lparen_after,
"prefer_type"))
3924 if (Tok.is(tok::r_paren)) {
3925 Diag(Tok, diag::err_omp_expected_pref_spec);
3929 while (Tok.isNot(tok::r_paren) &&
3930 Tok.isNot(tok::annot_pragma_openmp_end)) {
3932 if (Tok.is(tok::l_brace)) {
3936 Diag(Tok, diag::err_omp_prefer_type_brace_60);
3940 tok::annot_pragma_openmp_end);
3942 Expr *FrExpr =
nullptr;
3943 SmallVector<Expr *, 2> AttrExprs;
3944 bool SeenFr =
false;
3948 if (Tok.is(tok::r_brace)) {
3949 Diag(Tok, diag::err_omp_expected_fr_or_attr_selector);
3953 while (Tok.isNot(tok::r_brace) &&
3954 Tok.isNot(tok::annot_pragma_openmp_end)) {
3955 if (Tok.is(tok::identifier) &&
3956 Tok.getIdentifierInfo()->isStr(
"fr")) {
3958 Diag(Tok, diag::err_omp_interop_multiple_fr);
3962 {tok::comma, tok::r_brace, tok::annot_pragma_openmp_end},
3972 }
else if (Tok.is(tok::identifier) &&
3973 Tok.getIdentifierInfo()->isStr(
"attr")) {
3974 if (ParseOMPInteropAttrSelector(AttrExprs))
3979 Diag(Tok, diag::err_omp_expected_fr_or_attr_selector);
3982 if (Tok.is(tok::comma))
3985 if (BT.consumeClose())
3988 if (FrExpr || !AttrExprs.empty())
3989 InteropInfo.
Prefs.emplace_back(FrExpr, AttrExprs);
3994 SourceLocation Loc = Tok.getLocation();
3998 PTExpr = Actions.ActOnFinishFullExpr(PTExpr.
get(), Loc,
4001 InteropInfo.
Prefs.emplace_back(PTExpr.
get(),
4002 llvm::SmallVector<Expr *, 2>{});
4005 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
4010 if (Tok.is(tok::comma))
4016 Diag(Tok, diag::err_omp_expected_interop_type);
4019 if (!Tok.is(tok::comma))
4024 if (!HasError && !IsTarget && !IsTargetSync) {
4025 Diag(Tok, diag::err_omp_expected_interop_type);
4029 if (Kind == OMPC_init) {
4030 if (Tok.isNot(tok::colon) && (IsTarget || IsTargetSync))
4031 Diag(Tok, diag::warn_pragma_expected_colon) <<
"interop types";
4032 if (Tok.is(tok::colon))
4049 if (T.expectAndConsume(diag::err_expected_lparen_after,
4050 getOpenMPClauseName(Kind).data()))
4053 bool InteropError =
false;
4054 OMPInteropInfo InteropInfo;
4055 if (Kind == OMPC_init)
4056 InteropError = ParseOMPInteropInfo(InteropInfo, OMPC_init);
4059 SourceLocation VarLoc = Tok.getLocation();
4062 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
4067 SourceLocation RLoc = Tok.getLocation();
4068 if (!T.consumeClose())
4069 RLoc = T.getCloseLocation();
4071 if (ParseOnly || !InteropVarExpr.
isUsable() || InteropError)
4074 if (Kind == OMPC_init)
4075 return Actions.OpenMP().ActOnOpenMPInitClause(
4076 InteropVarExpr.
get(), InteropInfo, Loc, T.getOpenLocation(), VarLoc,
4078 if (Kind == OMPC_use)
4079 return Actions.OpenMP().ActOnOpenMPUseClause(
4080 InteropVarExpr.
get(), Loc, T.getOpenLocation(), VarLoc, RLoc);
4082 if (Kind == OMPC_destroy)
4083 return Actions.OpenMP().ActOnOpenMPDestroyClause(
4084 InteropVarExpr.
get(), Loc, T.getOpenLocation(), VarLoc, RLoc);
4086 llvm_unreachable(
"Unexpected interop variable clause.");
4089OMPClause *Parser::ParseOpenMPOMPXAttributesClause(
bool ParseOnly) {
4093 if (T.expectAndConsume(diag::err_expected_lparen_after,
4094 getOpenMPClauseName(OMPC_ompx_attribute).data()))
4097 ParsedAttributes ParsedAttrs(AttrFactory);
4098 ParseAttributes(PAKM_GNU | PAKM_CXX11, ParsedAttrs);
4101 if (T.consumeClose())
4107 SmallVector<Attr *> Attrs;
4108 for (
const ParsedAttr &PA : ParsedAttrs) {
4109 switch (PA.getKind()) {
4110 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
4111 if (!PA.checkExactlyNumArgs(Actions, 2))
4113 if (
auto *A = Actions.AMDGPU().CreateAMDGPUFlatWorkGroupSizeAttr(
4114 PA, PA.getArgAsExpr(0), PA.getArgAsExpr(1)))
4117 case ParsedAttr::AT_AMDGPUWavesPerEU:
4118 if (!PA.checkAtLeastNumArgs(Actions, 1) ||
4119 !PA.checkAtMostNumArgs(Actions, 2))
4121 if (
auto *A = Actions.AMDGPU().CreateAMDGPUWavesPerEUAttr(
4122 PA, PA.getArgAsExpr(0),
4123 PA.getNumArgs() > 1 ? PA.getArgAsExpr(1) :
nullptr))
4126 case ParsedAttr::AT_CUDALaunchBounds:
4127 if (!PA.checkAtLeastNumArgs(Actions, 1) ||
4128 !PA.checkAtMostNumArgs(Actions, 3))
4130 if (
auto *A = Actions.CreateLaunchBoundsAttr(
4131 PA, PA.getArgAsExpr(0),
4132 PA.getNumArgs() > 1 ? PA.getArgAsExpr(1) :
nullptr,
4133 PA.getNumArgs() > 2 ? PA.getArgAsExpr(2) :
nullptr,
4138 Diag(Loc, diag::warn_omp_invalid_attribute_for_ompx_attributes) << PA;
4143 return Actions.OpenMP().ActOnOpenMPXAttributeClause(
4144 Attrs, Loc, T.getOpenLocation(), T.getCloseLocation());
4150 if (!Val || ParseOnly)
4152 if (
getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
4153 (
static_cast<DefaultKind
>(Val->Type) == OMP_DEFAULT_private ||
4154 static_cast<DefaultKind
>(Val->Type) ==
4155 OMP_DEFAULT_firstprivate)) {
4156 Diag(Val->LOpen, diag::err_omp_invalid_dsa)
4157 << getOpenMPClauseName(
static_cast<DefaultKind
>(Val->Type) ==
4160 : OMPC_firstprivate)
4161 << getOpenMPClauseName(OMPC_default) <<
"5.1";
4164 return Actions.OpenMP().ActOnOpenMPSimpleClause(
4165 Kind, Val->Type, Val->TypeLoc, Val->LOpen, Val->Loc, Val->RLoc);
4169 SourceLocation Loc = Tok.getLocation();
4174 return Actions.OpenMP().ActOnOpenMPClause(Kind, Loc, Tok.getLocation());
4181 SourceLocation DelimLoc;
4184 if (T.expectAndConsume(diag::err_expected_lparen_after,
4185 getOpenMPClauseName(Kind).data()))
4189 SmallVector<unsigned, 4> Arg;
4190 SmallVector<SourceLocation, 4> KLoc;
4191 if (Kind == OMPC_schedule) {
4192 enum { Modifier1, Modifier2, ScheduleKind, NumberOfElements };
4193 Arg.resize(NumberOfElements);
4194 KLoc.resize(NumberOfElements);
4199 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4202 Arg[Modifier1] = KindModifier;
4203 KLoc[Modifier1] = Tok.getLocation();
4204 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4205 Tok.isNot(tok::annot_pragma_openmp_end))
4207 if (Tok.is(tok::comma)) {
4211 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4215 KLoc[Modifier2] = Tok.getLocation();
4216 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4217 Tok.isNot(tok::annot_pragma_openmp_end))
4221 if (Tok.is(tok::colon))
4224 Diag(Tok, diag::warn_pragma_expected_colon) <<
"schedule modifier";
4226 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4228 Arg[ScheduleKind] = KindModifier;
4229 KLoc[ScheduleKind] = Tok.getLocation();
4230 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4231 Tok.isNot(tok::annot_pragma_openmp_end))
4233 if ((Arg[ScheduleKind] == OMPC_SCHEDULE_static ||
4234 Arg[ScheduleKind] == OMPC_SCHEDULE_dynamic ||
4235 Arg[ScheduleKind] == OMPC_SCHEDULE_guided) &&
4238 }
else if (Kind == OMPC_dist_schedule) {
4240 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts()));
4241 KLoc.push_back(Tok.getLocation());
4242 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4243 Tok.isNot(tok::annot_pragma_openmp_end))
4245 if (Arg.back() == OMPC_DIST_SCHEDULE_static && Tok.is(tok::comma))
4247 }
else if (Kind == OMPC_default) {
4250 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4252 Arg.push_back(Modifier);
4253 KLoc.push_back(Tok.getLocation());
4254 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4255 Tok.isNot(tok::annot_pragma_openmp_end))
4258 if (Tok.is(tok::colon) &&
getLangOpts().OpenMP >= 60) {
4263 Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4264 Arg.push_back(VariableCategory);
4265 KLoc.push_back(Tok.getLocation());
4266 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4267 Tok.isNot(tok::annot_pragma_openmp_end))
4270 Arg.push_back(OMPC_DEFAULT_VC_all);
4271 KLoc.push_back(SourceLocation());
4273 }
else if (Kind == OMPC_defaultmap) {
4276 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4282 Arg.push_back(Modifier);
4283 KLoc.push_back(Tok.getLocation());
4284 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4285 Tok.isNot(tok::annot_pragma_openmp_end))
4288 if (Tok.is(tok::colon) ||
getLangOpts().OpenMP < 50) {
4289 if (Tok.is(tok::colon))
4292 Diag(Tok, diag::warn_pragma_expected_colon) <<
"defaultmap modifier";
4295 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts()));
4296 KLoc.push_back(Tok.getLocation());
4297 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4298 Tok.isNot(tok::annot_pragma_openmp_end))
4302 KLoc.push_back(SourceLocation());
4304 }
else if (Kind == OMPC_order) {
4305 enum { Modifier, OrderKind, NumberOfElements };
4306 Arg.resize(NumberOfElements);
4307 KLoc.resize(NumberOfElements);
4311 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4314 Arg[Modifier] = KindModifier;
4315 KLoc[Modifier] = Tok.getLocation();
4316 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4317 Tok.isNot(tok::annot_pragma_openmp_end))
4320 if (Tok.is(tok::colon))
4323 Diag(Tok, diag::warn_pragma_expected_colon) <<
"order modifier";
4325 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4327 Arg[OrderKind] = KindModifier;
4328 KLoc[OrderKind] = Tok.getLocation();
4329 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4330 Tok.isNot(tok::annot_pragma_openmp_end))
4332 }
else if (Kind == OMPC_device) {
4338 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts()));
4339 KLoc.push_back(Tok.getLocation());
4345 KLoc.emplace_back();
4347 }
else if (Kind == OMPC_grainsize) {
4351 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
4355 Arg.push_back(Modifier);
4356 KLoc.push_back(Tok.getLocation());
4362 if (Modifier == OMPC_GRAINSIZE_strict) {
4363 Diag(Tok, diag::err_modifier_expected_colon) <<
"strict";
4368 KLoc.emplace_back();
4372 KLoc.emplace_back();
4374 }
else if (Kind == OMPC_dyn_groupprivate) {
4375 enum { SimpleModifier, ComplexModifier, NumberOfModifiers };
4376 Arg.resize(NumberOfModifiers);
4377 KLoc.resize(NumberOfModifiers);
4381 auto ConsumeModifier = [&]() {
4382 unsigned Type = NumberOfModifiers;
4385 if (!Tok.isAnnotation() && PP.getSpelling(Tok) ==
"fallback" &&
4389 ParenT.consumeOpen();
4392 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4395 Diag(Tok.getLocation(), diag::err_expected)
4396 <<
"'abort', 'null' or 'default_mem' in fallback modifier";
4398 return std::make_tuple(
Type, Modifier, Loc);
4400 Type = ComplexModifier;
4401 Loc = Tok.getLocation();
4402 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4403 Tok.isNot(tok::annot_pragma_openmp_end))
4405 ParenT.consumeClose();
4408 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
getLangOpts());
4410 Type = SimpleModifier;
4411 Loc = Tok.getLocation();
4412 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
4413 Tok.isNot(tok::annot_pragma_openmp_end))
4417 return std::make_tuple(
Type, Modifier, Loc);
4420 auto SaveModifier = [&](
unsigned Type,
unsigned Modifier,
4421 SourceLocation Loc) {
4422 assert(
Type < NumberOfModifiers &&
"Unexpected modifier type");
4423 if (!KLoc[
Type].isValid()) {
4424 Arg[
Type] = Modifier;
4427 Diag(Loc, diag::err_omp_incompatible_dyn_groupprivate_modifier)
4434 auto [Type1, Mod1, Loc1] = ConsumeModifier();
4435 if (Type1 < NumberOfModifiers) {
4436 SaveModifier(Type1, Mod1, Loc1);
4437 if (Tok.is(tok::comma)) {
4440 auto [Type2, Mod2, Loc2] = ConsumeModifier();
4441 if (Type2 < NumberOfModifiers)
4442 SaveModifier(Type2, Mod2, Loc2);
4445 if (Tok.is(tok::colon))
4448 Diag(Tok, diag::warn_pragma_expected_colon)
4449 <<
"dyn_groupprivate modifier";
4451 }
else if (Kind == OMPC_num_tasks) {
4455 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
4459 Arg.push_back(Modifier);
4460 KLoc.push_back(Tok.getLocation());
4466 if (Modifier == OMPC_NUMTASKS_strict) {
4467 Diag(Tok, diag::err_modifier_expected_colon) <<
"strict";
4472 KLoc.emplace_back();
4476 KLoc.emplace_back();
4479 assert(Kind == OMPC_if);
4480 KLoc.push_back(Tok.getLocation());
4481 TentativeParsingAction TPA(*
this);
4483 Arg.push_back(
static_cast<unsigned>(DK));
4484 if (DK != OMPD_unknown) {
4486 if (Tok.is(tok::colon) &&
getLangOpts().OpenMP > 40) {
4491 Arg.back() =
unsigned(OMPD_unknown);
4498 bool NeedAnExpression = (
Kind == OMPC_schedule && DelimLoc.
isValid()) ||
4499 (
Kind == OMPC_dist_schedule && DelimLoc.
isValid()) ||
4500 Kind == OMPC_if ||
Kind == OMPC_device ||
4501 Kind == OMPC_grainsize ||
Kind == OMPC_num_tasks ||
4502 Kind == OMPC_dyn_groupprivate;
4503 if (NeedAnExpression) {
4504 SourceLocation ELoc = Tok.getLocation();
4510 Actions.ActOnFinishFullExpr(Val.
get(), ELoc,
false);
4514 SourceLocation RLoc = Tok.getLocation();
4515 if (!T.consumeClose())
4516 RLoc = T.getCloseLocation();
4518 if (NeedAnExpression && Val.
isInvalid())
4521 if (Kind == OMPC_default &&
getLangOpts().OpenMP < 51 && Arg[0] &&
4522 (
static_cast<DefaultKind
>(Arg[0]) == OMP_DEFAULT_private ||
4523 static_cast<DefaultKind
>(Arg[0]) == OMP_DEFAULT_firstprivate)) {
4524 Diag(KLoc[0], diag::err_omp_invalid_dsa)
4525 << getOpenMPClauseName(
static_cast<DefaultKind
>(Arg[0]) ==
4528 : OMPC_firstprivate)
4529 << getOpenMPClauseName(OMPC_default) <<
"5.1";
4535 return Actions.OpenMP().ActOnOpenMPSingleExprWithArgClause(
4536 Kind, Arg, Val.
get(), Loc, T.getOpenLocation(), KLoc, DelimLoc, RLoc);
4541 if (ReductionIdScopeSpec.
isEmpty()) {
4579 ReductionIdScopeSpec,
nullptr,
4583 false,
nullptr, ReductionId);
4590 if (!
Tok.is(tok::identifier))
4597 return TypeModifier;
4603 if (T.expectAndConsume(diag::err_expected_lparen_after,
"mapper")) {
4604 SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
4610 ParseOptionalCXXScopeSpecifier(
Data.ReductionOrMapperIdScopeSpec,
4614 if (Tok.isNot(tok::identifier) && Tok.isNot(tok::kw_default)) {
4615 Diag(Tok.getLocation(), diag::err_omp_mapper_illegal_identifier);
4616 SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
4620 auto &DeclNames = Actions.getASTContext().DeclarationNames;
4622 DeclNames.getIdentifier(Tok.getIdentifierInfo()), Tok.getLocation());
4625 return T.consumeClose();
4631 bool HasMapType =
false;
4633 StringRef PreMapName =
"";
4637 if (TypeModifier == OMPC_MAP_MODIFIER_always ||
4638 TypeModifier == OMPC_MAP_MODIFIER_close ||
4639 TypeModifier == OMPC_MAP_MODIFIER_present ||
4640 TypeModifier == OMPC_MAP_MODIFIER_ompx_hold) {
4641 Data.MapTypeModifiers.push_back(TypeModifier);
4642 Data.MapTypeModifiersLoc.push_back(Tok.getLocation());
4643 if (PP.LookAhead(0).isNot(tok::comma) &&
4644 PP.LookAhead(0).isNot(tok::colon) &&
getLangOpts().OpenMP >= 52)
4645 Diag(Tok.getLocation(), diag::err_omp_missing_comma)
4646 <<
"map type modifier";
4648 }
else if (TypeModifier == OMPC_MAP_MODIFIER_mapper) {
4649 Data.MapTypeModifiers.push_back(TypeModifier);
4650 Data.MapTypeModifiersLoc.push_back(Tok.getLocation());
4654 if (Tok.isNot(tok::comma) && Tok.isNot(tok::colon) &&
4656 Diag(
Data.MapTypeModifiersLoc.back(), diag::err_omp_missing_comma)
4657 <<
"map type modifier";
4662 Data.ExtraModifier = MapKind;
4664 PreMapLoc = Tok.getLocation();
4665 PreMapName = Tok.getIdentifierInfo()->getName();
4667 Diag(Tok, diag::err_omp_more_one_map_type);
4668 Diag(PreMapLoc, diag::note_previous_map_type_specified_here)
4672 }
else if (TypeModifier == OMPC_MAP_MODIFIER_self) {
4673 Data.MapTypeModifiers.push_back(TypeModifier);
4674 Data.MapTypeModifiersLoc.push_back(Tok.getLocation());
4675 if (PP.LookAhead(0).isNot(tok::comma) &&
4676 PP.LookAhead(0).isNot(tok::colon))
4677 Diag(Tok.getLocation(), diag::err_omp_missing_comma)
4678 <<
"map type modifier";
4680 Diag(Tok, diag::err_omp_unknown_map_type_modifier)
4690 if (Tok.is(tok::comma)) {
4691 Diag(Tok, diag::err_omp_map_type_modifier_missing);
4696 if (PP.LookAhead(0).is(tok::colon)) {
4704 Diag(Tok, diag::err_omp_unknown_map_type_modifier)
4715 if (!Tok.is(tok::colon)) {
4716 Diag(Tok, diag::err_omp_unknown_map_type);
4730 if (!
Tok.isOneOf(tok::identifier, tok::kw_delete))
4735 if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_from ||
4736 MapType == OMPC_MAP_tofrom || MapType == OMPC_MAP_alloc ||
4737 MapType == OMPC_MAP_delete || MapType == OMPC_MAP_release)
4747 if (
Tok.is(tok::colon)) {
4748 P.
Diag(
Tok, diag::err_omp_map_type_missing);
4753 P.
Diag(
Tok, diag::err_omp_unknown_map_type);
4757ExprResult Parser::ParseOpenMPIteratorsExpr() {
4758 assert(Tok.is(tok::identifier) && PP.getSpelling(Tok) ==
"iterator" &&
4759 "Expected 'iterator' token.");
4763 if (T.expectAndConsume(diag::err_expected_lparen_after,
"iterator"))
4766 SourceLocation LLoc = T.getOpenLocation();
4767 SmallVector<SemaOpenMP::OMPIteratorData, 4>
Data;
4768 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::annot_pragma_openmp_end)) {
4771 if (Tok.isNot(tok::identifier) ||
NextToken().
isNot(tok::equal)) {
4778 IteratorType = TR.
get();
4782 IdentifierInfo *II =
nullptr;
4783 SourceLocation IdLoc;
4784 if (Tok.is(tok::identifier)) {
4785 II = Tok.getIdentifierInfo();
4788 Diag(Tok, diag::err_expected_unqualified_id) << 0;
4792 SourceLocation AssignLoc;
4793 if (Tok.is(tok::equal))
4796 Diag(Tok, diag::err_omp_expected_equal_in_iterator);
4801 SourceLocation Loc = Tok.getLocation();
4804 Begin = Actions.ActOnFinishFullExpr(Begin.
get(), Loc,
4807 SourceLocation ColonLoc;
4808 if (Tok.is(tok::colon))
4812 Loc = Tok.getLocation();
4815 End = Actions.ActOnFinishFullExpr(End.
get(), Loc,
4818 SourceLocation SecColonLoc;
4821 if (Tok.is(tok::colon)) {
4825 Loc = Tok.getLocation();
4828 Step = Actions.ActOnFinishFullExpr(Step.
get(), Loc,
4833 if (Tok.isNot(tok::comma) && Tok.isNot(tok::r_paren))
4834 Diag(Tok, diag::err_omp_expected_punc_after_iterator);
4835 if (Tok.is(tok::comma))
4838 SemaOpenMP::OMPIteratorData &D =
Data.emplace_back();
4841 D.
Type = IteratorType;
4851 SourceLocation RLoc = Tok.getLocation();
4852 if (!T.consumeClose())
4853 RLoc = T.getCloseLocation();
4855 return Actions.OpenMP().ActOnOMPIteratorExpr(
getCurScope(), IteratorKwLoc,
4864 if (Kind != OMPC_depend || LangOpts.OpenMP < 51)
4867 if (Tok.is(tok::identifier) &&
4868 Tok.getIdentifierInfo()->isStr(
"omp_all_memory")) {
4870 if (
Data.ExtraModifier == OMPC_DEPEND_outallmemory ||
4871 Data.ExtraModifier == OMPC_DEPEND_inoutallmemory)
4872 Diag(Tok, diag::warn_omp_more_one_omp_all_memory);
4873 else if (
Data.ExtraModifier != OMPC_DEPEND_out &&
4874 Data.ExtraModifier != OMPC_DEPEND_inout)
4875 Diag(Tok, diag::err_omp_requires_out_inout_depend_type);
4877 Data.ExtraModifier =
Data.ExtraModifier == OMPC_DEPEND_out
4878 ? OMPC_DEPEND_outallmemory
4879 : OMPC_DEPEND_inoutallmemory;
4889 if (Tok.isNot(tok::identifier) ||
4890 !Tok.getIdentifierInfo()->isStr(
"omp_num_args")) {
4905 if (Tok.isOneOf(tok::plus, tok::minus)) {
4910 if (Offset.isInvalid())
4912 Bound.
E = Offset.get();
4916 if (!Tok.isOneOf(tok::colon, tok::comma, tok::r_paren,
4917 tok::annot_pragma_openmp_end)) {
4918 Diag(Tok, diag::err_omp_num_args_invalid_form) << 1;
4926 bool IsError =
false;
4932 bool ItemError =
false;
4933 if (Tok.isNot(tok::colon)) {
4937 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
4942 if (Tok.is(tok::colon)) {
4946 if (!Tok.isOneOf(tok::comma, tok::r_paren,
4947 tok::annot_pragma_openmp_end)) {
4951 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
4958 Item.
Lower = LowerBound;
4959 Item.
Upper = UpperBound;
4960 Items.push_back(Item);
4962 }
else if (!ItemError &&
4967 Diag(ItemLoc, diag::err_omp_num_args_invalid_form) << 0;
4971 Item.
E = LowerBound.
E;
4972 Items.push_back(Item);
4978 if (Tok.isNot(tok::comma)) {
4979 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::annot_pragma_openmp_end)) {
4980 Diag(Tok, diag::err_omp_expected_punc)
4981 << getOpenMPClauseName(OMPC_adjust_args) << 0;
4983 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
4986 if (Tok.isNot(tok::comma))
5003 Data.DepModOrTailExpr = Tail.
get();
5005 if (CurTok.
isNot(tok::r_paren) && CurTok.
isNot(tok::comma)) {
5006 P.
Diag(CurTok, diag::err_expected_punc) <<
"step expression";
5024 bool AllocatorSeen =
false;
5025 bool AlignSeen =
false;
5044 if (
Tok.is(tok::l_paren)) {
5045 switch (CurrentModifier) {
5046 case OMPC_ALLOCATE_allocator: {
5047 if (AllocatorSeen) {
5048 P.
Diag(
Tok, diag::err_omp_duplicate_modifier)
5050 << getOpenMPClauseName(Kind);
5052 Data.AllocClauseModifiers.push_back(CurrentModifier);
5053 Data.AllocClauseModifiersLoc.push_back(CurrentModifierLoc);
5056 tok::annot_pragma_openmp_end);
5060 AllocatorSeen =
true;
5063 case OMPC_ALLOCATE_align: {
5065 P.
Diag(
Tok, diag::err_omp_duplicate_modifier)
5067 << getOpenMPClauseName(Kind);
5069 Data.AllocClauseModifiers.push_back(CurrentModifier);
5070 Data.AllocClauseModifiersLoc.push_back(CurrentModifierLoc);
5074 Data.AllocateAlignment = Val.
get();
5079 llvm_unreachable(
"Unexpected allocate modifier");
5082 P.
Diag(
Tok, diag::err_expected) << tok::l_paren;
5084 if (
Tok.isNot(tok::comma))
5087 CurrentModifierLoc =
Tok.getLocation();
5092 P.
Diag(
Tok, diag::err_omp_expected_modifier) << getOpenMPClauseName(Kind);
5095 }
while (!AllocatorSeen || !AlignSeen);
5104 bool InvalidReductionId =
false;
5105 bool IsInvalidMapperModifier =
false;
5109 if (T.expectAndConsume(diag::err_expected_lparen_after,
5110 getOpenMPClauseName(Kind).data()))
5113 bool HasIterator =
false;
5114 bool InvalidIterator =
false;
5115 bool NeedRParenForLinear =
false;
5119 bool ParsedAdjustArgsList =
false;
5120 bool InvalidAdjustArgsList =
false;
5122 tok::annot_pragma_openmp_end);
5124 if (Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
5125 Kind == OMPC_in_reduction) {
5127 if (Kind == OMPC_reduction &&
getLangOpts().OpenMP >= 50 &&
5128 (Tok.is(tok::identifier) || Tok.is(tok::kw_default)) &&
5131 Data.ExtraModifier =
5133 Data.ExtraModifierLoc = Tok.getLocation();
5135 assert(Tok.is(tok::comma) &&
"Expected comma.");
5139 if (Kind == OMPC_reduction &&
getLangOpts().OpenMP >= 60 &&
5140 Tok.is(tok::identifier) && PP.getSpelling(Tok) ==
"original" &&
5146 if (Tok.is(tok::kw_private)) {
5147 Data.OriginalSharingModifier = OMPC_ORIGINAL_SHARING_private;
5148 Data.OriginalSharingModifierLoc = Tok.getLocation();
5150 }
else if (Tok.is(tok::identifier) &&
5151 (PP.getSpelling(Tok) ==
"shared" ||
5152 PP.getSpelling(Tok) ==
"default")) {
5153 Data.OriginalSharingModifier = OMPC_ORIGINAL_SHARING_shared;
5154 Data.OriginalSharingModifierLoc = Tok.getLocation();
5157 Diag(Tok.getLocation(), diag::err_expected)
5158 <<
"'private or shared or default'";
5163 if (!Tok.is(tok::comma)) {
5164 Diag(Tok.getLocation(), diag::err_expected) <<
"',' (comma)";
5171 ParseOptionalCXXScopeSpecifier(
Data.ReductionOrMapperIdScopeSpec,
5176 *
this,
Data.ReductionOrMapperIdScopeSpec, UnqualifiedReductionId);
5177 if (InvalidReductionId) {
5178 SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
5181 if (Tok.is(tok::colon))
5184 Diag(Tok, diag::warn_pragma_expected_colon) <<
"reduction identifier";
5185 if (!InvalidReductionId)
5186 Data.ReductionOrMapperId =
5187 Actions.GetNameFromUnqualifiedId(UnqualifiedReductionId);
5188 }
else if (Kind == OMPC_depend || Kind == OMPC_doacross) {
5190 if (Tok.is(tok::identifier) && PP.getSpelling(Tok) ==
"iterator") {
5199 ExprResult IteratorRes = ParseOpenMPIteratorsExpr();
5200 Data.DepModOrTailExpr = IteratorRes.
get();
5202 ExpectAndConsume(tok::comma);
5208 Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) :
"",
5210 Data.ExtraModifierLoc = Tok.getLocation();
5212 (Kind == OMPC_doacross &&
5214 SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
5219 if (DKind == OMPD_ordered_standalone && Kind == OMPC_depend &&
5220 Data.ExtraModifier == OMPC_DEPEND_source) {
5226 if (Tok.is(tok::colon)) {
5228 }
else if (Kind != OMPC_doacross || Tok.isNot(tok::r_paren)) {
5229 Diag(Tok, DKind == OMPD_ordered_standalone
5230 ? diag::warn_pragma_expected_colon_r_paren
5231 : diag::warn_pragma_expected_colon)
5232 << (Kind == OMPC_depend ?
"dependency type" :
"dependence-type");
5234 if (Kind == OMPC_doacross) {
5235 if (Tok.is(tok::identifier) &&
5236 Tok.getIdentifierInfo()->isStr(
"omp_cur_iteration")) {
5237 Data.ExtraModifier =
Data.ExtraModifier == OMPC_DOACROSS_source
5238 ? OMPC_DOACROSS_source_omp_cur_iteration
5239 : OMPC_DOACROSS_sink_omp_cur_iteration;
5242 if (
Data.ExtraModifier == OMPC_DOACROSS_sink_omp_cur_iteration) {
5243 if (Tok.isNot(tok::minus)) {
5244 Diag(Tok, diag::err_omp_sink_and_source_iteration_not_allowd)
5245 << getOpenMPClauseName(Kind) << 0 << 0;
5252 if (Tok.isNot(tok::numeric_constant) ||
5253 (PP.parseSimpleIntegerLiteral(Tok,
Value) &&
Value != 1)) {
5254 Diag(Loc, diag::err_omp_sink_and_source_iteration_not_allowd)
5255 << getOpenMPClauseName(Kind) << 0 << 0;
5261 if (
Data.ExtraModifier == OMPC_DOACROSS_source_omp_cur_iteration) {
5262 if (Tok.isNot(tok::r_paren)) {
5263 Diag(Tok, diag::err_omp_sink_and_source_iteration_not_allowd)
5264 << getOpenMPClauseName(Kind) << 1 << 1;
5270 if (Kind == OMPC_doacross &&
5271 (
Data.ExtraModifier == OMPC_DOACROSS_source ||
5272 Data.ExtraModifier == OMPC_DOACROSS_source_omp_cur_iteration ||
5273 Data.ExtraModifier == OMPC_DOACROSS_sink_omp_cur_iteration)) {
5279 }
else if (Kind == OMPC_linear) {
5281 Data.ExtraModifier = OMPC_LINEAR_val;
5282 if (Tok.is(tok::identifier) && PP.LookAhead(0).is(tok::l_paren)) {
5283 Data.ExtraModifier =
5287 NeedRParenForLinear =
true;
5289 Diag(
Data.ExtraModifierLoc, diag::err_omp_deprecate_old_syntax)
5290 <<
"linear-modifier(list)" << getOpenMPClauseName(Kind)
5291 <<
"linear(list: [linear-modifier,] step(step-size))";
5293 }
else if (Kind == OMPC_lastprivate) {
5300 Tok.is(tok::identifier) && PP.LookAhead(0).is(tok::colon)) {
5301 Data.ExtraModifier =
5303 Data.ExtraModifierLoc = Tok.getLocation();
5305 assert(Tok.is(tok::colon) &&
"Expected colon.");
5308 }
else if (Kind == OMPC_map) {
5310 if (Tok.is(tok::identifier) && PP.getSpelling(Tok) ==
"iterator") {
5313 Data.MapTypeModifiers.push_back(OMPC_MAP_MODIFIER_iterator);
5314 Data.MapTypeModifiersLoc.push_back(Tok.getLocation());
5315 ExprResult IteratorRes = ParseOpenMPIteratorsExpr();
5316 Data.IteratorExpr = IteratorRes.
get();
5318 ExpectAndConsume(tok::comma);
5320 Diag(Tok, diag::err_omp_unknown_map_type_modifier)
5323 InvalidIterator =
true;
5333 Data.ExtraModifierLoc = Tok.getLocation();
5336 TentativeParsingAction TPA(*
this);
5337 bool ColonPresent =
false;
5338 if (
SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
5340 if (Tok.is(tok::colon))
5341 ColonPresent =
true;
5348 Diag(Tok, diag::err_omp_map_modifier_specification_list);
5350 if (
getLangOpts().OpenMP < 60 && !IsInvalidMapperModifier)
5356 Data.ExtraModifier = OMPC_MAP_tofrom;
5358 if (DKind == OMPD_target_enter_data)
5359 Data.ExtraModifier = OMPC_MAP_to;
5360 else if (DKind == OMPD_target_exit_data)
5361 Data.ExtraModifier = OMPC_MAP_from;
5363 Data.IsMapTypeImplicit =
true;
5366 if (Tok.is(tok::colon))
5368 }
else if (Kind == OMPC_to || Kind == OMPC_from) {
5369 while (Tok.is(tok::identifier)) {
5374 Data.MotionModifiers.push_back(Modifier);
5375 Data.MotionModifiersLoc.push_back(Tok.getLocation());
5376 if (PP.getSpelling(Tok) ==
"iterator" &&
getLangOpts().OpenMP >= 51) {
5378 Tail = ParseOpenMPIteratorsExpr();
5379 Tail = Actions.ActOnFinishFullExpr(Tail.
get(), T.getOpenLocation(),
5382 Data.IteratorExpr = Tail.
get();
5385 if (Modifier == OMPC_MOTION_MODIFIER_mapper) {
5387 if (IsInvalidMapperModifier)
5395 if (Tok.is(tok::comma))
5399 if (!
Data.MotionModifiers.empty() && Tok.isNot(tok::colon)) {
5400 if (!IsInvalidMapperModifier) {
5402 Diag(Tok, diag::warn_pragma_expected_colon) <<
")";
5404 Diag(Tok, diag::warn_pragma_expected_colon) <<
"motion modifier";
5406 SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
5414 }
else if (Kind == OMPC_allocate ||
5415 (Kind == OMPC_affinity && Tok.is(tok::identifier) &&
5416 PP.getSpelling(Tok) ==
"iterator")) {
5420 TentativeParsingAction TPA(*
this);
5425 if (Kind == OMPC_allocate) {
5430 Tail = ParseOpenMPIteratorsExpr();
5432 Tail = Actions.ActOnFinishFullExpr(Tail.
get(), T.getOpenLocation(),
5435 if (Tok.is(tok::colon)) {
5442 if (Kind == OMPC_allocate &&
Data.AllocClauseModifiers.size()) {
5443 SkipUntil(tok::r_paren, tok::annot_pragma_openmp_end,
5445 Diag(Tok, diag::err_modifier_expected_colon) <<
"allocate clause";
5452 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
5455 }
else if (Kind == OMPC_adjust_args) {
5459 Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) :
"",
5461 Data.ExtraModifierLoc = Tok.getLocation();
5463 Diag(Tok, diag::err_omp_unknown_adjust_args_op)
5468 if (Tok.is(tok::colon))
5469 Data.ColonLoc = Tok.getLocation();
5473 if (Tok.is(tok::l_paren)) {
5476 if (Tok.is(tok::identifier)) {
5477 std::string Modifier = PP.getSpelling(Tok);
5478 if (Modifier ==
"fb_nullify" || Modifier ==
"fb_preserve") {
5479 Data.NeedDevicePtrModifier =
5480 Modifier ==
"fb_nullify" ? OMPC_NEED_DEVICE_PTR_fb_nullify
5481 : OMPC_NEED_DEVICE_PTR_fb_preserve;
5483 Diag(Tok, diag::err_omp_unknown_need_device_ptr_kind);
5484 SkipUntil(tok::r_paren, tok::annot_pragma_openmp_end,
5489 if (Tok.is(tok::r_paren)) {
5490 Data.NeedDevicePtrModifierLoc = Tok.getLocation();
5493 Diag(Tok, diag::err_expected) << tok::r_paren;
5494 SkipUntil(tok::r_paren, tok::annot_pragma_openmp_end,
5503 ExpectAndConsume(tok::colon, diag::warn_pragma_expected_colon,
5509 ParsedAdjustArgsList =
true;
5513 }
else if (Kind == OMPC_use_device_ptr) {
5517 if (
getLangOpts().OpenMP >= 61 && Tok.is(tok::identifier)) {
5521 Data.ExtraModifier = FallbackModifier;
5522 Data.ExtraModifierLoc = Tok.getLocation();
5524 if (Tok.is(tok::colon))
5527 Diag(Tok, diag::err_modifier_expected_colon) <<
"fallback";
5530 }
else if (Kind == OMPC_num_teams || Kind == OMPC_thread_limit) {
5534 Data.ExtraModifierArray[0] =
Data.ExtraModifierArray[1] =
5539 bool CanParseLowerBoundModifier = (Kind == OMPC_num_teams);
5540 if (Tok.is(tok::identifier) && Tok.getIdentifierInfo()->isStr(
"dims") &&
5547 Data.ExtraModifierArray[Mod] =
5548 Kind == OMPC_num_teams ?
static_cast<int>(OMPC_NUMTEAMS_dims)
5549 :
static_cast<int>(OMPC_THREADLIMIT_dims);
5550 Data.ExtraModifierExprArray[Mod] = ExprR.
get();
5551 Data.ExtraModifierLocArray[Mod] = TLoc;
5555 if (Tok.is(tok::colon)) {
5558 CanParseLowerBoundModifier =
false;
5559 }
else if (CanParseLowerBoundModifier && Tok.is(tok::comma)) {
5564 Diag(Tok, diag::err_modifier_expected_colon)
5565 << getOpenMPClauseName(Kind);
5567 Data.RLoc = Tok.getLocation();
5568 if (!T.consumeClose())
5569 Data.RLoc = T.getCloseLocation();
5575 if (CanParseLowerBoundModifier) {
5576 TentativeParsingAction TPA(*
this);
5581 Data.RLoc = Tok.getLocation();
5582 if (!T.consumeClose())
5583 Data.RLoc = T.getCloseLocation();
5588 if (Tok.is(tok::colon)) {
5591 Data.ExtraModifierArray[Mod] = OMPC_NUMTEAMS_lower_bound;
5592 Data.ExtraModifierExprArray[Mod] = FirstExpr.
get();
5593 Data.ExtraModifierLocArray[Mod] = TLoc;
5601 }
else if (Kind == OMPC_num_threads) {
5605 bool HasModifier =
false;
5607 if (Tok.is(tok::identifier) && Tok.getIdentifierInfo()->isStr(
"dims") &&
5618 Diag(TLoc, diag::err_omp_incompatible_modifiers)
5621 << getOpenMPClauseName(Kind);
5623 Data.ExtraModifierArray[1] =
static_cast<int>(OMPC_NUMTHREADS_dims);
5624 Data.ExtraModifierExprArray[1] =
5626 Data.ExtraModifierLocArray[1] = TLoc;
5633 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
5638 Diag(Tok, diag::err_omp_incompatible_modifiers)
5641 Data.ExtraModifierArray[0])
5642 << getOpenMPClauseName(Kind);
5643 Data.ExtraModifierArray[0] = Modifier;
5644 Data.ExtraModifierLocArray[0] = Tok.getLocation();
5654 if (Tok.is(tok::comma))
5662 if (!Tok.is(tok::colon)) {
5663 Diag(Tok, diag::err_modifier_expected_colon)
5664 << getOpenMPClauseName(Kind);
5666 Data.RLoc = Tok.getLocation();
5667 if (!T.consumeClose())
5668 Data.RLoc = T.getCloseLocation();
5676 (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
5677 Kind != OMPC_in_reduction && Kind != OMPC_depend &&
5678 Kind != OMPC_doacross && Kind != OMPC_map && Kind != OMPC_adjust_args) ||
5679 (Kind == OMPC_reduction && !InvalidReductionId) ||
5683 (Kind == OMPC_adjust_args &&
5685 const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
5686 while (!ParsedAdjustArgsList &&
5687 (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&
5688 Tok.isNot(tok::annot_pragma_openmp_end)))) {
5695 Vars.push_back(VarExpr.
get());
5697 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
5702 IsComma = Tok.is(tok::comma);
5705 else if (Tok.isNot(tok::r_paren) &&
5706 Tok.isNot(tok::annot_pragma_openmp_end) &&
5707 (!MayHaveTail || Tok.isNot(tok::colon))) {
5708 llvm::omp::Version OMPVersion = Actions.getLangOpts().getOpenMPVersion();
5709 Diag(Tok, diag::err_omp_expected_punc)
5710 << ((Kind == OMPC_flush)
5711 ? getOpenMPDirectiveName(OMPD_flush, OMPVersion)
5712 : getOpenMPClauseName(Kind))
5713 << (Kind == OMPC_flush);
5718 if (NeedRParenForLinear)
5722 const bool MustHaveTail = MayHaveTail && Tok.is(tok::colon);
5723 bool StepFound =
false;
5724 bool ModifierFound =
false;
5726 Data.ColonLoc = Tok.getLocation();
5729 if (
getLangOpts().OpenMP >= 52 && Kind == OMPC_linear) {
5730 bool Malformed =
false;
5731 while (Tok.isNot(tok::r_paren)) {
5732 if (Tok.is(tok::identifier)) {
5737 Kind, Tok.isAnnotation() ?
"" : PP.getSpelling(Tok),
5740 if (LinKind == OMPC_LINEAR_step) {
5742 Diag(Tok, diag::err_omp_multiple_step_or_linear_modifier) << 0;
5745 tok::annot_pragma_openmp_end);
5749 Diag(StepModifierLoc, diag::err_expected_lparen_after) <<
"step";
5754 Data.StepModifierLoc = StepModifierLoc;
5758 }
else if (LinKind >= 0 && LinKind < OMPC_LINEAR_step) {
5760 Diag(Tok, diag::err_omp_multiple_step_or_linear_modifier) << 1;
5762 Data.ExtraModifier = LinKind;
5764 ModifierFound =
true;
5769 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
5778 if (Tok.is(tok::comma))
5780 if (Tok.is(tok::r_paren) || Tok.is(tok::annot_pragma_openmp_end))
5783 if (!Malformed && !StepFound && !ModifierFound)
5784 Diag(ELoc, diag::err_expected_expression);
5788 Tail = Actions.ActOnFinishFullExpr(Tail.
get(), ELoc,
5791 Data.DepModOrTailExpr = Tail.
get();
5793 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
5799 Data.RLoc = Tok.getLocation();
5800 if (!T.consumeClose())
5801 Data.RLoc = T.getCloseLocation();
5805 return (Kind != OMPC_depend && Kind != OMPC_doacross && Kind != OMPC_map &&
5806 Vars.empty() && AdjustArgsItems.empty()) ||
5807 (MustHaveTail && !
Data.DepModOrTailExpr && StepFound) ||
5808 InvalidReductionId || IsInvalidMapperModifier || InvalidIterator ||
5809 InvalidAdjustArgsList;
5837 "Expected parsing to start at clause name");
5842 if (T.consumeOpen()) {
5843 Diag(
Tok, diag::err_expected) << tok::l_paren;
5856 Exprs.push_back(Val.
get());
5859 bool Result = T.consumeClose();
5860 OpenLoc = T.getOpenLocation();
5861 CloseLoc = T.getCloseLocation();
Defines the clang::ASTContext interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
static OpenMPDirectiveKind checkOpenMPDirectiveName(Parser &P, SourceLocation Loc, OpenMPDirectiveKind Kind, StringRef Name)
static OpenMPDirectiveKind parseOpenMPDirectiveKind(Parser &P)
static OpenMPMapModifierKind isMapModifier(Parser &P)
Checks if the token is a valid map-type-modifier.
static std::optional< SimpleClauseData > parseOpenMPSimpleClause(Parser &P, OpenMPClauseKind Kind)
static bool checkExtensionProperty(Parser &P, SourceLocation Loc, OMPTraitProperty &TIProperty, OMPTraitSelector &TISelector, llvm::StringMap< SourceLocation > &Seen)
static ExprResult parseOpenMPAllocateClauseModifiers(Parser &P, OpenMPClauseKind Kind, SemaOpenMP::OpenMPVarListDataTy &Data)
Parse 'allocate' clause modifiers.
static DeclarationName parseOpenMPReductionId(Parser &P)
static ExprResult parseContextScore(Parser &P)
Parse optional 'score' '(' <expr> ')' ':'.
static bool ParseReductionId(Parser &P, CXXScopeSpec &ReductionIdScopeSpec, UnqualifiedId &ReductionId)
static bool parseStepSize(Parser &P, SemaOpenMP::OpenMPVarListDataTy &Data, OpenMPClauseKind CKind, SourceLocation ELoc)
Parse step size expression.
static void parseMapType(Parser &P, SemaOpenMP::OpenMPVarListDataTy &Data)
Parse map-type in map clause.
static bool parseDeclareSimdClauses(Parser &P, OMPDeclareSimdDeclAttr::BranchStateTy &BS, ExprResult &SimdLen, SmallVectorImpl< Expr * > &Uniforms, SmallVectorImpl< Expr * > &Aligneds, SmallVectorImpl< Expr * > &Alignments, SmallVectorImpl< Expr * > &Linears, SmallVectorImpl< unsigned > &LinModifiers, SmallVectorImpl< Expr * > &Steps)
Parses clauses for 'declare simd' directive.
static OpenMPMapClauseKind isMapType(Parser &P)
Checks if the token is a valid map-type.
This file declares semantic analysis functions specific to AMDGPU.
This file declares facilities that support code completion.
This file declares semantic analysis for OpenMP constructs and clauses.
Defines the clang::TokenKind enum and support functions.
VerifyDiagnosticConsumer::Directive Directive
void getAsVariantMatchInfo(ASTContext &ASTCtx, llvm::omp::VariantMatchInfo &VMI) const
Create a variant match info object from this trait info object.
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
bool anyScoreOrCondition(llvm::function_ref< bool(Expr *&, bool)> Cond)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
DeclarationNameTable DeclarationNames
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
Represents a C++ nested-name-specifier or a global scope specifier.
bool isEmpty() const
No scope specifier.
static const TST TST_unspecified
Decl - This represents one declaration (or definition), e.g.
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
SourceLocation getLocation() const
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
The name of a declaration.
bool isEmpty() const
Evaluates true when this declaration name is empty.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
llvm::omp::Version getOpenMPVersion() const
Return the OpenMP version.
This represents a decl that may have a name.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
This is a basic class for representing single OpenMP clause.
static const ParsedAttributesView & none()
ParsedAttributes - A collection of parsed attributes.
Introduces zero or more scopes for parsing.
void Enter(unsigned ScopeFlags)
ParseScope - Introduces a new scope for parsing.
Parser - This implements a parser for the C family of languages.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Preprocessor & getPreprocessor() const
bool parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data)
Parse map-type-modifiers in map clause.
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
ParseStringLiteralExpression - This handles the various token types that form string literals,...
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
bool ParseOpenMPAdjustArgsList(SmallVectorImpl< OMPAdjustArgsItem > &Items)
Parses an OpenMP 6.0 'adjust_args' parameter list, whose items may be parameter names,...
Sema & getActions() const
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
bool parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy &Data)
Parses the mapper modifier in map, to, and from clauses.
friend class ParsingOpenMPDirectiveRAII
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
friend class ColonProtectionRAIIObject
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
bool TryConsumeToken(tok::TokenKind Expected)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Scope * getCurScope() const
bool ParseOpenMPVarList(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, SmallVectorImpl< Expr * > &Vars, SemaOpenMP::OpenMPVarListDataTy &Data, SmallVectorImpl< OMPAdjustArgsItem > &AdjustArgsItems)
Parses clauses with list.
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
const Token & getCurToken() const
bool ParseOpenMPAdjustArgsBound(OMPAdjustArgsItem::Bound &Bound)
Parses one bound of an OpenMP 6.0 'adjust_args' parameter range, which may be 'omp_num_args' with an ...
void ExitScope()
ExitScope - Pop a scope off the scope stack.
ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc, bool IsAddressOfOperand=false)
Parses simple expression in parens for single-expression clauses of OpenMP constructs.
const LangOptions & getLangOpts() const
friend class ParenBraceBracketBalancer
ExprResult ParseExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
bool ParseOpenMPReservedLocator(OpenMPClauseKind Kind, SemaOpenMP::OpenMPVarListDataTy &Data, const LangOptions &LangOpts)
Parses a reserved locator like 'omp_all_memory'.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
ExprResult ParseAssignmentExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Parse an expr that doesn't include (top-level) commas.
friend class BalancedDelimiterTracker
unsigned ReenterTemplateScopes(MultiParseScope &S, Decl *D)
Re-enter a possible template scope, creating as many template parameter scopes as necessary.
bool ParseOpenMPDeclareBeginVariantDirective(SourceLocation Loc)
Parses 'omp begin declare variant' directive.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The collection of all-type qualifiers we support.
Represents a struct/union/class.
@ OpenMPDirectiveScope
This is the scope of OpenMP executable directive.
@ CompoundStmtScope
This is a compound statement scope.
@ OpenMPSimdDirectiveScope
This is the scope of some OpenMP simd directive.
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ OpenMPLoopDirectiveScope
This is the scope of some OpenMP loop directive.
@ DeclScope
This is a scope that can contain a declaration.
Smart pointer class that efficiently represents Objective-C method names.
bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind, SourceLocation LinLoc)
Checks correctness of linear modifiers.
OMPClause * ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< UsesAllocatorsData > Data)
Called on well-formed 'uses_allocators' clause.
OMPClause * ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
OMPClause * ActOnOpenMPVarListClause(OpenMPClauseKind Kind, ArrayRef< Expr * > Vars, const OMPVarListLocTy &Locs, OpenMPVarListDataTy &Data)
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Sema - This implements semantic analysis and AST building for C.
Scope * getCurScope() const
Retrieve the parser's current scope.
void ActOnExitFunctionContext()
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
ASTContext & getASTContext() const
const LangOptions & getLangOpts() const
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
A trivial tuple used to represent a source range.
StringLiteral - This represents a string literal expression, e.g.
Token - This structure provides full information about a lexed token.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
tok::TokenKind getKind() const
bool isNot(tok::TokenKind K) const
Base wrapper for a particular "section" of type source info.
The base class of the type hierarchy.
QualType getCanonicalTypeInternal() const
Represents a C++ unqualified-id that has been parsed.
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
Represents a variable declaration or definition.
Defines the clang::TargetInfo interface.
PRESERVE_NONE bool Ret(InterpState &S)
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.
Top level wrappers for InstallAPI frontend operations.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
@ OMPC_DEFAULTMAP_MODIFIER_unknown
@ OMPC_ORDER_MODIFIER_unknown
OpenMPNeedDevicePtrModifier
OpenMP 6.1 need_device modifier.
@ OMPC_NEED_DEVICE_PTR_unknown
OpenMPAdjustArgsOpKind
OpenMP adjust-op kinds for 'adjust_args' clause.
@ OMPC_ADJUST_ARGS_unknown
bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a distribute directive.
OpenMPDeviceType
OpenMP device type for 'device_type' clause.
@ OMPC_DEVICE_TYPE_unknown
@ OMPC_SCHEDULE_MODIFIER_unknown
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a target code offload directive.
@ OMPC_DYN_GROUPPRIVATE_FALLBACK_unknown
@ OMPC_DYN_GROUPPRIVATE_FALLBACK_last
@ Property
The type of a property.
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
@ OMPC_LASTPRIVATE_unknown
OpenMPGrainsizeClauseModifier
unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str, const LangOptions &LangOpts)
OpenMPNumTasksClauseModifier
OpenMPUseDevicePtrFallbackModifier
OpenMP 6.1 use_device_ptr fallback modifier.
@ OMPC_USE_DEVICE_PTR_FALLBACK_unknown
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
OpenMPMotionModifierKind
OpenMP modifier kind for 'to' or 'from' clause.
@ OMPC_MOTION_MODIFIER_unknown
@ OMPC_DEFAULTMAP_unknown
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
bool isOpenMPExecutableDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is considered as "executable".
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
@ OMPC_DYN_GROUPPRIVATE_unknown
bool isOpenMPInformationalDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is considered as "informational".
bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a simd directive.
@ OMPC_THREADLIMIT_unknown
OpenMPNumThreadsClauseModifier
@ OMPC_NUMTHREADS_unknown
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
OpenMPMapModifierKind
OpenMP modifier kind for 'map' clause.
@ OMPC_MAP_MODIFIER_unknown
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
ActionResult< Expr * > ExprResult
bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a taskloop directive.
ActionResult< Stmt * > StmtResult
OpenMPDefaultClauseVariableCategory getOpenMPDefaultVariableCategory(StringRef Str, const LangOptions &LangOpts)
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
int const char * function
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 unsigned
llvm::omp::TraitProperty Kind
StringRef RawString
The raw string as we parsed it. This is needed for the isa trait set (which accepts anything) and (la...
llvm::omp::TraitSelector Kind
SmallVector< OMPTraitProperty, 1 > Properties
SmallVector< OMPTraitSelector, 2 > Selectors
Clang specific specialization of the OMPContext to lookup target features.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
One bound of a parameter range.
Expr * E
The bound expression, or the logical offset for a NumArgs bound.
One item in an OpenMP 'adjust_args' parameter list.
Expr * E
A named parameter or positional expression for a Single item.
llvm::SmallVector< OMPInteropPref, 4 > Prefs
This structure contains most locations needed for by an OMPVarListClause.
std::optional< Expr * > Indirect
The directive with indirect clause.
OpenMPDirectiveKind Kind
The directive kind, begin declare target or declare target.
OMPDeclareTargetDeclAttr::DevTypeTy DT
The 'device_type' as parsed from the clause.
SourceLocation Loc
The directive location.
llvm::DenseMap< NamedDecl *, MapInfo > ExplicitlyMapped
Explicitly listed variables and functions in a 'to' or 'link' clause.
SourceLocation DeclIdentLoc
SourceLocation SecColonLoc
IdentifierInfo * DeclIdent
OMPIteratorExpr::IteratorRange Range
Data used for processing a list of variables in OpenMP clauses.
Data for list of allocators.
Expr * AllocatorTraits
Allocator traits.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
Expr * Allocator
Allocator.