diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2016-03-17 10:19:46 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2016-03-17 10:19:46 +0000 |
commit | a839dddf9232b652a26c55b4a6ce3f757ae8ab46 (patch) | |
tree | 1d2ab393bbca6914e76ffd5b445ff8d7cedc768b /clang/lib/Sema/TreeTransform.h | |
parent | b59b488e21f7ba968aed86b216024bd490b4daea (diff) | |
download | bcm5719-llvm-a839dddf9232b652a26c55b4a6ce3f757ae8ab46.tar.gz bcm5719-llvm-a839dddf9232b652a26c55b4a6ce3f757ae8ab46.zip |
[OPENMP 4.0] Use 'declare reduction' constructs in 'reduction' clauses.
OpenMP 4.0 allows to define custom reduction operations using '#pragma
omp declare reduction' construct. Patch allows to use this custom
defined reduction operations in 'reduction' clauses.
llvm-svn: 263701
Diffstat (limited to 'clang/lib/Sema/TreeTransform.h')
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index ffffb7757c2..6f09c0f5355 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1561,10 +1561,11 @@ public: SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, - const DeclarationNameInfo &ReductionId) { + const DeclarationNameInfo &ReductionId, + ArrayRef<Expr *> UnresolvedReductions) { return getSema().ActOnOpenMPReductionClause( VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, - ReductionId); + ReductionId, UnresolvedReductions); } /// \brief Build a new OpenMP 'linear' clause. @@ -7791,9 +7792,31 @@ TreeTransform<Derived>::TransformOMPReductionClause(OMPReductionClause *C) { if (!NameInfo.getName()) return nullptr; } + // Build a list of all UDR decls with the same names ranged by the Scopes. + // The Scope boundary is a duplication of the previous decl. + llvm::SmallVector<Expr *, 16> UnresolvedReductions; + for (auto *E : C->reduction_ops()) { + // Transform all the decls. + if (E) { + auto *ULE = cast<UnresolvedLookupExpr>(E); + UnresolvedSet<8> Decls; + for (auto *D : ULE->decls()) { + NamedDecl *InstD = + cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D)); + Decls.addDecl(InstD, InstD->getAccess()); + } + UnresolvedReductions.push_back( + UnresolvedLookupExpr::Create( + SemaRef.Context, /*NamingClass=*/nullptr, + ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), + NameInfo, /*ADL=*/true, ULE->isOverloaded(), + Decls.begin(), Decls.end())); + } else + UnresolvedReductions.push_back(nullptr); + } return getDerived().RebuildOMPReductionClause( Vars, C->getLocStart(), C->getLParenLoc(), C->getColonLoc(), - C->getLocEnd(), ReductionIdScopeSpec, NameInfo); + C->getLocEnd(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions); } template <typename Derived> |