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