[OPENMP50]Add basic support for depobj construct.
Added basic parsing/sema/serialization support for depobj directive.
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 8c822ec..3c44c0e 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -1842,6 +1842,7 @@
case OMPD_taskwait:
case OMPD_taskgroup:
case OMPD_flush:
+ case OMPD_depobj:
case OMPD_for:
case OMPD_for_simd:
case OMPD_sections:
@@ -2064,6 +2065,7 @@
break;
}
case OMPD_flush:
+ case OMPD_depobj:
case OMPD_taskyield:
case OMPD_barrier:
case OMPD_taskwait:
@@ -2123,10 +2125,13 @@
case OMPD_target_teams_distribute_parallel_for:
case OMPD_target_teams_distribute_parallel_for_simd:
case OMPD_target_teams_distribute_simd: {
- // Special processing for flush clause.
- Token FlushTok;
- if (DKind == OMPD_flush)
- FlushTok = Tok;
+ // Special processing for flush and depobj clauses.
+ Token ImplicitTok;
+ bool ImplicitClauseAllowed = false;
+ if (DKind == OMPD_flush || DKind == OMPD_depobj) {
+ ImplicitTok = Tok;
+ ImplicitClauseAllowed = true;
+ }
ConsumeToken();
// Parse directive name of the 'critical' directive if any.
if (DKind == OMPD_critical) {
@@ -2156,22 +2161,32 @@
Actions.StartOpenMPDSABlock(DKind, DirName, Actions.getCurScope(), Loc);
while (Tok.isNot(tok::annot_pragma_openmp_end)) {
- bool FlushHasClause = false;
- if (DKind == OMPD_flush && Tok.is(tok::l_paren)) {
- FlushHasClause = true;
+ bool HasImplicitClause = false;
+ if (ImplicitClauseAllowed && Tok.is(tok::l_paren)) {
+ HasImplicitClause = true;
// Push copy of the current token back to stream to properly parse
- // pseudo-clause OMPFlushClause.
+ // pseudo-clause OMPFlushClause or OMPDepobjClause.
PP.EnterToken(Tok, /*IsReinject*/ true);
- PP.EnterToken(FlushTok, /*IsReinject*/ true);
+ PP.EnterToken(ImplicitTok, /*IsReinject*/ true);
ConsumeAnyToken();
}
- OpenMPClauseKind CKind =
- Tok.isAnnotation()
- ? OMPC_unknown
- : FlushHasClause ? OMPC_flush
- : getOpenMPClauseKind(PP.getSpelling(Tok));
+ OpenMPClauseKind CKind = Tok.isAnnotation()
+ ? OMPC_unknown
+ : getOpenMPClauseKind(PP.getSpelling(Tok));
+ if (HasImplicitClause) {
+ assert(CKind == OMPC_unknown && "Must be unknown implicit clause.");
+ if (DKind == OMPD_flush) {
+ CKind = OMPC_flush;
+ } else {
+ assert(DKind == OMPD_depobj &&
+ "Expected flush or depobj directives.");
+ CKind = OMPC_depobj;
+ }
+ }
+ // No more implicit clauses allowed.
+ ImplicitClauseAllowed = false;
Actions.StartOpenMPClause(CKind);
- FlushHasClause = false;
+ HasImplicitClause = false;
OMPClause *Clause =
ParseOpenMPClause(DKind, CKind, !FirstClauses[CKind].getInt());
FirstClauses[CKind].setInt(true);
@@ -2324,7 +2339,8 @@
/// nogroup-clause | num_tasks-clause | hint-clause | to-clause |
/// from-clause | is_device_ptr-clause | task_reduction-clause |
/// in_reduction-clause | allocator-clause | allocate-clause |
-/// acq_rel-clause | acquire-clause | release-clause | relaxed-clause
+/// acq_rel-clause | acquire-clause | release-clause | relaxed-clause |
+/// depobj-clause
///
OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
OpenMPClauseKind CKind, bool FirstClause) {
@@ -2355,6 +2371,7 @@
case OMPC_num_tasks:
case OMPC_hint:
case OMPC_allocator:
+ case OMPC_depobj:
// OpenMP [2.5, Restrictions]
// At most one num_threads clause can appear on the directive.
// OpenMP [2.8.1, simd construct, Restrictions]