xref: /freebsd/contrib/llvm-project/clang/lib/AST/StmtOpenMP.cpp (revision 6be3386466ab79a84b48429ae66244f21526d3df)
1 //===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the subclesses of Stmt class declared in StmtOpenMP.h
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/ASTContext.h"
14 #include "clang/AST/StmtOpenMP.h"
15 
16 using namespace clang;
17 using namespace llvm::omp;
18 
19 void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) {
20   assert(Clauses.size() == getNumClauses() &&
21          "Number of clauses is not the same as the preallocated buffer");
22   std::copy(Clauses.begin(), Clauses.end(), getClauses().begin());
23 }
24 
25 bool OMPExecutableDirective::isStandaloneDirective() const {
26   // Special case: 'omp target enter data', 'omp target exit data',
27   // 'omp target update' are stand-alone directives, but for implementation
28   // reasons they have empty synthetic structured block, to simplify codegen.
29   if (isa<OMPTargetEnterDataDirective>(this) ||
30       isa<OMPTargetExitDataDirective>(this) ||
31       isa<OMPTargetUpdateDirective>(this))
32     return true;
33   return !hasAssociatedStmt() || !getAssociatedStmt();
34 }
35 
36 const Stmt *OMPExecutableDirective::getStructuredBlock() const {
37   assert(!isStandaloneDirective() &&
38          "Standalone Executable Directives don't have Structured Blocks.");
39   if (auto *LD = dyn_cast<OMPLoopDirective>(this))
40     return LD->getBody();
41   return getInnermostCapturedStmt()->getCapturedStmt();
42 }
43 
44 Stmt *OMPLoopDirective::tryToFindNextInnerLoop(Stmt *CurStmt,
45                                                bool TryImperfectlyNestedLoops) {
46   Stmt *OrigStmt = CurStmt;
47   CurStmt = CurStmt->IgnoreContainers();
48   // Additional work for imperfectly nested loops, introduced in OpenMP 5.0.
49   if (TryImperfectlyNestedLoops) {
50     if (auto *CS = dyn_cast<CompoundStmt>(CurStmt)) {
51       CurStmt = nullptr;
52       SmallVector<CompoundStmt *, 4> Statements(1, CS);
53       SmallVector<CompoundStmt *, 4> NextStatements;
54       while (!Statements.empty()) {
55         CS = Statements.pop_back_val();
56         if (!CS)
57           continue;
58         for (Stmt *S : CS->body()) {
59           if (!S)
60             continue;
61           if (isa<ForStmt>(S) || isa<CXXForRangeStmt>(S)) {
62             // Only single loop construct is allowed.
63             if (CurStmt) {
64               CurStmt = OrigStmt;
65               break;
66             }
67             CurStmt = S;
68             continue;
69           }
70           S = S->IgnoreContainers();
71           if (auto *InnerCS = dyn_cast_or_null<CompoundStmt>(S))
72             NextStatements.push_back(InnerCS);
73         }
74         if (Statements.empty()) {
75           // Found single inner loop or multiple loops - exit.
76           if (CurStmt)
77             break;
78           Statements.swap(NextStatements);
79         }
80       }
81       if (!CurStmt)
82         CurStmt = OrigStmt;
83     }
84   }
85   return CurStmt;
86 }
87 
88 Stmt *OMPLoopDirective::getBody() {
89   // This relies on the loop form is already checked by Sema.
90   Stmt *Body =
91       getInnermostCapturedStmt()->getCapturedStmt()->IgnoreContainers();
92   if (auto *For = dyn_cast<ForStmt>(Body)) {
93     Body = For->getBody();
94   } else {
95     assert(isa<CXXForRangeStmt>(Body) &&
96            "Expected canonical for loop or range-based for loop.");
97     Body = cast<CXXForRangeStmt>(Body)->getBody();
98   }
99   for (unsigned Cnt = 1; Cnt < CollapsedNum; ++Cnt) {
100     Body = tryToFindNextInnerLoop(Body, /*TryImperfectlyNestedLoops=*/true);
101     if (auto *For = dyn_cast<ForStmt>(Body)) {
102       Body = For->getBody();
103     } else {
104       assert(isa<CXXForRangeStmt>(Body) &&
105              "Expected canonical for loop or range-based for loop.");
106       Body = cast<CXXForRangeStmt>(Body)->getBody();
107     }
108   }
109   return Body;
110 }
111 
112 void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) {
113   assert(A.size() == getCollapsedNumber() &&
114          "Number of loop counters is not the same as the collapsed number");
115   std::copy(A.begin(), A.end(), getCounters().begin());
116 }
117 
118 void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {
119   assert(A.size() == getCollapsedNumber() && "Number of loop private counters "
120                                              "is not the same as the collapsed "
121                                              "number");
122   std::copy(A.begin(), A.end(), getPrivateCounters().begin());
123 }
124 
125 void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {
126   assert(A.size() == getCollapsedNumber() &&
127          "Number of counter inits is not the same as the collapsed number");
128   std::copy(A.begin(), A.end(), getInits().begin());
129 }
130 
131 void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
132   assert(A.size() == getCollapsedNumber() &&
133          "Number of counter updates is not the same as the collapsed number");
134   std::copy(A.begin(), A.end(), getUpdates().begin());
135 }
136 
137 void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) {
138   assert(A.size() == getCollapsedNumber() &&
139          "Number of counter finals is not the same as the collapsed number");
140   std::copy(A.begin(), A.end(), getFinals().begin());
141 }
142 
143 void OMPLoopDirective::setDependentCounters(ArrayRef<Expr *> A) {
144   assert(
145       A.size() == getCollapsedNumber() &&
146       "Number of dependent counters is not the same as the collapsed number");
147   llvm::copy(A, getDependentCounters().begin());
148 }
149 
150 void OMPLoopDirective::setDependentInits(ArrayRef<Expr *> A) {
151   assert(A.size() == getCollapsedNumber() &&
152          "Number of dependent inits is not the same as the collapsed number");
153   llvm::copy(A, getDependentInits().begin());
154 }
155 
156 void OMPLoopDirective::setFinalsConditions(ArrayRef<Expr *> A) {
157   assert(A.size() == getCollapsedNumber() &&
158          "Number of finals conditions is not the same as the collapsed number");
159   llvm::copy(A, getFinalsConditions().begin());
160 }
161 
162 OMPParallelDirective *OMPParallelDirective::Create(
163     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
164     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
165     bool HasCancel) {
166   unsigned Size =
167       llvm::alignTo(sizeof(OMPParallelDirective), alignof(OMPClause *));
168   void *Mem =
169       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
170   OMPParallelDirective *Dir =
171       new (Mem) OMPParallelDirective(StartLoc, EndLoc, Clauses.size());
172   Dir->setClauses(Clauses);
173   Dir->setAssociatedStmt(AssociatedStmt);
174   Dir->setTaskReductionRefExpr(TaskRedRef);
175   Dir->setHasCancel(HasCancel);
176   return Dir;
177 }
178 
179 OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,
180                                                         unsigned NumClauses,
181                                                         EmptyShell) {
182   unsigned Size =
183       llvm::alignTo(sizeof(OMPParallelDirective), alignof(OMPClause *));
184   void *Mem =
185       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
186   return new (Mem) OMPParallelDirective(NumClauses);
187 }
188 
189 OMPSimdDirective *
190 OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
191                          SourceLocation EndLoc, unsigned CollapsedNum,
192                          ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
193                          const HelperExprs &Exprs) {
194   unsigned Size = llvm::alignTo(sizeof(OMPSimdDirective), alignof(OMPClause *));
195   void *Mem =
196       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
197                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
198   OMPSimdDirective *Dir = new (Mem)
199       OMPSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
200   Dir->setClauses(Clauses);
201   Dir->setAssociatedStmt(AssociatedStmt);
202   Dir->setIterationVariable(Exprs.IterationVarRef);
203   Dir->setLastIteration(Exprs.LastIteration);
204   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
205   Dir->setPreCond(Exprs.PreCond);
206   Dir->setCond(Exprs.Cond);
207   Dir->setInit(Exprs.Init);
208   Dir->setInc(Exprs.Inc);
209   Dir->setCounters(Exprs.Counters);
210   Dir->setPrivateCounters(Exprs.PrivateCounters);
211   Dir->setInits(Exprs.Inits);
212   Dir->setUpdates(Exprs.Updates);
213   Dir->setFinals(Exprs.Finals);
214   Dir->setDependentCounters(Exprs.DependentCounters);
215   Dir->setDependentInits(Exprs.DependentInits);
216   Dir->setFinalsConditions(Exprs.FinalsConditions);
217   Dir->setPreInits(Exprs.PreInits);
218   return Dir;
219 }
220 
221 OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,
222                                                 unsigned NumClauses,
223                                                 unsigned CollapsedNum,
224                                                 EmptyShell) {
225   unsigned Size = llvm::alignTo(sizeof(OMPSimdDirective), alignof(OMPClause *));
226   void *Mem =
227       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
228                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
229   return new (Mem) OMPSimdDirective(CollapsedNum, NumClauses);
230 }
231 
232 OMPForDirective *OMPForDirective::Create(
233     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
234     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
235     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
236   unsigned Size = llvm::alignTo(sizeof(OMPForDirective), alignof(OMPClause *));
237   void *Mem =
238       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
239                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
240   OMPForDirective *Dir =
241       new (Mem) OMPForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
242   Dir->setClauses(Clauses);
243   Dir->setAssociatedStmt(AssociatedStmt);
244   Dir->setIterationVariable(Exprs.IterationVarRef);
245   Dir->setLastIteration(Exprs.LastIteration);
246   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
247   Dir->setPreCond(Exprs.PreCond);
248   Dir->setCond(Exprs.Cond);
249   Dir->setInit(Exprs.Init);
250   Dir->setInc(Exprs.Inc);
251   Dir->setIsLastIterVariable(Exprs.IL);
252   Dir->setLowerBoundVariable(Exprs.LB);
253   Dir->setUpperBoundVariable(Exprs.UB);
254   Dir->setStrideVariable(Exprs.ST);
255   Dir->setEnsureUpperBound(Exprs.EUB);
256   Dir->setNextLowerBound(Exprs.NLB);
257   Dir->setNextUpperBound(Exprs.NUB);
258   Dir->setNumIterations(Exprs.NumIterations);
259   Dir->setCounters(Exprs.Counters);
260   Dir->setPrivateCounters(Exprs.PrivateCounters);
261   Dir->setInits(Exprs.Inits);
262   Dir->setUpdates(Exprs.Updates);
263   Dir->setFinals(Exprs.Finals);
264   Dir->setDependentCounters(Exprs.DependentCounters);
265   Dir->setDependentInits(Exprs.DependentInits);
266   Dir->setFinalsConditions(Exprs.FinalsConditions);
267   Dir->setPreInits(Exprs.PreInits);
268   Dir->setTaskReductionRefExpr(TaskRedRef);
269   Dir->setHasCancel(HasCancel);
270   return Dir;
271 }
272 
273 OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,
274                                               unsigned NumClauses,
275                                               unsigned CollapsedNum,
276                                               EmptyShell) {
277   unsigned Size = llvm::alignTo(sizeof(OMPForDirective), alignof(OMPClause *));
278   void *Mem =
279       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
280                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
281   return new (Mem) OMPForDirective(CollapsedNum, NumClauses);
282 }
283 
284 OMPForSimdDirective *
285 OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
286                             SourceLocation EndLoc, unsigned CollapsedNum,
287                             ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
288                             const HelperExprs &Exprs) {
289   unsigned Size =
290       llvm::alignTo(sizeof(OMPForSimdDirective), alignof(OMPClause *));
291   void *Mem =
292       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
293                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
294   OMPForSimdDirective *Dir = new (Mem)
295       OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
296   Dir->setClauses(Clauses);
297   Dir->setAssociatedStmt(AssociatedStmt);
298   Dir->setIterationVariable(Exprs.IterationVarRef);
299   Dir->setLastIteration(Exprs.LastIteration);
300   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
301   Dir->setPreCond(Exprs.PreCond);
302   Dir->setCond(Exprs.Cond);
303   Dir->setInit(Exprs.Init);
304   Dir->setInc(Exprs.Inc);
305   Dir->setIsLastIterVariable(Exprs.IL);
306   Dir->setLowerBoundVariable(Exprs.LB);
307   Dir->setUpperBoundVariable(Exprs.UB);
308   Dir->setStrideVariable(Exprs.ST);
309   Dir->setEnsureUpperBound(Exprs.EUB);
310   Dir->setNextLowerBound(Exprs.NLB);
311   Dir->setNextUpperBound(Exprs.NUB);
312   Dir->setNumIterations(Exprs.NumIterations);
313   Dir->setCounters(Exprs.Counters);
314   Dir->setPrivateCounters(Exprs.PrivateCounters);
315   Dir->setInits(Exprs.Inits);
316   Dir->setUpdates(Exprs.Updates);
317   Dir->setFinals(Exprs.Finals);
318   Dir->setDependentCounters(Exprs.DependentCounters);
319   Dir->setDependentInits(Exprs.DependentInits);
320   Dir->setFinalsConditions(Exprs.FinalsConditions);
321   Dir->setPreInits(Exprs.PreInits);
322   return Dir;
323 }
324 
325 OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,
326                                                       unsigned NumClauses,
327                                                       unsigned CollapsedNum,
328                                                       EmptyShell) {
329   unsigned Size =
330       llvm::alignTo(sizeof(OMPForSimdDirective), alignof(OMPClause *));
331   void *Mem =
332       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
333                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
334   return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses);
335 }
336 
337 OMPSectionsDirective *OMPSectionsDirective::Create(
338     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
339     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
340     bool HasCancel) {
341   unsigned Size =
342       llvm::alignTo(sizeof(OMPSectionsDirective), alignof(OMPClause *));
343   void *Mem =
344       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
345   OMPSectionsDirective *Dir =
346       new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size());
347   Dir->setClauses(Clauses);
348   Dir->setAssociatedStmt(AssociatedStmt);
349   Dir->setTaskReductionRefExpr(TaskRedRef);
350   Dir->setHasCancel(HasCancel);
351   return Dir;
352 }
353 
354 OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,
355                                                         unsigned NumClauses,
356                                                         EmptyShell) {
357   unsigned Size =
358       llvm::alignTo(sizeof(OMPSectionsDirective), alignof(OMPClause *));
359   void *Mem =
360       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
361   return new (Mem) OMPSectionsDirective(NumClauses);
362 }
363 
364 OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,
365                                                  SourceLocation StartLoc,
366                                                  SourceLocation EndLoc,
367                                                  Stmt *AssociatedStmt,
368                                                  bool HasCancel) {
369   unsigned Size = llvm::alignTo(sizeof(OMPSectionDirective), alignof(Stmt *));
370   void *Mem = C.Allocate(Size + sizeof(Stmt *));
371   OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc);
372   Dir->setAssociatedStmt(AssociatedStmt);
373   Dir->setHasCancel(HasCancel);
374   return Dir;
375 }
376 
377 OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
378                                                       EmptyShell) {
379   unsigned Size = llvm::alignTo(sizeof(OMPSectionDirective), alignof(Stmt *));
380   void *Mem = C.Allocate(Size + sizeof(Stmt *));
381   return new (Mem) OMPSectionDirective();
382 }
383 
384 OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
385                                                SourceLocation StartLoc,
386                                                SourceLocation EndLoc,
387                                                ArrayRef<OMPClause *> Clauses,
388                                                Stmt *AssociatedStmt) {
389   unsigned Size =
390       llvm::alignTo(sizeof(OMPSingleDirective), alignof(OMPClause *));
391   void *Mem =
392       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
393   OMPSingleDirective *Dir =
394       new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size());
395   Dir->setClauses(Clauses);
396   Dir->setAssociatedStmt(AssociatedStmt);
397   return Dir;
398 }
399 
400 OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
401                                                     unsigned NumClauses,
402                                                     EmptyShell) {
403   unsigned Size =
404       llvm::alignTo(sizeof(OMPSingleDirective), alignof(OMPClause *));
405   void *Mem =
406       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
407   return new (Mem) OMPSingleDirective(NumClauses);
408 }
409 
410 OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,
411                                                SourceLocation StartLoc,
412                                                SourceLocation EndLoc,
413                                                Stmt *AssociatedStmt) {
414   unsigned Size = llvm::alignTo(sizeof(OMPMasterDirective), alignof(Stmt *));
415   void *Mem = C.Allocate(Size + sizeof(Stmt *));
416   OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc);
417   Dir->setAssociatedStmt(AssociatedStmt);
418   return Dir;
419 }
420 
421 OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,
422                                                     EmptyShell) {
423   unsigned Size = llvm::alignTo(sizeof(OMPMasterDirective), alignof(Stmt *));
424   void *Mem = C.Allocate(Size + sizeof(Stmt *));
425   return new (Mem) OMPMasterDirective();
426 }
427 
428 OMPCriticalDirective *OMPCriticalDirective::Create(
429     const ASTContext &C, const DeclarationNameInfo &Name,
430     SourceLocation StartLoc, SourceLocation EndLoc,
431     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
432   unsigned Size =
433       llvm::alignTo(sizeof(OMPCriticalDirective), alignof(OMPClause *));
434   void *Mem =
435       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
436   OMPCriticalDirective *Dir =
437       new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc, Clauses.size());
438   Dir->setClauses(Clauses);
439   Dir->setAssociatedStmt(AssociatedStmt);
440   return Dir;
441 }
442 
443 OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,
444                                                         unsigned NumClauses,
445                                                         EmptyShell) {
446   unsigned Size =
447       llvm::alignTo(sizeof(OMPCriticalDirective), alignof(OMPClause *));
448   void *Mem =
449       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
450   return new (Mem) OMPCriticalDirective(NumClauses);
451 }
452 
453 OMPParallelForDirective *OMPParallelForDirective::Create(
454     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
455     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
456     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
457   unsigned Size =
458       llvm::alignTo(sizeof(OMPParallelForDirective), alignof(OMPClause *));
459   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
460                          sizeof(Stmt *) *
461                              numLoopChildren(CollapsedNum, OMPD_parallel_for));
462   OMPParallelForDirective *Dir = new (Mem)
463       OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
464   Dir->setClauses(Clauses);
465   Dir->setAssociatedStmt(AssociatedStmt);
466   Dir->setIterationVariable(Exprs.IterationVarRef);
467   Dir->setLastIteration(Exprs.LastIteration);
468   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
469   Dir->setPreCond(Exprs.PreCond);
470   Dir->setCond(Exprs.Cond);
471   Dir->setInit(Exprs.Init);
472   Dir->setInc(Exprs.Inc);
473   Dir->setIsLastIterVariable(Exprs.IL);
474   Dir->setLowerBoundVariable(Exprs.LB);
475   Dir->setUpperBoundVariable(Exprs.UB);
476   Dir->setStrideVariable(Exprs.ST);
477   Dir->setEnsureUpperBound(Exprs.EUB);
478   Dir->setNextLowerBound(Exprs.NLB);
479   Dir->setNextUpperBound(Exprs.NUB);
480   Dir->setNumIterations(Exprs.NumIterations);
481   Dir->setCounters(Exprs.Counters);
482   Dir->setPrivateCounters(Exprs.PrivateCounters);
483   Dir->setInits(Exprs.Inits);
484   Dir->setUpdates(Exprs.Updates);
485   Dir->setFinals(Exprs.Finals);
486   Dir->setDependentCounters(Exprs.DependentCounters);
487   Dir->setDependentInits(Exprs.DependentInits);
488   Dir->setFinalsConditions(Exprs.FinalsConditions);
489   Dir->setPreInits(Exprs.PreInits);
490   Dir->setTaskReductionRefExpr(TaskRedRef);
491   Dir->setHasCancel(HasCancel);
492   return Dir;
493 }
494 
495 OMPParallelForDirective *
496 OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
497                                      unsigned CollapsedNum, EmptyShell) {
498   unsigned Size =
499       llvm::alignTo(sizeof(OMPParallelForDirective), alignof(OMPClause *));
500   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
501                          sizeof(Stmt *) *
502                              numLoopChildren(CollapsedNum, OMPD_parallel_for));
503   return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses);
504 }
505 
506 OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create(
507     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
508     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
509     const HelperExprs &Exprs) {
510   unsigned Size =
511       llvm::alignTo(sizeof(OMPParallelForSimdDirective), alignof(OMPClause *));
512   void *Mem = C.Allocate(
513       Size + sizeof(OMPClause *) * Clauses.size() +
514       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
515   OMPParallelForSimdDirective *Dir = new (Mem) OMPParallelForSimdDirective(
516       StartLoc, EndLoc, CollapsedNum, Clauses.size());
517   Dir->setClauses(Clauses);
518   Dir->setAssociatedStmt(AssociatedStmt);
519   Dir->setIterationVariable(Exprs.IterationVarRef);
520   Dir->setLastIteration(Exprs.LastIteration);
521   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
522   Dir->setPreCond(Exprs.PreCond);
523   Dir->setCond(Exprs.Cond);
524   Dir->setInit(Exprs.Init);
525   Dir->setInc(Exprs.Inc);
526   Dir->setIsLastIterVariable(Exprs.IL);
527   Dir->setLowerBoundVariable(Exprs.LB);
528   Dir->setUpperBoundVariable(Exprs.UB);
529   Dir->setStrideVariable(Exprs.ST);
530   Dir->setEnsureUpperBound(Exprs.EUB);
531   Dir->setNextLowerBound(Exprs.NLB);
532   Dir->setNextUpperBound(Exprs.NUB);
533   Dir->setNumIterations(Exprs.NumIterations);
534   Dir->setCounters(Exprs.Counters);
535   Dir->setPrivateCounters(Exprs.PrivateCounters);
536   Dir->setInits(Exprs.Inits);
537   Dir->setUpdates(Exprs.Updates);
538   Dir->setFinals(Exprs.Finals);
539   Dir->setDependentCounters(Exprs.DependentCounters);
540   Dir->setDependentInits(Exprs.DependentInits);
541   Dir->setFinalsConditions(Exprs.FinalsConditions);
542   Dir->setPreInits(Exprs.PreInits);
543   return Dir;
544 }
545 
546 OMPParallelForSimdDirective *
547 OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,
548                                          unsigned NumClauses,
549                                          unsigned CollapsedNum, EmptyShell) {
550   unsigned Size =
551       llvm::alignTo(sizeof(OMPParallelForSimdDirective), alignof(OMPClause *));
552   void *Mem = C.Allocate(
553       Size + sizeof(OMPClause *) * NumClauses +
554       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
555   return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses);
556 }
557 
558 OMPParallelMasterDirective *OMPParallelMasterDirective::Create(
559     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
560     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) {
561   unsigned Size =
562       llvm::alignTo(sizeof(OMPParallelMasterDirective), alignof(OMPClause *));
563   void *Mem =
564       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
565   auto *Dir =
566       new (Mem) OMPParallelMasterDirective(StartLoc, EndLoc, Clauses.size());
567   Dir->setClauses(Clauses);
568   Dir->setAssociatedStmt(AssociatedStmt);
569   Dir->setTaskReductionRefExpr(TaskRedRef);
570   return Dir;
571 }
572 
573 OMPParallelMasterDirective *OMPParallelMasterDirective::CreateEmpty(const ASTContext &C,
574                                                         unsigned NumClauses,
575                                                         EmptyShell) {
576   unsigned Size =
577       llvm::alignTo(sizeof(OMPParallelMasterDirective), alignof(OMPClause *));
578   void *Mem =
579       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
580   return new (Mem) OMPParallelMasterDirective(NumClauses);
581 }
582 
583 OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
584     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
585     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
586     bool HasCancel) {
587   unsigned Size =
588       llvm::alignTo(sizeof(OMPParallelSectionsDirective), alignof(OMPClause *));
589   void *Mem =
590       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
591   OMPParallelSectionsDirective *Dir =
592       new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size());
593   Dir->setClauses(Clauses);
594   Dir->setAssociatedStmt(AssociatedStmt);
595   Dir->setTaskReductionRefExpr(TaskRedRef);
596   Dir->setHasCancel(HasCancel);
597   return Dir;
598 }
599 
600 OMPParallelSectionsDirective *
601 OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
602                                           unsigned NumClauses, EmptyShell) {
603   unsigned Size =
604       llvm::alignTo(sizeof(OMPParallelSectionsDirective), alignof(OMPClause *));
605   void *Mem =
606       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
607   return new (Mem) OMPParallelSectionsDirective(NumClauses);
608 }
609 
610 OMPTaskDirective *
611 OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
612                          SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
613                          Stmt *AssociatedStmt, bool HasCancel) {
614   unsigned Size = llvm::alignTo(sizeof(OMPTaskDirective), alignof(OMPClause *));
615   void *Mem =
616       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
617   OMPTaskDirective *Dir =
618       new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size());
619   Dir->setClauses(Clauses);
620   Dir->setAssociatedStmt(AssociatedStmt);
621   Dir->setHasCancel(HasCancel);
622   return Dir;
623 }
624 
625 OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
626                                                 unsigned NumClauses,
627                                                 EmptyShell) {
628   unsigned Size = llvm::alignTo(sizeof(OMPTaskDirective), alignof(OMPClause *));
629   void *Mem =
630       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
631   return new (Mem) OMPTaskDirective(NumClauses);
632 }
633 
634 OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
635                                                      SourceLocation StartLoc,
636                                                      SourceLocation EndLoc) {
637   void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
638   OMPTaskyieldDirective *Dir =
639       new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc);
640   return Dir;
641 }
642 
643 OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
644                                                           EmptyShell) {
645   void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
646   return new (Mem) OMPTaskyieldDirective();
647 }
648 
649 OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
650                                                  SourceLocation StartLoc,
651                                                  SourceLocation EndLoc) {
652   void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
653   OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc);
654   return Dir;
655 }
656 
657 OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
658                                                       EmptyShell) {
659   void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
660   return new (Mem) OMPBarrierDirective();
661 }
662 
663 OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C,
664                                                    SourceLocation StartLoc,
665                                                    SourceLocation EndLoc) {
666   void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
667   OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc);
668   return Dir;
669 }
670 
671 OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
672                                                         EmptyShell) {
673   void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
674   return new (Mem) OMPTaskwaitDirective();
675 }
676 
677 OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
678     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
679     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {
680   unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective) +
681                                     sizeof(OMPClause *) * Clauses.size(),
682                                 alignof(Stmt *));
683   void *Mem = C.Allocate(Size + sizeof(Stmt *) + sizeof(Expr *));
684   OMPTaskgroupDirective *Dir =
685       new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc, Clauses.size());
686   Dir->setAssociatedStmt(AssociatedStmt);
687   Dir->setReductionRef(ReductionRef);
688   Dir->setClauses(Clauses);
689   return Dir;
690 }
691 
692 OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
693                                                           unsigned NumClauses,
694                                                           EmptyShell) {
695   unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective) +
696                                     sizeof(OMPClause *) * NumClauses,
697                                 alignof(Stmt *));
698   void *Mem = C.Allocate(Size + sizeof(Stmt *) + sizeof(Expr *));
699   return new (Mem) OMPTaskgroupDirective(NumClauses);
700 }
701 
702 OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
703     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
704     OpenMPDirectiveKind CancelRegion) {
705   unsigned Size =
706       llvm::alignTo(sizeof(OMPCancellationPointDirective), alignof(Stmt *));
707   void *Mem = C.Allocate(Size);
708   OMPCancellationPointDirective *Dir =
709       new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc);
710   Dir->setCancelRegion(CancelRegion);
711   return Dir;
712 }
713 
714 OMPCancellationPointDirective *
715 OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
716   unsigned Size =
717       llvm::alignTo(sizeof(OMPCancellationPointDirective), alignof(Stmt *));
718   void *Mem = C.Allocate(Size);
719   return new (Mem) OMPCancellationPointDirective();
720 }
721 
722 OMPCancelDirective *
723 OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
724                            SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
725                            OpenMPDirectiveKind CancelRegion) {
726   unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
727                                     sizeof(OMPClause *) * Clauses.size(),
728                                 alignof(Stmt *));
729   void *Mem = C.Allocate(Size);
730   OMPCancelDirective *Dir =
731       new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size());
732   Dir->setClauses(Clauses);
733   Dir->setCancelRegion(CancelRegion);
734   return Dir;
735 }
736 
737 OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
738                                                     unsigned NumClauses,
739                                                     EmptyShell) {
740   unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
741                                     sizeof(OMPClause *) * NumClauses,
742                                 alignof(Stmt *));
743   void *Mem = C.Allocate(Size);
744   return new (Mem) OMPCancelDirective(NumClauses);
745 }
746 
747 OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
748                                              SourceLocation StartLoc,
749                                              SourceLocation EndLoc,
750                                              ArrayRef<OMPClause *> Clauses) {
751   unsigned Size =
752       llvm::alignTo(sizeof(OMPFlushDirective), alignof(OMPClause *));
753   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
754   OMPFlushDirective *Dir =
755       new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size());
756   Dir->setClauses(Clauses);
757   return Dir;
758 }
759 
760 OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
761                                                   unsigned NumClauses,
762                                                   EmptyShell) {
763   unsigned Size =
764       llvm::alignTo(sizeof(OMPFlushDirective), alignof(OMPClause *));
765   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
766   return new (Mem) OMPFlushDirective(NumClauses);
767 }
768 
769 OMPDepobjDirective *OMPDepobjDirective::Create(const ASTContext &C,
770                                                SourceLocation StartLoc,
771                                                SourceLocation EndLoc,
772                                                ArrayRef<OMPClause *> Clauses) {
773   unsigned Size =
774       llvm::alignTo(sizeof(OMPDepobjDirective), alignof(OMPClause *));
775   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size(),
776                          alignof(OMPDepobjDirective));
777   auto *Dir = new (Mem) OMPDepobjDirective(StartLoc, EndLoc, Clauses.size());
778   Dir->setClauses(Clauses);
779   return Dir;
780 }
781 
782 OMPDepobjDirective *OMPDepobjDirective::CreateEmpty(const ASTContext &C,
783                                                     unsigned NumClauses,
784                                                     EmptyShell) {
785   unsigned Size =
786       llvm::alignTo(sizeof(OMPDepobjDirective), alignof(OMPClause *));
787   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses,
788                          alignof(OMPDepobjDirective));
789   return new (Mem) OMPDepobjDirective(NumClauses);
790 }
791 
792 OMPScanDirective *OMPScanDirective::Create(const ASTContext &C,
793                                            SourceLocation StartLoc,
794                                            SourceLocation EndLoc,
795                                            ArrayRef<OMPClause *> Clauses) {
796   unsigned Size = llvm::alignTo(sizeof(OMPScanDirective), alignof(OMPClause *));
797   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size(),
798                          alignof(OMPScanDirective));
799   auto *Dir = new (Mem) OMPScanDirective(StartLoc, EndLoc, Clauses.size());
800   Dir->setClauses(Clauses);
801   return Dir;
802 }
803 
804 OMPScanDirective *OMPScanDirective::CreateEmpty(const ASTContext &C,
805                                                 unsigned NumClauses,
806                                                 EmptyShell) {
807   unsigned Size = llvm::alignTo(sizeof(OMPScanDirective), alignof(OMPClause *));
808   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses,
809                          alignof(OMPScanDirective));
810   return new (Mem) OMPScanDirective(NumClauses);
811 }
812 
813 OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
814                                                  SourceLocation StartLoc,
815                                                  SourceLocation EndLoc,
816                                                  ArrayRef<OMPClause *> Clauses,
817                                                  Stmt *AssociatedStmt) {
818   unsigned Size =
819       llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
820   void *Mem =
821       C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size());
822   OMPOrderedDirective *Dir =
823       new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size());
824   Dir->setClauses(Clauses);
825   Dir->setAssociatedStmt(AssociatedStmt);
826   return Dir;
827 }
828 
829 OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
830                                                       unsigned NumClauses,
831                                                       EmptyShell) {
832   unsigned Size =
833       llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
834   void *Mem =
835       C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses);
836   return new (Mem) OMPOrderedDirective(NumClauses);
837 }
838 
839 OMPAtomicDirective *OMPAtomicDirective::Create(
840     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
841     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
842     Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) {
843   unsigned Size =
844       llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
845   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
846                          5 * sizeof(Stmt *));
847   OMPAtomicDirective *Dir =
848       new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size());
849   Dir->setClauses(Clauses);
850   Dir->setAssociatedStmt(AssociatedStmt);
851   Dir->setX(X);
852   Dir->setV(V);
853   Dir->setExpr(E);
854   Dir->setUpdateExpr(UE);
855   Dir->IsXLHSInRHSPart = IsXLHSInRHSPart;
856   Dir->IsPostfixUpdate = IsPostfixUpdate;
857   return Dir;
858 }
859 
860 OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
861                                                     unsigned NumClauses,
862                                                     EmptyShell) {
863   unsigned Size =
864       llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
865   void *Mem =
866       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *));
867   return new (Mem) OMPAtomicDirective(NumClauses);
868 }
869 
870 OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
871                                                SourceLocation StartLoc,
872                                                SourceLocation EndLoc,
873                                                ArrayRef<OMPClause *> Clauses,
874                                                Stmt *AssociatedStmt) {
875   unsigned Size =
876       llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
877   void *Mem =
878       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
879   OMPTargetDirective *Dir =
880       new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size());
881   Dir->setClauses(Clauses);
882   Dir->setAssociatedStmt(AssociatedStmt);
883   return Dir;
884 }
885 
886 OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
887                                                     unsigned NumClauses,
888                                                     EmptyShell) {
889   unsigned Size =
890       llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
891   void *Mem =
892       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
893   return new (Mem) OMPTargetDirective(NumClauses);
894 }
895 
896 OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
897     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
898     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
899     bool HasCancel) {
900   unsigned Size =
901       llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
902   void *Mem =
903       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
904   OMPTargetParallelDirective *Dir =
905       new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size());
906   Dir->setClauses(Clauses);
907   Dir->setAssociatedStmt(AssociatedStmt);
908   Dir->setTaskReductionRefExpr(TaskRedRef);
909   Dir->setHasCancel(HasCancel);
910   return Dir;
911 }
912 
913 OMPTargetParallelDirective *
914 OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
915                                         unsigned NumClauses, EmptyShell) {
916   unsigned Size =
917       llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
918   void *Mem =
919       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
920   return new (Mem) OMPTargetParallelDirective(NumClauses);
921 }
922 
923 OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
924     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
925     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
926     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
927   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
928                                 alignof(OMPClause *));
929   void *Mem = C.Allocate(
930       Size + sizeof(OMPClause *) * Clauses.size() +
931       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
932   OMPTargetParallelForDirective *Dir = new (Mem) OMPTargetParallelForDirective(
933       StartLoc, EndLoc, CollapsedNum, Clauses.size());
934   Dir->setClauses(Clauses);
935   Dir->setAssociatedStmt(AssociatedStmt);
936   Dir->setIterationVariable(Exprs.IterationVarRef);
937   Dir->setLastIteration(Exprs.LastIteration);
938   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
939   Dir->setPreCond(Exprs.PreCond);
940   Dir->setCond(Exprs.Cond);
941   Dir->setInit(Exprs.Init);
942   Dir->setInc(Exprs.Inc);
943   Dir->setIsLastIterVariable(Exprs.IL);
944   Dir->setLowerBoundVariable(Exprs.LB);
945   Dir->setUpperBoundVariable(Exprs.UB);
946   Dir->setStrideVariable(Exprs.ST);
947   Dir->setEnsureUpperBound(Exprs.EUB);
948   Dir->setNextLowerBound(Exprs.NLB);
949   Dir->setNextUpperBound(Exprs.NUB);
950   Dir->setNumIterations(Exprs.NumIterations);
951   Dir->setCounters(Exprs.Counters);
952   Dir->setPrivateCounters(Exprs.PrivateCounters);
953   Dir->setInits(Exprs.Inits);
954   Dir->setUpdates(Exprs.Updates);
955   Dir->setFinals(Exprs.Finals);
956   Dir->setDependentCounters(Exprs.DependentCounters);
957   Dir->setDependentInits(Exprs.DependentInits);
958   Dir->setFinalsConditions(Exprs.FinalsConditions);
959   Dir->setPreInits(Exprs.PreInits);
960   Dir->setTaskReductionRefExpr(TaskRedRef);
961   Dir->setHasCancel(HasCancel);
962   return Dir;
963 }
964 
965 OMPTargetParallelForDirective *
966 OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
967                                            unsigned NumClauses,
968                                            unsigned CollapsedNum, EmptyShell) {
969   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
970                                 alignof(OMPClause *));
971   void *Mem = C.Allocate(
972       Size + sizeof(OMPClause *) * NumClauses +
973       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
974   return new (Mem) OMPTargetParallelForDirective(CollapsedNum, NumClauses);
975 }
976 
977 OMPTargetDataDirective *OMPTargetDataDirective::Create(
978     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
979     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
980   void *Mem = C.Allocate(
981       llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
982       sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
983   OMPTargetDataDirective *Dir =
984       new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size());
985   Dir->setClauses(Clauses);
986   Dir->setAssociatedStmt(AssociatedStmt);
987   return Dir;
988 }
989 
990 OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
991                                                             unsigned N,
992                                                             EmptyShell) {
993   void *Mem = C.Allocate(
994       llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
995       sizeof(OMPClause *) * N + sizeof(Stmt *));
996   return new (Mem) OMPTargetDataDirective(N);
997 }
998 
999 OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
1000     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1001     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1002   void *Mem = C.Allocate(
1003       llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
1004       sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1005   OMPTargetEnterDataDirective *Dir =
1006       new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size());
1007   Dir->setClauses(Clauses);
1008   Dir->setAssociatedStmt(AssociatedStmt);
1009   return Dir;
1010 }
1011 
1012 OMPTargetEnterDataDirective *
1013 OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
1014                                          EmptyShell) {
1015   void *Mem = C.Allocate(
1016       llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
1017       sizeof(OMPClause *) * N + sizeof(Stmt *));
1018   return new (Mem) OMPTargetEnterDataDirective(N);
1019 }
1020 
1021 OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create(
1022     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1023     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1024   void *Mem = C.Allocate(
1025       llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
1026       sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1027   OMPTargetExitDataDirective *Dir =
1028       new (Mem) OMPTargetExitDataDirective(StartLoc, EndLoc, Clauses.size());
1029   Dir->setClauses(Clauses);
1030   Dir->setAssociatedStmt(AssociatedStmt);
1031   return Dir;
1032 }
1033 
1034 OMPTargetExitDataDirective *
1035 OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
1036                                         EmptyShell) {
1037   void *Mem = C.Allocate(
1038       llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
1039       sizeof(OMPClause *) * N + sizeof(Stmt *));
1040   return new (Mem) OMPTargetExitDataDirective(N);
1041 }
1042 
1043 OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
1044                                              SourceLocation StartLoc,
1045                                              SourceLocation EndLoc,
1046                                              ArrayRef<OMPClause *> Clauses,
1047                                              Stmt *AssociatedStmt) {
1048   unsigned Size =
1049       llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
1050   void *Mem =
1051       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1052   OMPTeamsDirective *Dir =
1053       new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size());
1054   Dir->setClauses(Clauses);
1055   Dir->setAssociatedStmt(AssociatedStmt);
1056   return Dir;
1057 }
1058 
1059 OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
1060                                                   unsigned NumClauses,
1061                                                   EmptyShell) {
1062   unsigned Size =
1063       llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
1064   void *Mem =
1065       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1066   return new (Mem) OMPTeamsDirective(NumClauses);
1067 }
1068 
1069 OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
1070     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1071     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1072     const HelperExprs &Exprs, bool HasCancel) {
1073   unsigned Size =
1074       llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
1075   void *Mem =
1076       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1077                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
1078   OMPTaskLoopDirective *Dir = new (Mem)
1079       OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1080   Dir->setClauses(Clauses);
1081   Dir->setAssociatedStmt(AssociatedStmt);
1082   Dir->setIterationVariable(Exprs.IterationVarRef);
1083   Dir->setLastIteration(Exprs.LastIteration);
1084   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1085   Dir->setPreCond(Exprs.PreCond);
1086   Dir->setCond(Exprs.Cond);
1087   Dir->setInit(Exprs.Init);
1088   Dir->setInc(Exprs.Inc);
1089   Dir->setIsLastIterVariable(Exprs.IL);
1090   Dir->setLowerBoundVariable(Exprs.LB);
1091   Dir->setUpperBoundVariable(Exprs.UB);
1092   Dir->setStrideVariable(Exprs.ST);
1093   Dir->setEnsureUpperBound(Exprs.EUB);
1094   Dir->setNextLowerBound(Exprs.NLB);
1095   Dir->setNextUpperBound(Exprs.NUB);
1096   Dir->setNumIterations(Exprs.NumIterations);
1097   Dir->setCounters(Exprs.Counters);
1098   Dir->setPrivateCounters(Exprs.PrivateCounters);
1099   Dir->setInits(Exprs.Inits);
1100   Dir->setUpdates(Exprs.Updates);
1101   Dir->setFinals(Exprs.Finals);
1102   Dir->setDependentCounters(Exprs.DependentCounters);
1103   Dir->setDependentInits(Exprs.DependentInits);
1104   Dir->setFinalsConditions(Exprs.FinalsConditions);
1105   Dir->setPreInits(Exprs.PreInits);
1106   Dir->setHasCancel(HasCancel);
1107   return Dir;
1108 }
1109 
1110 OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
1111                                                         unsigned NumClauses,
1112                                                         unsigned CollapsedNum,
1113                                                         EmptyShell) {
1114   unsigned Size =
1115       llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
1116   void *Mem =
1117       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1118                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
1119   return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses);
1120 }
1121 
1122 OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
1123     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1124     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1125     const HelperExprs &Exprs) {
1126   unsigned Size =
1127       llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
1128   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1129                          sizeof(Stmt *) *
1130                              numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
1131   OMPTaskLoopSimdDirective *Dir = new (Mem)
1132       OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1133   Dir->setClauses(Clauses);
1134   Dir->setAssociatedStmt(AssociatedStmt);
1135   Dir->setIterationVariable(Exprs.IterationVarRef);
1136   Dir->setLastIteration(Exprs.LastIteration);
1137   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1138   Dir->setPreCond(Exprs.PreCond);
1139   Dir->setCond(Exprs.Cond);
1140   Dir->setInit(Exprs.Init);
1141   Dir->setInc(Exprs.Inc);
1142   Dir->setIsLastIterVariable(Exprs.IL);
1143   Dir->setLowerBoundVariable(Exprs.LB);
1144   Dir->setUpperBoundVariable(Exprs.UB);
1145   Dir->setStrideVariable(Exprs.ST);
1146   Dir->setEnsureUpperBound(Exprs.EUB);
1147   Dir->setNextLowerBound(Exprs.NLB);
1148   Dir->setNextUpperBound(Exprs.NUB);
1149   Dir->setNumIterations(Exprs.NumIterations);
1150   Dir->setCounters(Exprs.Counters);
1151   Dir->setPrivateCounters(Exprs.PrivateCounters);
1152   Dir->setInits(Exprs.Inits);
1153   Dir->setUpdates(Exprs.Updates);
1154   Dir->setFinals(Exprs.Finals);
1155   Dir->setDependentCounters(Exprs.DependentCounters);
1156   Dir->setDependentInits(Exprs.DependentInits);
1157   Dir->setFinalsConditions(Exprs.FinalsConditions);
1158   Dir->setPreInits(Exprs.PreInits);
1159   return Dir;
1160 }
1161 
1162 OMPTaskLoopSimdDirective *
1163 OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1164                                       unsigned CollapsedNum, EmptyShell) {
1165   unsigned Size =
1166       llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
1167   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1168                          sizeof(Stmt *) *
1169                              numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
1170   return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses);
1171 }
1172 
1173 OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create(
1174     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1175     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1176     const HelperExprs &Exprs, bool HasCancel) {
1177   unsigned Size =
1178       llvm::alignTo(sizeof(OMPMasterTaskLoopDirective), alignof(OMPClause *));
1179   void *Mem = C.Allocate(
1180       Size + sizeof(OMPClause *) * Clauses.size() +
1181       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_master_taskloop));
1182   OMPMasterTaskLoopDirective *Dir = new (Mem) OMPMasterTaskLoopDirective(
1183       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1184   Dir->setClauses(Clauses);
1185   Dir->setAssociatedStmt(AssociatedStmt);
1186   Dir->setIterationVariable(Exprs.IterationVarRef);
1187   Dir->setLastIteration(Exprs.LastIteration);
1188   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1189   Dir->setPreCond(Exprs.PreCond);
1190   Dir->setCond(Exprs.Cond);
1191   Dir->setInit(Exprs.Init);
1192   Dir->setInc(Exprs.Inc);
1193   Dir->setIsLastIterVariable(Exprs.IL);
1194   Dir->setLowerBoundVariable(Exprs.LB);
1195   Dir->setUpperBoundVariable(Exprs.UB);
1196   Dir->setStrideVariable(Exprs.ST);
1197   Dir->setEnsureUpperBound(Exprs.EUB);
1198   Dir->setNextLowerBound(Exprs.NLB);
1199   Dir->setNextUpperBound(Exprs.NUB);
1200   Dir->setNumIterations(Exprs.NumIterations);
1201   Dir->setCounters(Exprs.Counters);
1202   Dir->setPrivateCounters(Exprs.PrivateCounters);
1203   Dir->setInits(Exprs.Inits);
1204   Dir->setUpdates(Exprs.Updates);
1205   Dir->setFinals(Exprs.Finals);
1206   Dir->setDependentCounters(Exprs.DependentCounters);
1207   Dir->setDependentInits(Exprs.DependentInits);
1208   Dir->setFinalsConditions(Exprs.FinalsConditions);
1209   Dir->setPreInits(Exprs.PreInits);
1210   Dir->setHasCancel(HasCancel);
1211   return Dir;
1212 }
1213 
1214 OMPMasterTaskLoopDirective *
1215 OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1216                                         unsigned NumClauses,
1217                                         unsigned CollapsedNum, EmptyShell) {
1218   unsigned Size =
1219       llvm::alignTo(sizeof(OMPMasterTaskLoopDirective), alignof(OMPClause *));
1220   void *Mem = C.Allocate(
1221       Size + sizeof(OMPClause *) * NumClauses +
1222       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_master_taskloop));
1223   return new (Mem) OMPMasterTaskLoopDirective(CollapsedNum, NumClauses);
1224 }
1225 
1226 OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create(
1227     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1228     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1229     const HelperExprs &Exprs) {
1230   unsigned Size = llvm::alignTo(sizeof(OMPMasterTaskLoopSimdDirective),
1231                                 alignof(OMPClause *));
1232   void *Mem =
1233       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1234                  sizeof(Stmt *) *
1235                      numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd));
1236   auto *Dir = new (Mem) OMPMasterTaskLoopSimdDirective(
1237       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1238   Dir->setClauses(Clauses);
1239   Dir->setAssociatedStmt(AssociatedStmt);
1240   Dir->setIterationVariable(Exprs.IterationVarRef);
1241   Dir->setLastIteration(Exprs.LastIteration);
1242   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1243   Dir->setPreCond(Exprs.PreCond);
1244   Dir->setCond(Exprs.Cond);
1245   Dir->setInit(Exprs.Init);
1246   Dir->setInc(Exprs.Inc);
1247   Dir->setIsLastIterVariable(Exprs.IL);
1248   Dir->setLowerBoundVariable(Exprs.LB);
1249   Dir->setUpperBoundVariable(Exprs.UB);
1250   Dir->setStrideVariable(Exprs.ST);
1251   Dir->setEnsureUpperBound(Exprs.EUB);
1252   Dir->setNextLowerBound(Exprs.NLB);
1253   Dir->setNextUpperBound(Exprs.NUB);
1254   Dir->setNumIterations(Exprs.NumIterations);
1255   Dir->setCounters(Exprs.Counters);
1256   Dir->setPrivateCounters(Exprs.PrivateCounters);
1257   Dir->setInits(Exprs.Inits);
1258   Dir->setUpdates(Exprs.Updates);
1259   Dir->setFinals(Exprs.Finals);
1260   Dir->setDependentCounters(Exprs.DependentCounters);
1261   Dir->setDependentInits(Exprs.DependentInits);
1262   Dir->setFinalsConditions(Exprs.FinalsConditions);
1263   Dir->setPreInits(Exprs.PreInits);
1264   return Dir;
1265 }
1266 
1267 OMPMasterTaskLoopSimdDirective *
1268 OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1269                                             unsigned NumClauses,
1270                                             unsigned CollapsedNum, EmptyShell) {
1271   unsigned Size = llvm::alignTo(sizeof(OMPMasterTaskLoopSimdDirective),
1272                                 alignof(OMPClause *));
1273   void *Mem =
1274       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1275                  sizeof(Stmt *) *
1276                      numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd));
1277   return new (Mem) OMPMasterTaskLoopSimdDirective(CollapsedNum, NumClauses);
1278 }
1279 
1280 OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create(
1281     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1282     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1283     const HelperExprs &Exprs, bool HasCancel) {
1284   unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopDirective),
1285                                 alignof(OMPClause *));
1286   void *Mem = C.Allocate(
1287       Size + sizeof(OMPClause *) * Clauses.size() +
1288       sizeof(Stmt *) *
1289           numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop));
1290   auto *Dir = new (Mem) OMPParallelMasterTaskLoopDirective(
1291       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1292   Dir->setClauses(Clauses);
1293   Dir->setAssociatedStmt(AssociatedStmt);
1294   Dir->setIterationVariable(Exprs.IterationVarRef);
1295   Dir->setLastIteration(Exprs.LastIteration);
1296   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1297   Dir->setPreCond(Exprs.PreCond);
1298   Dir->setCond(Exprs.Cond);
1299   Dir->setInit(Exprs.Init);
1300   Dir->setInc(Exprs.Inc);
1301   Dir->setIsLastIterVariable(Exprs.IL);
1302   Dir->setLowerBoundVariable(Exprs.LB);
1303   Dir->setUpperBoundVariable(Exprs.UB);
1304   Dir->setStrideVariable(Exprs.ST);
1305   Dir->setEnsureUpperBound(Exprs.EUB);
1306   Dir->setNextLowerBound(Exprs.NLB);
1307   Dir->setNextUpperBound(Exprs.NUB);
1308   Dir->setNumIterations(Exprs.NumIterations);
1309   Dir->setCounters(Exprs.Counters);
1310   Dir->setPrivateCounters(Exprs.PrivateCounters);
1311   Dir->setInits(Exprs.Inits);
1312   Dir->setUpdates(Exprs.Updates);
1313   Dir->setFinals(Exprs.Finals);
1314   Dir->setDependentCounters(Exprs.DependentCounters);
1315   Dir->setDependentInits(Exprs.DependentInits);
1316   Dir->setFinalsConditions(Exprs.FinalsConditions);
1317   Dir->setPreInits(Exprs.PreInits);
1318   Dir->setHasCancel(HasCancel);
1319   return Dir;
1320 }
1321 
1322 OMPParallelMasterTaskLoopDirective *
1323 OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1324                                                 unsigned NumClauses,
1325                                                 unsigned CollapsedNum,
1326                                                 EmptyShell) {
1327   unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopDirective),
1328                                 alignof(OMPClause *));
1329   void *Mem = C.Allocate(
1330       Size + sizeof(OMPClause *) * NumClauses +
1331       sizeof(Stmt *) *
1332           numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop));
1333   return new (Mem) OMPParallelMasterTaskLoopDirective(CollapsedNum, NumClauses);
1334 }
1335 
1336 OMPParallelMasterTaskLoopSimdDirective *
1337 OMPParallelMasterTaskLoopSimdDirective::Create(
1338     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1339     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1340     const HelperExprs &Exprs) {
1341   unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopSimdDirective),
1342                                 alignof(OMPClause *));
1343   void *Mem = C.Allocate(
1344       Size + sizeof(OMPClause *) * Clauses.size() +
1345       sizeof(Stmt *) *
1346           numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd));
1347   auto *Dir = new (Mem) OMPParallelMasterTaskLoopSimdDirective(
1348       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1349   Dir->setClauses(Clauses);
1350   Dir->setAssociatedStmt(AssociatedStmt);
1351   Dir->setIterationVariable(Exprs.IterationVarRef);
1352   Dir->setLastIteration(Exprs.LastIteration);
1353   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1354   Dir->setPreCond(Exprs.PreCond);
1355   Dir->setCond(Exprs.Cond);
1356   Dir->setInit(Exprs.Init);
1357   Dir->setInc(Exprs.Inc);
1358   Dir->setIsLastIterVariable(Exprs.IL);
1359   Dir->setLowerBoundVariable(Exprs.LB);
1360   Dir->setUpperBoundVariable(Exprs.UB);
1361   Dir->setStrideVariable(Exprs.ST);
1362   Dir->setEnsureUpperBound(Exprs.EUB);
1363   Dir->setNextLowerBound(Exprs.NLB);
1364   Dir->setNextUpperBound(Exprs.NUB);
1365   Dir->setNumIterations(Exprs.NumIterations);
1366   Dir->setCounters(Exprs.Counters);
1367   Dir->setPrivateCounters(Exprs.PrivateCounters);
1368   Dir->setInits(Exprs.Inits);
1369   Dir->setUpdates(Exprs.Updates);
1370   Dir->setFinals(Exprs.Finals);
1371   Dir->setDependentCounters(Exprs.DependentCounters);
1372   Dir->setDependentInits(Exprs.DependentInits);
1373   Dir->setFinalsConditions(Exprs.FinalsConditions);
1374   Dir->setPreInits(Exprs.PreInits);
1375   return Dir;
1376 }
1377 
1378 OMPParallelMasterTaskLoopSimdDirective *
1379 OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1380                                                     unsigned NumClauses,
1381                                                     unsigned CollapsedNum,
1382                                                     EmptyShell) {
1383   unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopSimdDirective),
1384                                 alignof(OMPClause *));
1385   void *Mem = C.Allocate(
1386       Size + sizeof(OMPClause *) * NumClauses +
1387       sizeof(Stmt *) *
1388           numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd));
1389   return new (Mem)
1390       OMPParallelMasterTaskLoopSimdDirective(CollapsedNum, NumClauses);
1391 }
1392 
1393 OMPDistributeDirective *OMPDistributeDirective::Create(
1394     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1395     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1396     const HelperExprs &Exprs) {
1397   unsigned Size =
1398       llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
1399   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1400                          sizeof(Stmt *) *
1401                              numLoopChildren(CollapsedNum, OMPD_distribute));
1402   OMPDistributeDirective *Dir = new (Mem)
1403       OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1404   Dir->setClauses(Clauses);
1405   Dir->setAssociatedStmt(AssociatedStmt);
1406   Dir->setIterationVariable(Exprs.IterationVarRef);
1407   Dir->setLastIteration(Exprs.LastIteration);
1408   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1409   Dir->setPreCond(Exprs.PreCond);
1410   Dir->setCond(Exprs.Cond);
1411   Dir->setInit(Exprs.Init);
1412   Dir->setInc(Exprs.Inc);
1413   Dir->setIsLastIterVariable(Exprs.IL);
1414   Dir->setLowerBoundVariable(Exprs.LB);
1415   Dir->setUpperBoundVariable(Exprs.UB);
1416   Dir->setStrideVariable(Exprs.ST);
1417   Dir->setEnsureUpperBound(Exprs.EUB);
1418   Dir->setNextLowerBound(Exprs.NLB);
1419   Dir->setNextUpperBound(Exprs.NUB);
1420   Dir->setNumIterations(Exprs.NumIterations);
1421   Dir->setCounters(Exprs.Counters);
1422   Dir->setPrivateCounters(Exprs.PrivateCounters);
1423   Dir->setInits(Exprs.Inits);
1424   Dir->setUpdates(Exprs.Updates);
1425   Dir->setFinals(Exprs.Finals);
1426   Dir->setDependentCounters(Exprs.DependentCounters);
1427   Dir->setDependentInits(Exprs.DependentInits);
1428   Dir->setFinalsConditions(Exprs.FinalsConditions);
1429   Dir->setPreInits(Exprs.PreInits);
1430   return Dir;
1431 }
1432 
1433 OMPDistributeDirective *
1434 OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1435                                     unsigned CollapsedNum, EmptyShell) {
1436   unsigned Size =
1437       llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
1438   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1439                          sizeof(Stmt *) *
1440                              numLoopChildren(CollapsedNum, OMPD_distribute));
1441   return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
1442 }
1443 
1444 OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
1445     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1446     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1447   unsigned Size =
1448       llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
1449   void *Mem =
1450       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1451   OMPTargetUpdateDirective *Dir =
1452       new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
1453   Dir->setClauses(Clauses);
1454   Dir->setAssociatedStmt(AssociatedStmt);
1455   return Dir;
1456 }
1457 
1458 OMPTargetUpdateDirective *
1459 OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1460                                       EmptyShell) {
1461   unsigned Size =
1462       llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
1463   void *Mem =
1464       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1465   return new (Mem) OMPTargetUpdateDirective(NumClauses);
1466 }
1467 
1468 OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1469     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1470     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1471     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1472   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
1473                                 alignof(OMPClause *));
1474   void *Mem = C.Allocate(
1475       Size + sizeof(OMPClause *) * Clauses.size() +
1476       sizeof(Stmt *) *
1477           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1478   OMPDistributeParallelForDirective *Dir =
1479       new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc,
1480                                                   CollapsedNum, Clauses.size());
1481   Dir->setClauses(Clauses);
1482   Dir->setAssociatedStmt(AssociatedStmt);
1483   Dir->setIterationVariable(Exprs.IterationVarRef);
1484   Dir->setLastIteration(Exprs.LastIteration);
1485   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1486   Dir->setPreCond(Exprs.PreCond);
1487   Dir->setCond(Exprs.Cond);
1488   Dir->setInit(Exprs.Init);
1489   Dir->setInc(Exprs.Inc);
1490   Dir->setIsLastIterVariable(Exprs.IL);
1491   Dir->setLowerBoundVariable(Exprs.LB);
1492   Dir->setUpperBoundVariable(Exprs.UB);
1493   Dir->setStrideVariable(Exprs.ST);
1494   Dir->setEnsureUpperBound(Exprs.EUB);
1495   Dir->setNextLowerBound(Exprs.NLB);
1496   Dir->setNextUpperBound(Exprs.NUB);
1497   Dir->setNumIterations(Exprs.NumIterations);
1498   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1499   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1500   Dir->setDistInc(Exprs.DistInc);
1501   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1502   Dir->setCounters(Exprs.Counters);
1503   Dir->setPrivateCounters(Exprs.PrivateCounters);
1504   Dir->setInits(Exprs.Inits);
1505   Dir->setUpdates(Exprs.Updates);
1506   Dir->setFinals(Exprs.Finals);
1507   Dir->setDependentCounters(Exprs.DependentCounters);
1508   Dir->setDependentInits(Exprs.DependentInits);
1509   Dir->setFinalsConditions(Exprs.FinalsConditions);
1510   Dir->setPreInits(Exprs.PreInits);
1511   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1512   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1513   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1514   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1515   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1516   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1517   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1518   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1519   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1520   Dir->setTaskReductionRefExpr(TaskRedRef);
1521   Dir->HasCancel = HasCancel;
1522   return Dir;
1523 }
1524 
1525 OMPDistributeParallelForDirective *
1526 OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1527                                                unsigned NumClauses,
1528                                                unsigned CollapsedNum,
1529                                                EmptyShell) {
1530   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
1531                                 alignof(OMPClause *));
1532   void *Mem = C.Allocate(
1533       Size + sizeof(OMPClause *) * NumClauses +
1534       sizeof(Stmt *) *
1535           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1536   return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses);
1537 }
1538 
1539 OMPDistributeParallelForSimdDirective *
1540 OMPDistributeParallelForSimdDirective::Create(
1541     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1542     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1543     const HelperExprs &Exprs) {
1544   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
1545                                 alignof(OMPClause *));
1546   void *Mem = C.Allocate(
1547       Size + sizeof(OMPClause *) * Clauses.size() +
1548       sizeof(Stmt *) *
1549           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1550   OMPDistributeParallelForSimdDirective *Dir = new (Mem)
1551       OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1552                                             Clauses.size());
1553   Dir->setClauses(Clauses);
1554   Dir->setAssociatedStmt(AssociatedStmt);
1555   Dir->setIterationVariable(Exprs.IterationVarRef);
1556   Dir->setLastIteration(Exprs.LastIteration);
1557   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1558   Dir->setPreCond(Exprs.PreCond);
1559   Dir->setCond(Exprs.Cond);
1560   Dir->setInit(Exprs.Init);
1561   Dir->setInc(Exprs.Inc);
1562   Dir->setIsLastIterVariable(Exprs.IL);
1563   Dir->setLowerBoundVariable(Exprs.LB);
1564   Dir->setUpperBoundVariable(Exprs.UB);
1565   Dir->setStrideVariable(Exprs.ST);
1566   Dir->setEnsureUpperBound(Exprs.EUB);
1567   Dir->setNextLowerBound(Exprs.NLB);
1568   Dir->setNextUpperBound(Exprs.NUB);
1569   Dir->setNumIterations(Exprs.NumIterations);
1570   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1571   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1572   Dir->setDistInc(Exprs.DistInc);
1573   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1574   Dir->setCounters(Exprs.Counters);
1575   Dir->setPrivateCounters(Exprs.PrivateCounters);
1576   Dir->setInits(Exprs.Inits);
1577   Dir->setUpdates(Exprs.Updates);
1578   Dir->setFinals(Exprs.Finals);
1579   Dir->setDependentCounters(Exprs.DependentCounters);
1580   Dir->setDependentInits(Exprs.DependentInits);
1581   Dir->setFinalsConditions(Exprs.FinalsConditions);
1582   Dir->setPreInits(Exprs.PreInits);
1583   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1584   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1585   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1586   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1587   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1588   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1589   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1590   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1591   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1592   return Dir;
1593 }
1594 
1595 OMPDistributeParallelForSimdDirective *
1596 OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1597                                                    unsigned NumClauses,
1598                                                    unsigned CollapsedNum,
1599                                                    EmptyShell) {
1600   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
1601                                 alignof(OMPClause *));
1602   void *Mem = C.Allocate(
1603       Size + sizeof(OMPClause *) * NumClauses +
1604       sizeof(Stmt *) *
1605           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1606   return new (Mem)
1607       OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1608 }
1609 
1610 OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1611     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1612     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1613     const HelperExprs &Exprs) {
1614   unsigned Size =
1615       llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
1616   void *Mem = C.Allocate(
1617       Size + sizeof(OMPClause *) * Clauses.size() +
1618       sizeof(Stmt *) *
1619           numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1620   OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective(
1621       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1622   Dir->setClauses(Clauses);
1623   Dir->setAssociatedStmt(AssociatedStmt);
1624   Dir->setIterationVariable(Exprs.IterationVarRef);
1625   Dir->setLastIteration(Exprs.LastIteration);
1626   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1627   Dir->setPreCond(Exprs.PreCond);
1628   Dir->setCond(Exprs.Cond);
1629   Dir->setInit(Exprs.Init);
1630   Dir->setInc(Exprs.Inc);
1631   Dir->setIsLastIterVariable(Exprs.IL);
1632   Dir->setLowerBoundVariable(Exprs.LB);
1633   Dir->setUpperBoundVariable(Exprs.UB);
1634   Dir->setStrideVariable(Exprs.ST);
1635   Dir->setEnsureUpperBound(Exprs.EUB);
1636   Dir->setNextLowerBound(Exprs.NLB);
1637   Dir->setNextUpperBound(Exprs.NUB);
1638   Dir->setNumIterations(Exprs.NumIterations);
1639   Dir->setCounters(Exprs.Counters);
1640   Dir->setPrivateCounters(Exprs.PrivateCounters);
1641   Dir->setInits(Exprs.Inits);
1642   Dir->setUpdates(Exprs.Updates);
1643   Dir->setFinals(Exprs.Finals);
1644   Dir->setDependentCounters(Exprs.DependentCounters);
1645   Dir->setDependentInits(Exprs.DependentInits);
1646   Dir->setFinalsConditions(Exprs.FinalsConditions);
1647   Dir->setPreInits(Exprs.PreInits);
1648   return Dir;
1649 }
1650 
1651 OMPDistributeSimdDirective *
1652 OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1653                                         unsigned NumClauses,
1654                                         unsigned CollapsedNum, EmptyShell) {
1655   unsigned Size =
1656       llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
1657   void *Mem = C.Allocate(
1658       Size + sizeof(OMPClause *) * NumClauses +
1659       sizeof(Stmt *) *
1660           numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1661   return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses);
1662 }
1663 
1664 OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1665     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1666     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1667     const HelperExprs &Exprs) {
1668   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
1669                                 alignof(OMPClause *));
1670   void *Mem = C.Allocate(
1671       Size + sizeof(OMPClause *) * Clauses.size() +
1672       sizeof(Stmt *) *
1673           numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1674   OMPTargetParallelForSimdDirective *Dir =
1675       new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
1676                                                   CollapsedNum, Clauses.size());
1677   Dir->setClauses(Clauses);
1678   Dir->setAssociatedStmt(AssociatedStmt);
1679   Dir->setIterationVariable(Exprs.IterationVarRef);
1680   Dir->setLastIteration(Exprs.LastIteration);
1681   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1682   Dir->setPreCond(Exprs.PreCond);
1683   Dir->setCond(Exprs.Cond);
1684   Dir->setInit(Exprs.Init);
1685   Dir->setInc(Exprs.Inc);
1686   Dir->setIsLastIterVariable(Exprs.IL);
1687   Dir->setLowerBoundVariable(Exprs.LB);
1688   Dir->setUpperBoundVariable(Exprs.UB);
1689   Dir->setStrideVariable(Exprs.ST);
1690   Dir->setEnsureUpperBound(Exprs.EUB);
1691   Dir->setNextLowerBound(Exprs.NLB);
1692   Dir->setNextUpperBound(Exprs.NUB);
1693   Dir->setNumIterations(Exprs.NumIterations);
1694   Dir->setCounters(Exprs.Counters);
1695   Dir->setPrivateCounters(Exprs.PrivateCounters);
1696   Dir->setInits(Exprs.Inits);
1697   Dir->setUpdates(Exprs.Updates);
1698   Dir->setFinals(Exprs.Finals);
1699   Dir->setDependentCounters(Exprs.DependentCounters);
1700   Dir->setDependentInits(Exprs.DependentInits);
1701   Dir->setFinalsConditions(Exprs.FinalsConditions);
1702   Dir->setPreInits(Exprs.PreInits);
1703   return Dir;
1704 }
1705 
1706 OMPTargetParallelForSimdDirective *
1707 OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1708                                                unsigned NumClauses,
1709                                                unsigned CollapsedNum,
1710                                                EmptyShell) {
1711   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
1712                                 alignof(OMPClause *));
1713   void *Mem = C.Allocate(
1714       Size + sizeof(OMPClause *) * NumClauses +
1715       sizeof(Stmt *) *
1716           numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1717   return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
1718 }
1719 
1720 OMPTargetSimdDirective *
1721 OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1722                                SourceLocation EndLoc, unsigned CollapsedNum,
1723                                ArrayRef<OMPClause *> Clauses,
1724                                Stmt *AssociatedStmt, const HelperExprs &Exprs) {
1725   unsigned Size =
1726       llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
1727   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1728                          sizeof(Stmt *) *
1729                              numLoopChildren(CollapsedNum, OMPD_target_simd));
1730   OMPTargetSimdDirective *Dir = new (Mem)
1731       OMPTargetSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1732   Dir->setClauses(Clauses);
1733   Dir->setAssociatedStmt(AssociatedStmt);
1734   Dir->setIterationVariable(Exprs.IterationVarRef);
1735   Dir->setLastIteration(Exprs.LastIteration);
1736   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1737   Dir->setPreCond(Exprs.PreCond);
1738   Dir->setCond(Exprs.Cond);
1739   Dir->setInit(Exprs.Init);
1740   Dir->setInc(Exprs.Inc);
1741   Dir->setCounters(Exprs.Counters);
1742   Dir->setPrivateCounters(Exprs.PrivateCounters);
1743   Dir->setInits(Exprs.Inits);
1744   Dir->setUpdates(Exprs.Updates);
1745   Dir->setFinals(Exprs.Finals);
1746   Dir->setDependentCounters(Exprs.DependentCounters);
1747   Dir->setDependentInits(Exprs.DependentInits);
1748   Dir->setFinalsConditions(Exprs.FinalsConditions);
1749   Dir->setPreInits(Exprs.PreInits);
1750   return Dir;
1751 }
1752 
1753 OMPTargetSimdDirective *
1754 OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1755                                     unsigned CollapsedNum, EmptyShell) {
1756   unsigned Size =
1757       llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
1758   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1759                          sizeof(Stmt *) *
1760                              numLoopChildren(CollapsedNum, OMPD_target_simd));
1761   return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses);
1762 }
1763 
1764 OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
1765     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1766     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1767     const HelperExprs &Exprs) {
1768   unsigned Size =
1769       llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
1770   void *Mem = C.Allocate(
1771       Size + sizeof(OMPClause *) * Clauses.size() +
1772       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1773   OMPTeamsDistributeDirective *Dir = new (Mem) OMPTeamsDistributeDirective(
1774       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1775   Dir->setClauses(Clauses);
1776   Dir->setAssociatedStmt(AssociatedStmt);
1777   Dir->setIterationVariable(Exprs.IterationVarRef);
1778   Dir->setLastIteration(Exprs.LastIteration);
1779   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1780   Dir->setPreCond(Exprs.PreCond);
1781   Dir->setCond(Exprs.Cond);
1782   Dir->setInit(Exprs.Init);
1783   Dir->setInc(Exprs.Inc);
1784   Dir->setIsLastIterVariable(Exprs.IL);
1785   Dir->setLowerBoundVariable(Exprs.LB);
1786   Dir->setUpperBoundVariable(Exprs.UB);
1787   Dir->setStrideVariable(Exprs.ST);
1788   Dir->setEnsureUpperBound(Exprs.EUB);
1789   Dir->setNextLowerBound(Exprs.NLB);
1790   Dir->setNextUpperBound(Exprs.NUB);
1791   Dir->setNumIterations(Exprs.NumIterations);
1792   Dir->setCounters(Exprs.Counters);
1793   Dir->setPrivateCounters(Exprs.PrivateCounters);
1794   Dir->setInits(Exprs.Inits);
1795   Dir->setUpdates(Exprs.Updates);
1796   Dir->setFinals(Exprs.Finals);
1797   Dir->setDependentCounters(Exprs.DependentCounters);
1798   Dir->setDependentInits(Exprs.DependentInits);
1799   Dir->setFinalsConditions(Exprs.FinalsConditions);
1800   Dir->setPreInits(Exprs.PreInits);
1801   return Dir;
1802 }
1803 
1804 OMPTeamsDistributeDirective *
1805 OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1806                                          unsigned NumClauses,
1807                                          unsigned CollapsedNum, EmptyShell) {
1808   unsigned Size =
1809       llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
1810   void *Mem = C.Allocate(
1811       Size + sizeof(OMPClause *) * NumClauses +
1812       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1813   return new (Mem) OMPTeamsDistributeDirective(CollapsedNum, NumClauses);
1814 }
1815 
1816 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
1817     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1818     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1819     const HelperExprs &Exprs) {
1820   unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1821                                 alignof(OMPClause *));
1822   void *Mem =
1823       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1824                  sizeof(Stmt *) *
1825                      numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1826   OMPTeamsDistributeSimdDirective *Dir =
1827       new (Mem) OMPTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
1828                                                 Clauses.size());
1829   Dir->setClauses(Clauses);
1830   Dir->setAssociatedStmt(AssociatedStmt);
1831   Dir->setIterationVariable(Exprs.IterationVarRef);
1832   Dir->setLastIteration(Exprs.LastIteration);
1833   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1834   Dir->setPreCond(Exprs.PreCond);
1835   Dir->setCond(Exprs.Cond);
1836   Dir->setInit(Exprs.Init);
1837   Dir->setInc(Exprs.Inc);
1838   Dir->setIsLastIterVariable(Exprs.IL);
1839   Dir->setLowerBoundVariable(Exprs.LB);
1840   Dir->setUpperBoundVariable(Exprs.UB);
1841   Dir->setStrideVariable(Exprs.ST);
1842   Dir->setEnsureUpperBound(Exprs.EUB);
1843   Dir->setNextLowerBound(Exprs.NLB);
1844   Dir->setNextUpperBound(Exprs.NUB);
1845   Dir->setNumIterations(Exprs.NumIterations);
1846   Dir->setCounters(Exprs.Counters);
1847   Dir->setPrivateCounters(Exprs.PrivateCounters);
1848   Dir->setInits(Exprs.Inits);
1849   Dir->setUpdates(Exprs.Updates);
1850   Dir->setFinals(Exprs.Finals);
1851   Dir->setDependentCounters(Exprs.DependentCounters);
1852   Dir->setDependentInits(Exprs.DependentInits);
1853   Dir->setFinalsConditions(Exprs.FinalsConditions);
1854   Dir->setPreInits(Exprs.PreInits);
1855   return Dir;
1856 }
1857 
1858 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
1859     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1860     EmptyShell) {
1861   unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1862                                 alignof(OMPClause *));
1863   void *Mem =
1864       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1865                  sizeof(Stmt *) *
1866                      numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1867   return new (Mem) OMPTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
1868 }
1869 
1870 OMPTeamsDistributeParallelForSimdDirective *
1871 OMPTeamsDistributeParallelForSimdDirective::Create(
1872     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1873     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1874     const HelperExprs &Exprs) {
1875   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1876                             alignof(OMPClause *));
1877   void *Mem =
1878       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1879                  sizeof(Stmt *) *
1880                      numLoopChildren(CollapsedNum,
1881                                      OMPD_teams_distribute_parallel_for_simd));
1882   OMPTeamsDistributeParallelForSimdDirective *Dir = new (Mem)
1883       OMPTeamsDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1884                                                  Clauses.size());
1885   Dir->setClauses(Clauses);
1886   Dir->setAssociatedStmt(AssociatedStmt);
1887   Dir->setIterationVariable(Exprs.IterationVarRef);
1888   Dir->setLastIteration(Exprs.LastIteration);
1889   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1890   Dir->setPreCond(Exprs.PreCond);
1891   Dir->setCond(Exprs.Cond);
1892   Dir->setInit(Exprs.Init);
1893   Dir->setInc(Exprs.Inc);
1894   Dir->setIsLastIterVariable(Exprs.IL);
1895   Dir->setLowerBoundVariable(Exprs.LB);
1896   Dir->setUpperBoundVariable(Exprs.UB);
1897   Dir->setStrideVariable(Exprs.ST);
1898   Dir->setEnsureUpperBound(Exprs.EUB);
1899   Dir->setNextLowerBound(Exprs.NLB);
1900   Dir->setNextUpperBound(Exprs.NUB);
1901   Dir->setNumIterations(Exprs.NumIterations);
1902   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1903   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1904   Dir->setDistInc(Exprs.DistInc);
1905   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1906   Dir->setCounters(Exprs.Counters);
1907   Dir->setPrivateCounters(Exprs.PrivateCounters);
1908   Dir->setInits(Exprs.Inits);
1909   Dir->setUpdates(Exprs.Updates);
1910   Dir->setFinals(Exprs.Finals);
1911   Dir->setDependentCounters(Exprs.DependentCounters);
1912   Dir->setDependentInits(Exprs.DependentInits);
1913   Dir->setFinalsConditions(Exprs.FinalsConditions);
1914   Dir->setPreInits(Exprs.PreInits);
1915   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1916   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1917   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1918   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1919   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1920   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1921   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1922   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1923   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1924   return Dir;
1925 }
1926 
1927 OMPTeamsDistributeParallelForSimdDirective *
1928 OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1929                                                         unsigned NumClauses,
1930                                                         unsigned CollapsedNum,
1931                                                         EmptyShell) {
1932   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1933                             alignof(OMPClause *));
1934   void *Mem =
1935       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1936                  sizeof(Stmt *) *
1937                      numLoopChildren(CollapsedNum,
1938                                      OMPD_teams_distribute_parallel_for_simd));
1939   return new (Mem)
1940       OMPTeamsDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1941 }
1942 
1943 OMPTeamsDistributeParallelForDirective *
1944 OMPTeamsDistributeParallelForDirective::Create(
1945     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1946     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1947     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1948   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1949                             alignof(OMPClause *));
1950   void *Mem = C.Allocate(
1951       Size + sizeof(OMPClause *) * Clauses.size() +
1952       sizeof(Stmt *) *
1953           numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1954   OMPTeamsDistributeParallelForDirective *Dir = new (Mem)
1955       OMPTeamsDistributeParallelForDirective(StartLoc, EndLoc, CollapsedNum,
1956                                              Clauses.size());
1957   Dir->setClauses(Clauses);
1958   Dir->setAssociatedStmt(AssociatedStmt);
1959   Dir->setIterationVariable(Exprs.IterationVarRef);
1960   Dir->setLastIteration(Exprs.LastIteration);
1961   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1962   Dir->setPreCond(Exprs.PreCond);
1963   Dir->setCond(Exprs.Cond);
1964   Dir->setInit(Exprs.Init);
1965   Dir->setInc(Exprs.Inc);
1966   Dir->setIsLastIterVariable(Exprs.IL);
1967   Dir->setLowerBoundVariable(Exprs.LB);
1968   Dir->setUpperBoundVariable(Exprs.UB);
1969   Dir->setStrideVariable(Exprs.ST);
1970   Dir->setEnsureUpperBound(Exprs.EUB);
1971   Dir->setNextLowerBound(Exprs.NLB);
1972   Dir->setNextUpperBound(Exprs.NUB);
1973   Dir->setNumIterations(Exprs.NumIterations);
1974   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1975   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1976   Dir->setDistInc(Exprs.DistInc);
1977   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1978   Dir->setCounters(Exprs.Counters);
1979   Dir->setPrivateCounters(Exprs.PrivateCounters);
1980   Dir->setInits(Exprs.Inits);
1981   Dir->setUpdates(Exprs.Updates);
1982   Dir->setFinals(Exprs.Finals);
1983   Dir->setDependentCounters(Exprs.DependentCounters);
1984   Dir->setDependentInits(Exprs.DependentInits);
1985   Dir->setFinalsConditions(Exprs.FinalsConditions);
1986   Dir->setPreInits(Exprs.PreInits);
1987   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1988   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1989   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1990   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1991   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1992   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1993   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1994   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1995   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1996   Dir->setTaskReductionRefExpr(TaskRedRef);
1997   Dir->HasCancel = HasCancel;
1998   return Dir;
1999 }
2000 
2001 OMPTeamsDistributeParallelForDirective *
2002 OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
2003                                                     unsigned NumClauses,
2004                                                     unsigned CollapsedNum,
2005                                                     EmptyShell) {
2006   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
2007                             alignof(OMPClause *));
2008   void *Mem = C.Allocate(
2009       Size + sizeof(OMPClause *) * NumClauses +
2010       sizeof(Stmt *) *
2011           numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
2012   return new (Mem)
2013       OMPTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
2014 }
2015 
2016 OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
2017     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2018     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
2019   auto Size =
2020       llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
2021   void *Mem =
2022       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
2023   OMPTargetTeamsDirective *Dir =
2024       new (Mem) OMPTargetTeamsDirective(StartLoc, EndLoc, Clauses.size());
2025   Dir->setClauses(Clauses);
2026   Dir->setAssociatedStmt(AssociatedStmt);
2027   return Dir;
2028 }
2029 
2030 OMPTargetTeamsDirective *
2031 OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
2032                                      EmptyShell) {
2033   auto Size =
2034       llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
2035   void *Mem =
2036       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
2037   return new (Mem) OMPTargetTeamsDirective(NumClauses);
2038 }
2039 
2040 OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
2041     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2042     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2043     const HelperExprs &Exprs) {
2044   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
2045                             alignof(OMPClause *));
2046   void *Mem = C.Allocate(
2047       Size + sizeof(OMPClause *) * Clauses.size() +
2048       sizeof(Stmt *) *
2049           numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
2050   OMPTargetTeamsDistributeDirective *Dir =
2051       new (Mem) OMPTargetTeamsDistributeDirective(StartLoc, EndLoc, CollapsedNum,
2052                                                   Clauses.size());
2053   Dir->setClauses(Clauses);
2054   Dir->setAssociatedStmt(AssociatedStmt);
2055   Dir->setIterationVariable(Exprs.IterationVarRef);
2056   Dir->setLastIteration(Exprs.LastIteration);
2057   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2058   Dir->setPreCond(Exprs.PreCond);
2059   Dir->setCond(Exprs.Cond);
2060   Dir->setInit(Exprs.Init);
2061   Dir->setInc(Exprs.Inc);
2062   Dir->setIsLastIterVariable(Exprs.IL);
2063   Dir->setLowerBoundVariable(Exprs.LB);
2064   Dir->setUpperBoundVariable(Exprs.UB);
2065   Dir->setStrideVariable(Exprs.ST);
2066   Dir->setEnsureUpperBound(Exprs.EUB);
2067   Dir->setNextLowerBound(Exprs.NLB);
2068   Dir->setNextUpperBound(Exprs.NUB);
2069   Dir->setNumIterations(Exprs.NumIterations);
2070   Dir->setCounters(Exprs.Counters);
2071   Dir->setPrivateCounters(Exprs.PrivateCounters);
2072   Dir->setInits(Exprs.Inits);
2073   Dir->setUpdates(Exprs.Updates);
2074   Dir->setFinals(Exprs.Finals);
2075   Dir->setDependentCounters(Exprs.DependentCounters);
2076   Dir->setDependentInits(Exprs.DependentInits);
2077   Dir->setFinalsConditions(Exprs.FinalsConditions);
2078   Dir->setPreInits(Exprs.PreInits);
2079   return Dir;
2080 }
2081 
2082 OMPTargetTeamsDistributeDirective *
2083 OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
2084                                                unsigned NumClauses,
2085                                                unsigned CollapsedNum,
2086                                                EmptyShell) {
2087   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
2088                             alignof(OMPClause *));
2089   void *Mem = C.Allocate(
2090       Size + sizeof(OMPClause *) * NumClauses +
2091       sizeof(Stmt *) *
2092            numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
2093   return new (Mem) OMPTargetTeamsDistributeDirective(CollapsedNum, NumClauses);
2094 }
2095 
2096 OMPTargetTeamsDistributeParallelForDirective *
2097 OMPTargetTeamsDistributeParallelForDirective::Create(
2098     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2099     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2100     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
2101   auto Size =
2102       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
2103                     alignof(OMPClause *));
2104   void *Mem = C.Allocate(
2105       Size + sizeof(OMPClause *) * Clauses.size() +
2106       sizeof(Stmt *) *
2107           numLoopChildren(CollapsedNum,
2108                           OMPD_target_teams_distribute_parallel_for));
2109   OMPTargetTeamsDistributeParallelForDirective *Dir =
2110       new (Mem) OMPTargetTeamsDistributeParallelForDirective(
2111            StartLoc, EndLoc, CollapsedNum, Clauses.size());
2112   Dir->setClauses(Clauses);
2113   Dir->setAssociatedStmt(AssociatedStmt);
2114   Dir->setIterationVariable(Exprs.IterationVarRef);
2115   Dir->setLastIteration(Exprs.LastIteration);
2116   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2117   Dir->setPreCond(Exprs.PreCond);
2118   Dir->setCond(Exprs.Cond);
2119   Dir->setInit(Exprs.Init);
2120   Dir->setInc(Exprs.Inc);
2121   Dir->setIsLastIterVariable(Exprs.IL);
2122   Dir->setLowerBoundVariable(Exprs.LB);
2123   Dir->setUpperBoundVariable(Exprs.UB);
2124   Dir->setStrideVariable(Exprs.ST);
2125   Dir->setEnsureUpperBound(Exprs.EUB);
2126   Dir->setNextLowerBound(Exprs.NLB);
2127   Dir->setNextUpperBound(Exprs.NUB);
2128   Dir->setNumIterations(Exprs.NumIterations);
2129   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
2130   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
2131   Dir->setDistInc(Exprs.DistInc);
2132   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
2133   Dir->setCounters(Exprs.Counters);
2134   Dir->setPrivateCounters(Exprs.PrivateCounters);
2135   Dir->setInits(Exprs.Inits);
2136   Dir->setUpdates(Exprs.Updates);
2137   Dir->setFinals(Exprs.Finals);
2138   Dir->setDependentCounters(Exprs.DependentCounters);
2139   Dir->setDependentInits(Exprs.DependentInits);
2140   Dir->setFinalsConditions(Exprs.FinalsConditions);
2141   Dir->setPreInits(Exprs.PreInits);
2142   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2143   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2144   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2145   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2146   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2147   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2148   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2149   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2150   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2151   Dir->setTaskReductionRefExpr(TaskRedRef);
2152   Dir->HasCancel = HasCancel;
2153   return Dir;
2154 }
2155 
2156 OMPTargetTeamsDistributeParallelForDirective *
2157 OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
2158                                                           unsigned NumClauses,
2159                                                           unsigned CollapsedNum,
2160                                                           EmptyShell) {
2161   auto Size =
2162       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
2163                     alignof(OMPClause *));
2164   void *Mem = C.Allocate(
2165       Size + sizeof(OMPClause *) * NumClauses +
2166       sizeof(Stmt *) *
2167            numLoopChildren(CollapsedNum,
2168                            OMPD_target_teams_distribute_parallel_for));
2169   return new (Mem)
2170       OMPTargetTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
2171 }
2172 
2173 OMPTargetTeamsDistributeParallelForSimdDirective *
2174 OMPTargetTeamsDistributeParallelForSimdDirective::Create(
2175     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2176     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2177     const HelperExprs &Exprs) {
2178   auto Size =
2179       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
2180                     alignof(OMPClause *));
2181   void *Mem = C.Allocate(
2182       Size + sizeof(OMPClause *) * Clauses.size() +
2183       sizeof(Stmt *) *
2184           numLoopChildren(CollapsedNum,
2185                           OMPD_target_teams_distribute_parallel_for_simd));
2186   OMPTargetTeamsDistributeParallelForSimdDirective *Dir =
2187       new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
2188            StartLoc, EndLoc, CollapsedNum, Clauses.size());
2189   Dir->setClauses(Clauses);
2190   Dir->setAssociatedStmt(AssociatedStmt);
2191   Dir->setIterationVariable(Exprs.IterationVarRef);
2192   Dir->setLastIteration(Exprs.LastIteration);
2193   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2194   Dir->setPreCond(Exprs.PreCond);
2195   Dir->setCond(Exprs.Cond);
2196   Dir->setInit(Exprs.Init);
2197   Dir->setInc(Exprs.Inc);
2198   Dir->setIsLastIterVariable(Exprs.IL);
2199   Dir->setLowerBoundVariable(Exprs.LB);
2200   Dir->setUpperBoundVariable(Exprs.UB);
2201   Dir->setStrideVariable(Exprs.ST);
2202   Dir->setEnsureUpperBound(Exprs.EUB);
2203   Dir->setNextLowerBound(Exprs.NLB);
2204   Dir->setNextUpperBound(Exprs.NUB);
2205   Dir->setNumIterations(Exprs.NumIterations);
2206   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
2207   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
2208   Dir->setDistInc(Exprs.DistInc);
2209   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
2210   Dir->setCounters(Exprs.Counters);
2211   Dir->setPrivateCounters(Exprs.PrivateCounters);
2212   Dir->setInits(Exprs.Inits);
2213   Dir->setUpdates(Exprs.Updates);
2214   Dir->setFinals(Exprs.Finals);
2215   Dir->setDependentCounters(Exprs.DependentCounters);
2216   Dir->setDependentInits(Exprs.DependentInits);
2217   Dir->setFinalsConditions(Exprs.FinalsConditions);
2218   Dir->setPreInits(Exprs.PreInits);
2219   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2220   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2221   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2222   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2223   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2224   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2225   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2226   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2227   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2228   return Dir;
2229 }
2230 
2231 OMPTargetTeamsDistributeParallelForSimdDirective *
2232 OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
2233     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
2234     EmptyShell) {
2235   auto Size =
2236       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
2237                     alignof(OMPClause *));
2238   void *Mem = C.Allocate(
2239       Size + sizeof(OMPClause *) * NumClauses +
2240       sizeof(Stmt *) *
2241           numLoopChildren(CollapsedNum,
2242                           OMPD_target_teams_distribute_parallel_for_simd));
2243   return new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
2244       CollapsedNum, NumClauses);
2245 }
2246 
2247 OMPTargetTeamsDistributeSimdDirective *
2248 OMPTargetTeamsDistributeSimdDirective::Create(
2249     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2250     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2251     const HelperExprs &Exprs) {
2252   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
2253                             alignof(OMPClause *));
2254   void *Mem = C.Allocate(
2255       Size + sizeof(OMPClause *) * Clauses.size() +
2256       sizeof(Stmt *) *
2257           numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
2258   OMPTargetTeamsDistributeSimdDirective *Dir = new (Mem)
2259       OMPTargetTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
2260                                             Clauses.size());
2261   Dir->setClauses(Clauses);
2262   Dir->setAssociatedStmt(AssociatedStmt);
2263   Dir->setIterationVariable(Exprs.IterationVarRef);
2264   Dir->setLastIteration(Exprs.LastIteration);
2265   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2266   Dir->setPreCond(Exprs.PreCond);
2267   Dir->setCond(Exprs.Cond);
2268   Dir->setInit(Exprs.Init);
2269   Dir->setInc(Exprs.Inc);
2270   Dir->setIsLastIterVariable(Exprs.IL);
2271   Dir->setLowerBoundVariable(Exprs.LB);
2272   Dir->setUpperBoundVariable(Exprs.UB);
2273   Dir->setStrideVariable(Exprs.ST);
2274   Dir->setEnsureUpperBound(Exprs.EUB);
2275   Dir->setNextLowerBound(Exprs.NLB);
2276   Dir->setNextUpperBound(Exprs.NUB);
2277   Dir->setNumIterations(Exprs.NumIterations);
2278   Dir->setCounters(Exprs.Counters);
2279   Dir->setPrivateCounters(Exprs.PrivateCounters);
2280   Dir->setInits(Exprs.Inits);
2281   Dir->setUpdates(Exprs.Updates);
2282   Dir->setFinals(Exprs.Finals);
2283   Dir->setDependentCounters(Exprs.DependentCounters);
2284   Dir->setDependentInits(Exprs.DependentInits);
2285   Dir->setFinalsConditions(Exprs.FinalsConditions);
2286   Dir->setPreInits(Exprs.PreInits);
2287   return Dir;
2288 }
2289 
2290 OMPTargetTeamsDistributeSimdDirective *
2291 OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
2292                                                    unsigned NumClauses,
2293                                                    unsigned CollapsedNum,
2294                                                    EmptyShell) {
2295   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
2296                             alignof(OMPClause *));
2297   void *Mem = C.Allocate(
2298       Size + sizeof(OMPClause *) * NumClauses +
2299       sizeof(Stmt *) *
2300           numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
2301   return new (Mem)
2302       OMPTargetTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
2303 }
2304