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