clang  5.0.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 #include "llvm/ADT/MapVector.h"
24 
25 namespace clang {
26 
27 //===----------------------------------------------------------------------===//
28 // AST classes for clauses.
29 //===----------------------------------------------------------------------===//
30 
31 /// \brief This is a basic class for representing single OpenMP clause.
32 ///
33 class OMPClause {
34  /// \brief Starting location of the clause (the clause keyword).
35  SourceLocation StartLoc;
36  /// \brief Ending location of the clause.
37  SourceLocation EndLoc;
38  /// \brief Kind of the clause.
40 
41 protected:
43  : StartLoc(StartLoc), EndLoc(EndLoc), Kind(K) {}
44 
45 public:
46  /// \brief Returns the starting location of the clause.
47  SourceLocation getLocStart() const { return StartLoc; }
48  /// \brief Returns the ending location of the clause.
49  SourceLocation getLocEnd() const { return EndLoc; }
50 
51  /// \brief Sets the starting location of the clause.
52  void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
53  /// \brief Sets the ending location of the clause.
54  void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
55 
56  /// \brief Returns kind of OpenMP clause (private, shared, reduction, etc.).
57  OpenMPClauseKind getClauseKind() const { return Kind; }
58 
59  bool isImplicit() const { return StartLoc.isInvalid(); }
60 
63  typedef llvm::iterator_range<child_iterator> child_range;
64  typedef llvm::iterator_range<const_child_iterator> const_child_range;
65 
68  auto Children = const_cast<OMPClause *>(this)->children();
69  return const_child_range(Children.begin(), Children.end());
70  }
71  static bool classof(const OMPClause *) { return true; }
72 };
73 
74 /// Class that handles pre-initialization statement for some clauses, like
75 /// 'shedule', 'firstprivate' etc.
77  friend class OMPClauseReader;
78  /// Pre-initialization statement for the clause.
79  Stmt *PreInit;
80  /// Region that captures the associated stmt.
81  OpenMPDirectiveKind CaptureRegion;
82 
83 protected:
84  /// Set pre-initialization statement for the clause.
86  PreInit = S;
87  CaptureRegion = ThisRegion;
88  }
90  : PreInit(nullptr), CaptureRegion(OMPD_unknown) {
91  assert(get(This) && "get is not tuned for pre-init.");
92  }
93 
94 public:
95  /// Get pre-initialization statement for the clause.
96  const Stmt *getPreInitStmt() const { return PreInit; }
97  /// Get pre-initialization statement for the clause.
98  Stmt *getPreInitStmt() { return PreInit; }
99  /// Get capture region for the stmt in the clause.
100  OpenMPDirectiveKind getCaptureRegion() { return CaptureRegion; }
101  static OMPClauseWithPreInit *get(OMPClause *C);
102  static const OMPClauseWithPreInit *get(const OMPClause *C);
103 };
104 
105 /// Class that handles post-update expression for some clauses, like
106 /// 'lastprivate', 'reduction' etc.
108  friend class OMPClauseReader;
109  /// Post-update expression for the clause.
110  Expr *PostUpdate;
111 protected:
112  /// Set pre-initialization statement for the clause.
113  void setPostUpdateExpr(Expr *S) { PostUpdate = S; }
115  : OMPClauseWithPreInit(This), PostUpdate(nullptr) {
116  assert(get(This) && "get is not tuned for post-update.");
117  }
118 
119 public:
120  /// Get post-update expression for the clause.
121  const Expr *getPostUpdateExpr() const { return PostUpdate; }
122  /// Get post-update expression for the clause.
123  Expr *getPostUpdateExpr() { return PostUpdate; }
124  static OMPClauseWithPostUpdate *get(OMPClause *C);
125  static const OMPClauseWithPostUpdate *get(const OMPClause *C);
126 };
127 
128 /// \brief This represents clauses with the list of variables like 'private',
129 /// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
130 /// '#pragma omp ...' directives.
131 template <class T> class OMPVarListClause : public OMPClause {
132  friend class OMPClauseReader;
133  /// \brief Location of '('.
134  SourceLocation LParenLoc;
135  /// \brief Number of variables in the list.
136  unsigned NumVars;
138 protected:
139  /// \brief Fetches list of variables associated with this clause.
142  static_cast<T *>(this)->template getTrailingObjects<Expr *>(), NumVars);
143  }
144 
145  /// \brief Sets the list of variables for this clause.
147  assert(VL.size() == NumVars &&
148  "Number of variables is not the same as the preallocated buffer");
149  std::copy(VL.begin(), VL.end(),
150  static_cast<T *>(this)->template getTrailingObjects<Expr *>());
151  }
152 
153  /// \brief Build a clause with \a N variables
154  ///
155  /// \param K Kind of the clause.
156  /// \param StartLoc Starting location of the clause (the clause keyword).
157  /// \param LParenLoc Location of '('.
158  /// \param EndLoc Ending location of the clause.
159  /// \param N Number of the variables in the clause.
160  ///
162  SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
163  : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {}
164 
165 public:
168  typedef llvm::iterator_range<varlist_iterator> varlist_range;
169  typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
170 
171  unsigned varlist_size() const { return NumVars; }
172  bool varlist_empty() const { return NumVars == 0; }
173 
176  }
179  }
180 
181  varlist_iterator varlist_begin() { return getVarRefs().begin(); }
183  varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
184  varlist_const_iterator varlist_end() const { return getVarRefs().end(); }
185 
186  /// \brief Sets the location of '('.
187  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
188  /// \brief Returns the location of '('.
189  SourceLocation getLParenLoc() const { return LParenLoc; }
190 
191  /// \brief Fetches list of all variables in the clause.
193  return llvm::makeArrayRef(
194  static_cast<const T *>(this)->template getTrailingObjects<Expr *>(),
195  NumVars);
196  }
197 };
198 
199 /// \brief This represents 'if' clause in the '#pragma omp ...' directive.
200 ///
201 /// \code
202 /// #pragma omp parallel if(parallel:a > 5)
203 /// \endcode
204 /// In this example directive '#pragma omp parallel' has simple 'if' clause with
205 /// condition 'a > 5' and directive name modifier 'parallel'.
206 ///
208  friend class OMPClauseReader;
209  /// \brief Location of '('.
210  SourceLocation LParenLoc;
211  /// \brief Condition of the 'if' clause.
212  Stmt *Condition;
213  /// \brief Location of ':' (if any).
215  /// \brief Directive name modifier for the clause.
216  OpenMPDirectiveKind NameModifier;
217  /// \brief Name modifier location.
218  SourceLocation NameModifierLoc;
219 
220  /// \brief Set condition.
221  ///
222  void setCondition(Expr *Cond) { Condition = Cond; }
223  /// \brief Set directive name modifier for the clause.
224  ///
225  void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
226  /// \brief Set location of directive name modifier for the clause.
227  ///
228  void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
229  /// \brief Set location of ':'.
230  ///
231  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
232 
233 public:
234  /// \brief Build 'if' clause with condition \a Cond.
235  ///
236  /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
237  /// \param Cond Condition of the clause.
238  /// \param HelperCond Helper condition for the clause.
239  /// \param CaptureRegion Innermost OpenMP region where expressions in this
240  /// clause must be captured.
241  /// \param StartLoc Starting location of the clause.
242  /// \param LParenLoc Location of '('.
243  /// \param NameModifierLoc Location of directive name modifier.
244  /// \param ColonLoc [OpenMP 4.1] Location of ':'.
245  /// \param EndLoc Ending location of the clause.
246  ///
247  OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond,
248  OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
249  SourceLocation LParenLoc, SourceLocation NameModifierLoc,
251  : OMPClause(OMPC_if, StartLoc, EndLoc), OMPClauseWithPreInit(this),
252  LParenLoc(LParenLoc), Condition(Cond), ColonLoc(ColonLoc),
253  NameModifier(NameModifier), NameModifierLoc(NameModifierLoc) {
254  setPreInitStmt(HelperCond, CaptureRegion);
255  }
256 
257  /// \brief Build an empty clause.
258  ///
260  : OMPClause(OMPC_if, SourceLocation(), SourceLocation()),
261  OMPClauseWithPreInit(this), LParenLoc(), Condition(nullptr), ColonLoc(),
262  NameModifier(OMPD_unknown), NameModifierLoc() {}
263 
264  /// \brief Sets the location of '('.
265  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
266  /// \brief Returns the location of '('.
267  SourceLocation getLParenLoc() const { return LParenLoc; }
268 
269  /// \brief Return the location of ':'.
270  SourceLocation getColonLoc() const { return ColonLoc; }
271 
272  /// \brief Returns condition.
273  Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
274  /// \brief Return directive name modifier associated with the clause.
275  OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
276 
277  /// \brief Return the location of directive name modifier.
278  SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
279 
280  static bool classof(const OMPClause *T) {
281  return T->getClauseKind() == OMPC_if;
282  }
283 
284  child_range children() { return child_range(&Condition, &Condition + 1); }
285 };
286 
287 /// \brief This represents 'final' clause in the '#pragma omp ...' directive.
288 ///
289 /// \code
290 /// #pragma omp task final(a > 5)
291 /// \endcode
292 /// In this example directive '#pragma omp task' has simple 'final'
293 /// clause with condition 'a > 5'.
294 ///
295 class OMPFinalClause : public OMPClause {
296  friend class OMPClauseReader;
297  /// \brief Location of '('.
298  SourceLocation LParenLoc;
299  /// \brief Condition of the 'if' clause.
300  Stmt *Condition;
301 
302  /// \brief Set condition.
303  ///
304  void setCondition(Expr *Cond) { Condition = Cond; }
305 
306 public:
307  /// \brief Build 'final' clause with condition \a Cond.
308  ///
309  /// \param StartLoc Starting location of the clause.
310  /// \param LParenLoc Location of '('.
311  /// \param Cond Condition of the clause.
312  /// \param EndLoc Ending location of the clause.
313  ///
314  OMPFinalClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,
315  SourceLocation EndLoc)
316  : OMPClause(OMPC_final, StartLoc, EndLoc), LParenLoc(LParenLoc),
317  Condition(Cond) {}
318 
319  /// \brief Build an empty clause.
320  ///
322  : OMPClause(OMPC_final, SourceLocation(), SourceLocation()),
323  LParenLoc(SourceLocation()), Condition(nullptr) {}
324 
325  /// \brief Sets the location of '('.
326  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
327  /// \brief Returns the location of '('.
328  SourceLocation getLParenLoc() const { return LParenLoc; }
329 
330  /// \brief Returns condition.
331  Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
332 
333  static bool classof(const OMPClause *T) {
334  return T->getClauseKind() == OMPC_final;
335  }
336 
337  child_range children() { return child_range(&Condition, &Condition + 1); }
338 };
339 
340 /// \brief This represents 'num_threads' clause in the '#pragma omp ...'
341 /// directive.
342 ///
343 /// \code
344 /// #pragma omp parallel num_threads(6)
345 /// \endcode
346 /// In this example directive '#pragma omp parallel' has simple 'num_threads'
347 /// clause with number of threads '6'.
348 ///
350  friend class OMPClauseReader;
351  /// \brief Location of '('.
352  SourceLocation LParenLoc;
353  /// \brief Condition of the 'num_threads' clause.
354  Stmt *NumThreads;
355 
356  /// \brief Set condition.
357  ///
358  void setNumThreads(Expr *NThreads) { NumThreads = NThreads; }
359 
360 public:
361  /// \brief Build 'num_threads' clause with condition \a NumThreads.
362  ///
363  /// \param NumThreads Number of threads for the construct.
364  /// \param HelperNumThreads Helper Number of threads for the construct.
365  /// \param CaptureRegion Innermost OpenMP region where expressions in this
366  /// clause must be captured.
367  /// \param StartLoc Starting location of the clause.
368  /// \param LParenLoc Location of '('.
369  /// \param EndLoc Ending location of the clause.
370  ///
371  OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads,
372  OpenMPDirectiveKind CaptureRegion,
373  SourceLocation StartLoc, SourceLocation LParenLoc,
374  SourceLocation EndLoc)
375  : OMPClause(OMPC_num_threads, StartLoc, EndLoc),
376  OMPClauseWithPreInit(this), LParenLoc(LParenLoc),
377  NumThreads(NumThreads) {
378  setPreInitStmt(HelperNumThreads, CaptureRegion);
379  }
380 
381  /// \brief Build an empty clause.
382  ///
384  : OMPClause(OMPC_num_threads, SourceLocation(), SourceLocation()),
385  OMPClauseWithPreInit(this), LParenLoc(SourceLocation()),
386  NumThreads(nullptr) {}
387 
388  /// \brief Sets the location of '('.
389  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
390  /// \brief Returns the location of '('.
391  SourceLocation getLParenLoc() const { return LParenLoc; }
392 
393  /// \brief Returns number of threads.
394  Expr *getNumThreads() const { return cast_or_null<Expr>(NumThreads); }
395 
396  static bool classof(const OMPClause *T) {
397  return T->getClauseKind() == OMPC_num_threads;
398  }
399 
400  child_range children() { return child_range(&NumThreads, &NumThreads + 1); }
401 };
402 
403 /// \brief This represents 'safelen' clause in the '#pragma omp ...'
404 /// directive.
405 ///
406 /// \code
407 /// #pragma omp simd safelen(4)
408 /// \endcode
409 /// In this example directive '#pragma omp simd' has clause 'safelen'
410 /// with single expression '4'.
411 /// If the safelen clause is used then no two iterations executed
412 /// concurrently with SIMD instructions can have a greater distance
413 /// in the logical iteration space than its value. The parameter of
414 /// the safelen clause must be a constant positive integer expression.
415 ///
416 class OMPSafelenClause : public OMPClause {
417  friend class OMPClauseReader;
418  /// \brief Location of '('.
419  SourceLocation LParenLoc;
420  /// \brief Safe iteration space distance.
421  Stmt *Safelen;
422 
423  /// \brief Set safelen.
424  void setSafelen(Expr *Len) { Safelen = Len; }
425 
426 public:
427  /// \brief Build 'safelen' clause.
428  ///
429  /// \param Len Expression associated with this clause.
430  /// \param StartLoc Starting location of the clause.
431  /// \param EndLoc Ending location of the clause.
432  ///
434  SourceLocation EndLoc)
435  : OMPClause(OMPC_safelen, StartLoc, EndLoc), LParenLoc(LParenLoc),
436  Safelen(Len) {}
437 
438  /// \brief Build an empty clause.
439  ///
440  explicit OMPSafelenClause()
441  : OMPClause(OMPC_safelen, SourceLocation(), SourceLocation()),
442  LParenLoc(SourceLocation()), Safelen(nullptr) {}
443 
444  /// \brief Sets the location of '('.
445  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
446  /// \brief Returns the location of '('.
447  SourceLocation getLParenLoc() const { return LParenLoc; }
448 
449  /// \brief Return safe iteration space distance.
450  Expr *getSafelen() const { return cast_or_null<Expr>(Safelen); }
451 
452  static bool classof(const OMPClause *T) {
453  return T->getClauseKind() == OMPC_safelen;
454  }
455 
456  child_range children() { return child_range(&Safelen, &Safelen + 1); }
457 };
458 
459 /// \brief This represents 'simdlen' clause in the '#pragma omp ...'
460 /// directive.
461 ///
462 /// \code
463 /// #pragma omp simd simdlen(4)
464 /// \endcode
465 /// In this example directive '#pragma omp simd' has clause 'simdlen'
466 /// with single expression '4'.
467 /// If the 'simdlen' clause is used then it specifies the preferred number of
468 /// iterations to be executed concurrently. The parameter of the 'simdlen'
469 /// clause must be a constant positive integer expression.
470 ///
471 class OMPSimdlenClause : public OMPClause {
472  friend class OMPClauseReader;
473  /// \brief Location of '('.
474  SourceLocation LParenLoc;
475  /// \brief Safe iteration space distance.
476  Stmt *Simdlen;
477 
478  /// \brief Set simdlen.
479  void setSimdlen(Expr *Len) { Simdlen = Len; }
480 
481 public:
482  /// \brief Build 'simdlen' clause.
483  ///
484  /// \param Len Expression associated with this clause.
485  /// \param StartLoc Starting location of the clause.
486  /// \param EndLoc Ending location of the clause.
487  ///
489  SourceLocation EndLoc)
490  : OMPClause(OMPC_simdlen, StartLoc, EndLoc), LParenLoc(LParenLoc),
491  Simdlen(Len) {}
492 
493  /// \brief Build an empty clause.
494  ///
495  explicit OMPSimdlenClause()
496  : OMPClause(OMPC_simdlen, SourceLocation(), SourceLocation()),
497  LParenLoc(SourceLocation()), Simdlen(nullptr) {}
498 
499  /// \brief Sets the location of '('.
500  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
501  /// \brief Returns the location of '('.
502  SourceLocation getLParenLoc() const { return LParenLoc; }
503 
504  /// \brief Return safe iteration space distance.
505  Expr *getSimdlen() const { return cast_or_null<Expr>(Simdlen); }
506 
507  static bool classof(const OMPClause *T) {
508  return T->getClauseKind() == OMPC_simdlen;
509  }
510 
511  child_range children() { return child_range(&Simdlen, &Simdlen + 1); }
512 };
513 
514 /// \brief This represents 'collapse' clause in the '#pragma omp ...'
515 /// directive.
516 ///
517 /// \code
518 /// #pragma omp simd collapse(3)
519 /// \endcode
520 /// In this example directive '#pragma omp simd' has clause 'collapse'
521 /// with single expression '3'.
522 /// The parameter must be a constant positive integer expression, it specifies
523 /// the number of nested loops that should be collapsed into a single iteration
524 /// space.
525 ///
526 class OMPCollapseClause : public OMPClause {
527  friend class OMPClauseReader;
528  /// \brief Location of '('.
529  SourceLocation LParenLoc;
530  /// \brief Number of for-loops.
531  Stmt *NumForLoops;
532 
533  /// \brief Set the number of associated for-loops.
534  void setNumForLoops(Expr *Num) { NumForLoops = Num; }
535 
536 public:
537  /// \brief Build 'collapse' clause.
538  ///
539  /// \param Num Expression associated with this clause.
540  /// \param StartLoc Starting location of the clause.
541  /// \param LParenLoc Location of '('.
542  /// \param EndLoc Ending location of the clause.
543  ///
545  SourceLocation LParenLoc, SourceLocation EndLoc)
546  : OMPClause(OMPC_collapse, StartLoc, EndLoc), LParenLoc(LParenLoc),
547  NumForLoops(Num) {}
548 
549  /// \brief Build an empty clause.
550  ///
551  explicit OMPCollapseClause()
552  : OMPClause(OMPC_collapse, SourceLocation(), SourceLocation()),
553  LParenLoc(SourceLocation()), NumForLoops(nullptr) {}
554 
555  /// \brief Sets the location of '('.
556  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
557  /// \brief Returns the location of '('.
558  SourceLocation getLParenLoc() const { return LParenLoc; }
559 
560  /// \brief Return the number of associated for-loops.
561  Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
562 
563  static bool classof(const OMPClause *T) {
564  return T->getClauseKind() == OMPC_collapse;
565  }
566 
567  child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
568 };
569 
570 /// \brief This represents 'default' clause in the '#pragma omp ...' directive.
571 ///
572 /// \code
573 /// #pragma omp parallel default(shared)
574 /// \endcode
575 /// In this example directive '#pragma omp parallel' has simple 'default'
576 /// clause with kind 'shared'.
577 ///
578 class OMPDefaultClause : public OMPClause {
579  friend class OMPClauseReader;
580  /// \brief Location of '('.
581  SourceLocation LParenLoc;
582  /// \brief A kind of the 'default' clause.
584  /// \brief Start location of the kind in source code.
585  SourceLocation KindKwLoc;
586 
587  /// \brief Set kind of the clauses.
588  ///
589  /// \param K Argument of clause.
590  ///
591  void setDefaultKind(OpenMPDefaultClauseKind K) { Kind = K; }
592 
593  /// \brief Set argument location.
594  ///
595  /// \param KLoc Argument location.
596  ///
597  void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
598 
599 public:
600  /// \brief Build 'default' clause with argument \a A ('none' or 'shared').
601  ///
602  /// \param A Argument of the clause ('none' or 'shared').
603  /// \param ALoc Starting location of the argument.
604  /// \param StartLoc Starting location of the clause.
605  /// \param LParenLoc Location of '('.
606  /// \param EndLoc Ending location of the clause.
607  ///
609  SourceLocation StartLoc, SourceLocation LParenLoc,
610  SourceLocation EndLoc)
611  : OMPClause(OMPC_default, StartLoc, EndLoc), LParenLoc(LParenLoc),
612  Kind(A), KindKwLoc(ALoc) {}
613 
614  /// \brief Build an empty clause.
615  ///
617  : OMPClause(OMPC_default, SourceLocation(), SourceLocation()),
619  KindKwLoc(SourceLocation()) {}
620 
621  /// \brief Sets the location of '('.
622  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
623  /// \brief Returns the location of '('.
624  SourceLocation getLParenLoc() const { return LParenLoc; }
625 
626  /// \brief Returns kind of the clause.
628 
629  /// \brief Returns location of clause kind.
630  SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
631 
632  static bool classof(const OMPClause *T) {
633  return T->getClauseKind() == OMPC_default;
634  }
635 
638  }
639 };
640 
641 /// \brief This represents 'proc_bind' clause in the '#pragma omp ...'
642 /// directive.
643 ///
644 /// \code
645 /// #pragma omp parallel proc_bind(master)
646 /// \endcode
647 /// In this example directive '#pragma omp parallel' has simple 'proc_bind'
648 /// clause with kind 'master'.
649 ///
650 class OMPProcBindClause : public OMPClause {
651  friend class OMPClauseReader;
652  /// \brief Location of '('.
653  SourceLocation LParenLoc;
654  /// \brief A kind of the 'proc_bind' clause.
656  /// \brief Start location of the kind in source code.
657  SourceLocation KindKwLoc;
658 
659  /// \brief Set kind of the clause.
660  ///
661  /// \param K Kind of clause.
662  ///
663  void setProcBindKind(OpenMPProcBindClauseKind K) { Kind = K; }
664 
665  /// \brief Set clause kind location.
666  ///
667  /// \param KLoc Kind location.
668  ///
669  void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
670 
671 public:
672  /// \brief Build 'proc_bind' clause with argument \a A ('master', 'close' or
673  /// 'spread').
674  ///
675  /// \param A Argument of the clause ('master', 'close' or 'spread').
676  /// \param ALoc Starting location of the argument.
677  /// \param StartLoc Starting location of the clause.
678  /// \param LParenLoc Location of '('.
679  /// \param EndLoc Ending location of the clause.
680  ///
682  SourceLocation StartLoc, SourceLocation LParenLoc,
683  SourceLocation EndLoc)
684  : OMPClause(OMPC_proc_bind, StartLoc, EndLoc), LParenLoc(LParenLoc),
685  Kind(A), KindKwLoc(ALoc) {}
686 
687  /// \brief Build an empty clause.
688  ///
690  : OMPClause(OMPC_proc_bind, SourceLocation(), SourceLocation()),
692  KindKwLoc(SourceLocation()) {}
693 
694  /// \brief Sets the location of '('.
695  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
696  /// \brief Returns the location of '('.
697  SourceLocation getLParenLoc() const { return LParenLoc; }
698 
699  /// \brief Returns kind of the clause.
701 
702  /// \brief Returns location of clause kind.
703  SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
704 
705  static bool classof(const OMPClause *T) {
706  return T->getClauseKind() == OMPC_proc_bind;
707  }
708 
711  }
712 };
713 
714 /// \brief This represents 'schedule' clause in the '#pragma omp ...' directive.
715 ///
716 /// \code
717 /// #pragma omp for schedule(static, 3)
718 /// \endcode
719 /// In this example directive '#pragma omp for' has 'schedule' clause with
720 /// arguments 'static' and '3'.
721 ///
723  friend class OMPClauseReader;
724  /// \brief Location of '('.
725  SourceLocation LParenLoc;
726  /// \brief A kind of the 'schedule' clause.
728  /// \brief Modifiers for 'schedule' clause.
729  enum {FIRST, SECOND, NUM_MODIFIERS};
730  OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
731  /// \brief Locations of modifiers.
732  SourceLocation ModifiersLoc[NUM_MODIFIERS];
733  /// \brief Start location of the schedule ind in source code.
734  SourceLocation KindLoc;
735  /// \brief Location of ',' (if any).
736  SourceLocation CommaLoc;
737  /// \brief Chunk size.
738  Expr *ChunkSize;
739 
740  /// \brief Set schedule kind.
741  ///
742  /// \param K Schedule kind.
743  ///
744  void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
745  /// \brief Set the first schedule modifier.
746  ///
747  /// \param M Schedule modifier.
748  ///
749  void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
750  Modifiers[FIRST] = M;
751  }
752  /// \brief Set the second schedule modifier.
753  ///
754  /// \param M Schedule modifier.
755  ///
756  void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
757  Modifiers[SECOND] = M;
758  }
759  /// \brief Set location of the first schedule modifier.
760  ///
761  void setFirstScheduleModifierLoc(SourceLocation Loc) {
762  ModifiersLoc[FIRST] = Loc;
763  }
764  /// \brief Set location of the second schedule modifier.
765  ///
766  void setSecondScheduleModifierLoc(SourceLocation Loc) {
767  ModifiersLoc[SECOND] = Loc;
768  }
769  /// \brief Set schedule modifier location.
770  ///
771  /// \param M Schedule modifier location.
772  ///
773  void setScheduleModifer(OpenMPScheduleClauseModifier M) {
774  if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
775  Modifiers[FIRST] = M;
776  else {
777  assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
778  Modifiers[SECOND] = M;
779  }
780  }
781  /// \brief Sets the location of '('.
782  ///
783  /// \param Loc Location of '('.
784  ///
785  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
786  /// \brief Set schedule kind start location.
787  ///
788  /// \param KLoc Schedule kind location.
789  ///
790  void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
791  /// \brief Set location of ','.
792  ///
793  /// \param Loc Location of ','.
794  ///
795  void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
796  /// \brief Set chunk size.
797  ///
798  /// \param E Chunk size.
799  ///
800  void setChunkSize(Expr *E) { ChunkSize = E; }
801 
802 public:
803  /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size
804  /// expression \a ChunkSize.
805  ///
806  /// \param StartLoc Starting location of the clause.
807  /// \param LParenLoc Location of '('.
808  /// \param KLoc Starting location of the argument.
809  /// \param CommaLoc Location of ','.
810  /// \param EndLoc Ending location of the clause.
811  /// \param Kind Schedule kind.
812  /// \param ChunkSize Chunk size.
813  /// \param HelperChunkSize Helper chunk size for combined directives.
814  /// \param M1 The first modifier applied to 'schedule' clause.
815  /// \param M1Loc Location of the first modifier
816  /// \param M2 The second modifier applied to 'schedule' clause.
817  /// \param M2Loc Location of the second modifier
818  ///
820  SourceLocation KLoc, SourceLocation CommaLoc,
822  Expr *ChunkSize, Stmt *HelperChunkSize,
825  : OMPClause(OMPC_schedule, StartLoc, EndLoc), OMPClauseWithPreInit(this),
826  LParenLoc(LParenLoc), Kind(Kind), KindLoc(KLoc), CommaLoc(CommaLoc),
827  ChunkSize(ChunkSize) {
828  setPreInitStmt(HelperChunkSize);
829  Modifiers[FIRST] = M1;
830  Modifiers[SECOND] = M2;
831  ModifiersLoc[FIRST] = M1Loc;
832  ModifiersLoc[SECOND] = M2Loc;
833  }
834 
835  /// \brief Build an empty clause.
836  ///
837  explicit OMPScheduleClause()
838  : OMPClause(OMPC_schedule, SourceLocation(), SourceLocation()),
840  ChunkSize(nullptr) {
841  Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
842  Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
843  }
844 
845  /// \brief Get kind of the clause.
846  ///
848  /// \brief Get the first modifier of the clause.
849  ///
851  return Modifiers[FIRST];
852  }
853  /// \brief Get the second modifier of the clause.
854  ///
856  return Modifiers[SECOND];
857  }
858  /// \brief Get location of '('.
859  ///
860  SourceLocation getLParenLoc() { return LParenLoc; }
861  /// \brief Get kind location.
862  ///
863  SourceLocation getScheduleKindLoc() { return KindLoc; }
864  /// \brief Get the first modifier location.
865  ///
867  return ModifiersLoc[FIRST];
868  }
869  /// \brief Get the second modifier location.
870  ///
872  return ModifiersLoc[SECOND];
873  }
874  /// \brief Get location of ','.
875  ///
876  SourceLocation getCommaLoc() { return CommaLoc; }
877  /// \brief Get chunk size.
878  ///
879  Expr *getChunkSize() { return ChunkSize; }
880  /// \brief Get chunk size.
881  ///
882  const Expr *getChunkSize() const { return ChunkSize; }
883 
884  static bool classof(const OMPClause *T) {
885  return T->getClauseKind() == OMPC_schedule;
886  }
887 
889  return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
890  reinterpret_cast<Stmt **>(&ChunkSize) + 1);
891  }
892 };
893 
894 /// \brief This represents 'ordered' clause in the '#pragma omp ...' directive.
895 ///
896 /// \code
897 /// #pragma omp for ordered (2)
898 /// \endcode
899 /// In this example directive '#pragma omp for' has 'ordered' clause with
900 /// parameter 2.
901 ///
902 class OMPOrderedClause : public OMPClause {
903  friend class OMPClauseReader;
904  /// \brief Location of '('.
905  SourceLocation LParenLoc;
906  /// \brief Number of for-loops.
907  Stmt *NumForLoops;
908 
909  /// \brief Set the number of associated for-loops.
910  void setNumForLoops(Expr *Num) { NumForLoops = Num; }
911 
912 public:
913  /// \brief Build 'ordered' clause.
914  ///
915  /// \param Num Expression, possibly associated with this clause.
916  /// \param StartLoc Starting location of the clause.
917  /// \param LParenLoc Location of '('.
918  /// \param EndLoc Ending location of the clause.
919  ///
921  SourceLocation LParenLoc, SourceLocation EndLoc)
922  : OMPClause(OMPC_ordered, StartLoc, EndLoc), LParenLoc(LParenLoc),
923  NumForLoops(Num) {}
924 
925  /// \brief Build an empty clause.
926  ///
927  explicit OMPOrderedClause()
928  : OMPClause(OMPC_ordered, SourceLocation(), SourceLocation()),
929  LParenLoc(SourceLocation()), NumForLoops(nullptr) {}
930 
931  /// \brief Sets the location of '('.
932  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
933  /// \brief Returns the location of '('.
934  SourceLocation getLParenLoc() const { return LParenLoc; }
935 
936  /// \brief Return the number of associated for-loops.
937  Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
938 
939  static bool classof(const OMPClause *T) {
940  return T->getClauseKind() == OMPC_ordered;
941  }
942 
943  child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
944 };
945 
946 /// \brief This represents 'nowait' clause in the '#pragma omp ...' directive.
947 ///
948 /// \code
949 /// #pragma omp for nowait
950 /// \endcode
951 /// In this example directive '#pragma omp for' has 'nowait' clause.
952 ///
953 class OMPNowaitClause : public OMPClause {
954 public:
955  /// \brief Build 'nowait' clause.
956  ///
957  /// \param StartLoc Starting location of the clause.
958  /// \param EndLoc Ending location of the clause.
959  ///
961  : OMPClause(OMPC_nowait, StartLoc, EndLoc) {}
962 
963  /// \brief Build an empty clause.
964  ///
966  : OMPClause(OMPC_nowait, SourceLocation(), SourceLocation()) {}
967 
968  static bool classof(const OMPClause *T) {
969  return T->getClauseKind() == OMPC_nowait;
970  }
971 
974  }
975 };
976 
977 /// \brief This represents 'untied' clause in the '#pragma omp ...' directive.
978 ///
979 /// \code
980 /// #pragma omp task untied
981 /// \endcode
982 /// In this example directive '#pragma omp task' has 'untied' clause.
983 ///
984 class OMPUntiedClause : public OMPClause {
985 public:
986  /// \brief Build 'untied' clause.
987  ///
988  /// \param StartLoc Starting location of the clause.
989  /// \param EndLoc Ending location of the clause.
990  ///
992  : OMPClause(OMPC_untied, StartLoc, EndLoc) {}
993 
994  /// \brief Build an empty clause.
995  ///
997  : OMPClause(OMPC_untied, SourceLocation(), SourceLocation()) {}
998 
999  static bool classof(const OMPClause *T) {
1000  return T->getClauseKind() == OMPC_untied;
1001  }
1002 
1005  }
1006 };
1007 
1008 /// \brief This represents 'mergeable' clause in the '#pragma omp ...'
1009 /// directive.
1010 ///
1011 /// \code
1012 /// #pragma omp task mergeable
1013 /// \endcode
1014 /// In this example directive '#pragma omp task' has 'mergeable' clause.
1015 ///
1017 public:
1018  /// \brief Build 'mergeable' clause.
1019  ///
1020  /// \param StartLoc Starting location of the clause.
1021  /// \param EndLoc Ending location of the clause.
1022  ///
1024  : OMPClause(OMPC_mergeable, StartLoc, EndLoc) {}
1025 
1026  /// \brief Build an empty clause.
1027  ///
1029  : OMPClause(OMPC_mergeable, SourceLocation(), SourceLocation()) {}
1030 
1031  static bool classof(const OMPClause *T) {
1032  return T->getClauseKind() == OMPC_mergeable;
1033  }
1034 
1037  }
1038 };
1039 
1040 /// \brief This represents 'read' clause in the '#pragma omp atomic' directive.
1041 ///
1042 /// \code
1043 /// #pragma omp atomic read
1044 /// \endcode
1045 /// In this example directive '#pragma omp atomic' has 'read' clause.
1046 ///
1047 class OMPReadClause : public OMPClause {
1048 public:
1049  /// \brief Build 'read' clause.
1050  ///
1051  /// \param StartLoc Starting location of the clause.
1052  /// \param EndLoc Ending location of the clause.
1053  ///
1055  : OMPClause(OMPC_read, StartLoc, EndLoc) {}
1056 
1057  /// \brief Build an empty clause.
1058  ///
1060 
1061  static bool classof(const OMPClause *T) {
1062  return T->getClauseKind() == OMPC_read;
1063  }
1064 
1067  }
1068 };
1069 
1070 /// \brief This represents 'write' clause in the '#pragma omp atomic' directive.
1071 ///
1072 /// \code
1073 /// #pragma omp atomic write
1074 /// \endcode
1075 /// In this example directive '#pragma omp atomic' has 'write' clause.
1076 ///
1077 class OMPWriteClause : public OMPClause {
1078 public:
1079  /// \brief Build 'write' clause.
1080  ///
1081  /// \param StartLoc Starting location of the clause.
1082  /// \param EndLoc Ending location of the clause.
1083  ///
1085  : OMPClause(OMPC_write, StartLoc, EndLoc) {}
1086 
1087  /// \brief Build an empty clause.
1088  ///
1090  : OMPClause(OMPC_write, SourceLocation(), SourceLocation()) {}
1091 
1092  static bool classof(const OMPClause *T) {
1093  return T->getClauseKind() == OMPC_write;
1094  }
1095 
1098  }
1099 };
1100 
1101 /// \brief This represents 'update' clause in the '#pragma omp atomic'
1102 /// directive.
1103 ///
1104 /// \code
1105 /// #pragma omp atomic update
1106 /// \endcode
1107 /// In this example directive '#pragma omp atomic' has 'update' clause.
1108 ///
1109 class OMPUpdateClause : public OMPClause {
1110 public:
1111  /// \brief Build 'update' clause.
1112  ///
1113  /// \param StartLoc Starting location of the clause.
1114  /// \param EndLoc Ending location of the clause.
1115  ///
1117  : OMPClause(OMPC_update, StartLoc, EndLoc) {}
1118 
1119  /// \brief Build an empty clause.
1120  ///
1122  : OMPClause(OMPC_update, SourceLocation(), SourceLocation()) {}
1123 
1124  static bool classof(const OMPClause *T) {
1125  return T->getClauseKind() == OMPC_update;
1126  }
1127 
1130  }
1131 };
1132 
1133 /// \brief This represents 'capture' clause in the '#pragma omp atomic'
1134 /// directive.
1135 ///
1136 /// \code
1137 /// #pragma omp atomic capture
1138 /// \endcode
1139 /// In this example directive '#pragma omp atomic' has 'capture' clause.
1140 ///
1141 class OMPCaptureClause : public OMPClause {
1142 public:
1143  /// \brief Build 'capture' clause.
1144  ///
1145  /// \param StartLoc Starting location of the clause.
1146  /// \param EndLoc Ending location of the clause.
1147  ///
1149  : OMPClause(OMPC_capture, StartLoc, EndLoc) {}
1150 
1151  /// \brief Build an empty clause.
1152  ///
1154  : OMPClause(OMPC_capture, SourceLocation(), SourceLocation()) {}
1155 
1156  static bool classof(const OMPClause *T) {
1157  return T->getClauseKind() == OMPC_capture;
1158  }
1159 
1162  }
1163 };
1164 
1165 /// \brief This represents 'seq_cst' clause in the '#pragma omp atomic'
1166 /// directive.
1167 ///
1168 /// \code
1169 /// #pragma omp atomic seq_cst
1170 /// \endcode
1171 /// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
1172 ///
1173 class OMPSeqCstClause : public OMPClause {
1174 public:
1175  /// \brief Build 'seq_cst' clause.
1176  ///
1177  /// \param StartLoc Starting location of the clause.
1178  /// \param EndLoc Ending location of the clause.
1179  ///
1181  : OMPClause(OMPC_seq_cst, StartLoc, EndLoc) {}
1182 
1183  /// \brief Build an empty clause.
1184  ///
1186  : OMPClause(OMPC_seq_cst, SourceLocation(), SourceLocation()) {}
1187 
1188  static bool classof(const OMPClause *T) {
1189  return T->getClauseKind() == OMPC_seq_cst;
1190  }
1191 
1194  }
1195 };
1196 
1197 /// \brief This represents clause 'private' in the '#pragma omp ...' directives.
1198 ///
1199 /// \code
1200 /// #pragma omp parallel private(a,b)
1201 /// \endcode
1202 /// In this example directive '#pragma omp parallel' has clause 'private'
1203 /// with the variables 'a' and 'b'.
1204 ///
1205 class OMPPrivateClause final
1206  : public OMPVarListClause<OMPPrivateClause>,
1207  private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
1208  friend TrailingObjects;
1209  friend OMPVarListClause;
1210  friend class OMPClauseReader;
1211  /// \brief Build clause with number of variables \a N.
1212  ///
1213  /// \param StartLoc Starting location of the clause.
1214  /// \param LParenLoc Location of '('.
1215  /// \param EndLoc Ending location of the clause.
1216  /// \param N Number of the variables in the clause.
1217  ///
1218  OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1219  SourceLocation EndLoc, unsigned N)
1220  : OMPVarListClause<OMPPrivateClause>(OMPC_private, StartLoc, LParenLoc,
1221  EndLoc, N) {}
1222 
1223  /// \brief Build an empty clause.
1224  ///
1225  /// \param N Number of variables.
1226  ///
1227  explicit OMPPrivateClause(unsigned N)
1230  N) {}
1231 
1232  /// \brief Sets the list of references to private copies with initializers for
1233  /// new private variables.
1234  /// \param VL List of references.
1235  void setPrivateCopies(ArrayRef<Expr *> VL);
1236 
1237  /// \brief Gets the list of references to private copies with initializers for
1238  /// new private variables.
1239  MutableArrayRef<Expr *> getPrivateCopies() {
1240  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1241  }
1242  ArrayRef<const Expr *> getPrivateCopies() const {
1243  return llvm::makeArrayRef(varlist_end(), varlist_size());
1244  }
1245 
1246 public:
1247  /// \brief Creates clause with a list of variables \a VL.
1248  ///
1249  /// \param C AST context.
1250  /// \param StartLoc Starting location of the clause.
1251  /// \param LParenLoc Location of '('.
1252  /// \param EndLoc Ending location of the clause.
1253  /// \param VL List of references to the variables.
1254  /// \param PrivateVL List of references to private copies with initializers.
1255  ///
1256  static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
1257  SourceLocation LParenLoc,
1258  SourceLocation EndLoc, ArrayRef<Expr *> VL,
1259  ArrayRef<Expr *> PrivateVL);
1260  /// \brief Creates an empty clause with the place for \a N variables.
1261  ///
1262  /// \param C AST context.
1263  /// \param N The number of variables.
1264  ///
1265  static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1266 
1269  typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
1270  typedef llvm::iterator_range<private_copies_const_iterator>
1272 
1274  return private_copies_range(getPrivateCopies().begin(),
1275  getPrivateCopies().end());
1276  }
1278  return private_copies_const_range(getPrivateCopies().begin(),
1279  getPrivateCopies().end());
1280  }
1281 
1283  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1284  reinterpret_cast<Stmt **>(varlist_end()));
1285  }
1286 
1287  static bool classof(const OMPClause *T) {
1288  return T->getClauseKind() == OMPC_private;
1289  }
1290 };
1291 
1292 /// \brief This represents clause 'firstprivate' in the '#pragma omp ...'
1293 /// directives.
1294 ///
1295 /// \code
1296 /// #pragma omp parallel firstprivate(a,b)
1297 /// \endcode
1298 /// In this example directive '#pragma omp parallel' has clause 'firstprivate'
1299 /// with the variables 'a' and 'b'.
1300 ///
1302  : public OMPVarListClause<OMPFirstprivateClause>,
1303  public OMPClauseWithPreInit,
1304  private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
1305  friend TrailingObjects;
1306  friend OMPVarListClause;
1307  friend class OMPClauseReader;
1308 
1309  /// \brief Build clause with number of variables \a N.
1310  ///
1311  /// \param StartLoc Starting location of the clause.
1312  /// \param LParenLoc Location of '('.
1313  /// \param EndLoc Ending location of the clause.
1314  /// \param N Number of the variables in the clause.
1315  ///
1317  SourceLocation EndLoc, unsigned N)
1318  : OMPVarListClause<OMPFirstprivateClause>(OMPC_firstprivate, StartLoc,
1319  LParenLoc, EndLoc, N),
1320  OMPClauseWithPreInit(this) {}
1321 
1322  /// \brief Build an empty clause.
1323  ///
1324  /// \param N Number of variables.
1325  ///
1326  explicit OMPFirstprivateClause(unsigned N)
1328  OMPC_firstprivate, SourceLocation(), SourceLocation(),
1329  SourceLocation(), N),
1330  OMPClauseWithPreInit(this) {}
1331  /// \brief Sets the list of references to private copies with initializers for
1332  /// new private variables.
1333  /// \param VL List of references.
1334  void setPrivateCopies(ArrayRef<Expr *> VL);
1335 
1336  /// \brief Gets the list of references to private copies with initializers for
1337  /// new private variables.
1338  MutableArrayRef<Expr *> getPrivateCopies() {
1339  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1340  }
1341  ArrayRef<const Expr *> getPrivateCopies() const {
1342  return llvm::makeArrayRef(varlist_end(), varlist_size());
1343  }
1344 
1345  /// \brief Sets the list of references to initializer variables for new
1346  /// private variables.
1347  /// \param VL List of references.
1348  void setInits(ArrayRef<Expr *> VL);
1349 
1350  /// \brief Gets the list of references to initializer variables for new
1351  /// private variables.
1352  MutableArrayRef<Expr *> getInits() {
1353  return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1354  }
1355  ArrayRef<const Expr *> getInits() const {
1356  return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1357  }
1358 
1359 public:
1360  /// \brief Creates clause with a list of variables \a VL.
1361  ///
1362  /// \param C AST context.
1363  /// \param StartLoc Starting location of the clause.
1364  /// \param LParenLoc Location of '('.
1365  /// \param EndLoc Ending location of the clause.
1366  /// \param VL List of references to the original variables.
1367  /// \param PrivateVL List of references to private copies with initializers.
1368  /// \param InitVL List of references to auto generated variables used for
1369  /// initialization of a single array element. Used if firstprivate variable is
1370  /// of array type.
1371  /// \param PreInit Statement that must be executed before entering the OpenMP
1372  /// region with this clause.
1373  ///
1374  static OMPFirstprivateClause *
1375  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1376  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
1377  ArrayRef<Expr *> InitVL, Stmt *PreInit);
1378  /// \brief Creates an empty clause with the place for \a N variables.
1379  ///
1380  /// \param C AST context.
1381  /// \param N The number of variables.
1382  ///
1383  static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1384 
1387  typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
1388  typedef llvm::iterator_range<private_copies_const_iterator>
1390 
1392  return private_copies_range(getPrivateCopies().begin(),
1393  getPrivateCopies().end());
1394  }
1396  return private_copies_const_range(getPrivateCopies().begin(),
1397  getPrivateCopies().end());
1398  }
1399 
1402  typedef llvm::iterator_range<inits_iterator> inits_range;
1403  typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
1404 
1406  return inits_range(getInits().begin(), getInits().end());
1407  }
1409  return inits_const_range(getInits().begin(), getInits().end());
1410  }
1411 
1413  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1414  reinterpret_cast<Stmt **>(varlist_end()));
1415  }
1416 
1417  static bool classof(const OMPClause *T) {
1418  return T->getClauseKind() == OMPC_firstprivate;
1419  }
1420 };
1421 
1422 /// \brief This represents clause 'lastprivate' in the '#pragma omp ...'
1423 /// directives.
1424 ///
1425 /// \code
1426 /// #pragma omp simd lastprivate(a,b)
1427 /// \endcode
1428 /// In this example directive '#pragma omp simd' has clause 'lastprivate'
1429 /// with the variables 'a' and 'b'.
1431  : public OMPVarListClause<OMPLastprivateClause>,
1432  public OMPClauseWithPostUpdate,
1433  private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
1434  // There are 4 additional tail-allocated arrays at the end of the class:
1435  // 1. Contains list of pseudo variables with the default initialization for
1436  // each non-firstprivate variables. Used in codegen for initialization of
1437  // lastprivate copies.
1438  // 2. List of helper expressions for proper generation of assignment operation
1439  // required for lastprivate clause. This list represents private variables
1440  // (for arrays, single array element).
1441  // 3. List of helper expressions for proper generation of assignment operation
1442  // required for lastprivate clause. This list represents original variables
1443  // (for arrays, single array element).
1444  // 4. List of helper expressions that represents assignment operation:
1445  // \code
1446  // DstExprs = SrcExprs;
1447  // \endcode
1448  // Required for proper codegen of final assignment performed by the
1449  // lastprivate clause.
1450  //
1451  friend TrailingObjects;
1452  friend OMPVarListClause;
1453  friend class OMPClauseReader;
1454 
1455  /// \brief Build clause with number of variables \a N.
1456  ///
1457  /// \param StartLoc Starting location of the clause.
1458  /// \param LParenLoc Location of '('.
1459  /// \param EndLoc Ending location of the clause.
1460  /// \param N Number of the variables in the clause.
1461  ///
1463  SourceLocation EndLoc, unsigned N)
1464  : OMPVarListClause<OMPLastprivateClause>(OMPC_lastprivate, StartLoc,
1465  LParenLoc, EndLoc, N),
1466  OMPClauseWithPostUpdate(this) {}
1467 
1468  /// \brief Build an empty clause.
1469  ///
1470  /// \param N Number of variables.
1471  ///
1472  explicit OMPLastprivateClause(unsigned N)
1474  OMPC_lastprivate, SourceLocation(), SourceLocation(),
1475  SourceLocation(), N),
1476  OMPClauseWithPostUpdate(this) {}
1477 
1478  /// \brief Get the list of helper expressions for initialization of private
1479  /// copies for lastprivate variables.
1480  MutableArrayRef<Expr *> getPrivateCopies() {
1481  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1482  }
1483  ArrayRef<const Expr *> getPrivateCopies() const {
1484  return llvm::makeArrayRef(varlist_end(), varlist_size());
1485  }
1486 
1487  /// \brief Set list of helper expressions, required for proper codegen of the
1488  /// clause. These expressions represent private variables (for arrays, single
1489  /// array element) in the final assignment statement performed by the
1490  /// lastprivate clause.
1491  void setSourceExprs(ArrayRef<Expr *> SrcExprs);
1492 
1493  /// \brief Get the list of helper source expressions.
1494  MutableArrayRef<Expr *> getSourceExprs() {
1495  return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1496  }
1497  ArrayRef<const Expr *> getSourceExprs() const {
1498  return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1499  }
1500 
1501  /// \brief Set list of helper expressions, required for proper codegen of the
1502  /// clause. These expressions represent original variables (for arrays, single
1503  /// array element) in the final assignment statement performed by the
1504  /// lastprivate clause.
1505  void setDestinationExprs(ArrayRef<Expr *> DstExprs);
1506 
1507  /// \brief Get the list of helper destination expressions.
1508  MutableArrayRef<Expr *> getDestinationExprs() {
1509  return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
1510  }
1511  ArrayRef<const Expr *> getDestinationExprs() const {
1512  return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
1513  }
1514 
1515  /// \brief Set list of helper assignment expressions, required for proper
1516  /// codegen of the clause. These expressions are assignment expressions that
1517  /// assign private copy of the variable to original variable.
1518  void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
1519 
1520  /// \brief Get the list of helper assignment expressions.
1521  MutableArrayRef<Expr *> getAssignmentOps() {
1522  return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
1523  }
1524  ArrayRef<const Expr *> getAssignmentOps() const {
1525  return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
1526  }
1527 
1528 public:
1529  /// \brief Creates clause with a list of variables \a VL.
1530  ///
1531  /// \param C AST context.
1532  /// \param StartLoc Starting location of the clause.
1533  /// \param LParenLoc Location of '('.
1534  /// \param EndLoc Ending location of the clause.
1535  /// \param VL List of references to the variables.
1536  /// \param SrcExprs List of helper expressions for proper generation of
1537  /// assignment operation required for lastprivate clause. This list represents
1538  /// private variables (for arrays, single array element).
1539  /// \param DstExprs List of helper expressions for proper generation of
1540  /// assignment operation required for lastprivate clause. This list represents
1541  /// original variables (for arrays, single array element).
1542  /// \param AssignmentOps List of helper expressions that represents assignment
1543  /// operation:
1544  /// \code
1545  /// DstExprs = SrcExprs;
1546  /// \endcode
1547  /// Required for proper codegen of final assignment performed by the
1548  /// lastprivate clause.
1549  /// \param PreInit Statement that must be executed before entering the OpenMP
1550  /// region with this clause.
1551  /// \param PostUpdate Expression that must be executed after exit from the
1552  /// OpenMP region with this clause.
1553  ///
1554  static OMPLastprivateClause *
1555  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1556  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
1557  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
1558  Stmt *PreInit, Expr *PostUpdate);
1559  /// \brief Creates an empty clause with the place for \a N variables.
1560  ///
1561  /// \param C AST context.
1562  /// \param N The number of variables.
1563  ///
1564  static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1565 
1568  typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
1569  typedef llvm::iterator_range<helper_expr_const_iterator>
1571 
1572  /// \brief Set list of helper expressions, required for generation of private
1573  /// copies of original lastprivate variables.
1574  void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
1575 
1577  return helper_expr_const_range(getPrivateCopies().begin(),
1578  getPrivateCopies().end());
1579  }
1581  return helper_expr_range(getPrivateCopies().begin(),
1582  getPrivateCopies().end());
1583  }
1585  return helper_expr_const_range(getSourceExprs().begin(),
1586  getSourceExprs().end());
1587  }
1589  return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
1590  }
1592  return helper_expr_const_range(getDestinationExprs().begin(),
1593  getDestinationExprs().end());
1594  }
1596  return helper_expr_range(getDestinationExprs().begin(),
1597  getDestinationExprs().end());
1598  }
1600  return helper_expr_const_range(getAssignmentOps().begin(),
1601  getAssignmentOps().end());
1602  }
1604  return helper_expr_range(getAssignmentOps().begin(),
1605  getAssignmentOps().end());
1606  }
1607 
1609  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1610  reinterpret_cast<Stmt **>(varlist_end()));
1611  }
1612 
1613  static bool classof(const OMPClause *T) {
1614  return T->getClauseKind() == OMPC_lastprivate;
1615  }
1616 };
1617 
1618 /// \brief This represents clause 'shared' in the '#pragma omp ...' directives.
1619 ///
1620 /// \code
1621 /// #pragma omp parallel shared(a,b)
1622 /// \endcode
1623 /// In this example directive '#pragma omp parallel' has clause 'shared'
1624 /// with the variables 'a' and 'b'.
1625 ///
1626 class OMPSharedClause final
1627  : public OMPVarListClause<OMPSharedClause>,
1628  private llvm::TrailingObjects<OMPSharedClause, Expr *> {
1629  friend TrailingObjects;
1630  friend OMPVarListClause;
1631  /// \brief Build clause with number of variables \a N.
1632  ///
1633  /// \param StartLoc Starting location of the clause.
1634  /// \param LParenLoc Location of '('.
1635  /// \param EndLoc Ending location of the clause.
1636  /// \param N Number of the variables in the clause.
1637  ///
1638  OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1639  SourceLocation EndLoc, unsigned N)
1640  : OMPVarListClause<OMPSharedClause>(OMPC_shared, StartLoc, LParenLoc,
1641  EndLoc, N) {}
1642 
1643  /// \brief Build an empty clause.
1644  ///
1645  /// \param N Number of variables.
1646  ///
1647  explicit OMPSharedClause(unsigned N)
1650  N) {}
1651 
1652 public:
1653  /// \brief Creates clause with a list of variables \a VL.
1654  ///
1655  /// \param C AST context.
1656  /// \param StartLoc Starting location of the clause.
1657  /// \param LParenLoc Location of '('.
1658  /// \param EndLoc Ending location of the clause.
1659  /// \param VL List of references to the variables.
1660  ///
1661  static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
1662  SourceLocation LParenLoc,
1663  SourceLocation EndLoc, ArrayRef<Expr *> VL);
1664  /// \brief Creates an empty clause with \a N variables.
1665  ///
1666  /// \param C AST context.
1667  /// \param N The number of variables.
1668  ///
1669  static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
1670 
1672  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1673  reinterpret_cast<Stmt **>(varlist_end()));
1674  }
1675 
1676  static bool classof(const OMPClause *T) {
1677  return T->getClauseKind() == OMPC_shared;
1678  }
1679 };
1680 
1681 /// \brief This represents clause 'reduction' in the '#pragma omp ...'
1682 /// directives.
1683 ///
1684 /// \code
1685 /// #pragma omp parallel reduction(+:a,b)
1686 /// \endcode
1687 /// In this example directive '#pragma omp parallel' has clause 'reduction'
1688 /// with operator '+' and the variables 'a' and 'b'.
1689 ///
1691  : public OMPVarListClause<OMPReductionClause>,
1692  public OMPClauseWithPostUpdate,
1693  private llvm::TrailingObjects<OMPReductionClause, Expr *> {
1694  friend TrailingObjects;
1695  friend OMPVarListClause;
1696  friend class OMPClauseReader;
1697  /// \brief Location of ':'.
1699  /// \brief Nested name specifier for C++.
1700  NestedNameSpecifierLoc QualifierLoc;
1701  /// \brief Name of custom operator.
1702  DeclarationNameInfo NameInfo;
1703 
1704  /// \brief Build clause with number of variables \a N.
1705  ///
1706  /// \param StartLoc Starting location of the clause.
1707  /// \param LParenLoc Location of '('.
1708  /// \param EndLoc Ending location of the clause.
1709  /// \param ColonLoc Location of ':'.
1710  /// \param N Number of the variables in the clause.
1711  /// \param QualifierLoc The nested-name qualifier with location information
1712  /// \param NameInfo The full name info for reduction identifier.
1713  ///
1714  OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1715  SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N,
1716  NestedNameSpecifierLoc QualifierLoc,
1717  const DeclarationNameInfo &NameInfo)
1718  : OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
1719  LParenLoc, EndLoc, N),
1720  OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
1721  QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
1722 
1723  /// \brief Build an empty clause.
1724  ///
1725  /// \param N Number of variables.
1726  ///
1727  explicit OMPReductionClause(unsigned N)
1728  : OMPVarListClause<OMPReductionClause>(OMPC_reduction, SourceLocation(),
1730  N),
1731  OMPClauseWithPostUpdate(this), ColonLoc(), QualifierLoc(), NameInfo() {}
1732 
1733  /// \brief Sets location of ':' symbol in clause.
1734  void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
1735  /// \brief Sets the name info for specified reduction identifier.
1736  void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
1737  /// \brief Sets the nested name specifier.
1738  void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
1739 
1740  /// \brief Set list of helper expressions, required for proper codegen of the
1741  /// clause. These expressions represent private copy of the reduction
1742  /// variable.
1743  void setPrivates(ArrayRef<Expr *> Privates);
1744 
1745  /// \brief Get the list of helper privates.
1746  MutableArrayRef<Expr *> getPrivates() {
1747  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1748  }
1749  ArrayRef<const Expr *> getPrivates() const {
1750  return llvm::makeArrayRef(varlist_end(), varlist_size());
1751  }
1752 
1753  /// \brief Set list of helper expressions, required for proper codegen of the
1754  /// clause. These expressions represent LHS expression in the final
1755  /// reduction expression performed by the reduction clause.
1756  void setLHSExprs(ArrayRef<Expr *> LHSExprs);
1757 
1758  /// \brief Get the list of helper LHS expressions.
1759  MutableArrayRef<Expr *> getLHSExprs() {
1760  return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
1761  }
1762  ArrayRef<const Expr *> getLHSExprs() const {
1763  return llvm::makeArrayRef(getPrivates().end(), varlist_size());
1764  }
1765 
1766  /// \brief Set list of helper expressions, required for proper codegen of the
1767  /// clause. These expressions represent RHS expression in the final
1768  /// reduction expression performed by the reduction clause.
1769  /// Also, variables in these expressions are used for proper initialization of
1770  /// reduction copies.
1771  void setRHSExprs(ArrayRef<Expr *> RHSExprs);
1772 
1773  /// \brief Get the list of helper destination expressions.
1774  MutableArrayRef<Expr *> getRHSExprs() {
1775  return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
1776  }
1777  ArrayRef<const Expr *> getRHSExprs() const {
1778  return llvm::makeArrayRef(getLHSExprs().end(), varlist_size());
1779  }
1780 
1781  /// \brief Set list of helper reduction expressions, required for proper
1782  /// codegen of the clause. These expressions are binary expressions or
1783  /// operator/custom reduction call that calculates new value from source
1784  /// helper expressions to destination helper expressions.
1785  void setReductionOps(ArrayRef<Expr *> ReductionOps);
1786 
1787  /// \brief Get the list of helper reduction expressions.
1788  MutableArrayRef<Expr *> getReductionOps() {
1789  return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
1790  }
1791  ArrayRef<const Expr *> getReductionOps() const {
1792  return llvm::makeArrayRef(getRHSExprs().end(), varlist_size());
1793  }
1794 
1795 public:
1796  /// \brief Creates clause with a list of variables \a VL.
1797  ///
1798  /// \param StartLoc Starting location of the clause.
1799  /// \param LParenLoc Location of '('.
1800  /// \param ColonLoc Location of ':'.
1801  /// \param EndLoc Ending location of the clause.
1802  /// \param VL The variables in the clause.
1803  /// \param QualifierLoc The nested-name qualifier with location information
1804  /// \param NameInfo The full name info for reduction identifier.
1805  /// \param Privates List of helper expressions for proper generation of
1806  /// private copies.
1807  /// \param LHSExprs List of helper expressions for proper generation of
1808  /// assignment operation required for copyprivate clause. This list represents
1809  /// LHSs of the reduction expressions.
1810  /// \param RHSExprs List of helper expressions for proper generation of
1811  /// assignment operation required for copyprivate clause. This list represents
1812  /// RHSs of the reduction expressions.
1813  /// Also, variables in these expressions are used for proper initialization of
1814  /// reduction copies.
1815  /// \param ReductionOps List of helper expressions that represents reduction
1816  /// expressions:
1817  /// \code
1818  /// LHSExprs binop RHSExprs;
1819  /// operator binop(LHSExpr, RHSExpr);
1820  /// <CutomReduction>(LHSExpr, RHSExpr);
1821  /// \endcode
1822  /// Required for proper codegen of final reduction operation performed by the
1823  /// reduction clause.
1824  /// \param PreInit Statement that must be executed before entering the OpenMP
1825  /// region with this clause.
1826  /// \param PostUpdate Expression that must be executed after exit from the
1827  /// OpenMP region with this clause.
1828  ///
1829  static OMPReductionClause *
1830  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1831  SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
1832  NestedNameSpecifierLoc QualifierLoc,
1833  const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
1834  ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
1835  ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
1836  /// \brief Creates an empty clause with the place for \a N variables.
1837  ///
1838  /// \param C AST context.
1839  /// \param N The number of variables.
1840  ///
1841  static OMPReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
1842 
1843  /// \brief Gets location of ':' symbol in clause.
1845  /// \brief Gets the name info for specified reduction identifier.
1846  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
1847  /// \brief Gets the nested name specifier.
1848  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
1849 
1852  typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
1853  typedef llvm::iterator_range<helper_expr_const_iterator>
1855 
1857  return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
1858  }
1860  return helper_expr_range(getPrivates().begin(), getPrivates().end());
1861  }
1863  return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
1864  }
1866  return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
1867  }
1869  return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
1870  }
1872  return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
1873  }
1875  return helper_expr_const_range(getReductionOps().begin(),
1876  getReductionOps().end());
1877  }
1879  return helper_expr_range(getReductionOps().begin(),
1880  getReductionOps().end());
1881  }
1882 
1884  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1885  reinterpret_cast<Stmt **>(varlist_end()));
1886  }
1887 
1888  static bool classof(const OMPClause *T) {
1889  return T->getClauseKind() == OMPC_reduction;
1890  }
1891 };
1892 
1893 /// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
1894 /// directives.
1895 ///
1896 /// \code
1897 /// #pragma omp taskgroup task_reduction(+:a,b)
1898 /// \endcode
1899 /// In this example directive '#pragma omp taskgroup' has clause
1900 /// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
1901 ///
1903  : public OMPVarListClause<OMPTaskReductionClause>,
1904  public OMPClauseWithPostUpdate,
1905  private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> {
1906  friend TrailingObjects;
1907  friend OMPVarListClause;
1908  friend class OMPClauseReader;
1909  /// Location of ':'.
1911  /// Nested name specifier for C++.
1912  NestedNameSpecifierLoc QualifierLoc;
1913  /// Name of custom operator.
1914  DeclarationNameInfo NameInfo;
1915 
1916  /// Build clause with number of variables \a N.
1917  ///
1918  /// \param StartLoc Starting location of the clause.
1919  /// \param LParenLoc Location of '('.
1920  /// \param EndLoc Ending location of the clause.
1921  /// \param ColonLoc Location of ':'.
1922  /// \param N Number of the variables in the clause.
1923  /// \param QualifierLoc The nested-name qualifier with location information
1924  /// \param NameInfo The full name info for reduction identifier.
1925  ///
1928  unsigned N, NestedNameSpecifierLoc QualifierLoc,
1929  const DeclarationNameInfo &NameInfo)
1930  : OMPVarListClause<OMPTaskReductionClause>(OMPC_task_reduction, StartLoc,
1931  LParenLoc, EndLoc, N),
1932  OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
1933  QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
1934 
1935  /// Build an empty clause.
1936  ///
1937  /// \param N Number of variables.
1938  ///
1939  explicit OMPTaskReductionClause(unsigned N)
1941  OMPC_task_reduction, SourceLocation(), SourceLocation(),
1942  SourceLocation(), N),
1943  OMPClauseWithPostUpdate(this), ColonLoc(), QualifierLoc(), NameInfo() {}
1944 
1945  /// Sets location of ':' symbol in clause.
1946  void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
1947  /// Sets the name info for specified reduction identifier.
1948  void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
1949  /// Sets the nested name specifier.
1950  void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
1951 
1952  /// Set list of helper expressions, required for proper codegen of the clause.
1953  /// These expressions represent private copy of the reduction variable.
1954  void setPrivates(ArrayRef<Expr *> Privates);
1955 
1956  /// Get the list of helper privates.
1957  MutableArrayRef<Expr *> getPrivates() {
1958  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1959  }
1960  ArrayRef<const Expr *> getPrivates() const {
1961  return llvm::makeArrayRef(varlist_end(), varlist_size());
1962  }
1963 
1964  /// Set list of helper expressions, required for proper codegen of the clause.
1965  /// These expressions represent LHS expression in the final reduction
1966  /// expression performed by the reduction clause.
1967  void setLHSExprs(ArrayRef<Expr *> LHSExprs);
1968 
1969  /// Get the list of helper LHS expressions.
1970  MutableArrayRef<Expr *> getLHSExprs() {
1971  return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
1972  }
1973  ArrayRef<const Expr *> getLHSExprs() const {
1974  return llvm::makeArrayRef(getPrivates().end(), varlist_size());
1975  }
1976 
1977  /// Set list of helper expressions, required for proper codegen of the clause.
1978  /// These expressions represent RHS expression in the final reduction
1979  /// expression performed by the reduction clause. Also, variables in these
1980  /// expressions are used for proper initialization of reduction copies.
1981  void setRHSExprs(ArrayRef<Expr *> RHSExprs);
1982 
1983  /// Get the list of helper destination expressions.
1984  MutableArrayRef<Expr *> getRHSExprs() {
1985  return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
1986  }
1987  ArrayRef<const Expr *> getRHSExprs() const {
1988  return llvm::makeArrayRef(getLHSExprs().end(), varlist_size());
1989  }
1990 
1991  /// Set list of helper reduction expressions, required for proper
1992  /// codegen of the clause. These expressions are binary expressions or
1993  /// operator/custom reduction call that calculates new value from source
1994  /// helper expressions to destination helper expressions.
1995  void setReductionOps(ArrayRef<Expr *> ReductionOps);
1996 
1997  /// Get the list of helper reduction expressions.
1998  MutableArrayRef<Expr *> getReductionOps() {
1999  return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
2000  }
2001  ArrayRef<const Expr *> getReductionOps() const {
2002  return llvm::makeArrayRef(getRHSExprs().end(), varlist_size());
2003  }
2004 
2005 public:
2006  /// Creates clause with a list of variables \a VL.
2007  ///
2008  /// \param StartLoc Starting location of the clause.
2009  /// \param LParenLoc Location of '('.
2010  /// \param ColonLoc Location of ':'.
2011  /// \param EndLoc Ending location of the clause.
2012  /// \param VL The variables in the clause.
2013  /// \param QualifierLoc The nested-name qualifier with location information
2014  /// \param NameInfo The full name info for reduction identifier.
2015  /// \param Privates List of helper expressions for proper generation of
2016  /// private copies.
2017  /// \param LHSExprs List of helper expressions for proper generation of
2018  /// assignment operation required for copyprivate clause. This list represents
2019  /// LHSs of the reduction expressions.
2020  /// \param RHSExprs List of helper expressions for proper generation of
2021  /// assignment operation required for copyprivate clause. This list represents
2022  /// RHSs of the reduction expressions.
2023  /// Also, variables in these expressions are used for proper initialization of
2024  /// reduction copies.
2025  /// \param ReductionOps List of helper expressions that represents reduction
2026  /// expressions:
2027  /// \code
2028  /// LHSExprs binop RHSExprs;
2029  /// operator binop(LHSExpr, RHSExpr);
2030  /// <CutomReduction>(LHSExpr, RHSExpr);
2031  /// \endcode
2032  /// Required for proper codegen of final reduction operation performed by the
2033  /// reduction clause.
2034  /// \param PreInit Statement that must be executed before entering the OpenMP
2035  /// region with this clause.
2036  /// \param PostUpdate Expression that must be executed after exit from the
2037  /// OpenMP region with this clause.
2038  ///
2039  static OMPTaskReductionClause *
2040  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2041  SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
2042  NestedNameSpecifierLoc QualifierLoc,
2043  const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
2044  ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
2045  ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
2046 
2047  /// Creates an empty clause with the place for \a N variables.
2048  ///
2049  /// \param C AST context.
2050  /// \param N The number of variables.
2051  ///
2052  static OMPTaskReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
2053 
2054  /// Gets location of ':' symbol in clause.
2056  /// Gets the name info for specified reduction identifier.
2057  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
2058  /// Gets the nested name specifier.
2059  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2060 
2063  typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
2064  typedef llvm::iterator_range<helper_expr_const_iterator>
2066 
2068  return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
2069  }
2071  return helper_expr_range(getPrivates().begin(), getPrivates().end());
2072  }
2074  return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
2075  }
2077  return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
2078  }
2080  return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
2081  }
2083  return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
2084  }
2086  return helper_expr_const_range(getReductionOps().begin(),
2087  getReductionOps().end());
2088  }
2090  return helper_expr_range(getReductionOps().begin(),
2091  getReductionOps().end());
2092  }
2093 
2095  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2096  reinterpret_cast<Stmt **>(varlist_end()));
2097  }
2098 
2099  static bool classof(const OMPClause *T) {
2100  return T->getClauseKind() == OMPC_task_reduction;
2101  }
2102 };
2103 
2104 /// \brief This represents clause 'linear' in the '#pragma omp ...'
2105 /// directives.
2106 ///
2107 /// \code
2108 /// #pragma omp simd linear(a,b : 2)
2109 /// \endcode
2110 /// In this example directive '#pragma omp simd' has clause 'linear'
2111 /// with variables 'a', 'b' and linear step '2'.
2112 ///
2113 class OMPLinearClause final
2114  : public OMPVarListClause<OMPLinearClause>,
2115  public OMPClauseWithPostUpdate,
2116  private llvm::TrailingObjects<OMPLinearClause, Expr *> {
2117  friend TrailingObjects;
2118  friend OMPVarListClause;
2119  friend class OMPClauseReader;
2120  /// \brief Modifier of 'linear' clause.
2122  /// \brief Location of linear modifier if any.
2124  /// \brief Location of ':'.
2126 
2127  /// \brief Sets the linear step for clause.
2128  void setStep(Expr *Step) { *(getFinals().end()) = Step; }
2129 
2130  /// \brief Sets the expression to calculate linear step for clause.
2131  void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
2132 
2133  /// \brief Build 'linear' clause with given number of variables \a NumVars.
2134  ///
2135  /// \param StartLoc Starting location of the clause.
2136  /// \param LParenLoc Location of '('.
2137  /// \param ColonLoc Location of ':'.
2138  /// \param EndLoc Ending location of the clause.
2139  /// \param NumVars Number of variables.
2140  ///
2141  OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2143  SourceLocation ColonLoc, SourceLocation EndLoc,
2144  unsigned NumVars)
2145  : OMPVarListClause<OMPLinearClause>(OMPC_linear, StartLoc, LParenLoc,
2146  EndLoc, NumVars),
2147  OMPClauseWithPostUpdate(this), Modifier(Modifier),
2148  ModifierLoc(ModifierLoc), ColonLoc(ColonLoc) {}
2149 
2150  /// \brief Build an empty clause.
2151  ///
2152  /// \param NumVars Number of variables.
2153  ///
2154  explicit OMPLinearClause(unsigned NumVars)
2155  : OMPVarListClause<OMPLinearClause>(OMPC_linear, SourceLocation(),
2156  SourceLocation(), SourceLocation(),
2157  NumVars),
2158  OMPClauseWithPostUpdate(this), Modifier(OMPC_LINEAR_val), ModifierLoc(),
2159  ColonLoc() {}
2160 
2161  /// \brief Gets the list of initial values for linear variables.
2162  ///
2163  /// There are NumVars expressions with initial values allocated after the
2164  /// varlist, they are followed by NumVars update expressions (used to update
2165  /// the linear variable's value on current iteration) and they are followed by
2166  /// NumVars final expressions (used to calculate the linear variable's
2167  /// value after the loop body). After these lists, there are 2 helper
2168  /// expressions - linear step and a helper to calculate it before the
2169  /// loop body (used when the linear step is not constant):
2170  ///
2171  /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
2172  /// Finals[]; Step; CalcStep; }
2173  ///
2176  }
2177  ArrayRef<const Expr *> getPrivates() const {
2178  return llvm::makeArrayRef(varlist_end(), varlist_size());
2179  }
2180 
2183  }
2184  ArrayRef<const Expr *> getInits() const {
2185  return llvm::makeArrayRef(getPrivates().end(), varlist_size());
2186  }
2187 
2188  /// \brief Sets the list of update expressions for linear variables.
2190  return MutableArrayRef<Expr *>(getInits().end(), varlist_size());
2191  }
2192  ArrayRef<const Expr *> getUpdates() const {
2193  return llvm::makeArrayRef(getInits().end(), varlist_size());
2194  }
2195 
2196  /// \brief Sets the list of final update expressions for linear variables.
2198  return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size());
2199  }
2200  ArrayRef<const Expr *> getFinals() const {
2201  return llvm::makeArrayRef(getUpdates().end(), varlist_size());
2202  }
2203 
2204  /// \brief Sets the list of the copies of original linear variables.
2205  /// \param PL List of expressions.
2206  void setPrivates(ArrayRef<Expr *> PL);
2207 
2208  /// \brief Sets the list of the initial values for linear variables.
2209  /// \param IL List of expressions.
2210  void setInits(ArrayRef<Expr *> IL);
2211 
2212 public:
2213  /// \brief Creates clause with a list of variables \a VL and a linear step
2214  /// \a Step.
2215  ///
2216  /// \param C AST Context.
2217  /// \param StartLoc Starting location of the clause.
2218  /// \param LParenLoc Location of '('.
2219  /// \param Modifier Modifier of 'linear' clause.
2220  /// \param ModifierLoc Modifier location.
2221  /// \param ColonLoc Location of ':'.
2222  /// \param EndLoc Ending location of the clause.
2223  /// \param VL List of references to the variables.
2224  /// \param PL List of private copies of original variables.
2225  /// \param IL List of initial values for the variables.
2226  /// \param Step Linear step.
2227  /// \param CalcStep Calculation of the linear step.
2228  /// \param PreInit Statement that must be executed before entering the OpenMP
2229  /// region with this clause.
2230  /// \param PostUpdate Expression that must be executed after exit from the
2231  /// OpenMP region with this clause.
2232  static OMPLinearClause *
2233  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2235  SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
2236  ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep,
2237  Stmt *PreInit, Expr *PostUpdate);
2238 
2239  /// \brief Creates an empty clause with the place for \a NumVars variables.
2240  ///
2241  /// \param C AST context.
2242  /// \param NumVars Number of variables.
2243  ///
2244  static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
2245 
2246  /// \brief Set modifier.
2248  /// \brief Return modifier.
2250 
2251  /// \brief Set modifier location.
2253  /// \brief Return modifier location.
2255 
2256  /// \brief Sets the location of ':'.
2257  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2258  /// \brief Returns the location of ':'.
2260 
2261  /// \brief Returns linear step.
2262  Expr *getStep() { return *(getFinals().end()); }
2263  /// \brief Returns linear step.
2264  const Expr *getStep() const { return *(getFinals().end()); }
2265  /// \brief Returns expression to calculate linear step.
2266  Expr *getCalcStep() { return *(getFinals().end() + 1); }
2267  /// \brief Returns expression to calculate linear step.
2268  const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
2269 
2270  /// \brief Sets the list of update expressions for linear variables.
2271  /// \param UL List of expressions.
2272  void setUpdates(ArrayRef<Expr *> UL);
2273 
2274  /// \brief Sets the list of final update expressions for linear variables.
2275  /// \param FL List of expressions.
2276  void setFinals(ArrayRef<Expr *> FL);
2277 
2280  typedef llvm::iterator_range<privates_iterator> privates_range;
2281  typedef llvm::iterator_range<privates_const_iterator> privates_const_range;
2282 
2284  return privates_range(getPrivates().begin(), getPrivates().end());
2285  }
2286  privates_const_range privates() const {
2287  return privates_const_range(getPrivates().begin(), getPrivates().end());
2288  }
2289 
2292  typedef llvm::iterator_range<inits_iterator> inits_range;
2293  typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
2294 
2296  return inits_range(getInits().begin(), getInits().end());
2297  }
2298  inits_const_range inits() const {
2299  return inits_const_range(getInits().begin(), getInits().end());
2300  }
2301 
2304  typedef llvm::iterator_range<updates_iterator> updates_range;
2305  typedef llvm::iterator_range<updates_const_iterator> updates_const_range;
2306 
2308  return updates_range(getUpdates().begin(), getUpdates().end());
2309  }
2310  updates_const_range updates() const {
2311  return updates_const_range(getUpdates().begin(), getUpdates().end());
2312  }
2313 
2316  typedef llvm::iterator_range<finals_iterator> finals_range;
2317  typedef llvm::iterator_range<finals_const_iterator> finals_const_range;
2318 
2320  return finals_range(getFinals().begin(), getFinals().end());
2321  }
2322  finals_const_range finals() const {
2323  return finals_const_range(getFinals().begin(), getFinals().end());
2324  }
2325 
2327  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2328  reinterpret_cast<Stmt **>(varlist_end()));
2329  }
2330 
2331  static bool classof(const OMPClause *T) {
2332  return T->getClauseKind() == OMPC_linear;
2333  }
2334 };
2335 
2336 /// \brief This represents clause 'aligned' in the '#pragma omp ...'
2337 /// directives.
2338 ///
2339 /// \code
2340 /// #pragma omp simd aligned(a,b : 8)
2341 /// \endcode
2342 /// In this example directive '#pragma omp simd' has clause 'aligned'
2343 /// with variables 'a', 'b' and alignment '8'.
2344 ///
2345 class OMPAlignedClause final
2346  : public OMPVarListClause<OMPAlignedClause>,
2347  private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
2348  friend TrailingObjects;
2349  friend OMPVarListClause;
2350  friend class OMPClauseReader;
2351  /// \brief Location of ':'.
2352  SourceLocation ColonLoc;
2353 
2354  /// \brief Sets the alignment for clause.
2355  void setAlignment(Expr *A) { *varlist_end() = A; }
2356 
2357  /// \brief Build 'aligned' clause with given number of variables \a NumVars.
2358  ///
2359  /// \param StartLoc Starting location of the clause.
2360  /// \param LParenLoc Location of '('.
2361  /// \param ColonLoc Location of ':'.
2362  /// \param EndLoc Ending location of the clause.
2363  /// \param NumVars Number of variables.
2364  ///
2365  OMPAlignedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2366  SourceLocation ColonLoc, SourceLocation EndLoc,
2367  unsigned NumVars)
2368  : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, StartLoc, LParenLoc,
2369  EndLoc, NumVars),
2370  ColonLoc(ColonLoc) {}
2371 
2372  /// \brief Build an empty clause.
2373  ///
2374  /// \param NumVars Number of variables.
2375  ///
2376  explicit OMPAlignedClause(unsigned NumVars)
2377  : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, SourceLocation(),
2378  SourceLocation(), SourceLocation(),
2379  NumVars),
2380  ColonLoc(SourceLocation()) {}
2381 
2382 public:
2383  /// \brief Creates clause with a list of variables \a VL and alignment \a A.
2384  ///
2385  /// \param C AST Context.
2386  /// \param StartLoc Starting location of the clause.
2387  /// \param LParenLoc Location of '('.
2388  /// \param ColonLoc Location of ':'.
2389  /// \param EndLoc Ending location of the clause.
2390  /// \param VL List of references to the variables.
2391  /// \param A Alignment.
2392  static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
2393  SourceLocation LParenLoc,
2394  SourceLocation ColonLoc,
2395  SourceLocation EndLoc, ArrayRef<Expr *> VL,
2396  Expr *A);
2397 
2398  /// \brief Creates an empty clause with the place for \a NumVars variables.
2399  ///
2400  /// \param C AST context.
2401  /// \param NumVars Number of variables.
2402  ///
2403  static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
2404 
2405  /// \brief Sets the location of ':'.
2406  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2407  /// \brief Returns the location of ':'.
2408  SourceLocation getColonLoc() const { return ColonLoc; }
2409 
2410  /// \brief Returns alignment.
2411  Expr *getAlignment() { return *varlist_end(); }
2412  /// \brief Returns alignment.
2413  const Expr *getAlignment() const { return *varlist_end(); }
2414 
2415  child_range children() {
2416  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2417  reinterpret_cast<Stmt **>(varlist_end()));
2418  }
2419 
2420  static bool classof(const OMPClause *T) {
2421  return T->getClauseKind() == OMPC_aligned;
2422  }
2423 };
2424 
2425 /// \brief This represents clause 'copyin' in the '#pragma omp ...' directives.
2426 ///
2427 /// \code
2428 /// #pragma omp parallel copyin(a,b)
2429 /// \endcode
2430 /// In this example directive '#pragma omp parallel' has clause 'copyin'
2431 /// with the variables 'a' and 'b'.
2432 ///
2433 class OMPCopyinClause final
2434  : public OMPVarListClause<OMPCopyinClause>,
2435  private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
2436  // Class has 3 additional tail allocated arrays:
2437  // 1. List of helper expressions for proper generation of assignment operation
2438  // required for copyin clause. This list represents sources.
2439  // 2. List of helper expressions for proper generation of assignment operation
2440  // required for copyin clause. This list represents destinations.
2441  // 3. List of helper expressions that represents assignment operation:
2442  // \code
2443  // DstExprs = SrcExprs;
2444  // \endcode
2445  // Required for proper codegen of propagation of master's thread values of
2446  // threadprivate variables to local instances of that variables in other
2447  // implicit threads.
2448 
2449  friend TrailingObjects;
2450  friend OMPVarListClause;
2451  friend class OMPClauseReader;
2452  /// \brief Build clause with number of variables \a N.
2453  ///
2454  /// \param StartLoc Starting location of the clause.
2455  /// \param LParenLoc Location of '('.
2456  /// \param EndLoc Ending location of the clause.
2457  /// \param N Number of the variables in the clause.
2458  ///
2459  OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2460  SourceLocation EndLoc, unsigned N)
2461  : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, StartLoc, LParenLoc,
2462  EndLoc, N) {}
2463 
2464  /// \brief Build an empty clause.
2465  ///
2466  /// \param N Number of variables.
2467  ///
2468  explicit OMPCopyinClause(unsigned N)
2469  : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, SourceLocation(),
2470  SourceLocation(), SourceLocation(),
2471  N) {}
2472 
2473  /// \brief Set list of helper expressions, required for proper codegen of the
2474  /// clause. These expressions represent source expression in the final
2475  /// assignment statement performed by the copyin clause.
2476  void setSourceExprs(ArrayRef<Expr *> SrcExprs);
2477 
2478  /// \brief Get the list of helper source expressions.
2479  MutableArrayRef<Expr *> getSourceExprs() {
2480  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2481  }
2482  ArrayRef<const Expr *> getSourceExprs() const {
2483  return llvm::makeArrayRef(varlist_end(), varlist_size());
2484  }
2485 
2486  /// \brief Set list of helper expressions, required for proper codegen of the
2487  /// clause. These expressions represent destination expression in the final
2488  /// assignment statement performed by the copyin clause.
2489  void setDestinationExprs(ArrayRef<Expr *> DstExprs);
2490 
2491  /// \brief Get the list of helper destination expressions.
2492  MutableArrayRef<Expr *> getDestinationExprs() {
2493  return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
2494  }
2495  ArrayRef<const Expr *> getDestinationExprs() const {
2496  return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
2497  }
2498 
2499  /// \brief Set list of helper assignment expressions, required for proper
2500  /// codegen of the clause. These expressions are assignment expressions that
2501  /// assign source helper expressions to destination helper expressions
2502  /// correspondingly.
2503  void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
2504 
2505  /// \brief Get the list of helper assignment expressions.
2506  MutableArrayRef<Expr *> getAssignmentOps() {
2507  return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
2508  }
2509  ArrayRef<const Expr *> getAssignmentOps() const {
2510  return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
2511  }
2512 
2513 public:
2514  /// \brief Creates clause with a list of variables \a VL.
2515  ///
2516  /// \param C AST context.
2517  /// \param StartLoc Starting location of the clause.
2518  /// \param LParenLoc Location of '('.
2519  /// \param EndLoc Ending location of the clause.
2520  /// \param VL List of references to the variables.
2521  /// \param SrcExprs List of helper expressions for proper generation of
2522  /// assignment operation required for copyin clause. This list represents
2523  /// sources.
2524  /// \param DstExprs List of helper expressions for proper generation of
2525  /// assignment operation required for copyin clause. This list represents
2526  /// destinations.
2527  /// \param AssignmentOps List of helper expressions that represents assignment
2528  /// operation:
2529  /// \code
2530  /// DstExprs = SrcExprs;
2531  /// \endcode
2532  /// Required for proper codegen of propagation of master's thread values of
2533  /// threadprivate variables to local instances of that variables in other
2534  /// implicit threads.
2535  ///
2536  static OMPCopyinClause *
2537  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2538  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
2539  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
2540  /// \brief Creates an empty clause with \a N variables.
2541  ///
2542  /// \param C AST context.
2543  /// \param N The number of variables.
2544  ///
2545  static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
2546 
2547  typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
2548  typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
2549  typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
2550  typedef llvm::iterator_range<helper_expr_const_iterator>
2552 
2554  return helper_expr_const_range(getSourceExprs().begin(),
2555  getSourceExprs().end());
2556  }
2558  return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
2559  }
2561  return helper_expr_const_range(getDestinationExprs().begin(),
2562  getDestinationExprs().end());
2563  }
2565  return helper_expr_range(getDestinationExprs().begin(),
2566  getDestinationExprs().end());
2567  }
2569  return helper_expr_const_range(getAssignmentOps().begin(),
2570  getAssignmentOps().end());
2571  }
2573  return helper_expr_range(getAssignmentOps().begin(),
2574  getAssignmentOps().end());
2575  }
2576 
2577  child_range children() {
2578  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2579  reinterpret_cast<Stmt **>(varlist_end()));
2580  }
2581 
2582  static bool classof(const OMPClause *T) {
2583  return T->getClauseKind() == OMPC_copyin;
2584  }
2585 };
2586 
2587 /// \brief This represents clause 'copyprivate' in the '#pragma omp ...'
2588 /// directives.
2589 ///
2590 /// \code
2591 /// #pragma omp single copyprivate(a,b)
2592 /// \endcode
2593 /// In this example directive '#pragma omp single' has clause 'copyprivate'
2594 /// with the variables 'a' and 'b'.
2595 ///
2597  : public OMPVarListClause<OMPCopyprivateClause>,
2598  private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
2599  friend TrailingObjects;
2600  friend OMPVarListClause;
2601  friend class OMPClauseReader;
2602  /// \brief Build clause with number of variables \a N.
2603  ///
2604  /// \param StartLoc Starting location of the clause.
2605  /// \param LParenLoc Location of '('.
2606  /// \param EndLoc Ending location of the clause.
2607  /// \param N Number of the variables in the clause.
2608  ///
2609  OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2610  SourceLocation EndLoc, unsigned N)
2611  : OMPVarListClause<OMPCopyprivateClause>(OMPC_copyprivate, StartLoc,
2612  LParenLoc, EndLoc, N) {}
2613 
2614  /// \brief Build an empty clause.
2615  ///
2616  /// \param N Number of variables.
2617  ///
2618  explicit OMPCopyprivateClause(unsigned N)
2620  OMPC_copyprivate, SourceLocation(), SourceLocation(),
2621  SourceLocation(), N) {}
2622 
2623  /// \brief Set list of helper expressions, required for proper codegen of the
2624  /// clause. These expressions represent source expression in the final
2625  /// assignment statement performed by the copyprivate clause.
2626  void setSourceExprs(ArrayRef<Expr *> SrcExprs);
2627 
2628  /// \brief Get the list of helper source expressions.
2629  MutableArrayRef<Expr *> getSourceExprs() {
2630  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2631  }
2632  ArrayRef<const Expr *> getSourceExprs() const {
2633  return llvm::makeArrayRef(varlist_end(), varlist_size());
2634  }
2635 
2636  /// \brief Set list of helper expressions, required for proper codegen of the
2637  /// clause. These expressions represent destination expression in the final
2638  /// assignment statement performed by the copyprivate clause.
2639  void setDestinationExprs(ArrayRef<Expr *> DstExprs);
2640 
2641  /// \brief Get the list of helper destination expressions.
2642  MutableArrayRef<Expr *> getDestinationExprs() {
2643  return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
2644  }
2645  ArrayRef<const Expr *> getDestinationExprs() const {
2646  return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
2647  }
2648 
2649  /// \brief Set list of helper assignment expressions, required for proper
2650  /// codegen of the clause. These expressions are assignment expressions that
2651  /// assign source helper expressions to destination helper expressions
2652  /// correspondingly.
2653  void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
2654 
2655  /// \brief Get the list of helper assignment expressions.
2656  MutableArrayRef<Expr *> getAssignmentOps() {
2657  return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
2658  }
2659  ArrayRef<const Expr *> getAssignmentOps() const {
2660  return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
2661  }
2662 
2663 public:
2664  /// \brief Creates clause with a list of variables \a VL.
2665  ///
2666  /// \param C AST context.
2667  /// \param StartLoc Starting location of the clause.
2668  /// \param LParenLoc Location of '('.
2669  /// \param EndLoc Ending location of the clause.
2670  /// \param VL List of references to the variables.
2671  /// \param SrcExprs List of helper expressions for proper generation of
2672  /// assignment operation required for copyprivate clause. This list represents
2673  /// sources.
2674  /// \param DstExprs List of helper expressions for proper generation of
2675  /// assignment operation required for copyprivate clause. This list represents
2676  /// destinations.
2677  /// \param AssignmentOps List of helper expressions that represents assignment
2678  /// operation:
2679  /// \code
2680  /// DstExprs = SrcExprs;
2681  /// \endcode
2682  /// Required for proper codegen of final assignment performed by the
2683  /// copyprivate clause.
2684  ///
2685  static OMPCopyprivateClause *
2686  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2687  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
2688  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
2689  /// \brief Creates an empty clause with \a N variables.
2690  ///
2691  /// \param C AST context.
2692  /// \param N The number of variables.
2693  ///
2694  static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
2695 
2696  typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
2697  typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
2698  typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
2699  typedef llvm::iterator_range<helper_expr_const_iterator>
2701 
2703  return helper_expr_const_range(getSourceExprs().begin(),
2704  getSourceExprs().end());
2705  }
2707  return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
2708  }
2710  return helper_expr_const_range(getDestinationExprs().begin(),
2711  getDestinationExprs().end());
2712  }
2714  return helper_expr_range(getDestinationExprs().begin(),
2715  getDestinationExprs().end());
2716  }
2718  return helper_expr_const_range(getAssignmentOps().begin(),
2719  getAssignmentOps().end());
2720  }
2722  return helper_expr_range(getAssignmentOps().begin(),
2723  getAssignmentOps().end());
2724  }
2725 
2726  child_range children() {
2727  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2728  reinterpret_cast<Stmt **>(varlist_end()));
2729  }
2730 
2731  static bool classof(const OMPClause *T) {
2732  return T->getClauseKind() == OMPC_copyprivate;
2733  }
2734 };
2735 
2736 /// \brief This represents implicit clause 'flush' for the '#pragma omp flush'
2737 /// directive.
2738 /// This clause does not exist by itself, it can be only as a part of 'omp
2739 /// flush' directive. This clause is introduced to keep the original structure
2740 /// of \a OMPExecutableDirective class and its derivatives and to use the
2741 /// existing infrastructure of clauses with the list of variables.
2742 ///
2743 /// \code
2744 /// #pragma omp flush(a,b)
2745 /// \endcode
2746 /// In this example directive '#pragma omp flush' has implicit clause 'flush'
2747 /// with the variables 'a' and 'b'.
2748 ///
2749 class OMPFlushClause final
2750  : public OMPVarListClause<OMPFlushClause>,
2751  private llvm::TrailingObjects<OMPFlushClause, Expr *> {
2752  friend TrailingObjects;
2753  friend OMPVarListClause;
2754  /// \brief Build clause with number of variables \a N.
2755  ///
2756  /// \param StartLoc Starting location of the clause.
2757  /// \param LParenLoc Location of '('.
2758  /// \param EndLoc Ending location of the clause.
2759  /// \param N Number of the variables in the clause.
2760  ///
2761  OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2762  SourceLocation EndLoc, unsigned N)
2763  : OMPVarListClause<OMPFlushClause>(OMPC_flush, StartLoc, LParenLoc,
2764  EndLoc, N) {}
2765 
2766  /// \brief Build an empty clause.
2767  ///
2768  /// \param N Number of variables.
2769  ///
2770  explicit OMPFlushClause(unsigned N)
2771  : OMPVarListClause<OMPFlushClause>(OMPC_flush, SourceLocation(),
2772  SourceLocation(), SourceLocation(),
2773  N) {}
2774 
2775 public:
2776  /// \brief Creates clause with a list of variables \a VL.
2777  ///
2778  /// \param C AST context.
2779  /// \param StartLoc Starting location of the clause.
2780  /// \param LParenLoc Location of '('.
2781  /// \param EndLoc Ending location of the clause.
2782  /// \param VL List of references to the variables.
2783  ///
2784  static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
2785  SourceLocation LParenLoc, SourceLocation EndLoc,
2786  ArrayRef<Expr *> VL);
2787  /// \brief Creates an empty clause with \a N variables.
2788  ///
2789  /// \param C AST context.
2790  /// \param N The number of variables.
2791  ///
2792  static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
2793 
2794  child_range children() {
2795  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2796  reinterpret_cast<Stmt **>(varlist_end()));
2797  }
2798 
2799  static bool classof(const OMPClause *T) {
2800  return T->getClauseKind() == OMPC_flush;
2801  }
2802 };
2803 
2804 /// \brief This represents implicit clause 'depend' for the '#pragma omp task'
2805 /// directive.
2806 ///
2807 /// \code
2808 /// #pragma omp task depend(in:a,b)
2809 /// \endcode
2810 /// In this example directive '#pragma omp task' with clause 'depend' with the
2811 /// variables 'a' and 'b' with dependency 'in'.
2812 ///
2813 class OMPDependClause final
2814  : public OMPVarListClause<OMPDependClause>,
2815  private llvm::TrailingObjects<OMPDependClause, Expr *> {
2816  friend TrailingObjects;
2817  friend OMPVarListClause;
2818  friend class OMPClauseReader;
2819  /// \brief Dependency type (one of in, out, inout).
2820  OpenMPDependClauseKind DepKind;
2821  /// \brief Dependency type location.
2822  SourceLocation DepLoc;
2823  /// \brief Colon location.
2824  SourceLocation ColonLoc;
2825  /// \brief Build clause with number of variables \a N.
2826  ///
2827  /// \param StartLoc Starting location of the clause.
2828  /// \param LParenLoc Location of '('.
2829  /// \param EndLoc Ending location of the clause.
2830  /// \param N Number of the variables in the clause.
2831  ///
2832  OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2833  SourceLocation EndLoc, unsigned N)
2834  : OMPVarListClause<OMPDependClause>(OMPC_depend, StartLoc, LParenLoc,
2835  EndLoc, N),
2836  DepKind(OMPC_DEPEND_unknown) {}
2837 
2838  /// \brief Build an empty clause.
2839  ///
2840  /// \param N Number of variables.
2841  ///
2842  explicit OMPDependClause(unsigned N)
2843  : OMPVarListClause<OMPDependClause>(OMPC_depend, SourceLocation(),
2844  SourceLocation(), SourceLocation(),
2845  N),
2846  DepKind(OMPC_DEPEND_unknown) {}
2847  /// \brief Set dependency kind.
2848  void setDependencyKind(OpenMPDependClauseKind K) { DepKind = K; }
2849 
2850  /// \brief Set dependency kind and its location.
2851  void setDependencyLoc(SourceLocation Loc) { DepLoc = Loc; }
2852 
2853  /// \brief Set colon location.
2854  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2855 
2856 public:
2857  /// \brief Creates clause with a list of variables \a VL.
2858  ///
2859  /// \param C AST context.
2860  /// \param StartLoc Starting location of the clause.
2861  /// \param LParenLoc Location of '('.
2862  /// \param EndLoc Ending location of the clause.
2863  /// \param DepKind Dependency type.
2864  /// \param DepLoc Location of the dependency type.
2865  /// \param ColonLoc Colon location.
2866  /// \param VL List of references to the variables.
2867  static OMPDependClause *
2868  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2869  SourceLocation EndLoc, OpenMPDependClauseKind DepKind,
2870  SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL);
2871  /// \brief Creates an empty clause with \a N variables.
2872  ///
2873  /// \param C AST context.
2874  /// \param N The number of variables.
2875  ///
2876  static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N);
2877 
2878  /// \brief Get dependency type.
2879  OpenMPDependClauseKind getDependencyKind() const { return DepKind; }
2880  /// \brief Get dependency type location.
2881  SourceLocation getDependencyLoc() const { return DepLoc; }
2882  /// \brief Get colon location.
2883  SourceLocation getColonLoc() const { return ColonLoc; }
2884 
2885  /// Set the loop counter value for the depend clauses with 'sink|source' kind
2886  /// of dependency. Required for codegen.
2887  void setCounterValue(Expr *V);
2888  /// Get the loop counter value.
2889  Expr *getCounterValue();
2890  /// Get the loop counter value.
2891  const Expr *getCounterValue() const;
2892 
2893  child_range children() {
2894  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2895  reinterpret_cast<Stmt **>(varlist_end()));
2896  }
2897 
2898  static bool classof(const OMPClause *T) {
2899  return T->getClauseKind() == OMPC_depend;
2900  }
2901 };
2902 
2903 /// \brief This represents 'device' clause in the '#pragma omp ...'
2904 /// directive.
2905 ///
2906 /// \code
2907 /// #pragma omp target device(a)
2908 /// \endcode
2909 /// In this example directive '#pragma omp target' has clause 'device'
2910 /// with single expression 'a'.
2911 ///
2912 class OMPDeviceClause : public OMPClause {
2913  friend class OMPClauseReader;
2914  /// \brief Location of '('.
2915  SourceLocation LParenLoc;
2916  /// \brief Device number.
2917  Stmt *Device;
2918  /// \brief Set the device number.
2919  ///
2920  /// \param E Device number.
2921  ///
2922  void setDevice(Expr *E) { Device = E; }
2923 
2924 public:
2925  /// \brief Build 'device' clause.
2926  ///
2927  /// \param E Expression associated with this clause.
2928  /// \param StartLoc Starting location of the clause.
2929  /// \param LParenLoc Location of '('.
2930  /// \param EndLoc Ending location of the clause.
2931  ///
2932  OMPDeviceClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc,
2933  SourceLocation EndLoc)
2934  : OMPClause(OMPC_device, StartLoc, EndLoc), LParenLoc(LParenLoc),
2935  Device(E) {}
2936 
2937  /// \brief Build an empty clause.
2938  ///
2940  : OMPClause(OMPC_device, SourceLocation(), SourceLocation()),
2941  LParenLoc(SourceLocation()), Device(nullptr) {}
2942  /// \brief Sets the location of '('.
2943  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2944  /// \brief Returns the location of '('.
2945  SourceLocation getLParenLoc() const { return LParenLoc; }
2946  /// \brief Return device number.
2947  Expr *getDevice() { return cast<Expr>(Device); }
2948  /// \brief Return device number.
2949  Expr *getDevice() const { return cast<Expr>(Device); }
2950 
2951  static bool classof(const OMPClause *T) {
2952  return T->getClauseKind() == OMPC_device;
2953  }
2954 
2955  child_range children() { return child_range(&Device, &Device + 1); }
2956 };
2957 
2958 /// \brief This represents 'threads' clause in the '#pragma omp ...' directive.
2959 ///
2960 /// \code
2961 /// #pragma omp ordered threads
2962 /// \endcode
2963 /// In this example directive '#pragma omp ordered' has simple 'threads' clause.
2964 ///
2965 class OMPThreadsClause : public OMPClause {
2966 public:
2967  /// \brief Build 'threads' clause.
2968  ///
2969  /// \param StartLoc Starting location of the clause.
2970  /// \param EndLoc Ending location of the clause.
2971  ///
2972  OMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc)
2973  : OMPClause(OMPC_threads, StartLoc, EndLoc) {}
2974 
2975  /// \brief Build an empty clause.
2976  ///
2978  : OMPClause(OMPC_threads, SourceLocation(), SourceLocation()) {}
2979 
2980  static bool classof(const OMPClause *T) {
2981  return T->getClauseKind() == OMPC_threads;
2982  }
2983 
2984  child_range children() {
2985  return child_range(child_iterator(), child_iterator());
2986  }
2987 };
2988 
2989 /// \brief This represents 'simd' clause in the '#pragma omp ...' directive.
2990 ///
2991 /// \code
2992 /// #pragma omp ordered simd
2993 /// \endcode
2994 /// In this example directive '#pragma omp ordered' has simple 'simd' clause.
2995 ///
2996 class OMPSIMDClause : public OMPClause {
2997 public:
2998  /// \brief Build 'simd' clause.
2999  ///
3000  /// \param StartLoc Starting location of the clause.
3001  /// \param EndLoc Ending location of the clause.
3002  ///
3003  OMPSIMDClause(SourceLocation StartLoc, SourceLocation EndLoc)
3004  : OMPClause(OMPC_simd, StartLoc, EndLoc) {}
3005 
3006  /// \brief Build an empty clause.
3007  ///
3008  OMPSIMDClause() : OMPClause(OMPC_simd, SourceLocation(), SourceLocation()) {}
3009 
3010  static bool classof(const OMPClause *T) {
3011  return T->getClauseKind() == OMPC_simd;
3012  }
3013 
3014  child_range children() {
3015  return child_range(child_iterator(), child_iterator());
3016  }
3017 };
3018 
3019 /// \brief Struct that defines common infrastructure to handle mappable
3020 /// expressions used in OpenMP clauses.
3022 public:
3023  // \brief Class that represents a component of a mappable expression. E.g.
3024  // for an expression S.a, the first component is a declaration reference
3025  // expression associated with 'S' and the second is a member expression
3026  // associated with the field declaration 'a'. If the expression is an array
3027  // subscript it may not have any associated declaration. In that case the
3028  // associated declaration is set to nullptr.
3030  // \brief Expression associated with the component.
3031  Expr *AssociatedExpression = nullptr;
3032  // \brief Declaration associated with the declaration. If the component does
3033  // not have a declaration (e.g. array subscripts or section), this is set to
3034  // nullptr.
3035  ValueDecl *AssociatedDeclaration = nullptr;
3036 
3037  public:
3038  explicit MappableComponent() {}
3039  explicit MappableComponent(Expr *AssociatedExpression,
3040  ValueDecl *AssociatedDeclaration)
3041  : AssociatedExpression(AssociatedExpression),
3042  AssociatedDeclaration(
3043  AssociatedDeclaration
3044  ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
3045  : nullptr) {}
3046 
3047  Expr *getAssociatedExpression() const { return AssociatedExpression; }
3048  ValueDecl *getAssociatedDeclaration() const {
3049  return AssociatedDeclaration;
3050  }
3051  };
3052 
3053  // \brief List of components of an expression. This first one is the whole
3054  // expression and the last one is the base expression.
3055  typedef SmallVector<MappableComponent, 8> MappableExprComponentList;
3056  typedef ArrayRef<MappableComponent> MappableExprComponentListRef;
3057 
3058  // \brief List of all component lists associated to the same base declaration.
3059  // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
3060  // their component list but the same base declaration 'S'.
3061  typedef SmallVector<MappableExprComponentList, 8> MappableExprComponentLists;
3062  typedef ArrayRef<MappableExprComponentList> MappableExprComponentListsRef;
3063 
3064 protected:
3065  // \brief Return the total number of elements in a list of component lists.
3066  static unsigned
3067  getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists);
3068 
3069  // \brief Return the total number of elements in a list of declarations. All
3070  // declarations are expected to be canonical.
3071  static unsigned
3072  getUniqueDeclarationsTotalNumber(ArrayRef<ValueDecl *> Declarations);
3073 };
3074 
3075 /// \brief This represents clauses with a list of expressions that are mappable.
3076 /// Examples of these clauses are 'map' in
3077 /// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
3078 /// in '#pragma omp target update...' directives.
3079 template <class T>
3082  friend class OMPClauseReader;
3083 
3084  /// \brief Number of unique declarations in this clause.
3085  unsigned NumUniqueDeclarations;
3086 
3087  /// \brief Number of component lists in this clause.
3088  unsigned NumComponentLists;
3089 
3090  /// \brief Total number of components in this clause.
3091  unsigned NumComponents;
3092 
3093 protected:
3094  /// \brief Get the unique declarations that are in the trailing objects of the
3095  /// class.
3096  MutableArrayRef<ValueDecl *> getUniqueDeclsRef() {
3097  return MutableArrayRef<ValueDecl *>(
3098  static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(),
3099  NumUniqueDeclarations);
3100  }
3101 
3102  /// \brief Get the unique declarations that are in the trailing objects of the
3103  /// class.
3104  ArrayRef<ValueDecl *> getUniqueDeclsRef() const {
3105  return ArrayRef<ValueDecl *>(
3106  static_cast<const T *>(this)
3107  ->template getTrailingObjects<ValueDecl *>(),
3108  NumUniqueDeclarations);
3109  }
3110 
3111  /// \brief Set the unique declarations that are in the trailing objects of the
3112  /// class.
3113  void setUniqueDecls(ArrayRef<ValueDecl *> UDs) {
3114  assert(UDs.size() == NumUniqueDeclarations &&
3115  "Unexpected amount of unique declarations.");
3116  std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin());
3117  }
3118 
3119  /// \brief Get the number of lists per declaration that are in the trailing
3120  /// objects of the class.
3121  MutableArrayRef<unsigned> getDeclNumListsRef() {
3122  return MutableArrayRef<unsigned>(
3123  static_cast<T *>(this)->template getTrailingObjects<unsigned>(),
3124  NumUniqueDeclarations);
3125  }
3126 
3127  /// \brief Get the number of lists per declaration that are in the trailing
3128  /// objects of the class.
3129  ArrayRef<unsigned> getDeclNumListsRef() const {
3130  return ArrayRef<unsigned>(
3131  static_cast<const T *>(this)->template getTrailingObjects<unsigned>(),
3132  NumUniqueDeclarations);
3133  }
3134 
3135  /// \brief Set the number of lists per declaration that are in the trailing
3136  /// objects of the class.
3137  void setDeclNumLists(ArrayRef<unsigned> DNLs) {
3138  assert(DNLs.size() == NumUniqueDeclarations &&
3139  "Unexpected amount of list numbers.");
3140  std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin());
3141  }
3142 
3143  /// \brief Get the cumulative component lists sizes that are in the trailing
3144  /// objects of the class. They are appended after the number of lists.
3145  MutableArrayRef<unsigned> getComponentListSizesRef() {
3146  return MutableArrayRef<unsigned>(
3147  static_cast<T *>(this)->template getTrailingObjects<unsigned>() +
3148  NumUniqueDeclarations,
3149  NumComponentLists);
3150  }
3151 
3152  /// \brief Get the cumulative component lists sizes that are in the trailing
3153  /// objects of the class. They are appended after the number of lists.
3154  ArrayRef<unsigned> getComponentListSizesRef() const {
3155  return ArrayRef<unsigned>(
3156  static_cast<const T *>(this)->template getTrailingObjects<unsigned>() +
3157  NumUniqueDeclarations,
3158  NumComponentLists);
3159  }
3160 
3161  /// \brief Set the cumulative component lists sizes that are in the trailing
3162  /// objects of the class.
3163  void setComponentListSizes(ArrayRef<unsigned> CLSs) {
3164  assert(CLSs.size() == NumComponentLists &&
3165  "Unexpected amount of component lists.");
3166  std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin());
3167  }
3168 
3169  /// \brief Get the components that are in the trailing objects of the class.
3170  MutableArrayRef<MappableComponent> getComponentsRef() {
3171  return MutableArrayRef<MappableComponent>(
3172  static_cast<T *>(this)
3173  ->template getTrailingObjects<MappableComponent>(),
3174  NumComponents);
3175  }
3176 
3177  /// \brief Get the components that are in the trailing objects of the class.
3178  ArrayRef<MappableComponent> getComponentsRef() const {
3179  return ArrayRef<MappableComponent>(
3180  static_cast<const T *>(this)
3181  ->template getTrailingObjects<MappableComponent>(),
3182  NumComponents);
3183  }
3184 
3185  /// \brief Set the components that are in the trailing objects of the class.
3186  /// This requires the list sizes so that it can also fill the original
3187  /// expressions, which are the first component of each list.
3188  void setComponents(ArrayRef<MappableComponent> Components,
3189  ArrayRef<unsigned> CLSs) {
3190  assert(Components.size() == NumComponents &&
3191  "Unexpected amount of component lists.");
3192  assert(CLSs.size() == NumComponentLists &&
3193  "Unexpected amount of list sizes.");
3194  std::copy(Components.begin(), Components.end(), getComponentsRef().begin());
3195  }
3196 
3197  /// \brief Fill the clause information from the list of declarations and
3198  /// associated component lists.
3199  void setClauseInfo(ArrayRef<ValueDecl *> Declarations,
3200  MappableExprComponentListsRef ComponentLists) {
3201  // Perform some checks to make sure the data sizes are consistent with the
3202  // information available when the clause was created.
3203  assert(getUniqueDeclarationsTotalNumber(Declarations) ==
3204  NumUniqueDeclarations &&
3205  "Unexpected number of mappable expression info entries!");
3206  assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
3207  "Unexpected total number of components!");
3208  assert(Declarations.size() == ComponentLists.size() &&
3209  "Declaration and component lists size is not consistent!");
3210  assert(Declarations.size() == NumComponentLists &&
3211  "Unexpected declaration and component lists size!");
3212 
3213  // Organize the components by declaration and retrieve the original
3214  // expression. Original expressions are always the first component of the
3215  // mappable component list.
3216  llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
3217  ComponentListMap;
3218  {
3219  auto CI = ComponentLists.begin();
3220  for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
3221  ++DI, ++CI) {
3222  assert(!CI->empty() && "Invalid component list!");
3223  ComponentListMap[*DI].push_back(*CI);
3224  }
3225  }
3226 
3227  // Iterators of the target storage.
3228  auto UniqueDeclarations = getUniqueDeclsRef();
3229  auto UDI = UniqueDeclarations.begin();
3230 
3231  auto DeclNumLists = getDeclNumListsRef();
3232  auto DNLI = DeclNumLists.begin();
3233 
3234  auto ComponentListSizes = getComponentListSizesRef();
3235  auto CLSI = ComponentListSizes.begin();
3236 
3237  auto Components = getComponentsRef();
3238  auto CI = Components.begin();
3239 
3240  // Variable to compute the accumulation of the number of components.
3241  unsigned PrevSize = 0u;
3242 
3243  // Scan all the declarations and associated component lists.
3244  for (auto &M : ComponentListMap) {
3245  // The declaration.
3246  auto *D = M.first;
3247  // The component lists.
3248  auto CL = M.second;
3249 
3250  // Initialize the entry.
3251  *UDI = D;
3252  ++UDI;
3253 
3254  *DNLI = CL.size();
3255  ++DNLI;
3256 
3257  // Obtain the cumulative sizes and concatenate all the components in the
3258  // reserved storage.
3259  for (auto C : CL) {
3260  // Accumulate with the previous size.
3261  PrevSize += C.size();
3262 
3263  // Save the size.
3264  *CLSI = PrevSize;
3265  ++CLSI;
3266 
3267  // Append components after the current components iterator.
3268  CI = std::copy(C.begin(), C.end(), CI);
3269  }
3270  }
3271  }
3272 
3273  /// \brief Build a clause for \a NumUniqueDeclarations declarations, \a
3274  /// NumComponentLists total component lists, and \a NumComponents total
3275  /// components.
3276  ///
3277  /// \param K Kind of the clause.
3278  /// \param StartLoc Starting location of the clause (the clause keyword).
3279  /// \param LParenLoc Location of '('.
3280  /// \param EndLoc Ending location of the clause.
3281  /// \param NumVars Number of expressions listed in the clause.
3282  /// \param NumUniqueDeclarations Number of unique base declarations in this
3283  /// clause.
3284  /// \param NumComponentLists Number of component lists in this clause - one
3285  /// list for each expression in the clause.
3286  /// \param NumComponents Total number of expression components in the clause.
3287  ///
3288  OMPMappableExprListClause(OpenMPClauseKind K, SourceLocation StartLoc,
3289  SourceLocation LParenLoc, SourceLocation EndLoc,
3290  unsigned NumVars, unsigned NumUniqueDeclarations,
3291  unsigned NumComponentLists, unsigned NumComponents)
3292  : OMPVarListClause<T>(K, StartLoc, LParenLoc, EndLoc, NumVars),
3293  NumUniqueDeclarations(NumUniqueDeclarations),
3294  NumComponentLists(NumComponentLists), NumComponents(NumComponents) {}
3295 
3296 public:
3297  /// \brief Return the number of unique base declarations in this clause.
3298  unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
3299  /// \brief Return the number of lists derived from the clause expressions.
3300  unsigned getTotalComponentListNum() const { return NumComponentLists; }
3301  /// \brief Return the total number of components in all lists derived from the
3302  /// clause.
3303  unsigned getTotalComponentsNum() const { return NumComponents; }
3304 
3305  /// \brief Iterator that browse the components by lists. It also allows
3306  /// browsing components of a single declaration.
3308  : public llvm::iterator_adaptor_base<
3309  const_component_lists_iterator,
3310  MappableExprComponentListRef::const_iterator,
3311  std::forward_iterator_tag, MappableComponent, ptrdiff_t,
3312  MappableComponent, MappableComponent> {
3313  // The declaration the iterator currently refers to.
3314  ArrayRef<ValueDecl *>::iterator DeclCur;
3315 
3316  // The list number associated with the current declaration.
3317  ArrayRef<unsigned>::iterator NumListsCur;
3318 
3319  // Remaining lists for the current declaration.
3320  unsigned RemainingLists;
3321 
3322  // The cumulative size of the previous list, or zero if there is no previous
3323  // list.
3324  unsigned PrevListSize;
3325 
3326  // The cumulative sizes of the current list - it will delimit the remaining
3327  // range of interest.
3328  ArrayRef<unsigned>::const_iterator ListSizeCur;
3329  ArrayRef<unsigned>::const_iterator ListSizeEnd;
3330 
3331  // Iterator to the end of the components storage.
3332  MappableExprComponentListRef::const_iterator End;
3333 
3334  public:
3335  /// \brief Construct an iterator that scans all lists.
3337  ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
3338  ArrayRef<unsigned> CumulativeListSizes,
3339  MappableExprComponentListRef Components)
3340  : const_component_lists_iterator::iterator_adaptor_base(
3341  Components.begin()),
3342  DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
3343  RemainingLists(0u), PrevListSize(0u),
3344  ListSizeCur(CumulativeListSizes.begin()),
3345  ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
3346  assert(UniqueDecls.size() == DeclsListNum.size() &&
3347  "Inconsistent number of declarations and list sizes!");
3348  if (!DeclsListNum.empty())
3349  RemainingLists = *NumListsCur;
3350  }
3351 
3352  /// \brief Construct an iterator that scan lists for a given declaration \a
3353  /// Declaration.
3355  const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
3356  ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
3357  MappableExprComponentListRef Components)
3358  : const_component_lists_iterator(UniqueDecls, DeclsListNum,
3359  CumulativeListSizes, Components) {
3360 
3361  // Look for the desired declaration. While we are looking for it, we
3362  // update the state so that we know the component where a given list
3363  // starts.
3364  for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
3365  if (*DeclCur == Declaration)
3366  break;
3367 
3368  assert(*NumListsCur > 0 && "No lists associated with declaration??");
3369 
3370  // Skip the lists associated with the current declaration, but save the
3371  // last list size that was skipped.
3372  std::advance(ListSizeCur, *NumListsCur - 1);
3373  PrevListSize = *ListSizeCur;
3374  ++ListSizeCur;
3375  }
3376 
3377  // If we didn't find any declaration, advance the iterator to after the
3378  // last component and set remaining lists to zero.
3379  if (ListSizeCur == CumulativeListSizes.end()) {
3380  this->I = End;
3381  RemainingLists = 0u;
3382  return;
3383  }
3384 
3385  // Set the remaining lists with the total number of lists of the current
3386  // declaration.
3387  RemainingLists = *NumListsCur;
3388 
3389  // Adjust the list size end iterator to the end of the relevant range.
3390  ListSizeEnd = ListSizeCur;
3391  std::advance(ListSizeEnd, RemainingLists);
3392 
3393  // Given that the list sizes are cumulative, the index of the component
3394  // that start the list is the size of the previous list.
3395  std::advance(this->I, PrevListSize);
3396  }
3397 
3398  // Return the array with the current list. The sizes are cumulative, so the
3399  // array size is the difference between the current size and previous one.
3400  std::pair<const ValueDecl *, MappableExprComponentListRef>
3401  operator*() const {
3402  assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
3403  return std::make_pair(
3404  *DeclCur,
3405  MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize));
3406  }
3407  std::pair<const ValueDecl *, MappableExprComponentListRef>
3408  operator->() const {
3409  return **this;
3410  }
3411 
3412  // Skip the components of the current list.
3414  assert(ListSizeCur != ListSizeEnd && RemainingLists &&
3415  "Invalid iterator!");
3416 
3417  // If we don't have more lists just skip all the components. Otherwise,
3418  // advance the iterator by the number of components in the current list.
3419  if (std::next(ListSizeCur) == ListSizeEnd) {
3420  this->I = End;
3421  RemainingLists = 0;
3422  } else {
3423  std::advance(this->I, *ListSizeCur - PrevListSize);
3424  PrevListSize = *ListSizeCur;
3425 
3426  // We are done with a declaration, move to the next one.
3427  if (!(--RemainingLists)) {
3428  ++DeclCur;
3429  ++NumListsCur;
3430  RemainingLists = *NumListsCur;
3431  assert(RemainingLists && "No lists in the following declaration??");
3432  }
3433  }
3434 
3435  ++ListSizeCur;
3436  return *this;
3437  }
3438  };
3439 
3440  typedef llvm::iterator_range<const_component_lists_iterator>
3442 
3443  /// \brief Iterators for all component lists.
3444  const_component_lists_iterator component_lists_begin() const {
3445  return const_component_lists_iterator(
3446  getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(),
3447  getComponentsRef());
3448  }
3449  const_component_lists_iterator component_lists_end() const {
3450  return const_component_lists_iterator(
3451  ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(),
3452  MappableExprComponentListRef(getComponentsRef().end(),
3453  getComponentsRef().end()));
3454  }
3456  return {component_lists_begin(), component_lists_end()};
3457  }
3458 
3459  /// \brief Iterators for component lists associated with the provided
3460  /// declaration.
3461  const_component_lists_iterator
3462  decl_component_lists_begin(const ValueDecl *VD) const {
3463  return const_component_lists_iterator(
3464  VD, getUniqueDeclsRef(), getDeclNumListsRef(),
3465  getComponentListSizesRef(), getComponentsRef());
3466  }
3467  const_component_lists_iterator decl_component_lists_end() const {
3468  return component_lists_end();
3469  }
3471  return {decl_component_lists_begin(VD), decl_component_lists_end()};
3472  }
3473 
3474  /// Iterators to access all the declarations, number of lists, list sizes, and
3475  /// components.
3476  typedef ArrayRef<ValueDecl *>::iterator const_all_decls_iterator;
3477  typedef llvm::iterator_range<const_all_decls_iterator> const_all_decls_range;
3479  auto A = getUniqueDeclsRef();
3480  return const_all_decls_range(A.begin(), A.end());
3481  }
3482 
3483  typedef ArrayRef<unsigned>::iterator const_all_num_lists_iterator;
3484  typedef llvm::iterator_range<const_all_num_lists_iterator>
3487  auto A = getDeclNumListsRef();
3488  return const_all_num_lists_range(A.begin(), A.end());
3489  }
3490 
3491  typedef ArrayRef<unsigned>::iterator const_all_lists_sizes_iterator;
3492  typedef llvm::iterator_range<const_all_lists_sizes_iterator>
3495  auto A = getComponentListSizesRef();
3496  return const_all_lists_sizes_range(A.begin(), A.end());
3497  }
3498 
3499  typedef ArrayRef<MappableComponent>::iterator const_all_components_iterator;
3500  typedef llvm::iterator_range<const_all_components_iterator>
3503  auto A = getComponentsRef();
3504  return const_all_components_range(A.begin(), A.end());
3505  }
3506 };
3507 
3508 /// \brief This represents clause 'map' in the '#pragma omp ...'
3509 /// directives.
3510 ///
3511 /// \code
3512 /// #pragma omp target map(a,b)
3513 /// \endcode
3514 /// In this example directive '#pragma omp target' has clause 'map'
3515 /// with the variables 'a' and 'b'.
3516 ///
3517 class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
3518  private llvm::TrailingObjects<
3519  OMPMapClause, Expr *, ValueDecl *, unsigned,
3520  OMPClauseMappableExprCommon::MappableComponent> {
3521  friend TrailingObjects;
3522  friend OMPVarListClause;
3524  friend class OMPClauseReader;
3525 
3526  /// Define the sizes of each trailing object array except the last one. This
3527  /// is required for TrailingObjects to work properly.
3528  size_t numTrailingObjects(OverloadToken<Expr *>) const {
3529  return varlist_size();
3530  }
3531  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
3532  return getUniqueDeclarationsNum();
3533  }
3534  size_t numTrailingObjects(OverloadToken<unsigned>) const {
3535  return getUniqueDeclarationsNum() + getTotalComponentListNum();
3536  }
3537 
3538  /// \brief Map type modifier for the 'map' clause.
3539  OpenMPMapClauseKind MapTypeModifier;
3540  /// \brief Map type for the 'map' clause.
3541  OpenMPMapClauseKind MapType;
3542  /// \brief Is this an implicit map type or not.
3543  bool MapTypeIsImplicit;
3544  /// \brief Location of the map type.
3545  SourceLocation MapLoc;
3546  /// \brief Colon location.
3547  SourceLocation ColonLoc;
3548 
3549  /// \brief Set type modifier for the clause.
3550  ///
3551  /// \param T Type Modifier for the clause.
3552  ///
3553  void setMapTypeModifier(OpenMPMapClauseKind T) { MapTypeModifier = T; }
3554 
3555  /// \brief Set type for the clause.
3556  ///
3557  /// \param T Type for the clause.
3558  ///
3559  void setMapType(OpenMPMapClauseKind T) { MapType = T; }
3560 
3561  /// \brief Set type location.
3562  ///
3563  /// \param TLoc Type location.
3564  ///
3565  void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
3566 
3567  /// \brief Set colon location.
3568  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3569 
3570  /// \brief Build a clause for \a NumVars listed expressions, \a
3571  /// NumUniqueDeclarations declarations, \a NumComponentLists total component
3572  /// lists, and \a NumComponents total expression components.
3573  ///
3574  /// \param MapTypeModifier Map type modifier.
3575  /// \param MapType Map type.
3576  /// \param MapTypeIsImplicit Map type is inferred implicitly.
3577  /// \param MapLoc Location of the map type.
3578  /// \param StartLoc Starting location of the clause.
3579  /// \param EndLoc Ending location of the clause.
3580  /// \param NumVars Number of expressions listed in this clause.
3581  /// \param NumUniqueDeclarations Number of unique base declarations in this
3582  /// clause.
3583  /// \param NumComponentLists Number of component lists in this clause.
3584  /// \param NumComponents Total number of expression components in the clause.
3585  ///
3586  explicit OMPMapClause(OpenMPMapClauseKind MapTypeModifier,
3587  OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
3588  SourceLocation MapLoc, SourceLocation StartLoc,
3589  SourceLocation LParenLoc, SourceLocation EndLoc,
3590  unsigned NumVars, unsigned NumUniqueDeclarations,
3591  unsigned NumComponentLists, unsigned NumComponents)
3592  : OMPMappableExprListClause(OMPC_map, StartLoc, LParenLoc, EndLoc,
3593  NumVars, NumUniqueDeclarations,
3594  NumComponentLists, NumComponents),
3595  MapTypeModifier(MapTypeModifier), MapType(MapType),
3596  MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {}
3597 
3598  /// \brief Build an empty clause.
3599  ///
3600  /// \param NumVars Number of expressions listed in this clause.
3601  /// \param NumUniqueDeclarations Number of unique base declarations in this
3602  /// clause.
3603  /// \param NumComponentLists Number of component lists in this clause.
3604  /// \param NumComponents Total number of expression components in the clause.
3605  ///
3606  explicit OMPMapClause(unsigned NumVars, unsigned NumUniqueDeclarations,
3607  unsigned NumComponentLists, unsigned NumComponents)
3609  OMPC_map, SourceLocation(), SourceLocation(), SourceLocation(),
3610  NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents),
3611  MapTypeModifier(OMPC_MAP_unknown), MapType(OMPC_MAP_unknown),
3612  MapTypeIsImplicit(false), MapLoc() {}
3613 
3614 public:
3615  /// \brief Creates clause with a list of variables \a VL.
3616  ///
3617  /// \param C AST context.
3618  /// \param StartLoc Starting location of the clause.
3619  /// \param EndLoc Ending location of the clause.
3620  /// \param Vars The original expression used in the clause.
3621  /// \param Declarations Declarations used in the clause.
3622  /// \param ComponentLists Component lists used in the clause.
3623  /// \param TypeModifier Map type modifier.
3624  /// \param Type Map type.
3625  /// \param TypeIsImplicit Map type is inferred implicitly.
3626  /// \param TypeLoc Location of the map type.
3627  ///
3628  static OMPMapClause *Create(const ASTContext &C, SourceLocation StartLoc,
3629  SourceLocation LParenLoc, SourceLocation EndLoc,
3630  ArrayRef<Expr *> Vars,
3631  ArrayRef<ValueDecl *> Declarations,
3632  MappableExprComponentListsRef ComponentLists,
3633  OpenMPMapClauseKind TypeModifier,
3634  OpenMPMapClauseKind Type, bool TypeIsImplicit,
3635  SourceLocation TypeLoc);
3636  /// \brief Creates an empty clause with the place for for \a NumVars original
3637  /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
3638  /// lists, and \a NumComponents expression components.
3639  ///
3640  /// \param C AST context.
3641  /// \param NumVars Number of expressions listed in the clause.
3642  /// \param NumUniqueDeclarations Number of unique base declarations in this
3643  /// clause.
3644  /// \param NumComponentLists Number of unique base declarations in this
3645  /// clause.
3646  /// \param NumComponents Total number of expression components in the clause.
3647  ///
3648  static OMPMapClause *CreateEmpty(const ASTContext &C, unsigned NumVars,
3649  unsigned NumUniqueDeclarations,
3650  unsigned NumComponentLists,
3651  unsigned NumComponents);
3652 
3653  /// \brief Fetches mapping kind for the clause.
3654  OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
3655 
3656  /// \brief Is this an implicit map type?
3657  /// We have to capture 'IsMapTypeImplicit' from the parser for more
3658  /// informative error messages. It helps distinguish map(r) from
3659  /// map(tofrom: r), which is important to print more helpful error
3660  /// messages for some target directives.
3661  bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
3662 
3663  /// \brief Fetches the map type modifier for the clause.
3664  OpenMPMapClauseKind getMapTypeModifier() const LLVM_READONLY {
3665  return MapTypeModifier;
3666  }
3667 
3668  /// \brief Fetches location of clause mapping kind.
3669  SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
3670 
3671  /// \brief Get colon location.
3672  SourceLocation getColonLoc() const { return ColonLoc; }
3673 
3674  static bool classof(const OMPClause *T) {
3675  return T->getClauseKind() == OMPC_map;
3676  }
3677 
3678  child_range children() {
3679  return child_range(
3680  reinterpret_cast<Stmt **>(varlist_begin()),
3681  reinterpret_cast<Stmt **>(varlist_end()));
3682  }
3683 };
3684 
3685 /// \brief This represents 'num_teams' clause in the '#pragma omp ...'
3686 /// directive.
3687 ///
3688 /// \code
3689 /// #pragma omp teams num_teams(n)
3690 /// \endcode
3691 /// In this example directive '#pragma omp teams' has clause 'num_teams'
3692 /// with single expression 'n'.
3693 ///
3695  friend class OMPClauseReader;
3696  /// \brief Location of '('.
3697  SourceLocation LParenLoc;
3698  /// \brief NumTeams number.
3699  Stmt *NumTeams;
3700  /// \brief Set the NumTeams number.
3701  ///
3702  /// \param E NumTeams number.
3703  ///
3704  void setNumTeams(Expr *E) { NumTeams = E; }
3705 
3706 public:
3707  /// \brief Build 'num_teams' clause.
3708  ///
3709  /// \param E Expression associated with this clause.
3710  /// \param HelperE Helper Expression associated with this clause.
3711  /// \param CaptureRegion Innermost OpenMP region where expressions in this
3712  /// clause must be captured.
3713  /// \param StartLoc Starting location of the clause.
3714  /// \param LParenLoc Location of '('.
3715  /// \param EndLoc Ending location of the clause.
3716  ///
3717  OMPNumTeamsClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion,
3718  SourceLocation StartLoc, SourceLocation LParenLoc,
3719  SourceLocation EndLoc)
3720  : OMPClause(OMPC_num_teams, StartLoc, EndLoc), OMPClauseWithPreInit(this),
3721  LParenLoc(LParenLoc), NumTeams(E) {
3722  setPreInitStmt(HelperE, CaptureRegion);
3723  }
3724 
3725  /// \brief Build an empty clause.
3726  ///
3728  : OMPClause(OMPC_num_teams, SourceLocation(), SourceLocation()),
3729  OMPClauseWithPreInit(this), LParenLoc(SourceLocation()),
3730  NumTeams(nullptr) {}
3731  /// \brief Sets the location of '('.
3732  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3733  /// \brief Returns the location of '('.
3734  SourceLocation getLParenLoc() const { return LParenLoc; }
3735  /// \brief Return NumTeams number.
3736  Expr *getNumTeams() { return cast<Expr>(NumTeams); }
3737  /// \brief Return NumTeams number.
3738  Expr *getNumTeams() const { return cast<Expr>(NumTeams); }
3739 
3740  static bool classof(const OMPClause *T) {
3741  return T->getClauseKind() == OMPC_num_teams;
3742  }
3743 
3744  child_range children() { return child_range(&NumTeams, &NumTeams + 1); }
3745 };
3746 
3747 /// \brief This represents 'thread_limit' clause in the '#pragma omp ...'
3748 /// directive.
3749 ///
3750 /// \code
3751 /// #pragma omp teams thread_limit(n)
3752 /// \endcode
3753 /// In this example directive '#pragma omp teams' has clause 'thread_limit'
3754 /// with single expression 'n'.
3755 ///
3757  friend class OMPClauseReader;
3758  /// \brief Location of '('.
3759  SourceLocation LParenLoc;
3760  /// \brief ThreadLimit number.
3761  Stmt *ThreadLimit;
3762  /// \brief Set the ThreadLimit number.
3763  ///
3764  /// \param E ThreadLimit number.
3765  ///
3766  void setThreadLimit(Expr *E) { ThreadLimit = E; }
3767 
3768 public:
3769  /// \brief Build 'thread_limit' clause.
3770  ///
3771  /// \param E Expression associated with this clause.
3772  /// \param HelperE Helper Expression associated with this clause.
3773  /// \param CaptureRegion Innermost OpenMP region where expressions in this
3774  /// clause must be captured.
3775  /// \param StartLoc Starting location of the clause.
3776  /// \param LParenLoc Location of '('.
3777  /// \param EndLoc Ending location of the clause.
3778  ///
3779  OMPThreadLimitClause(Expr *E, Stmt *HelperE,
3780  OpenMPDirectiveKind CaptureRegion,
3781  SourceLocation StartLoc, SourceLocation LParenLoc,
3782  SourceLocation EndLoc)
3783  : OMPClause(OMPC_thread_limit, StartLoc, EndLoc),
3784  OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadLimit(E) {
3785  setPreInitStmt(HelperE, CaptureRegion);
3786  }
3787 
3788  /// \brief Build an empty clause.
3789  ///
3791  : OMPClause(OMPC_thread_limit, SourceLocation(), SourceLocation()),
3792  OMPClauseWithPreInit(this), LParenLoc(SourceLocation()),
3793  ThreadLimit(nullptr) {}
3794  /// \brief Sets the location of '('.
3795  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3796  /// \brief Returns the location of '('.
3797  SourceLocation getLParenLoc() const { return LParenLoc; }
3798  /// \brief Return ThreadLimit number.
3799  Expr *getThreadLimit() { return cast<Expr>(ThreadLimit); }
3800  /// \brief Return ThreadLimit number.
3801  Expr *getThreadLimit() const { return cast<Expr>(ThreadLimit); }
3802 
3803  static bool classof(const OMPClause *T) {
3804  return T->getClauseKind() == OMPC_thread_limit;
3805  }
3806 
3807  child_range children() { return child_range(&ThreadLimit, &ThreadLimit + 1); }
3808 };
3809 
3810 /// \brief This represents 'priority' clause in the '#pragma omp ...'
3811 /// directive.
3812 ///
3813 /// \code
3814 /// #pragma omp task priority(n)
3815 /// \endcode
3816 /// In this example directive '#pragma omp teams' has clause 'priority' with
3817 /// single expression 'n'.
3818 ///
3820  friend class OMPClauseReader;
3821  /// \brief Location of '('.
3822  SourceLocation LParenLoc;
3823  /// \brief Priority number.
3824  Stmt *Priority;
3825  /// \brief Set the Priority number.
3826  ///
3827  /// \param E Priority number.
3828  ///
3829  void setPriority(Expr *E) { Priority = E; }
3830 
3831 public:
3832  /// \brief Build 'priority' clause.
3833  ///
3834  /// \param E Expression associated with this clause.
3835  /// \param StartLoc Starting location of the clause.
3836  /// \param LParenLoc Location of '('.
3837  /// \param EndLoc Ending location of the clause.
3838  ///
3839  OMPPriorityClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc,
3840  SourceLocation EndLoc)
3841  : OMPClause(OMPC_priority, StartLoc, EndLoc), LParenLoc(LParenLoc),
3842  Priority(E) {}
3843 
3844  /// \brief Build an empty clause.
3845  ///
3847  : OMPClause(OMPC_priority, SourceLocation(), SourceLocation()),
3848  LParenLoc(SourceLocation()), Priority(nullptr) {}
3849  /// \brief Sets the location of '('.
3850  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3851  /// \brief Returns the location of '('.
3852  SourceLocation getLParenLoc() const { return LParenLoc; }
3853  /// \brief Return Priority number.
3854  Expr *getPriority() { return cast<Expr>(Priority); }
3855  /// \brief Return Priority number.
3856  Expr *getPriority() const { return cast<Expr>(Priority); }
3857 
3858  static bool classof(const OMPClause *T) {
3859  return T->getClauseKind() == OMPC_priority;
3860  }
3861 
3862  child_range children() { return child_range(&Priority, &Priority + 1); }
3863 };
3864 
3865 /// \brief This represents 'grainsize' clause in the '#pragma omp ...'
3866 /// directive.
3867 ///
3868 /// \code
3869 /// #pragma omp taskloop grainsize(4)
3870 /// \endcode
3871 /// In this example directive '#pragma omp taskloop' has clause 'grainsize'
3872 /// with single expression '4'.
3873 ///
3875  friend class OMPClauseReader;
3876  /// \brief Location of '('.
3877  SourceLocation LParenLoc;
3878  /// \brief Safe iteration space distance.
3879  Stmt *Grainsize;
3880 
3881  /// \brief Set safelen.
3882  void setGrainsize(Expr *Size) { Grainsize = Size; }
3883 
3884 public:
3885  /// \brief Build 'grainsize' clause.
3886  ///
3887  /// \param Size Expression associated with this clause.
3888  /// \param StartLoc Starting location of the clause.
3889  /// \param EndLoc Ending location of the clause.
3890  ///
3891  OMPGrainsizeClause(Expr *Size, SourceLocation StartLoc,
3892  SourceLocation LParenLoc, SourceLocation EndLoc)
3893  : OMPClause(OMPC_grainsize, StartLoc, EndLoc), LParenLoc(LParenLoc),
3894  Grainsize(Size) {}
3895 
3896  /// \brief Build an empty clause.
3897  ///
3899  : OMPClause(OMPC_grainsize, SourceLocation(), SourceLocation()),
3900  LParenLoc(SourceLocation()), Grainsize(nullptr) {}
3901 
3902  /// \brief Sets the location of '('.
3903  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3904  /// \brief Returns the location of '('.
3905  SourceLocation getLParenLoc() const { return LParenLoc; }
3906 
3907  /// \brief Return safe iteration space distance.
3908  Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
3909 
3910  static bool classof(const OMPClause *T) {
3911  return T->getClauseKind() == OMPC_grainsize;
3912  }
3913 
3914  child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
3915 };
3916 
3917 /// \brief This represents 'nogroup' clause in the '#pragma omp ...' directive.
3918 ///
3919 /// \code
3920 /// #pragma omp taskloop nogroup
3921 /// \endcode
3922 /// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
3923 ///
3924 class OMPNogroupClause : public OMPClause {
3925 public:
3926  /// \brief Build 'nogroup' clause.
3927  ///
3928  /// \param StartLoc Starting location of the clause.
3929  /// \param EndLoc Ending location of the clause.
3930  ///
3931  OMPNogroupClause(SourceLocation StartLoc, SourceLocation EndLoc)
3932  : OMPClause(OMPC_nogroup, StartLoc, EndLoc) {}
3933 
3934  /// \brief Build an empty clause.
3935  ///
3937  : OMPClause(OMPC_nogroup, SourceLocation(), SourceLocation()) {}
3938 
3939  static bool classof(const OMPClause *T) {
3940  return T->getClauseKind() == OMPC_nogroup;
3941  }
3942 
3943  child_range children() {
3944  return child_range(child_iterator(), child_iterator());
3945  }
3946 };
3947 
3948 /// \brief This represents 'num_tasks' clause in the '#pragma omp ...'
3949 /// directive.
3950 ///
3951 /// \code
3952 /// #pragma omp taskloop num_tasks(4)
3953 /// \endcode
3954 /// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
3955 /// with single expression '4'.
3956 ///
3958  friend class OMPClauseReader;
3959  /// \brief Location of '('.
3960  SourceLocation LParenLoc;
3961  /// \brief Safe iteration space distance.
3962  Stmt *NumTasks;
3963 
3964  /// \brief Set safelen.
3965  void setNumTasks(Expr *Size) { NumTasks = Size; }
3966 
3967 public:
3968  /// \brief Build 'num_tasks' clause.
3969  ///
3970  /// \param Size Expression associated with this clause.
3971  /// \param StartLoc Starting location of the clause.
3972  /// \param EndLoc Ending location of the clause.
3973  ///
3974  OMPNumTasksClause(Expr *Size, SourceLocation StartLoc,
3975  SourceLocation LParenLoc, SourceLocation EndLoc)
3976  : OMPClause(OMPC_num_tasks, StartLoc, EndLoc), LParenLoc(LParenLoc),
3977  NumTasks(Size) {}
3978 
3979  /// \brief Build an empty clause.
3980  ///
3982  : OMPClause(OMPC_num_tasks, SourceLocation(), SourceLocation()),
3983  LParenLoc(SourceLocation()), NumTasks(nullptr) {}
3984 
3985  /// \brief Sets the location of '('.
3986  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3987  /// \brief Returns the location of '('.
3988  SourceLocation getLParenLoc() const { return LParenLoc; }
3989 
3990  /// \brief Return safe iteration space distance.
3991  Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
3992 
3993  static bool classof(const OMPClause *T) {
3994  return T->getClauseKind() == OMPC_num_tasks;
3995  }
3996 
3997  child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
3998 };
3999 
4000 /// \brief This represents 'hint' clause in the '#pragma omp ...' directive.
4001 ///
4002 /// \code
4003 /// #pragma omp critical (name) hint(6)
4004 /// \endcode
4005 /// In this example directive '#pragma omp critical' has name 'name' and clause
4006 /// 'hint' with argument '6'.
4007 ///
4008 class OMPHintClause : public OMPClause {
4009  friend class OMPClauseReader;
4010  /// \brief Location of '('.
4011  SourceLocation LParenLoc;
4012  /// \brief Hint expression of the 'hint' clause.
4013  Stmt *Hint;
4014 
4015  /// \brief Set hint expression.
4016  ///
4017  void setHint(Expr *H) { Hint = H; }
4018 
4019 public:
4020  /// \brief Build 'hint' clause with expression \a Hint.
4021  ///
4022  /// \param Hint Hint expression.
4023  /// \param StartLoc Starting location of the clause.
4024  /// \param LParenLoc Location of '('.
4025  /// \param EndLoc Ending location of the clause.
4026  ///
4027  OMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc,
4028  SourceLocation EndLoc)
4029  : OMPClause(OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
4030  Hint(Hint) {}
4031 
4032  /// \brief Build an empty clause.
4033  ///
4035  : OMPClause(OMPC_hint, SourceLocation(), SourceLocation()),
4036  LParenLoc(SourceLocation()), Hint(nullptr) {}
4037 
4038  /// \brief Sets the location of '('.
4039  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4040  /// \brief Returns the location of '('.
4041  SourceLocation getLParenLoc() const { return LParenLoc; }
4042 
4043  /// \brief Returns number of threads.
4044  Expr *getHint() const { return cast_or_null<Expr>(Hint); }
4045 
4046  static bool classof(const OMPClause *T) {
4047  return T->getClauseKind() == OMPC_hint;
4048  }
4049 
4050  child_range children() { return child_range(&Hint, &Hint + 1); }
4051 };
4052 
4053 /// \brief This represents 'dist_schedule' clause in the '#pragma omp ...'
4054 /// directive.
4055 ///
4056 /// \code
4057 /// #pragma omp distribute dist_schedule(static, 3)
4058 /// \endcode
4059 /// In this example directive '#pragma omp distribute' has 'dist_schedule'
4060 /// clause with arguments 'static' and '3'.
4061 ///
4063  friend class OMPClauseReader;
4064  /// \brief Location of '('.
4065  SourceLocation LParenLoc;
4066  /// \brief A kind of the 'schedule' clause.
4068  /// \brief Start location of the schedule kind in source code.
4069  SourceLocation KindLoc;
4070  /// \brief Location of ',' (if any).
4071  SourceLocation CommaLoc;
4072  /// \brief Chunk size.
4073  Expr *ChunkSize;
4074 
4075  /// \brief Set schedule kind.
4076  ///
4077  /// \param K Schedule kind.
4078  ///
4079  void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
4080  /// \brief Sets the location of '('.
4081  ///
4082  /// \param Loc Location of '('.
4083  ///
4084  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4085  /// \brief Set schedule kind start location.
4086  ///
4087  /// \param KLoc Schedule kind location.
4088  ///
4089  void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
4090  /// \brief Set location of ','.
4091  ///
4092  /// \param Loc Location of ','.
4093  ///
4094  void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
4095  /// \brief Set chunk size.
4096  ///
4097  /// \param E Chunk size.
4098  ///
4099  void setChunkSize(Expr *E) { ChunkSize = E; }
4100 
4101 public:
4102  /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk
4103  /// size expression \a ChunkSize.
4104  ///
4105  /// \param StartLoc Starting location of the clause.
4106  /// \param LParenLoc Location of '('.
4107  /// \param KLoc Starting location of the argument.
4108  /// \param CommaLoc Location of ','.
4109  /// \param EndLoc Ending location of the clause.
4110  /// \param Kind DistSchedule kind.
4111  /// \param ChunkSize Chunk size.
4112  /// \param HelperChunkSize Helper chunk size for combined directives.
4113  ///
4114  OMPDistScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4115  SourceLocation KLoc, SourceLocation CommaLoc,
4116  SourceLocation EndLoc,
4117  OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
4118  Stmt *HelperChunkSize)
4119  : OMPClause(OMPC_dist_schedule, StartLoc, EndLoc),
4120  OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
4121  KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
4122  setPreInitStmt(HelperChunkSize);
4123  }
4124 
4125  /// \brief Build an empty clause.
4126  ///
4128  : OMPClause(OMPC_dist_schedule, SourceLocation(), SourceLocation()),
4130  ChunkSize(nullptr) {}
4131 
4132  /// \brief Get kind of the clause.
4133  ///
4135  /// \brief Get location of '('.
4136  ///
4137  SourceLocation getLParenLoc() { return LParenLoc; }
4138  /// \brief Get kind location.
4139  ///
4140  SourceLocation getDistScheduleKindLoc() { return KindLoc; }
4141  /// \brief Get location of ','.
4142  ///
4143  SourceLocation getCommaLoc() { return CommaLoc; }
4144  /// \brief Get chunk size.
4145  ///
4146  Expr *getChunkSize() { return ChunkSize; }
4147  /// \brief Get chunk size.
4148  ///
4149  const Expr *getChunkSize() const { return ChunkSize; }
4150 
4151  static bool classof(const OMPClause *T) {
4152  return T->getClauseKind() == OMPC_dist_schedule;
4153  }
4154 
4155  child_range children() {
4156  return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
4157  reinterpret_cast<Stmt **>(&ChunkSize) + 1);
4158  }
4159 };
4160 
4161 /// \brief This represents 'defaultmap' clause in the '#pragma omp ...' directive.
4162 ///
4163 /// \code
4164 /// #pragma omp target defaultmap(tofrom: scalar)
4165 /// \endcode
4166 /// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
4167 /// 'scalar' with modifier 'tofrom'.
4168 ///
4170  friend class OMPClauseReader;
4171  /// \brief Location of '('.
4172  SourceLocation LParenLoc;
4173  /// \brief Modifiers for 'defaultmap' clause.
4175  /// \brief Locations of modifiers.
4176  SourceLocation ModifierLoc;
4177  /// \brief A kind of the 'defaultmap' clause.
4179  /// \brief Start location of the defaultmap kind in source code.
4180  SourceLocation KindLoc;
4181 
4182  /// \brief Set defaultmap kind.
4183  ///
4184  /// \param K Defaultmap kind.
4185  ///
4186  void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
4187  /// \brief Set the defaultmap modifier.
4188  ///
4189  /// \param M Defaultmap modifier.
4190  ///
4191  void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
4192  Modifier = M;
4193  }
4194  /// \brief Set location of the defaultmap modifier.
4195  ///
4196  void setDefaultmapModifierLoc(SourceLocation Loc) {
4197  ModifierLoc = Loc;
4198  }
4199  /// \brief Sets the location of '('.
4200  ///
4201  /// \param Loc Location of '('.
4202  ///
4203  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4204  /// \brief Set defaultmap kind start location.
4205  ///
4206  /// \param KLoc Defaultmap kind location.
4207  ///
4208  void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
4209 
4210 public:
4211  /// \brief Build 'defaultmap' clause with defaultmap kind \a Kind
4212  ///
4213  /// \param StartLoc Starting location of the clause.
4214  /// \param LParenLoc Location of '('.
4215  /// \param KLoc Starting location of the argument.
4216  /// \param EndLoc Ending location of the clause.
4217  /// \param Kind Defaultmap kind.
4218  /// \param M The modifier applied to 'defaultmap' clause.
4219  /// \param MLoc Location of the modifier
4220  ///
4221  OMPDefaultmapClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4222  SourceLocation MLoc, SourceLocation KLoc,
4223  SourceLocation EndLoc, OpenMPDefaultmapClauseKind Kind,
4225  : OMPClause(OMPC_defaultmap, StartLoc, EndLoc), LParenLoc(LParenLoc),
4226  Modifier(M), ModifierLoc(MLoc), Kind(Kind), KindLoc(KLoc) {}
4227 
4228  /// \brief Build an empty clause.
4229  ///
4231  : OMPClause(OMPC_defaultmap, SourceLocation(), SourceLocation()),
4234 
4235  /// \brief Get kind of the clause.
4236  ///
4238  /// \brief Get the modifier of the clause.
4239  ///
4241  return Modifier;
4242  }
4243  /// \brief Get location of '('.
4244  ///
4245  SourceLocation getLParenLoc() { return LParenLoc; }
4246  /// \brief Get kind location.
4247  ///
4248  SourceLocation getDefaultmapKindLoc() { return KindLoc; }
4249  /// \brief Get the modifier location.
4250  ///
4251  SourceLocation getDefaultmapModifierLoc() const {
4252  return ModifierLoc;
4253  }
4254 
4255  static bool classof(const OMPClause *T) {
4256  return T->getClauseKind() == OMPC_defaultmap;
4257  }
4258 
4259  child_range children() {
4260  return child_range(child_iterator(), child_iterator());
4261  }
4262 };
4263 
4264 /// \brief This represents clause 'to' in the '#pragma omp ...'
4265 /// directives.
4266 ///
4267 /// \code
4268 /// #pragma omp target update to(a,b)
4269 /// \endcode
4270 /// In this example directive '#pragma omp target update' has clause 'to'
4271 /// with the variables 'a' and 'b'.
4272 ///
4273 class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
4274  private llvm::TrailingObjects<
4275  OMPToClause, Expr *, ValueDecl *, unsigned,
4276  OMPClauseMappableExprCommon::MappableComponent> {
4277  friend TrailingObjects;
4278  friend OMPVarListClause;
4280  friend class OMPClauseReader;
4281 
4282  /// Define the sizes of each trailing object array except the last one. This
4283  /// is required for TrailingObjects to work properly.
4284  size_t numTrailingObjects(OverloadToken<Expr *>) const {
4285  return varlist_size();
4286  }
4287  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4288  return getUniqueDeclarationsNum();
4289  }
4290  size_t numTrailingObjects(OverloadToken<unsigned>) const {
4291  return getUniqueDeclarationsNum() + getTotalComponentListNum();
4292  }
4293 
4294  /// \brief Build clause with number of variables \a NumVars.
4295  ///
4296  /// \param StartLoc Starting location of the clause.
4297  /// \param EndLoc Ending location of the clause.
4298  /// \param NumVars Number of expressions listed in this clause.
4299  /// \param NumUniqueDeclarations Number of unique base declarations in this
4300  /// clause.
4301  /// \param NumComponentLists Number of component lists in this clause.
4302  /// \param NumComponents Total number of expression components in the clause.
4303  ///
4304  explicit OMPToClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4305  SourceLocation EndLoc, unsigned NumVars,
4306  unsigned NumUniqueDeclarations,
4307  unsigned NumComponentLists, unsigned NumComponents)
4308  : OMPMappableExprListClause(OMPC_to, StartLoc, LParenLoc, EndLoc, NumVars,
4309  NumUniqueDeclarations, NumComponentLists,
4310  NumComponents) {}
4311 
4312  /// \brief Build an empty clause.
4313  ///
4314  /// \param NumVars Number of expressions listed in this clause.
4315  /// \param NumUniqueDeclarations Number of unique base declarations in this
4316  /// clause.
4317  /// \param NumComponentLists Number of component lists in this clause.
4318  /// \param NumComponents Total number of expression components in the clause.
4319  ///
4320  explicit OMPToClause(unsigned NumVars, unsigned NumUniqueDeclarations,
4321  unsigned NumComponentLists, unsigned NumComponents)
4323  OMPC_to, SourceLocation(), SourceLocation(), SourceLocation(),
4324  NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents) {}
4325 
4326 public:
4327  /// \brief Creates clause with a list of variables \a Vars.
4328  ///
4329  /// \param C AST context.
4330  /// \param StartLoc Starting location of the clause.
4331  /// \param EndLoc Ending location of the clause.
4332  /// \param Vars The original expression used in the clause.
4333  /// \param Declarations Declarations used in the clause.
4334  /// \param ComponentLists Component lists used in the clause.
4335  ///
4336  static OMPToClause *Create(const ASTContext &C, SourceLocation StartLoc,
4337  SourceLocation LParenLoc, SourceLocation EndLoc,
4338  ArrayRef<Expr *> Vars,
4339  ArrayRef<ValueDecl *> Declarations,
4340  MappableExprComponentListsRef ComponentLists);
4341 
4342  /// \brief Creates an empty clause with the place for \a NumVars variables.
4343  ///
4344  /// \param C AST context.
4345  /// \param NumVars Number of expressions listed in the clause.
4346  /// \param NumUniqueDeclarations Number of unique base declarations in this
4347  /// clause.
4348  /// \param NumComponentLists Number of unique base declarations in this
4349  /// clause.
4350  /// \param NumComponents Total number of expression components in the clause.
4351  ///
4352  static OMPToClause *CreateEmpty(const ASTContext &C, unsigned NumVars,
4353  unsigned NumUniqueDeclarations,
4354  unsigned NumComponentLists,
4355  unsigned NumComponents);
4356 
4357  static bool classof(const OMPClause *T) {
4358  return T->getClauseKind() == OMPC_to;
4359  }
4360 
4361  child_range children() {
4362  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4363  reinterpret_cast<Stmt **>(varlist_end()));
4364  }
4365 };
4366 
4367 /// \brief This represents clause 'from' in the '#pragma omp ...'
4368 /// directives.
4369 ///
4370 /// \code
4371 /// #pragma omp target update from(a,b)
4372 /// \endcode
4373 /// In this example directive '#pragma omp target update' has clause 'from'
4374 /// with the variables 'a' and 'b'.
4375 ///
4376 class OMPFromClause final
4377  : public OMPMappableExprListClause<OMPFromClause>,
4378  private llvm::TrailingObjects<
4379  OMPFromClause, Expr *, ValueDecl *, unsigned,
4380  OMPClauseMappableExprCommon::MappableComponent> {
4381  friend TrailingObjects;
4382  friend OMPVarListClause;
4384  friend class OMPClauseReader;
4385 
4386  /// Define the sizes of each trailing object array except the last one. This
4387  /// is required for TrailingObjects to work properly.
4388  size_t numTrailingObjects(OverloadToken<Expr *>) const {
4389  return varlist_size();
4390  }
4391  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4392  return getUniqueDeclarationsNum();
4393  }
4394  size_t numTrailingObjects(OverloadToken<unsigned>) const {
4395  return getUniqueDeclarationsNum() + getTotalComponentListNum();
4396  }
4397 
4398  /// \brief Build clause with number of variables \a NumVars.
4399  ///
4400  /// \param StartLoc Starting location of the clause.
4401  /// \param EndLoc Ending location of the clause.
4402  /// \param NumVars Number of expressions listed in this clause.
4403  /// \param NumUniqueDeclarations Number of unique base declarations in this
4404  /// clause.
4405  /// \param NumComponentLists Number of component lists in this clause.
4406  /// \param NumComponents Total number of expression components in the clause.
4407  ///
4408  explicit OMPFromClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4409  SourceLocation EndLoc, unsigned NumVars,
4410  unsigned NumUniqueDeclarations,
4411  unsigned NumComponentLists, unsigned NumComponents)
4412  : OMPMappableExprListClause(OMPC_from, StartLoc, LParenLoc, EndLoc,
4413  NumVars, NumUniqueDeclarations,
4414  NumComponentLists, NumComponents) {}
4415 
4416  /// \brief Build an empty clause.
4417  ///
4418  /// \param NumVars Number of expressions listed in this clause.
4419  /// \param NumUniqueDeclarations Number of unique base declarations in this
4420  /// clause.
4421  /// \param NumComponentLists Number of component lists in this clause.
4422  /// \param NumComponents Total number of expression components in the clause.
4423  ///
4424  explicit OMPFromClause(unsigned NumVars, unsigned NumUniqueDeclarations,
4425  unsigned NumComponentLists, unsigned NumComponents)
4427  OMPC_from, SourceLocation(), SourceLocation(), SourceLocation(),
4428  NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents) {}
4429 
4430 public:
4431  /// \brief Creates clause with a list of variables \a Vars.
4432  ///
4433  /// \param C AST context.
4434  /// \param StartLoc Starting location of the clause.
4435  /// \param EndLoc Ending location of the clause.
4436  /// \param Vars The original expression used in the clause.
4437  /// \param Declarations Declarations used in the clause.
4438  /// \param ComponentLists Component lists used in the clause.
4439  ///
4440  static OMPFromClause *Create(const ASTContext &C, SourceLocation StartLoc,
4441  SourceLocation LParenLoc, SourceLocation EndLoc,
4442  ArrayRef<Expr *> Vars,
4443  ArrayRef<ValueDecl *> Declarations,
4444  MappableExprComponentListsRef ComponentLists);
4445 
4446  /// \brief Creates an empty clause with the place for \a NumVars variables.
4447  ///
4448  /// \param C AST context.
4449  /// \param NumVars Number of expressions listed in the clause.
4450  /// \param NumUniqueDeclarations Number of unique base declarations in this
4451  /// clause.
4452  /// \param NumComponentLists Number of unique base declarations in this
4453  /// clause.
4454  /// \param NumComponents Total number of expression components in the clause.
4455  ///
4456  static OMPFromClause *CreateEmpty(const ASTContext &C, unsigned NumVars,
4457  unsigned NumUniqueDeclarations,
4458  unsigned NumComponentLists,
4459  unsigned NumComponents);
4460 
4461  static bool classof(const OMPClause *T) {
4462  return T->getClauseKind() == OMPC_from;
4463  }
4464 
4465  child_range children() {
4466  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4467  reinterpret_cast<Stmt **>(varlist_end()));
4468  }
4469 };
4470 
4471 /// This represents clause 'use_device_ptr' in the '#pragma omp ...'
4472 /// directives.
4473 ///
4474 /// \code
4475 /// #pragma omp target data use_device_ptr(a,b)
4476 /// \endcode
4477 /// In this example directive '#pragma omp target data' has clause
4478 /// 'use_device_ptr' with the variables 'a' and 'b'.
4479 ///
4481  : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
4482  private llvm::TrailingObjects<
4483  OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
4484  OMPClauseMappableExprCommon::MappableComponent> {
4485  friend TrailingObjects;
4486  friend OMPVarListClause;
4488  friend class OMPClauseReader;
4489 
4490  /// Define the sizes of each trailing object array except the last one. This
4491  /// is required for TrailingObjects to work properly.
4492  size_t numTrailingObjects(OverloadToken<Expr *>) const {
4493  return 3 * varlist_size();
4494  }
4495  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4496  return getUniqueDeclarationsNum();
4497  }
4498  size_t numTrailingObjects(OverloadToken<unsigned>) const {
4499  return getUniqueDeclarationsNum() + getTotalComponentListNum();
4500  }
4501 
4502  /// Build clause with number of variables \a NumVars.
4503  ///
4504  /// \param StartLoc Starting location of the clause.
4505  /// \param EndLoc Ending location of the clause.
4506  /// \param NumVars Number of expressions listed in this clause.
4507  /// \param NumUniqueDeclarations Number of unique base declarations in this
4508  /// clause.
4509  /// \param NumComponentLists Number of component lists in this clause.
4510  /// \param NumComponents Total number of expression components in the clause.
4511  ///
4512  explicit OMPUseDevicePtrClause(SourceLocation StartLoc,
4513  SourceLocation LParenLoc,
4514  SourceLocation EndLoc, unsigned NumVars,
4515  unsigned NumUniqueDeclarations,
4516  unsigned NumComponentLists,
4517  unsigned NumComponents)
4518  : OMPMappableExprListClause(OMPC_use_device_ptr, StartLoc, LParenLoc,
4519  EndLoc, NumVars, NumUniqueDeclarations,
4520  NumComponentLists, NumComponents) {}
4521 
4522  /// Build an empty clause.
4523  ///
4524  /// \param NumVars Number of expressions listed in this clause.
4525  /// \param NumUniqueDeclarations Number of unique base declarations in this
4526  /// clause.
4527  /// \param NumComponentLists Number of component lists in this clause.
4528  /// \param NumComponents Total number of expression components in the clause.
4529  ///
4530  explicit OMPUseDevicePtrClause(unsigned NumVars,
4531  unsigned NumUniqueDeclarations,
4532  unsigned NumComponentLists,
4533  unsigned NumComponents)
4534  : OMPMappableExprListClause(OMPC_use_device_ptr, SourceLocation(),
4535  SourceLocation(), SourceLocation(), NumVars,
4536  NumUniqueDeclarations, NumComponentLists,
4537  NumComponents) {}
4538 
4539  /// Sets the list of references to private copies with initializers for new
4540  /// private variables.
4541  /// \param VL List of references.
4542  void setPrivateCopies(ArrayRef<Expr *> VL);
4543 
4544  /// Gets the list of references to private copies with initializers for new
4545  /// private variables.
4546  MutableArrayRef<Expr *> getPrivateCopies() {
4547  return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4548  }
4549  ArrayRef<const Expr *> getPrivateCopies() const {
4550  return llvm::makeArrayRef(varlist_end(), varlist_size());
4551  }
4552 
4553  /// Sets the list of references to initializer variables for new private
4554  /// variables.
4555  /// \param VL List of references.
4556  void setInits(ArrayRef<Expr *> VL);
4557 
4558  /// Gets the list of references to initializer variables for new private
4559  /// variables.
4560  MutableArrayRef<Expr *> getInits() {
4561  return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
4562  }
4563  ArrayRef<const Expr *> getInits() const {
4564  return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
4565  }
4566 
4567 public:
4568  /// Creates clause with a list of variables \a Vars.
4569  ///
4570  /// \param C AST context.
4571  /// \param StartLoc Starting location of the clause.
4572  /// \param EndLoc Ending location of the clause.
4573  /// \param Vars The original expression used in the clause.
4574  /// \param PrivateVars Expressions referring to private copies.
4575  /// \param Inits Expressions referring to private copy initializers.
4576  /// \param Declarations Declarations used in the clause.
4577  /// \param ComponentLists Component lists used in the clause.
4578  ///
4579  static OMPUseDevicePtrClause *
4580  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4581  SourceLocation EndLoc, ArrayRef<Expr *> Vars,
4582  ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *> Inits,
4583  ArrayRef<ValueDecl *> Declarations,
4584  MappableExprComponentListsRef ComponentLists);
4585 
4586  /// Creates an empty clause with the place for \a NumVars variables.
4587  ///
4588  /// \param C AST context.
4589  /// \param NumVars Number of expressions listed in the clause.
4590  /// \param NumUniqueDeclarations Number of unique base declarations in this
4591  /// clause.
4592  /// \param NumComponentLists Number of unique base declarations in this
4593  /// clause.
4594  /// \param NumComponents Total number of expression components in the clause.
4595  ///
4596  static OMPUseDevicePtrClause *CreateEmpty(const ASTContext &C,
4597  unsigned NumVars,
4598  unsigned NumUniqueDeclarations,
4599  unsigned NumComponentLists,
4600  unsigned NumComponents);
4601 
4602  typedef MutableArrayRef<Expr *>::iterator private_copies_iterator;
4603  typedef ArrayRef<const Expr *>::iterator private_copies_const_iterator;
4604  typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
4605  typedef llvm::iterator_range<private_copies_const_iterator>
4607 
4609  return private_copies_range(getPrivateCopies().begin(),
4610  getPrivateCopies().end());
4611  }
4613  return private_copies_const_range(getPrivateCopies().begin(),
4614  getPrivateCopies().end());
4615  }
4616 
4617  typedef MutableArrayRef<Expr *>::iterator inits_iterator;
4618  typedef ArrayRef<const Expr *>::iterator inits_const_iterator;
4619  typedef llvm::iterator_range<inits_iterator> inits_range;
4620  typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
4621 
4623  return inits_range(getInits().begin(), getInits().end());
4624  }
4626  return inits_const_range(getInits().begin(), getInits().end());
4627  }
4628 
4629  child_range children() {
4630  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4631  reinterpret_cast<Stmt **>(varlist_end()));
4632  }
4633 
4634  static bool classof(const OMPClause *T) {
4635  return T->getClauseKind() == OMPC_use_device_ptr;
4636  }
4637 };
4638 
4639 /// This represents clause 'is_device_ptr' in the '#pragma omp ...'
4640 /// directives.
4641 ///
4642 /// \code
4643 /// #pragma omp target is_device_ptr(a,b)
4644 /// \endcode
4645 /// In this example directive '#pragma omp target' has clause
4646 /// 'is_device_ptr' with the variables 'a' and 'b'.
4647 ///
4649  : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
4650  private llvm::TrailingObjects<
4651  OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
4652  OMPClauseMappableExprCommon::MappableComponent> {
4653  friend TrailingObjects;
4654  friend OMPVarListClause;
4656  friend class OMPClauseReader;
4657 
4658  /// Define the sizes of each trailing object array except the last one. This
4659  /// is required for TrailingObjects to work properly.
4660  size_t numTrailingObjects(OverloadToken<Expr *>) const {
4661  return varlist_size();
4662  }
4663  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4664  return getUniqueDeclarationsNum();
4665  }
4666  size_t numTrailingObjects(OverloadToken<unsigned>) const {
4667  return getUniqueDeclarationsNum() + getTotalComponentListNum();
4668  }
4669  /// Build clause with number of variables \a NumVars.
4670  ///
4671  /// \param StartLoc Starting location of the clause.
4672  /// \param EndLoc Ending location of the clause.
4673  /// \param NumVars Number of expressions listed in this clause.
4674  /// \param NumUniqueDeclarations Number of unique base declarations in this
4675  /// clause.
4676  /// \param NumComponentLists Number of component lists in this clause.
4677  /// \param NumComponents Total number of expression components in the clause.
4678  ///
4679  explicit OMPIsDevicePtrClause(SourceLocation StartLoc,
4680  SourceLocation LParenLoc, SourceLocation EndLoc,
4681  unsigned NumVars,
4682  unsigned NumUniqueDeclarations,
4683  unsigned NumComponentLists,
4684  unsigned NumComponents)
4685  : OMPMappableExprListClause(OMPC_is_device_ptr, StartLoc, LParenLoc,
4686  EndLoc, NumVars, NumUniqueDeclarations,
4687  NumComponentLists, NumComponents) {}
4688 
4689  /// Build an empty clause.
4690  ///
4691  /// \param NumVars Number of expressions listed in this clause.
4692  /// \param NumUniqueDeclarations Number of unique base declarations in this
4693  /// clause.
4694  /// \param NumComponentLists Number of component lists in this clause.
4695  /// \param NumComponents Total number of expression components in the clause.
4696  ///
4697  explicit OMPIsDevicePtrClause(unsigned NumVars,
4698  unsigned NumUniqueDeclarations,
4699  unsigned NumComponentLists,
4700  unsigned NumComponents)
4701  : OMPMappableExprListClause(OMPC_is_device_ptr, SourceLocation(),
4702  SourceLocation(), SourceLocation(), NumVars,
4703  NumUniqueDeclarations, NumComponentLists,
4704  NumComponents) {}
4705 
4706 public:
4707  /// Creates clause with a list of variables \a Vars.
4708  ///
4709  /// \param C AST context.
4710  /// \param StartLoc Starting location of the clause.
4711  /// \param EndLoc Ending location of the clause.
4712  /// \param Vars The original expression used in the clause.
4713  /// \param Declarations Declarations used in the clause.
4714  /// \param ComponentLists Component lists used in the clause.
4715  ///
4716  static OMPIsDevicePtrClause *
4717  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4718  SourceLocation EndLoc, ArrayRef<Expr *> Vars,
4719  ArrayRef<ValueDecl *> Declarations,
4720  MappableExprComponentListsRef ComponentLists);
4721 
4722  /// Creates an empty clause with the place for \a NumVars variables.
4723  ///
4724  /// \param C AST context.
4725  /// \param NumVars Number of expressions listed in the clause.
4726  /// \param NumUniqueDeclarations Number of unique base declarations in this
4727  /// clause.
4728  /// \param NumComponentLists Number of unique base declarations in this
4729  /// clause.
4730  /// \param NumComponents Total number of expression components in the clause.
4731  ///
4732  static OMPIsDevicePtrClause *CreateEmpty(const ASTContext &C,
4733  unsigned NumVars,
4734  unsigned NumUniqueDeclarations,
4735  unsigned NumComponentLists,
4736  unsigned NumComponents);
4737 
4738  child_range children() {
4739  return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4740  reinterpret_cast<Stmt **>(varlist_end()));
4741  }
4742 
4743  static bool classof(const OMPClause *T) {
4744  return T->getClauseKind() == OMPC_is_device_ptr;
4745  }
4746 };
4747 } // end namespace clang
4748 
4749 #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
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.
child_range children()
Definition: OpenMPClause.h:284
OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'capture' clause.
OMPNumTeamsClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'num_teams' clause.
private_copies_const_range private_copies() const
varlist_const_range varlists() const
Definition: OpenMPClause.h:177
helper_expr_range source_exprs()
OMPHintClause()
Build an empty clause.
child_range children()
static OMPReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
static const Decl * getCanonicalDecl(const Decl *D)
OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'untied' clause.
Definition: OpenMPClause.h:991
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
Definition: OpenMPClause.h:855
llvm::iterator_range< private_copies_iterator > private_copies_range
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
child_range children()
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Iterator that browse the components by lists.
OMPSeqCstClause()
Build an empty clause.
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:934
This represents clause 'copyin' in the '#pragma omp ...' directives.
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
helper_expr_range source_exprs()
SourceLocation getColonLoc() const
Get colon location.
helper_expr_const_range source_exprs() const
const Expr * getChunkSize() const
Get chunk size.
static bool classof(const OMPClause *T)
std::pair< const ValueDecl *, MappableExprComponentListRef > operator*() const
MutableArrayRef< Expr * >::iterator inits_iterator
SourceLocation getCommaLoc()
Get location of ','.
Definition: OpenMPClause.h:876
helper_expr_range privates()
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:505
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
Definition: OpenMPKinds.h:107
const_component_lists_iterator(const ValueDecl *Declaration, ArrayRef< ValueDecl * > UniqueDecls, ArrayRef< unsigned > DeclsListNum, ArrayRef< unsigned > CumulativeListSizes, MappableExprComponentListRef Components)
Construct an iterator that scan lists for a given declaration Declaration.
private_copies_range private_copies()
Stmt - This represents one statement.
Definition: Stmt.h:60
static bool classof(const OMPClause *T)
Class that handles pre-initialization statement for some clauses, like 'shedule', 'firstprivate' etc...
Definition: OpenMPClause.h:76
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:507
ArrayRef< MappableComponent > MappableExprComponentListRef
helper_expr_range rhs_exprs()
OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'update' clause.
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:697
OpenMPProcBindClauseKind getProcBindKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:700
SourceLocation getLParenLoc() const
Returns the location of '('.
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'grainsize' clause in the '#pragma omp ...' directive.
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:999
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
helper_expr_const_range lhs_exprs() const
llvm::iterator_range< child_iterator > child_range
Definition: OpenMPClause.h:63
This represents 'if' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:207
OpenMPDirectiveKind getCaptureRegion()
Get capture region for the stmt in the clause.
Definition: OpenMPClause.h:100
const_component_lists_range component_lists() const
private_copies_const_range private_copies() const
OMPSIMDClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'simd' clause.
This represents 'priority' clause in the '#pragma omp ...' directive.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:695
inits_range inits()
SourceLocation getColonLoc() const
Returns the location of ':'.
This represents 'update' clause in the '#pragma omp atomic' directive.
child_range children()
void setComponents(ArrayRef< MappableComponent > Components, ArrayRef< unsigned > CLSs)
Set the components that are in the trailing objects of the class.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:556
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:189
SourceLocation getColonLoc() const
Get colon location.
ArrayRef< const Expr * > getVarRefs() const
Fetches list of all variables in the clause.
Definition: OpenMPClause.h:192
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
Definition: OpenMPKinds.h:115
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:500
Expr * getAlignment()
Returns alignment.
OMPOrderedClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'ordered' clause.
Definition: OpenMPClause.h:920
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:932
llvm::iterator_range< const_all_decls_iterator > const_all_decls_range
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:705
This represents 'read' clause in the '#pragma omp atomic' directive.
OMPFinalClause()
Build an empty clause.
Definition: OpenMPClause.h:321
Expr * getNumTeams() const
Return NumTeams number.
finals_range finals()
helper_expr_range source_exprs()
This represents clause 'private' in the '#pragma omp ...' directives.
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:452
static bool classof(const OMPClause *T)
ArrayRef< const Expr * >::iterator private_copies_const_iterator
const Expr * getPostUpdateExpr() const
Get post-update expression for the clause.
Definition: OpenMPClause.h:121
This represents 'num_threads' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:349
varlist_range varlists()
Definition: OpenMPClause.h:174
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
ArrayRef< MappableComponent >::iterator const_all_components_iterator
llvm::iterator_range< private_copies_iterator > private_copies_range
friend OMPVarListClause
Definition: OpenMPClause.h:83
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
This represents clauses with a list of expressions that are mappable.
MutableArrayRef< Expr * >::iterator privates_iterator
bool varlist_empty() const
Definition: OpenMPClause.h:172
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
static bool classof(const OMPClause *T)
OMPNumTasksClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'num_tasks' clause.
OMPNogroupClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'nogroup' clause.
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:937
llvm::iterator_range< private_copies_iterator > private_copies_range
Struct that defines common infrastructure to handle mappable expressions used in OpenMP clauses...
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'nogroup' clause in the '#pragma omp ...' directive.
This represents 'safelen' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:416
void setClauseInfo(ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Fill the clause information from the list of declarations and associated component lists...
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:333
OMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'hint' clause with expression Hint.
child_range children()
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:328
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:394
This represents clauses with the list of variables like 'private', 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the '#pragma omp ...' directives.
Definition: OpenMPClause.h:131
OMPProcBindClause()
Build an empty clause.
Definition: OpenMPClause.h:689
unsigned getTotalComponentListNum() const
Return the number of lists derived from the clause expressions.
CalcStep
Definition: OpenMPClause.h:137
child_range children()
SourceLocation getLParenLoc() const
Returns the location of '('.
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
llvm::iterator_range< inits_iterator > inits_range
Step
Definition: OpenMPClause.h:137
ArrayRef< const Expr * >::iterator updates_const_iterator
child_range children()
clang::OMPLinearClause OMPVarListClause, OMPClauseWithPostUpdate, llvm::TrailingObjects getPrivates()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
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
ArrayRef< const Expr * >::iterator inits_const_iterator
This represents 'simd' clause in the '#pragma omp ...' directive.
const_component_lists_iterator(ArrayRef< ValueDecl * > UniqueDecls, ArrayRef< unsigned > DeclsListNum, ArrayRef< unsigned > CumulativeListSizes, MappableExprComponentListRef Components)
Construct an iterator that scans all lists.
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
Definition: OpenMPClause.h:850
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:632
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition: OpenMPKinds.h:84
static bool classof(const OMPClause *T)
helper_expr_range assignment_ops()
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
OMPSIMDClause()
Build an empty clause.
void setUpdates(ArrayRef< Expr * > UL)
Sets the list of update expressions for linear variables.
OMPPriorityClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'priority' clause.
SourceLocation getLocStart() const
Returns the starting location of the clause.
Definition: OpenMPClause.h:47
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:161
helper_expr_range privates()
varlist_iterator varlist_begin()
Definition: OpenMPClause.h:181
child_range children()
Expr * getChunkSize()
Get chunk size.
This represents clause 'map' in the '#pragma omp ...' directives.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
This represents clause 'to' in the '#pragma omp ...' directives.
void setColonLoc(SourceLocation Loc)
Sets the location of ':'.
ArrayRef< const Expr * >::iterator private_copies_const_iterator
private_copies_const_range private_copies() const
OMPMappableExprListClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Build a clause for NumUniqueDeclarations declarations, NumComponentLists total component lists...
Defines some OpenMP-specific enums and functions.
OMPPriorityClause()
Build an empty clause.
llvm::iterator_range< varlist_const_iterator > varlist_const_range
Definition: OpenMPClause.h:169
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
helper_expr_range lhs_exprs()
Expr * getNumTeams()
Return NumTeams number.
const_component_lists_iterator decl_component_lists_end() const
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
llvm::iterator_range< updates_iterator > updates_range
OMPDefaultmapClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KLoc, SourceLocation EndLoc, OpenMPDefaultmapClauseKind Kind, OpenMPDefaultmapClauseModifier M)
Build 'defaultmap' clause with defaultmap kind Kind.
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
child_range children()
Definition: OpenMPClause.h:337
unsigned getTotalComponentsNum() const
Return the total number of components in all lists derived from the clause.
MutableArrayRef< unsigned > getComponentListSizesRef()
Get the cumulative component lists sizes that are in the trailing objects of the class.
llvm::iterator_range< const_all_lists_sizes_iterator > const_all_lists_sizes_range
OMPSafelenClause()
Build an empty clause.
Definition: OpenMPClause.h:440
llvm::iterator_range< varlist_iterator > varlist_range
Definition: OpenMPClause.h:168
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Definition: OpenMPKinds.h:100
SourceLocation getFirstScheduleModifierLoc() const
Get the first modifier location.
Definition: OpenMPClause.h:866
llvm::iterator_range< const_component_lists_iterator > const_component_lists_range
void setModifierLoc(SourceLocation Loc)
Set modifier location.
void setCalcStep(Expr *CalcStep)
Sets the expression to calculate linear step for clause.
Definition: OpenMPClause.h:96
OpenMPLinearClauseKind getModifier() const
Return modifier.
helper_expr_range destination_exprs()
helper_expr_const_range private_copies() const
SourceLocation getDefaultmapKindLoc()
Get kind location.
void setFinals(ArrayRef< Expr * > FL)
Sets the list of final update expressions for linear variables.
llvm::iterator_range< privates_const_iterator > privates_const_range
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
llvm::iterator_range< inits_const_iterator > inits_const_range
static bool classof(const OMPClause *T)
helper_expr_const_range source_exprs() const
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
Definition: OpenMPClause.h:847
ArrayRef< ValueDecl * > getUniqueDeclsRef() const
Get the unique declarations that are in the trailing objects of the class.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:622
OMPDistScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KLoc, SourceLocation CommaLoc, SourceLocation EndLoc, OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, Stmt *HelperChunkSize)
Build 'dist_schedule' clause with schedule kind Kind and chunk size expression ChunkSize.
Expr * getThreadLimit() const
Return ThreadLimit number.
static bool classof(const OMPClause *T)
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc...
Definition: OpenMPClause.h:107
This represents 'default' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:578
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:681
OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'write' clause.
This represents 'final' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:295
This represents 'mergeable' clause in the '#pragma omp ...' directive.
MutableArrayRef< Expr * > getFinals()
Sets the list of final update expressions for linear variables.
SourceLocation getSecondScheduleModifierLoc() const
Get the second modifier location.
Definition: OpenMPClause.h:871
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
llvm::iterator_range< helper_expr_iterator > helper_expr_range
This represents clause 'reduction' in the '#pragma omp ...' directives.
OMPNogroupClause()
Build an empty clause.
llvm::iterator_range< helper_expr_iterator > helper_expr_range
void setColonLoc(SourceLocation Loc)
Sets the location of ':'.
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:396
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
child_range children()
Definition: OpenMPClause.h:943
child_range children()
Definition: OpenMPClause.h:972
Expr * getHint() const
Returns number of threads.
detail::InMemoryDirectory::const_iterator I
child_range children()
Definition: OpenMPClause.h:636
Expr * getPostUpdateExpr()
Get post-update expression for the clause.
Definition: OpenMPClause.h:123
static OMPTaskReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
updates_range updates()
bool isInvalid() const
static bool classof(const OMPClause *T)
llvm::iterator_range< finals_const_iterator > finals_const_range
OMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'seq_cst' clause.
void setModifier(OpenMPLinearClauseKind Kind)
Set modifier.
private_copies_range private_copies()
This represents clause 'from' in the '#pragma omp ...' directives.
static bool classof(const OMPClause *T)
OMPScheduleClause()
Build an empty clause.
Definition: OpenMPClause.h:837
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
OMPGrainsizeClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'grainsize' clause.
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:627
child_range children()
child_range children()
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:57
child_range children()
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
OMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'collapse' clause.
Definition: OpenMPClause.h:544
ArrayRef< unsigned >::iterator const_all_num_lists_iterator
SourceLocation getLocEnd() const
Returns the ending location of the clause.
Definition: OpenMPClause.h:49
static bool classof(const OMPClause *)
Definition: OpenMPClause.h:71
OMPDistScheduleClause()
Build an empty clause.
static bool classof(const OMPClause *T)
llvm::iterator_range< inits_const_iterator > inits_const_range
child_range children()
OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, unsigned NumVars)
Build 'linear' clause with given number of variables NumVars.
Definition: OpenMPClause.h:106
This represents 'threads' clause in the '#pragma omp ...' directive.
const_child_range children() const
Definition: OpenMPClause.h:67
friend class OMPClauseReader
Definition: OpenMPClause.h:84
helper_expr_range assignment_ops()
SourceLocation getDefaultKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:630
child_range children()
OMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'nowait' clause.
Definition: OpenMPClause.h:960
child_range children()
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:54
child_range children()
OMPWriteClause()
Build an empty clause.
MutableArrayRef< Expr * >::iterator varlist_iterator
Definition: OpenMPClause.h:166
static bool classof(const OMPClause *T)
OMPCaptureClause()
Build an empty clause.
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:968
OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'safelen' clause.
Definition: OpenMPClause.h:433
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
varlist_const_iterator varlist_end() const
Definition: OpenMPClause.h:184
const SmallVectorImpl< AnnotatedLine * >::const_iterator End
static bool classof(const OMPClause *T)
helper_expr_range assignment_ops()
bool isImplicit() const
Definition: OpenMPClause.h:59
This represents implicit clause 'depend' for the '#pragma omp task' directive.
Expr * getStep()
Returns linear step.
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:502
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:650
This represents 'capture' clause in the '#pragma omp atomic' directive.
Expr - This represents one expression.
Definition: Expr.h:105
SourceLocation getMapLoc() const LLVM_READONLY
Fetches location of clause mapping kind.
llvm::iterator_range< inits_iterator > inits_range
OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build 'if' clause with condition Cond.
Definition: OpenMPClause.h:247
helper_expr_const_range assignment_ops() const
This represents 'simdlen' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:471
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
SourceLocation getScheduleKindLoc()
Get kind location.
Definition: OpenMPClause.h:863
ArrayRef< unsigned > getComponentListSizesRef() const
Get the cumulative component lists sizes that are in the trailing objects of the class.
SmallVector< MappableExprComponentList, 8 > MappableExprComponentLists
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:331
static bool classof(const OMPClause *T)
MutableArrayRef< Expr * > getVarRefs()
Fetches list of variables associated with this clause.
Definition: OpenMPClause.h:140
Inits[]
Definition: OpenMPClause.h:136
helper_expr_const_range reduction_ops() const
const Expr * getAlignment() const
Returns alignment.
void setInits(ArrayRef< Expr * > IL)
Sets the list of the initial values for linear variables.
OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:33
static bool classof(const OMPClause *T)
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:187
MutableArrayRef< Expr * >::iterator private_copies_iterator
SourceLocation getLParenLoc() const
Returns the location of '('.
inits_const_range inits() const
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Definition: OpenMPClause.h:275
static bool classof(const OMPClause *T)
llvm::iterator_range< const_child_iterator > const_child_range
Definition: OpenMPClause.h:64
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:326
void setDeclNumLists(ArrayRef< unsigned > DNLs)
Set the number of lists per declaration that are in the trailing objects of the class.
This represents 'ordered' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:902
const_all_components_range all_components() const
MutableArrayRef< unsigned > getDeclNumListsRef()
Get the number of lists per declaration that are in the trailing objects of the class.
Expr * getCalcStep()
Returns expression to calculate linear step.
const_all_num_lists_range all_num_lists() const
SourceLocation getColonLoc() const
Return the location of ':'.
Definition: OpenMPClause.h:270
ArrayRef< const Expr * >::iterator varlist_const_iterator
Definition: OpenMPClause.h:167
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:267
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:939
helper_expr_const_range rhs_exprs() const
void setPrivateCopies(ArrayRef< Expr * > PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
inits_const_range inits() const
Expr * getDevice()
Return device number.
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
SourceLocation getLParenLoc() const
Returns the location of '('.
This represents 'collapse' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:526
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
SourceLocation getCommaLoc()
Get location of ','.
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:703
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
OpenMPProcBindClauseKind
OpenMP attributes for 'proc_bind' clause.
Definition: OpenMPKinds.h:51
const_component_lists_range decl_component_lists(const ValueDecl *VD) const
const_component_lists_iterator component_lists_end() const
llvm::iterator_range< inits_const_iterator > inits_const_range
OMPThreadLimitClause()
Build an empty clause.
helper_expr_const_range privates() const
helper_expr_range destination_exprs()
helper_expr_const_range destination_exprs() const
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
This represents 'untied' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:984
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:391
helper_expr_range lhs_exprs()
child_range children()
static bool classof(const OMPClause *T)
ArrayRef< const Expr * >::iterator inits_const_iterator
OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'mergeable' clause.
OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'num_threads' clause with condition NumThreads.
Definition: OpenMPClause.h:371
helper_expr_const_range privates() const
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:563
static bool classof(const OMPClause *T)
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:113
SourceLocation getLParenLoc()
Get location of '('.
Definition: OpenMPClause.h:860
helper_expr_range destination_exprs()
void setUniqueDecls(ArrayRef< ValueDecl * > UDs)
Set the unique declarations that are in the trailing objects of the class.
This represents 'num_teams' clause in the '#pragma omp ...' directive.
OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'simdlen' clause.
Definition: OpenMPClause.h:488
#define false
Definition: stdbool.h:33
MutableArrayRef< Expr * >::iterator private_copies_iterator
Kind
SourceLocation getLParenLoc()
Get location of '('.
MappableComponent(Expr *AssociatedExpression, ValueDecl *AssociatedDeclaration)
helper_expr_range private_copies()
ArrayRef< const Expr * >::iterator inits_const_iterator
static OMPFirstprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL, ArrayRef< Expr * > InitVL, Stmt *PreInit)
Creates clause with a list of variables VL.
OMPCollapseClause()
Build an empty clause.
Definition: OpenMPClause.h:551
static bool classof(const OMPClause *T)
OMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'threads' clause.
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:561
Encodes a location in the source.
StmtIterator child_iterator
Definition: OpenMPClause.h:61
This represents 'hint' clause in the '#pragma omp ...' directive.
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition: OpenMPKinds.h:76
helper_expr_const_range reduction_ops() const
MutableArrayRef< Expr * > getInits()
helper_expr_range rhs_exprs()
SourceLocation getLParenLoc() const
Returns the location of '('.
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
private_copies_range private_copies()
void setVarRefs(ArrayRef< Expr * > VL)
Sets the list of variables for this clause.
Definition: OpenMPClause.h:146
const_component_lists_iterator decl_component_lists_begin(const ValueDecl *VD) const
Iterators for component lists associated with the provided declaration.
const_component_lists_iterator component_lists_begin() const
Iterators for all component lists.
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:273
helper_expr_const_range lhs_exprs() const
This represents 'schedule' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:722
OMPMergeableClause()
Build an empty clause.
MutableArrayRef< Expr * >::iterator inits_iterator
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:389
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
This represents clause 'shared' in the '#pragma omp ...' directives.
OMPNumTeamsClause()
Build an empty clause.
varlist_const_iterator varlist_begin() const
Definition: OpenMPClause.h:183
const_all_lists_sizes_range all_lists_sizes() const
child_range children()
Expr * getPriority()
Return Priority number.
MutableArrayRef< Expr * >::iterator helper_expr_iterator
OpenMPLinearClauseKind Modifier
Modifier of 'linear' clause.
Definition: OpenMPClause.h:86
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
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:33
SourceLocation getDefaultmapModifierLoc() const
Get the modifier location.
child_range children()
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
OMPDeviceClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'device' clause.
OpenMPMapClauseKind getMapTypeModifier() const LLVM_READONLY
Fetches the map type modifier for the clause.
static bool classof(const OMPClause *T)
child_range children()
SourceLocation getLParenLoc() const
Returns the location of '('.
ArrayRef< const Expr * >::iterator privates_const_iterator
SourceLocation getDependencyLoc() const
Get dependency type location.
child_range children()
helper_expr_range reduction_ops()
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
static bool classof(const OMPClause *T)
llvm::iterator_range< helper_expr_iterator > helper_expr_range
Expr * getGrainsize() const
Return safe iteration space distance.
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
const Expr * getChunkSize() const
Get chunk size.
Definition: OpenMPClause.h:882
OMPDefaultmapClause()
Build an empty clause.
void setStep(Expr *Step)
Sets the linear step for clause.
Definition: OpenMPClause.h:93
llvm::iterator_range< const_all_num_lists_iterator > const_all_num_lists_range
child_range children()
Definition: OpenMPClause.h:511
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition: OpenMPKinds.h:67
const_all_decls_range all_decls() const
This represents 'device' clause in the '#pragma omp ...' directive.
child_range children()
helper_expr_const_range rhs_exprs() const
OMPThreadsClause()
Build an empty clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
SourceLocation ModifierLoc
Location of linear modifier if any.
Definition: OpenMPClause.h:88
Expr * getDevice() const
Return device number.
child_range children()
static bool classof(const OMPClause *T)
static bool classof(const OMPClause *T)
ArrayRef< MappableExprComponentList > MappableExprComponentListsRef
OMPNumThreadsClause()
Build an empty clause.
Definition: OpenMPClause.h:383
Expr * getNumTasks() const
Return safe iteration space distance.
MutableArrayRef< ValueDecl * > getUniqueDeclsRef()
Get the unique declarations that are in the trailing objects of the class.
SourceLocation getLParenLoc()
Get location of '('.
unsigned getUniqueDeclarationsNum() const
Return the number of unique base declarations in this clause.
Stmt * getPreInitStmt()
Get pre-initialization statement for the clause.
Definition: OpenMPClause.h:98
U cast(CodeGen::Address addr)
Definition: Address.h:109
static bool classof(const OMPClause *T)
This represents clause 'linear' in the '#pragma omp ...' directives.
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:884
detail::InMemoryDirectory::const_iterator E
ArrayRef< const Expr * >::iterator private_copies_const_iterator
SourceLocation getColonLoc() const
Returns the location of ':'.
static bool classof(const OMPClause *T)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
llvm::iterator_range< privates_iterator > privates_range
ArrayRef< ValueDecl * >::iterator const_all_decls_iterator
Iterators to access all the declarations, number of lists, list sizes, and components.
void setLocStart(SourceLocation Loc)
Sets the starting location of the clause.
Definition: OpenMPClause.h:52
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static bool classof(const OMPClause *T)
std::pair< const ValueDecl *, MappableExprComponentListRef > operator->() const
bool isImplicitMapType() const LLVM_READONLY
Is this an implicit map type? We have to capture 'IsMapTypeImplicit' from the parser for more informa...
llvm::iterator_range< inits_iterator > inits_range
SmallVector< MappableComponent, 8 > MappableExprComponentList
void setComponentListSizes(ArrayRef< unsigned > CLSs)
Set the cumulative component lists sizes that are in the trailing objects of the class.
llvm::iterator_range< helper_expr_iterator > helper_expr_range
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:450
Expr * getPriority() const
Return Priority number.
OMPDefaultClause(OpenMPDefaultClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'default' clause with argument A ('none' or 'shared').
Definition: OpenMPClause.h:608
MutableArrayRef< Expr * >::iterator helper_expr_iterator
ConstStmtIterator const_child_iterator
Definition: OpenMPClause.h:62
OMPReadClause()
Build an empty clause.
OMPThreadLimitClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'thread_limit' clause.
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:624
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
friend TrailingObjects
Definition: OpenMPClause.h:82
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:558
OMPUntiedClause()
Build an empty clause.
Definition: OpenMPClause.h:996
ArrayRef< unsigned > getDeclNumListsRef() const
Get the number of lists per declaration that are in the trailing objects of the class.
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition: OpenMPKinds.h:59
OMPFinalClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'final' clause with condition Cond.
Definition: OpenMPClause.h:314
OpenMPDefaultClauseKind
OpenMP attributes for 'default' clause.
Definition: OpenMPKinds.h:43
OMPDeviceClause()
Build an empty clause.
SourceLocation getDistScheduleKindLoc()
Get kind location.
OMPNowaitClause()
Build an empty clause.
Definition: OpenMPClause.h:965
privates_range privates()
MutableArrayRef< Expr * >::iterator helper_expr_iterator
This represents 'write' clause in the '#pragma omp atomic' directive.
MutableArrayRef< Expr * >::iterator inits_iterator
OMPNumTasksClause()
Build an empty clause.
MutableArrayRef< Expr * >::iterator private_copies_iterator
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:447
static bool classof(const OMPClause *T)
helper_expr_const_range destination_exprs() const
llvm::iterator_range< const_all_components_iterator > const_all_components_range
child_range children()
Defines the clang::SourceLocation class and associated facilities.
This represents 'nowait' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:953
MutableArrayRef< MappableComponent > getComponentsRef()
Get the components that are in the trailing objects of the class.
helper_expr_range reduction_ops()
varlist_iterator varlist_end()
Definition: OpenMPClause.h:182
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
child_range children()
MutableArrayRef< Expr * >::iterator finals_iterator
MutableArrayRef< Expr * >::iterator helper_expr_iterator
Privates[]
Gets the list of initial values for linear variables.
Definition: OpenMPClause.h:136
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition: OpenMPKinds.h:92
MutableArrayRef< Expr * >::iterator updates_iterator
OMPClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation EndLoc)
Definition: OpenMPClause.h:42
OMPSimdlenClause()
Build an empty clause.
Definition: OpenMPClause.h:495
child_range children()
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
helper_expr_const_range assignment_ops() const
Expr * getThreadLimit()
Return ThreadLimit number.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
OMPIfClause()
Build an empty clause.
Definition: OpenMPClause.h:259
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:445
OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KLoc, SourceLocation CommaLoc, SourceLocation EndLoc, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, Stmt *HelperChunkSize, OpenMPScheduleClauseModifier M1, SourceLocation M1Loc, OpenMPScheduleClauseModifier M2, SourceLocation M2Loc)
Build 'schedule' clause with schedule kind Kind and chunk size expression ChunkSize.
Definition: OpenMPClause.h:819
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=OMPD_unknown)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:85
OMPUpdateClause()
Build an empty clause.
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
void setPrivates(ArrayRef< Expr * > PL)
Sets the list of the copies of original linear variables.
llvm::iterator_range< updates_const_iterator > updates_const_range
OMPGrainsizeClause()
Build an empty clause.
child_range children()
Definition: OpenMPClause.h:456
SourceLocation getLParenLoc() const
Returns the location of '('.
child_range children()
static bool classof(const OMPClause *T)
Expr * getChunkSize()
Get chunk size.
Definition: OpenMPClause.h:879
llvm::iterator_range< finals_iterator > finals_range
const Stmt * getPreInitStmt() const
Get pre-initialization statement for the clause.
Definition: OpenMPClause.h:96
ArrayRef< unsigned >::iterator const_all_lists_sizes_iterator
OMPReadClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'read' clause.
helper_expr_const_range destination_exprs() const
SourceLocation getModifierLoc() const
Return modifier location.
OMPClauseWithPostUpdate(const OMPClause *This)
Definition: OpenMPClause.h:114
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
child_range children()
static bool classof(const OMPClause *T)
child_range children()
child_range children()
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
Definition: OpenMPClause.h:278
child_range children()
SourceLocation ColonLoc
Location of ':'.
Definition: OpenMPClause.h:90
ArrayRef< MappableComponent > getComponentsRef() const
Get the components that are in the trailing objects of the class.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:265
unsigned varlist_size() const
Definition: OpenMPClause.h:171
OMPOrderedClause()
Build an empty clause.
Definition: OpenMPClause.h:927
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.
OMPDefaultClause()
Build an empty clause.
Definition: OpenMPClause.h:616
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:280
helper_expr_const_range assignment_ops() const
OMPClauseWithPreInit(const OMPClause *This)
Definition: OpenMPClause.h:89
helper_expr_const_range source_exprs() const
static bool classof(const OMPClause *T)