diff options
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index ba0481874577..ae91a6470471 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -36,6 +36,7 @@ #include "llvm/ADT/PointerEmbeddedInt.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Frontend/OpenMP/OMPAssume.h" #include "llvm/Frontend/OpenMP/OMPConstants.h" #include <set> @@ -7051,7 +7052,8 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG, QualType AdjustedFnType = FD->getType(); if (NumAppendArgs) { - if (isa<FunctionNoProtoType>(FD->getType())) { + const auto *PTy = AdjustedFnType->getAsAdjusted<FunctionProtoType>(); + if (!PTy) { Diag(FD->getLocation(), diag::err_omp_declare_variant_prototype_required) << SR; return None; @@ -7069,8 +7071,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG, Diag(SR.getBegin(), diag::err_omp_interop_type_not_found) << SR; return None; } - QualType InteropType = QualType(TD->getTypeForDecl(), 0); - auto *PTy = cast<FunctionProtoType>(FD->getType()); + QualType InteropType = Context.getTypeDeclType(TD); if (PTy->isVariadic()) { Diag(FD->getLocation(), diag::err_omp_append_args_with_varargs) << SR; return None; @@ -13148,7 +13149,7 @@ StmtResult Sema::ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses, if (FullClause) { if (!VerifyPositiveIntegerConstantInClause( LoopHelper.NumIterations, OMPC_full, /*StrictlyPositive=*/false, - /*SuppressExprDigs=*/true) + /*SuppressExprDiags=*/true) .isUsable()) { Diag(AStmt->getBeginLoc(), diag::err_omp_unroll_full_variable_trip_count); Diag(FullClause->getBeginLoc(), diag::note_omp_directive_here) @@ -20761,8 +20762,7 @@ Sema::ActOnOpenMPEndDeclareTargetDirective() { void Sema::ActOnFinishedOpenMPDeclareTargetContext( DeclareTargetContextInfo &DTCI) { for (auto &It : DTCI.ExplicitlyMapped) - ActOnOpenMPDeclareTargetName(It.first, It.second.Loc, It.second.MT, - DTCI.DT); + ActOnOpenMPDeclareTargetName(It.first, It.second.Loc, It.second.MT, DTCI); } NamedDecl *Sema::lookupOpenMPDeclareTargetName(Scope *CurScope, @@ -20799,9 +20799,9 @@ NamedDecl *Sema::lookupOpenMPDeclareTargetName(Scope *CurScope, return ND; } -void Sema::ActOnOpenMPDeclareTargetName( - NamedDecl *ND, SourceLocation Loc, OMPDeclareTargetDeclAttr::MapTypeTy MT, - OMPDeclareTargetDeclAttr::DevTypeTy DT) { +void Sema::ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc, + OMPDeclareTargetDeclAttr::MapTypeTy MT, + DeclareTargetContextInfo &DTCI) { assert((isa<VarDecl>(ND) || isa<FunctionDecl>(ND) || isa<FunctionTemplateDecl>(ND)) && "Expected variable, function or function template."); @@ -20818,10 +20818,10 @@ void Sema::ActOnOpenMPDeclareTargetName( auto *VD = cast<ValueDecl>(ND); llvm::Optional<OMPDeclareTargetDeclAttr *> ActiveAttr = OMPDeclareTargetDeclAttr::getActiveAttr(VD); - if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getDevType() != DT && + if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getDevType() != DTCI.DT && ActiveAttr.getValue()->getLevel() == Level) { Diag(Loc, diag::err_omp_device_type_mismatch) - << OMPDeclareTargetDeclAttr::ConvertDevTypeTyToStr(DT) + << OMPDeclareTargetDeclAttr::ConvertDevTypeTyToStr(DTCI.DT) << OMPDeclareTargetDeclAttr::ConvertDevTypeTyToStr( ActiveAttr.getValue()->getDevType()); return; @@ -20835,8 +20835,16 @@ void Sema::ActOnOpenMPDeclareTargetName( if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getLevel() == Level) return; - auto *A = OMPDeclareTargetDeclAttr::CreateImplicit(Context, MT, DT, Level, - SourceRange(Loc, Loc)); + Expr *IndirectE = nullptr; + bool IsIndirect = false; + if (DTCI.Indirect.hasValue()) { + IndirectE = DTCI.Indirect.getValue(); + if (!IndirectE) + IsIndirect = true; + } + auto *A = OMPDeclareTargetDeclAttr::CreateImplicit( + Context, MT, DTCI.DT, IndirectE, IsIndirect, Level, + SourceRange(Loc, Loc)); ND->addAttr(A); if (ASTMutationListener *ML = Context.getASTMutationListener()) ML->DeclarationMarkedOpenMPDeclareTarget(ND, A); @@ -20927,9 +20935,16 @@ void Sema::checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, if (ActiveAttr.hasValue() && ActiveAttr.getValue()->getLevel() >= Level) return; DeclareTargetContextInfo &DTCI = DeclareTargetNesting.back(); + Expr *IndirectE = nullptr; + bool IsIndirect = false; + if (DTCI.Indirect.hasValue()) { + IndirectE = DTCI.Indirect.getValue(); + if (!IndirectE) + IsIndirect = true; + } auto *A = OMPDeclareTargetDeclAttr::CreateImplicit( - Context, OMPDeclareTargetDeclAttr::MT_To, DTCI.DT, Level, - SourceRange(DTCI.Loc, DTCI.Loc)); + Context, OMPDeclareTargetDeclAttr::MT_To, DTCI.DT, IndirectE, + IsIndirect, Level, SourceRange(DTCI.Loc, DTCI.Loc)); D->addAttr(A); if (ASTMutationListener *ML = Context.getASTMutationListener()) ML->DeclarationMarkedOpenMPDeclareTarget(D, A); |