clang  3.7.0
OpenMPClause.h
Go to the documentation of this file.
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"
23 
24 namespace clang {
25 
26 //===----------------------------------------------------------------------===//
27 // AST classes for clauses.
28 //===----------------------------------------------------------------------===//
29 
30 /// \brief This is a basic class for representing single OpenMP clause.
31 ///
32 class 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.
39 
40 protected:
42  : StartLoc(StartLoc), EndLoc(EndLoc), Kind(K) {}
43 
44 public:
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 
62  return const_cast<OMPClause *>(this)->children();
63  }
64  static bool classof(const OMPClause *) { 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.
70 template <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 
77 protected:
78  /// \brief Fetches list of variables associated with this clause.
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.
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  ///
107  SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
108  : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {}
109 
110 public:
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 
121  }
124  }
125 
126  varlist_iterator varlist_begin() { return getVarRefs().begin(); }
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.
138  return llvm::makeArrayRef(
139  reinterpret_cast<const Expr *const *>(
140  reinterpret_cast<const char *>(this) +
141  llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<const 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 ///
154 class 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 
165 public:
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  ///
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 ///
207 class 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 
218 public:
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  ///
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 ///
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 
272 public:
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  ///
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 ///
319 class 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 
329 public:
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  ///
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 ///
374 class 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 
384 public:
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  ///
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 ///
426 class OMPDefaultClause : public OMPClause {
427  friend class OMPClauseReader;
428  /// \brief Location of '('.
429  SourceLocation LParenLoc;
430  /// \brief A kind of the 'default' clause.
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 
447 public:
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  ///
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  ///
465  : OMPClause(OMPC_default, SourceLocation(), SourceLocation()),
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.
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 ///
496 class OMPProcBindClause : public OMPClause {
497  friend class OMPClauseReader;
498  /// \brief Location of '('.
499  SourceLocation LParenLoc;
500  /// \brief A kind of the 'proc_bind' clause.
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 
517 public:
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  ///
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  ///
536  : OMPClause(OMPC_proc_bind, SourceLocation(), SourceLocation()),
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.
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 ///
566 class OMPScheduleClause : public OMPClause {
567  friend class OMPClauseReader;
568  /// \brief Location of '('.
569  SourceLocation LParenLoc;
570  /// \brief A kind of the 'schedule' clause.
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 and a reference to pseudo variable for combined
577  /// directives.
578  enum { CHUNK_SIZE, HELPER_CHUNK_SIZE, NUM_EXPRS };
579  Stmt *ChunkSizes[NUM_EXPRS];
580 
581  /// \brief Set schedule kind.
582  ///
583  /// \param K Schedule kind.
584  ///
585  void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
586  /// \brief Sets the location of '('.
587  ///
588  /// \param Loc Location of '('.
589  ///
590  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
591  /// \brief Set schedule kind start location.
592  ///
593  /// \param KLoc Schedule kind location.
594  ///
595  void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
596  /// \brief Set location of ','.
597  ///
598  /// \param Loc Location of ','.
599  ///
600  void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
601  /// \brief Set chunk size.
602  ///
603  /// \param E Chunk size.
604  ///
605  void setChunkSize(Expr *E) { ChunkSizes[CHUNK_SIZE] = E; }
606  /// \brief Set helper chunk size.
607  ///
608  /// \param E Helper chunk size.
609  ///
610  void setHelperChunkSize(Expr *E) { ChunkSizes[HELPER_CHUNK_SIZE] = E; }
611 
612 public:
613  /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size
614  /// expression \a ChunkSize.
615  ///
616  /// \param StartLoc Starting location of the clause.
617  /// \param LParenLoc Location of '('.
618  /// \param KLoc Starting location of the argument.
619  /// \param CommaLoc Location of ','.
620  /// \param EndLoc Ending location of the clause.
621  /// \param Kind Schedule kind.
622  /// \param ChunkSize Chunk size.
623  /// \param HelperChunkSize Helper chunk size for combined directives.
624  ///
626  SourceLocation KLoc, SourceLocation CommaLoc,
628  Expr *ChunkSize, Expr *HelperChunkSize)
629  : OMPClause(OMPC_schedule, StartLoc, EndLoc), LParenLoc(LParenLoc),
630  Kind(Kind), KindLoc(KLoc), CommaLoc(CommaLoc) {
631  ChunkSizes[CHUNK_SIZE] = ChunkSize;
632  ChunkSizes[HELPER_CHUNK_SIZE] = HelperChunkSize;
633  }
634 
635  /// \brief Build an empty clause.
636  ///
637  explicit OMPScheduleClause()
638  : OMPClause(OMPC_schedule, SourceLocation(), SourceLocation()),
640  ChunkSizes[CHUNK_SIZE] = nullptr;
641  ChunkSizes[HELPER_CHUNK_SIZE] = nullptr;
642  }
643 
644  /// \brief Get kind of the clause.
645  ///
647  /// \brief Get location of '('.
648  ///
649  SourceLocation getLParenLoc() { return LParenLoc; }
650  /// \brief Get kind location.
651  ///
652  SourceLocation getScheduleKindLoc() { return KindLoc; }
653  /// \brief Get location of ','.
654  ///
655  SourceLocation getCommaLoc() { return CommaLoc; }
656  /// \brief Get chunk size.
657  ///
658  Expr *getChunkSize() { return dyn_cast_or_null<Expr>(ChunkSizes[CHUNK_SIZE]); }
659  /// \brief Get chunk size.
660  ///
661  Expr *getChunkSize() const {
662  return dyn_cast_or_null<Expr>(ChunkSizes[CHUNK_SIZE]);
663  }
664  /// \brief Get helper chunk size.
665  ///
667  return dyn_cast_or_null<Expr>(ChunkSizes[HELPER_CHUNK_SIZE]);
668  }
669  /// \brief Get helper chunk size.
670  ///
672  return dyn_cast_or_null<Expr>(ChunkSizes[HELPER_CHUNK_SIZE]);
673  }
674 
675  static bool classof(const OMPClause *T) {
676  return T->getClauseKind() == OMPC_schedule;
677  }
678 
680  return StmtRange(&ChunkSizes[CHUNK_SIZE], &ChunkSizes[CHUNK_SIZE] + 1);
681  }
682 };
683 
684 /// \brief This represents 'ordered' clause in the '#pragma omp ...' directive.
685 ///
686 /// \code
687 /// #pragma omp for ordered
688 /// \endcode
689 /// In this example directive '#pragma omp for' has 'ordered' clause.
690 ///
691 class OMPOrderedClause : public OMPClause {
692 public:
693  /// \brief Build 'ordered' clause.
694  ///
695  /// \param StartLoc Starting location of the clause.
696  /// \param EndLoc Ending location of the clause.
697  ///
699  : OMPClause(OMPC_ordered, StartLoc, EndLoc) {}
700 
701  /// \brief Build an empty clause.
702  ///
704  : OMPClause(OMPC_ordered, SourceLocation(), SourceLocation()) {}
705 
706  static bool classof(const OMPClause *T) {
707  return T->getClauseKind() == OMPC_ordered;
708  }
709 
710  StmtRange children() { return StmtRange(); }
711 };
712 
713 /// \brief This represents 'nowait' clause in the '#pragma omp ...' directive.
714 ///
715 /// \code
716 /// #pragma omp for nowait
717 /// \endcode
718 /// In this example directive '#pragma omp for' has 'nowait' clause.
719 ///
720 class OMPNowaitClause : public OMPClause {
721 public:
722  /// \brief Build 'nowait' clause.
723  ///
724  /// \param StartLoc Starting location of the clause.
725  /// \param EndLoc Ending location of the clause.
726  ///
728  : OMPClause(OMPC_nowait, StartLoc, EndLoc) {}
729 
730  /// \brief Build an empty clause.
731  ///
733  : OMPClause(OMPC_nowait, SourceLocation(), SourceLocation()) {}
734 
735  static bool classof(const OMPClause *T) {
736  return T->getClauseKind() == OMPC_nowait;
737  }
738 
739  StmtRange children() { return StmtRange(); }
740 };
741 
742 /// \brief This represents 'untied' clause in the '#pragma omp ...' directive.
743 ///
744 /// \code
745 /// #pragma omp task untied
746 /// \endcode
747 /// In this example directive '#pragma omp task' has 'untied' clause.
748 ///
749 class OMPUntiedClause : public OMPClause {
750 public:
751  /// \brief Build 'untied' clause.
752  ///
753  /// \param StartLoc Starting location of the clause.
754  /// \param EndLoc Ending location of the clause.
755  ///
757  : OMPClause(OMPC_untied, StartLoc, EndLoc) {}
758 
759  /// \brief Build an empty clause.
760  ///
762  : OMPClause(OMPC_untied, SourceLocation(), SourceLocation()) {}
763 
764  static bool classof(const OMPClause *T) {
765  return T->getClauseKind() == OMPC_untied;
766  }
767 
768  StmtRange children() { return StmtRange(); }
769 };
770 
771 /// \brief This represents 'mergeable' clause in the '#pragma omp ...'
772 /// directive.
773 ///
774 /// \code
775 /// #pragma omp task mergeable
776 /// \endcode
777 /// In this example directive '#pragma omp task' has 'mergeable' clause.
778 ///
780 public:
781  /// \brief Build 'mergeable' clause.
782  ///
783  /// \param StartLoc Starting location of the clause.
784  /// \param EndLoc Ending location of the clause.
785  ///
787  : OMPClause(OMPC_mergeable, StartLoc, EndLoc) {}
788 
789  /// \brief Build an empty clause.
790  ///
792  : OMPClause(OMPC_mergeable, SourceLocation(), SourceLocation()) {}
793 
794  static bool classof(const OMPClause *T) {
795  return T->getClauseKind() == OMPC_mergeable;
796  }
797 
798  StmtRange children() { return StmtRange(); }
799 };
800 
801 /// \brief This represents 'read' clause in the '#pragma omp atomic' directive.
802 ///
803 /// \code
804 /// #pragma omp atomic read
805 /// \endcode
806 /// In this example directive '#pragma omp atomic' has 'read' clause.
807 ///
808 class OMPReadClause : public OMPClause {
809 public:
810  /// \brief Build 'read' clause.
811  ///
812  /// \param StartLoc Starting location of the clause.
813  /// \param EndLoc Ending location of the clause.
814  ///
816  : OMPClause(OMPC_read, StartLoc, EndLoc) {}
817 
818  /// \brief Build an empty clause.
819  ///
821 
822  static bool classof(const OMPClause *T) {
823  return T->getClauseKind() == OMPC_read;
824  }
825 
826  StmtRange children() { return StmtRange(); }
827 };
828 
829 /// \brief This represents 'write' clause in the '#pragma omp atomic' directive.
830 ///
831 /// \code
832 /// #pragma omp atomic write
833 /// \endcode
834 /// In this example directive '#pragma omp atomic' has 'write' clause.
835 ///
836 class OMPWriteClause : public OMPClause {
837 public:
838  /// \brief Build 'write' clause.
839  ///
840  /// \param StartLoc Starting location of the clause.
841  /// \param EndLoc Ending location of the clause.
842  ///
844  : OMPClause(OMPC_write, StartLoc, EndLoc) {}
845 
846  /// \brief Build an empty clause.
847  ///
849  : OMPClause(OMPC_write, SourceLocation(), SourceLocation()) {}
850 
851  static bool classof(const OMPClause *T) {
852  return T->getClauseKind() == OMPC_write;
853  }
854 
855  StmtRange children() { return StmtRange(); }
856 };
857 
858 /// \brief This represents 'update' clause in the '#pragma omp atomic'
859 /// directive.
860 ///
861 /// \code
862 /// #pragma omp atomic update
863 /// \endcode
864 /// In this example directive '#pragma omp atomic' has 'update' clause.
865 ///
866 class OMPUpdateClause : public OMPClause {
867 public:
868  /// \brief Build 'update' clause.
869  ///
870  /// \param StartLoc Starting location of the clause.
871  /// \param EndLoc Ending location of the clause.
872  ///
874  : OMPClause(OMPC_update, StartLoc, EndLoc) {}
875 
876  /// \brief Build an empty clause.
877  ///
879  : OMPClause(OMPC_update, SourceLocation(), SourceLocation()) {}
880 
881  static bool classof(const OMPClause *T) {
882  return T->getClauseKind() == OMPC_update;
883  }
884 
885  StmtRange children() { return StmtRange(); }
886 };
887 
888 /// \brief This represents 'capture' clause in the '#pragma omp atomic'
889 /// directive.
890 ///
891 /// \code
892 /// #pragma omp atomic capture
893 /// \endcode
894 /// In this example directive '#pragma omp atomic' has 'capture' clause.
895 ///
896 class OMPCaptureClause : public OMPClause {
897 public:
898  /// \brief Build 'capture' clause.
899  ///
900  /// \param StartLoc Starting location of the clause.
901  /// \param EndLoc Ending location of the clause.
902  ///
904  : OMPClause(OMPC_capture, StartLoc, EndLoc) {}
905 
906  /// \brief Build an empty clause.
907  ///
909  : OMPClause(OMPC_capture, SourceLocation(), SourceLocation()) {}
910 
911  static bool classof(const OMPClause *T) {
912  return T->getClauseKind() == OMPC_capture;
913  }
914 
915  StmtRange children() { return StmtRange(); }
916 };
917 
918 /// \brief This represents 'seq_cst' clause in the '#pragma omp atomic'
919 /// directive.
920 ///
921 /// \code
922 /// #pragma omp atomic seq_cst
923 /// \endcode
924 /// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
925 ///
926 class OMPSeqCstClause : public OMPClause {
927 public:
928  /// \brief Build 'seq_cst' clause.
929  ///
930  /// \param StartLoc Starting location of the clause.
931  /// \param EndLoc Ending location of the clause.
932  ///
934  : OMPClause(OMPC_seq_cst, StartLoc, EndLoc) {}
935 
936  /// \brief Build an empty clause.
937  ///
939  : OMPClause(OMPC_seq_cst, SourceLocation(), SourceLocation()) {}
940 
941  static bool classof(const OMPClause *T) {
942  return T->getClauseKind() == OMPC_seq_cst;
943  }
944 
945  StmtRange children() { return StmtRange(); }
946 };
947 
948 /// \brief This represents clause 'private' in the '#pragma omp ...' directives.
949 ///
950 /// \code
951 /// #pragma omp parallel private(a,b)
952 /// \endcode
953 /// In this example directive '#pragma omp parallel' has clause 'private'
954 /// with the variables 'a' and 'b'.
955 ///
956 class OMPPrivateClause : public OMPVarListClause<OMPPrivateClause> {
957  friend class OMPClauseReader;
958  /// \brief Build clause with number of variables \a N.
959  ///
960  /// \param StartLoc Starting location of the clause.
961  /// \param LParenLoc Location of '('.
962  /// \param EndLoc Ending location of the clause.
963  /// \param N Number of the variables in the clause.
964  ///
965  OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
966  SourceLocation EndLoc, unsigned N)
967  : OMPVarListClause<OMPPrivateClause>(OMPC_private, StartLoc, LParenLoc,
968  EndLoc, N) {}
969 
970  /// \brief Build an empty clause.
971  ///
972  /// \param N Number of variables.
973  ///
974  explicit OMPPrivateClause(unsigned N)
977  N) {}
978 
979  /// \brief Sets the list of references to private copies with initializers for
980  /// new private variables.
981  /// \param VL List of references.
982  void setPrivateCopies(ArrayRef<Expr *> VL);
983 
984  /// \brief Gets the list of references to private copies with initializers for
985  /// new private variables.
986  MutableArrayRef<Expr *> getPrivateCopies() {
987  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
988  }
989  ArrayRef<const Expr *> getPrivateCopies() const {
990  return llvm::makeArrayRef(varlist_end(), varlist_size());
991  }
992 
993 public:
994  /// \brief Creates clause with a list of variables \a VL.
995  ///
996  /// \param C AST context.
997  /// \param StartLoc Starting location of the clause.
998  /// \param LParenLoc Location of '('.
999  /// \param EndLoc Ending location of the clause.
1000  /// \param VL List of references to the variables.
1001  /// \param PrivateVL List of references to private copies with initializers.
1002  ///
1003  static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
1004  SourceLocation LParenLoc,
1005  SourceLocation EndLoc, ArrayRef<Expr *> VL,
1006  ArrayRef<Expr *> PrivateVL);
1007  /// \brief Creates an empty clause with the place for \a N variables.
1008  ///
1009  /// \param C AST context.
1010  /// \param N The number of variables.
1011  ///
1012  static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1013 
1016  typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
1017  typedef llvm::iterator_range<private_copies_const_iterator>
1019 
1021  return private_copies_range(getPrivateCopies().begin(),
1022  getPrivateCopies().end());
1023  }
1025  return private_copies_const_range(getPrivateCopies().begin(),
1026  getPrivateCopies().end());
1027  }
1028 
1030  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1031  reinterpret_cast<Stmt **>(varlist_end()));
1032  }
1033 
1034  static bool classof(const OMPClause *T) {
1035  return T->getClauseKind() == OMPC_private;
1036  }
1037 };
1038 
1039 /// \brief This represents clause 'firstprivate' in the '#pragma omp ...'
1040 /// directives.
1041 ///
1042 /// \code
1043 /// #pragma omp parallel firstprivate(a,b)
1044 /// \endcode
1045 /// In this example directive '#pragma omp parallel' has clause 'firstprivate'
1046 /// with the variables 'a' and 'b'.
1047 ///
1048 class OMPFirstprivateClause : public OMPVarListClause<OMPFirstprivateClause> {
1049  friend class OMPClauseReader;
1050 
1051  /// \brief Build clause with number of variables \a N.
1052  ///
1053  /// \param StartLoc Starting location of the clause.
1054  /// \param LParenLoc Location of '('.
1055  /// \param EndLoc Ending location of the clause.
1056  /// \param N Number of the variables in the clause.
1057  ///
1059  SourceLocation EndLoc, unsigned N)
1060  : OMPVarListClause<OMPFirstprivateClause>(OMPC_firstprivate, StartLoc,
1061  LParenLoc, EndLoc, N) {}
1062 
1063  /// \brief Build an empty clause.
1064  ///
1065  /// \param N Number of variables.
1066  ///
1067  explicit OMPFirstprivateClause(unsigned N)
1069  OMPC_firstprivate, SourceLocation(), SourceLocation(),
1070  SourceLocation(), N) {}
1071  /// \brief Sets the list of references to private copies with initializers for
1072  /// new private variables.
1073  /// \param VL List of references.
1074  void setPrivateCopies(ArrayRef<Expr *> VL);
1075 
1076  /// \brief Gets the list of references to private copies with initializers for
1077  /// new private variables.
1078  MutableArrayRef<Expr *> getPrivateCopies() {
1079  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1080  }
1081  ArrayRef<const Expr *> getPrivateCopies() const {
1082  return llvm::makeArrayRef(varlist_end(), varlist_size());
1083  }
1084 
1085  /// \brief Sets the list of references to initializer variables for new
1086  /// private variables.
1087  /// \param VL List of references.
1088  void setInits(ArrayRef<Expr *> VL);
1089 
1090  /// \brief Gets the list of references to initializer variables for new
1091  /// private variables.
1092  MutableArrayRef<Expr *> getInits() {
1093  return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1094  }
1095  ArrayRef<const Expr *> getInits() const {
1096  return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1097  }
1098 
1099 public:
1100  /// \brief Creates clause with a list of variables \a VL.
1101  ///
1102  /// \param C AST context.
1103  /// \param StartLoc Starting location of the clause.
1104  /// \param LParenLoc Location of '('.
1105  /// \param EndLoc Ending location of the clause.
1106  /// \param VL List of references to the original variables.
1107  /// \param PrivateVL List of references to private copies with initializers.
1108  /// \param InitVL List of references to auto generated variables used for
1109  /// initialization of a single array element. Used if firstprivate variable is
1110  /// of array type.
1111  ///
1112  static OMPFirstprivateClause *
1113  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1114  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
1115  ArrayRef<Expr *> InitVL);
1116  /// \brief Creates an empty clause with the place for \a N variables.
1117  ///
1118  /// \param C AST context.
1119  /// \param N The number of variables.
1120  ///
1121  static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1122 
1125  typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
1126  typedef llvm::iterator_range<private_copies_const_iterator>
1128 
1130  return private_copies_range(getPrivateCopies().begin(),
1131  getPrivateCopies().end());
1132  }
1134  return private_copies_const_range(getPrivateCopies().begin(),
1135  getPrivateCopies().end());
1136  }
1137 
1140  typedef llvm::iterator_range<inits_iterator> inits_range;
1141  typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
1142 
1144  return inits_range(getInits().begin(), getInits().end());
1145  }
1147  return inits_const_range(getInits().begin(), getInits().end());
1148  }
1149 
1151  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1152  reinterpret_cast<Stmt **>(varlist_end()));
1153  }
1154 
1155  static bool classof(const OMPClause *T) {
1156  return T->getClauseKind() == OMPC_firstprivate;
1157  }
1158 };
1159 
1160 /// \brief This represents clause 'lastprivate' in the '#pragma omp ...'
1161 /// directives.
1162 ///
1163 /// \code
1164 /// #pragma omp simd lastprivate(a,b)
1165 /// \endcode
1166 /// In this example directive '#pragma omp simd' has clause 'lastprivate'
1167 /// with the variables 'a' and 'b'.
1168 class OMPLastprivateClause : public OMPVarListClause<OMPLastprivateClause> {
1169  // There are 4 additional tail-allocated arrays at the end of the class:
1170  // 1. Contains list of pseudo variables with the default initialization for
1171  // each non-firstprivate variables. Used in codegen for initialization of
1172  // lastprivate copies.
1173  // 2. List of helper expressions for proper generation of assignment operation
1174  // required for lastprivate clause. This list represents private variables
1175  // (for arrays, single array element).
1176  // 3. List of helper expressions for proper generation of assignment operation
1177  // required for lastprivate clause. This list represents original variables
1178  // (for arrays, single array element).
1179  // 4. List of helper expressions that represents assignment operation:
1180  // \code
1181  // DstExprs = SrcExprs;
1182  // \endcode
1183  // Required for proper codegen of final assignment performed by the
1184  // lastprivate clause.
1185  //
1186  friend class OMPClauseReader;
1187 
1188  /// \brief Build clause with number of variables \a N.
1189  ///
1190  /// \param StartLoc Starting location of the clause.
1191  /// \param LParenLoc Location of '('.
1192  /// \param EndLoc Ending location of the clause.
1193  /// \param N Number of the variables in the clause.
1194  ///
1196  SourceLocation EndLoc, unsigned N)
1197  : OMPVarListClause<OMPLastprivateClause>(OMPC_lastprivate, StartLoc,
1198  LParenLoc, EndLoc, N) {}
1199 
1200  /// \brief Build an empty clause.
1201  ///
1202  /// \param N Number of variables.
1203  ///
1204  explicit OMPLastprivateClause(unsigned N)
1206  OMPC_lastprivate, SourceLocation(), SourceLocation(),
1207  SourceLocation(), N) {}
1208 
1209  /// \brief Get the list of helper expressions for initialization of private
1210  /// copies for lastprivate variables.
1211  MutableArrayRef<Expr *> getPrivateCopies() {
1212  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1213  }
1214  ArrayRef<const Expr *> getPrivateCopies() const {
1215  return llvm::makeArrayRef(varlist_end(), varlist_size());
1216  }
1217 
1218  /// \brief Set list of helper expressions, required for proper codegen of the
1219  /// clause. These expressions represent private variables (for arrays, single
1220  /// array element) in the final assignment statement performed by the
1221  /// lastprivate clause.
1222  void setSourceExprs(ArrayRef<Expr *> SrcExprs);
1223 
1224  /// \brief Get the list of helper source expressions.
1225  MutableArrayRef<Expr *> getSourceExprs() {
1226  return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1227  }
1228  ArrayRef<const Expr *> getSourceExprs() const {
1229  return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1230  }
1231 
1232  /// \brief Set list of helper expressions, required for proper codegen of the
1233  /// clause. These expressions represent original variables (for arrays, single
1234  /// array element) in the final assignment statement performed by the
1235  /// lastprivate clause.
1236  void setDestinationExprs(ArrayRef<Expr *> DstExprs);
1237 
1238  /// \brief Get the list of helper destination expressions.
1239  MutableArrayRef<Expr *> getDestinationExprs() {
1240  return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
1241  }
1242  ArrayRef<const Expr *> getDestinationExprs() const {
1243  return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
1244  }
1245 
1246  /// \brief Set list of helper assignment expressions, required for proper
1247  /// codegen of the clause. These expressions are assignment expressions that
1248  /// assign private copy of the variable to original variable.
1249  void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
1250 
1251  /// \brief Get the list of helper assignment expressions.
1252  MutableArrayRef<Expr *> getAssignmentOps() {
1253  return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
1254  }
1255  ArrayRef<const Expr *> getAssignmentOps() const {
1256  return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
1257  }
1258 
1259 public:
1260  /// \brief Creates clause with a list of variables \a VL.
1261  ///
1262  /// \param C AST context.
1263  /// \param StartLoc Starting location of the clause.
1264  /// \param LParenLoc Location of '('.
1265  /// \param EndLoc Ending location of the clause.
1266  /// \param VL List of references to the variables.
1267  /// \param SrcExprs List of helper expressions for proper generation of
1268  /// assignment operation required for lastprivate clause. This list represents
1269  /// private variables (for arrays, single array element).
1270  /// \param DstExprs List of helper expressions for proper generation of
1271  /// assignment operation required for lastprivate clause. This list represents
1272  /// original variables (for arrays, single array element).
1273  /// \param AssignmentOps List of helper expressions that represents assignment
1274  /// operation:
1275  /// \code
1276  /// DstExprs = SrcExprs;
1277  /// \endcode
1278  /// Required for proper codegen of final assignment performed by the
1279  /// lastprivate clause.
1280  ///
1281  ///
1282  static OMPLastprivateClause *
1283  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1284  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
1285  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
1286  /// \brief Creates an empty clause with the place for \a N variables.
1287  ///
1288  /// \param C AST context.
1289  /// \param N The number of variables.
1290  ///
1291  static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1292 
1295  typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
1296  typedef llvm::iterator_range<helper_expr_const_iterator>
1298 
1299  /// \brief Set list of helper expressions, required for generation of private
1300  /// copies of original lastprivate variables.
1301  void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
1302 
1304  return helper_expr_const_range(getPrivateCopies().begin(),
1305  getPrivateCopies().end());
1306  }
1308  return helper_expr_range(getPrivateCopies().begin(),
1309  getPrivateCopies().end());
1310  }
1312  return helper_expr_const_range(getSourceExprs().begin(),
1313  getSourceExprs().end());
1314  }
1316  return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
1317  }
1319  return helper_expr_const_range(getDestinationExprs().begin(),
1320  getDestinationExprs().end());
1321  }
1323  return helper_expr_range(getDestinationExprs().begin(),
1324  getDestinationExprs().end());
1325  }
1327  return helper_expr_const_range(getAssignmentOps().begin(),
1328  getAssignmentOps().end());
1329  }
1331  return helper_expr_range(getAssignmentOps().begin(),
1332  getAssignmentOps().end());
1333  }
1334 
1336  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1337  reinterpret_cast<Stmt **>(varlist_end()));
1338  }
1339 
1340  static bool classof(const OMPClause *T) {
1341  return T->getClauseKind() == OMPC_lastprivate;
1342  }
1343 };
1344 
1345 /// \brief This represents clause 'shared' in the '#pragma omp ...' directives.
1346 ///
1347 /// \code
1348 /// #pragma omp parallel shared(a,b)
1349 /// \endcode
1350 /// In this example directive '#pragma omp parallel' has clause 'shared'
1351 /// with the variables 'a' and 'b'.
1352 ///
1353 class OMPSharedClause : public OMPVarListClause<OMPSharedClause> {
1354  /// \brief Build clause with number of variables \a N.
1355  ///
1356  /// \param StartLoc Starting location of the clause.
1357  /// \param LParenLoc Location of '('.
1358  /// \param EndLoc Ending location of the clause.
1359  /// \param N Number of the variables in the clause.
1360  ///
1361  OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1362  SourceLocation EndLoc, unsigned N)
1363  : OMPVarListClause<OMPSharedClause>(OMPC_shared, StartLoc, LParenLoc,
1364  EndLoc, N) {}
1365 
1366  /// \brief Build an empty clause.
1367  ///
1368  /// \param N Number of variables.
1369  ///
1370  explicit OMPSharedClause(unsigned N)
1373  N) {}
1374 
1375 public:
1376  /// \brief Creates clause with a list of variables \a VL.
1377  ///
1378  /// \param C AST context.
1379  /// \param StartLoc Starting location of the clause.
1380  /// \param LParenLoc Location of '('.
1381  /// \param EndLoc Ending location of the clause.
1382  /// \param VL List of references to the variables.
1383  ///
1384  static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
1385  SourceLocation LParenLoc,
1386  SourceLocation EndLoc, ArrayRef<Expr *> VL);
1387  /// \brief Creates an empty clause with \a N variables.
1388  ///
1389  /// \param C AST context.
1390  /// \param N The number of variables.
1391  ///
1392  static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
1393 
1395  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1396  reinterpret_cast<Stmt **>(varlist_end()));
1397  }
1398 
1399  static bool classof(const OMPClause *T) {
1400  return T->getClauseKind() == OMPC_shared;
1401  }
1402 };
1403 
1404 /// \brief This represents clause 'reduction' in the '#pragma omp ...'
1405 /// directives.
1406 ///
1407 /// \code
1408 /// #pragma omp parallel reduction(+:a,b)
1409 /// \endcode
1410 /// In this example directive '#pragma omp parallel' has clause 'reduction'
1411 /// with operator '+' and the variables 'a' and 'b'.
1412 ///
1413 class OMPReductionClause : public OMPVarListClause<OMPReductionClause> {
1414  friend class OMPClauseReader;
1415  /// \brief Location of ':'.
1417  /// \brief Nested name specifier for C++.
1418  NestedNameSpecifierLoc QualifierLoc;
1419  /// \brief Name of custom operator.
1420  DeclarationNameInfo NameInfo;
1421 
1422  /// \brief Build clause with number of variables \a N.
1423  ///
1424  /// \param StartLoc Starting location of the clause.
1425  /// \param LParenLoc Location of '('.
1426  /// \param EndLoc Ending location of the clause.
1427  /// \param ColonLoc Location of ':'.
1428  /// \param N Number of the variables in the clause.
1429  /// \param QualifierLoc The nested-name qualifier with location information
1430  /// \param NameInfo The full name info for reduction identifier.
1431  ///
1432  OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1433  SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N,
1434  NestedNameSpecifierLoc QualifierLoc,
1435  const DeclarationNameInfo &NameInfo)
1436  : OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
1437  LParenLoc, EndLoc, N),
1438  ColonLoc(ColonLoc), QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
1439 
1440  /// \brief Build an empty clause.
1441  ///
1442  /// \param N Number of variables.
1443  ///
1444  explicit OMPReductionClause(unsigned N)
1445  : OMPVarListClause<OMPReductionClause>(OMPC_reduction, SourceLocation(),
1447  N),
1448  ColonLoc(), QualifierLoc(), NameInfo() {}
1449 
1450  /// \brief Sets location of ':' symbol in clause.
1451  void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
1452  /// \brief Sets the name info for specified reduction identifier.
1453  void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
1454  /// \brief Sets the nested name specifier.
1455  void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
1456 
1457  /// \brief Set list of helper expressions, required for proper codegen of the
1458  /// clause. These expressions represent LHS expression in the final
1459  /// reduction expression performed by the reduction clause.
1460  void setLHSExprs(ArrayRef<Expr *> LHSExprs);
1461 
1462  /// \brief Get the list of helper LHS expressions.
1463  MutableArrayRef<Expr *> getLHSExprs() {
1464  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1465  }
1466  ArrayRef<const Expr *> getLHSExprs() const {
1467  return llvm::makeArrayRef(varlist_end(), varlist_size());
1468  }
1469 
1470  /// \brief Set list of helper expressions, required for proper codegen of the
1471  /// clause. These expressions represent RHS expression in the final
1472  /// reduction expression performed by the reduction clause.
1473  /// Also, variables in these expressions are used for proper initialization of
1474  /// reduction copies.
1475  void setRHSExprs(ArrayRef<Expr *> RHSExprs);
1476 
1477  /// \brief Get the list of helper destination expressions.
1478  MutableArrayRef<Expr *> getRHSExprs() {
1479  return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
1480  }
1481  ArrayRef<const Expr *> getRHSExprs() const {
1482  return llvm::makeArrayRef(getLHSExprs().end(), varlist_size());
1483  }
1484 
1485  /// \brief Set list of helper reduction expressions, required for proper
1486  /// codegen of the clause. These expressions are binary expressions or
1487  /// operator/custom reduction call that calculates new value from source
1488  /// helper expressions to destination helper expressions.
1489  void setReductionOps(ArrayRef<Expr *> ReductionOps);
1490 
1491  /// \brief Get the list of helper reduction expressions.
1492  MutableArrayRef<Expr *> getReductionOps() {
1493  return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
1494  }
1495  ArrayRef<const Expr *> getReductionOps() const {
1496  return llvm::makeArrayRef(getRHSExprs().end(), varlist_size());
1497  }
1498 
1499 public:
1500  /// \brief Creates clause with a list of variables \a VL.
1501  ///
1502  /// \param StartLoc Starting location of the clause.
1503  /// \param LParenLoc Location of '('.
1504  /// \param ColonLoc Location of ':'.
1505  /// \param EndLoc Ending location of the clause.
1506  /// \param VL The variables in the clause.
1507  /// \param QualifierLoc The nested-name qualifier with location information
1508  /// \param NameInfo The full name info for reduction identifier.
1509  /// \param LHSExprs List of helper expressions for proper generation of
1510  /// assignment operation required for copyprivate clause. This list represents
1511  /// LHSs of the reduction expressions.
1512  /// \param RHSExprs List of helper expressions for proper generation of
1513  /// assignment operation required for copyprivate clause. This list represents
1514  /// RHSs of the reduction expressions.
1515  /// Also, variables in these expressions are used for proper initialization of
1516  /// reduction copies.
1517  /// \param ReductionOps List of helper expressions that represents reduction
1518  /// expressions:
1519  /// \code
1520  /// LHSExprs binop RHSExprs;
1521  /// operator binop(LHSExpr, RHSExpr);
1522  /// <CutomReduction>(LHSExpr, RHSExpr);
1523  /// \endcode
1524  /// Required for proper codegen of final reduction operation performed by the
1525  /// reduction clause.
1526  ///
1527  static OMPReductionClause *
1528  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1529  SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
1530  NestedNameSpecifierLoc QualifierLoc,
1531  const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> LHSExprs,
1532  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps);
1533  /// \brief Creates an empty clause with the place for \a N variables.
1534  ///
1535  /// \param C AST context.
1536  /// \param N The number of variables.
1537  ///
1538  static OMPReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
1539 
1540  /// \brief Gets location of ':' symbol in clause.
1542  /// \brief Gets the name info for specified reduction identifier.
1543  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
1544  /// \brief Gets the nested name specifier.
1545  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
1546 
1549  typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
1550  typedef llvm::iterator_range<helper_expr_const_iterator>
1552 
1554  return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
1555  }
1557  return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
1558  }
1560  return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
1561  }
1563  return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
1564  }
1566  return helper_expr_const_range(getReductionOps().begin(),
1567  getReductionOps().end());
1568  }
1570  return helper_expr_range(getReductionOps().begin(),
1571  getReductionOps().end());
1572  }
1573 
1575  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1576  reinterpret_cast<Stmt **>(varlist_end()));
1577  }
1578 
1579  static bool classof(const OMPClause *T) {
1580  return T->getClauseKind() == OMPC_reduction;
1581  }
1582 };
1583 
1584 /// \brief This represents clause 'linear' in the '#pragma omp ...'
1585 /// directives.
1586 ///
1587 /// \code
1588 /// #pragma omp simd linear(a,b : 2)
1589 /// \endcode
1590 /// In this example directive '#pragma omp simd' has clause 'linear'
1591 /// with variables 'a', 'b' and linear step '2'.
1592 ///
1593 class OMPLinearClause : public OMPVarListClause<OMPLinearClause> {
1594  friend class OMPClauseReader;
1595  /// \brief Location of ':'.
1597 
1598  /// \brief Sets the linear step for clause.
1599  void setStep(Expr *Step) { *(getFinals().end()) = Step; }
1600 
1601  /// \brief Sets the expression to calculate linear step for clause.
1602  void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
1603 
1604  /// \brief Build 'linear' clause with given number of variables \a NumVars.
1605  ///
1606  /// \param StartLoc Starting location of the clause.
1607  /// \param LParenLoc Location of '('.
1608  /// \param ColonLoc Location of ':'.
1609  /// \param EndLoc Ending location of the clause.
1610  /// \param NumVars Number of variables.
1611  ///
1612  OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1613  SourceLocation ColonLoc, SourceLocation EndLoc,
1614  unsigned NumVars)
1615  : OMPVarListClause<OMPLinearClause>(OMPC_linear, StartLoc, LParenLoc,
1616  EndLoc, NumVars),
1617  ColonLoc(ColonLoc) {}
1618 
1619  /// \brief Build an empty clause.
1620  ///
1621  /// \param NumVars Number of variables.
1622  ///
1623  explicit OMPLinearClause(unsigned NumVars)
1624  : OMPVarListClause<OMPLinearClause>(OMPC_linear, SourceLocation(),
1625  SourceLocation(), SourceLocation(),
1626  NumVars),
1627  ColonLoc(SourceLocation()) {}
1628 
1629  /// \brief Gets the list of initial values for linear variables.
1630  ///
1631  /// There are NumVars expressions with initial values allocated after the
1632  /// varlist, they are followed by NumVars update expressions (used to update
1633  /// the linear variable's value on current iteration) and they are followed by
1634  /// NumVars final expressions (used to calculate the linear variable's
1635  /// value after the loop body). After these lists, there are 2 helper
1636  /// expressions - linear step and a helper to calculate it before the
1637  /// loop body (used when the linear step is not constant):
1638  ///
1639  /// { Vars[] /* in OMPVarListClause */; Inits[]; Updates[]; Finals[];
1640  /// Step; CalcStep; }
1641  ///
1644  }
1645  ArrayRef<const Expr *> getInits() const {
1646  return llvm::makeArrayRef(varlist_end(), varlist_size());
1647  }
1648 
1649  /// \brief Sets the list of update expressions for linear variables.
1651  return MutableArrayRef<Expr *>(getInits().end(), varlist_size());
1652  }
1653  ArrayRef<const Expr *> getUpdates() const {
1654  return llvm::makeArrayRef(getInits().end(), varlist_size());
1655  }
1656 
1657  /// \brief Sets the list of final update expressions for linear variables.
1659  return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size());
1660  }
1661  ArrayRef<const Expr *> getFinals() const {
1662  return llvm::makeArrayRef(getUpdates().end(), varlist_size());
1663  }
1664 
1665  /// \brief Sets the list of the initial values for linear variables.
1666  /// \param IL List of expressions.
1667  void setInits(ArrayRef<Expr *> IL);
1668 
1669 public:
1670  /// \brief Creates clause with a list of variables \a VL and a linear step
1671  /// \a Step.
1672  ///
1673  /// \param C AST Context.
1674  /// \param StartLoc Starting location of the clause.
1675  /// \param LParenLoc Location of '('.
1676  /// \param ColonLoc Location of ':'.
1677  /// \param EndLoc Ending location of the clause.
1678  /// \param VL List of references to the variables.
1679  /// \param IL List of initial values for the variables.
1680  /// \param Step Linear step.
1681  /// \param CalcStep Calculation of the linear step.
1682  static OMPLinearClause *Create(const ASTContext &C, SourceLocation StartLoc,
1683  SourceLocation LParenLoc,
1684  SourceLocation ColonLoc, SourceLocation EndLoc,
1685  ArrayRef<Expr *> VL, ArrayRef<Expr *> IL,
1686  Expr *Step, Expr *CalcStep);
1687 
1688  /// \brief Creates an empty clause with the place for \a NumVars variables.
1689  ///
1690  /// \param C AST context.
1691  /// \param NumVars Number of variables.
1692  ///
1693  static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
1694 
1695  /// \brief Sets the location of ':'.
1696  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
1697  /// \brief Returns the location of '('.
1699 
1700  /// \brief Returns linear step.
1701  Expr *getStep() { return *(getFinals().end()); }
1702  /// \brief Returns linear step.
1703  const Expr *getStep() const { return *(getFinals().end()); }
1704  /// \brief Returns expression to calculate linear step.
1705  Expr *getCalcStep() { return *(getFinals().end() + 1); }
1706  /// \brief Returns expression to calculate linear step.
1707  const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
1708 
1709  /// \brief Sets the list of update expressions for linear variables.
1710  /// \param UL List of expressions.
1711  void setUpdates(ArrayRef<Expr *> UL);
1712 
1713  /// \brief Sets the list of final update expressions for linear variables.
1714  /// \param FL List of expressions.
1715  void setFinals(ArrayRef<Expr *> FL);
1716 
1719  typedef llvm::iterator_range<inits_iterator> inits_range;
1720  typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
1721 
1723  return inits_range(getInits().begin(), getInits().end());
1724  }
1725  inits_const_range inits() const {
1726  return inits_const_range(getInits().begin(), getInits().end());
1727  }
1728 
1731  typedef llvm::iterator_range<updates_iterator> updates_range;
1732  typedef llvm::iterator_range<updates_const_iterator> updates_const_range;
1733 
1735  return updates_range(getUpdates().begin(), getUpdates().end());
1736  }
1737  updates_const_range updates() const {
1738  return updates_const_range(getUpdates().begin(), getUpdates().end());
1739  }
1740 
1743  typedef llvm::iterator_range<finals_iterator> finals_range;
1744  typedef llvm::iterator_range<finals_const_iterator> finals_const_range;
1745 
1747  return finals_range(getFinals().begin(), getFinals().end());
1748  }
1749  finals_const_range finals() const {
1750  return finals_const_range(getFinals().begin(), getFinals().end());
1751  }
1752 
1754  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1755  reinterpret_cast<Stmt **>(varlist_end()));
1756  }
1757 
1758  static bool classof(const OMPClause *T) {
1759  return T->getClauseKind() == OMPC_linear;
1760  }
1761 };
1762 
1763 /// \brief This represents clause 'aligned' in the '#pragma omp ...'
1764 /// directives.
1765 ///
1766 /// \code
1767 /// #pragma omp simd aligned(a,b : 8)
1768 /// \endcode
1769 /// In this example directive '#pragma omp simd' has clause 'aligned'
1770 /// with variables 'a', 'b' and alignment '8'.
1771 ///
1772 class OMPAlignedClause : public OMPVarListClause<OMPAlignedClause> {
1773  friend class OMPClauseReader;
1774  /// \brief Location of ':'.
1775  SourceLocation ColonLoc;
1776 
1777  /// \brief Sets the alignment for clause.
1778  void setAlignment(Expr *A) { *varlist_end() = A; }
1779 
1780  /// \brief Build 'aligned' clause with given number of variables \a NumVars.
1781  ///
1782  /// \param StartLoc Starting location of the clause.
1783  /// \param LParenLoc Location of '('.
1784  /// \param ColonLoc Location of ':'.
1785  /// \param EndLoc Ending location of the clause.
1786  /// \param NumVars Number of variables.
1787  ///
1788  OMPAlignedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1789  SourceLocation ColonLoc, SourceLocation EndLoc,
1790  unsigned NumVars)
1791  : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, StartLoc, LParenLoc,
1792  EndLoc, NumVars),
1793  ColonLoc(ColonLoc) {}
1794 
1795  /// \brief Build an empty clause.
1796  ///
1797  /// \param NumVars Number of variables.
1798  ///
1799  explicit OMPAlignedClause(unsigned NumVars)
1800  : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, SourceLocation(),
1801  SourceLocation(), SourceLocation(),
1802  NumVars),
1803  ColonLoc(SourceLocation()) {}
1804 
1805 public:
1806  /// \brief Creates clause with a list of variables \a VL and alignment \a A.
1807  ///
1808  /// \param C AST Context.
1809  /// \param StartLoc Starting location of the clause.
1810  /// \param LParenLoc Location of '('.
1811  /// \param ColonLoc Location of ':'.
1812  /// \param EndLoc Ending location of the clause.
1813  /// \param VL List of references to the variables.
1814  /// \param A Alignment.
1815  static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
1816  SourceLocation LParenLoc,
1817  SourceLocation ColonLoc,
1818  SourceLocation EndLoc, ArrayRef<Expr *> VL,
1819  Expr *A);
1820 
1821  /// \brief Creates an empty clause with the place for \a NumVars variables.
1822  ///
1823  /// \param C AST context.
1824  /// \param NumVars Number of variables.
1825  ///
1826  static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
1827 
1828  /// \brief Sets the location of ':'.
1829  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
1830  /// \brief Returns the location of ':'.
1831  SourceLocation getColonLoc() const { return ColonLoc; }
1832 
1833  /// \brief Returns alignment.
1834  Expr *getAlignment() { return *varlist_end(); }
1835  /// \brief Returns alignment.
1836  const Expr *getAlignment() const { return *varlist_end(); }
1837 
1838  StmtRange children() {
1839  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1840  reinterpret_cast<Stmt **>(varlist_end()));
1841  }
1842 
1843  static bool classof(const OMPClause *T) {
1844  return T->getClauseKind() == OMPC_aligned;
1845  }
1846 };
1847 
1848 /// \brief This represents clause 'copyin' in the '#pragma omp ...' directives.
1849 ///
1850 /// \code
1851 /// #pragma omp parallel copyin(a,b)
1852 /// \endcode
1853 /// In this example directive '#pragma omp parallel' has clause 'copyin'
1854 /// with the variables 'a' and 'b'.
1855 ///
1856 class OMPCopyinClause : public OMPVarListClause<OMPCopyinClause> {
1857  // Class has 3 additional tail allocated arrays:
1858  // 1. List of helper expressions for proper generation of assignment operation
1859  // required for copyin clause. This list represents sources.
1860  // 2. List of helper expressions for proper generation of assignment operation
1861  // required for copyin clause. This list represents destinations.
1862  // 3. List of helper expressions that represents assignment operation:
1863  // \code
1864  // DstExprs = SrcExprs;
1865  // \endcode
1866  // Required for proper codegen of propagation of master's thread values of
1867  // threadprivate variables to local instances of that variables in other
1868  // implicit threads.
1869 
1870  friend class OMPClauseReader;
1871  /// \brief Build clause with number of variables \a N.
1872  ///
1873  /// \param StartLoc Starting location of the clause.
1874  /// \param LParenLoc Location of '('.
1875  /// \param EndLoc Ending location of the clause.
1876  /// \param N Number of the variables in the clause.
1877  ///
1878  OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1879  SourceLocation EndLoc, unsigned N)
1880  : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, StartLoc, LParenLoc,
1881  EndLoc, N) {}
1882 
1883  /// \brief Build an empty clause.
1884  ///
1885  /// \param N Number of variables.
1886  ///
1887  explicit OMPCopyinClause(unsigned N)
1888  : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, SourceLocation(),
1889  SourceLocation(), SourceLocation(),
1890  N) {}
1891 
1892  /// \brief Set list of helper expressions, required for proper codegen of the
1893  /// clause. These expressions represent source expression in the final
1894  /// assignment statement performed by the copyin clause.
1895  void setSourceExprs(ArrayRef<Expr *> SrcExprs);
1896 
1897  /// \brief Get the list of helper source expressions.
1898  MutableArrayRef<Expr *> getSourceExprs() {
1899  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1900  }
1901  ArrayRef<const Expr *> getSourceExprs() const {
1902  return llvm::makeArrayRef(varlist_end(), varlist_size());
1903  }
1904 
1905  /// \brief Set list of helper expressions, required for proper codegen of the
1906  /// clause. These expressions represent destination expression in the final
1907  /// assignment statement performed by the copyin clause.
1908  void setDestinationExprs(ArrayRef<Expr *> DstExprs);
1909 
1910  /// \brief Get the list of helper destination expressions.
1911  MutableArrayRef<Expr *> getDestinationExprs() {
1912  return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
1913  }
1914  ArrayRef<const Expr *> getDestinationExprs() const {
1915  return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
1916  }
1917 
1918  /// \brief Set list of helper assignment expressions, required for proper
1919  /// codegen of the clause. These expressions are assignment expressions that
1920  /// assign source helper expressions to destination helper expressions
1921  /// correspondingly.
1922  void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
1923 
1924  /// \brief Get the list of helper assignment expressions.
1925  MutableArrayRef<Expr *> getAssignmentOps() {
1926  return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
1927  }
1928  ArrayRef<const Expr *> getAssignmentOps() const {
1929  return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
1930  }
1931 
1932 public:
1933  /// \brief Creates clause with a list of variables \a VL.
1934  ///
1935  /// \param C AST context.
1936  /// \param StartLoc Starting location of the clause.
1937  /// \param LParenLoc Location of '('.
1938  /// \param EndLoc Ending location of the clause.
1939  /// \param VL List of references to the variables.
1940  /// \param SrcExprs List of helper expressions for proper generation of
1941  /// assignment operation required for copyin clause. This list represents
1942  /// sources.
1943  /// \param DstExprs List of helper expressions for proper generation of
1944  /// assignment operation required for copyin clause. This list represents
1945  /// destinations.
1946  /// \param AssignmentOps List of helper expressions that represents assignment
1947  /// operation:
1948  /// \code
1949  /// DstExprs = SrcExprs;
1950  /// \endcode
1951  /// Required for proper codegen of propagation of master's thread values of
1952  /// threadprivate variables to local instances of that variables in other
1953  /// implicit threads.
1954  ///
1955  static OMPCopyinClause *
1956  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1957  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
1958  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
1959  /// \brief Creates an empty clause with \a N variables.
1960  ///
1961  /// \param C AST context.
1962  /// \param N The number of variables.
1963  ///
1964  static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
1965 
1966  typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
1967  typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
1968  typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
1969  typedef llvm::iterator_range<helper_expr_const_iterator>
1971 
1973  return helper_expr_const_range(getSourceExprs().begin(),
1974  getSourceExprs().end());
1975  }
1977  return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
1978  }
1980  return helper_expr_const_range(getDestinationExprs().begin(),
1981  getDestinationExprs().end());
1982  }
1984  return helper_expr_range(getDestinationExprs().begin(),
1985  getDestinationExprs().end());
1986  }
1988  return helper_expr_const_range(getAssignmentOps().begin(),
1989  getAssignmentOps().end());
1990  }
1992  return helper_expr_range(getAssignmentOps().begin(),
1993  getAssignmentOps().end());
1994  }
1995 
1996  StmtRange children() {
1997  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1998  reinterpret_cast<Stmt **>(varlist_end()));
1999  }
2000 
2001  static bool classof(const OMPClause *T) {
2002  return T->getClauseKind() == OMPC_copyin;
2003  }
2004 };
2005 
2006 /// \brief This represents clause 'copyprivate' in the '#pragma omp ...'
2007 /// directives.
2008 ///
2009 /// \code
2010 /// #pragma omp single copyprivate(a,b)
2011 /// \endcode
2012 /// In this example directive '#pragma omp single' has clause 'copyprivate'
2013 /// with the variables 'a' and 'b'.
2014 ///
2015 class OMPCopyprivateClause : public OMPVarListClause<OMPCopyprivateClause> {
2016  friend class OMPClauseReader;
2017  /// \brief Build clause with number of variables \a N.
2018  ///
2019  /// \param StartLoc Starting location of the clause.
2020  /// \param LParenLoc Location of '('.
2021  /// \param EndLoc Ending location of the clause.
2022  /// \param N Number of the variables in the clause.
2023  ///
2024  OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2025  SourceLocation EndLoc, unsigned N)
2026  : OMPVarListClause<OMPCopyprivateClause>(OMPC_copyprivate, StartLoc,
2027  LParenLoc, EndLoc, N) {}
2028 
2029  /// \brief Build an empty clause.
2030  ///
2031  /// \param N Number of variables.
2032  ///
2033  explicit OMPCopyprivateClause(unsigned N)
2035  OMPC_copyprivate, SourceLocation(), SourceLocation(),
2036  SourceLocation(), N) {}
2037 
2038  /// \brief Set list of helper expressions, required for proper codegen of the
2039  /// clause. These expressions represent source expression in the final
2040  /// assignment statement performed by the copyprivate clause.
2041  void setSourceExprs(ArrayRef<Expr *> SrcExprs);
2042 
2043  /// \brief Get the list of helper source expressions.
2044  MutableArrayRef<Expr *> getSourceExprs() {
2045  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2046  }
2047  ArrayRef<const Expr *> getSourceExprs() const {
2048  return llvm::makeArrayRef(varlist_end(), varlist_size());
2049  }
2050 
2051  /// \brief Set list of helper expressions, required for proper codegen of the
2052  /// clause. These expressions represent destination expression in the final
2053  /// assignment statement performed by the copyprivate clause.
2054  void setDestinationExprs(ArrayRef<Expr *> DstExprs);
2055 
2056  /// \brief Get the list of helper destination expressions.
2057  MutableArrayRef<Expr *> getDestinationExprs() {
2058  return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
2059  }
2060  ArrayRef<const Expr *> getDestinationExprs() const {
2061  return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
2062  }
2063 
2064  /// \brief Set list of helper assignment expressions, required for proper
2065  /// codegen of the clause. These expressions are assignment expressions that
2066  /// assign source helper expressions to destination helper expressions
2067  /// correspondingly.
2068  void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
2069 
2070  /// \brief Get the list of helper assignment expressions.
2071  MutableArrayRef<Expr *> getAssignmentOps() {
2072  return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
2073  }
2074  ArrayRef<const Expr *> getAssignmentOps() const {
2075  return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
2076  }
2077 
2078 public:
2079  /// \brief Creates clause with a list of variables \a VL.
2080  ///
2081  /// \param C AST context.
2082  /// \param StartLoc Starting location of the clause.
2083  /// \param LParenLoc Location of '('.
2084  /// \param EndLoc Ending location of the clause.
2085  /// \param VL List of references to the variables.
2086  /// \param SrcExprs List of helper expressions for proper generation of
2087  /// assignment operation required for copyprivate clause. This list represents
2088  /// sources.
2089  /// \param DstExprs List of helper expressions for proper generation of
2090  /// assignment operation required for copyprivate clause. This list represents
2091  /// destinations.
2092  /// \param AssignmentOps List of helper expressions that represents assignment
2093  /// operation:
2094  /// \code
2095  /// DstExprs = SrcExprs;
2096  /// \endcode
2097  /// Required for proper codegen of final assignment performed by the
2098  /// copyprivate clause.
2099  ///
2100  static OMPCopyprivateClause *
2101  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2102  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
2103  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
2104  /// \brief Creates an empty clause with \a N variables.
2105  ///
2106  /// \param C AST context.
2107  /// \param N The number of variables.
2108  ///
2109  static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
2110 
2111  typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
2112  typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
2113  typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
2114  typedef llvm::iterator_range<helper_expr_const_iterator>
2116 
2118  return helper_expr_const_range(getSourceExprs().begin(),
2119  getSourceExprs().end());
2120  }
2122  return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
2123  }
2125  return helper_expr_const_range(getDestinationExprs().begin(),
2126  getDestinationExprs().end());
2127  }
2129  return helper_expr_range(getDestinationExprs().begin(),
2130  getDestinationExprs().end());
2131  }
2133  return helper_expr_const_range(getAssignmentOps().begin(),
2134  getAssignmentOps().end());
2135  }
2137  return helper_expr_range(getAssignmentOps().begin(),
2138  getAssignmentOps().end());
2139  }
2140 
2141  StmtRange children() {
2142  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
2143  reinterpret_cast<Stmt **>(varlist_end()));
2144  }
2145 
2146  static bool classof(const OMPClause *T) {
2147  return T->getClauseKind() == OMPC_copyprivate;
2148  }
2149 };
2150 
2151 /// \brief This represents implicit clause 'flush' for the '#pragma omp flush'
2152 /// directive.
2153 /// This clause does not exist by itself, it can be only as a part of 'omp
2154 /// flush' directive. This clause is introduced to keep the original structure
2155 /// of \a OMPExecutableDirective class and its derivatives and to use the
2156 /// existing infrastructure of clauses with the list of variables.
2157 ///
2158 /// \code
2159 /// #pragma omp flush(a,b)
2160 /// \endcode
2161 /// In this example directive '#pragma omp flush' has implicit clause 'flush'
2162 /// with the variables 'a' and 'b'.
2163 ///
2164 class OMPFlushClause : public OMPVarListClause<OMPFlushClause> {
2165  /// \brief Build clause with number of variables \a N.
2166  ///
2167  /// \param StartLoc Starting location of the clause.
2168  /// \param LParenLoc Location of '('.
2169  /// \param EndLoc Ending location of the clause.
2170  /// \param N Number of the variables in the clause.
2171  ///
2172  OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2173  SourceLocation EndLoc, unsigned N)
2174  : OMPVarListClause<OMPFlushClause>(OMPC_flush, StartLoc, LParenLoc,
2175  EndLoc, N) {}
2176 
2177  /// \brief Build an empty clause.
2178  ///
2179  /// \param N Number of variables.
2180  ///
2181  explicit OMPFlushClause(unsigned N)
2182  : OMPVarListClause<OMPFlushClause>(OMPC_flush, SourceLocation(),
2183  SourceLocation(), SourceLocation(),
2184  N) {}
2185 
2186 public:
2187  /// \brief Creates clause with a list of variables \a VL.
2188  ///
2189  /// \param C AST context.
2190  /// \param StartLoc Starting location of the clause.
2191  /// \param LParenLoc Location of '('.
2192  /// \param EndLoc Ending location of the clause.
2193  /// \param VL List of references to the variables.
2194  ///
2195  static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
2196  SourceLocation LParenLoc, SourceLocation EndLoc,
2197  ArrayRef<Expr *> VL);
2198  /// \brief Creates an empty clause with \a N variables.
2199  ///
2200  /// \param C AST context.
2201  /// \param N The number of variables.
2202  ///
2203  static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
2204 
2205  StmtRange children() {
2206  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
2207  reinterpret_cast<Stmt **>(varlist_end()));
2208  }
2209 
2210  static bool classof(const OMPClause *T) {
2211  return T->getClauseKind() == OMPC_flush;
2212  }
2213 };
2214 
2215 /// \brief This represents implicit clause 'depend' for the '#pragma omp task'
2216 /// directive.
2217 ///
2218 /// \code
2219 /// #pragma omp task depend(in:a,b)
2220 /// \endcode
2221 /// In this example directive '#pragma omp task' with clause 'depend' with the
2222 /// variables 'a' and 'b' with dependency 'in'.
2223 ///
2224 class OMPDependClause : public OMPVarListClause<OMPDependClause> {
2225  friend class OMPClauseReader;
2226  /// \brief Dependency type (one of in, out, inout).
2227  OpenMPDependClauseKind DepKind;
2228  /// \brief Dependency type location.
2229  SourceLocation DepLoc;
2230  /// \brief Colon location.
2231  SourceLocation ColonLoc;
2232  /// \brief Build clause with number of variables \a N.
2233  ///
2234  /// \param StartLoc Starting location of the clause.
2235  /// \param LParenLoc Location of '('.
2236  /// \param EndLoc Ending location of the clause.
2237  /// \param N Number of the variables in the clause.
2238  ///
2239  OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2240  SourceLocation EndLoc, unsigned N)
2241  : OMPVarListClause<OMPDependClause>(OMPC_depend, StartLoc, LParenLoc,
2242  EndLoc, N),
2243  DepKind(OMPC_DEPEND_unknown) {}
2244 
2245  /// \brief Build an empty clause.
2246  ///
2247  /// \param N Number of variables.
2248  ///
2249  explicit OMPDependClause(unsigned N)
2250  : OMPVarListClause<OMPDependClause>(OMPC_depend, SourceLocation(),
2251  SourceLocation(), SourceLocation(),
2252  N),
2253  DepKind(OMPC_DEPEND_unknown) {}
2254  /// \brief Set dependency kind.
2255  void setDependencyKind(OpenMPDependClauseKind K) { DepKind = K; }
2256 
2257  /// \brief Set dependency kind and its location.
2258  void setDependencyLoc(SourceLocation Loc) { DepLoc = Loc; }
2259 
2260  /// \brief Set colon location.
2261  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2262 
2263 public:
2264  /// \brief Creates clause with a list of variables \a VL.
2265  ///
2266  /// \param C AST context.
2267  /// \param StartLoc Starting location of the clause.
2268  /// \param LParenLoc Location of '('.
2269  /// \param EndLoc Ending location of the clause.
2270  /// \param DepKind Dependency type.
2271  /// \param DepLoc Location of the dependency type.
2272  /// \param ColonLoc Colon location.
2273  /// \param VL List of references to the variables.
2274  ///
2275  static OMPDependClause *
2276  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2277  SourceLocation EndLoc, OpenMPDependClauseKind DepKind,
2278  SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL);
2279  /// \brief Creates an empty clause with \a N variables.
2280  ///
2281  /// \param C AST context.
2282  /// \param N The number of variables.
2283  ///
2284  static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N);
2285 
2286  /// \brief Get dependency type.
2287  OpenMPDependClauseKind getDependencyKind() const { return DepKind; }
2288  /// \brief Get dependency type location.
2289  SourceLocation getDependencyLoc() const { return DepLoc; }
2290  /// \brief Get colon location.
2291  SourceLocation getColonLoc() const { return ColonLoc; }
2292 
2293  StmtRange children() {
2294  return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
2295  reinterpret_cast<Stmt **>(varlist_end()));
2296  }
2297 
2298  static bool classof(const OMPClause *T) {
2299  return T->getClauseKind() == OMPC_depend;
2300  }
2301 };
2302 
2303 } // end namespace clang
2304 
2305 #endif
2306 
static OMPPrivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1193
OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'capture' clause.
Definition: OpenMPClause.h:903
private_copies_const_range private_copies() const
varlist_const_range varlists() const
Definition: OpenMPClause.h:122
helper_expr_range source_exprs()
OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'untied' clause.
Definition: OpenMPClause.h:756
llvm::iterator_range< private_copies_iterator > private_copies_range
OMPSeqCstClause()
Build an empty clause.
Definition: OpenMPClause.h:938
StmtRange children()
This represents clause 'copyin' in the '#pragma omp ...' directives.
helper_expr_range source_exprs()
SourceLocation getColonLoc() const
Get colon location.
helper_expr_const_range source_exprs() const
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:941
MutableArrayRef< Expr * >::iterator inits_iterator
SourceLocation getCommaLoc()
Get location of ','.
Definition: OpenMPClause.h:655
private_copies_range private_copies()
StmtRange children()
OMPIfClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'if' clause with condition Cond.
Definition: OpenMPClause.h:173
OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'update' clause.
Definition: OpenMPClause.h:873
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:543
OpenMPProcBindClauseKind getProcBindKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:546
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: Stmt.cpp:1243
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:764
This represents 'if' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:154
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:541
inits_range inits()
SourceLocation getColonLoc() const
Returns the location of ':'.
This represents 'update' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:866
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:404
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:134
ArrayRef< const Expr * > getVarRefs() const
Fetches list of all variables in the clause.
Definition: OpenMPClause.h:137
StmtRange children()
Expr * getAlignment()
Returns alignment.
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: Stmt.cpp:1561
Expr * getHelperChunkSize() const
Get helper chunk size.
Definition: OpenMPClause.h:671
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:551
This represents 'read' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:808
OMPFinalClause()
Build an empty clause.
Definition: OpenMPClause.h:233
finals_range finals()
helper_expr_range source_exprs()
This represents clause 'private' in the '#pragma omp ...' directives.
Definition: OpenMPClause.h:956
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:355
static bool classof(const OMPClause *T)
ArrayRef< const Expr * >::iterator private_copies_const_iterator
This represents 'num_threads' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:261
varlist_range varlists()
Definition: OpenMPClause.h:119
bool varlist_empty() const
Definition: OpenMPClause.h:117
This represents implicit clause 'flush' for the '#pragma omp flush' directive. This clause does not e...
llvm::iterator_range< private_copies_iterator > private_copies_range
This represents 'safelen' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:319
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:245
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:240
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:297
This represents clauses with the list of variables like 'private', 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the '#pragma omp ...' directives.
Definition: OpenMPClause.h:70
OMPProcBindClause()
Build an empty clause.
Definition: OpenMPClause.h:535
CalcStep
Definition: OpenMPClause.h:304
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1303
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
ArrayRef< const Expr * >::iterator updates_const_iterator
static OMPFirstprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL, ArrayRef< Expr * > InitVL)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1228
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:89
A C++ nested-name-specifier augmented with source location information.
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
ArrayRef< const Expr * >::iterator finals_const_iterator
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:480
helper_expr_range assignment_ops()
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
void setUpdates(ArrayRef< Expr * > UL)
Sets the list of update expressions for linear variables.
SourceLocation getLocStart() const
Returns the starting location of the clause.
Definition: OpenMPClause.h:46
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
OMPVarListClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
Build a clause with N variables.
Definition: OpenMPClause.h:106
varlist_iterator varlist_begin()
Definition: OpenMPClause.h:126
void setColonLoc(SourceLocation Loc)
Sets the location of ':'.
ArrayRef< const Expr * >::iterator private_copies_const_iterator
private_copies_const_range private_copies() const
Defines some OpenMP-specific enums and functions.
llvm::iterator_range< varlist_const_iterator > varlist_const_range
Definition: OpenMPClause.h:114
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
llvm::iterator_range< updates_iterator > updates_range
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
StmtRange children()
OMPSafelenClause()
Build an empty clause.
Definition: OpenMPClause.h:343
llvm::iterator_range< varlist_iterator > varlist_range
Definition: OpenMPClause.h:113
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
helper_expr_range destination_exprs()
helper_expr_const_range private_copies() const
void setFinals(ArrayRef< Expr * > FL)
Sets the list of final update expressions for linear variables.
StmtRange children()
Definition: OpenMPClause.h:826
helper_expr_const_range source_exprs() const
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
Definition: OpenMPClause.h:646
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:470
Expr * getChunkSize() const
Get chunk size.
Definition: OpenMPClause.h:661
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep)
Creates clause with a list of variables VL and a linear step Step.
void setCalcStep(Expr *CalcStep)
Sets the expression to calculate linear step for clause.
Definition: OpenMPClause.h:266
This represents 'default' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:426
OMPProcBindClause(OpenMPProcBindClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'proc_bind' clause with argument A ('master', 'close' or 'spread').
Definition: OpenMPClause.h:527
OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'write' clause.
Definition: OpenMPClause.h:843
static OMPReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1543
This represents 'final' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:207
This represents 'mergeable' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:779
MutableArrayRef< Expr * > getFinals()
Sets the list of final update expressions for linear variables.
llvm::iterator_range< helper_expr_iterator > helper_expr_range
This represents clause 'reduction' in the '#pragma omp ...' directives.
void setColonLoc(SourceLocation Loc)
Sets the location of ':'.
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:299
updates_range updates()
bool isInvalid() const
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:794
llvm::iterator_range< finals_const_iterator > finals_const_range
OMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'seq_cst' clause.
Definition: OpenMPClause.h:933
OMPScheduleClause()
Build an empty clause.
Definition: OpenMPClause.h:637
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:475
StmtRange children()
Definition: OpenMPClause.h:196
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:56
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
OMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'collapse' clause.
Definition: OpenMPClause.h:392
SourceLocation getLocEnd() const
Returns the ending location of the clause.
Definition: OpenMPClause.h:48
static bool classof(const OMPClause *)
Definition: OpenMPClause.h:64
llvm::iterator_range< inits_const_iterator > inits_const_range
friend class OMPClauseReader
Definition: OpenMPClause.h:258
helper_expr_range assignment_ops()
SourceLocation getDefaultKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:478
OMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'nowait' clause.
Definition: OpenMPClause.h:727
This represents clause 'aligned' in the '#pragma omp ...' directives.
static bool classof(const OMPClause *T)
void setLocEnd(SourceLocation Loc)
Sets the ending location of the clause.
Definition: OpenMPClause.h:53
OMPWriteClause()
Build an empty clause.
Definition: OpenMPClause.h:848
MutableArrayRef< Expr * >::iterator varlist_iterator
Definition: OpenMPClause.h:111
OMPCaptureClause()
Build an empty clause.
Definition: OpenMPClause.h:908
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:735
OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'safelen' clause.
Definition: OpenMPClause.h:336
varlist_const_iterator varlist_end() const
Definition: OpenMPClause.h:129
helper_expr_range assignment_ops()
bool isImplicit() const
Definition: OpenMPClause.h:58
This represents implicit clause 'depend' for the '#pragma omp task' directive.
Expr * getStep()
Returns linear step.
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:496
This represents 'capture' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:896
llvm::iterator_range< inits_iterator > inits_range
helper_expr_const_range assignment_ops() const
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
SourceLocation getScheduleKindLoc()
Get kind location.
Definition: OpenMPClause.h:652
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:243
MutableArrayRef< Expr * > getVarRefs()
Fetches list of variables associated with this clause.
Definition: OpenMPClause.h:79
const Expr * getAlignment() const
Returns alignment.
void setInits(ArrayRef< Expr * > IL)
Sets the list of the initial values for linear variables.
OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KLoc, SourceLocation CommaLoc, SourceLocation EndLoc, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, Expr *HelperChunkSize)
Build 'schedule' clause with schedule kind Kind and chunk size expression ChunkSize.
Definition: OpenMPClause.h:625
OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:33
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:132
MutableArrayRef< Expr * >::iterator private_copies_iterator
static bool classof(const OMPClause *T)
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:238
This represents 'ordered' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:691
Expr * getCalcStep()
Returns expression to calculate linear step.
OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, unsigned NumVars)
Build 'linear' clause with given number of variables NumVars.
Definition: OpenMPClause.h:276
ArrayRef< const Expr * >::iterator varlist_const_iterator
Definition: OpenMPClause.h:112
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:187
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
static bool classof(const OMPClause *T)
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:706
void setPrivateCopies(ArrayRef< Expr * > PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
Definition: Stmt.cpp:1251
inits_const_range inits() const
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: Stmt.cpp:1207
This represents 'collapse' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:374
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
llvm::iterator_range< helper_expr_iterator > helper_expr_range
MutableArrayRef< Expr * >::iterator helper_expr_iterator
SourceLocation getProcBindKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:549
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
OpenMPProcBindClauseKind
OpenMP attributes for 'proc_bind' clause.
Definition: OpenMPKinds.h:50
llvm::iterator_range< inits_const_iterator > inits_const_range
helper_expr_range destination_exprs()
helper_expr_const_range destination_exprs() const
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:926
This represents 'untied' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:749
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:294
helper_expr_range lhs_exprs()
static bool classof(const OMPClause *T)
ArrayRef< const Expr * >::iterator inits_const_iterator
OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'mergeable' clause.
Definition: OpenMPClause.h:786
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:411
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc()
Get location of '('.
Definition: OpenMPClause.h:649
helper_expr_range destination_exprs()
OMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'num_threads' clause with condition NumThreads.
Definition: OpenMPClause.h:280
Kind
helper_expr_range private_copies()
ArrayRef< const Expr * >::iterator inits_const_iterator
OMPCollapseClause()
Build an empty clause.
Definition: OpenMPClause.h:399
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:881
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:409
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition: OpenMPKinds.h:66
helper_expr_const_range reduction_ops() const
clang::OMPLinearClause OMPVarListClause getInits()
helper_expr_range rhs_exprs()
private_copies_range private_copies()
void setVarRefs(ArrayRef< Expr * > VL)
Sets the list of variables for this clause.
Definition: OpenMPClause.h:88
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:190
helper_expr_const_range lhs_exprs() const
This represents 'schedule' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:566
OMPMergeableClause()
Build an empty clause.
Definition: OpenMPClause.h:791
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:292
This represents clause 'shared' in the '#pragma omp ...' directives.
varlist_const_iterator varlist_begin() const
Definition: OpenMPClause.h:128
MutableArrayRef< Expr * >::iterator helper_expr_iterator
static bool classof(const OMPClause *T)
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:32
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
SourceLocation getDependencyLoc() const
Get dependency type location.
helper_expr_range reduction_ops()
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:822
llvm::iterator_range< helper_expr_iterator > helper_expr_range
helper_expr_const_range rhs_exprs() const
static bool classof(const OMPClause *T)
* Step
Definition: OpenMPClause.h:304
OMPNumThreadsClause()
Build an empty clause.
Definition: OpenMPClause.h:287
This represents clause 'linear' in the '#pragma omp ...' directives.
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:675
ConstStmtRange children() const
Definition: OpenMPClause.h:61
SourceLocation getColonLoc() const
Returns the location of '('.
static bool classof(const OMPClause *T)
void setLocStart(SourceLocation Loc)
Sets the starting location of the clause.
Definition: OpenMPClause.h:51
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: Stmt.cpp:1317
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:851
llvm::iterator_range< inits_iterator > inits_range
llvm::iterator_range< helper_expr_iterator > helper_expr_range
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:353
void setStep(Expr *Step)
Sets the linear step for clause.
Definition: OpenMPClause.h:263
OMPDefaultClause(OpenMPDefaultClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'default' clause with argument A ('none' or 'shared').
Definition: OpenMPClause.h:456
MutableArrayRef< Expr * >::iterator helper_expr_iterator
OMPReadClause()
Build an empty clause.
Definition: OpenMPClause.h:820
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:472
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:406
OMPUntiedClause()
Build an empty clause.
Definition: OpenMPClause.h:761
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition: OpenMPKinds.h:58
OMPFinalClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'final' clause with condition Cond.
Definition: OpenMPClause.h:226
OpenMPDefaultClauseKind
OpenMP attributes for 'default' clause.
Definition: OpenMPKinds.h:42
StmtRange children()
Definition: Stmt.cpp:1176
OMPNowaitClause()
Build an empty clause.
Definition: OpenMPClause.h:732
MutableArrayRef< Expr * >::iterator helper_expr_iterator
This represents 'write' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:836
MutableArrayRef< Expr * >::iterator inits_iterator
MutableArrayRef< Expr * >::iterator private_copies_iterator
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:350
helper_expr_const_range destination_exprs() const
Defines the clang::SourceLocation class and associated facilities.
This represents 'nowait' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:720
varlist_iterator varlist_end()
Definition: OpenMPClause.h:127
MutableArrayRef< Expr * >::iterator finals_iterator
MutableArrayRef< Expr * >::iterator updates_iterator
OMPClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation EndLoc)
Definition: OpenMPClause.h:41
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
helper_expr_const_range assignment_ops() const
OMPIfClause()
Build an empty clause.
Definition: OpenMPClause.h:180
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:348
OMPUpdateClause()
Build an empty clause.
Definition: OpenMPClause.h:878
Expr * getHelperChunkSize()
Get helper chunk size.
Definition: OpenMPClause.h:666
llvm::iterator_range< updates_const_iterator > updates_const_range
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:911
Expr * getChunkSize()
Get chunk size.
Definition: OpenMPClause.h:658
llvm::iterator_range< finals_iterator > finals_range
OMPReadClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'read' clause.
Definition: OpenMPClause.h:815
helper_expr_const_range destination_exprs() const
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: Stmt.cpp:1295
SourceLocation ColonLoc
Location of ':'.
Definition: OpenMPClause.h:260
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:185
unsigned varlist_size() const
Definition: OpenMPClause.h:116
OMPOrderedClause()
Build an empty clause.
Definition: OpenMPClause.h:703
OMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'ordered' clause.
Definition: OpenMPClause.h:698
OMPDefaultClause()
Build an empty clause.
Definition: OpenMPClause.h:464
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:192
helper_expr_const_range assignment_ops() const
helper_expr_const_range source_exprs() const
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1279