blob: d1544e6baa5b9980e04e9b800355d4ae02c9fb5f [file] [log] [blame]
Alexey Bataeva769e072013-03-22 06:34:35 +00001//===--- ParseOpenMP.cpp - OpenMP directives parsing ----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9/// \file
10/// \brief This file implements parsing of all OpenMP directives and clauses.
11///
12//===----------------------------------------------------------------------===//
13
Chandler Carruth5553d0d2014-01-07 11:51:46 +000014#include "RAIIObjectsForParser.h"
Alexey Bataev9959db52014-05-06 10:08:46 +000015#include "clang/AST/ASTConsumer.h"
16#include "clang/AST/ASTContext.h"
Alexey Bataev5ec3eb12013-07-19 03:13:43 +000017#include "clang/AST/StmtOpenMP.h"
Alexey Bataeva769e072013-03-22 06:34:35 +000018#include "clang/Parse/ParseDiagnostic.h"
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000019#include "clang/Parse/Parser.h"
20#include "clang/Sema/Scope.h"
21#include "llvm/ADT/PointerIntPair.h"
Alexey Bataeva769e072013-03-22 06:34:35 +000022using namespace clang;
23
24//===----------------------------------------------------------------------===//
25// OpenMP declarative directives.
26//===----------------------------------------------------------------------===//
27
Alexey Bataev4acb8592014-07-07 13:01:15 +000028static OpenMPDirectiveKind ParseOpenMPDirectiveKind(Parser &P) {
29 auto Tok = P.getCurToken();
30 auto DKind =
31 Tok.isAnnotation()
32 ? OMPD_unknown
33 : getOpenMPDirectiveKind(P.getPreprocessor().getSpelling(Tok));
34 if (DKind == OMPD_parallel) {
35 Tok = P.getPreprocessor().LookAhead(0);
36 auto SDKind =
37 Tok.isAnnotation()
38 ? OMPD_unknown
39 : getOpenMPDirectiveKind(P.getPreprocessor().getSpelling(Tok));
40 if (SDKind == OMPD_for) {
41 P.ConsumeToken();
42 DKind = OMPD_parallel_for;
Alexey Bataev84d0b3e2014-07-08 08:12:03 +000043 } else if (SDKind == OMPD_sections) {
44 P.ConsumeToken();
45 DKind = OMPD_parallel_sections;
Alexey Bataev4acb8592014-07-07 13:01:15 +000046 }
47 }
48 return DKind;
49}
50
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000051/// \brief Parsing of declarative OpenMP directives.
52///
53/// threadprivate-directive:
54/// annot_pragma_openmp 'threadprivate' simple-variable-list
Alexey Bataeva769e072013-03-22 06:34:35 +000055///
56Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() {
57 assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
Alexey Bataevee6507d2013-11-18 08:17:37 +000058 ParenBraceBracketBalancer BalancerRAIIObj(*this);
Alexey Bataeva769e072013-03-22 06:34:35 +000059
60 SourceLocation Loc = ConsumeToken();
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000061 SmallVector<Expr *, 5> Identifiers;
Alexey Bataev4acb8592014-07-07 13:01:15 +000062 auto DKind = ParseOpenMPDirectiveKind(*this);
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000063
64 switch (DKind) {
Alexey Bataeva769e072013-03-22 06:34:35 +000065 case OMPD_threadprivate:
66 ConsumeToken();
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000067 if (!ParseOpenMPSimpleVarList(OMPD_threadprivate, Identifiers, true)) {
Alexey Bataeva769e072013-03-22 06:34:35 +000068 // The last seen token is annot_pragma_openmp_end - need to check for
69 // extra tokens.
70 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
71 Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
Alexey Bataeva55ed262014-05-28 06:15:33 +000072 << getOpenMPDirectiveName(OMPD_threadprivate);
Alp Tokerd751fa72013-12-18 19:10:49 +000073 SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
Alexey Bataeva769e072013-03-22 06:34:35 +000074 }
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000075 // Skip the last annot_pragma_openmp_end.
Alexey Bataeva769e072013-03-22 06:34:35 +000076 ConsumeToken();
Alexey Bataeva55ed262014-05-28 06:15:33 +000077 return Actions.ActOnOpenMPThreadprivateDirective(Loc, Identifiers);
Alexey Bataeva769e072013-03-22 06:34:35 +000078 }
79 break;
80 case OMPD_unknown:
81 Diag(Tok, diag::err_omp_unknown_directive);
82 break;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +000083 case OMPD_parallel:
Alexey Bataev1b59ab52014-02-27 08:29:12 +000084 case OMPD_simd:
Alexey Bataev5ec3eb12013-07-19 03:13:43 +000085 case OMPD_task:
Alexey Bataev68446b72014-07-18 07:47:19 +000086 case OMPD_taskyield:
Alexey Bataev4d1dfea2014-07-18 09:11:51 +000087 case OMPD_barrier:
Alexey Bataev2df347a2014-07-18 10:17:07 +000088 case OMPD_taskwait:
Alexey Bataev6125da92014-07-21 11:26:11 +000089 case OMPD_flush:
Alexey Bataevf29276e2014-06-18 04:14:57 +000090 case OMPD_for:
Alexey Bataevd3f8dd22014-06-25 11:44:49 +000091 case OMPD_sections:
Alexey Bataev1e0498a2014-06-26 08:21:58 +000092 case OMPD_section:
Alexey Bataevd1e40fb2014-06-26 12:05:45 +000093 case OMPD_single:
Alexander Musman80c22892014-07-17 08:54:58 +000094 case OMPD_master:
Alexander Musmand9ed09f2014-07-21 09:42:05 +000095 case OMPD_critical:
Alexey Bataev4acb8592014-07-07 13:01:15 +000096 case OMPD_parallel_for:
Alexey Bataev84d0b3e2014-07-08 08:12:03 +000097 case OMPD_parallel_sections:
Alexey Bataeva769e072013-03-22 06:34:35 +000098 Diag(Tok, diag::err_omp_unexpected_directive)
Alexey Bataeva55ed262014-05-28 06:15:33 +000099 << getOpenMPDirectiveName(DKind);
Alexey Bataeva769e072013-03-22 06:34:35 +0000100 break;
101 }
Alp Tokerd751fa72013-12-18 19:10:49 +0000102 SkipUntil(tok::annot_pragma_openmp_end);
Alexey Bataeva769e072013-03-22 06:34:35 +0000103 return DeclGroupPtrTy();
104}
105
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000106/// \brief Parsing of declarative or executable OpenMP directives.
107///
108/// threadprivate-directive:
109/// annot_pragma_openmp 'threadprivate' simple-variable-list
110/// annot_pragma_openmp_end
111///
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000112/// executable-directive:
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000113/// annot_pragma_openmp 'parallel' | 'simd' | 'for' | 'sections' |
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000114/// 'section' | 'single' | 'master' | 'critical' [ '(' <name> ')' ] |
115/// 'parallel for' | 'parallel sections' | 'task' | 'taskyield' |
Alexey Bataev6125da92014-07-21 11:26:11 +0000116/// 'barrier' | 'taskwait' | 'flush' {clause} annot_pragma_openmp_end
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000117///
Alexey Bataev68446b72014-07-18 07:47:19 +0000118StmtResult
119Parser::ParseOpenMPDeclarativeOrExecutableDirective(bool StandAloneAllowed) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000120 assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
Alexey Bataevee6507d2013-11-18 08:17:37 +0000121 ParenBraceBracketBalancer BalancerRAIIObj(*this);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000122 SmallVector<Expr *, 5> Identifiers;
123 SmallVector<OMPClause *, 5> Clauses;
Alexey Bataev4ca40ed2014-05-12 04:23:46 +0000124 SmallVector<llvm::PointerIntPair<OMPClause *, 1, bool>, OMPC_unknown + 1>
Alexey Bataeva55ed262014-05-28 06:15:33 +0000125 FirstClauses(OMPC_unknown + 1);
Alexander Musmana8e9d2e2014-06-03 10:16:47 +0000126 unsigned ScopeFlags =
Alexey Bataeva55ed262014-05-28 06:15:33 +0000127 Scope::FnScope | Scope::DeclScope | Scope::OpenMPDirectiveScope;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000128 SourceLocation Loc = ConsumeToken(), EndLoc;
Alexey Bataev4acb8592014-07-07 13:01:15 +0000129 auto DKind = ParseOpenMPDirectiveKind(*this);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000130 // Name of critical directive.
131 DeclarationNameInfo DirName;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000132 StmtResult Directive = StmtError();
Alexey Bataev68446b72014-07-18 07:47:19 +0000133 bool HasAssociatedStatement = true;
Alexey Bataev6125da92014-07-21 11:26:11 +0000134 bool FlushHasClause = false;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000135
136 switch (DKind) {
137 case OMPD_threadprivate:
138 ConsumeToken();
139 if (!ParseOpenMPSimpleVarList(OMPD_threadprivate, Identifiers, false)) {
140 // The last seen token is annot_pragma_openmp_end - need to check for
141 // extra tokens.
142 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
143 Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
Alexey Bataeva55ed262014-05-28 06:15:33 +0000144 << getOpenMPDirectiveName(OMPD_threadprivate);
Alp Tokerd751fa72013-12-18 19:10:49 +0000145 SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000146 }
147 DeclGroupPtrTy Res =
Alexey Bataeva55ed262014-05-28 06:15:33 +0000148 Actions.ActOnOpenMPThreadprivateDirective(Loc, Identifiers);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000149 Directive = Actions.ActOnDeclStmt(Res, Loc, Tok.getLocation());
150 }
Alp Tokerd751fa72013-12-18 19:10:49 +0000151 SkipUntil(tok::annot_pragma_openmp_end);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000152 break;
Alexey Bataev6125da92014-07-21 11:26:11 +0000153 case OMPD_flush:
154 if (PP.LookAhead(0).is(tok::l_paren)) {
155 FlushHasClause = true;
156 // Push copy of the current token back to stream to properly parse
157 // pseudo-clause OMPFlushClause.
158 PP.EnterToken(Tok);
159 }
Alexey Bataev68446b72014-07-18 07:47:19 +0000160 case OMPD_taskyield:
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000161 case OMPD_barrier:
Alexey Bataev2df347a2014-07-18 10:17:07 +0000162 case OMPD_taskwait:
Alexey Bataev68446b72014-07-18 07:47:19 +0000163 if (!StandAloneAllowed) {
164 Diag(Tok, diag::err_omp_immediate_directive)
165 << getOpenMPDirectiveName(DKind);
166 }
167 HasAssociatedStatement = false;
Alexey Bataev6125da92014-07-21 11:26:11 +0000168 // Fall through for further analysis.
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000169 case OMPD_parallel:
Alexey Bataevf29276e2014-06-18 04:14:57 +0000170 case OMPD_simd:
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000171 case OMPD_for:
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000172 case OMPD_sections:
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000173 case OMPD_single:
Alexey Bataev4acb8592014-07-07 13:01:15 +0000174 case OMPD_section:
Alexander Musman80c22892014-07-17 08:54:58 +0000175 case OMPD_master:
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000176 case OMPD_critical:
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000177 case OMPD_parallel_for:
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000178 case OMPD_parallel_sections:
179 case OMPD_task: {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000180 ConsumeToken();
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000181 // Parse directive name of the 'critical' directive if any.
182 if (DKind == OMPD_critical) {
183 BalancedDelimiterTracker T(*this, tok::l_paren,
184 tok::annot_pragma_openmp_end);
185 if (!T.consumeOpen()) {
186 if (Tok.isAnyIdentifier()) {
187 DirName =
188 DeclarationNameInfo(Tok.getIdentifierInfo(), Tok.getLocation());
189 ConsumeAnyToken();
190 } else {
191 Diag(Tok, diag::err_omp_expected_identifier_for_critical);
192 }
193 T.consumeClose();
194 }
195 }
Alexey Bataev758e55e2013-09-06 18:03:48 +0000196
Alexey Bataevf29276e2014-06-18 04:14:57 +0000197 if (isOpenMPLoopDirective(DKind))
198 ScopeFlags |= Scope::OpenMPLoopDirectiveScope;
199 if (isOpenMPSimdDirective(DKind))
200 ScopeFlags |= Scope::OpenMPSimdDirectiveScope;
201 ParseScope OMPDirectiveScope(this, ScopeFlags);
Alexey Bataevbae9a792014-06-27 10:37:06 +0000202 Actions.StartOpenMPDSABlock(DKind, DirName, Actions.getCurScope(), Loc);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000203
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000204 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
Alexey Bataev6125da92014-07-21 11:26:11 +0000205 OpenMPClauseKind CKind =
206 Tok.isAnnotation()
207 ? OMPC_unknown
208 : FlushHasClause ? OMPC_flush
209 : getOpenMPClauseKind(PP.getSpelling(Tok));
210 FlushHasClause = false;
Alexey Bataeva55ed262014-05-28 06:15:33 +0000211 OMPClause *Clause =
212 ParseOpenMPClause(DKind, CKind, !FirstClauses[CKind].getInt());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000213 FirstClauses[CKind].setInt(true);
214 if (Clause) {
215 FirstClauses[CKind].setPointer(Clause);
216 Clauses.push_back(Clause);
217 }
218
219 // Skip ',' if any.
220 if (Tok.is(tok::comma))
221 ConsumeToken();
222 }
223 // End location of the directive.
224 EndLoc = Tok.getLocation();
225 // Consume final annot_pragma_openmp_end.
226 ConsumeToken();
227
228 StmtResult AssociatedStmt;
229 bool CreateDirective = true;
Alexey Bataev68446b72014-07-18 07:47:19 +0000230 if (HasAssociatedStatement) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000231 // The body is a block scope like in Lambdas and Blocks.
232 Sema::CompoundScopeRAII CompoundScope(Actions);
Alexey Bataevbae9a792014-06-27 10:37:06 +0000233 Actions.ActOnOpenMPRegionStart(DKind, getCurScope());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000234 Actions.ActOnStartOfCompoundStmt();
235 // Parse statement
236 AssociatedStmt = ParseStatement();
237 Actions.ActOnFinishOfCompoundStmt();
238 if (!AssociatedStmt.isUsable()) {
239 Actions.ActOnCapturedRegionError();
240 CreateDirective = false;
241 } else {
Nikola Smiljanic01a75982014-05-29 10:55:11 +0000242 AssociatedStmt = Actions.ActOnCapturedRegionEnd(AssociatedStmt.get());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000243 CreateDirective = AssociatedStmt.isUsable();
244 }
245 }
246 if (CreateDirective)
Alexey Bataeva55ed262014-05-28 06:15:33 +0000247 Directive = Actions.ActOnOpenMPExecutableDirective(
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000248 DKind, DirName, Clauses, AssociatedStmt.get(), Loc, EndLoc);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000249
250 // Exit scope.
Alexey Bataev758e55e2013-09-06 18:03:48 +0000251 Actions.EndOpenMPDSABlock(Directive.get());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000252 OMPDirectiveScope.Exit();
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000253 break;
Alexey Bataeva55ed262014-05-28 06:15:33 +0000254 }
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000255 case OMPD_unknown:
256 Diag(Tok, diag::err_omp_unknown_directive);
Alp Tokerd751fa72013-12-18 19:10:49 +0000257 SkipUntil(tok::annot_pragma_openmp_end);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000258 break;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000259 }
260 return Directive;
261}
262
Alexey Bataeva769e072013-03-22 06:34:35 +0000263/// \brief Parses list of simple variables for '#pragma omp threadprivate'
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000264/// directive.
Alexey Bataeva769e072013-03-22 06:34:35 +0000265///
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000266/// simple-variable-list:
267/// '(' id-expression {, id-expression} ')'
268///
269bool Parser::ParseOpenMPSimpleVarList(OpenMPDirectiveKind Kind,
270 SmallVectorImpl<Expr *> &VarList,
271 bool AllowScopeSpecifier) {
272 VarList.clear();
Alexey Bataeva769e072013-03-22 06:34:35 +0000273 // Parse '('.
Alp Tokerd751fa72013-12-18 19:10:49 +0000274 BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000275 if (T.expectAndConsume(diag::err_expected_lparen_after,
276 getOpenMPDirectiveName(Kind)))
277 return true;
278 bool IsCorrect = true;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000279 bool NoIdentIsFound = true;
Alexey Bataeva769e072013-03-22 06:34:35 +0000280
281 // Read tokens while ')' or annot_pragma_openmp_end is not found.
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000282 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::annot_pragma_openmp_end)) {
Alexey Bataeva769e072013-03-22 06:34:35 +0000283 CXXScopeSpec SS;
284 SourceLocation TemplateKWLoc;
285 UnqualifiedId Name;
286 // Read var name.
287 Token PrevTok = Tok;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000288 NoIdentIsFound = false;
Alexey Bataeva769e072013-03-22 06:34:35 +0000289
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000290 if (AllowScopeSpecifier && getLangOpts().CPlusPlus &&
291 ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false)) {
Alexey Bataeva769e072013-03-22 06:34:35 +0000292 IsCorrect = false;
293 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
Alp Tokerd751fa72013-12-18 19:10:49 +0000294 StopBeforeMatch);
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000295 } else if (ParseUnqualifiedId(SS, false, false, false, ParsedType(),
296 TemplateKWLoc, Name)) {
Alexey Bataeva769e072013-03-22 06:34:35 +0000297 IsCorrect = false;
298 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
Alp Tokerd751fa72013-12-18 19:10:49 +0000299 StopBeforeMatch);
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000300 } else if (Tok.isNot(tok::comma) && Tok.isNot(tok::r_paren) &&
301 Tok.isNot(tok::annot_pragma_openmp_end)) {
302 IsCorrect = false;
303 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
Alp Tokerd751fa72013-12-18 19:10:49 +0000304 StopBeforeMatch);
Alp Tokerec543272013-12-24 09:48:30 +0000305 Diag(PrevTok.getLocation(), diag::err_expected)
306 << tok::identifier
307 << SourceRange(PrevTok.getLocation(), PrevTokLocation);
Alexey Bataeva769e072013-03-22 06:34:35 +0000308 } else {
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000309 DeclarationNameInfo NameInfo = Actions.GetNameFromUnqualifiedId(Name);
Alexey Bataeva55ed262014-05-28 06:15:33 +0000310 ExprResult Res =
311 Actions.ActOnOpenMPIdExpression(getCurScope(), SS, NameInfo);
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000312 if (Res.isUsable())
Nikola Smiljanic01a75982014-05-29 10:55:11 +0000313 VarList.push_back(Res.get());
Alexey Bataeva769e072013-03-22 06:34:35 +0000314 }
315 // Consume ','.
316 if (Tok.is(tok::comma)) {
317 ConsumeToken();
318 }
Alexey Bataeva769e072013-03-22 06:34:35 +0000319 }
320
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000321 if (NoIdentIsFound) {
Alp Tokerec543272013-12-24 09:48:30 +0000322 Diag(Tok, diag::err_expected) << tok::identifier;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000323 IsCorrect = false;
324 }
325
326 // Parse ')'.
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000327 IsCorrect = !T.consumeClose() && IsCorrect;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000328
329 return !IsCorrect && VarList.empty();
Alexey Bataeva769e072013-03-22 06:34:35 +0000330}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000331
332/// \brief Parsing of OpenMP clauses.
333///
334/// clause:
Alexey Bataev3778b602014-07-17 07:32:53 +0000335/// if-clause | final-clause | num_threads-clause | safelen-clause |
336/// default-clause | private-clause | firstprivate-clause | shared-clause
337/// | linear-clause | aligned-clause | collapse-clause |
338/// lastprivate-clause | reduction-clause | proc_bind-clause |
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000339/// schedule-clause | copyin-clause | copyprivate-clause | untied-clause |
Alexey Bataev6125da92014-07-21 11:26:11 +0000340/// mergeable-clause | flush-clause
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000341///
342OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
343 OpenMPClauseKind CKind, bool FirstClause) {
Craig Topper161e4db2014-05-21 06:02:52 +0000344 OMPClause *Clause = nullptr;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000345 bool ErrorFound = false;
346 // Check if clause is allowed for the given directive.
347 if (CKind != OMPC_unknown && !isAllowedClauseForDirective(DKind, CKind)) {
Alexey Bataeva55ed262014-05-28 06:15:33 +0000348 Diag(Tok, diag::err_omp_unexpected_clause) << getOpenMPClauseName(CKind)
349 << getOpenMPDirectiveName(DKind);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000350 ErrorFound = true;
351 }
352
353 switch (CKind) {
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000354 case OMPC_if:
Alexey Bataev3778b602014-07-17 07:32:53 +0000355 case OMPC_final:
Alexey Bataev568a8332014-03-06 06:15:19 +0000356 case OMPC_num_threads:
Alexey Bataev62c87d22014-03-21 04:51:18 +0000357 case OMPC_safelen:
Alexander Musman8bd31e62014-05-27 15:12:19 +0000358 case OMPC_collapse:
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000359 // OpenMP [2.5, Restrictions]
360 // At most one if clause can appear on the directive.
Alexey Bataev568a8332014-03-06 06:15:19 +0000361 // At most one num_threads clause can appear on the directive.
Alexey Bataev62c87d22014-03-21 04:51:18 +0000362 // OpenMP [2.8.1, simd construct, Restrictions]
Alexander Musman8bd31e62014-05-27 15:12:19 +0000363 // Only one safelen clause can appear on a simd directive.
364 // Only one collapse clause can appear on a simd directive.
Alexey Bataev3778b602014-07-17 07:32:53 +0000365 // OpenMP [2.11.1, task Construct, Restrictions]
366 // At most one if clause can appear on the directive.
367 // At most one final clause can appear on the directive.
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000368 if (!FirstClause) {
Alexey Bataeva55ed262014-05-28 06:15:33 +0000369 Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)
370 << getOpenMPClauseName(CKind);
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000371 }
372
373 Clause = ParseOpenMPSingleExprClause(CKind);
374 break;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000375 case OMPC_default:
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000376 case OMPC_proc_bind:
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000377 // OpenMP [2.14.3.1, Restrictions]
378 // Only a single default clause may be specified on a parallel, task or
379 // teams directive.
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000380 // OpenMP [2.5, parallel Construct, Restrictions]
381 // At most one proc_bind clause can appear on the directive.
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000382 if (!FirstClause) {
Alexey Bataeva55ed262014-05-28 06:15:33 +0000383 Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)
384 << getOpenMPClauseName(CKind);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000385 }
386
387 Clause = ParseOpenMPSimpleClause(CKind);
388 break;
Alexey Bataev56dafe82014-06-20 07:16:17 +0000389 case OMPC_schedule:
390 // OpenMP [2.7.1, Restrictions, p. 3]
391 // Only one schedule clause can appear on a loop directive.
392 if (!FirstClause) {
393 Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)
394 << getOpenMPClauseName(CKind);
395 }
396
397 Clause = ParseOpenMPSingleExprWithArgClause(CKind);
398 break;
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000399 case OMPC_ordered:
Alexey Bataev236070f2014-06-20 11:19:47 +0000400 case OMPC_nowait:
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000401 case OMPC_untied:
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000402 case OMPC_mergeable:
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000403 // OpenMP [2.7.1, Restrictions, p. 9]
404 // Only one ordered clause can appear on a loop directive.
Alexey Bataev236070f2014-06-20 11:19:47 +0000405 // OpenMP [2.7.1, Restrictions, C/C++, p. 4]
406 // Only one nowait clause can appear on a for directive.
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000407 if (!FirstClause) {
408 Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)
409 << getOpenMPClauseName(CKind);
410 }
411
412 Clause = ParseOpenMPClause(CKind);
413 break;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000414 case OMPC_private:
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000415 case OMPC_firstprivate:
Alexander Musman1bb328c2014-06-04 13:06:39 +0000416 case OMPC_lastprivate:
Alexey Bataev758e55e2013-09-06 18:03:48 +0000417 case OMPC_shared:
Alexey Bataevc5e02582014-06-16 07:08:35 +0000418 case OMPC_reduction:
Alexander Musman8dba6642014-04-22 13:09:42 +0000419 case OMPC_linear:
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000420 case OMPC_aligned:
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000421 case OMPC_copyin:
Alexey Bataevbae9a792014-06-27 10:37:06 +0000422 case OMPC_copyprivate:
Alexey Bataev6125da92014-07-21 11:26:11 +0000423 case OMPC_flush:
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000424 Clause = ParseOpenMPVarListClause(CKind);
425 break;
426 case OMPC_unknown:
427 Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
Alexey Bataeva55ed262014-05-28 06:15:33 +0000428 << getOpenMPDirectiveName(DKind);
Alp Tokerd751fa72013-12-18 19:10:49 +0000429 SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000430 break;
431 case OMPC_threadprivate:
Alexey Bataeva55ed262014-05-28 06:15:33 +0000432 Diag(Tok, diag::err_omp_unexpected_clause) << getOpenMPClauseName(CKind)
433 << getOpenMPDirectiveName(DKind);
Alp Tokerd751fa72013-12-18 19:10:49 +0000434 SkipUntil(tok::comma, tok::annot_pragma_openmp_end, StopBeforeMatch);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000435 break;
436 }
Craig Topper161e4db2014-05-21 06:02:52 +0000437 return ErrorFound ? nullptr : Clause;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000438}
439
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000440/// \brief Parsing of OpenMP clauses with single expressions like 'if',
Alexey Bataev3778b602014-07-17 07:32:53 +0000441/// 'final', 'collapse', 'safelen', 'num_threads', 'simdlen', 'num_teams' or
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000442/// 'thread_limit'.
443///
444/// if-clause:
445/// 'if' '(' expression ')'
446///
Alexey Bataev3778b602014-07-17 07:32:53 +0000447/// final-clause:
448/// 'final' '(' expression ')'
449///
Alexey Bataev62c87d22014-03-21 04:51:18 +0000450/// num_threads-clause:
451/// 'num_threads' '(' expression ')'
452///
453/// safelen-clause:
454/// 'safelen' '(' expression ')'
455///
Alexander Musman8bd31e62014-05-27 15:12:19 +0000456/// collapse-clause:
457/// 'collapse' '(' expression ')'
458///
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000459OMPClause *Parser::ParseOpenMPSingleExprClause(OpenMPClauseKind Kind) {
460 SourceLocation Loc = ConsumeToken();
461
462 BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
463 if (T.expectAndConsume(diag::err_expected_lparen_after,
464 getOpenMPClauseName(Kind)))
Craig Topper161e4db2014-05-21 06:02:52 +0000465 return nullptr;
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000466
467 ExprResult LHS(ParseCastExpression(false, false, NotTypeCast));
468 ExprResult Val(ParseRHSOfBinaryExpression(LHS, prec::Conditional));
469
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000470 // Parse ')'.
471 T.consumeClose();
472
473 if (Val.isInvalid())
Craig Topper161e4db2014-05-21 06:02:52 +0000474 return nullptr;
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000475
Alexey Bataeva55ed262014-05-28 06:15:33 +0000476 return Actions.ActOnOpenMPSingleExprClause(
Nikola Smiljanic01a75982014-05-29 10:55:11 +0000477 Kind, Val.get(), Loc, T.getOpenLocation(), T.getCloseLocation());
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000478}
479
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000480/// \brief Parsing of simple OpenMP clauses like 'default' or 'proc_bind'.
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000481///
482/// default-clause:
483/// 'default' '(' 'none' | 'shared' ')
484///
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000485/// proc_bind-clause:
486/// 'proc_bind' '(' 'master' | 'close' | 'spread' ')
487///
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000488OMPClause *Parser::ParseOpenMPSimpleClause(OpenMPClauseKind Kind) {
489 SourceLocation Loc = Tok.getLocation();
490 SourceLocation LOpen = ConsumeToken();
491 // Parse '('.
Alp Tokerd751fa72013-12-18 19:10:49 +0000492 BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000493 if (T.expectAndConsume(diag::err_expected_lparen_after,
494 getOpenMPClauseName(Kind)))
Craig Topper161e4db2014-05-21 06:02:52 +0000495 return nullptr;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000496
Alexey Bataeva55ed262014-05-28 06:15:33 +0000497 unsigned Type = getOpenMPSimpleClauseType(
498 Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok));
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000499 SourceLocation TypeLoc = Tok.getLocation();
500 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
501 Tok.isNot(tok::annot_pragma_openmp_end))
502 ConsumeAnyToken();
503
504 // Parse ')'.
505 T.consumeClose();
506
507 return Actions.ActOnOpenMPSimpleClause(Kind, Type, TypeLoc, LOpen, Loc,
508 Tok.getLocation());
509}
510
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000511/// \brief Parsing of OpenMP clauses like 'ordered'.
512///
513/// ordered-clause:
514/// 'ordered'
515///
Alexey Bataev236070f2014-06-20 11:19:47 +0000516/// nowait-clause:
517/// 'nowait'
518///
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000519/// untied-clause:
520/// 'untied'
521///
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000522/// mergeable-clause:
523/// 'mergeable'
524///
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000525OMPClause *Parser::ParseOpenMPClause(OpenMPClauseKind Kind) {
526 SourceLocation Loc = Tok.getLocation();
527 ConsumeAnyToken();
528
529 return Actions.ActOnOpenMPClause(Kind, Loc, Tok.getLocation());
530}
531
532
Alexey Bataev56dafe82014-06-20 07:16:17 +0000533/// \brief Parsing of OpenMP clauses with single expressions and some additional
534/// argument like 'schedule' or 'dist_schedule'.
535///
536/// schedule-clause:
537/// 'schedule' '(' kind [',' expression ] ')'
538///
539OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPClauseKind Kind) {
540 SourceLocation Loc = ConsumeToken();
541 SourceLocation CommaLoc;
542 // Parse '('.
543 BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
544 if (T.expectAndConsume(diag::err_expected_lparen_after,
545 getOpenMPClauseName(Kind)))
546 return nullptr;
547
548 ExprResult Val;
549 unsigned Type = getOpenMPSimpleClauseType(
550 Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok));
551 SourceLocation KLoc = Tok.getLocation();
552 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
553 Tok.isNot(tok::annot_pragma_openmp_end))
554 ConsumeAnyToken();
555
556 if (Kind == OMPC_schedule &&
557 (Type == OMPC_SCHEDULE_static || Type == OMPC_SCHEDULE_dynamic ||
558 Type == OMPC_SCHEDULE_guided) &&
559 Tok.is(tok::comma)) {
560 CommaLoc = ConsumeAnyToken();
561 ExprResult LHS(ParseCastExpression(false, false, NotTypeCast));
562 Val = ParseRHSOfBinaryExpression(LHS, prec::Conditional);
563 if (Val.isInvalid())
564 return nullptr;
565 }
566
567 // Parse ')'.
568 T.consumeClose();
569
570 return Actions.ActOnOpenMPSingleExprWithArgClause(
571 Kind, Type, Val.get(), Loc, T.getOpenLocation(), KLoc, CommaLoc,
572 T.getCloseLocation());
573}
574
Alexey Bataevc5e02582014-06-16 07:08:35 +0000575static bool ParseReductionId(Parser &P, CXXScopeSpec &ReductionIdScopeSpec,
576 UnqualifiedId &ReductionId) {
577 SourceLocation TemplateKWLoc;
578 if (ReductionIdScopeSpec.isEmpty()) {
579 auto OOK = OO_None;
580 switch (P.getCurToken().getKind()) {
581 case tok::plus:
582 OOK = OO_Plus;
583 break;
584 case tok::minus:
585 OOK = OO_Minus;
586 break;
587 case tok::star:
588 OOK = OO_Star;
589 break;
590 case tok::amp:
591 OOK = OO_Amp;
592 break;
593 case tok::pipe:
594 OOK = OO_Pipe;
595 break;
596 case tok::caret:
597 OOK = OO_Caret;
598 break;
599 case tok::ampamp:
600 OOK = OO_AmpAmp;
601 break;
602 case tok::pipepipe:
603 OOK = OO_PipePipe;
604 break;
605 default:
606 break;
607 }
608 if (OOK != OO_None) {
609 SourceLocation OpLoc = P.ConsumeToken();
Alexey Bataev23b69422014-06-18 07:08:49 +0000610 SourceLocation SymbolLocations[] = {OpLoc, OpLoc, SourceLocation()};
Alexey Bataevc5e02582014-06-16 07:08:35 +0000611 ReductionId.setOperatorFunctionId(OpLoc, OOK, SymbolLocations);
612 return false;
613 }
614 }
615 return P.ParseUnqualifiedId(ReductionIdScopeSpec, /*EnteringContext*/ false,
616 /*AllowDestructorName*/ false,
617 /*AllowConstructorName*/ false, ParsedType(),
618 TemplateKWLoc, ReductionId);
619}
620
Alexander Musman1bb328c2014-06-04 13:06:39 +0000621/// \brief Parsing of OpenMP clause 'private', 'firstprivate', 'lastprivate',
Alexey Bataev6125da92014-07-21 11:26:11 +0000622/// 'shared', 'copyin', 'copyprivate', 'flush' or 'reduction'.
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000623///
624/// private-clause:
625/// 'private' '(' list ')'
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000626/// firstprivate-clause:
627/// 'firstprivate' '(' list ')'
Alexander Musman1bb328c2014-06-04 13:06:39 +0000628/// lastprivate-clause:
629/// 'lastprivate' '(' list ')'
Alexey Bataev758e55e2013-09-06 18:03:48 +0000630/// shared-clause:
631/// 'shared' '(' list ')'
Alexander Musman8dba6642014-04-22 13:09:42 +0000632/// linear-clause:
633/// 'linear' '(' list [ ':' linear-step ] ')'
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000634/// aligned-clause:
635/// 'aligned' '(' list [ ':' alignment ] ')'
Alexey Bataevc5e02582014-06-16 07:08:35 +0000636/// reduction-clause:
637/// 'reduction' '(' reduction-identifier ':' list ')'
Alexey Bataev6125da92014-07-21 11:26:11 +0000638/// copyprivate-clause:
639/// 'copyprivate' '(' list ')'
640/// flush-clause:
641/// 'flush' '(' list ')'
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000642///
643OMPClause *Parser::ParseOpenMPVarListClause(OpenMPClauseKind Kind) {
644 SourceLocation Loc = Tok.getLocation();
645 SourceLocation LOpen = ConsumeToken();
Alexander Musman8dba6642014-04-22 13:09:42 +0000646 SourceLocation ColonLoc = SourceLocation();
Alexey Bataevc5e02582014-06-16 07:08:35 +0000647 // Optional scope specifier and unqualified id for reduction identifier.
648 CXXScopeSpec ReductionIdScopeSpec;
649 UnqualifiedId ReductionId;
650 bool InvalidReductionId = false;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000651 // Parse '('.
Alp Tokerd751fa72013-12-18 19:10:49 +0000652 BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000653 if (T.expectAndConsume(diag::err_expected_lparen_after,
654 getOpenMPClauseName(Kind)))
Craig Topper161e4db2014-05-21 06:02:52 +0000655 return nullptr;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000656
Alexey Bataevc5e02582014-06-16 07:08:35 +0000657 // Handle reduction-identifier for reduction clause.
658 if (Kind == OMPC_reduction) {
659 ColonProtectionRAIIObject ColonRAII(*this);
660 if (getLangOpts().CPlusPlus) {
661 ParseOptionalCXXScopeSpecifier(ReductionIdScopeSpec, ParsedType(), false);
662 }
663 InvalidReductionId =
664 ParseReductionId(*this, ReductionIdScopeSpec, ReductionId);
665 if (InvalidReductionId) {
666 SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
667 StopBeforeMatch);
668 }
669 if (Tok.is(tok::colon)) {
670 ColonLoc = ConsumeToken();
671 } else {
672 Diag(Tok, diag::warn_pragma_expected_colon) << "reduction identifier";
673 }
674 }
675
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000676 SmallVector<Expr *, 5> Vars;
Alexey Bataevc5e02582014-06-16 07:08:35 +0000677 bool IsComma = !InvalidReductionId;
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000678 const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
Alexander Musman8dba6642014-04-22 13:09:42 +0000679 while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000680 Tok.isNot(tok::annot_pragma_openmp_end))) {
Alexander Musman8dba6642014-04-22 13:09:42 +0000681 ColonProtectionRAIIObject ColonRAII(*this, MayHaveTail);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000682 // Parse variable
683 ExprResult VarExpr = ParseAssignmentExpression();
684 if (VarExpr.isUsable()) {
Nikola Smiljanic01a75982014-05-29 10:55:11 +0000685 Vars.push_back(VarExpr.get());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000686 } else {
687 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
Alp Tokerd751fa72013-12-18 19:10:49 +0000688 StopBeforeMatch);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000689 }
690 // Skip ',' if any
691 IsComma = Tok.is(tok::comma);
Alexander Musman8dba6642014-04-22 13:09:42 +0000692 if (IsComma)
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000693 ConsumeToken();
Alexander Musman8dba6642014-04-22 13:09:42 +0000694 else if (Tok.isNot(tok::r_paren) &&
695 Tok.isNot(tok::annot_pragma_openmp_end) &&
696 (!MayHaveTail || Tok.isNot(tok::colon)))
Alexey Bataev6125da92014-07-21 11:26:11 +0000697 Diag(Tok, diag::err_omp_expected_punc)
698 << ((Kind == OMPC_flush) ? getOpenMPDirectiveName(OMPD_flush)
699 : getOpenMPClauseName(Kind))
700 << (Kind == OMPC_flush);
Alexander Musman8dba6642014-04-22 13:09:42 +0000701 }
702
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000703 // Parse ':' linear-step (or ':' alignment).
Craig Topper161e4db2014-05-21 06:02:52 +0000704 Expr *TailExpr = nullptr;
Alexander Musman8dba6642014-04-22 13:09:42 +0000705 const bool MustHaveTail = MayHaveTail && Tok.is(tok::colon);
706 if (MustHaveTail) {
707 ColonLoc = Tok.getLocation();
708 ConsumeToken();
709 ExprResult Tail = ParseAssignmentExpression();
710 if (Tail.isUsable())
Nikola Smiljanic01a75982014-05-29 10:55:11 +0000711 TailExpr = Tail.get();
Alexander Musman8dba6642014-04-22 13:09:42 +0000712 else
713 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
714 StopBeforeMatch);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000715 }
716
717 // Parse ')'.
718 T.consumeClose();
Alexey Bataevc5e02582014-06-16 07:08:35 +0000719 if (Vars.empty() || (MustHaveTail && !TailExpr) || InvalidReductionId)
Craig Topper161e4db2014-05-21 06:02:52 +0000720 return nullptr;
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000721
Alexey Bataevc5e02582014-06-16 07:08:35 +0000722 return Actions.ActOnOpenMPVarListClause(
723 Kind, Vars, TailExpr, Loc, LOpen, ColonLoc, Tok.getLocation(),
724 ReductionIdScopeSpec,
725 ReductionId.isValid() ? Actions.GetNameFromUnqualifiedId(ReductionId)
726 : DeclarationNameInfo());
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000727}
728