@@ -3717,6 +3717,7 @@ namespace {
37173717class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
37183718 DSAStackTy *Stack;
37193719 Sema &SemaRef;
3720+ OpenMPDirectiveKind DKind = OMPD_unknown;
37203721 bool ErrorFound = false;
37213722 bool TryCaptureCXXThisMembers = false;
37223723 CapturedStmt *CS = nullptr;
@@ -3748,7 +3749,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
37483749 // Try to capture inner this->member references to generate correct mappings
37493750 // and diagnostics.
37503751 if (TryCaptureCXXThisMembers ||
3751- (isOpenMPTargetExecutionDirective(Stack->getCurrentDirective() ) &&
3752+ (isOpenMPTargetExecutionDirective(DKind ) &&
37523753 llvm::any_of(S->getInnermostCapturedStmt()->captures(),
37533754 [](const CapturedStmt::Capture &C) {
37543755 return C.capturesThis();
@@ -3818,7 +3819,6 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
38183819 return;
38193820
38203821 SourceLocation ELoc = E->getExprLoc();
3821- OpenMPDirectiveKind DKind = Stack->getCurrentDirective();
38223822 // The default(none) clause requires that each variable that is referenced
38233823 // in the construct, and does not have a predetermined data-sharing
38243824 // attribute, must have its data-sharing attribute explicitly determined
@@ -3983,7 +3983,6 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
39833983 E->containsUnexpandedParameterPack() || E->isInstantiationDependent())
39843984 return;
39853985 auto *FD = dyn_cast<FieldDecl>(E->getMemberDecl());
3986- OpenMPDirectiveKind DKind = Stack->getCurrentDirective();
39873986 if (auto *TE = dyn_cast<CXXThisExpr>(E->getBase()->IgnoreParenCasts())) {
39883987 if (!FD)
39893988 return;
@@ -4065,8 +4064,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
40654064 if (isOpenMPTargetExecutionDirective(DKind)) {
40664065 OMPClauseMappableExprCommon::MappableExprComponentList CurComponents;
40674066 if (!checkMapClauseExpressionBase(SemaRef, E, CurComponents, OMPC_map,
4068- Stack->getCurrentDirective(),
4069- /*NoDiagnose=*/true))
4067+ DKind, /*NoDiagnose=*/true))
40704068 return;
40714069 const auto *VD = cast<ValueDecl>(
40724070 CurComponents.back().getAssociatedDeclaration()->getCanonicalDecl());
@@ -4119,8 +4117,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
41194117 // Skip analysis of arguments of implicitly defined map clause for target
41204118 // directives.
41214119 if (C && !((isa<OMPFirstprivateClause>(C) || isa<OMPMapClause>(C)) &&
4122- C->isImplicit() &&
4123- !isOpenMPTaskingDirective(Stack->getCurrentDirective()))) {
4120+ C->isImplicit() && !isOpenMPTaskingDirective(DKind))) {
41244121 for (Stmt *CC : C->children()) {
41254122 if (CC)
41264123 Visit(CC);
@@ -4169,7 +4166,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
41694166 VarDecl *VD = Cap.getCapturedVar();
41704167 // Do not try to map the variable if it or its sub-component was mapped
41714168 // already.
4172- if (isOpenMPTargetExecutionDirective(Stack->getCurrentDirective() ) &&
4169+ if (isOpenMPTargetExecutionDirective(DKind ) &&
41734170 Stack->checkMappableExprComponentListsForDecl(
41744171 VD, /*CurrentRegionOnly=*/true,
41754172 [](OMPClauseMappableExprCommon::MappableExprComponentListRef,
@@ -4200,8 +4197,9 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
42004197
42014198 DSAAttrChecker(DSAStackTy *S, Sema &SemaRef, CapturedStmt *CS)
42024199 : Stack(S), SemaRef(SemaRef), ErrorFound(false), CS(CS) {
4200+ DKind = S->getCurrentDirective();
42034201 // Process declare target link variables for the target directives.
4204- if (isOpenMPTargetExecutionDirective(S->getCurrentDirective() )) {
4202+ if (isOpenMPTargetExecutionDirective(DKind )) {
42054203 for (DeclRefExpr *E : Stack->getLinkGlobals())
42064204 Visit(E);
42074205 }
0 commit comments