diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/OpenMPClause.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 33 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 23 |
4 files changed, 41 insertions, 30 deletions
diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp index 1ef43f7694c..1d1da53732d 100644 --- a/clang/lib/AST/OpenMPClause.cpp +++ b/clang/lib/AST/OpenMPClause.cpp @@ -400,10 +400,12 @@ OMPMapClause *OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, OpenMPMapClauseKind TypeModifier, OpenMPMapClauseKind Type, + bool TypeIsImplicit, SourceLocation TypeLoc) { void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); - OMPMapClause *Clause = new (Mem) OMPMapClause( - TypeModifier, Type, TypeLoc, StartLoc, LParenLoc, EndLoc, VL.size()); + OMPMapClause *Clause = + new (Mem) OMPMapClause(TypeModifier, Type, TypeIsImplicit, TypeLoc, + StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); Clause->setMapTypeModifier(TypeModifier); Clause->setMapType(Type); diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 94d90c0e210..a2e887f7cfd 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -898,6 +898,7 @@ OMPClause *Parser::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, OpenMPLinearClauseKind LinearModifier = OMPC_LINEAR_val; OpenMPMapClauseKind MapType = OMPC_MAP_unknown; OpenMPMapClauseKind MapTypeModifier = OMPC_MAP_unknown; + bool MapTypeIsImplicit = false; bool MapTypeModifierSpecified = false; bool UnexpectedId = false; SourceLocation DepLinMapLoc; @@ -948,7 +949,8 @@ OMPClause *Parser::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, Kind, llvm::None, /*TailExpr=*/nullptr, Loc, LOpen, /*ColonLoc=*/SourceLocation(), Tok.getLocation(), ReductionIdScopeSpec, DeclarationNameInfo(), DepKind, - LinearModifier, MapTypeModifier, MapType, DepLinMapLoc); + LinearModifier, MapTypeModifier, MapType, MapTypeIsImplicit, + DepLinMapLoc); } } if (Tok.is(tok::colon)) { @@ -1012,9 +1014,11 @@ OMPClause *Parser::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, ConsumeToken(); } else { MapType = OMPC_MAP_tofrom; + MapTypeIsImplicit = true; } } else { MapType = OMPC_MAP_tofrom; + MapTypeIsImplicit = true; } } else { UnexpectedId = true; @@ -1095,6 +1099,7 @@ OMPClause *Parser::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, ReductionIdScopeSpec, ReductionId.isValid() ? Actions.GetNameFromUnqualifiedId(ReductionId) : DeclarationNameInfo(), - DepKind, LinearModifier, MapTypeModifier, MapType, DepLinMapLoc); + DepKind, LinearModifier, MapTypeModifier, MapType, MapTypeIsImplicit, + DepLinMapLoc); } diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 1b515536389..3817704a1ac 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -6513,8 +6513,9 @@ OMPClause *Sema::ActOnOpenMPVarListClause( SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, OpenMPDependClauseKind DepKind, - OpenMPLinearClauseKind LinKind, OpenMPMapClauseKind MapTypeModifier, - OpenMPMapClauseKind MapType, SourceLocation DepLinMapLoc) { + OpenMPLinearClauseKind LinKind, OpenMPMapClauseKind MapTypeModifier, + OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, + SourceLocation DepLinMapLoc) { OMPClause *Res = nullptr; switch (Kind) { case OMPC_private: @@ -6555,8 +6556,9 @@ OMPClause *Sema::ActOnOpenMPVarListClause( StartLoc, LParenLoc, EndLoc); break; case OMPC_map: - Res = ActOnOpenMPMapClause(MapTypeModifier, MapType, DepLinMapLoc, ColonLoc, - VarList, StartLoc, LParenLoc, EndLoc); + Res = ActOnOpenMPMapClause(MapTypeModifier, MapType, IsMapTypeImplicit, + DepLinMapLoc, ColonLoc, VarList, StartLoc, + LParenLoc, EndLoc); break; case OMPC_if: case OMPC_final: @@ -8474,10 +8476,12 @@ static bool CheckTypeMappable(SourceLocation SL, SourceRange SR, Sema &SemaRef, return true; } -OMPClause *Sema::ActOnOpenMPMapClause( - OpenMPMapClauseKind MapTypeModifier, OpenMPMapClauseKind MapType, - SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList, - SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) { +OMPClause * +Sema::ActOnOpenMPMapClause(OpenMPMapClauseKind MapTypeModifier, + OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, + SourceLocation MapLoc, SourceLocation ColonLoc, + ArrayRef<Expr *> VarList, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation EndLoc) { SmallVector<Expr *, 4> Vars; for (auto &RE : VarList) { @@ -8592,9 +8596,8 @@ OMPClause *Sema::ActOnOpenMPMapClause( if (DKind == OMPD_target_enter_data && !(MapType == OMPC_MAP_to || MapType == OMPC_MAP_alloc)) { Diag(StartLoc, diag::err_omp_invalid_map_type_for_directive) - << - // TODO: Need to determine if map type is implicitly determined - 0 << getOpenMPSimpleClauseTypeName(OMPC_map, MapType) + << (IsMapTypeImplicit ? 1 : 0) + << getOpenMPSimpleClauseTypeName(OMPC_map, MapType) << getOpenMPDirectiveName(DKind); // Proceed to add the variable in a map clause anyway, to prevent // further spurious messages @@ -8609,9 +8612,8 @@ OMPClause *Sema::ActOnOpenMPMapClause( !(MapType == OMPC_MAP_from || MapType == OMPC_MAP_release || MapType == OMPC_MAP_delete)) { Diag(StartLoc, diag::err_omp_invalid_map_type_for_directive) - << - // TODO: Need to determine if map type is implicitly determined - 0 << getOpenMPSimpleClauseTypeName(OMPC_map, MapType) + << (IsMapTypeImplicit ? 1 : 0) + << getOpenMPSimpleClauseTypeName(OMPC_map, MapType) << getOpenMPDirectiveName(DKind); // Proceed to add the variable in a map clause anyway, to prevent // further spurious messages @@ -8625,7 +8627,8 @@ OMPClause *Sema::ActOnOpenMPMapClause( return nullptr; return OMPMapClause::Create(Context, StartLoc, LParenLoc, EndLoc, Vars, - MapTypeModifier, MapType, MapLoc); + MapTypeModifier, MapType, IsMapTypeImplicit, + MapLoc); } OMPClause *Sema::ActOnOpenMPNumTeamsClause(Expr *NumTeams, diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 3b435731952..11793c6ebcc 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1658,14 +1658,15 @@ public: /// /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. - OMPClause *RebuildOMPMapClause( - OpenMPMapClauseKind MapTypeModifier, OpenMPMapClauseKind MapType, - SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList, - SourceLocation StartLoc, SourceLocation LParenLoc, - SourceLocation EndLoc) { - return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType, MapLoc, - ColonLoc, VarList,StartLoc, - LParenLoc, EndLoc); + OMPClause * + RebuildOMPMapClause(OpenMPMapClauseKind MapTypeModifier, + OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, + SourceLocation MapLoc, SourceLocation ColonLoc, + ArrayRef<Expr *> VarList, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation EndLoc) { + return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType, + IsMapTypeImplicit, MapLoc, ColonLoc, + VarList, StartLoc, LParenLoc, EndLoc); } /// \brief Build a new OpenMP 'num_teams' clause. @@ -7860,9 +7861,9 @@ OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) { Vars.push_back(EVar.get()); } return getDerived().RebuildOMPMapClause( - C->getMapTypeModifier(), C->getMapType(), C->getMapLoc(), - C->getColonLoc(), Vars, C->getLocStart(), C->getLParenLoc(), - C->getLocEnd()); + C->getMapTypeModifier(), C->getMapType(), C->isImplicitMapType(), + C->getMapLoc(), C->getColonLoc(), Vars, C->getLocStart(), + C->getLParenLoc(), C->getLocEnd()); } template <typename Derived> |