From d4183dabd7a959746d558098762ab61e97d5ee6d Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Tue, 3 Sep 2013 12:55:52 +0000 Subject: OpenMP: Data-sharing attributes analysis and clause 'shared' llvm-svn: 189795 --- clang/lib/AST/Stmt.cpp | 30 ++++++++++++++++++++++++++++++ clang/lib/AST/StmtPrinter.cpp | 8 ++++++++ clang/lib/AST/StmtProfile.cpp | 3 +++ 3 files changed, 41 insertions(+) (limited to 'clang/lib/AST') diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 2711e9ba979..0d654eeee35 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -1111,6 +1111,16 @@ bool CapturedStmt::capturesVariable(const VarDecl *Var) const { return false; } +StmtRange OMPClause::children() { + switch(getClauseKind()) { + default : break; +#define OPENMP_CLAUSE(Name, Class) \ + case OMPC_ ## Name : return static_cast(this)->children(); +#include "clang/Basic/OpenMPKinds.def" + } + llvm_unreachable("unknown OMPClause"); +} + OMPPrivateClause *OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -1131,6 +1141,26 @@ OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C, return new (Mem) OMPPrivateClause(N); } +OMPSharedClause *OMPSharedClause::Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc, + ArrayRef VL) { + void *Mem = C.Allocate(sizeof(OMPSharedClause) + sizeof(Expr *) * VL.size(), + llvm::alignOf()); + OMPSharedClause *Clause = new (Mem) OMPSharedClause(StartLoc, LParenLoc, + EndLoc, VL.size()); + Clause->setVarRefs(VL); + return Clause; +} + +OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, + unsigned N) { + void *Mem = C.Allocate(sizeof(OMPSharedClause) + sizeof(Expr *) * N, + llvm::alignOf()); + return new (Mem) OMPSharedClause(N); +} + void OMPExecutableDirective::setClauses(ArrayRef Clauses) { assert(Clauses.size() == this->Clauses.size() && "Number of clauses is not the same as the preallocated buffer"); diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index d59475e48ca..98b56bcbc7c 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -614,6 +614,14 @@ void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) { } } +void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) { + if (!Node->varlist_empty()) { + OS << "shared"; + PROCESS_OMP_CLAUSE_LIST(OMPSharedClause, Node, '(') + OS << ")"; + } +} + #undef PROCESS_OMP_CLAUSE_LIST } diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index eb93c1df0e2..77c34c41aaf 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -272,6 +272,9 @@ void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { } void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) { PROCESS_OMP_CLAUSE_LIST(OMPPrivateClause, C) } +void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) { + PROCESS_OMP_CLAUSE_LIST(OMPSharedClause, C) +} #undef PROCESS_OMP_CLAUSE_LIST } -- cgit v1.2.3