diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-09-17 17:36:49 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-09-17 17:36:49 +0000 |
commit | de1444208cc8ad20b90f1d8dd2394dc2ab64a217 (patch) | |
tree | 80dcb2ca96f0000337315bf0b7dda5d10eaf6818 /lib/Sema/SemaOpenMP.cpp | |
parent | 20204588ea38f51a99c62beea362106795dd0e19 (diff) | |
download | clang-de1444208cc8ad20b90f1d8dd2394dc2ab64a217.tar.gz |
[OPENMP5.0]Introduce attribute for declare variant directive.
Added attribute for declare variant directive. It will allow to handle
declare variant directive at the codegen and will allow to add extra
checks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372147 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOpenMP.cpp')
-rw-r--r-- | lib/Sema/SemaOpenMP.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index ef2ef8b261..cd343bd13d 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -4945,8 +4945,12 @@ Sema::ActOnOpenMPDeclareVariantDirective(Sema::DeclGroupPtrTy DG, // Do not check templates, wait until instantiation. if (VariantRef->isTypeDependent() || VariantRef->isValueDependent() || VariantRef->containsUnexpandedParameterPack() || - VariantRef->isInstantiationDependent() || FD->isDependentContext()) + VariantRef->isInstantiationDependent() || FD->isDependentContext()) { + auto *NewAttr = + OMPDeclareVariantAttr::CreateImplicit(Context, VariantRef, SR); + FD->addAttr(NewAttr); return DG; + } // Convert VariantRef expression to the type of the original function to // resolve possible conflicts. @@ -5025,6 +5029,17 @@ Sema::ActOnOpenMPDeclareVariantDirective(Sema::DeclGroupPtrTy DG, return DG; } + // Check if variant function is not marked with declare variant directive. + if (NewFD->hasAttrs() && NewFD->hasAttr<OMPDeclareVariantAttr>()) { + Diag(VariantRef->getExprLoc(), + diag::warn_omp_declare_variant_marked_as_declare_variant) + << VariantRef->getSourceRange(); + SourceRange SR = + NewFD->specific_attr_begin<OMPDeclareVariantAttr>()->getRange(); + Diag(SR.getBegin(), diag::note_omp_marked_declare_variant_here) << SR; + return DG; + } + enum DoesntSupport { VirtFuncs = 1, Constructors = 3, @@ -5087,9 +5102,30 @@ Sema::ActOnOpenMPDeclareVariantDirective(Sema::DeclGroupPtrTy DG, /*TemplatesSupported=*/true, /*ConstexprSupported=*/false)) return DG; + auto *NewAttr = OMPDeclareVariantAttr::CreateImplicit(Context, DRE, SR); + FD->addAttr(NewAttr); return DG; } +void Sema::markOpenMPDeclareVariantFuncsReferenced(SourceLocation Loc, + FunctionDecl *Func, + bool MightBeOdrUse) { + assert(LangOpts.OpenMP && "Expected OpenMP mode."); + + if (!Func->isDependentContext() && Func->hasAttrs()) { + for (OMPDeclareVariantAttr *A : + Func->specific_attrs<OMPDeclareVariantAttr>()) { + // TODO: add checks for active OpenMP context where possible. + Expr *VariantRef = A->getVariantFuncRef(); + auto *DRE = dyn_cast<DeclRefExpr>(VariantRef->IgnoreParenImpCasts()); + auto *F = cast<FunctionDecl>(DRE->getDecl()); + if (!F->isDefined() && F->isTemplateInstantiation()) + InstantiateFunctionDefinition(Loc, F->getFirstDecl()); + MarkFunctionReferenced(Loc, F, MightBeOdrUse); + } + } +} + StmtResult Sema::ActOnOpenMPParallelDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |