diff options
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/DeclOpenMP.cpp | 27 | ||||
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 6 | ||||
-rw-r--r-- | clang/lib/AST/OpenMPClause.cpp | 8 | ||||
-rw-r--r-- | clang/lib/AST/StmtProfile.cpp | 5 |
4 files changed, 39 insertions, 7 deletions
diff --git a/clang/lib/AST/DeclOpenMP.cpp b/clang/lib/AST/DeclOpenMP.cpp index f50775bced2..af321280d41 100644 --- a/clang/lib/AST/DeclOpenMP.cpp +++ b/clang/lib/AST/DeclOpenMP.cpp @@ -59,20 +59,26 @@ void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) { void OMPAllocateDecl::anchor() { } OMPAllocateDecl *OMPAllocateDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation L, - ArrayRef<Expr *> VL) { - OMPAllocateDecl *D = new (C, DC, additionalSizeToAlloc<Expr *>(VL.size())) + SourceLocation L, ArrayRef<Expr *> VL, + ArrayRef<OMPClause *> CL) { + OMPAllocateDecl *D = new ( + C, DC, additionalSizeToAlloc<Expr *, OMPClause *>(VL.size(), CL.size())) OMPAllocateDecl(OMPAllocate, DC, L); D->NumVars = VL.size(); D->setVars(VL); + D->NumClauses = CL.size(); + D->setClauses(CL); return D; } OMPAllocateDecl *OMPAllocateDecl::CreateDeserialized(ASTContext &C, unsigned ID, - unsigned N) { - OMPAllocateDecl *D = new (C, ID, additionalSizeToAlloc<Expr *>(N)) - OMPAllocateDecl(OMPAllocate, nullptr, SourceLocation()); - D->NumVars = N; + unsigned NVars, + unsigned NClauses) { + OMPAllocateDecl *D = + new (C, ID, additionalSizeToAlloc<Expr *, OMPClause *>(NVars, NClauses)) + OMPAllocateDecl(OMPAllocate, nullptr, SourceLocation()); + D->NumVars = NVars; + D->NumClauses = NClauses; return D; } @@ -82,6 +88,13 @@ void OMPAllocateDecl::setVars(ArrayRef<Expr *> VL) { std::uninitialized_copy(VL.begin(), VL.end(), getTrailingObjects<Expr *>()); } +void OMPAllocateDecl::setClauses(ArrayRef<OMPClause *> CL) { + assert(CL.size() == NumClauses && + "Number of variables is not the same as the preallocated buffer"); + std::uninitialized_copy(CL.begin(), CL.end(), + getTrailingObjects<OMPClause *>()); +} + //===----------------------------------------------------------------------===// // OMPRequiresDecl Implementation. //===----------------------------------------------------------------------===// diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index d023a034e51..20096730692 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -1560,6 +1560,12 @@ void DeclPrinter::VisitOMPAllocateDecl(OMPAllocateDecl *D) { } Out << ")"; } + if (!D->clauselist_empty()) { + Out << " "; + OMPClausePrinter Printer(Out, Policy); + for (OMPClause *C : D->clauselists()) + Printer.Visit(C); + } } void DeclPrinter::VisitOMPRequiresDecl(OMPRequiresDecl *D) { diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp index 4016dd0f061..5ee10fb2a11 100644 --- a/clang/lib/AST/OpenMPClause.cpp +++ b/clang/lib/AST/OpenMPClause.cpp @@ -73,6 +73,7 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) { case OMPC_final: case OMPC_safelen: case OMPC_simdlen: + case OMPC_allocator: case OMPC_collapse: case OMPC_private: case OMPC_shared: @@ -145,6 +146,7 @@ const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) case OMPC_num_threads: case OMPC_safelen: case OMPC_simdlen: + case OMPC_allocator: case OMPC_collapse: case OMPC_private: case OMPC_shared: @@ -1086,6 +1088,12 @@ void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) { OS << ")"; } +void OMPClausePrinter::VisitOMPAllocatorClause(OMPAllocatorClause *Node) { + OS << "allocator("; + Node->getAllocator()->printPretty(OS, nullptr, Policy, 0); + OS << ")"; +} + void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) { OS << "collapse("; Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0); diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index c064ea90a26..53655a18f91 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -457,6 +457,11 @@ void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) { Profiler->VisitStmt(C->getSimdlen()); } +void OMPClauseProfiler::VisitOMPAllocatorClause(const OMPAllocatorClause *C) { + if (C->getAllocator()) + Profiler->VisitStmt(C->getAllocator()); +} + void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) { if (C->getNumForLoops()) Profiler->VisitStmt(C->getNumForLoops()); |