@@ -17321,96 +17321,97 @@ OMPClause *SemaOpenMP::ActOnOpenMPDefaultClause(
1732117321 << getOpenMPSimpleClauseTypeName(OMPC_default, unsigned(M));
1732217322 return nullptr;
1732317323 }
17324- bool IsTargetDefault = getLangOpts().OpenMP >= 60 &&
17325- DSAStack->getCurrentDirective() == OMPD_target;
17324+
17325+ bool IsTargetDefault =
17326+ getLangOpts().OpenMP >= 60 &&
17327+ isOpenMPTargetExecutionDirective(DSAStack->getCurrentDirective());
1732617328
1732717329 // OpenMP 6.0, page 224, lines 3-4 default Clause, Semantics
1732817330 // If data-sharing-attribute is shared then the clause has no effect
1732917331 // on a target construct;
1733017332 if (IsTargetDefault && M == OMP_DEFAULT_shared)
1733117333 return nullptr;
1733217334
17333- OpenMPDefaultmapClauseModifier DefMapMod;
17334- OpenMPDefaultmapClauseKind DefMapKind;
17335- std::function<void(SourceLocation)> SetDefaultDSA;
17336- std::function<void(SourceLocation)> SetDefaultDSAVC ;
17337- // default data-sharing-attribute
17338- switch (M) {
17339- case OMP_DEFAULT_none:
17340- DefMapMod = OMPC_DEFAULTMAP_MODIFIER_none;
17341- SetDefaultDSA = [&](SourceLocation MLoc) {
17342- DSAStack->setDefaultDSANone(MLoc) ;
17343- };
17344- break ;
17345- case OMP_DEFAULT_firstprivate:
17346- DefMapMod = OMPC_DEFAULTMAP_MODIFIER_firstprivate;
17347- SetDefaultDSA = [&](SourceLocation MLoc) {
17348- DSAStack->setDefaultDSAFirstPrivate(MLoc) ;
17349- };
17350- break ;
17351- case OMP_DEFAULT_private:
17352- DefMapMod = OMPC_DEFAULTMAP_MODIFIER_private;
17353- SetDefaultDSA = [&](SourceLocation MLoc) {
17354- DSAStack->setDefaultDSAPrivate(MLoc) ;
17355- };
17356- break ;
17357- case OMP_DEFAULT_shared:
17358- assert(!IsTargetDefault && "DSA shared invalid with target directive");
17359- SetDefaultDSA = [&](SourceLocation MLoc) {
17335+ auto &&SetDefaultClauseAttrs = [&](llvm::omp::DefaultKind M,
17336+ OpenMPDefaultClauseVariableCategory
17337+ VCKind) {
17338+ OpenMPDefaultmapClauseModifier DefMapMod ;
17339+ OpenMPDefaultmapClauseKind DefMapKind;
17340+ // default data-sharing-attribute
17341+ switch (M) {
17342+ case OMP_DEFAULT_none:
17343+ if (IsTargetDefault)
17344+ DefMapMod = OMPC_DEFAULTMAP_MODIFIER_none ;
17345+ else
17346+ DSAStack->setDefaultDSANone(MLoc) ;
17347+ break;
17348+ case OMP_DEFAULT_firstprivate:
17349+ if (IsTargetDefault)
17350+ DefMapMod = OMPC_DEFAULTMAP_MODIFIER_firstprivate ;
17351+ else
17352+ DSAStack->setDefaultDSAFirstPrivate(MLoc) ;
17353+ break;
17354+ case OMP_DEFAULT_private:
17355+ if (IsTargetDefault)
17356+ DefMapMod = OMPC_DEFAULTMAP_MODIFIER_private ;
17357+ else
17358+ DSAStack->setDefaultDSAPrivate(MLoc) ;
17359+ break;
17360+ case OMP_DEFAULT_shared:
17361+ assert(!IsTargetDefault && "DSA shared invalid with target directive");
1736017362 DSAStack->setDefaultDSAShared(MLoc);
17361- };
17362- break;
17363- default:
17364- llvm_unreachable("unexpected DSA in OpenMP default clause");
17365- }
17366- // default variable-category
17367- switch (VCKind) {
17368- case OMPC_DEFAULT_VC_aggregate:
17369- DefMapKind = OMPC_DEFAULTMAP_aggregate;
17370- SetDefaultDSAVC = [&](SourceLocation VCKindLoc) {
17371- DSAStack->setDefaultDSAVCAggregate(VCKindLoc);
17372- };
17373- break;
17374- case OMPC_DEFAULT_VC_pointer:
17375- DefMapKind = OMPC_DEFAULTMAP_pointer;
17376- SetDefaultDSAVC = [&](SourceLocation VCKindLoc) {
17377- DSAStack->setDefaultDSAVCPointer(VCKindLoc);
17378- };
17379- break;
17380- case OMPC_DEFAULT_VC_scalar:
17381- DefMapKind = OMPC_DEFAULTMAP_scalar;
17382- SetDefaultDSAVC = [&](SourceLocation VCKindLoc) {
17383- DSAStack->setDefaultDSAVCScalar(VCKindLoc);
17384- };
17385- break;
17386- case OMPC_DEFAULT_VC_all:
17387- DefMapKind = OMPC_DEFAULTMAP_all;
17388- SetDefaultDSAVC = [&](SourceLocation VCKindLoc) {
17389- DSAStack->setDefaultDSAVCAll(VCKindLoc);
17390- };
17391- break;
17392- default:
17393- llvm_unreachable("unexpected variable category in OpenMP default clause");
17394- }
17395-
17396- // OpenMP 6.0, page 224, lines 4-5 default Clause, Semantics
17397- // otherwise, its effect on a target construct is equivalent to
17398- // specifying the defaultmap clause with the same data-sharing-attribute
17399- // and variable-category.
17400- if (IsTargetDefault) {
17401- if (DefMapKind == OMPC_DEFAULTMAP_all) {
17402- DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_aggregate, MLoc);
17403- DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_scalar, MLoc);
17404- DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_pointer, MLoc);
17405- } else {
17406- DSAStack->setDefaultDMAAttr(DefMapMod, DefMapKind, MLoc);
17363+ break;
17364+ default:
17365+ llvm_unreachable("unexpected DSA in OpenMP default clause");
1740717366 }
17408- } else {
17409- // If earlier than OpenMP 6.0, or not a target directive, then set
17410- // default DSA as before.
17411- SetDefaultDSA(MLoc);
17412- SetDefaultDSAVC(VCKindLoc);
17413- }
17367+ // default variable-category
17368+ switch (VCKind) {
17369+ case OMPC_DEFAULT_VC_aggregate:
17370+ if (IsTargetDefault)
17371+ DefMapKind = OMPC_DEFAULTMAP_aggregate;
17372+ else
17373+ DSAStack->setDefaultDSAVCAggregate(VCKindLoc);
17374+ break;
17375+ case OMPC_DEFAULT_VC_pointer:
17376+ if (IsTargetDefault)
17377+ DefMapKind = OMPC_DEFAULTMAP_pointer;
17378+ else
17379+ DSAStack->setDefaultDSAVCPointer(VCKindLoc);
17380+ break;
17381+ case OMPC_DEFAULT_VC_scalar:
17382+ if (IsTargetDefault)
17383+ DefMapKind = OMPC_DEFAULTMAP_scalar;
17384+ else
17385+ DSAStack->setDefaultDSAVCScalar(VCKindLoc);
17386+ break;
17387+ case OMPC_DEFAULT_VC_all:
17388+ if (IsTargetDefault)
17389+ DefMapKind = OMPC_DEFAULTMAP_all;
17390+ else
17391+ DSAStack->setDefaultDSAVCAll(VCKindLoc);
17392+ break;
17393+ default:
17394+ llvm_unreachable("unexpected variable category in OpenMP default clause");
17395+ }
17396+ // OpenMP 6.0, page 224, lines 4-5 default Clause, Semantics
17397+ // otherwise, its effect on a target construct is equivalent to
17398+ // specifying the defaultmap clause with the same data-sharing-attribute
17399+ // and variable-category.
17400+ //
17401+ // If earlier than OpenMP 6.0, or not a target directive, the default DSA
17402+ // is/was set as before.
17403+ if (IsTargetDefault) {
17404+ if (DefMapKind == OMPC_DEFAULTMAP_all) {
17405+ DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_aggregate, MLoc);
17406+ DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_scalar, MLoc);
17407+ DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_pointer, MLoc);
17408+ } else {
17409+ DSAStack->setDefaultDMAAttr(DefMapMod, DefMapKind, MLoc);
17410+ }
17411+ }
17412+ };
17413+
17414+ SetDefaultClauseAttrs(M, VCKind);
1741417415 return new (getASTContext())
1741517416 OMPDefaultClause(M, MLoc, VCKind, VCKindLoc, StartLoc, LParenLoc, EndLoc);
1741617417}
0 commit comments