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