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