OpenMPClause.h revision 274958
1//===- OpenMPClause.h - Classes for OpenMP clauses --------------*- C++ -*-===//
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 defines OpenMP AST classes for clauses.
11/// There are clauses for executable directives, clauses for declarative
12/// directives and clauses which can be used in both kinds of directives.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_CLANG_AST_OPENMPCLAUSE_H
17#define LLVM_CLANG_AST_OPENMPCLAUSE_H
18
19#include "clang/AST/Expr.h"
20#include "clang/AST/Stmt.h"
21#include "clang/Basic/OpenMPKinds.h"
22#include "clang/Basic/SourceLocation.h"
23
24namespace clang {
25
26//===----------------------------------------------------------------------===//
27// AST classes for clauses.
28//===----------------------------------------------------------------------===//
29
30/// \brief This is a basic class for representing single OpenMP clause.
31///
32class OMPClause {
33  /// \brief Starting location of the clause (the clause keyword).
34  SourceLocation StartLoc;
35  /// \brief Ending location of the clause.
36  SourceLocation EndLoc;
37  /// \brief Kind of the clause.
38  OpenMPClauseKind Kind;
39
40protected:
41  OMPClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation EndLoc)
42      : StartLoc(StartLoc), EndLoc(EndLoc), Kind(K) {}
43
44public:
45  /// \brief Returns the starting location of the clause.
46  SourceLocation getLocStart() const { return StartLoc; }
47  /// \brief Returns the ending location of the clause.
48  SourceLocation getLocEnd() const { return EndLoc; }
49
50  /// \brief Sets the starting location of the clause.
51  void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
52  /// \brief Sets the ending location of the clause.
53  void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
54
55  /// \brief Returns kind of OpenMP clause (private, shared, reduction, etc.).
56  OpenMPClauseKind getClauseKind() const { return Kind; }
57
58  bool isImplicit() const { return StartLoc.isInvalid(); }
59
60  StmtRange children();
61  ConstStmtRange children() const {
62    return const_cast<OMPClause *>(this)->children();
63  }
64  static bool classof(const OMPClause *T) { return true; }
65};
66
67/// \brief This represents clauses with the list of variables like 'private',
68/// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
69/// '#pragma omp ...' directives.
70template <class T> class OMPVarListClause : public OMPClause {
71  friend class OMPClauseReader;
72  /// \brief Location of '('.
73  SourceLocation LParenLoc;
74  /// \brief Number of variables in the list.
75  unsigned NumVars;
76
77protected:
78  /// \brief Fetches list of variables associated with this clause.
79  MutableArrayRef<Expr *> getVarRefs() {
80    return MutableArrayRef<Expr *>(
81        reinterpret_cast<Expr **>(
82            reinterpret_cast<char *>(this) +
83            llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<Expr *>())),
84        NumVars);
85  }
86
87  /// \brief Sets the list of variables for this clause.
88  void setVarRefs(ArrayRef<Expr *> VL) {
89    assert(VL.size() == NumVars &&
90           "Number of variables is not the same as the preallocated buffer");
91    std::copy(
92        VL.begin(), VL.end(),
93        reinterpret_cast<Expr **>(
94            reinterpret_cast<char *>(this) +
95            llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<Expr *>())));
96  }
97
98  /// \brief Build a clause with \a N variables
99  ///
100  /// \param K Kind of the clause.
101  /// \param StartLoc Starting location of the clause (the clause keyword).
102  /// \param LParenLoc Location of '('.
103  /// \param EndLoc Ending location of the clause.
104  /// \param N Number of the variables in the clause.
105  ///
106  OMPVarListClause(OpenMPClauseKind K, SourceLocation StartLoc,
107                   SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
108      : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {}
109
110public:
111  typedef MutableArrayRef<Expr *>::iterator varlist_iterator;
112  typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
113  typedef llvm::iterator_range<varlist_iterator> varlist_range;
114  typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
115
116  unsigned varlist_size() const { return NumVars; }
117  bool varlist_empty() const { return NumVars == 0; }
118
119  varlist_range varlists() {
120    return varlist_range(varlist_begin(), varlist_end());
121  }
122  varlist_const_range varlists() const {
123    return varlist_const_range(varlist_begin(), varlist_end());
124  }
125
126  varlist_iterator varlist_begin() { return getVarRefs().begin(); }
127  varlist_iterator varlist_end() { return getVarRefs().end(); }
128  varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
129  varlist_const_iterator varlist_end() const { return getVarRefs().end(); }
130
131  /// \brief Sets the location of '('.
132  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
133  /// \brief Returns the location of '('.
134  SourceLocation getLParenLoc() const { return LParenLoc; }
135
136  /// \brief Fetches list of all variables in the clause.
137  ArrayRef<const Expr *> getVarRefs() const {
138    return ArrayRef<const Expr *>(
139        reinterpret_cast<const Expr *const *>(
140            reinterpret_cast<const char *>(this) +
141            llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<Expr *>())),
142        NumVars);
143  }
144};
145
146/// \brief This represents 'if' clause in the '#pragma omp ...' directive.
147///
148/// \code
149/// #pragma omp parallel if(a > 5)
150/// \endcode
151/// In this example directive '#pragma omp parallel' has simple 'if'
152/// clause with condition 'a > 5'.
153///
154class OMPIfClause : public OMPClause {
155  friend class OMPClauseReader;
156  /// \brief Location of '('.
157  SourceLocation LParenLoc;
158  /// \brief Condition of the 'if' clause.
159  Stmt *Condition;
160
161  /// \brief Set condition.
162  ///
163  void setCondition(Expr *Cond) { Condition = Cond; }
164
165public:
166  /// \brief Build 'if' clause with condition \a Cond.
167  ///
168  /// \param StartLoc Starting location of the clause.
169  /// \param LParenLoc Location of '('.
170  /// \param Cond Condition of the clause.
171  /// \param EndLoc Ending location of the clause.
172  ///
173  OMPIfClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,
174              SourceLocation EndLoc)
175      : OMPClause(OMPC_if, StartLoc, EndLoc), LParenLoc(LParenLoc),
176        Condition(Cond) {}
177
178  /// \brief Build an empty clause.
179  ///
180  OMPIfClause()
181      : OMPClause(OMPC_if, SourceLocation(), SourceLocation()),
182        LParenLoc(SourceLocation()), Condition(nullptr) {}
183
184  /// \brief Sets the location of '('.
185  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
186  /// \brief Returns the location of '('.
187  SourceLocation getLParenLoc() const { return LParenLoc; }
188
189  /// \brief Returns condition.
190  Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
191
192  static bool classof(const OMPClause *T) {
193    return T->getClauseKind() == OMPC_if;
194  }
195
196  StmtRange children() { return StmtRange(&Condition, &Condition + 1); }
197};
198
199/// \brief This represents 'final' clause in the '#pragma omp ...' directive.
200///
201/// \code
202/// #pragma omp task final(a > 5)
203/// \endcode
204/// In this example directive '#pragma omp task' has simple 'final'
205/// clause with condition 'a > 5'.
206///
207class OMPFinalClause : public OMPClause {
208  friend class OMPClauseReader;
209  /// \brief Location of '('.
210  SourceLocation LParenLoc;
211  /// \brief Condition of the 'if' clause.
212  Stmt *Condition;
213
214  /// \brief Set condition.
215  ///
216  void setCondition(Expr *Cond) { Condition = Cond; }
217
218public:
219  /// \brief Build 'final' clause with condition \a Cond.
220  ///
221  /// \param StartLoc Starting location of the clause.
222  /// \param LParenLoc Location of '('.
223  /// \param Cond Condition of the clause.
224  /// \param EndLoc Ending location of the clause.
225  ///
226  OMPFinalClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,
227                 SourceLocation EndLoc)
228      : OMPClause(OMPC_final, StartLoc, EndLoc), LParenLoc(LParenLoc),
229        Condition(Cond) {}
230
231  /// \brief Build an empty clause.
232  ///
233  OMPFinalClause()
234      : OMPClause(OMPC_final, SourceLocation(), SourceLocation()),
235        LParenLoc(SourceLocation()), Condition(nullptr) {}
236
237  /// \brief Sets the location of '('.
238  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
239  /// \brief Returns the location of '('.
240  SourceLocation getLParenLoc() const { return LParenLoc; }
241
242  /// \brief Returns condition.
243  Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
244
245  static bool classof(const OMPClause *T) {
246    return T->getClauseKind() == OMPC_final;
247  }
248
249  StmtRange children() { return StmtRange(&Condition, &Condition + 1); }
250};
251
252/// \brief This represents 'num_threads' clause in the '#pragma omp ...'
253/// directive.
254///
255/// \code
256/// #pragma omp parallel num_threads(6)
257/// \endcode
258/// In this example directive '#pragma omp parallel' has simple 'num_threads'
259/// clause with number of threads '6'.
260///
261class OMPNumThreadsClause : public OMPClause {
262  friend class OMPClauseReader;
263  /// \brief Location of '('.
264  SourceLocation LParenLoc;
265  /// \brief Condition of the 'num_threads' clause.
266  Stmt *NumThreads;
267
268  /// \brief Set condition.
269  ///
270  void setNumThreads(Expr *NThreads) { NumThreads = NThreads; }
271
272public:
273  /// \brief Build 'num_threads' clause with condition \a NumThreads.
274  ///
275  /// \param NumThreads Number of threads for the construct.
276  /// \param StartLoc Starting location of the clause.
277  /// \param LParenLoc Location of '('.
278  /// \param EndLoc Ending location of the clause.
279  ///
280  OMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc,
281                      SourceLocation LParenLoc, SourceLocation EndLoc)
282      : OMPClause(OMPC_num_threads, StartLoc, EndLoc), LParenLoc(LParenLoc),
283        NumThreads(NumThreads) {}
284
285  /// \brief Build an empty clause.
286  ///
287  OMPNumThreadsClause()
288      : OMPClause(OMPC_num_threads, SourceLocation(), SourceLocation()),
289        LParenLoc(SourceLocation()), NumThreads(nullptr) {}
290
291  /// \brief Sets the location of '('.
292  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
293  /// \brief Returns the location of '('.
294  SourceLocation getLParenLoc() const { return LParenLoc; }
295
296  /// \brief Returns number of threads.
297  Expr *getNumThreads() const { return cast_or_null<Expr>(NumThreads); }
298
299  static bool classof(const OMPClause *T) {
300    return T->getClauseKind() == OMPC_num_threads;
301  }
302
303  StmtRange children() { return StmtRange(&NumThreads, &NumThreads + 1); }
304};
305
306/// \brief This represents 'safelen' clause in the '#pragma omp ...'
307/// directive.
308///
309/// \code
310/// #pragma omp simd safelen(4)
311/// \endcode
312/// In this example directive '#pragma omp simd' has clause 'safelen'
313/// with single expression '4'.
314/// If the safelen clause is used then no two iterations executed
315/// concurrently with SIMD instructions can have a greater distance
316/// in the logical iteration space than its value. The parameter of
317/// the safelen clause must be a constant positive integer expression.
318///
319class OMPSafelenClause : public OMPClause {
320  friend class OMPClauseReader;
321  /// \brief Location of '('.
322  SourceLocation LParenLoc;
323  /// \brief Safe iteration space distance.
324  Stmt *Safelen;
325
326  /// \brief Set safelen.
327  void setSafelen(Expr *Len) { Safelen = Len; }
328
329public:
330  /// \brief Build 'safelen' clause.
331  ///
332  /// \param Len Expression associated with this clause.
333  /// \param StartLoc Starting location of the clause.
334  /// \param EndLoc Ending location of the clause.
335  ///
336  OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc,
337                   SourceLocation EndLoc)
338      : OMPClause(OMPC_safelen, StartLoc, EndLoc), LParenLoc(LParenLoc),
339        Safelen(Len) {}
340
341  /// \brief Build an empty clause.
342  ///
343  explicit OMPSafelenClause()
344      : OMPClause(OMPC_safelen, SourceLocation(), SourceLocation()),
345        LParenLoc(SourceLocation()), Safelen(nullptr) {}
346
347  /// \brief Sets the location of '('.
348  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
349  /// \brief Returns the location of '('.
350  SourceLocation getLParenLoc() const { return LParenLoc; }
351
352  /// \brief Return safe iteration space distance.
353  Expr *getSafelen() const { return cast_or_null<Expr>(Safelen); }
354
355  static bool classof(const OMPClause *T) {
356    return T->getClauseKind() == OMPC_safelen;
357  }
358
359  StmtRange children() { return StmtRange(&Safelen, &Safelen + 1); }
360};
361
362/// \brief This represents 'collapse' clause in the '#pragma omp ...'
363/// directive.
364///
365/// \code
366/// #pragma omp simd collapse(3)
367/// \endcode
368/// In this example directive '#pragma omp simd' has clause 'collapse'
369/// with single expression '3'.
370/// The parameter must be a constant positive integer expression, it specifies
371/// the number of nested loops that should be collapsed into a single iteration
372/// space.
373///
374class OMPCollapseClause : public OMPClause {
375  friend class OMPClauseReader;
376  /// \brief Location of '('.
377  SourceLocation LParenLoc;
378  /// \brief Number of for-loops.
379  Stmt *NumForLoops;
380
381  /// \brief Set the number of associated for-loops.
382  void setNumForLoops(Expr *Num) { NumForLoops = Num; }
383
384public:
385  /// \brief Build 'collapse' clause.
386  ///
387  /// \param Num Expression associated with this clause.
388  /// \param StartLoc Starting location of the clause.
389  /// \param LParenLoc Location of '('.
390  /// \param EndLoc Ending location of the clause.
391  ///
392  OMPCollapseClause(Expr *Num, SourceLocation StartLoc,
393                    SourceLocation LParenLoc, SourceLocation EndLoc)
394      : OMPClause(OMPC_collapse, StartLoc, EndLoc), LParenLoc(LParenLoc),
395        NumForLoops(Num) {}
396
397  /// \brief Build an empty clause.
398  ///
399  explicit OMPCollapseClause()
400      : OMPClause(OMPC_collapse, SourceLocation(), SourceLocation()),
401        LParenLoc(SourceLocation()), NumForLoops(nullptr) {}
402
403  /// \brief Sets the location of '('.
404  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
405  /// \brief Returns the location of '('.
406  SourceLocation getLParenLoc() const { return LParenLoc; }
407
408  /// \brief Return the number of associated for-loops.
409  Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
410
411  static bool classof(const OMPClause *T) {
412    return T->getClauseKind() == OMPC_collapse;
413  }
414
415  StmtRange children() { return StmtRange(&NumForLoops, &NumForLoops + 1); }
416};
417
418/// \brief This represents 'default' clause in the '#pragma omp ...' directive.
419///
420/// \code
421/// #pragma omp parallel default(shared)
422/// \endcode
423/// In this example directive '#pragma omp parallel' has simple 'default'
424/// clause with kind 'shared'.
425///
426class OMPDefaultClause : public OMPClause {
427  friend class OMPClauseReader;
428  /// \brief Location of '('.
429  SourceLocation LParenLoc;
430  /// \brief A kind of the 'default' clause.
431  OpenMPDefaultClauseKind Kind;
432  /// \brief Start location of the kind in source code.
433  SourceLocation KindKwLoc;
434
435  /// \brief Set kind of the clauses.
436  ///
437  /// \param K Argument of clause.
438  ///
439  void setDefaultKind(OpenMPDefaultClauseKind K) { Kind = K; }
440
441  /// \brief Set argument location.
442  ///
443  /// \param KLoc Argument location.
444  ///
445  void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
446
447public:
448  /// \brief Build 'default' clause with argument \a A ('none' or 'shared').
449  ///
450  /// \param A Argument of the clause ('none' or 'shared').
451  /// \param ALoc Starting location of the argument.
452  /// \param StartLoc Starting location of the clause.
453  /// \param LParenLoc Location of '('.
454  /// \param EndLoc Ending location of the clause.
455  ///
456  OMPDefaultClause(OpenMPDefaultClauseKind A, SourceLocation ALoc,
457                   SourceLocation StartLoc, SourceLocation LParenLoc,
458                   SourceLocation EndLoc)
459      : OMPClause(OMPC_default, StartLoc, EndLoc), LParenLoc(LParenLoc),
460        Kind(A), KindKwLoc(ALoc) {}
461
462  /// \brief Build an empty clause.
463  ///
464  OMPDefaultClause()
465      : OMPClause(OMPC_default, SourceLocation(), SourceLocation()),
466        LParenLoc(SourceLocation()), Kind(OMPC_DEFAULT_unknown),
467        KindKwLoc(SourceLocation()) {}
468
469  /// \brief Sets the location of '('.
470  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
471  /// \brief Returns the location of '('.
472  SourceLocation getLParenLoc() const { return LParenLoc; }
473
474  /// \brief Returns kind of the clause.
475  OpenMPDefaultClauseKind getDefaultKind() const { return Kind; }
476
477  /// \brief Returns location of clause kind.
478  SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
479
480  static bool classof(const OMPClause *T) {
481    return T->getClauseKind() == OMPC_default;
482  }
483
484  StmtRange children() { return StmtRange(); }
485};
486
487/// \brief This represents 'proc_bind' clause in the '#pragma omp ...'
488/// directive.
489///
490/// \code
491/// #pragma omp parallel proc_bind(master)
492/// \endcode
493/// In this example directive '#pragma omp parallel' has simple 'proc_bind'
494/// clause with kind 'master'.
495///
496class OMPProcBindClause : public OMPClause {
497  friend class OMPClauseReader;
498  /// \brief Location of '('.
499  SourceLocation LParenLoc;
500  /// \brief A kind of the 'proc_bind' clause.
501  OpenMPProcBindClauseKind Kind;
502  /// \brief Start location of the kind in source code.
503  SourceLocation KindKwLoc;
504
505  /// \brief Set kind of the clause.
506  ///
507  /// \param K Kind of clause.
508  ///
509  void setProcBindKind(OpenMPProcBindClauseKind K) { Kind = K; }
510
511  /// \brief Set clause kind location.
512  ///
513  /// \param KLoc Kind location.
514  ///
515  void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
516
517public:
518  /// \brief Build 'proc_bind' clause with argument \a A ('master', 'close' or
519  ///        'spread').
520  ///
521  /// \param A Argument of the clause ('master', 'close' or 'spread').
522  /// \param ALoc Starting location of the argument.
523  /// \param StartLoc Starting location of the clause.
524  /// \param LParenLoc Location of '('.
525  /// \param EndLoc Ending location of the clause.
526  ///
527  OMPProcBindClause(OpenMPProcBindClauseKind A, SourceLocation ALoc,
528                    SourceLocation StartLoc, SourceLocation LParenLoc,
529                    SourceLocation EndLoc)
530      : OMPClause(OMPC_proc_bind, StartLoc, EndLoc), LParenLoc(LParenLoc),
531        Kind(A), KindKwLoc(ALoc) {}
532
533  /// \brief Build an empty clause.
534  ///
535  OMPProcBindClause()
536      : OMPClause(OMPC_proc_bind, SourceLocation(), SourceLocation()),
537        LParenLoc(SourceLocation()), Kind(OMPC_PROC_BIND_unknown),
538        KindKwLoc(SourceLocation()) {}
539
540  /// \brief Sets the location of '('.
541  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
542  /// \brief Returns the location of '('.
543  SourceLocation getLParenLoc() const { return LParenLoc; }
544
545  /// \brief Returns kind of the clause.
546  OpenMPProcBindClauseKind getProcBindKind() const { return Kind; }
547
548  /// \brief Returns location of clause kind.
549  SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
550
551  static bool classof(const OMPClause *T) {
552    return T->getClauseKind() == OMPC_proc_bind;
553  }
554
555  StmtRange children() { return StmtRange(); }
556};
557
558/// \brief This represents 'schedule' clause in the '#pragma omp ...' directive.
559///
560/// \code
561/// #pragma omp for schedule(static, 3)
562/// \endcode
563/// In this example directive '#pragma omp for' has 'schedule' clause with
564/// arguments 'static' and '3'.
565///
566class OMPScheduleClause : public OMPClause {
567  friend class OMPClauseReader;
568  /// \brief Location of '('.
569  SourceLocation LParenLoc;
570  /// \brief A kind of the 'schedule' clause.
571  OpenMPScheduleClauseKind Kind;
572  /// \brief Start location of the schedule ind in source code.
573  SourceLocation KindLoc;
574  /// \brief Location of ',' (if any).
575  SourceLocation CommaLoc;
576  /// \brief Chunk size.
577  Stmt *ChunkSize;
578
579  /// \brief Set schedule kind.
580  ///
581  /// \param K Schedule kind.
582  ///
583  void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
584  /// \brief Sets the location of '('.
585  ///
586  /// \param Loc Location of '('.
587  ///
588  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
589  /// \brief Set schedule kind start location.
590  ///
591  /// \param KLoc Schedule kind location.
592  ///
593  void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
594  /// \brief Set location of ','.
595  ///
596  /// \param Loc Location of ','.
597  ///
598  void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
599  /// \brief Set chunk size.
600  ///
601  /// \param E Chunk size.
602  ///
603  void setChunkSize(Expr *E) { ChunkSize = E; }
604
605public:
606  /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size
607  /// expression \a ChunkSize.
608  ///
609  /// \param StartLoc Starting location of the clause.
610  /// \param LParenLoc Location of '('.
611  /// \param KLoc Starting location of the argument.
612  /// \param CommaLoc Location of ','.
613  /// \param EndLoc Ending location of the clause.
614  /// \param Kind Schedule kind.
615  /// \param ChunkSize Chunk size.
616  ///
617  OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
618                    SourceLocation KLoc, SourceLocation CommaLoc,
619                    SourceLocation EndLoc, OpenMPScheduleClauseKind Kind,
620                    Expr *ChunkSize)
621      : OMPClause(OMPC_schedule, StartLoc, EndLoc), LParenLoc(LParenLoc),
622        Kind(Kind), KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {}
623
624  /// \brief Build an empty clause.
625  ///
626  explicit OMPScheduleClause()
627      : OMPClause(OMPC_schedule, SourceLocation(), SourceLocation()),
628        Kind(OMPC_SCHEDULE_unknown), ChunkSize(nullptr) {}
629
630  /// \brief Get kind of the clause.
631  ///
632  OpenMPScheduleClauseKind getScheduleKind() const { return Kind; }
633  /// \brief Get location of '('.
634  ///
635  SourceLocation getLParenLoc() { return LParenLoc; }
636  /// \brief Get kind location.
637  ///
638  SourceLocation getScheduleKindLoc() { return KindLoc; }
639  /// \brief Get location of ','.
640  ///
641  SourceLocation getCommaLoc() { return CommaLoc; }
642  /// \brief Get chunk size.
643  ///
644  Expr *getChunkSize() { return dyn_cast_or_null<Expr>(ChunkSize); }
645  /// \brief Get chunk size.
646  ///
647  Expr *getChunkSize() const { return dyn_cast_or_null<Expr>(ChunkSize); }
648
649  static bool classof(const OMPClause *T) {
650    return T->getClauseKind() == OMPC_schedule;
651  }
652
653  StmtRange children() { return StmtRange(&ChunkSize, &ChunkSize + 1); }
654};
655
656/// \brief This represents 'ordered' clause in the '#pragma omp ...' directive.
657///
658/// \code
659/// #pragma omp for ordered
660/// \endcode
661/// In this example directive '#pragma omp for' has 'ordered' clause.
662///
663class OMPOrderedClause : public OMPClause {
664public:
665  /// \brief Build 'ordered' clause.
666  ///
667  /// \param StartLoc Starting location of the clause.
668  /// \param EndLoc Ending location of the clause.
669  ///
670  OMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc)
671      : OMPClause(OMPC_ordered, StartLoc, EndLoc) {}
672
673  /// \brief Build an empty clause.
674  ///
675  OMPOrderedClause()
676      : OMPClause(OMPC_ordered, SourceLocation(), SourceLocation()) {}
677
678  static bool classof(const OMPClause *T) {
679    return T->getClauseKind() == OMPC_ordered;
680  }
681
682  StmtRange children() { return StmtRange(); }
683};
684
685/// \brief This represents 'nowait' clause in the '#pragma omp ...' directive.
686///
687/// \code
688/// #pragma omp for nowait
689/// \endcode
690/// In this example directive '#pragma omp for' has 'nowait' clause.
691///
692class OMPNowaitClause : public OMPClause {
693public:
694  /// \brief Build 'nowait' clause.
695  ///
696  /// \param StartLoc Starting location of the clause.
697  /// \param EndLoc Ending location of the clause.
698  ///
699  OMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc)
700      : OMPClause(OMPC_nowait, StartLoc, EndLoc) {}
701
702  /// \brief Build an empty clause.
703  ///
704  OMPNowaitClause()
705      : OMPClause(OMPC_nowait, SourceLocation(), SourceLocation()) {}
706
707  static bool classof(const OMPClause *T) {
708    return T->getClauseKind() == OMPC_nowait;
709  }
710
711  StmtRange children() { return StmtRange(); }
712};
713
714/// \brief This represents 'untied' clause in the '#pragma omp ...' directive.
715///
716/// \code
717/// #pragma omp task untied
718/// \endcode
719/// In this example directive '#pragma omp task' has 'untied' clause.
720///
721class OMPUntiedClause : public OMPClause {
722public:
723  /// \brief Build 'untied' clause.
724  ///
725  /// \param StartLoc Starting location of the clause.
726  /// \param EndLoc Ending location of the clause.
727  ///
728  OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
729      : OMPClause(OMPC_untied, StartLoc, EndLoc) {}
730
731  /// \brief Build an empty clause.
732  ///
733  OMPUntiedClause()
734      : OMPClause(OMPC_untied, SourceLocation(), SourceLocation()) {}
735
736  static bool classof(const OMPClause *T) {
737    return T->getClauseKind() == OMPC_untied;
738  }
739
740  StmtRange children() { return StmtRange(); }
741};
742
743/// \brief This represents 'mergeable' clause in the '#pragma omp ...'
744/// directive.
745///
746/// \code
747/// #pragma omp task mergeable
748/// \endcode
749/// In this example directive '#pragma omp task' has 'mergeable' clause.
750///
751class OMPMergeableClause : public OMPClause {
752public:
753  /// \brief Build 'mergeable' clause.
754  ///
755  /// \param StartLoc Starting location of the clause.
756  /// \param EndLoc Ending location of the clause.
757  ///
758  OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc)
759      : OMPClause(OMPC_mergeable, StartLoc, EndLoc) {}
760
761  /// \brief Build an empty clause.
762  ///
763  OMPMergeableClause()
764      : OMPClause(OMPC_mergeable, SourceLocation(), SourceLocation()) {}
765
766  static bool classof(const OMPClause *T) {
767    return T->getClauseKind() == OMPC_mergeable;
768  }
769
770  StmtRange children() { return StmtRange(); }
771};
772
773/// \brief This represents clause 'private' in the '#pragma omp ...' directives.
774///
775/// \code
776/// #pragma omp parallel private(a,b)
777/// \endcode
778/// In this example directive '#pragma omp parallel' has clause 'private'
779/// with the variables 'a' and 'b'.
780///
781class OMPPrivateClause : public OMPVarListClause<OMPPrivateClause> {
782  /// \brief Build clause with number of variables \a N.
783  ///
784  /// \param StartLoc Starting location of the clause.
785  /// \param LParenLoc Location of '('.
786  /// \param EndLoc Ending location of the clause.
787  /// \param N Number of the variables in the clause.
788  ///
789  OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
790                   SourceLocation EndLoc, unsigned N)
791      : OMPVarListClause<OMPPrivateClause>(OMPC_private, StartLoc, LParenLoc,
792                                           EndLoc, N) {}
793
794  /// \brief Build an empty clause.
795  ///
796  /// \param N Number of variables.
797  ///
798  explicit OMPPrivateClause(unsigned N)
799      : OMPVarListClause<OMPPrivateClause>(OMPC_private, SourceLocation(),
800                                           SourceLocation(), SourceLocation(),
801                                           N) {}
802
803public:
804  /// \brief Creates clause with a list of variables \a VL.
805  ///
806  /// \param C AST context.
807  /// \param StartLoc Starting location of the clause.
808  /// \param LParenLoc Location of '('.
809  /// \param EndLoc Ending location of the clause.
810  /// \param VL List of references to the variables.
811  ///
812  static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
813                                  SourceLocation LParenLoc,
814                                  SourceLocation EndLoc, ArrayRef<Expr *> VL);
815  /// \brief Creates an empty clause with the place for \a N variables.
816  ///
817  /// \param C AST context.
818  /// \param N The number of variables.
819  ///
820  static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
821
822  StmtRange children() {
823    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
824                     reinterpret_cast<Stmt **>(varlist_end()));
825  }
826
827  static bool classof(const OMPClause *T) {
828    return T->getClauseKind() == OMPC_private;
829  }
830};
831
832/// \brief This represents clause 'firstprivate' in the '#pragma omp ...'
833/// directives.
834///
835/// \code
836/// #pragma omp parallel firstprivate(a,b)
837/// \endcode
838/// In this example directive '#pragma omp parallel' has clause 'firstprivate'
839/// with the variables 'a' and 'b'.
840///
841class OMPFirstprivateClause : public OMPVarListClause<OMPFirstprivateClause> {
842  /// \brief Build clause with number of variables \a N.
843  ///
844  /// \param StartLoc Starting location of the clause.
845  /// \param LParenLoc Location of '('.
846  /// \param EndLoc Ending location of the clause.
847  /// \param N Number of the variables in the clause.
848  ///
849  OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
850                        SourceLocation EndLoc, unsigned N)
851      : OMPVarListClause<OMPFirstprivateClause>(OMPC_firstprivate, StartLoc,
852                                                LParenLoc, EndLoc, N) {}
853
854  /// \brief Build an empty clause.
855  ///
856  /// \param N Number of variables.
857  ///
858  explicit OMPFirstprivateClause(unsigned N)
859      : OMPVarListClause<OMPFirstprivateClause>(
860            OMPC_firstprivate, SourceLocation(), SourceLocation(),
861            SourceLocation(), N) {}
862
863public:
864  /// \brief Creates clause with a list of variables \a VL.
865  ///
866  /// \param C AST context.
867  /// \param StartLoc Starting location of the clause.
868  /// \param LParenLoc Location of '('.
869  /// \param EndLoc Ending location of the clause.
870  /// \param VL List of references to the variables.
871  ///
872  static OMPFirstprivateClause *
873  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
874         SourceLocation EndLoc, ArrayRef<Expr *> VL);
875  /// \brief Creates an empty clause with the place for \a N variables.
876  ///
877  /// \param C AST context.
878  /// \param N The number of variables.
879  ///
880  static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
881
882  StmtRange children() {
883    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
884                     reinterpret_cast<Stmt **>(varlist_end()));
885  }
886
887  static bool classof(const OMPClause *T) {
888    return T->getClauseKind() == OMPC_firstprivate;
889  }
890};
891
892/// \brief This represents clause 'lastprivate' in the '#pragma omp ...'
893/// directives.
894///
895/// \code
896/// #pragma omp simd lastprivate(a,b)
897/// \endcode
898/// In this example directive '#pragma omp simd' has clause 'lastprivate'
899/// with the variables 'a' and 'b'.
900///
901class OMPLastprivateClause : public OMPVarListClause<OMPLastprivateClause> {
902  /// \brief Build clause with number of variables \a N.
903  ///
904  /// \param StartLoc Starting location of the clause.
905  /// \param LParenLoc Location of '('.
906  /// \param EndLoc Ending location of the clause.
907  /// \param N Number of the variables in the clause.
908  ///
909  OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
910                       SourceLocation EndLoc, unsigned N)
911      : OMPVarListClause<OMPLastprivateClause>(OMPC_lastprivate, StartLoc,
912                                               LParenLoc, EndLoc, N) {}
913
914  /// \brief Build an empty clause.
915  ///
916  /// \param N Number of variables.
917  ///
918  explicit OMPLastprivateClause(unsigned N)
919      : OMPVarListClause<OMPLastprivateClause>(
920            OMPC_lastprivate, SourceLocation(), SourceLocation(),
921            SourceLocation(), N) {}
922
923public:
924  /// \brief Creates clause with a list of variables \a VL.
925  ///
926  /// \param C AST context.
927  /// \param StartLoc Starting location of the clause.
928  /// \param LParenLoc Location of '('.
929  /// \param EndLoc Ending location of the clause.
930  /// \param VL List of references to the variables.
931  ///
932  static OMPLastprivateClause *
933  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
934         SourceLocation EndLoc, ArrayRef<Expr *> VL);
935  /// \brief Creates an empty clause with the place for \a N variables.
936  ///
937  /// \param C AST context.
938  /// \param N The number of variables.
939  ///
940  static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
941
942  StmtRange children() {
943    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
944                     reinterpret_cast<Stmt **>(varlist_end()));
945  }
946
947  static bool classof(const OMPClause *T) {
948    return T->getClauseKind() == OMPC_lastprivate;
949  }
950};
951
952/// \brief This represents clause 'shared' in the '#pragma omp ...' directives.
953///
954/// \code
955/// #pragma omp parallel shared(a,b)
956/// \endcode
957/// In this example directive '#pragma omp parallel' has clause 'shared'
958/// with the variables 'a' and 'b'.
959///
960class OMPSharedClause : public OMPVarListClause<OMPSharedClause> {
961  /// \brief Build clause with number of variables \a N.
962  ///
963  /// \param StartLoc Starting location of the clause.
964  /// \param LParenLoc Location of '('.
965  /// \param EndLoc Ending location of the clause.
966  /// \param N Number of the variables in the clause.
967  ///
968  OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
969                  SourceLocation EndLoc, unsigned N)
970      : OMPVarListClause<OMPSharedClause>(OMPC_shared, StartLoc, LParenLoc,
971                                          EndLoc, N) {}
972
973  /// \brief Build an empty clause.
974  ///
975  /// \param N Number of variables.
976  ///
977  explicit OMPSharedClause(unsigned N)
978      : OMPVarListClause<OMPSharedClause>(OMPC_shared, SourceLocation(),
979                                          SourceLocation(), SourceLocation(),
980                                          N) {}
981
982public:
983  /// \brief Creates clause with a list of variables \a VL.
984  ///
985  /// \param C AST context.
986  /// \param StartLoc Starting location of the clause.
987  /// \param LParenLoc Location of '('.
988  /// \param EndLoc Ending location of the clause.
989  /// \param VL List of references to the variables.
990  ///
991  static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
992                                 SourceLocation LParenLoc,
993                                 SourceLocation EndLoc, ArrayRef<Expr *> VL);
994  /// \brief Creates an empty clause with \a N variables.
995  ///
996  /// \param C AST context.
997  /// \param N The number of variables.
998  ///
999  static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
1000
1001  StmtRange children() {
1002    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1003                     reinterpret_cast<Stmt **>(varlist_end()));
1004  }
1005
1006  static bool classof(const OMPClause *T) {
1007    return T->getClauseKind() == OMPC_shared;
1008  }
1009};
1010
1011/// \brief This represents clause 'reduction' in the '#pragma omp ...'
1012/// directives.
1013///
1014/// \code
1015/// #pragma omp parallel reduction(+:a,b)
1016/// \endcode
1017/// In this example directive '#pragma omp parallel' has clause 'reduction'
1018/// with operator '+' and the variables 'a' and 'b'.
1019///
1020class OMPReductionClause : public OMPVarListClause<OMPReductionClause> {
1021  friend class OMPClauseReader;
1022  /// \brief Location of ':'.
1023  SourceLocation ColonLoc;
1024  /// \brief Nested name specifier for C++.
1025  NestedNameSpecifierLoc QualifierLoc;
1026  /// \brief Name of custom operator.
1027  DeclarationNameInfo NameInfo;
1028
1029  /// \brief Build clause with number of variables \a N.
1030  ///
1031  /// \param StartLoc Starting location of the clause.
1032  /// \param LParenLoc Location of '('.
1033  /// \param EndLoc Ending location of the clause.
1034  /// \param ColonLoc Location of ':'.
1035  /// \param N Number of the variables in the clause.
1036  /// \param QualifierLoc The nested-name qualifier with location information
1037  /// \param NameInfo The full name info for reduction identifier.
1038  ///
1039  OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1040                     SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N,
1041                     NestedNameSpecifierLoc QualifierLoc,
1042                     const DeclarationNameInfo &NameInfo)
1043      : OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
1044                                             LParenLoc, EndLoc, N),
1045        ColonLoc(ColonLoc), QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
1046
1047  /// \brief Build an empty clause.
1048  ///
1049  /// \param N Number of variables.
1050  ///
1051  explicit OMPReductionClause(unsigned N)
1052      : OMPVarListClause<OMPReductionClause>(OMPC_reduction, SourceLocation(),
1053                                             SourceLocation(), SourceLocation(),
1054                                             N),
1055        ColonLoc(), QualifierLoc(), NameInfo() {}
1056
1057  /// \brief Sets location of ':' symbol in clause.
1058  void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
1059  /// \brief Sets the name info for specified reduction identifier.
1060  void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
1061  /// \brief Sets the nested name specifier.
1062  void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
1063
1064public:
1065  /// \brief Creates clause with a list of variables \a VL.
1066  ///
1067  /// \param StartLoc Starting location of the clause.
1068  /// \param LParenLoc Location of '('.
1069  /// \param ColonLoc Location of ':'.
1070  /// \param EndLoc Ending location of the clause.
1071  /// \param VL The variables in the clause.
1072  /// \param QualifierLoc The nested-name qualifier with location information
1073  /// \param NameInfo The full name info for reduction identifier.
1074  ///
1075  static OMPReductionClause *
1076  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1077         SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
1078         NestedNameSpecifierLoc QualifierLoc,
1079         const DeclarationNameInfo &NameInfo);
1080  /// \brief Creates an empty clause with the place for \a N variables.
1081  ///
1082  /// \param C AST context.
1083  /// \param N The number of variables.
1084  ///
1085  static OMPReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
1086
1087  /// \brief Gets location of ':' symbol in clause.
1088  SourceLocation getColonLoc() const { return ColonLoc; }
1089  /// \brief Gets the name info for specified reduction identifier.
1090  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
1091  /// \brief Gets the nested name specifier.
1092  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
1093
1094  StmtRange children() {
1095    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1096                     reinterpret_cast<Stmt **>(varlist_end()));
1097  }
1098
1099  static bool classof(const OMPClause *T) {
1100    return T->getClauseKind() == OMPC_reduction;
1101  }
1102};
1103
1104/// \brief This represents clause 'linear' in the '#pragma omp ...'
1105/// directives.
1106///
1107/// \code
1108/// #pragma omp simd linear(a,b : 2)
1109/// \endcode
1110/// In this example directive '#pragma omp simd' has clause 'linear'
1111/// with variables 'a', 'b' and linear step '2'.
1112///
1113class OMPLinearClause : public OMPVarListClause<OMPLinearClause> {
1114  friend class OMPClauseReader;
1115  /// \brief Location of ':'.
1116  SourceLocation ColonLoc;
1117
1118  /// \brief Sets the linear step for clause.
1119  void setStep(Expr *Step) { *varlist_end() = Step; }
1120
1121  /// \brief Build 'linear' clause with given number of variables \a NumVars.
1122  ///
1123  /// \param StartLoc Starting location of the clause.
1124  /// \param LParenLoc Location of '('.
1125  /// \param ColonLoc Location of ':'.
1126  /// \param EndLoc Ending location of the clause.
1127  /// \param NumVars Number of variables.
1128  ///
1129  OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1130                  SourceLocation ColonLoc, SourceLocation EndLoc,
1131                  unsigned NumVars)
1132      : OMPVarListClause<OMPLinearClause>(OMPC_linear, StartLoc, LParenLoc,
1133                                          EndLoc, NumVars),
1134        ColonLoc(ColonLoc) {}
1135
1136  /// \brief Build an empty clause.
1137  ///
1138  /// \param NumVars Number of variables.
1139  ///
1140  explicit OMPLinearClause(unsigned NumVars)
1141      : OMPVarListClause<OMPLinearClause>(OMPC_linear, SourceLocation(),
1142                                          SourceLocation(), SourceLocation(),
1143                                          NumVars),
1144        ColonLoc(SourceLocation()) {}
1145
1146public:
1147  /// \brief Creates clause with a list of variables \a VL and a linear step
1148  /// \a Step.
1149  ///
1150  /// \param C AST Context.
1151  /// \param StartLoc Starting location of the clause.
1152  /// \param LParenLoc Location of '('.
1153  /// \param ColonLoc Location of ':'.
1154  /// \param EndLoc Ending location of the clause.
1155  /// \param VL List of references to the variables.
1156  /// \param Step Linear step.
1157  static OMPLinearClause *Create(const ASTContext &C, SourceLocation StartLoc,
1158                                 SourceLocation LParenLoc,
1159                                 SourceLocation ColonLoc, SourceLocation EndLoc,
1160                                 ArrayRef<Expr *> VL, Expr *Step);
1161
1162  /// \brief Creates an empty clause with the place for \a NumVars variables.
1163  ///
1164  /// \param C AST context.
1165  /// \param NumVars Number of variables.
1166  ///
1167  static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
1168
1169  /// \brief Sets the location of ':'.
1170  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
1171  /// \brief Returns the location of '('.
1172  SourceLocation getColonLoc() const { return ColonLoc; }
1173
1174  /// \brief Returns linear step.
1175  Expr *getStep() { return *varlist_end(); }
1176  /// \brief Returns linear step.
1177  const Expr *getStep() const { return *varlist_end(); }
1178
1179  StmtRange children() {
1180    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1181                     reinterpret_cast<Stmt **>(varlist_end() + 1));
1182  }
1183
1184  static bool classof(const OMPClause *T) {
1185    return T->getClauseKind() == OMPC_linear;
1186  }
1187};
1188
1189/// \brief This represents clause 'aligned' in the '#pragma omp ...'
1190/// directives.
1191///
1192/// \code
1193/// #pragma omp simd aligned(a,b : 8)
1194/// \endcode
1195/// In this example directive '#pragma omp simd' has clause 'aligned'
1196/// with variables 'a', 'b' and alignment '8'.
1197///
1198class OMPAlignedClause : public OMPVarListClause<OMPAlignedClause> {
1199  friend class OMPClauseReader;
1200  /// \brief Location of ':'.
1201  SourceLocation ColonLoc;
1202
1203  /// \brief Sets the alignment for clause.
1204  void setAlignment(Expr *A) { *varlist_end() = A; }
1205
1206  /// \brief Build 'aligned' clause with given number of variables \a NumVars.
1207  ///
1208  /// \param StartLoc Starting location of the clause.
1209  /// \param LParenLoc Location of '('.
1210  /// \param ColonLoc Location of ':'.
1211  /// \param EndLoc Ending location of the clause.
1212  /// \param NumVars Number of variables.
1213  ///
1214  OMPAlignedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1215                   SourceLocation ColonLoc, SourceLocation EndLoc,
1216                   unsigned NumVars)
1217      : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, StartLoc, LParenLoc,
1218                                           EndLoc, NumVars),
1219        ColonLoc(ColonLoc) {}
1220
1221  /// \brief Build an empty clause.
1222  ///
1223  /// \param NumVars Number of variables.
1224  ///
1225  explicit OMPAlignedClause(unsigned NumVars)
1226      : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, SourceLocation(),
1227                                           SourceLocation(), SourceLocation(),
1228                                           NumVars),
1229        ColonLoc(SourceLocation()) {}
1230
1231public:
1232  /// \brief Creates clause with a list of variables \a VL and alignment \a A.
1233  ///
1234  /// \param C AST Context.
1235  /// \param StartLoc Starting location of the clause.
1236  /// \param LParenLoc Location of '('.
1237  /// \param ColonLoc Location of ':'.
1238  /// \param EndLoc Ending location of the clause.
1239  /// \param VL List of references to the variables.
1240  /// \param A Alignment.
1241  static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
1242                                  SourceLocation LParenLoc,
1243                                  SourceLocation ColonLoc,
1244                                  SourceLocation EndLoc, ArrayRef<Expr *> VL,
1245                                  Expr *A);
1246
1247  /// \brief Creates an empty clause with the place for \a NumVars variables.
1248  ///
1249  /// \param C AST context.
1250  /// \param NumVars Number of variables.
1251  ///
1252  static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
1253
1254  /// \brief Sets the location of ':'.
1255  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
1256  /// \brief Returns the location of ':'.
1257  SourceLocation getColonLoc() const { return ColonLoc; }
1258
1259  /// \brief Returns alignment.
1260  Expr *getAlignment() { return *varlist_end(); }
1261  /// \brief Returns alignment.
1262  const Expr *getAlignment() const { return *varlist_end(); }
1263
1264  StmtRange children() {
1265    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1266                     reinterpret_cast<Stmt **>(varlist_end() + 1));
1267  }
1268
1269  static bool classof(const OMPClause *T) {
1270    return T->getClauseKind() == OMPC_aligned;
1271  }
1272};
1273
1274/// \brief This represents clause 'copyin' in the '#pragma omp ...' directives.
1275///
1276/// \code
1277/// #pragma omp parallel copyin(a,b)
1278/// \endcode
1279/// In this example directive '#pragma omp parallel' has clause 'copyin'
1280/// with the variables 'a' and 'b'.
1281///
1282class OMPCopyinClause : public OMPVarListClause<OMPCopyinClause> {
1283  /// \brief Build clause with number of variables \a N.
1284  ///
1285  /// \param StartLoc Starting location of the clause.
1286  /// \param LParenLoc Location of '('.
1287  /// \param EndLoc Ending location of the clause.
1288  /// \param N Number of the variables in the clause.
1289  ///
1290  OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1291                  SourceLocation EndLoc, unsigned N)
1292      : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, StartLoc, LParenLoc,
1293                                          EndLoc, N) {}
1294
1295  /// \brief Build an empty clause.
1296  ///
1297  /// \param N Number of variables.
1298  ///
1299  explicit OMPCopyinClause(unsigned N)
1300      : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, SourceLocation(),
1301                                          SourceLocation(), SourceLocation(),
1302                                          N) {}
1303
1304public:
1305  /// \brief Creates clause with a list of variables \a VL.
1306  ///
1307  /// \param C AST context.
1308  /// \param StartLoc Starting location of the clause.
1309  /// \param LParenLoc Location of '('.
1310  /// \param EndLoc Ending location of the clause.
1311  /// \param VL List of references to the variables.
1312  ///
1313  static OMPCopyinClause *Create(const ASTContext &C, SourceLocation StartLoc,
1314                                 SourceLocation LParenLoc,
1315                                 SourceLocation EndLoc, ArrayRef<Expr *> VL);
1316  /// \brief Creates an empty clause with \a N variables.
1317  ///
1318  /// \param C AST context.
1319  /// \param N The number of variables.
1320  ///
1321  static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
1322
1323  StmtRange children() {
1324    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1325                     reinterpret_cast<Stmt **>(varlist_end()));
1326  }
1327
1328  static bool classof(const OMPClause *T) {
1329    return T->getClauseKind() == OMPC_copyin;
1330  }
1331};
1332
1333/// \brief This represents clause 'copyprivate' in the '#pragma omp ...'
1334/// directives.
1335///
1336/// \code
1337/// #pragma omp single copyprivate(a,b)
1338/// \endcode
1339/// In this example directive '#pragma omp single' has clause 'copyprivate'
1340/// with the variables 'a' and 'b'.
1341///
1342class OMPCopyprivateClause : public OMPVarListClause<OMPCopyprivateClause> {
1343  /// \brief Build clause with number of variables \a N.
1344  ///
1345  /// \param StartLoc Starting location of the clause.
1346  /// \param LParenLoc Location of '('.
1347  /// \param EndLoc Ending location of the clause.
1348  /// \param N Number of the variables in the clause.
1349  ///
1350  OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1351                       SourceLocation EndLoc, unsigned N)
1352      : OMPVarListClause<OMPCopyprivateClause>(OMPC_copyprivate, StartLoc,
1353                                               LParenLoc, EndLoc, N) {}
1354
1355  /// \brief Build an empty clause.
1356  ///
1357  /// \param N Number of variables.
1358  ///
1359  explicit OMPCopyprivateClause(unsigned N)
1360      : OMPVarListClause<OMPCopyprivateClause>(
1361            OMPC_copyprivate, SourceLocation(), SourceLocation(),
1362            SourceLocation(), N) {}
1363
1364public:
1365  /// \brief Creates clause with a list of variables \a VL.
1366  ///
1367  /// \param C AST context.
1368  /// \param StartLoc Starting location of the clause.
1369  /// \param LParenLoc Location of '('.
1370  /// \param EndLoc Ending location of the clause.
1371  /// \param VL List of references to the variables.
1372  ///
1373  static OMPCopyprivateClause *
1374  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1375         SourceLocation EndLoc, ArrayRef<Expr *> VL);
1376  /// \brief Creates an empty clause with \a N variables.
1377  ///
1378  /// \param C AST context.
1379  /// \param N The number of variables.
1380  ///
1381  static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1382
1383  StmtRange children() {
1384    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1385                     reinterpret_cast<Stmt **>(varlist_end()));
1386  }
1387
1388  static bool classof(const OMPClause *T) {
1389    return T->getClauseKind() == OMPC_copyprivate;
1390  }
1391};
1392
1393/// \brief This represents pseudo clause 'flush' for the '#pragma omp flush'
1394/// directive.
1395///
1396/// \code
1397/// #pragma omp flush(a,b)
1398/// \endcode
1399/// In this example directive '#pragma omp flush' has pseudo clause 'flush'
1400/// with the variables 'a' and 'b'.
1401///
1402class OMPFlushClause : public OMPVarListClause<OMPFlushClause> {
1403  /// \brief Build clause with number of variables \a N.
1404  ///
1405  /// \param StartLoc Starting location of the clause.
1406  /// \param LParenLoc Location of '('.
1407  /// \param EndLoc Ending location of the clause.
1408  /// \param N Number of the variables in the clause.
1409  ///
1410  OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1411                 SourceLocation EndLoc, unsigned N)
1412      : OMPVarListClause<OMPFlushClause>(OMPC_flush, StartLoc, LParenLoc,
1413                                         EndLoc, N) {}
1414
1415  /// \brief Build an empty clause.
1416  ///
1417  /// \param N Number of variables.
1418  ///
1419  explicit OMPFlushClause(unsigned N)
1420      : OMPVarListClause<OMPFlushClause>(OMPC_flush, SourceLocation(),
1421                                         SourceLocation(), SourceLocation(),
1422                                         N) {}
1423
1424public:
1425  /// \brief Creates clause with a list of variables \a VL.
1426  ///
1427  /// \param C AST context.
1428  /// \param StartLoc Starting location of the clause.
1429  /// \param LParenLoc Location of '('.
1430  /// \param EndLoc Ending location of the clause.
1431  /// \param VL List of references to the variables.
1432  ///
1433  static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
1434                                SourceLocation LParenLoc, SourceLocation EndLoc,
1435                                ArrayRef<Expr *> VL);
1436  /// \brief Creates an empty clause with \a N variables.
1437  ///
1438  /// \param C AST context.
1439  /// \param N The number of variables.
1440  ///
1441  static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
1442
1443  StmtRange children() {
1444    return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1445                     reinterpret_cast<Stmt **>(varlist_end()));
1446  }
1447
1448  static bool classof(const OMPClause *T) {
1449    return T->getClauseKind() == OMPC_flush;
1450  }
1451};
1452
1453} // end namespace clang
1454
1455#endif
1456