clang  6.0.0svn
StmtOpenMP.h
Go to the documentation of this file.
1 //===- StmtOpenMP.h - Classes for OpenMP directives ------------*- 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 executable directives and
11 /// clauses.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_AST_STMTOPENMP_H
16 #define LLVM_CLANG_AST_STMTOPENMP_H
17 
18 #include "clang/AST/Expr.h"
19 #include "clang/AST/OpenMPClause.h"
20 #include "clang/AST/Stmt.h"
23 
24 namespace clang {
25 
26 //===----------------------------------------------------------------------===//
27 // AST classes for directives.
28 //===----------------------------------------------------------------------===//
29 
30 /// \brief This is a basic class for representing single OpenMP executable
31 /// directive.
32 ///
33 class OMPExecutableDirective : public Stmt {
34  friend class ASTStmtReader;
35  /// \brief Kind of the directive.
37  /// \brief Starting location of the directive (directive keyword).
38  SourceLocation StartLoc;
39  /// \brief Ending location of the directive.
40  SourceLocation EndLoc;
41  /// \brief Numbers of clauses.
42  const unsigned NumClauses;
43  /// \brief Number of child expressions/stmts.
44  const unsigned NumChildren;
45  /// \brief Offset from this to the start of clauses.
46  /// There are NumClauses pointers to clauses, they are followed by
47  /// NumChildren pointers to child stmts/exprs (if the directive type
48  /// requires an associated stmt, then it has to be the first of them).
49  const unsigned ClausesOffset;
50 
51  /// \brief Get the clauses storage.
52  MutableArrayRef<OMPClause *> getClauses() {
53  OMPClause **ClauseStorage = reinterpret_cast<OMPClause **>(
54  reinterpret_cast<char *>(this) + ClausesOffset);
55  return MutableArrayRef<OMPClause *>(ClauseStorage, NumClauses);
56  }
57 
58 protected:
59  /// \brief Build instance of directive of class \a K.
60  ///
61  /// \param SC Statement class.
62  /// \param K Kind of OpenMP directive.
63  /// \param StartLoc Starting location of the directive (directive keyword).
64  /// \param EndLoc Ending location of the directive.
65  ///
66  template <typename T>
68  SourceLocation StartLoc, SourceLocation EndLoc,
69  unsigned NumClauses, unsigned NumChildren)
70  : Stmt(SC), Kind(K), StartLoc(std::move(StartLoc)),
71  EndLoc(std::move(EndLoc)), NumClauses(NumClauses),
72  NumChildren(NumChildren),
73  ClausesOffset(llvm::alignTo(sizeof(T), alignof(OMPClause *))) {}
74 
75  /// \brief Sets the list of variables for this clause.
76  ///
77  /// \param Clauses The list of clauses for the directive.
78  ///
79  void setClauses(ArrayRef<OMPClause *> Clauses);
80 
81  /// \brief Set the associated statement for the directive.
82  ///
83  /// /param S Associated statement.
84  ///
86  assert(hasAssociatedStmt() && "no associated statement.");
87  *child_begin() = S;
88  }
89 
90 public:
91  /// \brief Iterates over a filtered subrange of clauses applied to a
92  /// directive.
93  ///
94  /// This iterator visits only clauses of type SpecificClause.
95  template <typename SpecificClause>
97  : public llvm::iterator_adaptor_base<
98  specific_clause_iterator<SpecificClause>,
99  ArrayRef<OMPClause *>::const_iterator, std::forward_iterator_tag,
100  const SpecificClause *, ptrdiff_t, const SpecificClause *,
101  const SpecificClause *> {
103 
104  void SkipToNextClause() {
105  while (this->I != End && !isa<SpecificClause>(*this->I))
106  ++this->I;
107  }
108 
109  public:
111  : specific_clause_iterator::iterator_adaptor_base(Clauses.begin()),
112  End(Clauses.end()) {
113  SkipToNextClause();
114  }
115 
116  const SpecificClause *operator*() const {
117  return cast<SpecificClause>(*this->I);
118  }
119  const SpecificClause *operator->() const { return **this; }
120 
122  ++this->I;
123  SkipToNextClause();
124  return *this;
125  }
126  };
127 
128  template <typename SpecificClause>
129  static llvm::iterator_range<specific_clause_iterator<SpecificClause>>
133  llvm::makeArrayRef(Clauses.end(), 0))};
134  }
135 
136  template <typename SpecificClause>
137  llvm::iterator_range<specific_clause_iterator<SpecificClause>>
139  return getClausesOfKind<SpecificClause>(clauses());
140  }
141 
142  /// Gets a single clause of the specified kind associated with the
143  /// current directive iff there is only one clause of this kind (and assertion
144  /// is fired if there is more than one clause is associated with the
145  /// directive). Returns nullptr if no clause of this kind is associated with
146  /// the directive.
147  template <typename SpecificClause>
148  const SpecificClause *getSingleClause() const {
149  auto Clauses = getClausesOfKind<SpecificClause>();
150 
151  if (Clauses.begin() != Clauses.end()) {
152  assert(std::next(Clauses.begin()) == Clauses.end() &&
153  "There are at least 2 clauses of the specified kind");
154  return *Clauses.begin();
155  }
156  return nullptr;
157  }
158 
159  /// Returns true if the current directive has one or more clauses of a
160  /// specific kind.
161  template <typename SpecificClause>
162  bool hasClausesOfKind() const {
163  auto Clauses = getClausesOfKind<SpecificClause>();
164  return Clauses.begin() != Clauses.end();
165  }
166 
167  /// \brief Returns starting location of directive kind.
168  SourceLocation getLocStart() const { return StartLoc; }
169  /// \brief Returns ending location of directive.
170  SourceLocation getLocEnd() const { return EndLoc; }
171 
172  /// \brief Set starting location of directive kind.
173  ///
174  /// \param Loc New starting location of directive.
175  ///
176  void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
177  /// \brief Set ending location of directive.
178  ///
179  /// \param Loc New ending location of directive.
180  ///
181  void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
182 
183  /// \brief Get number of clauses.
184  unsigned getNumClauses() const { return NumClauses; }
185 
186  /// \brief Returns specified clause.
187  ///
188  /// \param i Number of clause.
189  ///
190  OMPClause *getClause(unsigned i) const { return clauses()[i]; }
191 
192  /// \brief Returns true if directive has associated statement.
193  bool hasAssociatedStmt() const { return NumChildren > 0; }
194 
195  /// \brief Returns statement associated with the directive.
197  assert(hasAssociatedStmt() && "no associated statement.");
198  return const_cast<Stmt *>(*child_begin());
199  }
200 
201  /// \brief Returns the captured statement associated with the
202  /// component region within the (combined) directive.
203  //
204  // \param RegionKind Component region kind.
207  getOpenMPCaptureRegions(CaptureRegions, getDirectiveKind());
208  assert(std::any_of(
209  CaptureRegions.begin(), CaptureRegions.end(),
210  [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) &&
211  "RegionKind not found in OpenMP CaptureRegions.");
212  auto *CS = cast<CapturedStmt>(getAssociatedStmt());
213  for (auto ThisCaptureRegion : CaptureRegions) {
214  if (ThisCaptureRegion == RegionKind)
215  return CS;
216  CS = cast<CapturedStmt>(CS->getCapturedStmt());
217  }
218  llvm_unreachable("Incorrect RegionKind specified for directive.");
219  }
220 
221  OpenMPDirectiveKind getDirectiveKind() const { return Kind; }
222 
223  static bool classof(const Stmt *S) {
224  return S->getStmtClass() >= firstOMPExecutableDirectiveConstant &&
225  S->getStmtClass() <= lastOMPExecutableDirectiveConstant;
226  }
227 
229  if (!hasAssociatedStmt())
231  Stmt **ChildStorage = reinterpret_cast<Stmt **>(getClauses().end());
232  return child_range(ChildStorage, ChildStorage + NumChildren);
233  }
234 
235  ArrayRef<OMPClause *> clauses() { return getClauses(); }
236 
238  return const_cast<OMPExecutableDirective *>(this)->getClauses();
239  }
240 };
241 
242 /// \brief This represents '#pragma omp parallel' directive.
243 ///
244 /// \code
245 /// #pragma omp parallel private(a,b) reduction(+: c,d)
246 /// \endcode
247 /// In this example directive '#pragma omp parallel' has clauses 'private'
248 /// with the variables 'a' and 'b' and 'reduction' with operator '+' and
249 /// variables 'c' and 'd'.
250 ///
252  friend class ASTStmtReader;
253  /// \brief true if the construct has inner cancel directive.
254  bool HasCancel;
255 
256  /// \brief Build directive with the given start and end location.
257  ///
258  /// \param StartLoc Starting location of the directive (directive keyword).
259  /// \param EndLoc Ending Location of the directive.
260  ///
262  unsigned NumClauses)
263  : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
264  StartLoc, EndLoc, NumClauses, 1),
265  HasCancel(false) {}
266 
267  /// \brief Build an empty directive.
268  ///
269  /// \param NumClauses Number of clauses.
270  ///
271  explicit OMPParallelDirective(unsigned NumClauses)
272  : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
273  SourceLocation(), SourceLocation(), NumClauses,
274  1),
275  HasCancel(false) {}
276 
277  /// \brief Set cancel state.
278  void setHasCancel(bool Has) { HasCancel = Has; }
279 
280 public:
281  /// \brief Creates directive with a list of \a Clauses.
282  ///
283  /// \param C AST context.
284  /// \param StartLoc Starting location of the directive kind.
285  /// \param EndLoc Ending Location of the directive.
286  /// \param Clauses List of clauses.
287  /// \param AssociatedStmt Statement associated with the directive.
288  /// \param HasCancel true if this directive has inner cancel directive.
289  ///
290  static OMPParallelDirective *
291  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
292  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel);
293 
294  /// \brief Creates an empty directive with the place for \a N clauses.
295  ///
296  /// \param C AST context.
297  /// \param NumClauses Number of clauses.
298  ///
300  unsigned NumClauses, EmptyShell);
301 
302  /// \brief Return true if current directive has inner cancel directive.
303  bool hasCancel() const { return HasCancel; }
304 
305  static bool classof(const Stmt *T) {
306  return T->getStmtClass() == OMPParallelDirectiveClass;
307  }
308 };
309 
310 /// \brief This is a common base class for loop directives ('omp simd', 'omp
311 /// for', 'omp for simd' etc.). It is responsible for the loop code generation.
312 ///
314  friend class ASTStmtReader;
315  /// \brief Number of collapsed loops as specified by 'collapse' clause.
316  unsigned CollapsedNum;
317 
318  /// \brief Offsets to the stored exprs.
319  /// This enumeration contains offsets to all the pointers to children
320  /// expressions stored in OMPLoopDirective.
321  /// The first 9 children are necessary for all the loop directives,
322  /// the next 8 are specific to the worksharing ones, and the next 11 are
323  /// used for combined constructs containing two pragmas associated to loops.
324  /// After the fixed children, three arrays of length CollapsedNum are
325  /// allocated: loop counters, their updates and final values.
326  /// PrevLowerBound and PrevUpperBound are used to communicate blocking
327  /// information in composite constructs which require loop blocking
328  /// DistInc is used to generate the increment expression for the distribute
329  /// loop when combined with a further nested loop
330  /// PrevEnsureUpperBound is used as the EnsureUpperBound expression for the
331  /// for loop when combined with a previous distribute loop in the same pragma
332  /// (e.g. 'distribute parallel for')
333  ///
334  enum {
335  AssociatedStmtOffset = 0,
336  IterationVariableOffset = 1,
337  LastIterationOffset = 2,
338  CalcLastIterationOffset = 3,
339  PreConditionOffset = 4,
340  CondOffset = 5,
341  InitOffset = 6,
342  IncOffset = 7,
343  PreInitsOffset = 8,
344  // The '...End' enumerators do not correspond to child expressions - they
345  // specify the offset to the end (and start of the following counters/
346  // updates/finals arrays).
347  DefaultEnd = 9,
348  // The following 8 exprs are used by worksharing and distribute loops only.
349  IsLastIterVariableOffset = 9,
350  LowerBoundVariableOffset = 10,
351  UpperBoundVariableOffset = 11,
352  StrideVariableOffset = 12,
353  EnsureUpperBoundOffset = 13,
354  NextLowerBoundOffset = 14,
355  NextUpperBoundOffset = 15,
356  NumIterationsOffset = 16,
357  // Offset to the end for worksharing loop directives.
358  WorksharingEnd = 17,
359  PrevLowerBoundVariableOffset = 17,
360  PrevUpperBoundVariableOffset = 18,
361  DistIncOffset = 19,
362  PrevEnsureUpperBoundOffset = 20,
363  CombinedLowerBoundVariableOffset = 21,
364  CombinedUpperBoundVariableOffset = 22,
365  CombinedEnsureUpperBoundOffset = 23,
366  CombinedInitOffset = 24,
367  CombinedConditionOffset = 25,
368  CombinedNextLowerBoundOffset = 26,
369  CombinedNextUpperBoundOffset = 27,
370  // Offset to the end (and start of the following counters/updates/finals
371  // arrays) for combined distribute loop directives.
372  CombinedDistributeEnd = 28,
373  };
374 
375  /// \brief Get the counters storage.
376  MutableArrayRef<Expr *> getCounters() {
377  Expr **Storage = reinterpret_cast<Expr **>(
378  &(*(std::next(child_begin(), getArraysOffset(getDirectiveKind())))));
379  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
380  }
381 
382  /// \brief Get the private counters storage.
383  MutableArrayRef<Expr *> getPrivateCounters() {
384  Expr **Storage = reinterpret_cast<Expr **>(&*std::next(
385  child_begin(), getArraysOffset(getDirectiveKind()) + CollapsedNum));
386  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
387  }
388 
389  /// \brief Get the updates storage.
391  Expr **Storage = reinterpret_cast<Expr **>(
392  &*std::next(child_begin(),
393  getArraysOffset(getDirectiveKind()) + 2 * CollapsedNum));
394  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
395  }
396 
397  /// \brief Get the updates storage.
399  Expr **Storage = reinterpret_cast<Expr **>(
400  &*std::next(child_begin(),
401  getArraysOffset(getDirectiveKind()) + 3 * CollapsedNum));
402  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
403  }
404 
405  /// \brief Get the final counter updates storage.
407  Expr **Storage = reinterpret_cast<Expr **>(
408  &*std::next(child_begin(),
409  getArraysOffset(getDirectiveKind()) + 4 * CollapsedNum));
410  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
411  }
412 
413 protected:
414  /// \brief Build instance of loop directive of class \a Kind.
415  ///
416  /// \param SC Statement class.
417  /// \param Kind Kind of OpenMP directive.
418  /// \param StartLoc Starting location of the directive (directive keyword).
419  /// \param EndLoc Ending location of the directive.
420  /// \param CollapsedNum Number of collapsed loops from 'collapse' clause.
421  /// \param NumClauses Number of clauses.
422  /// \param NumSpecialChildren Number of additional directive-specific stmts.
423  ///
424  template <typename T>
426  SourceLocation StartLoc, SourceLocation EndLoc,
427  unsigned CollapsedNum, unsigned NumClauses,
428  unsigned NumSpecialChildren = 0)
429  : OMPExecutableDirective(That, SC, Kind, StartLoc, EndLoc, NumClauses,
430  numLoopChildren(CollapsedNum, Kind) +
431  NumSpecialChildren),
432  CollapsedNum(CollapsedNum) {}
433 
434  /// \brief Offset to the start of children expression arrays.
437  return CombinedDistributeEnd;
440  return WorksharingEnd;
441  return DefaultEnd;
442  }
443 
444  /// \brief Children number.
445  static unsigned numLoopChildren(unsigned CollapsedNum,
447  return getArraysOffset(Kind) + 5 * CollapsedNum; // Counters,
448  // PrivateCounters, Inits,
449  // Updates and Finals
450  }
451 
453  *std::next(child_begin(), IterationVariableOffset) = IV;
454  }
455  void setLastIteration(Expr *LI) {
456  *std::next(child_begin(), LastIterationOffset) = LI;
457  }
459  *std::next(child_begin(), CalcLastIterationOffset) = CLI;
460  }
461  void setPreCond(Expr *PC) {
462  *std::next(child_begin(), PreConditionOffset) = PC;
463  }
464  void setCond(Expr *Cond) {
465  *std::next(child_begin(), CondOffset) = Cond;
466  }
467  void setInit(Expr *Init) { *std::next(child_begin(), InitOffset) = Init; }
468  void setInc(Expr *Inc) { *std::next(child_begin(), IncOffset) = Inc; }
469  void setPreInits(Stmt *PreInits) {
470  *std::next(child_begin(), PreInitsOffset) = PreInits;
471  }
476  "expected worksharing loop directive");
477  *std::next(child_begin(), IsLastIterVariableOffset) = IL;
478  }
483  "expected worksharing loop directive");
484  *std::next(child_begin(), LowerBoundVariableOffset) = LB;
485  }
490  "expected worksharing loop directive");
491  *std::next(child_begin(), UpperBoundVariableOffset) = UB;
492  }
497  "expected worksharing loop directive");
498  *std::next(child_begin(), StrideVariableOffset) = ST;
499  }
504  "expected worksharing loop directive");
505  *std::next(child_begin(), EnsureUpperBoundOffset) = EUB;
506  }
507  void setNextLowerBound(Expr *NLB) {
511  "expected worksharing loop directive");
512  *std::next(child_begin(), NextLowerBoundOffset) = NLB;
513  }
514  void setNextUpperBound(Expr *NUB) {
518  "expected worksharing loop directive");
519  *std::next(child_begin(), NextUpperBoundOffset) = NUB;
520  }
521  void setNumIterations(Expr *NI) {
525  "expected worksharing loop directive");
526  *std::next(child_begin(), NumIterationsOffset) = NI;
527  }
530  "expected loop bound sharing directive");
531  *std::next(child_begin(), PrevLowerBoundVariableOffset) = PrevLB;
532  }
535  "expected loop bound sharing directive");
536  *std::next(child_begin(), PrevUpperBoundVariableOffset) = PrevUB;
537  }
538  void setDistInc(Expr *DistInc) {
540  "expected loop bound sharing directive");
541  *std::next(child_begin(), DistIncOffset) = DistInc;
542  }
543  void setPrevEnsureUpperBound(Expr *PrevEUB) {
545  "expected loop bound sharing directive");
546  *std::next(child_begin(), PrevEnsureUpperBoundOffset) = PrevEUB;
547  }
550  "expected loop bound sharing directive");
551  *std::next(child_begin(), CombinedLowerBoundVariableOffset) = CombLB;
552  }
555  "expected loop bound sharing directive");
556  *std::next(child_begin(), CombinedUpperBoundVariableOffset) = CombUB;
557  }
560  "expected loop bound sharing directive");
561  *std::next(child_begin(), CombinedEnsureUpperBoundOffset) = CombEUB;
562  }
563  void setCombinedInit(Expr *CombInit) {
565  "expected loop bound sharing directive");
566  *std::next(child_begin(), CombinedInitOffset) = CombInit;
567  }
568  void setCombinedCond(Expr *CombCond) {
570  "expected loop bound sharing directive");
571  *std::next(child_begin(), CombinedConditionOffset) = CombCond;
572  }
575  "expected loop bound sharing directive");
576  *std::next(child_begin(), CombinedNextLowerBoundOffset) = CombNLB;
577  }
580  "expected loop bound sharing directive");
581  *std::next(child_begin(), CombinedNextUpperBoundOffset) = CombNUB;
582  }
583  void setCounters(ArrayRef<Expr *> A);
584  void setPrivateCounters(ArrayRef<Expr *> A);
585  void setInits(ArrayRef<Expr *> A);
587  void setFinals(ArrayRef<Expr *> A);
588 
589 public:
590  /// The expressions built to support OpenMP loops in combined/composite
591  /// pragmas (e.g. pragma omp distribute parallel for)
593  /// DistributeLowerBound - used when composing 'omp distribute' with
594  /// 'omp for' in a same construct.
596  /// DistributeUpperBound - used when composing 'omp distribute' with
597  /// 'omp for' in a same construct.
599  /// DistributeEnsureUpperBound - used when composing 'omp distribute'
600  /// with 'omp for' in a same construct, EUB depends on DistUB
602  /// Distribute loop iteration variable init used when composing 'omp
603  /// distribute'
604  /// with 'omp for' in a same construct
606  /// Distribute Loop condition used when composing 'omp distribute'
607  /// with 'omp for' in a same construct
609  /// Update of LowerBound for statically sheduled omp loops for
610  /// outer loop in combined constructs (e.g. 'distribute parallel for')
612  /// Update of UpperBound for statically sheduled omp loops for
613  /// outer loop in combined constructs (e.g. 'distribute parallel for')
615  };
616 
617  /// \brief The expressions built for the OpenMP loop CodeGen for the
618  /// whole collapsed loop nest.
619  struct HelperExprs {
620  /// \brief Loop iteration variable.
622  /// \brief Loop last iteration number.
624  /// \brief Loop number of iterations.
626  /// \brief Calculation of last iteration.
628  /// \brief Loop pre-condition.
630  /// \brief Loop condition.
632  /// \brief Loop iteration variable init.
634  /// \brief Loop increment.
636  /// \brief IsLastIteration - local flag variable passed to runtime.
638  /// \brief LowerBound - local variable passed to runtime.
640  /// \brief UpperBound - local variable passed to runtime.
642  /// \brief Stride - local variable passed to runtime.
644  /// \brief EnsureUpperBound -- expression UB = min(UB, NumIterations).
646  /// \brief Update of LowerBound for statically sheduled 'omp for' loops.
648  /// \brief Update of UpperBound for statically sheduled 'omp for' loops.
650  /// \brief PreviousLowerBound - local variable passed to runtime in the
651  /// enclosing schedule or null if that does not apply.
653  /// \brief PreviousUpperBound - local variable passed to runtime in the
654  /// enclosing schedule or null if that does not apply.
656  /// \brief DistInc - increment expression for distribute loop when found
657  /// combined with a further loop level (e.g. in 'distribute parallel for')
658  /// expression IV = IV + ST
660  /// \brief PrevEUB - expression similar to EUB but to be used when loop
661  /// scheduling uses PrevLB and PrevUB (e.g. in 'distribute parallel for'
662  /// when ensuring that the UB is either the calculated UB by the runtime or
663  /// the end of the assigned distribute chunk)
664  /// expression UB = min (UB, PrevUB)
666  /// \brief Counters Loop counters.
668  /// \brief PrivateCounters Loop counters.
670  /// \brief Expressions for loop counters inits for CodeGen.
672  /// \brief Expressions for loop counters update for CodeGen.
674  /// \brief Final loop counter values for GodeGen.
676  /// Init statement for all captured expressions.
678 
679  /// Expressions used when combining OpenMP loop pragmas
681 
682  /// \brief Check if all the expressions are built (does not check the
683  /// worksharing ones).
684  bool builtAll() {
685  return IterationVarRef != nullptr && LastIteration != nullptr &&
686  NumIterations != nullptr && PreCond != nullptr &&
687  Cond != nullptr && Init != nullptr && Inc != nullptr;
688  }
689 
690  /// \brief Initialize all the fields to null.
691  /// \param Size Number of elements in the counters/finals/updates arrays.
692  void clear(unsigned Size) {
693  IterationVarRef = nullptr;
694  LastIteration = nullptr;
695  CalcLastIteration = nullptr;
696  PreCond = nullptr;
697  Cond = nullptr;
698  Init = nullptr;
699  Inc = nullptr;
700  IL = nullptr;
701  LB = nullptr;
702  UB = nullptr;
703  ST = nullptr;
704  EUB = nullptr;
705  NLB = nullptr;
706  NUB = nullptr;
707  NumIterations = nullptr;
708  PrevLB = nullptr;
709  PrevUB = nullptr;
710  DistInc = nullptr;
711  PrevEUB = nullptr;
712  Counters.resize(Size);
713  PrivateCounters.resize(Size);
714  Inits.resize(Size);
715  Updates.resize(Size);
716  Finals.resize(Size);
717  for (unsigned i = 0; i < Size; ++i) {
718  Counters[i] = nullptr;
719  PrivateCounters[i] = nullptr;
720  Inits[i] = nullptr;
721  Updates[i] = nullptr;
722  Finals[i] = nullptr;
723  }
724  PreInits = nullptr;
725  DistCombinedFields.LB = nullptr;
726  DistCombinedFields.UB = nullptr;
727  DistCombinedFields.EUB = nullptr;
728  DistCombinedFields.Init = nullptr;
729  DistCombinedFields.Cond = nullptr;
730  DistCombinedFields.NLB = nullptr;
731  DistCombinedFields.NUB = nullptr;
732  }
733  };
734 
735  /// \brief Get number of collapsed loops.
736  unsigned getCollapsedNumber() const { return CollapsedNum; }
737 
739  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
740  *std::next(child_begin(), IterationVariableOffset)));
741  }
743  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
744  *std::next(child_begin(), LastIterationOffset)));
745  }
747  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
748  *std::next(child_begin(), CalcLastIterationOffset)));
749  }
750  Expr *getPreCond() const {
751  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
752  *std::next(child_begin(), PreConditionOffset)));
753  }
754  Expr *getCond() const {
755  return const_cast<Expr *>(
756  reinterpret_cast<const Expr *>(*std::next(child_begin(), CondOffset)));
757  }
758  Expr *getInit() const {
759  return const_cast<Expr *>(
760  reinterpret_cast<const Expr *>(*std::next(child_begin(), InitOffset)));
761  }
762  Expr *getInc() const {
763  return const_cast<Expr *>(
764  reinterpret_cast<const Expr *>(*std::next(child_begin(), IncOffset)));
765  }
766  const Stmt *getPreInits() const {
767  return *std::next(child_begin(), PreInitsOffset);
768  }
769  Stmt *getPreInits() { return *std::next(child_begin(), PreInitsOffset); }
774  "expected worksharing loop directive");
775  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
776  *std::next(child_begin(), IsLastIterVariableOffset)));
777  }
782  "expected worksharing loop directive");
783  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
784  *std::next(child_begin(), LowerBoundVariableOffset)));
785  }
790  "expected worksharing loop directive");
791  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
792  *std::next(child_begin(), UpperBoundVariableOffset)));
793  }
798  "expected worksharing loop directive");
799  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
800  *std::next(child_begin(), StrideVariableOffset)));
801  }
806  "expected worksharing loop directive");
807  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
808  *std::next(child_begin(), EnsureUpperBoundOffset)));
809  }
814  "expected worksharing loop directive");
815  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
816  *std::next(child_begin(), NextLowerBoundOffset)));
817  }
822  "expected worksharing loop directive");
823  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
824  *std::next(child_begin(), NextUpperBoundOffset)));
825  }
830  "expected worksharing loop directive");
831  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
832  *std::next(child_begin(), NumIterationsOffset)));
833  }
836  "expected loop bound sharing directive");
837  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
838  *std::next(child_begin(), PrevLowerBoundVariableOffset)));
839  }
842  "expected loop bound sharing directive");
843  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
844  *std::next(child_begin(), PrevUpperBoundVariableOffset)));
845  }
846  Expr *getDistInc() const {
848  "expected loop bound sharing directive");
849  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
850  *std::next(child_begin(), DistIncOffset)));
851  }
854  "expected loop bound sharing directive");
855  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
856  *std::next(child_begin(), PrevEnsureUpperBoundOffset)));
857  }
860  "expected loop bound sharing directive");
861  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
862  *std::next(child_begin(), CombinedLowerBoundVariableOffset)));
863  }
866  "expected loop bound sharing directive");
867  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
868  *std::next(child_begin(), CombinedUpperBoundVariableOffset)));
869  }
872  "expected loop bound sharing directive");
873  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
874  *std::next(child_begin(), CombinedEnsureUpperBoundOffset)));
875  }
878  "expected loop bound sharing directive");
879  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
880  *std::next(child_begin(), CombinedInitOffset)));
881  }
884  "expected loop bound sharing directive");
885  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
886  *std::next(child_begin(), CombinedConditionOffset)));
887  }
890  "expected loop bound sharing directive");
891  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
892  *std::next(child_begin(), CombinedNextLowerBoundOffset)));
893  }
896  "expected loop bound sharing directive");
897  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
898  *std::next(child_begin(), CombinedNextUpperBoundOffset)));
899  }
900  const Stmt *getBody() const {
901  // This relies on the loop form is already checked by Sema.
902  const Stmt *Body = getAssociatedStmt()->IgnoreContainers(true);
903  while(const auto *CS = dyn_cast<CapturedStmt>(Body))
904  Body = CS->getCapturedStmt();
905  Body = cast<ForStmt>(Body)->getBody();
906  for (unsigned Cnt = 1; Cnt < CollapsedNum; ++Cnt) {
907  Body = Body->IgnoreContainers();
908  Body = cast<ForStmt>(Body)->getBody();
909  }
910  return Body;
911  }
912 
913  ArrayRef<Expr *> counters() { return getCounters(); }
914 
916  return const_cast<OMPLoopDirective *>(this)->getCounters();
917  }
918 
919  ArrayRef<Expr *> private_counters() { return getPrivateCounters(); }
920 
922  return const_cast<OMPLoopDirective *>(this)->getPrivateCounters();
923  }
924 
926 
928  return const_cast<OMPLoopDirective *>(this)->getInits();
929  }
930 
932 
934  return const_cast<OMPLoopDirective *>(this)->getUpdates();
935  }
936 
938 
940  return const_cast<OMPLoopDirective *>(this)->getFinals();
941  }
942 
943  static bool classof(const Stmt *T) {
944  return T->getStmtClass() == OMPSimdDirectiveClass ||
945  T->getStmtClass() == OMPForDirectiveClass ||
946  T->getStmtClass() == OMPForSimdDirectiveClass ||
947  T->getStmtClass() == OMPParallelForDirectiveClass ||
948  T->getStmtClass() == OMPParallelForSimdDirectiveClass ||
949  T->getStmtClass() == OMPTaskLoopDirectiveClass ||
950  T->getStmtClass() == OMPTaskLoopSimdDirectiveClass ||
951  T->getStmtClass() == OMPDistributeDirectiveClass ||
952  T->getStmtClass() == OMPTargetParallelForDirectiveClass ||
953  T->getStmtClass() == OMPDistributeParallelForDirectiveClass ||
954  T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass ||
955  T->getStmtClass() == OMPDistributeSimdDirectiveClass ||
956  T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass ||
957  T->getStmtClass() == OMPTargetSimdDirectiveClass ||
958  T->getStmtClass() == OMPTeamsDistributeDirectiveClass ||
959  T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass ||
960  T->getStmtClass() ==
961  OMPTeamsDistributeParallelForSimdDirectiveClass ||
962  T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass ||
963  T->getStmtClass() ==
964  OMPTargetTeamsDistributeParallelForDirectiveClass ||
965  T->getStmtClass() ==
966  OMPTargetTeamsDistributeParallelForSimdDirectiveClass ||
967  T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass ||
968  T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass;
969  }
970 };
971 
972 /// \brief This represents '#pragma omp simd' directive.
973 ///
974 /// \code
975 /// #pragma omp simd private(a,b) linear(i,j:s) reduction(+:c,d)
976 /// \endcode
977 /// In this example directive '#pragma omp simd' has clauses 'private'
978 /// with the variables 'a' and 'b', 'linear' with variables 'i', 'j' and
979 /// linear step 's', 'reduction' with operator '+' and variables 'c' and 'd'.
980 ///
982  friend class ASTStmtReader;
983  /// \brief Build directive with the given start and end location.
984  ///
985  /// \param StartLoc Starting location of the directive kind.
986  /// \param EndLoc Ending location of the directive.
987  /// \param CollapsedNum Number of collapsed nested loops.
988  /// \param NumClauses Number of clauses.
989  ///
991  unsigned CollapsedNum, unsigned NumClauses)
992  : OMPLoopDirective(this, OMPSimdDirectiveClass, OMPD_simd, StartLoc,
993  EndLoc, CollapsedNum, NumClauses) {}
994 
995  /// \brief Build an empty directive.
996  ///
997  /// \param CollapsedNum Number of collapsed nested loops.
998  /// \param NumClauses Number of clauses.
999  ///
1000  explicit OMPSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
1001  : OMPLoopDirective(this, OMPSimdDirectiveClass, OMPD_simd,
1002  SourceLocation(), SourceLocation(), CollapsedNum,
1003  NumClauses) {}
1004 
1005 public:
1006  /// \brief Creates directive with a list of \a Clauses.
1007  ///
1008  /// \param C AST context.
1009  /// \param StartLoc Starting location of the directive kind.
1010  /// \param EndLoc Ending Location of the directive.
1011  /// \param CollapsedNum Number of collapsed loops.
1012  /// \param Clauses List of clauses.
1013  /// \param AssociatedStmt Statement, associated with the directive.
1014  /// \param Exprs Helper expressions for CodeGen.
1015  ///
1016  static OMPSimdDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1017  SourceLocation EndLoc, unsigned CollapsedNum,
1018  ArrayRef<OMPClause *> Clauses,
1019  Stmt *AssociatedStmt,
1020  const HelperExprs &Exprs);
1021 
1022  /// \brief Creates an empty directive with the place
1023  /// for \a NumClauses clauses.
1024  ///
1025  /// \param C AST context.
1026  /// \param CollapsedNum Number of collapsed nested loops.
1027  /// \param NumClauses Number of clauses.
1028  ///
1029  static OMPSimdDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1030  unsigned CollapsedNum, EmptyShell);
1031 
1032  static bool classof(const Stmt *T) {
1033  return T->getStmtClass() == OMPSimdDirectiveClass;
1034  }
1035 };
1036 
1037 /// \brief This represents '#pragma omp for' directive.
1038 ///
1039 /// \code
1040 /// #pragma omp for private(a,b) reduction(+:c,d)
1041 /// \endcode
1042 /// In this example directive '#pragma omp for' has clauses 'private' with the
1043 /// variables 'a' and 'b' and 'reduction' with operator '+' and variables 'c'
1044 /// and 'd'.
1045 ///
1047  friend class ASTStmtReader;
1048 
1049  /// \brief true if current directive has inner cancel directive.
1050  bool HasCancel;
1051 
1052  /// \brief Build directive with the given start and end location.
1053  ///
1054  /// \param StartLoc Starting location of the directive kind.
1055  /// \param EndLoc Ending location of the directive.
1056  /// \param CollapsedNum Number of collapsed nested loops.
1057  /// \param NumClauses Number of clauses.
1058  ///
1060  unsigned CollapsedNum, unsigned NumClauses)
1061  : OMPLoopDirective(this, OMPForDirectiveClass, OMPD_for, StartLoc, EndLoc,
1062  CollapsedNum, NumClauses),
1063  HasCancel(false) {}
1064 
1065  /// \brief Build an empty directive.
1066  ///
1067  /// \param CollapsedNum Number of collapsed nested loops.
1068  /// \param NumClauses Number of clauses.
1069  ///
1070  explicit OMPForDirective(unsigned CollapsedNum, unsigned NumClauses)
1071  : OMPLoopDirective(this, OMPForDirectiveClass, OMPD_for, SourceLocation(),
1072  SourceLocation(), CollapsedNum, NumClauses),
1073  HasCancel(false) {}
1074 
1075  /// \brief Set cancel state.
1076  void setHasCancel(bool Has) { HasCancel = Has; }
1077 
1078 public:
1079  /// \brief Creates directive with a list of \a Clauses.
1080  ///
1081  /// \param C AST context.
1082  /// \param StartLoc Starting location of the directive kind.
1083  /// \param EndLoc Ending Location of the directive.
1084  /// \param CollapsedNum Number of collapsed loops.
1085  /// \param Clauses List of clauses.
1086  /// \param AssociatedStmt Statement, associated with the directive.
1087  /// \param Exprs Helper expressions for CodeGen.
1088  /// \param HasCancel true if current directive has inner cancel directive.
1089  ///
1090  static OMPForDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1091  SourceLocation EndLoc, unsigned CollapsedNum,
1092  ArrayRef<OMPClause *> Clauses,
1093  Stmt *AssociatedStmt, const HelperExprs &Exprs,
1094  bool HasCancel);
1095 
1096  /// \brief Creates an empty directive with the place
1097  /// for \a NumClauses clauses.
1098  ///
1099  /// \param C AST context.
1100  /// \param CollapsedNum Number of collapsed nested loops.
1101  /// \param NumClauses Number of clauses.
1102  ///
1103  static OMPForDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1104  unsigned CollapsedNum, EmptyShell);
1105 
1106  /// \brief Return true if current directive has inner cancel directive.
1107  bool hasCancel() const { return HasCancel; }
1108 
1109  static bool classof(const Stmt *T) {
1110  return T->getStmtClass() == OMPForDirectiveClass;
1111  }
1112 };
1113 
1114 /// \brief This represents '#pragma omp for simd' directive.
1115 ///
1116 /// \code
1117 /// #pragma omp for simd private(a,b) linear(i,j:s) reduction(+:c,d)
1118 /// \endcode
1119 /// In this example directive '#pragma omp for simd' has clauses 'private'
1120 /// with the variables 'a' and 'b', 'linear' with variables 'i', 'j' and
1121 /// linear step 's', 'reduction' with operator '+' and variables 'c' and 'd'.
1122 ///
1124  friend class ASTStmtReader;
1125  /// \brief Build directive with the given start and end location.
1126  ///
1127  /// \param StartLoc Starting location of the directive kind.
1128  /// \param EndLoc Ending location of the directive.
1129  /// \param CollapsedNum Number of collapsed nested loops.
1130  /// \param NumClauses Number of clauses.
1131  ///
1133  unsigned CollapsedNum, unsigned NumClauses)
1134  : OMPLoopDirective(this, OMPForSimdDirectiveClass, OMPD_for_simd,
1135  StartLoc, EndLoc, CollapsedNum, NumClauses) {}
1136 
1137  /// \brief Build an empty directive.
1138  ///
1139  /// \param CollapsedNum Number of collapsed nested loops.
1140  /// \param NumClauses Number of clauses.
1141  ///
1142  explicit OMPForSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
1143  : OMPLoopDirective(this, OMPForSimdDirectiveClass, OMPD_for_simd,
1144  SourceLocation(), SourceLocation(), CollapsedNum,
1145  NumClauses) {}
1146 
1147 public:
1148  /// \brief Creates directive with a list of \a Clauses.
1149  ///
1150  /// \param C AST context.
1151  /// \param StartLoc Starting location of the directive kind.
1152  /// \param EndLoc Ending Location of the directive.
1153  /// \param CollapsedNum Number of collapsed loops.
1154  /// \param Clauses List of clauses.
1155  /// \param AssociatedStmt Statement, associated with the directive.
1156  /// \param Exprs Helper expressions for CodeGen.
1157  ///
1158  static OMPForSimdDirective *
1159  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1160  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1161  Stmt *AssociatedStmt, const HelperExprs &Exprs);
1162 
1163  /// \brief Creates an empty directive with the place
1164  /// for \a NumClauses clauses.
1165  ///
1166  /// \param C AST context.
1167  /// \param CollapsedNum Number of collapsed nested loops.
1168  /// \param NumClauses Number of clauses.
1169  ///
1171  unsigned NumClauses,
1172  unsigned CollapsedNum, EmptyShell);
1173 
1174  static bool classof(const Stmt *T) {
1175  return T->getStmtClass() == OMPForSimdDirectiveClass;
1176  }
1177 };
1178 
1179 /// \brief This represents '#pragma omp sections' directive.
1180 ///
1181 /// \code
1182 /// #pragma omp sections private(a,b) reduction(+:c,d)
1183 /// \endcode
1184 /// In this example directive '#pragma omp sections' has clauses 'private' with
1185 /// the variables 'a' and 'b' and 'reduction' with operator '+' and variables
1186 /// 'c' and 'd'.
1187 ///
1189  friend class ASTStmtReader;
1190 
1191  /// \brief true if current directive has inner cancel directive.
1192  bool HasCancel;
1193 
1194  /// \brief Build directive with the given start and end location.
1195  ///
1196  /// \param StartLoc Starting location of the directive kind.
1197  /// \param EndLoc Ending location of the directive.
1198  /// \param NumClauses Number of clauses.
1199  ///
1201  unsigned NumClauses)
1202  : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
1203  StartLoc, EndLoc, NumClauses, 1),
1204  HasCancel(false) {}
1205 
1206  /// \brief Build an empty directive.
1207  ///
1208  /// \param NumClauses Number of clauses.
1209  ///
1210  explicit OMPSectionsDirective(unsigned NumClauses)
1211  : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
1212  SourceLocation(), SourceLocation(), NumClauses,
1213  1),
1214  HasCancel(false) {}
1215 
1216  /// \brief Set cancel state.
1217  void setHasCancel(bool Has) { HasCancel = Has; }
1218 
1219 public:
1220  /// \brief Creates directive with a list of \a Clauses.
1221  ///
1222  /// \param C AST context.
1223  /// \param StartLoc Starting location of the directive kind.
1224  /// \param EndLoc Ending Location of the directive.
1225  /// \param Clauses List of clauses.
1226  /// \param AssociatedStmt Statement, associated with the directive.
1227  /// \param HasCancel true if current directive has inner directive.
1228  ///
1229  static OMPSectionsDirective *
1230  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1231  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel);
1232 
1233  /// \brief Creates an empty directive with the place for \a NumClauses
1234  /// clauses.
1235  ///
1236  /// \param C AST context.
1237  /// \param NumClauses Number of clauses.
1238  ///
1240  unsigned NumClauses, EmptyShell);
1241 
1242  /// \brief Return true if current directive has inner cancel directive.
1243  bool hasCancel() const { return HasCancel; }
1244 
1245  static bool classof(const Stmt *T) {
1246  return T->getStmtClass() == OMPSectionsDirectiveClass;
1247  }
1248 };
1249 
1250 /// \brief This represents '#pragma omp section' directive.
1251 ///
1252 /// \code
1253 /// #pragma omp section
1254 /// \endcode
1255 ///
1257  friend class ASTStmtReader;
1258 
1259  /// \brief true if current directive has inner cancel directive.
1260  bool HasCancel;
1261 
1262  /// \brief Build directive with the given start and end location.
1263  ///
1264  /// \param StartLoc Starting location of the directive kind.
1265  /// \param EndLoc Ending location of the directive.
1266  ///
1268  : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
1269  StartLoc, EndLoc, 0, 1),
1270  HasCancel(false) {}
1271 
1272  /// \brief Build an empty directive.
1273  ///
1274  explicit OMPSectionDirective()
1275  : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
1276  SourceLocation(), SourceLocation(), 0, 1),
1277  HasCancel(false) {}
1278 
1279 public:
1280  /// \brief Creates directive.
1281  ///
1282  /// \param C AST context.
1283  /// \param StartLoc Starting location of the directive kind.
1284  /// \param EndLoc Ending Location of the directive.
1285  /// \param AssociatedStmt Statement, associated with the directive.
1286  /// \param HasCancel true if current directive has inner directive.
1287  ///
1288  static OMPSectionDirective *Create(const ASTContext &C,
1289  SourceLocation StartLoc,
1290  SourceLocation EndLoc,
1291  Stmt *AssociatedStmt, bool HasCancel);
1292 
1293  /// \brief Creates an empty directive.
1294  ///
1295  /// \param C AST context.
1296  ///
1298 
1299  /// \brief Set cancel state.
1300  void setHasCancel(bool Has) { HasCancel = Has; }
1301 
1302  /// \brief Return true if current directive has inner cancel directive.
1303  bool hasCancel() const { return HasCancel; }
1304 
1305  static bool classof(const Stmt *T) {
1306  return T->getStmtClass() == OMPSectionDirectiveClass;
1307  }
1308 };
1309 
1310 /// \brief This represents '#pragma omp single' directive.
1311 ///
1312 /// \code
1313 /// #pragma omp single private(a,b) copyprivate(c,d)
1314 /// \endcode
1315 /// In this example directive '#pragma omp single' has clauses 'private' with
1316 /// the variables 'a' and 'b' and 'copyprivate' with variables 'c' and 'd'.
1317 ///
1319  friend class ASTStmtReader;
1320  /// \brief Build directive with the given start and end location.
1321  ///
1322  /// \param StartLoc Starting location of the directive kind.
1323  /// \param EndLoc Ending location of the directive.
1324  /// \param NumClauses Number of clauses.
1325  ///
1327  unsigned NumClauses)
1328  : OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
1329  StartLoc, EndLoc, NumClauses, 1) {}
1330 
1331  /// \brief Build an empty directive.
1332  ///
1333  /// \param NumClauses Number of clauses.
1334  ///
1335  explicit OMPSingleDirective(unsigned NumClauses)
1336  : OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
1337  SourceLocation(), SourceLocation(), NumClauses,
1338  1) {}
1339 
1340 public:
1341  /// \brief Creates directive with a list of \a Clauses.
1342  ///
1343  /// \param C AST context.
1344  /// \param StartLoc Starting location of the directive kind.
1345  /// \param EndLoc Ending Location of the directive.
1346  /// \param Clauses List of clauses.
1347  /// \param AssociatedStmt Statement, associated with the directive.
1348  ///
1349  static OMPSingleDirective *
1350  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1351  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
1352 
1353  /// \brief Creates an empty directive with the place for \a NumClauses
1354  /// clauses.
1355  ///
1356  /// \param C AST context.
1357  /// \param NumClauses Number of clauses.
1358  ///
1359  static OMPSingleDirective *CreateEmpty(const ASTContext &C,
1360  unsigned NumClauses, EmptyShell);
1361 
1362  static bool classof(const Stmt *T) {
1363  return T->getStmtClass() == OMPSingleDirectiveClass;
1364  }
1365 };
1366 
1367 /// \brief This represents '#pragma omp master' directive.
1368 ///
1369 /// \code
1370 /// #pragma omp master
1371 /// \endcode
1372 ///
1374  friend class ASTStmtReader;
1375  /// \brief Build directive with the given start and end location.
1376  ///
1377  /// \param StartLoc Starting location of the directive kind.
1378  /// \param EndLoc Ending location of the directive.
1379  ///
1381  : OMPExecutableDirective(this, OMPMasterDirectiveClass, OMPD_master,
1382  StartLoc, EndLoc, 0, 1) {}
1383 
1384  /// \brief Build an empty directive.
1385  ///
1386  explicit OMPMasterDirective()
1387  : OMPExecutableDirective(this, OMPMasterDirectiveClass, OMPD_master,
1388  SourceLocation(), SourceLocation(), 0, 1) {}
1389 
1390 public:
1391  /// \brief Creates directive.
1392  ///
1393  /// \param C AST context.
1394  /// \param StartLoc Starting location of the directive kind.
1395  /// \param EndLoc Ending Location of the directive.
1396  /// \param AssociatedStmt Statement, associated with the directive.
1397  ///
1398  static OMPMasterDirective *Create(const ASTContext &C,
1399  SourceLocation StartLoc,
1400  SourceLocation EndLoc,
1401  Stmt *AssociatedStmt);
1402 
1403  /// \brief Creates an empty directive.
1404  ///
1405  /// \param C AST context.
1406  ///
1408 
1409  static bool classof(const Stmt *T) {
1410  return T->getStmtClass() == OMPMasterDirectiveClass;
1411  }
1412 };
1413 
1414 /// \brief This represents '#pragma omp critical' directive.
1415 ///
1416 /// \code
1417 /// #pragma omp critical
1418 /// \endcode
1419 ///
1421  friend class ASTStmtReader;
1422  /// \brief Name of the directive.
1423  DeclarationNameInfo DirName;
1424  /// \brief Build directive with the given start and end location.
1425  ///
1426  /// \param Name Name of the directive.
1427  /// \param StartLoc Starting location of the directive kind.
1428  /// \param EndLoc Ending location of the directive.
1429  /// \param NumClauses Number of clauses.
1430  ///
1432  SourceLocation EndLoc, unsigned NumClauses)
1433  : OMPExecutableDirective(this, OMPCriticalDirectiveClass, OMPD_critical,
1434  StartLoc, EndLoc, NumClauses, 1),
1435  DirName(Name) {}
1436 
1437  /// \brief Build an empty directive.
1438  ///
1439  /// \param NumClauses Number of clauses.
1440  ///
1441  explicit OMPCriticalDirective(unsigned NumClauses)
1442  : OMPExecutableDirective(this, OMPCriticalDirectiveClass, OMPD_critical,
1443  SourceLocation(), SourceLocation(), NumClauses,
1444  1),
1445  DirName() {}
1446 
1447  /// \brief Set name of the directive.
1448  ///
1449  /// \param Name Name of the directive.
1450  ///
1451  void setDirectiveName(const DeclarationNameInfo &Name) { DirName = Name; }
1452 
1453 public:
1454  /// \brief Creates directive.
1455  ///
1456  /// \param C AST context.
1457  /// \param Name Name of the directive.
1458  /// \param StartLoc Starting location of the directive kind.
1459  /// \param EndLoc Ending Location of the directive.
1460  /// \param Clauses List of clauses.
1461  /// \param AssociatedStmt Statement, associated with the directive.
1462  ///
1463  static OMPCriticalDirective *
1464  Create(const ASTContext &C, const DeclarationNameInfo &Name,
1465  SourceLocation StartLoc, SourceLocation EndLoc,
1466  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
1467 
1468  /// \brief Creates an empty directive.
1469  ///
1470  /// \param C AST context.
1471  /// \param NumClauses Number of clauses.
1472  ///
1474  unsigned NumClauses, EmptyShell);
1475 
1476  /// \brief Return name of the directive.
1477  ///
1478  DeclarationNameInfo getDirectiveName() const { return DirName; }
1479 
1480  static bool classof(const Stmt *T) {
1481  return T->getStmtClass() == OMPCriticalDirectiveClass;
1482  }
1483 };
1484 
1485 /// \brief This represents '#pragma omp parallel for' directive.
1486 ///
1487 /// \code
1488 /// #pragma omp parallel for private(a,b) reduction(+:c,d)
1489 /// \endcode
1490 /// In this example directive '#pragma omp parallel for' has clauses 'private'
1491 /// with the variables 'a' and 'b' and 'reduction' with operator '+' and
1492 /// variables 'c' and 'd'.
1493 ///
1495  friend class ASTStmtReader;
1496 
1497  /// \brief true if current region has inner cancel directive.
1498  bool HasCancel;
1499 
1500  /// \brief Build directive with the given start and end location.
1501  ///
1502  /// \param StartLoc Starting location of the directive kind.
1503  /// \param EndLoc Ending location of the directive.
1504  /// \param CollapsedNum Number of collapsed nested loops.
1505  /// \param NumClauses Number of clauses.
1506  ///
1508  unsigned CollapsedNum, unsigned NumClauses)
1509  : OMPLoopDirective(this, OMPParallelForDirectiveClass, OMPD_parallel_for,
1510  StartLoc, EndLoc, CollapsedNum, NumClauses),
1511  HasCancel(false) {}
1512 
1513  /// \brief Build an empty directive.
1514  ///
1515  /// \param CollapsedNum Number of collapsed nested loops.
1516  /// \param NumClauses Number of clauses.
1517  ///
1518  explicit OMPParallelForDirective(unsigned CollapsedNum, unsigned NumClauses)
1519  : OMPLoopDirective(this, OMPParallelForDirectiveClass, OMPD_parallel_for,
1520  SourceLocation(), SourceLocation(), CollapsedNum,
1521  NumClauses),
1522  HasCancel(false) {}
1523 
1524  /// \brief Set cancel state.
1525  void setHasCancel(bool Has) { HasCancel = Has; }
1526 
1527 public:
1528  /// \brief Creates directive with a list of \a Clauses.
1529  ///
1530  /// \param C AST context.
1531  /// \param StartLoc Starting location of the directive kind.
1532  /// \param EndLoc Ending Location of the directive.
1533  /// \param CollapsedNum Number of collapsed loops.
1534  /// \param Clauses List of clauses.
1535  /// \param AssociatedStmt Statement, associated with the directive.
1536  /// \param Exprs Helper expressions for CodeGen.
1537  /// \param HasCancel true if current directive has inner cancel directive.
1538  ///
1539  static OMPParallelForDirective *
1540  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1541  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1542  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
1543 
1544  /// \brief Creates an empty directive with the place
1545  /// for \a NumClauses clauses.
1546  ///
1547  /// \param C AST context.
1548  /// \param CollapsedNum Number of collapsed nested loops.
1549  /// \param NumClauses Number of clauses.
1550  ///
1552  unsigned NumClauses,
1553  unsigned CollapsedNum,
1554  EmptyShell);
1555 
1556  /// \brief Return true if current directive has inner cancel directive.
1557  bool hasCancel() const { return HasCancel; }
1558 
1559  static bool classof(const Stmt *T) {
1560  return T->getStmtClass() == OMPParallelForDirectiveClass;
1561  }
1562 };
1563 
1564 /// \brief This represents '#pragma omp parallel for simd' directive.
1565 ///
1566 /// \code
1567 /// #pragma omp parallel for simd private(a,b) linear(i,j:s) reduction(+:c,d)
1568 /// \endcode
1569 /// In this example directive '#pragma omp parallel for simd' has clauses
1570 /// 'private' with the variables 'a' and 'b', 'linear' with variables 'i', 'j'
1571 /// and linear step 's', 'reduction' with operator '+' and variables 'c' and
1572 /// 'd'.
1573 ///
1575  friend class ASTStmtReader;
1576  /// \brief Build directive with the given start and end location.
1577  ///
1578  /// \param StartLoc Starting location of the directive kind.
1579  /// \param EndLoc Ending location of the directive.
1580  /// \param CollapsedNum Number of collapsed nested loops.
1581  /// \param NumClauses Number of clauses.
1582  ///
1584  unsigned CollapsedNum, unsigned NumClauses)
1585  : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass,
1586  OMPD_parallel_for_simd, StartLoc, EndLoc, CollapsedNum,
1587  NumClauses) {}
1588 
1589  /// \brief Build an empty directive.
1590  ///
1591  /// \param CollapsedNum Number of collapsed nested loops.
1592  /// \param NumClauses Number of clauses.
1593  ///
1594  explicit OMPParallelForSimdDirective(unsigned CollapsedNum,
1595  unsigned NumClauses)
1596  : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass,
1597  OMPD_parallel_for_simd, SourceLocation(),
1598  SourceLocation(), CollapsedNum, NumClauses) {}
1599 
1600 public:
1601  /// \brief Creates directive with a list of \a Clauses.
1602  ///
1603  /// \param C AST context.
1604  /// \param StartLoc Starting location of the directive kind.
1605  /// \param EndLoc Ending Location of the directive.
1606  /// \param CollapsedNum Number of collapsed loops.
1607  /// \param Clauses List of clauses.
1608  /// \param AssociatedStmt Statement, associated with the directive.
1609  /// \param Exprs Helper expressions for CodeGen.
1610  ///
1612  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1613  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1614  Stmt *AssociatedStmt, const HelperExprs &Exprs);
1615 
1616  /// \brief Creates an empty directive with the place
1617  /// for \a NumClauses clauses.
1618  ///
1619  /// \param C AST context.
1620  /// \param CollapsedNum Number of collapsed nested loops.
1621  /// \param NumClauses Number of clauses.
1622  ///
1624  unsigned NumClauses,
1625  unsigned CollapsedNum,
1626  EmptyShell);
1627 
1628  static bool classof(const Stmt *T) {
1629  return T->getStmtClass() == OMPParallelForSimdDirectiveClass;
1630  }
1631 };
1632 
1633 /// \brief This represents '#pragma omp parallel sections' directive.
1634 ///
1635 /// \code
1636 /// #pragma omp parallel sections private(a,b) reduction(+:c,d)
1637 /// \endcode
1638 /// In this example directive '#pragma omp parallel sections' has clauses
1639 /// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
1640 /// and variables 'c' and 'd'.
1641 ///
1643  friend class ASTStmtReader;
1644 
1645  /// \brief true if current directive has inner cancel directive.
1646  bool HasCancel;
1647 
1648  /// \brief Build directive with the given start and end location.
1649  ///
1650  /// \param StartLoc Starting location of the directive kind.
1651  /// \param EndLoc Ending location of the directive.
1652  /// \param NumClauses Number of clauses.
1653  ///
1655  unsigned NumClauses)
1656  : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
1657  OMPD_parallel_sections, StartLoc, EndLoc,
1658  NumClauses, 1),
1659  HasCancel(false) {}
1660 
1661  /// \brief Build an empty directive.
1662  ///
1663  /// \param NumClauses Number of clauses.
1664  ///
1665  explicit OMPParallelSectionsDirective(unsigned NumClauses)
1666  : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
1667  OMPD_parallel_sections, SourceLocation(),
1668  SourceLocation(), NumClauses, 1),
1669  HasCancel(false) {}
1670 
1671  /// \brief Set cancel state.
1672  void setHasCancel(bool Has) { HasCancel = Has; }
1673 
1674 public:
1675  /// \brief Creates directive with a list of \a Clauses.
1676  ///
1677  /// \param C AST context.
1678  /// \param StartLoc Starting location of the directive kind.
1679  /// \param EndLoc Ending Location of the directive.
1680  /// \param Clauses List of clauses.
1681  /// \param AssociatedStmt Statement, associated with the directive.
1682  /// \param HasCancel true if current directive has inner cancel directive.
1683  ///
1685  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1686  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel);
1687 
1688  /// \brief Creates an empty directive with the place for \a NumClauses
1689  /// clauses.
1690  ///
1691  /// \param C AST context.
1692  /// \param NumClauses Number of clauses.
1693  ///
1695  CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
1696 
1697  /// \brief Return true if current directive has inner cancel directive.
1698  bool hasCancel() const { return HasCancel; }
1699 
1700  static bool classof(const Stmt *T) {
1701  return T->getStmtClass() == OMPParallelSectionsDirectiveClass;
1702  }
1703 };
1704 
1705 /// \brief This represents '#pragma omp task' directive.
1706 ///
1707 /// \code
1708 /// #pragma omp task private(a,b) final(d)
1709 /// \endcode
1710 /// In this example directive '#pragma omp task' has clauses 'private' with the
1711 /// variables 'a' and 'b' and 'final' with condition 'd'.
1712 ///
1714  friend class ASTStmtReader;
1715  /// \brief true if this directive has inner cancel directive.
1716  bool HasCancel;
1717 
1718  /// \brief Build directive with the given start and end location.
1719  ///
1720  /// \param StartLoc Starting location of the directive kind.
1721  /// \param EndLoc Ending location of the directive.
1722  /// \param NumClauses Number of clauses.
1723  ///
1725  unsigned NumClauses)
1726  : OMPExecutableDirective(this, OMPTaskDirectiveClass, OMPD_task, StartLoc,
1727  EndLoc, NumClauses, 1),
1728  HasCancel(false) {}
1729 
1730  /// \brief Build an empty directive.
1731  ///
1732  /// \param NumClauses Number of clauses.
1733  ///
1734  explicit OMPTaskDirective(unsigned NumClauses)
1735  : OMPExecutableDirective(this, OMPTaskDirectiveClass, OMPD_task,
1736  SourceLocation(), SourceLocation(), NumClauses,
1737  1),
1738  HasCancel(false) {}
1739 
1740  /// \brief Set cancel state.
1741  void setHasCancel(bool Has) { HasCancel = Has; }
1742 
1743 public:
1744  /// \brief Creates directive with a list of \a Clauses.
1745  ///
1746  /// \param C AST context.
1747  /// \param StartLoc Starting location of the directive kind.
1748  /// \param EndLoc Ending Location of the directive.
1749  /// \param Clauses List of clauses.
1750  /// \param AssociatedStmt Statement, associated with the directive.
1751  /// \param HasCancel true, if current directive has inner cancel directive.
1752  ///
1753  static OMPTaskDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1754  SourceLocation EndLoc,
1755  ArrayRef<OMPClause *> Clauses,
1756  Stmt *AssociatedStmt, bool HasCancel);
1757 
1758  /// \brief Creates an empty directive with the place for \a NumClauses
1759  /// clauses.
1760  ///
1761  /// \param C AST context.
1762  /// \param NumClauses Number of clauses.
1763  ///
1764  static OMPTaskDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1765  EmptyShell);
1766 
1767  /// \brief Return true if current directive has inner cancel directive.
1768  bool hasCancel() const { return HasCancel; }
1769 
1770  static bool classof(const Stmt *T) {
1771  return T->getStmtClass() == OMPTaskDirectiveClass;
1772  }
1773 };
1774 
1775 /// \brief This represents '#pragma omp taskyield' directive.
1776 ///
1777 /// \code
1778 /// #pragma omp taskyield
1779 /// \endcode
1780 ///
1782  friend class ASTStmtReader;
1783  /// \brief Build directive with the given start and end location.
1784  ///
1785  /// \param StartLoc Starting location of the directive kind.
1786  /// \param EndLoc Ending location of the directive.
1787  ///
1789  : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, OMPD_taskyield,
1790  StartLoc, EndLoc, 0, 0) {}
1791 
1792  /// \brief Build an empty directive.
1793  ///
1794  explicit OMPTaskyieldDirective()
1795  : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, OMPD_taskyield,
1796  SourceLocation(), SourceLocation(), 0, 0) {}
1797 
1798 public:
1799  /// \brief Creates directive.
1800  ///
1801  /// \param C AST context.
1802  /// \param StartLoc Starting location of the directive kind.
1803  /// \param EndLoc Ending Location of the directive.
1804  ///
1805  static OMPTaskyieldDirective *
1806  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
1807 
1808  /// \brief Creates an empty directive.
1809  ///
1810  /// \param C AST context.
1811  ///
1813 
1814  static bool classof(const Stmt *T) {
1815  return T->getStmtClass() == OMPTaskyieldDirectiveClass;
1816  }
1817 };
1818 
1819 /// \brief This represents '#pragma omp barrier' directive.
1820 ///
1821 /// \code
1822 /// #pragma omp barrier
1823 /// \endcode
1824 ///
1826  friend class ASTStmtReader;
1827  /// \brief Build directive with the given start and end location.
1828  ///
1829  /// \param StartLoc Starting location of the directive kind.
1830  /// \param EndLoc Ending location of the directive.
1831  ///
1833  : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
1834  StartLoc, EndLoc, 0, 0) {}
1835 
1836  /// \brief Build an empty directive.
1837  ///
1838  explicit OMPBarrierDirective()
1839  : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
1840  SourceLocation(), SourceLocation(), 0, 0) {}
1841 
1842 public:
1843  /// \brief Creates directive.
1844  ///
1845  /// \param C AST context.
1846  /// \param StartLoc Starting location of the directive kind.
1847  /// \param EndLoc Ending Location of the directive.
1848  ///
1849  static OMPBarrierDirective *
1850  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
1851 
1852  /// \brief Creates an empty directive.
1853  ///
1854  /// \param C AST context.
1855  ///
1857 
1858  static bool classof(const Stmt *T) {
1859  return T->getStmtClass() == OMPBarrierDirectiveClass;
1860  }
1861 };
1862 
1863 /// \brief This represents '#pragma omp taskwait' directive.
1864 ///
1865 /// \code
1866 /// #pragma omp taskwait
1867 /// \endcode
1868 ///
1870  friend class ASTStmtReader;
1871  /// \brief Build directive with the given start and end location.
1872  ///
1873  /// \param StartLoc Starting location of the directive kind.
1874  /// \param EndLoc Ending location of the directive.
1875  ///
1877  : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, OMPD_taskwait,
1878  StartLoc, EndLoc, 0, 0) {}
1879 
1880  /// \brief Build an empty directive.
1881  ///
1882  explicit OMPTaskwaitDirective()
1883  : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, OMPD_taskwait,
1884  SourceLocation(), SourceLocation(), 0, 0) {}
1885 
1886 public:
1887  /// \brief Creates directive.
1888  ///
1889  /// \param C AST context.
1890  /// \param StartLoc Starting location of the directive kind.
1891  /// \param EndLoc Ending Location of the directive.
1892  ///
1893  static OMPTaskwaitDirective *
1894  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
1895 
1896  /// \brief Creates an empty directive.
1897  ///
1898  /// \param C AST context.
1899  ///
1901 
1902  static bool classof(const Stmt *T) {
1903  return T->getStmtClass() == OMPTaskwaitDirectiveClass;
1904  }
1905 };
1906 
1907 /// This represents '#pragma omp taskgroup' directive.
1908 ///
1909 /// \code
1910 /// #pragma omp taskgroup
1911 /// \endcode
1912 ///
1914  friend class ASTStmtReader;
1915  /// Build directive with the given start and end location.
1916  ///
1917  /// \param StartLoc Starting location of the directive kind.
1918  /// \param EndLoc Ending location of the directive.
1919  /// \param NumClauses Number of clauses.
1920  ///
1922  unsigned NumClauses)
1923  : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
1924  StartLoc, EndLoc, NumClauses, 2) {}
1925 
1926  /// Build an empty directive.
1927  /// \param NumClauses Number of clauses.
1928  ///
1929  explicit OMPTaskgroupDirective(unsigned NumClauses)
1930  : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
1931  SourceLocation(), SourceLocation(), NumClauses,
1932  2) {}
1933 
1934  /// Sets the task_reduction return variable.
1935  void setReductionRef(Expr *RR) {
1936  *std::next(child_begin(), 1) = RR;
1937  }
1938 
1939 public:
1940  /// Creates directive.
1941  ///
1942  /// \param C AST context.
1943  /// \param StartLoc Starting location of the directive kind.
1944  /// \param EndLoc Ending Location of the directive.
1945  /// \param Clauses List of clauses.
1946  /// \param AssociatedStmt Statement, associated with the directive.
1947  /// \param ReductionRef Reference to the task_reduction return variable.
1948  ///
1949  static OMPTaskgroupDirective *
1950  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1951  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1952  Expr *ReductionRef);
1953 
1954  /// Creates an empty directive.
1955  ///
1956  /// \param C AST context.
1957  /// \param NumClauses Number of clauses.
1958  ///
1960  unsigned NumClauses, EmptyShell);
1961 
1962 
1963  /// Returns reference to the task_reduction return variable.
1964  const Expr *getReductionRef() const {
1965  return static_cast<const Expr *>(*std::next(child_begin(), 1));
1966  }
1968  return static_cast<Expr *>(*std::next(child_begin(), 1));
1969  }
1970 
1971  static bool classof(const Stmt *T) {
1972  return T->getStmtClass() == OMPTaskgroupDirectiveClass;
1973  }
1974 };
1975 
1976 /// \brief This represents '#pragma omp flush' directive.
1977 ///
1978 /// \code
1979 /// #pragma omp flush(a,b)
1980 /// \endcode
1981 /// In this example directive '#pragma omp flush' has 2 arguments- variables 'a'
1982 /// and 'b'.
1983 /// 'omp flush' directive does not have clauses but have an optional list of
1984 /// variables to flush. This list of variables is stored within some fake clause
1985 /// FlushClause.
1987  friend class ASTStmtReader;
1988  /// \brief Build directive with the given start and end location.
1989  ///
1990  /// \param StartLoc Starting location of the directive kind.
1991  /// \param EndLoc Ending location of the directive.
1992  /// \param NumClauses Number of clauses.
1993  ///
1995  unsigned NumClauses)
1996  : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
1997  StartLoc, EndLoc, NumClauses, 0) {}
1998 
1999  /// \brief Build an empty directive.
2000  ///
2001  /// \param NumClauses Number of clauses.
2002  ///
2003  explicit OMPFlushDirective(unsigned NumClauses)
2004  : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
2005  SourceLocation(), SourceLocation(), NumClauses,
2006  0) {}
2007 
2008 public:
2009  /// \brief Creates directive with a list of \a Clauses.
2010  ///
2011  /// \param C AST context.
2012  /// \param StartLoc Starting location of the directive kind.
2013  /// \param EndLoc Ending Location of the directive.
2014  /// \param Clauses List of clauses (only single OMPFlushClause clause is
2015  /// allowed).
2016  ///
2017  static OMPFlushDirective *Create(const ASTContext &C, SourceLocation StartLoc,
2018  SourceLocation EndLoc,
2019  ArrayRef<OMPClause *> Clauses);
2020 
2021  /// \brief Creates an empty directive with the place for \a NumClauses
2022  /// clauses.
2023  ///
2024  /// \param C AST context.
2025  /// \param NumClauses Number of clauses.
2026  ///
2027  static OMPFlushDirective *CreateEmpty(const ASTContext &C,
2028  unsigned NumClauses, EmptyShell);
2029 
2030  static bool classof(const Stmt *T) {
2031  return T->getStmtClass() == OMPFlushDirectiveClass;
2032  }
2033 };
2034 
2035 /// \brief This represents '#pragma omp ordered' directive.
2036 ///
2037 /// \code
2038 /// #pragma omp ordered
2039 /// \endcode
2040 ///
2042  friend class ASTStmtReader;
2043  /// \brief Build directive with the given start and end location.
2044  ///
2045  /// \param StartLoc Starting location of the directive kind.
2046  /// \param EndLoc Ending location of the directive.
2047  /// \param NumClauses Number of clauses.
2048  ///
2050  unsigned NumClauses)
2051  : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
2052  StartLoc, EndLoc, NumClauses, 1) {}
2053 
2054  /// \brief Build an empty directive.
2055  ///
2056  /// \param NumClauses Number of clauses.
2057  ///
2058  explicit OMPOrderedDirective(unsigned NumClauses)
2059  : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
2060  SourceLocation(), SourceLocation(), NumClauses,
2061  1) {}
2062 
2063 public:
2064  /// \brief Creates directive.
2065  ///
2066  /// \param C AST context.
2067  /// \param StartLoc Starting location of the directive kind.
2068  /// \param EndLoc Ending Location of the directive.
2069  /// \param Clauses List of clauses.
2070  /// \param AssociatedStmt Statement, associated with the directive.
2071  ///
2072  static OMPOrderedDirective *
2073  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2074  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2075 
2076  /// \brief Creates an empty directive.
2077  ///
2078  /// \param C AST context.
2079  /// \param NumClauses Number of clauses.
2080  ///
2082  unsigned NumClauses, EmptyShell);
2083 
2084  static bool classof(const Stmt *T) {
2085  return T->getStmtClass() == OMPOrderedDirectiveClass;
2086  }
2087 };
2088 
2089 /// \brief This represents '#pragma omp atomic' directive.
2090 ///
2091 /// \code
2092 /// #pragma omp atomic capture
2093 /// \endcode
2094 /// In this example directive '#pragma omp atomic' has clause 'capture'.
2095 ///
2097  friend class ASTStmtReader;
2098  /// \brief Used for 'atomic update' or 'atomic capture' constructs. They may
2099  /// have atomic expressions of forms
2100  /// \code
2101  /// x = x binop expr;
2102  /// x = expr binop x;
2103  /// \endcode
2104  /// This field is true for the first form of the expression and false for the
2105  /// second. Required for correct codegen of non-associative operations (like
2106  /// << or >>).
2107  bool IsXLHSInRHSPart;
2108  /// \brief Used for 'atomic update' or 'atomic capture' constructs. They may
2109  /// have atomic expressions of forms
2110  /// \code
2111  /// v = x; <update x>;
2112  /// <update x>; v = x;
2113  /// \endcode
2114  /// This field is true for the first(postfix) form of the expression and false
2115  /// otherwise.
2116  bool IsPostfixUpdate;
2117 
2118  /// \brief Build directive with the given start and end location.
2119  ///
2120  /// \param StartLoc Starting location of the directive kind.
2121  /// \param EndLoc Ending location of the directive.
2122  /// \param NumClauses Number of clauses.
2123  ///
2125  unsigned NumClauses)
2126  : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
2127  StartLoc, EndLoc, NumClauses, 5),
2128  IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
2129 
2130  /// \brief Build an empty directive.
2131  ///
2132  /// \param NumClauses Number of clauses.
2133  ///
2134  explicit OMPAtomicDirective(unsigned NumClauses)
2135  : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
2136  SourceLocation(), SourceLocation(), NumClauses,
2137  5),
2138  IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
2139 
2140  /// \brief Set 'x' part of the associated expression/statement.
2141  void setX(Expr *X) { *std::next(child_begin()) = X; }
2142  /// \brief Set helper expression of the form
2143  /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2144  /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2145  void setUpdateExpr(Expr *UE) { *std::next(child_begin(), 2) = UE; }
2146  /// \brief Set 'v' part of the associated expression/statement.
2147  void setV(Expr *V) { *std::next(child_begin(), 3) = V; }
2148  /// \brief Set 'expr' part of the associated expression/statement.
2149  void setExpr(Expr *E) { *std::next(child_begin(), 4) = E; }
2150 
2151 public:
2152  /// \brief Creates directive with a list of \a Clauses and 'x', 'v' and 'expr'
2153  /// parts of the atomic construct (see Section 2.12.6, atomic Construct, for
2154  /// detailed description of 'x', 'v' and 'expr').
2155  ///
2156  /// \param C AST context.
2157  /// \param StartLoc Starting location of the directive kind.
2158  /// \param EndLoc Ending Location of the directive.
2159  /// \param Clauses List of clauses.
2160  /// \param AssociatedStmt Statement, associated with the directive.
2161  /// \param X 'x' part of the associated expression/statement.
2162  /// \param V 'v' part of the associated expression/statement.
2163  /// \param E 'expr' part of the associated expression/statement.
2164  /// \param UE Helper expression of the form
2165  /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2166  /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2167  /// \param IsXLHSInRHSPart true if \a UE has the first form and false if the
2168  /// second.
2169  /// \param IsPostfixUpdate true if original value of 'x' must be stored in
2170  /// 'v', not an updated one.
2171  static OMPAtomicDirective *
2172  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2173  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
2174  Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate);
2175 
2176  /// \brief Creates an empty directive with the place for \a NumClauses
2177  /// clauses.
2178  ///
2179  /// \param C AST context.
2180  /// \param NumClauses Number of clauses.
2181  ///
2182  static OMPAtomicDirective *CreateEmpty(const ASTContext &C,
2183  unsigned NumClauses, EmptyShell);
2184 
2185  /// \brief Get 'x' part of the associated expression/statement.
2186  Expr *getX() { return cast_or_null<Expr>(*std::next(child_begin())); }
2187  const Expr *getX() const {
2188  return cast_or_null<Expr>(*std::next(child_begin()));
2189  }
2190  /// \brief Get helper expression of the form
2191  /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2192  /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2194  return cast_or_null<Expr>(*std::next(child_begin(), 2));
2195  }
2196  const Expr *getUpdateExpr() const {
2197  return cast_or_null<Expr>(*std::next(child_begin(), 2));
2198  }
2199  /// \brief Return true if helper update expression has form
2200  /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form
2201  /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2202  bool isXLHSInRHSPart() const { return IsXLHSInRHSPart; }
2203  /// \brief Return true if 'v' expression must be updated to original value of
2204  /// 'x', false if 'v' must be updated to the new value of 'x'.
2205  bool isPostfixUpdate() const { return IsPostfixUpdate; }
2206  /// \brief Get 'v' part of the associated expression/statement.
2207  Expr *getV() { return cast_or_null<Expr>(*std::next(child_begin(), 3)); }
2208  const Expr *getV() const {
2209  return cast_or_null<Expr>(*std::next(child_begin(), 3));
2210  }
2211  /// \brief Get 'expr' part of the associated expression/statement.
2212  Expr *getExpr() { return cast_or_null<Expr>(*std::next(child_begin(), 4)); }
2213  const Expr *getExpr() const {
2214  return cast_or_null<Expr>(*std::next(child_begin(), 4));
2215  }
2216 
2217  static bool classof(const Stmt *T) {
2218  return T->getStmtClass() == OMPAtomicDirectiveClass;
2219  }
2220 };
2221 
2222 /// \brief This represents '#pragma omp target' directive.
2223 ///
2224 /// \code
2225 /// #pragma omp target if(a)
2226 /// \endcode
2227 /// In this example directive '#pragma omp target' has clause 'if' with
2228 /// condition 'a'.
2229 ///
2231  friend class ASTStmtReader;
2232  /// \brief Build directive with the given start and end location.
2233  ///
2234  /// \param StartLoc Starting location of the directive kind.
2235  /// \param EndLoc Ending location of the directive.
2236  /// \param NumClauses Number of clauses.
2237  ///
2239  unsigned NumClauses)
2240  : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
2241  StartLoc, EndLoc, NumClauses, 1) {}
2242 
2243  /// \brief Build an empty directive.
2244  ///
2245  /// \param NumClauses Number of clauses.
2246  ///
2247  explicit OMPTargetDirective(unsigned NumClauses)
2248  : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
2249  SourceLocation(), SourceLocation(), NumClauses,
2250  1) {}
2251 
2252 public:
2253  /// \brief Creates directive with a list of \a Clauses.
2254  ///
2255  /// \param C AST context.
2256  /// \param StartLoc Starting location of the directive kind.
2257  /// \param EndLoc Ending Location of the directive.
2258  /// \param Clauses List of clauses.
2259  /// \param AssociatedStmt Statement, associated with the directive.
2260  ///
2261  static OMPTargetDirective *
2262  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2263  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2264 
2265  /// \brief Creates an empty directive with the place for \a NumClauses
2266  /// clauses.
2267  ///
2268  /// \param C AST context.
2269  /// \param NumClauses Number of clauses.
2270  ///
2271  static OMPTargetDirective *CreateEmpty(const ASTContext &C,
2272  unsigned NumClauses, EmptyShell);
2273 
2274  static bool classof(const Stmt *T) {
2275  return T->getStmtClass() == OMPTargetDirectiveClass;
2276  }
2277 };
2278 
2279 /// \brief This represents '#pragma omp target data' directive.
2280 ///
2281 /// \code
2282 /// #pragma omp target data device(0) if(a) map(b[:])
2283 /// \endcode
2284 /// In this example directive '#pragma omp target data' has clauses 'device'
2285 /// with the value '0', 'if' with condition 'a' and 'map' with array
2286 /// section 'b[:]'.
2287 ///
2289  friend class ASTStmtReader;
2290  /// \brief Build directive with the given start and end location.
2291  ///
2292  /// \param StartLoc Starting location of the directive kind.
2293  /// \param EndLoc Ending Location of the directive.
2294  /// \param NumClauses The number of clauses.
2295  ///
2297  unsigned NumClauses)
2298  : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
2299  OMPD_target_data, StartLoc, EndLoc, NumClauses,
2300  1) {}
2301 
2302  /// \brief Build an empty directive.
2303  ///
2304  /// \param NumClauses Number of clauses.
2305  ///
2306  explicit OMPTargetDataDirective(unsigned NumClauses)
2307  : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
2308  OMPD_target_data, SourceLocation(),
2309  SourceLocation(), NumClauses, 1) {}
2310 
2311 public:
2312  /// \brief Creates directive with a list of \a Clauses.
2313  ///
2314  /// \param C AST context.
2315  /// \param StartLoc Starting location of the directive kind.
2316  /// \param EndLoc Ending Location of the directive.
2317  /// \param Clauses List of clauses.
2318  /// \param AssociatedStmt Statement, associated with the directive.
2319  ///
2320  static OMPTargetDataDirective *
2321  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2322  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2323 
2324  /// \brief Creates an empty directive with the place for \a N clauses.
2325  ///
2326  /// \param C AST context.
2327  /// \param N The number of clauses.
2328  ///
2329  static OMPTargetDataDirective *CreateEmpty(const ASTContext &C, unsigned N,
2330  EmptyShell);
2331 
2332  static bool classof(const Stmt *T) {
2333  return T->getStmtClass() == OMPTargetDataDirectiveClass;
2334  }
2335 };
2336 
2337 /// \brief This represents '#pragma omp target enter data' directive.
2338 ///
2339 /// \code
2340 /// #pragma omp target enter data device(0) if(a) map(b[:])
2341 /// \endcode
2342 /// In this example directive '#pragma omp target enter data' has clauses
2343 /// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
2344 /// section 'b[:]'.
2345 ///
2347  friend class ASTStmtReader;
2348  /// \brief Build directive with the given start and end location.
2349  ///
2350  /// \param StartLoc Starting location of the directive kind.
2351  /// \param EndLoc Ending Location of the directive.
2352  /// \param NumClauses The number of clauses.
2353  ///
2355  unsigned NumClauses)
2356  : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
2357  OMPD_target_enter_data, StartLoc, EndLoc,
2358  NumClauses, /*NumChildren=*/1) {}
2359 
2360  /// \brief Build an empty directive.
2361  ///
2362  /// \param NumClauses Number of clauses.
2363  ///
2364  explicit OMPTargetEnterDataDirective(unsigned NumClauses)
2365  : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
2366  OMPD_target_enter_data, SourceLocation(),
2367  SourceLocation(), NumClauses,
2368  /*NumChildren=*/1) {}
2369 
2370 public:
2371  /// \brief Creates directive with a list of \a Clauses.
2372  ///
2373  /// \param C AST context.
2374  /// \param StartLoc Starting location of the directive kind.
2375  /// \param EndLoc Ending Location of the directive.
2376  /// \param Clauses List of clauses.
2377  /// \param AssociatedStmt Statement, associated with the directive.
2378  ///
2380  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2381  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2382 
2383  /// \brief Creates an empty directive with the place for \a N clauses.
2384  ///
2385  /// \param C AST context.
2386  /// \param N The number of clauses.
2387  ///
2389  unsigned N, EmptyShell);
2390 
2391  static bool classof(const Stmt *T) {
2392  return T->getStmtClass() == OMPTargetEnterDataDirectiveClass;
2393  }
2394 };
2395 
2396 /// \brief This represents '#pragma omp target exit data' directive.
2397 ///
2398 /// \code
2399 /// #pragma omp target exit data device(0) if(a) map(b[:])
2400 /// \endcode
2401 /// In this example directive '#pragma omp target exit data' has clauses
2402 /// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
2403 /// section 'b[:]'.
2404 ///
2406  friend class ASTStmtReader;
2407  /// \brief Build directive with the given start and end location.
2408  ///
2409  /// \param StartLoc Starting location of the directive kind.
2410  /// \param EndLoc Ending Location of the directive.
2411  /// \param NumClauses The number of clauses.
2412  ///
2414  unsigned NumClauses)
2415  : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
2416  OMPD_target_exit_data, StartLoc, EndLoc,
2417  NumClauses, /*NumChildren=*/1) {}
2418 
2419  /// \brief Build an empty directive.
2420  ///
2421  /// \param NumClauses Number of clauses.
2422  ///
2423  explicit OMPTargetExitDataDirective(unsigned NumClauses)
2424  : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
2425  OMPD_target_exit_data, SourceLocation(),
2426  SourceLocation(), NumClauses,
2427  /*NumChildren=*/1) {}
2428 
2429 public:
2430  /// \brief Creates directive with a list of \a Clauses.
2431  ///
2432  /// \param C AST context.
2433  /// \param StartLoc Starting location of the directive kind.
2434  /// \param EndLoc Ending Location of the directive.
2435  /// \param Clauses List of clauses.
2436  /// \param AssociatedStmt Statement, associated with the directive.
2437  ///
2439  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2440  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2441 
2442  /// \brief Creates an empty directive with the place for \a N clauses.
2443  ///
2444  /// \param C AST context.
2445  /// \param N The number of clauses.
2446  ///
2448  unsigned N, EmptyShell);
2449 
2450  static bool classof(const Stmt *T) {
2451  return T->getStmtClass() == OMPTargetExitDataDirectiveClass;
2452  }
2453 };
2454 
2455 /// \brief This represents '#pragma omp target parallel' directive.
2456 ///
2457 /// \code
2458 /// #pragma omp target parallel if(a)
2459 /// \endcode
2460 /// In this example directive '#pragma omp target parallel' has clause 'if' with
2461 /// condition 'a'.
2462 ///
2464  friend class ASTStmtReader;
2465  /// \brief Build directive with the given start and end location.
2466  ///
2467  /// \param StartLoc Starting location of the directive kind.
2468  /// \param EndLoc Ending location of the directive.
2469  /// \param NumClauses Number of clauses.
2470  ///
2472  unsigned NumClauses)
2473  : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
2474  OMPD_target_parallel, StartLoc, EndLoc,
2475  NumClauses, /*NumChildren=*/1) {}
2476 
2477  /// \brief Build an empty directive.
2478  ///
2479  /// \param NumClauses Number of clauses.
2480  ///
2481  explicit OMPTargetParallelDirective(unsigned NumClauses)
2482  : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
2483  OMPD_target_parallel, SourceLocation(),
2484  SourceLocation(), NumClauses,
2485  /*NumChildren=*/1) {}
2486 
2487 public:
2488  /// \brief Creates directive with a list of \a Clauses.
2489  ///
2490  /// \param C AST context.
2491  /// \param StartLoc Starting location of the directive kind.
2492  /// \param EndLoc Ending Location of the directive.
2493  /// \param Clauses List of clauses.
2494  /// \param AssociatedStmt Statement, associated with the directive.
2495  ///
2497  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2498  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2499 
2500  /// \brief Creates an empty directive with the place for \a NumClauses
2501  /// clauses.
2502  ///
2503  /// \param C AST context.
2504  /// \param NumClauses Number of clauses.
2505  ///
2507  CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
2508 
2509  static bool classof(const Stmt *T) {
2510  return T->getStmtClass() == OMPTargetParallelDirectiveClass;
2511  }
2512 };
2513 
2514 /// \brief This represents '#pragma omp target parallel for' directive.
2515 ///
2516 /// \code
2517 /// #pragma omp target parallel for private(a,b) reduction(+:c,d)
2518 /// \endcode
2519 /// In this example directive '#pragma omp target parallel for' has clauses
2520 /// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
2521 /// and variables 'c' and 'd'.
2522 ///
2524  friend class ASTStmtReader;
2525 
2526  /// \brief true if current region has inner cancel directive.
2527  bool HasCancel;
2528 
2529  /// \brief Build directive with the given start and end location.
2530  ///
2531  /// \param StartLoc Starting location of the directive kind.
2532  /// \param EndLoc Ending location of the directive.
2533  /// \param CollapsedNum Number of collapsed nested loops.
2534  /// \param NumClauses Number of clauses.
2535  ///
2537  unsigned CollapsedNum, unsigned NumClauses)
2538  : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
2539  OMPD_target_parallel_for, StartLoc, EndLoc,
2540  CollapsedNum, NumClauses),
2541  HasCancel(false) {}
2542 
2543  /// \brief Build an empty directive.
2544  ///
2545  /// \param CollapsedNum Number of collapsed nested loops.
2546  /// \param NumClauses Number of clauses.
2547  ///
2548  explicit OMPTargetParallelForDirective(unsigned CollapsedNum,
2549  unsigned NumClauses)
2550  : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
2551  OMPD_target_parallel_for, SourceLocation(),
2552  SourceLocation(), CollapsedNum, NumClauses),
2553  HasCancel(false) {}
2554 
2555  /// \brief Set cancel state.
2556  void setHasCancel(bool Has) { HasCancel = Has; }
2557 
2558 public:
2559  /// \brief Creates directive with a list of \a Clauses.
2560  ///
2561  /// \param C AST context.
2562  /// \param StartLoc Starting location of the directive kind.
2563  /// \param EndLoc Ending Location of the directive.
2564  /// \param CollapsedNum Number of collapsed loops.
2565  /// \param Clauses List of clauses.
2566  /// \param AssociatedStmt Statement, associated with the directive.
2567  /// \param Exprs Helper expressions for CodeGen.
2568  /// \param HasCancel true if current directive has inner cancel directive.
2569  ///
2571  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2572  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2573  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
2574 
2575  /// \brief Creates an empty directive with the place
2576  /// for \a NumClauses clauses.
2577  ///
2578  /// \param C AST context.
2579  /// \param CollapsedNum Number of collapsed nested loops.
2580  /// \param NumClauses Number of clauses.
2581  ///
2583  unsigned NumClauses,
2584  unsigned CollapsedNum,
2585  EmptyShell);
2586 
2587  /// \brief Return true if current directive has inner cancel directive.
2588  bool hasCancel() const { return HasCancel; }
2589 
2590  static bool classof(const Stmt *T) {
2591  return T->getStmtClass() == OMPTargetParallelForDirectiveClass;
2592  }
2593 };
2594 
2595 /// \brief This represents '#pragma omp teams' directive.
2596 ///
2597 /// \code
2598 /// #pragma omp teams if(a)
2599 /// \endcode
2600 /// In this example directive '#pragma omp teams' has clause 'if' with
2601 /// condition 'a'.
2602 ///
2604  friend class ASTStmtReader;
2605  /// \brief Build directive with the given start and end location.
2606  ///
2607  /// \param StartLoc Starting location of the directive kind.
2608  /// \param EndLoc Ending location of the directive.
2609  /// \param NumClauses Number of clauses.
2610  ///
2612  unsigned NumClauses)
2613  : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
2614  StartLoc, EndLoc, NumClauses, 1) {}
2615 
2616  /// \brief Build an empty directive.
2617  ///
2618  /// \param NumClauses Number of clauses.
2619  ///
2620  explicit OMPTeamsDirective(unsigned NumClauses)
2621  : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
2622  SourceLocation(), SourceLocation(), NumClauses,
2623  1) {}
2624 
2625 public:
2626  /// \brief Creates directive with a list of \a Clauses.
2627  ///
2628  /// \param C AST context.
2629  /// \param StartLoc Starting location of the directive kind.
2630  /// \param EndLoc Ending Location of the directive.
2631  /// \param Clauses List of clauses.
2632  /// \param AssociatedStmt Statement, associated with the directive.
2633  ///
2634  static OMPTeamsDirective *Create(const ASTContext &C, SourceLocation StartLoc,
2635  SourceLocation EndLoc,
2636  ArrayRef<OMPClause *> Clauses,
2637  Stmt *AssociatedStmt);
2638 
2639  /// \brief Creates an empty directive with the place for \a NumClauses
2640  /// clauses.
2641  ///
2642  /// \param C AST context.
2643  /// \param NumClauses Number of clauses.
2644  ///
2645  static OMPTeamsDirective *CreateEmpty(const ASTContext &C,
2646  unsigned NumClauses, EmptyShell);
2647 
2648  static bool classof(const Stmt *T) {
2649  return T->getStmtClass() == OMPTeamsDirectiveClass;
2650  }
2651 };
2652 
2653 /// \brief This represents '#pragma omp cancellation point' directive.
2654 ///
2655 /// \code
2656 /// #pragma omp cancellation point for
2657 /// \endcode
2658 ///
2659 /// In this example a cancellation point is created for innermost 'for' region.
2661  friend class ASTStmtReader;
2662  OpenMPDirectiveKind CancelRegion;
2663  /// \brief Build directive with the given start and end location.
2664  ///
2665  /// \param StartLoc Starting location of the directive kind.
2666  /// \param EndLoc Ending location of the directive.
2667  ///
2669  : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
2670  OMPD_cancellation_point, StartLoc, EndLoc, 0, 0),
2671  CancelRegion(OMPD_unknown) {}
2672 
2673  /// \brief Build an empty directive.
2674  ///
2676  : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
2677  OMPD_cancellation_point, SourceLocation(),
2678  SourceLocation(), 0, 0),
2679  CancelRegion(OMPD_unknown) {}
2680 
2681  /// \brief Set cancel region for current cancellation point.
2682  /// \param CR Cancellation region.
2683  void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
2684 
2685 public:
2686  /// \brief Creates directive.
2687  ///
2688  /// \param C AST context.
2689  /// \param StartLoc Starting location of the directive kind.
2690  /// \param EndLoc Ending Location of the directive.
2691  ///
2693  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2694  OpenMPDirectiveKind CancelRegion);
2695 
2696  /// \brief Creates an empty directive.
2697  ///
2698  /// \param C AST context.
2699  ///
2701  EmptyShell);
2702 
2703  /// \brief Get cancellation region for the current cancellation point.
2704  OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
2705 
2706  static bool classof(const Stmt *T) {
2707  return T->getStmtClass() == OMPCancellationPointDirectiveClass;
2708  }
2709 };
2710 
2711 /// \brief This represents '#pragma omp cancel' directive.
2712 ///
2713 /// \code
2714 /// #pragma omp cancel for
2715 /// \endcode
2716 ///
2717 /// In this example a cancel is created for innermost 'for' region.
2719  friend class ASTStmtReader;
2720  OpenMPDirectiveKind CancelRegion;
2721  /// \brief Build directive with the given start and end location.
2722  ///
2723  /// \param StartLoc Starting location of the directive kind.
2724  /// \param EndLoc Ending location of the directive.
2725  /// \param NumClauses Number of clauses.
2726  ///
2728  unsigned NumClauses)
2729  : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
2730  StartLoc, EndLoc, NumClauses, 0),
2731  CancelRegion(OMPD_unknown) {}
2732 
2733  /// \brief Build an empty directive.
2734  ///
2735  /// \param NumClauses Number of clauses.
2736  explicit OMPCancelDirective(unsigned NumClauses)
2737  : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
2738  SourceLocation(), SourceLocation(), NumClauses,
2739  0),
2740  CancelRegion(OMPD_unknown) {}
2741 
2742  /// \brief Set cancel region for current cancellation point.
2743  /// \param CR Cancellation region.
2744  void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
2745 
2746 public:
2747  /// \brief Creates directive.
2748  ///
2749  /// \param C AST context.
2750  /// \param StartLoc Starting location of the directive kind.
2751  /// \param EndLoc Ending Location of the directive.
2752  /// \param Clauses List of clauses.
2753  ///
2754  static OMPCancelDirective *
2755  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2756  ArrayRef<OMPClause *> Clauses, OpenMPDirectiveKind CancelRegion);
2757 
2758  /// \brief Creates an empty directive.
2759  ///
2760  /// \param C AST context.
2761  /// \param NumClauses Number of clauses.
2762  ///
2763  static OMPCancelDirective *CreateEmpty(const ASTContext &C,
2764  unsigned NumClauses, EmptyShell);
2765 
2766  /// \brief Get cancellation region for the current cancellation point.
2767  OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
2768 
2769  static bool classof(const Stmt *T) {
2770  return T->getStmtClass() == OMPCancelDirectiveClass;
2771  }
2772 };
2773 
2774 /// \brief This represents '#pragma omp taskloop' directive.
2775 ///
2776 /// \code
2777 /// #pragma omp taskloop private(a,b) grainsize(val) num_tasks(num)
2778 /// \endcode
2779 /// In this example directive '#pragma omp taskloop' has clauses 'private'
2780 /// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
2781 /// 'num_tasks' with expression 'num'.
2782 ///
2784  friend class ASTStmtReader;
2785  /// \brief Build directive with the given start and end location.
2786  ///
2787  /// \param StartLoc Starting location of the directive kind.
2788  /// \param EndLoc Ending location of the directive.
2789  /// \param CollapsedNum Number of collapsed nested loops.
2790  /// \param NumClauses Number of clauses.
2791  ///
2793  unsigned CollapsedNum, unsigned NumClauses)
2794  : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
2795  StartLoc, EndLoc, CollapsedNum, NumClauses) {}
2796 
2797  /// \brief Build an empty directive.
2798  ///
2799  /// \param CollapsedNum Number of collapsed nested loops.
2800  /// \param NumClauses Number of clauses.
2801  ///
2802  explicit OMPTaskLoopDirective(unsigned CollapsedNum, unsigned NumClauses)
2803  : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
2804  SourceLocation(), SourceLocation(), CollapsedNum,
2805  NumClauses) {}
2806 
2807 public:
2808  /// \brief Creates directive with a list of \a Clauses.
2809  ///
2810  /// \param C AST context.
2811  /// \param StartLoc Starting location of the directive kind.
2812  /// \param EndLoc Ending Location of the directive.
2813  /// \param CollapsedNum Number of collapsed loops.
2814  /// \param Clauses List of clauses.
2815  /// \param AssociatedStmt Statement, associated with the directive.
2816  /// \param Exprs Helper expressions for CodeGen.
2817  ///
2818  static OMPTaskLoopDirective *
2819  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2820  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2821  Stmt *AssociatedStmt, const HelperExprs &Exprs);
2822 
2823  /// \brief Creates an empty directive with the place
2824  /// for \a NumClauses clauses.
2825  ///
2826  /// \param C AST context.
2827  /// \param CollapsedNum Number of collapsed nested loops.
2828  /// \param NumClauses Number of clauses.
2829  ///
2831  unsigned NumClauses,
2832  unsigned CollapsedNum, EmptyShell);
2833 
2834  static bool classof(const Stmt *T) {
2835  return T->getStmtClass() == OMPTaskLoopDirectiveClass;
2836  }
2837 };
2838 
2839 /// \brief This represents '#pragma omp taskloop simd' directive.
2840 ///
2841 /// \code
2842 /// #pragma omp taskloop simd private(a,b) grainsize(val) num_tasks(num)
2843 /// \endcode
2844 /// In this example directive '#pragma omp taskloop simd' has clauses 'private'
2845 /// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
2846 /// 'num_tasks' with expression 'num'.
2847 ///
2849  friend class ASTStmtReader;
2850  /// \brief Build directive with the given start and end location.
2851  ///
2852  /// \param StartLoc Starting location of the directive kind.
2853  /// \param EndLoc Ending location of the directive.
2854  /// \param CollapsedNum Number of collapsed nested loops.
2855  /// \param NumClauses Number of clauses.
2856  ///
2858  unsigned CollapsedNum, unsigned NumClauses)
2859  : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
2860  OMPD_taskloop_simd, StartLoc, EndLoc, CollapsedNum,
2861  NumClauses) {}
2862 
2863  /// \brief Build an empty directive.
2864  ///
2865  /// \param CollapsedNum Number of collapsed nested loops.
2866  /// \param NumClauses Number of clauses.
2867  ///
2868  explicit OMPTaskLoopSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
2869  : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
2870  OMPD_taskloop_simd, SourceLocation(), SourceLocation(),
2871  CollapsedNum, NumClauses) {}
2872 
2873 public:
2874  /// \brief Creates directive with a list of \a Clauses.
2875  ///
2876  /// \param C AST context.
2877  /// \param StartLoc Starting location of the directive kind.
2878  /// \param EndLoc Ending Location of the directive.
2879  /// \param CollapsedNum Number of collapsed loops.
2880  /// \param Clauses List of clauses.
2881  /// \param AssociatedStmt Statement, associated with the directive.
2882  /// \param Exprs Helper expressions for CodeGen.
2883  ///
2884  static OMPTaskLoopSimdDirective *
2885  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2886  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2887  Stmt *AssociatedStmt, const HelperExprs &Exprs);
2888 
2889  /// \brief Creates an empty directive with the place
2890  /// for \a NumClauses clauses.
2891  ///
2892  /// \param C AST context.
2893  /// \param CollapsedNum Number of collapsed nested loops.
2894  /// \param NumClauses Number of clauses.
2895  ///
2897  unsigned NumClauses,
2898  unsigned CollapsedNum,
2899  EmptyShell);
2900 
2901  static bool classof(const Stmt *T) {
2902  return T->getStmtClass() == OMPTaskLoopSimdDirectiveClass;
2903  }
2904 };
2905 
2906 /// \brief This represents '#pragma omp distribute' directive.
2907 ///
2908 /// \code
2909 /// #pragma omp distribute private(a,b)
2910 /// \endcode
2911 /// In this example directive '#pragma omp distribute' has clauses 'private'
2912 /// with the variables 'a' and 'b'
2913 ///
2915  friend class ASTStmtReader;
2916 
2917  /// \brief Build directive with the given start and end location.
2918  ///
2919  /// \param StartLoc Starting location of the directive kind.
2920  /// \param EndLoc Ending location of the directive.
2921  /// \param CollapsedNum Number of collapsed nested loops.
2922  /// \param NumClauses Number of clauses.
2923  ///
2925  unsigned CollapsedNum, unsigned NumClauses)
2926  : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
2927  StartLoc, EndLoc, CollapsedNum, NumClauses)
2928  {}
2929 
2930  /// \brief Build an empty directive.
2931  ///
2932  /// \param CollapsedNum Number of collapsed nested loops.
2933  /// \param NumClauses Number of clauses.
2934  ///
2935  explicit OMPDistributeDirective(unsigned CollapsedNum, unsigned NumClauses)
2936  : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
2937  SourceLocation(), SourceLocation(), CollapsedNum,
2938  NumClauses)
2939  {}
2940 
2941 public:
2942  /// \brief Creates directive with a list of \a Clauses.
2943  ///
2944  /// \param C AST context.
2945  /// \param StartLoc Starting location of the directive kind.
2946  /// \param EndLoc Ending Location of the directive.
2947  /// \param CollapsedNum Number of collapsed loops.
2948  /// \param Clauses List of clauses.
2949  /// \param AssociatedStmt Statement, associated with the directive.
2950  /// \param Exprs Helper expressions for CodeGen.
2951  ///
2952  static OMPDistributeDirective *
2953  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2954  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2955  Stmt *AssociatedStmt, const HelperExprs &Exprs);
2956 
2957  /// \brief Creates an empty directive with the place
2958  /// for \a NumClauses clauses.
2959  ///
2960  /// \param C AST context.
2961  /// \param CollapsedNum Number of collapsed nested loops.
2962  /// \param NumClauses Number of clauses.
2963  ///
2965  unsigned NumClauses,
2966  unsigned CollapsedNum, EmptyShell);
2967 
2968  static bool classof(const Stmt *T) {
2969  return T->getStmtClass() == OMPDistributeDirectiveClass;
2970  }
2971 };
2972 
2973 /// \brief This represents '#pragma omp target update' directive.
2974 ///
2975 /// \code
2976 /// #pragma omp target update to(a) from(b) device(1)
2977 /// \endcode
2978 /// In this example directive '#pragma omp target update' has clause 'to' with
2979 /// argument 'a', clause 'from' with argument 'b' and clause 'device' with
2980 /// argument '1'.
2981 ///
2983  friend class ASTStmtReader;
2984  /// \brief Build directive with the given start and end location.
2985  ///
2986  /// \param StartLoc Starting location of the directive kind.
2987  /// \param EndLoc Ending Location of the directive.
2988  /// \param NumClauses The number of clauses.
2989  ///
2991  unsigned NumClauses)
2992  : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
2993  OMPD_target_update, StartLoc, EndLoc, NumClauses,
2994  1) {}
2995 
2996  /// \brief Build an empty directive.
2997  ///
2998  /// \param NumClauses Number of clauses.
2999  ///
3000  explicit OMPTargetUpdateDirective(unsigned NumClauses)
3001  : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
3002  OMPD_target_update, SourceLocation(),
3003  SourceLocation(), NumClauses, 1) {}
3004 
3005 public:
3006  /// \brief Creates directive with a list of \a Clauses.
3007  ///
3008  /// \param C AST context.
3009  /// \param StartLoc Starting location of the directive kind.
3010  /// \param EndLoc Ending Location of the directive.
3011  /// \param Clauses List of clauses.
3012  /// \param AssociatedStmt Statement, associated with the directive.
3013  ///
3014  static OMPTargetUpdateDirective *
3015  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3016  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
3017 
3018  /// \brief Creates an empty directive with the place for \a NumClauses
3019  /// clauses.
3020  ///
3021  /// \param C AST context.
3022  /// \param NumClauses The number of clauses.
3023  ///
3025  unsigned NumClauses, EmptyShell);
3026 
3027  static bool classof(const Stmt *T) {
3028  return T->getStmtClass() == OMPTargetUpdateDirectiveClass;
3029  }
3030 };
3031 
3032 /// \brief This represents '#pragma omp distribute parallel for' composite
3033 /// directive.
3034 ///
3035 /// \code
3036 /// #pragma omp distribute parallel for private(a,b)
3037 /// \endcode
3038 /// In this example directive '#pragma omp distribute parallel for' has clause
3039 /// 'private' with the variables 'a' and 'b'
3040 ///
3042  friend class ASTStmtReader;
3043  /// true if the construct has inner cancel directive.
3044  bool HasCancel = false;
3045 
3046  /// \brief Build directive with the given start and end location.
3047  ///
3048  /// \param StartLoc Starting location of the directive kind.
3049  /// \param EndLoc Ending location of the directive.
3050  /// \param CollapsedNum Number of collapsed nested loops.
3051  /// \param NumClauses Number of clauses.
3052  ///
3054  SourceLocation EndLoc,
3055  unsigned CollapsedNum, unsigned NumClauses)
3056  : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
3057  OMPD_distribute_parallel_for, StartLoc, EndLoc,
3058  CollapsedNum, NumClauses), HasCancel(false) {}
3059 
3060  /// \brief Build an empty directive.
3061  ///
3062  /// \param CollapsedNum Number of collapsed nested loops.
3063  /// \param NumClauses Number of clauses.
3064  ///
3065  explicit OMPDistributeParallelForDirective(unsigned CollapsedNum,
3066  unsigned NumClauses)
3067  : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
3068  OMPD_distribute_parallel_for, SourceLocation(),
3069  SourceLocation(), CollapsedNum, NumClauses),
3070  HasCancel(false) {}
3071 
3072  /// Set cancel state.
3073  void setHasCancel(bool Has) { HasCancel = Has; }
3074 
3075 public:
3076  /// \brief Creates directive with a list of \a Clauses.
3077  ///
3078  /// \param C AST context.
3079  /// \param StartLoc Starting location of the directive kind.
3080  /// \param EndLoc Ending Location of the directive.
3081  /// \param CollapsedNum Number of collapsed loops.
3082  /// \param Clauses List of clauses.
3083  /// \param AssociatedStmt Statement, associated with the directive.
3084  /// \param Exprs Helper expressions for CodeGen.
3085  /// \param HasCancel true if this directive has inner cancel directive.
3086  ///
3088  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3089  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3090  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
3091 
3092  /// \brief Creates an empty directive with the place
3093  /// for \a NumClauses clauses.
3094  ///
3095  /// \param C AST context.
3096  /// \param CollapsedNum Number of collapsed nested loops.
3097  /// \param NumClauses Number of clauses.
3098  ///
3100  unsigned NumClauses,
3101  unsigned CollapsedNum,
3102  EmptyShell);
3103 
3104  /// Return true if current directive has inner cancel directive.
3105  bool hasCancel() const { return HasCancel; }
3106 
3107  static bool classof(const Stmt *T) {
3108  return T->getStmtClass() == OMPDistributeParallelForDirectiveClass;
3109  }
3110 };
3111 
3112 /// This represents '#pragma omp distribute parallel for simd' composite
3113 /// directive.
3114 ///
3115 /// \code
3116 /// #pragma omp distribute parallel for simd private(x)
3117 /// \endcode
3118 /// In this example directive '#pragma omp distribute parallel for simd' has
3119 /// clause 'private' with the variables 'x'
3120 ///
3122  friend class ASTStmtReader;
3123 
3124  /// Build directive with the given start and end location.
3125  ///
3126  /// \param StartLoc Starting location of the directive kind.
3127  /// \param EndLoc Ending location of the directive.
3128  /// \param CollapsedNum Number of collapsed nested loops.
3129  /// \param NumClauses Number of clauses.
3130  ///
3132  SourceLocation EndLoc,
3133  unsigned CollapsedNum,
3134  unsigned NumClauses)
3135  : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
3136  OMPD_distribute_parallel_for_simd, StartLoc,
3137  EndLoc, CollapsedNum, NumClauses) {}
3138 
3139  /// Build an empty directive.
3140  ///
3141  /// \param CollapsedNum Number of collapsed nested loops.
3142  /// \param NumClauses Number of clauses.
3143  ///
3144  explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum,
3145  unsigned NumClauses)
3146  : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
3147  OMPD_distribute_parallel_for_simd,
3148  SourceLocation(), SourceLocation(), CollapsedNum,
3149  NumClauses) {}
3150 
3151 public:
3152  /// Creates directive with a list of \a Clauses.
3153  ///
3154  /// \param C AST context.
3155  /// \param StartLoc Starting location of the directive kind.
3156  /// \param EndLoc Ending Location of the directive.
3157  /// \param CollapsedNum Number of collapsed loops.
3158  /// \param Clauses List of clauses.
3159  /// \param AssociatedStmt Statement, associated with the directive.
3160  /// \param Exprs Helper expressions for CodeGen.
3161  ///
3163  const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3164  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3165  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3166 
3167  /// Creates an empty directive with the place for \a NumClauses clauses.
3168  ///
3169  /// \param C AST context.
3170  /// \param CollapsedNum Number of collapsed nested loops.
3171  /// \param NumClauses Number of clauses.
3172  ///
3174  const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3175  EmptyShell);
3176 
3177  static bool classof(const Stmt *T) {
3178  return T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass;
3179  }
3180 };
3181 
3182 /// This represents '#pragma omp distribute simd' composite directive.
3183 ///
3184 /// \code
3185 /// #pragma omp distribute simd private(x)
3186 /// \endcode
3187 /// In this example directive '#pragma omp distribute simd' has clause
3188 /// 'private' with the variables 'x'
3189 ///
3191  friend class ASTStmtReader;
3192 
3193  /// Build directive with the given start and end location.
3194  ///
3195  /// \param StartLoc Starting location of the directive kind.
3196  /// \param EndLoc Ending location of the directive.
3197  /// \param CollapsedNum Number of collapsed nested loops.
3198  /// \param NumClauses Number of clauses.
3199  ///
3201  unsigned CollapsedNum, unsigned NumClauses)
3202  : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
3203  OMPD_distribute_simd, StartLoc, EndLoc, CollapsedNum,
3204  NumClauses) {}
3205 
3206  /// Build an empty directive.
3207  ///
3208  /// \param CollapsedNum Number of collapsed nested loops.
3209  /// \param NumClauses Number of clauses.
3210  ///
3211  explicit OMPDistributeSimdDirective(unsigned CollapsedNum,
3212  unsigned NumClauses)
3213  : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
3214  OMPD_distribute_simd, SourceLocation(),
3215  SourceLocation(), CollapsedNum, NumClauses) {}
3216 
3217 public:
3218  /// Creates directive with a list of \a Clauses.
3219  ///
3220  /// \param C AST context.
3221  /// \param StartLoc Starting location of the directive kind.
3222  /// \param EndLoc Ending Location of the directive.
3223  /// \param CollapsedNum Number of collapsed loops.
3224  /// \param Clauses List of clauses.
3225  /// \param AssociatedStmt Statement, associated with the directive.
3226  /// \param Exprs Helper expressions for CodeGen.
3227  ///
3229  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3230  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3231  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3232 
3233  /// Creates an empty directive with the place for \a NumClauses clauses.
3234  ///
3235  /// \param C AST context.
3236  /// \param CollapsedNum Number of collapsed nested loops.
3237  /// \param NumClauses Number of clauses.
3238  ///
3240  unsigned NumClauses,
3241  unsigned CollapsedNum,
3242  EmptyShell);
3243 
3244  static bool classof(const Stmt *T) {
3245  return T->getStmtClass() == OMPDistributeSimdDirectiveClass;
3246  }
3247 };
3248 
3249 /// This represents '#pragma omp target parallel for simd' directive.
3250 ///
3251 /// \code
3252 /// #pragma omp target parallel for simd private(a) map(b) safelen(c)
3253 /// \endcode
3254 /// In this example directive '#pragma omp target parallel for simd' has clauses
3255 /// 'private' with the variable 'a', 'map' with the variable 'b' and 'safelen'
3256 /// with the variable 'c'.
3257 ///
3259  friend class ASTStmtReader;
3260 
3261  /// Build directive with the given start and end location.
3262  ///
3263  /// \param StartLoc Starting location of the directive kind.
3264  /// \param EndLoc Ending location of the directive.
3265  /// \param CollapsedNum Number of collapsed nested loops.
3266  /// \param NumClauses Number of clauses.
3267  ///
3269  unsigned CollapsedNum, unsigned NumClauses)
3270  : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
3271  OMPD_target_parallel_for_simd, StartLoc, EndLoc,
3272  CollapsedNum, NumClauses) {}
3273 
3274  /// Build an empty directive.
3275  ///
3276  /// \param CollapsedNum Number of collapsed nested loops.
3277  /// \param NumClauses Number of clauses.
3278  ///
3279  explicit OMPTargetParallelForSimdDirective(unsigned CollapsedNum,
3280  unsigned NumClauses)
3281  : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
3282  OMPD_target_parallel_for_simd, SourceLocation(),
3283  SourceLocation(), CollapsedNum, NumClauses) {}
3284 
3285 public:
3286  /// Creates directive with a list of \a Clauses.
3287  ///
3288  /// \param C AST context.
3289  /// \param StartLoc Starting location of the directive kind.
3290  /// \param EndLoc Ending Location of the directive.
3291  /// \param CollapsedNum Number of collapsed loops.
3292  /// \param Clauses List of clauses.
3293  /// \param AssociatedStmt Statement, associated with the directive.
3294  /// \param Exprs Helper expressions for CodeGen.
3295  ///
3297  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3298  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3299  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3300 
3301  /// Creates an empty directive with the place for \a NumClauses clauses.
3302  ///
3303  /// \param C AST context.
3304  /// \param CollapsedNum Number of collapsed nested loops.
3305  /// \param NumClauses Number of clauses.
3306  ///
3308  unsigned NumClauses,
3309  unsigned CollapsedNum,
3310  EmptyShell);
3311 
3312  static bool classof(const Stmt *T) {
3313  return T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass;
3314  }
3315 };
3316 
3317 /// This represents '#pragma omp target simd' directive.
3318 ///
3319 /// \code
3320 /// #pragma omp target simd private(a) map(b) safelen(c)
3321 /// \endcode
3322 /// In this example directive '#pragma omp target simd' has clauses 'private'
3323 /// with the variable 'a', 'map' with the variable 'b' and 'safelen' with
3324 /// the variable 'c'.
3325 ///
3327  friend class ASTStmtReader;
3328 
3329  /// Build directive with the given start and end location.
3330  ///
3331  /// \param StartLoc Starting location of the directive kind.
3332  /// \param EndLoc Ending location of the directive.
3333  /// \param CollapsedNum Number of collapsed nested loops.
3334  /// \param NumClauses Number of clauses.
3335  ///
3337  unsigned CollapsedNum, unsigned NumClauses)
3338  : OMPLoopDirective(this, OMPTargetSimdDirectiveClass,
3339  OMPD_target_simd, StartLoc, EndLoc, CollapsedNum,
3340  NumClauses) {}
3341 
3342  /// Build an empty directive.
3343  ///
3344  /// \param CollapsedNum Number of collapsed nested loops.
3345  /// \param NumClauses Number of clauses.
3346  ///
3347  explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
3348  : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd,
3349  SourceLocation(),SourceLocation(), CollapsedNum,
3350  NumClauses) {}
3351 
3352 public:
3353  /// Creates directive with a list of \a Clauses.
3354  ///
3355  /// \param C AST context.
3356  /// \param StartLoc Starting location of the directive kind.
3357  /// \param EndLoc Ending Location of the directive.
3358  /// \param CollapsedNum Number of collapsed loops.
3359  /// \param Clauses List of clauses.
3360  /// \param AssociatedStmt Statement, associated with the directive.
3361  /// \param Exprs Helper expressions for CodeGen.
3362  ///
3363  static OMPTargetSimdDirective *
3364  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3365  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3366  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3367 
3368  /// Creates an empty directive with the place for \a NumClauses clauses.
3369  ///
3370  /// \param C AST context.
3371  /// \param CollapsedNum Number of collapsed nested loops.
3372  /// \param NumClauses Number of clauses.
3373  ///
3375  unsigned NumClauses,
3376  unsigned CollapsedNum,
3377  EmptyShell);
3378 
3379  static bool classof(const Stmt *T) {
3380  return T->getStmtClass() == OMPTargetSimdDirectiveClass;
3381  }
3382 };
3383 
3384 /// This represents '#pragma omp teams distribute' directive.
3385 ///
3386 /// \code
3387 /// #pragma omp teams distribute private(a,b)
3388 /// \endcode
3389 /// In this example directive '#pragma omp teams distribute' has clauses
3390 /// 'private' with the variables 'a' and 'b'
3391 ///
3393  friend class ASTStmtReader;
3394 
3395  /// Build directive with the given start and end location.
3396  ///
3397  /// \param StartLoc Starting location of the directive kind.
3398  /// \param EndLoc Ending location of the directive.
3399  /// \param CollapsedNum Number of collapsed nested loops.
3400  /// \param NumClauses Number of clauses.
3401  ///
3403  unsigned CollapsedNum, unsigned NumClauses)
3404  : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
3405  OMPD_teams_distribute, StartLoc, EndLoc,
3406  CollapsedNum, NumClauses) {}
3407 
3408  /// Build an empty directive.
3409  ///
3410  /// \param CollapsedNum Number of collapsed nested loops.
3411  /// \param NumClauses Number of clauses.
3412  ///
3413  explicit OMPTeamsDistributeDirective(unsigned CollapsedNum,
3414  unsigned NumClauses)
3415  : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
3416  OMPD_teams_distribute, SourceLocation(),
3417  SourceLocation(), CollapsedNum, NumClauses) {}
3418 
3419 public:
3420  /// Creates directive with a list of \a Clauses.
3421  ///
3422  /// \param C AST context.
3423  /// \param StartLoc Starting location of the directive kind.
3424  /// \param EndLoc Ending Location of the directive.
3425  /// \param CollapsedNum Number of collapsed loops.
3426  /// \param Clauses List of clauses.
3427  /// \param AssociatedStmt Statement, associated with the directive.
3428  /// \param Exprs Helper expressions for CodeGen.
3429  ///
3431  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3432  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3433  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3434 
3435  /// Creates an empty directive with the place for \a NumClauses clauses.
3436  ///
3437  /// \param C AST context.
3438  /// \param CollapsedNum Number of collapsed nested loops.
3439  /// \param NumClauses Number of clauses.
3440  ///
3442  unsigned NumClauses,
3443  unsigned CollapsedNum,
3444  EmptyShell);
3445 
3446  static bool classof(const Stmt *T) {
3447  return T->getStmtClass() == OMPTeamsDistributeDirectiveClass;
3448  }
3449 };
3450 
3451 /// This represents '#pragma omp teams distribute simd'
3452 /// combined directive.
3453 ///
3454 /// \code
3455 /// #pragma omp teams distribute simd private(a,b)
3456 /// \endcode
3457 /// In this example directive '#pragma omp teams distribute simd'
3458 /// has clause 'private' with the variables 'a' and 'b'
3459 ///
3461  friend class ASTStmtReader;
3462 
3463  /// Build directive with the given start and end location.
3464  ///
3465  /// \param StartLoc Starting location of the directive kind.
3466  /// \param EndLoc Ending location of the directive.
3467  /// \param CollapsedNum Number of collapsed nested loops.
3468  /// \param NumClauses Number of clauses.
3469  ///
3471  SourceLocation EndLoc, unsigned CollapsedNum,
3472  unsigned NumClauses)
3473  : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
3474  OMPD_teams_distribute_simd, StartLoc, EndLoc,
3475  CollapsedNum, NumClauses) {}
3476 
3477  /// Build an empty directive.
3478  ///
3479  /// \param CollapsedNum Number of collapsed nested loops.
3480  /// \param NumClauses Number of clauses.
3481  ///
3482  explicit OMPTeamsDistributeSimdDirective(unsigned CollapsedNum,
3483  unsigned NumClauses)
3484  : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
3485  OMPD_teams_distribute_simd, SourceLocation(),
3486  SourceLocation(), CollapsedNum, NumClauses) {}
3487 
3488 public:
3489  /// Creates directive with a list of \a Clauses.
3490  ///
3491  /// \param C AST context.
3492  /// \param StartLoc Starting location of the directive kind.
3493  /// \param EndLoc Ending Location of the directive.
3494  /// \param CollapsedNum Number of collapsed loops.
3495  /// \param Clauses List of clauses.
3496  /// \param AssociatedStmt Statement, associated with the directive.
3497  /// \param Exprs Helper expressions for CodeGen.
3498  ///
3500  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3501  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3502  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3503 
3504  /// Creates an empty directive with the place
3505  /// for \a NumClauses clauses.
3506  ///
3507  /// \param C AST context.
3508  /// \param CollapsedNum Number of collapsed nested loops.
3509  /// \param NumClauses Number of clauses.
3510  ///
3512  unsigned NumClauses,
3513  unsigned CollapsedNum,
3514  EmptyShell);
3515 
3516  static bool classof(const Stmt *T) {
3517  return T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass;
3518  }
3519 };
3520 
3521 /// This represents '#pragma omp teams distribute parallel for simd' composite
3522 /// directive.
3523 ///
3524 /// \code
3525 /// #pragma omp teams distribute parallel for simd private(x)
3526 /// \endcode
3527 /// In this example directive '#pragma omp teams distribute parallel for simd'
3528 /// has clause 'private' with the variables 'x'
3529 ///
3531  : public OMPLoopDirective {
3532  friend class ASTStmtReader;
3533 
3534  /// Build directive with the given start and end location.
3535  ///
3536  /// \param StartLoc Starting location of the directive kind.
3537  /// \param EndLoc Ending location of the directive.
3538  /// \param CollapsedNum Number of collapsed nested loops.
3539  /// \param NumClauses Number of clauses.
3540  ///
3542  SourceLocation EndLoc,
3543  unsigned CollapsedNum,
3544  unsigned NumClauses)
3545  : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
3546  OMPD_teams_distribute_parallel_for_simd, StartLoc,
3547  EndLoc, CollapsedNum, NumClauses) {}
3548 
3549  /// Build an empty directive.
3550  ///
3551  /// \param CollapsedNum Number of collapsed nested loops.
3552  /// \param NumClauses Number of clauses.
3553  ///
3554  explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum,
3555  unsigned NumClauses)
3556  : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
3557  OMPD_teams_distribute_parallel_for_simd,
3558  SourceLocation(), SourceLocation(), CollapsedNum,
3559  NumClauses) {}
3560 
3561 public:
3562  /// Creates directive with a list of \a Clauses.
3563  ///
3564  /// \param C AST context.
3565  /// \param StartLoc Starting location of the directive kind.
3566  /// \param EndLoc Ending Location of the directive.
3567  /// \param CollapsedNum Number of collapsed loops.
3568  /// \param Clauses List of clauses.
3569  /// \param AssociatedStmt Statement, associated with the directive.
3570  /// \param Exprs Helper expressions for CodeGen.
3571  ///
3573  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3574  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3575  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3576 
3577  /// Creates an empty directive with the place for \a NumClauses clauses.
3578  ///
3579  /// \param C AST context.
3580  /// \param CollapsedNum Number of collapsed nested loops.
3581  /// \param NumClauses Number of clauses.
3582  ///
3584  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3585  EmptyShell);
3586 
3587  static bool classof(const Stmt *T) {
3588  return T->getStmtClass() == OMPTeamsDistributeParallelForSimdDirectiveClass;
3589  }
3590 };
3591 
3592 /// This represents '#pragma omp teams distribute parallel for' composite
3593 /// directive.
3594 ///
3595 /// \code
3596 /// #pragma omp teams distribute parallel for private(x)
3597 /// \endcode
3598 /// In this example directive '#pragma omp teams distribute parallel for'
3599 /// has clause 'private' with the variables 'x'
3600 ///
3602  friend class ASTStmtReader;
3603  /// true if the construct has inner cancel directive.
3604  bool HasCancel = false;
3605 
3606  /// Build directive with the given start and end location.
3607  ///
3608  /// \param StartLoc Starting location of the directive kind.
3609  /// \param EndLoc Ending location of the directive.
3610  /// \param CollapsedNum Number of collapsed nested loops.
3611  /// \param NumClauses Number of clauses.
3612  ///
3614  SourceLocation EndLoc,
3615  unsigned CollapsedNum,
3616  unsigned NumClauses)
3617  : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
3618  OMPD_teams_distribute_parallel_for, StartLoc, EndLoc,
3619  CollapsedNum, NumClauses), HasCancel(false) {}
3620 
3621  /// Build an empty directive.
3622  ///
3623  /// \param CollapsedNum Number of collapsed nested loops.
3624  /// \param NumClauses Number of clauses.
3625  ///
3626  explicit OMPTeamsDistributeParallelForDirective(unsigned CollapsedNum,
3627  unsigned NumClauses)
3628  : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
3629  OMPD_teams_distribute_parallel_for, SourceLocation(),
3630  SourceLocation(), CollapsedNum, NumClauses),
3631  HasCancel(false) {}
3632 
3633  /// Set cancel state.
3634  void setHasCancel(bool Has) { HasCancel = Has; }
3635 
3636 public:
3637  /// Creates directive with a list of \a Clauses.
3638  ///
3639  /// \param C AST context.
3640  /// \param StartLoc Starting location of the directive kind.
3641  /// \param EndLoc Ending Location of the directive.
3642  /// \param CollapsedNum Number of collapsed loops.
3643  /// \param Clauses List of clauses.
3644  /// \param AssociatedStmt Statement, associated with the directive.
3645  /// \param Exprs Helper expressions for CodeGen.
3646  /// \param HasCancel true if this directive has inner cancel directive.
3647  ///
3649  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3650  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3651  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
3652 
3653  /// Creates an empty directive with the place for \a NumClauses clauses.
3654  ///
3655  /// \param C AST context.
3656  /// \param CollapsedNum Number of collapsed nested loops.
3657  /// \param NumClauses Number of clauses.
3658  ///
3660  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3661  EmptyShell);
3662 
3663  /// Return true if current directive has inner cancel directive.
3664  bool hasCancel() const { return HasCancel; }
3665 
3666  static bool classof(const Stmt *T) {
3667  return T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass;
3668  }
3669 };
3670 
3671 /// This represents '#pragma omp target teams' directive.
3672 ///
3673 /// \code
3674 /// #pragma omp target teams if(a>0)
3675 /// \endcode
3676 /// In this example directive '#pragma omp target teams' has clause 'if' with
3677 /// condition 'a>0'.
3678 ///
3680  friend class ASTStmtReader;
3681  /// Build directive with the given start and end location.
3682  ///
3683  /// \param StartLoc Starting location of the directive kind.
3684  /// \param EndLoc Ending location of the directive.
3685  /// \param NumClauses Number of clauses.
3686  ///
3688  unsigned NumClauses)
3689  : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
3690  OMPD_target_teams, StartLoc, EndLoc, NumClauses,
3691  1) {}
3692 
3693  /// Build an empty directive.
3694  ///
3695  /// \param NumClauses Number of clauses.
3696  ///
3697  explicit OMPTargetTeamsDirective(unsigned NumClauses)
3698  : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
3699  OMPD_target_teams, SourceLocation(),
3700  SourceLocation(), NumClauses, 1) {}
3701 
3702 public:
3703  /// Creates directive with a list of \a Clauses.
3704  ///
3705  /// \param C AST context.
3706  /// \param StartLoc Starting location of the directive kind.
3707  /// \param EndLoc Ending Location of the directive.
3708  /// \param Clauses List of clauses.
3709  /// \param AssociatedStmt Statement, associated with the directive.
3710  ///
3711  static OMPTargetTeamsDirective *Create(const ASTContext &C,
3712  SourceLocation StartLoc,
3713  SourceLocation EndLoc,
3714  ArrayRef<OMPClause *> Clauses,
3715  Stmt *AssociatedStmt);
3716 
3717  /// Creates an empty directive with the place for \a NumClauses clauses.
3718  ///
3719  /// \param C AST context.
3720  /// \param NumClauses Number of clauses.
3721  ///
3723  unsigned NumClauses, EmptyShell);
3724 
3725  static bool classof(const Stmt *T) {
3726  return T->getStmtClass() == OMPTargetTeamsDirectiveClass;
3727  }
3728 };
3729 
3730 /// This represents '#pragma omp target teams distribute' combined directive.
3731 ///
3732 /// \code
3733 /// #pragma omp target teams distribute private(x)
3734 /// \endcode
3735 /// In this example directive '#pragma omp target teams distribute' has clause
3736 /// 'private' with the variables 'x'
3737 ///
3739  friend class ASTStmtReader;
3740 
3741  /// Build directive with the given start and end location.
3742  ///
3743  /// \param StartLoc Starting location of the directive kind.
3744  /// \param EndLoc Ending location of the directive.
3745  /// \param CollapsedNum Number of collapsed nested loops.
3746  /// \param NumClauses Number of clauses.
3747  ///
3749  SourceLocation EndLoc,
3750  unsigned CollapsedNum, unsigned NumClauses)
3751  : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
3752  OMPD_target_teams_distribute, StartLoc, EndLoc,
3753  CollapsedNum, NumClauses) {}
3754 
3755  /// Build an empty directive.
3756  ///
3757  /// \param CollapsedNum Number of collapsed nested loops.
3758  /// \param NumClauses Number of clauses.
3759  ///
3760  explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum,
3761  unsigned NumClauses)
3762  : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
3763  OMPD_target_teams_distribute, SourceLocation(),
3764  SourceLocation(), CollapsedNum, NumClauses) {}
3765 
3766 public:
3767  /// Creates directive with a list of \a Clauses.
3768  ///
3769  /// \param C AST context.
3770  /// \param StartLoc Starting location of the directive kind.
3771  /// \param EndLoc Ending Location of the directive.
3772  /// \param CollapsedNum Number of collapsed loops.
3773  /// \param Clauses List of clauses.
3774  /// \param AssociatedStmt Statement, associated with the directive.
3775  /// \param Exprs Helper expressions for CodeGen.
3776  ///
3778  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3779  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3780  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3781 
3782  /// Creates an empty directive with the place for \a NumClauses clauses.
3783  ///
3784  /// \param C AST context.
3785  /// \param CollapsedNum Number of collapsed nested loops.
3786  /// \param NumClauses Number of clauses.
3787  ///
3789  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3790  EmptyShell);
3791 
3792  static bool classof(const Stmt *T) {
3793  return T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass;
3794  }
3795 };
3796 
3797 /// This represents '#pragma omp target teams distribute parallel for' combined
3798 /// directive.
3799 ///
3800 /// \code
3801 /// #pragma omp target teams distribute parallel for private(x)
3802 /// \endcode
3803 /// In this example directive '#pragma omp target teams distribute parallel
3804 /// for' has clause 'private' with the variables 'x'
3805 ///
3807  : public OMPLoopDirective {
3808  friend class ASTStmtReader;
3809  /// true if the construct has inner cancel directive.
3810  bool HasCancel = false;
3811 
3812  /// Build directive with the given start and end location.
3813  ///
3814  /// \param StartLoc Starting location of the directive kind.
3815  /// \param EndLoc Ending location of the directive.
3816  /// \param CollapsedNum Number of collapsed nested loops.
3817  /// \param NumClauses Number of clauses.
3818  ///
3820  SourceLocation EndLoc,
3821  unsigned CollapsedNum,
3822  unsigned NumClauses)
3823  : OMPLoopDirective(this,
3824  OMPTargetTeamsDistributeParallelForDirectiveClass,
3825  OMPD_target_teams_distribute_parallel_for, StartLoc,
3826  EndLoc, CollapsedNum, NumClauses),
3827  HasCancel(false) {}
3828 
3829  /// Build an empty directive.
3830  ///
3831  /// \param CollapsedNum Number of collapsed nested loops.
3832  /// \param NumClauses Number of clauses.
3833  ///
3834  explicit OMPTargetTeamsDistributeParallelForDirective(unsigned CollapsedNum,
3835  unsigned NumClauses)
3836  : OMPLoopDirective(
3837  this, OMPTargetTeamsDistributeParallelForDirectiveClass,
3838  OMPD_target_teams_distribute_parallel_for, SourceLocation(),
3839  SourceLocation(), CollapsedNum, NumClauses),
3840  HasCancel(false) {}
3841 
3842  /// Set cancel state.
3843  void setHasCancel(bool Has) { HasCancel = Has; }
3844 
3845 public:
3846  /// Creates directive with a list of \a Clauses.
3847  ///
3848  /// \param C AST context.
3849  /// \param StartLoc Starting location of the directive kind.
3850  /// \param EndLoc Ending Location of the directive.
3851  /// \param CollapsedNum Number of collapsed loops.
3852  /// \param Clauses List of clauses.
3853  /// \param AssociatedStmt Statement, associated with the directive.
3854  /// \param Exprs Helper expressions for CodeGen.
3855  /// \param HasCancel true if this directive has inner cancel directive.
3856  ///
3858  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3859  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3860  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
3861 
3862  /// Creates an empty directive with the place for \a NumClauses clauses.
3863  ///
3864  /// \param C AST context.
3865  /// \param CollapsedNum Number of collapsed nested loops.
3866  /// \param NumClauses Number of clauses.
3867  ///
3869  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3870  EmptyShell);
3871 
3872  /// Return true if current directive has inner cancel directive.
3873  bool hasCancel() const { return HasCancel; }
3874 
3875  static bool classof(const Stmt *T) {
3876  return T->getStmtClass() ==
3877  OMPTargetTeamsDistributeParallelForDirectiveClass;
3878  }
3879 };
3880 
3881 /// This represents '#pragma omp target teams distribute parallel for simd'
3882 /// combined directive.
3883 ///
3884 /// \code
3885 /// #pragma omp target teams distribute parallel for simd private(x)
3886 /// \endcode
3887 /// In this example directive '#pragma omp target teams distribute parallel
3888 /// for simd' has clause 'private' with the variables 'x'
3889 ///
3891  : public OMPLoopDirective {
3892  friend class ASTStmtReader;
3893 
3894  /// Build directive with the given start and end location.
3895  ///
3896  /// \param StartLoc Starting location of the directive kind.
3897  /// \param EndLoc Ending location of the directive.
3898  /// \param CollapsedNum Number of collapsed nested loops.
3899  /// \param NumClauses Number of clauses.
3900  ///
3902  SourceLocation EndLoc,
3903  unsigned CollapsedNum,
3904  unsigned NumClauses)
3905  : OMPLoopDirective(this,
3906  OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
3907  OMPD_target_teams_distribute_parallel_for_simd,
3908  StartLoc, EndLoc, CollapsedNum, NumClauses) {}
3909 
3910  /// Build an empty directive.
3911  ///
3912  /// \param CollapsedNum Number of collapsed nested loops.
3913  /// \param NumClauses Number of clauses.
3914  ///
3916  unsigned CollapsedNum, unsigned NumClauses)
3917  : OMPLoopDirective(
3918  this, OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
3919  OMPD_target_teams_distribute_parallel_for_simd, SourceLocation(),
3920  SourceLocation(), CollapsedNum, NumClauses) {}
3921 
3922 public:
3923  /// Creates directive with a list of \a Clauses.
3924  ///
3925  /// \param C AST context.
3926  /// \param StartLoc Starting location of the directive kind.
3927  /// \param EndLoc Ending Location of the directive.
3928  /// \param CollapsedNum Number of collapsed loops.
3929  /// \param Clauses List of clauses.
3930  /// \param AssociatedStmt Statement, associated with the directive.
3931  /// \param Exprs Helper expressions for CodeGen.
3932  ///
3934  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3935  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3936  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3937 
3938  /// Creates an empty directive with the place for \a NumClauses clauses.
3939  ///
3940  /// \param C AST context.
3941  /// \param CollapsedNum Number of collapsed nested loops.
3942  /// \param NumClauses Number of clauses.
3943  ///
3945  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3946  EmptyShell);
3947 
3948  static bool classof(const Stmt *T) {
3949  return T->getStmtClass() ==
3950  OMPTargetTeamsDistributeParallelForSimdDirectiveClass;
3951  }
3952 };
3953 
3954 /// This represents '#pragma omp target teams distribute simd' combined
3955 /// directive.
3956 ///
3957 /// \code
3958 /// #pragma omp target teams distribute simd private(x)
3959 /// \endcode
3960 /// In this example directive '#pragma omp target teams distribute simd'
3961 /// has clause 'private' with the variables 'x'
3962 ///
3964  friend class ASTStmtReader;
3965 
3966  /// Build directive with the given start and end location.
3967  ///
3968  /// \param StartLoc Starting location of the directive kind.
3969  /// \param EndLoc Ending location of the directive.
3970  /// \param CollapsedNum Number of collapsed nested loops.
3971  /// \param NumClauses Number of clauses.
3972  ///
3974  SourceLocation EndLoc,
3975  unsigned CollapsedNum,
3976  unsigned NumClauses)
3977  : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
3978  OMPD_target_teams_distribute_simd, StartLoc, EndLoc,
3979  CollapsedNum, NumClauses) {}
3980 
3981  /// Build an empty directive.
3982  ///
3983  /// \param CollapsedNum Number of collapsed nested loops.
3984  /// \param NumClauses Number of clauses.
3985  ///
3986  explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum,
3987  unsigned NumClauses)
3988  : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
3989  OMPD_target_teams_distribute_simd, SourceLocation(),
3990  SourceLocation(), CollapsedNum, NumClauses) {}
3991 
3992 public:
3993  /// Creates directive with a list of \a Clauses.
3994  ///
3995  /// \param C AST context.
3996  /// \param StartLoc Starting location of the directive kind.
3997  /// \param EndLoc Ending Location of the directive.
3998  /// \param CollapsedNum Number of collapsed loops.
3999  /// \param Clauses List of clauses.
4000  /// \param AssociatedStmt Statement, associated with the directive.
4001  /// \param Exprs Helper expressions for CodeGen.
4002  ///
4004  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4005  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4006  Stmt *AssociatedStmt, const HelperExprs &Exprs);
4007 
4008  /// Creates an empty directive with the place for \a NumClauses clauses.
4009  ///
4010  /// \param C AST context.
4011  /// \param CollapsedNum Number of collapsed nested loops.
4012  /// \param NumClauses Number of clauses.
4013  ///
4015  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
4016  EmptyShell);
4017 
4018  static bool classof(const Stmt *T) {
4019  return T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass;
4020  }
4021 };
4022 
4023 } // end namespace clang
4024 
4025 #endif
void setPreInits(Stmt *PreInits)
Definition: StmtOpenMP.h:469
child_iterator child_begin()
Definition: Stmt.h:452
Expr * NLB
Update of LowerBound for statically sheduled &#39;omp for&#39; loops.
Definition: StmtOpenMP.h:647
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:303
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2084
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3190
Expr * getNextUpperBound() const
Definition: StmtOpenMP.h:818
SmallVector< Expr *, 4 > Finals
Final loop counter values for GodeGen.
Definition: StmtOpenMP.h:675
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1373
Expr * NUB
Update of UpperBound for statically sheduled omp loops for outer loop in combined constructs (e...
Definition: StmtOpenMP.h:614
SmallVector< Expr *, 4 > Updates
Expressions for loop counters update for CodeGen.
Definition: StmtOpenMP.h:673
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1713
void setEnsureUpperBound(Expr *EUB)
Definition: StmtOpenMP.h:500
Expr * getUpperBoundVariable() const
Definition: StmtOpenMP.h:786
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1362
ArrayRef< Expr * > inits() const
Definition: StmtOpenMP.h:927
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:235
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:943
OMPLoopDirective(const T *That, StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum, unsigned NumClauses, unsigned NumSpecialChildren=0)
Build instance of loop directive of class Kind.
Definition: StmtOpenMP.h:425
void setCombinedCond(Expr *CombCond)
Definition: StmtOpenMP.h:568
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2391
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:26
const Expr * getV() const
Definition: StmtOpenMP.h:2208
void setCombinedLowerBoundVariable(Expr *CombLB)
Definition: StmtOpenMP.h:548
void setHasCancel(bool Has)
Set cancel state.
Definition: StmtOpenMP.h:1300
Stmt - This represents one statement.
Definition: Stmt.h:66
void setLastIteration(Expr *LI)
Definition: StmtOpenMP.h:455
Expr * getLowerBoundVariable() const
Definition: StmtOpenMP.h:778
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3027
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2274
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1123
Expr * EUB
EnsureUpperBound – expression UB = min(UB, NumIterations).
Definition: StmtOpenMP.h:645
Expr * DistInc
DistInc - increment expression for distribute loop when found combined with a further loop level (e...
Definition: StmtOpenMP.h:659
This represents &#39;#pragma omp teams distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3601
void setPrevEnsureUpperBound(Expr *PrevEUB)
Definition: StmtOpenMP.h:543
void setUpperBoundVariable(Expr *UB)
Definition: StmtOpenMP.h:486
void setNumIterations(Expr *NI)
Definition: StmtOpenMP.h:521
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:3738
void setNextLowerBound(Expr *NLB)
Definition: StmtOpenMP.h:507
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:443
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1494
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:3806
Expr * getCombinedEnsureUpperBound() const
Definition: StmtOpenMP.h:870
void setIsLastIterVariable(Expr *IL)
Definition: StmtOpenMP.h:472
Expr * PrevLB
PreviousLowerBound - local variable passed to runtime in the enclosing schedule or null if that does ...
Definition: StmtOpenMP.h:652
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1698
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2405
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:2588
const Stmt * getBody() const
Definition: StmtOpenMP.h:900
Expr * getCombinedUpperBoundVariable() const
Definition: StmtOpenMP.h:864
void setUpdates(ArrayRef< Expr *> UL)
Sets the list of update expressions for linear variables.
Expr * getCalcLastIteration() const
Definition: StmtOpenMP.h:746
void setInit(Expr *Init)
Definition: StmtOpenMP.h:467
The expressions built to support OpenMP loops in combined/composite pragmas (e.g. ...
Definition: StmtOpenMP.h:592
bool isXLHSInRHSPart() const
Return true if helper update expression has form &#39;OpaqueValueExpr(x) binop OpaqueValueExpr(expr)&#39; and...
Definition: StmtOpenMP.h:2202
const Expr * getUpdateExpr() const
Definition: StmtOpenMP.h:2196
ArrayRef< Expr * > finals() const
Definition: StmtOpenMP.h:939
Expr * LastIteration
Loop last iteration number.
Definition: StmtOpenMP.h:623
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1770
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:251
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3244
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:149
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2590
Expr * getEnsureUpperBound() const
Definition: StmtOpenMP.h:802
Definition: Format.h:1900
Expr * getInc() const
Definition: StmtOpenMP.h:762
ArrayRef< Expr * > updates()
Definition: StmtOpenMP.h:931
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3326
static unsigned getArraysOffset(OpenMPDirectiveKind Kind)
Offset to the start of children expression arrays.
Definition: StmtOpenMP.h:435
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1814
Defines some OpenMP-specific enums and functions.
OpenMPDirectiveKind getDirectiveKind() const
Definition: StmtOpenMP.h:221
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:1825
This is a common base class for loop directives (&#39;omp simd&#39;, &#39;omp for&#39;, &#39;omp for simd&#39; etc...
Definition: StmtOpenMP.h:313
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1420
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:2704
void setCond(Expr *Cond)
Definition: StmtOpenMP.h:464
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3379
This represents &#39;#pragma omp distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3041
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3530
SourceLocation getLocEnd() const
Returns ending location of directive.
Definition: StmtOpenMP.h:170
ArrayRef< Expr * > finals()
Definition: StmtOpenMP.h:937
Expr * getIsLastIterVariable() const
Definition: StmtOpenMP.h:770
Expr * LB
DistributeLowerBound - used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same construct...
Definition: StmtOpenMP.h:595
Expr * EUB
DistributeEnsureUpperBound - used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same construct...
Definition: StmtOpenMP.h:601
Expr * getX()
Get &#39;x&#39; part of the associated expression/statement.
Definition: StmtOpenMP.h:2186
Expr * getIterationVariable() const
Definition: StmtOpenMP.h:738
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:3105
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3446
static bool classof(const Stmt *S)
Definition: StmtOpenMP.h:223
This represents &#39;#pragma omp cancellation point&#39; directive.
Definition: StmtOpenMP.h:2660
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1971
void setCombinedInit(Expr *CombInit)
Definition: StmtOpenMP.h:563
MutableArrayRef< Expr * > getFinals()
Sets the list of final update expressions for linear variables.
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2603
Expr * getInit() const
Definition: StmtOpenMP.h:758
Expr * CalcLastIteration
Calculation of last iteration.
Definition: StmtOpenMP.h:627
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3460
bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a worksharing directive.
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2509
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:305
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1245
StmtClass
Definition: Stmt.h:68
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1700
void setFinals(ArrayRef< Expr *> FL)
Sets the list of final update expressions for linear variables.
Expr * NUB
Update of UpperBound for statically sheduled &#39;omp for&#39; loops.
Definition: StmtOpenMP.h:649
Expr * Cond
Loop condition.
Definition: StmtOpenMP.h:631
SourceLocation getLocStart() const
Returns starting location of directive kind.
Definition: StmtOpenMP.h:168
Expr * PreCond
Loop pre-condition.
Definition: StmtOpenMP.h:629
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3258
ArrayRef< Expr * > private_counters()
Definition: StmtOpenMP.h:919
The expressions built for the OpenMP loop CodeGen for the whole collapsed loop nest.
Definition: StmtOpenMP.h:619
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1303
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1559
This represents &#39;#pragma omp taskgroup&#39; directive.
Definition: StmtOpenMP.h:1913
Expr * getCombinedLowerBoundVariable() const
Definition: StmtOpenMP.h:858
Expr * IterationVarRef
Loop iteration variable.
Definition: StmtOpenMP.h:621
Expr * Init
Distribute loop iteration variable init used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same...
Definition: StmtOpenMP.h:605
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:2914
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1557
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:3664
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2834
Expr - This represents one expression.
Definition: Expr.h:106
const FunctionProtoType * T
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
static unsigned numLoopChildren(unsigned CollapsedNum, OpenMPDirectiveKind Kind)
Children number.
Definition: StmtOpenMP.h:445
Stmt * IgnoreContainers(bool IgnoreCaptured=false)
Skip no-op (attributed, compound) container stmts and skip captured stmt at the top, if IgnoreCaptured is true.
Definition: Stmt.cpp:132
ArrayRef< OMPClause * > clauses() const
Definition: StmtOpenMP.h:237
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1107
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:3890
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1858
static llvm::iterator_range< specific_clause_iterator< SpecificClause > > getClausesOfKind(ArrayRef< OMPClause *> Clauses)
Definition: StmtOpenMP.h:130
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2968
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3963
bool builtAll()
Check if all the expressions are built (does not check the worksharing ones).
Definition: StmtOpenMP.h:684
unsigned getNumClauses() const
Get number of clauses.
Definition: StmtOpenMP.h:184
Expr * getDistInc() const
Definition: StmtOpenMP.h:846
Expr * getNextLowerBound() const
Definition: StmtOpenMP.h:810
Expr * PrevUB
PreviousUpperBound - local variable passed to runtime in the enclosing schedule or null if that does ...
Definition: StmtOpenMP.h:655
Expr * getPrevEnsureUpperBound() const
Definition: StmtOpenMP.h:852
This represents &#39;#pragma omp for&#39; directive.
Definition: StmtOpenMP.h:1046
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2769
ArrayRef< Expr * > counters() const
Definition: StmtOpenMP.h:915
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:3679
void setAssociatedStmt(Stmt *S)
Set the associated statement for the directive.
Definition: StmtOpenMP.h:85
bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a taskloop directive.
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1109
StmtIterator child_iterator
Child Iterators: All subclasses must implement &#39;children&#39; to permit easy iteration over the substatem...
Definition: Stmt.h:440
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:2718
void setDistInc(Expr *DistInc)
Definition: StmtOpenMP.h:538
Expr * NLB
Update of LowerBound for statically sheduled omp loops for outer loop in combined constructs (e...
Definition: StmtOpenMP.h:611
void setClauses(ArrayRef< OMPClause *> Clauses)
Sets the list of variables for this clause.
Definition: StmtOpenMP.cpp:20
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2450
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2030
This file defines OpenMP AST classes for clauses.
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2217
This represents &#39;#pragma omp flush&#39; directive.
Definition: StmtOpenMP.h:1986
bool hasClausesOfKind() const
Returns true if the current directive has one or more clauses of a specific kind. ...
Definition: StmtOpenMP.h:162
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1574
Expr * NumIterations
Loop number of iterations.
Definition: StmtOpenMP.h:625
void setLocStart(SourceLocation Loc)
Set starting location of directive kind.
Definition: StmtOpenMP.h:176
Expr * ST
Stride - local variable passed to runtime.
Definition: StmtOpenMP.h:643
Expr * getLastIteration() const
Definition: StmtOpenMP.h:742
const SpecificClause * getSingleClause() const
Gets a single clause of the specified kind associated with the current directive iff there is only on...
Definition: StmtOpenMP.h:148
bool isPostfixUpdate() const
Return true if &#39;v&#39; expression must be updated to original value of &#39;x&#39;, false if &#39;v&#39; must be updated ...
Definition: StmtOpenMP.h:2205
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2346
SmallVector< Expr *, 4 > PrivateCounters
PrivateCounters Loop counters.
Definition: StmtOpenMP.h:669
void setLowerBoundVariable(Expr *LB)
Definition: StmtOpenMP.h:479
Expr * getStrideVariable() const
Definition: StmtOpenMP.h:794
ArrayRef< Expr * > updates() const
Definition: StmtOpenMP.h:933
const Stmt * getPreInits() const
Definition: StmtOpenMP.h:766
#define false
Definition: stdbool.h:33
Kind
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2706
This captures a statement into a function.
Definition: Stmt.h:2054
SmallVector< Expr *, 4 > Counters
Counters Loop counters.
Definition: StmtOpenMP.h:667
specific_clause_iterator(ArrayRef< OMPClause *> Clauses)
Definition: StmtOpenMP.h:110
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1318
Encodes a location in the source.
void setPrevLowerBoundVariable(Expr *PrevLB)
Definition: StmtOpenMP.h:528
void setIterationVariable(Expr *IV)
Definition: StmtOpenMP.h:452
MutableArrayRef< Expr * > getInits()
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
void setCombinedNextLowerBound(Expr *CombNLB)
Definition: StmtOpenMP.h:573
OMPClause * getClause(unsigned i) const
Returns specified clause.
Definition: StmtOpenMP.h:190
Expr * getExpr()
Get &#39;expr&#39; part of the associated expression/statement.
Definition: StmtOpenMP.h:2212
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2648
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1478
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1305
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1902
This represents &#39;#pragma omp taskwait&#39; directive.
Definition: StmtOpenMP.h:1869
Expr * PrevEUB
PrevEUB - expression similar to EUB but to be used when loop scheduling uses PrevLB and PrevUB (e...
Definition: StmtOpenMP.h:665
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind)
Checks if the specified directive kind is one of the composite or combined directives that need loop ...
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3725
llvm::iterator_range< specific_clause_iterator< SpecificClause > > getClausesOfKind() const
Definition: StmtOpenMP.h:138
This represents &#39;#pragma omp target&#39; directive.
Definition: StmtOpenMP.h:2230
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1768
Expr * getV()
Get &#39;v&#39; part of the associated expression/statement.
Definition: StmtOpenMP.h:2207
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1480
DistCombinedHelperExprs DistCombinedFields
Expressions used when combining OpenMP loop pragmas.
Definition: StmtOpenMP.h:680
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2041
Expr * LB
LowerBound - local variable passed to runtime.
Definition: StmtOpenMP.h:639
void clear(unsigned Size)
Initialize all the fields to null.
Definition: StmtOpenMP.h:692
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:2982
Expr * Init
Loop iteration variable init.
Definition: StmtOpenMP.h:633
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:325
ArrayRef< Expr * > private_counters() const
Definition: StmtOpenMP.h:921
#define alignof
Definition: stdalign.h:29
void setPrevUpperBoundVariable(Expr *PrevUB)
Definition: StmtOpenMP.h:533
void setCombinedEnsureUpperBound(Expr *CombEUB)
Definition: StmtOpenMP.h:558
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3312
Dataflow Directional Tag Classes.
Expr * getPrevUpperBoundVariable() const
Definition: StmtOpenMP.h:840
SmallVector< Expr *, 4 > Inits
Expressions for loop counters inits for CodeGen.
Definition: StmtOpenMP.h:671
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2901
void setCombinedUpperBoundVariable(Expr *CombUB)
Definition: StmtOpenMP.h:553
Expr * getCond() const
Definition: StmtOpenMP.h:754
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1256
This represents &#39;#pragma omp teams distribute&#39; directive.
Definition: StmtOpenMP.h:3392
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:3873
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:981
StmtClass getStmtClass() const
Definition: Stmt.h:378
const Expr * getReductionRef() const
Returns reference to the task_reduction return variable.
Definition: StmtOpenMP.h:1964
Expr * getUpdateExpr()
Get helper expression of the form &#39;OpaqueValueExpr(x) binop OpaqueValueExpr(expr)&#39; or &#39;OpaqueValueExp...
Definition: StmtOpenMP.h:2193
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3792
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2096
Expr * getCombinedInit() const
Definition: StmtOpenMP.h:876
CapturedStmt * getCapturedStmt(OpenMPDirectiveKind RegionKind) const
Returns the captured statement associated with the component region within the (combined) directive...
Definition: StmtOpenMP.h:205
unsigned getCollapsedNumber() const
Get number of collapsed loops.
Definition: StmtOpenMP.h:736
Expr * getCombinedNextLowerBound() const
Definition: StmtOpenMP.h:888
ArrayRef< Expr * > counters()
Definition: StmtOpenMP.h:913
Expr * getCombinedNextUpperBound() const
Definition: StmtOpenMP.h:894
Iterates over a filtered subrange of clauses applied to a directive.
Definition: StmtOpenMP.h:96
void getOpenMPCaptureRegions(llvm::SmallVectorImpl< OpenMPDirectiveKind > &CaptureRegions, OpenMPDirectiveKind DKind)
Return the captured regions of an OpenMP directive.
bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a distribute directive.
ArrayRef< Expr * > inits()
Definition: StmtOpenMP.h:925
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2332
Expr * Inc
Loop increment.
Definition: StmtOpenMP.h:635
const Expr * getExpr() const
Definition: StmtOpenMP.h:2213
Expr * getNumIterations() const
Definition: StmtOpenMP.h:826
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
Definition: StmtOpenMP.h:193
Expr * getPrevLowerBoundVariable() const
Definition: StmtOpenMP.h:834
Expr * UB
DistributeUpperBound - used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same construct...
Definition: StmtOpenMP.h:598
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:13010
Expr * UB
UpperBound - local variable passed to runtime.
Definition: StmtOpenMP.h:641
Defines the clang::SourceLocation class and associated facilities.
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1628
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2463
void setStrideVariable(Expr *ST)
Definition: StmtOpenMP.h:493
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1032
Expr * getCombinedCond() const
Definition: StmtOpenMP.h:882
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1409
This represents &#39;#pragma omp taskloop simd&#39; directive.
Definition: StmtOpenMP.h:2848
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3107
Expr * getPreCond() const
Definition: StmtOpenMP.h:750
void setPreCond(Expr *PC)
Definition: StmtOpenMP.h:461
OMPExecutableDirective(const T *, StmtClass SC, OpenMPDirectiveKind K, SourceLocation StartLoc, SourceLocation EndLoc, unsigned NumClauses, unsigned NumChildren)
Build instance of directive of class K.
Definition: StmtOpenMP.h:67
This represents &#39;#pragma omp sections&#39; directive.
Definition: StmtOpenMP.h:1188
Expr * Cond
Distribute Loop condition used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same construct...
Definition: StmtOpenMP.h:608
Stmt * PreInits
Init statement for all captured expressions.
Definition: StmtOpenMP.h:677
void setInits(ArrayRef< Expr *> IL)
Sets the list of the initial values for linear variables.
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2288
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:2767
void setNextUpperBound(Expr *NUB)
Definition: StmtOpenMP.h:514
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3516
const Expr * getX() const
Definition: StmtOpenMP.h:2187
void setInc(Expr *Inc)
Definition: StmtOpenMP.h:468
Expr * IL
IsLastIteration - local flag variable passed to runtime.
Definition: StmtOpenMP.h:637
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:1781
This represents &#39;#pragma omp distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3121
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1642
void setCalcLastIteration(Expr *CLI)
Definition: StmtOpenMP.h:458
void setCombinedNextUpperBound(Expr *CombNUB)
Definition: StmtOpenMP.h:578
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1243
void setLocEnd(SourceLocation Loc)
Set ending location of directive.
Definition: StmtOpenMP.h:181
Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
Definition: StmtOpenMP.h:196
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1174
This represents &#39;#pragma omp target parallel for&#39; directive.
Definition: StmtOpenMP.h:2523
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.
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:2783