diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2013-07-19 03:13:43 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2013-07-19 03:13:43 +0000 |
| commit | 5ec3eb11fcb86c9b65588315dec2898d9be39499 (patch) | |
| tree | 47db933e9ac15e1d4378e63c5b8b70c7b5daf4e9 /clang/lib/AST/StmtPrinter.cpp | |
| parent | 63c5c2a0d8258ed4fb6b536ad2e60f26f946675c (diff) | |
| download | bcm5719-llvm-5ec3eb11fcb86c9b65588315dec2898d9be39499.tar.gz bcm5719-llvm-5ec3eb11fcb86c9b65588315dec2898d9be39499.zip | |
OpenMP: basic support for #pragma omp parallel
llvm-svn: 186647
Diffstat (limited to 'clang/lib/AST/StmtPrinter.cpp')
| -rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index d6358023907..c1732cdfd11 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -580,6 +580,67 @@ void StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) { } //===----------------------------------------------------------------------===// +// OpenMP clauses printing methods +//===----------------------------------------------------------------------===// + +namespace { +class OMPClausePrinter : public OMPClauseVisitor<OMPClausePrinter> { + raw_ostream &OS; +public: + OMPClausePrinter(raw_ostream &OS) : OS(OS) { } +#define OPENMP_CLAUSE(Name, Class) \ + void Visit##Class(Class *S); +#include "clang/Basic/OpenMPKinds.def" +}; + +void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) { + OS << "default(" + << getOpenMPSimpleClauseTypeName(OMPC_default, Node->getDefaultKind()) + << ")"; +} + +#define PROCESS_OMP_CLAUSE_LIST(Class, Node, StartSym) \ + for (OMPVarList<Class>::varlist_iterator I = Node->varlist_begin(), \ + E = Node->varlist_end(); \ + I != E; ++I) \ + OS << (I == Node->varlist_begin() ? StartSym : ',') \ + << *cast<NamedDecl>(cast<DeclRefExpr>(*I)->getDecl()); + +void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) { + if (!Node->varlist_empty()) { + OS << "private"; + PROCESS_OMP_CLAUSE_LIST(OMPPrivateClause, Node, '(') + OS << ")"; + } +} + +#undef PROCESS_OMP_CLAUSE_LIST +} + +//===----------------------------------------------------------------------===// +// OpenMP directives printing methods +//===----------------------------------------------------------------------===// + +void StmtPrinter::VisitOMPParallelDirective(OMPParallelDirective *Node) { + Indent() << "#pragma omp parallel "; + + OMPClausePrinter Printer(OS); + ArrayRef<OMPClause *> Clauses = Node->clauses(); + for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end(); + I != E; ++I) + if (*I && !(*I)->isImplicit()) { + Printer.Visit(*I); + OS << ' '; + } + OS << "\n"; + if (Node->getAssociatedStmt()) { + assert(isa<CapturedStmt>(Node->getAssociatedStmt()) && + "Expected captured statement!"); + Stmt *CS = cast<CapturedStmt>(Node->getAssociatedStmt())->getCapturedStmt(); + PrintStmt(CS); + } +} +//===----------------------------------------------------------------------===// // Expr printing methods. //===----------------------------------------------------------------------===// |

