1 //===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the subclesses of Stmt class declared in StmtOpenMP.h
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/StmtOpenMP.h"
15 
16 #include "clang/AST/ASTContext.h"
17 
18 using namespace clang;
19 
20 void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) {
21   assert(Clauses.size() == getNumClauses() &&
22          "Number of clauses is not the same as the preallocated buffer");
23   std::copy(Clauses.begin(), Clauses.end(), getClauses().begin());
24 }
25 
26 void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) {
27   assert(A.size() == getCollapsedNumber() &&
28          "Number of loop counters is not the same as the collapsed number");
29   std::copy(A.begin(), A.end(), getCounters().begin());
30 }
31 
32 void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {
33   assert(A.size() == getCollapsedNumber() && "Number of loop private counters "
34                                              "is not the same as the collapsed "
35                                              "number");
36   std::copy(A.begin(), A.end(), getPrivateCounters().begin());
37 }
38 
39 void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {
40   assert(A.size() == getCollapsedNumber() &&
41          "Number of counter inits is not the same as the collapsed number");
42   std::copy(A.begin(), A.end(), getInits().begin());
43 }
44 
45 void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
46   assert(A.size() == getCollapsedNumber() &&
47          "Number of counter updates is not the same as the collapsed number");
48   std::copy(A.begin(), A.end(), getUpdates().begin());
49 }
50 
51 void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) {
52   assert(A.size() == getCollapsedNumber() &&
53          "Number of counter finals is not the same as the collapsed number");
54   std::copy(A.begin(), A.end(), getFinals().begin());
55 }
56 
57 OMPParallelDirective *OMPParallelDirective::Create(
58     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
59     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
60   unsigned Size =
61       llvm::alignTo(sizeof(OMPParallelDirective), alignof(OMPClause *));
62   void *Mem =
63       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
64   OMPParallelDirective *Dir =
65       new (Mem) OMPParallelDirective(StartLoc, EndLoc, Clauses.size());
66   Dir->setClauses(Clauses);
67   Dir->setAssociatedStmt(AssociatedStmt);
68   Dir->setHasCancel(HasCancel);
69   return Dir;
70 }
71 
72 OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,
73                                                         unsigned NumClauses,
74                                                         EmptyShell) {
75   unsigned Size =
76       llvm::alignTo(sizeof(OMPParallelDirective), alignof(OMPClause *));
77   void *Mem =
78       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
79   return new (Mem) OMPParallelDirective(NumClauses);
80 }
81 
82 OMPSimdDirective *
83 OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
84                          SourceLocation EndLoc, unsigned CollapsedNum,
85                          ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
86                          const HelperExprs &Exprs) {
87   unsigned Size = llvm::alignTo(sizeof(OMPSimdDirective), alignof(OMPClause *));
88   void *Mem =
89       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
90                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
91   OMPSimdDirective *Dir = new (Mem)
92       OMPSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
93   Dir->setClauses(Clauses);
94   Dir->setAssociatedStmt(AssociatedStmt);
95   Dir->setIterationVariable(Exprs.IterationVarRef);
96   Dir->setLastIteration(Exprs.LastIteration);
97   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
98   Dir->setPreCond(Exprs.PreCond);
99   Dir->setCond(Exprs.Cond);
100   Dir->setInit(Exprs.Init);
101   Dir->setInc(Exprs.Inc);
102   Dir->setCounters(Exprs.Counters);
103   Dir->setPrivateCounters(Exprs.PrivateCounters);
104   Dir->setInits(Exprs.Inits);
105   Dir->setUpdates(Exprs.Updates);
106   Dir->setFinals(Exprs.Finals);
107   Dir->setPreInits(Exprs.PreInits);
108   return Dir;
109 }
110 
111 OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,
112                                                 unsigned NumClauses,
113                                                 unsigned CollapsedNum,
114                                                 EmptyShell) {
115   unsigned Size = llvm::alignTo(sizeof(OMPSimdDirective), alignof(OMPClause *));
116   void *Mem =
117       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
118                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
119   return new (Mem) OMPSimdDirective(CollapsedNum, NumClauses);
120 }
121 
122 OMPForDirective *
123 OMPForDirective::Create(const ASTContext &C, SourceLocation StartLoc,
124                         SourceLocation EndLoc, unsigned CollapsedNum,
125                         ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
126                         const HelperExprs &Exprs, bool HasCancel) {
127   unsigned Size = llvm::alignTo(sizeof(OMPForDirective), alignof(OMPClause *));
128   void *Mem =
129       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
130                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
131   OMPForDirective *Dir =
132       new (Mem) OMPForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
133   Dir->setClauses(Clauses);
134   Dir->setAssociatedStmt(AssociatedStmt);
135   Dir->setIterationVariable(Exprs.IterationVarRef);
136   Dir->setLastIteration(Exprs.LastIteration);
137   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
138   Dir->setPreCond(Exprs.PreCond);
139   Dir->setCond(Exprs.Cond);
140   Dir->setInit(Exprs.Init);
141   Dir->setInc(Exprs.Inc);
142   Dir->setIsLastIterVariable(Exprs.IL);
143   Dir->setLowerBoundVariable(Exprs.LB);
144   Dir->setUpperBoundVariable(Exprs.UB);
145   Dir->setStrideVariable(Exprs.ST);
146   Dir->setEnsureUpperBound(Exprs.EUB);
147   Dir->setNextLowerBound(Exprs.NLB);
148   Dir->setNextUpperBound(Exprs.NUB);
149   Dir->setNumIterations(Exprs.NumIterations);
150   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
151   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
152   Dir->setDistInc(Exprs.DistInc);
153   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
154   Dir->setCounters(Exprs.Counters);
155   Dir->setPrivateCounters(Exprs.PrivateCounters);
156   Dir->setInits(Exprs.Inits);
157   Dir->setUpdates(Exprs.Updates);
158   Dir->setFinals(Exprs.Finals);
159   Dir->setPreInits(Exprs.PreInits);
160   Dir->setHasCancel(HasCancel);
161   return Dir;
162 }
163 
164 OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,
165                                               unsigned NumClauses,
166                                               unsigned CollapsedNum,
167                                               EmptyShell) {
168   unsigned Size = llvm::alignTo(sizeof(OMPForDirective), alignof(OMPClause *));
169   void *Mem =
170       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
171                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
172   return new (Mem) OMPForDirective(CollapsedNum, NumClauses);
173 }
174 
175 OMPForSimdDirective *
176 OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
177                             SourceLocation EndLoc, unsigned CollapsedNum,
178                             ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
179                             const HelperExprs &Exprs) {
180   unsigned Size =
181       llvm::alignTo(sizeof(OMPForSimdDirective), alignof(OMPClause *));
182   void *Mem =
183       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
184                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
185   OMPForSimdDirective *Dir = new (Mem)
186       OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
187   Dir->setClauses(Clauses);
188   Dir->setAssociatedStmt(AssociatedStmt);
189   Dir->setIterationVariable(Exprs.IterationVarRef);
190   Dir->setLastIteration(Exprs.LastIteration);
191   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
192   Dir->setPreCond(Exprs.PreCond);
193   Dir->setCond(Exprs.Cond);
194   Dir->setInit(Exprs.Init);
195   Dir->setInc(Exprs.Inc);
196   Dir->setIsLastIterVariable(Exprs.IL);
197   Dir->setLowerBoundVariable(Exprs.LB);
198   Dir->setUpperBoundVariable(Exprs.UB);
199   Dir->setStrideVariable(Exprs.ST);
200   Dir->setEnsureUpperBound(Exprs.EUB);
201   Dir->setNextLowerBound(Exprs.NLB);
202   Dir->setNextUpperBound(Exprs.NUB);
203   Dir->setNumIterations(Exprs.NumIterations);
204   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
205   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
206   Dir->setDistInc(Exprs.DistInc);
207   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
208   Dir->setCounters(Exprs.Counters);
209   Dir->setPrivateCounters(Exprs.PrivateCounters);
210   Dir->setInits(Exprs.Inits);
211   Dir->setUpdates(Exprs.Updates);
212   Dir->setFinals(Exprs.Finals);
213   Dir->setPreInits(Exprs.PreInits);
214   return Dir;
215 }
216 
217 OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,
218                                                       unsigned NumClauses,
219                                                       unsigned CollapsedNum,
220                                                       EmptyShell) {
221   unsigned Size =
222       llvm::alignTo(sizeof(OMPForSimdDirective), alignof(OMPClause *));
223   void *Mem =
224       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
225                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
226   return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses);
227 }
228 
229 OMPSectionsDirective *OMPSectionsDirective::Create(
230     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
231     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
232   unsigned Size =
233       llvm::alignTo(sizeof(OMPSectionsDirective), alignof(OMPClause *));
234   void *Mem =
235       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
236   OMPSectionsDirective *Dir =
237       new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size());
238   Dir->setClauses(Clauses);
239   Dir->setAssociatedStmt(AssociatedStmt);
240   Dir->setHasCancel(HasCancel);
241   return Dir;
242 }
243 
244 OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,
245                                                         unsigned NumClauses,
246                                                         EmptyShell) {
247   unsigned Size =
248       llvm::alignTo(sizeof(OMPSectionsDirective), alignof(OMPClause *));
249   void *Mem =
250       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
251   return new (Mem) OMPSectionsDirective(NumClauses);
252 }
253 
254 OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,
255                                                  SourceLocation StartLoc,
256                                                  SourceLocation EndLoc,
257                                                  Stmt *AssociatedStmt,
258                                                  bool HasCancel) {
259   unsigned Size = llvm::alignTo(sizeof(OMPSectionDirective), alignof(Stmt *));
260   void *Mem = C.Allocate(Size + sizeof(Stmt *));
261   OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc);
262   Dir->setAssociatedStmt(AssociatedStmt);
263   Dir->setHasCancel(HasCancel);
264   return Dir;
265 }
266 
267 OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
268                                                       EmptyShell) {
269   unsigned Size = llvm::alignTo(sizeof(OMPSectionDirective), alignof(Stmt *));
270   void *Mem = C.Allocate(Size + sizeof(Stmt *));
271   return new (Mem) OMPSectionDirective();
272 }
273 
274 OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
275                                                SourceLocation StartLoc,
276                                                SourceLocation EndLoc,
277                                                ArrayRef<OMPClause *> Clauses,
278                                                Stmt *AssociatedStmt) {
279   unsigned Size =
280       llvm::alignTo(sizeof(OMPSingleDirective), alignof(OMPClause *));
281   void *Mem =
282       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
283   OMPSingleDirective *Dir =
284       new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size());
285   Dir->setClauses(Clauses);
286   Dir->setAssociatedStmt(AssociatedStmt);
287   return Dir;
288 }
289 
290 OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
291                                                     unsigned NumClauses,
292                                                     EmptyShell) {
293   unsigned Size =
294       llvm::alignTo(sizeof(OMPSingleDirective), alignof(OMPClause *));
295   void *Mem =
296       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
297   return new (Mem) OMPSingleDirective(NumClauses);
298 }
299 
300 OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,
301                                                SourceLocation StartLoc,
302                                                SourceLocation EndLoc,
303                                                Stmt *AssociatedStmt) {
304   unsigned Size = llvm::alignTo(sizeof(OMPMasterDirective), alignof(Stmt *));
305   void *Mem = C.Allocate(Size + sizeof(Stmt *));
306   OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc);
307   Dir->setAssociatedStmt(AssociatedStmt);
308   return Dir;
309 }
310 
311 OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,
312                                                     EmptyShell) {
313   unsigned Size = llvm::alignTo(sizeof(OMPMasterDirective), alignof(Stmt *));
314   void *Mem = C.Allocate(Size + sizeof(Stmt *));
315   return new (Mem) OMPMasterDirective();
316 }
317 
318 OMPCriticalDirective *OMPCriticalDirective::Create(
319     const ASTContext &C, const DeclarationNameInfo &Name,
320     SourceLocation StartLoc, SourceLocation EndLoc,
321     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
322   unsigned Size =
323       llvm::alignTo(sizeof(OMPCriticalDirective), alignof(OMPClause *));
324   void *Mem =
325       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
326   OMPCriticalDirective *Dir =
327       new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc, Clauses.size());
328   Dir->setClauses(Clauses);
329   Dir->setAssociatedStmt(AssociatedStmt);
330   return Dir;
331 }
332 
333 OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,
334                                                         unsigned NumClauses,
335                                                         EmptyShell) {
336   unsigned Size =
337       llvm::alignTo(sizeof(OMPCriticalDirective), alignof(OMPClause *));
338   void *Mem =
339       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
340   return new (Mem) OMPCriticalDirective(NumClauses);
341 }
342 
343 OMPParallelForDirective *OMPParallelForDirective::Create(
344     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
345     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
346     const HelperExprs &Exprs, bool HasCancel) {
347   unsigned Size =
348       llvm::alignTo(sizeof(OMPParallelForDirective), alignof(OMPClause *));
349   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
350                          sizeof(Stmt *) *
351                              numLoopChildren(CollapsedNum, OMPD_parallel_for));
352   OMPParallelForDirective *Dir = new (Mem)
353       OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
354   Dir->setClauses(Clauses);
355   Dir->setAssociatedStmt(AssociatedStmt);
356   Dir->setIterationVariable(Exprs.IterationVarRef);
357   Dir->setLastIteration(Exprs.LastIteration);
358   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
359   Dir->setPreCond(Exprs.PreCond);
360   Dir->setCond(Exprs.Cond);
361   Dir->setInit(Exprs.Init);
362   Dir->setInc(Exprs.Inc);
363   Dir->setIsLastIterVariable(Exprs.IL);
364   Dir->setLowerBoundVariable(Exprs.LB);
365   Dir->setUpperBoundVariable(Exprs.UB);
366   Dir->setStrideVariable(Exprs.ST);
367   Dir->setEnsureUpperBound(Exprs.EUB);
368   Dir->setNextLowerBound(Exprs.NLB);
369   Dir->setNextUpperBound(Exprs.NUB);
370   Dir->setNumIterations(Exprs.NumIterations);
371   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
372   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
373   Dir->setDistInc(Exprs.DistInc);
374   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
375   Dir->setCounters(Exprs.Counters);
376   Dir->setPrivateCounters(Exprs.PrivateCounters);
377   Dir->setInits(Exprs.Inits);
378   Dir->setUpdates(Exprs.Updates);
379   Dir->setFinals(Exprs.Finals);
380   Dir->setPreInits(Exprs.PreInits);
381   Dir->setHasCancel(HasCancel);
382   return Dir;
383 }
384 
385 OMPParallelForDirective *
386 OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
387                                      unsigned CollapsedNum, EmptyShell) {
388   unsigned Size =
389       llvm::alignTo(sizeof(OMPParallelForDirective), alignof(OMPClause *));
390   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
391                          sizeof(Stmt *) *
392                              numLoopChildren(CollapsedNum, OMPD_parallel_for));
393   return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses);
394 }
395 
396 OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create(
397     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
398     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
399     const HelperExprs &Exprs) {
400   unsigned Size =
401       llvm::alignTo(sizeof(OMPParallelForSimdDirective), alignof(OMPClause *));
402   void *Mem = C.Allocate(
403       Size + sizeof(OMPClause *) * Clauses.size() +
404       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
405   OMPParallelForSimdDirective *Dir = new (Mem) OMPParallelForSimdDirective(
406       StartLoc, EndLoc, CollapsedNum, Clauses.size());
407   Dir->setClauses(Clauses);
408   Dir->setAssociatedStmt(AssociatedStmt);
409   Dir->setIterationVariable(Exprs.IterationVarRef);
410   Dir->setLastIteration(Exprs.LastIteration);
411   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
412   Dir->setPreCond(Exprs.PreCond);
413   Dir->setCond(Exprs.Cond);
414   Dir->setInit(Exprs.Init);
415   Dir->setInc(Exprs.Inc);
416   Dir->setIsLastIterVariable(Exprs.IL);
417   Dir->setLowerBoundVariable(Exprs.LB);
418   Dir->setUpperBoundVariable(Exprs.UB);
419   Dir->setStrideVariable(Exprs.ST);
420   Dir->setEnsureUpperBound(Exprs.EUB);
421   Dir->setNextLowerBound(Exprs.NLB);
422   Dir->setNextUpperBound(Exprs.NUB);
423   Dir->setNumIterations(Exprs.NumIterations);
424   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
425   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
426   Dir->setDistInc(Exprs.DistInc);
427   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
428   Dir->setCounters(Exprs.Counters);
429   Dir->setPrivateCounters(Exprs.PrivateCounters);
430   Dir->setInits(Exprs.Inits);
431   Dir->setUpdates(Exprs.Updates);
432   Dir->setFinals(Exprs.Finals);
433   Dir->setPreInits(Exprs.PreInits);
434   return Dir;
435 }
436 
437 OMPParallelForSimdDirective *
438 OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,
439                                          unsigned NumClauses,
440                                          unsigned CollapsedNum, EmptyShell) {
441   unsigned Size =
442       llvm::alignTo(sizeof(OMPParallelForSimdDirective), alignof(OMPClause *));
443   void *Mem = C.Allocate(
444       Size + sizeof(OMPClause *) * NumClauses +
445       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
446   return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses);
447 }
448 
449 OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
450     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
451     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
452   unsigned Size =
453       llvm::alignTo(sizeof(OMPParallelSectionsDirective), alignof(OMPClause *));
454   void *Mem =
455       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
456   OMPParallelSectionsDirective *Dir =
457       new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size());
458   Dir->setClauses(Clauses);
459   Dir->setAssociatedStmt(AssociatedStmt);
460   Dir->setHasCancel(HasCancel);
461   return Dir;
462 }
463 
464 OMPParallelSectionsDirective *
465 OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
466                                           unsigned NumClauses, EmptyShell) {
467   unsigned Size =
468       llvm::alignTo(sizeof(OMPParallelSectionsDirective), alignof(OMPClause *));
469   void *Mem =
470       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
471   return new (Mem) OMPParallelSectionsDirective(NumClauses);
472 }
473 
474 OMPTaskDirective *
475 OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
476                          SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
477                          Stmt *AssociatedStmt, bool HasCancel) {
478   unsigned Size = llvm::alignTo(sizeof(OMPTaskDirective), alignof(OMPClause *));
479   void *Mem =
480       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
481   OMPTaskDirective *Dir =
482       new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size());
483   Dir->setClauses(Clauses);
484   Dir->setAssociatedStmt(AssociatedStmt);
485   Dir->setHasCancel(HasCancel);
486   return Dir;
487 }
488 
489 OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
490                                                 unsigned NumClauses,
491                                                 EmptyShell) {
492   unsigned Size = llvm::alignTo(sizeof(OMPTaskDirective), alignof(OMPClause *));
493   void *Mem =
494       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
495   return new (Mem) OMPTaskDirective(NumClauses);
496 }
497 
498 OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
499                                                      SourceLocation StartLoc,
500                                                      SourceLocation EndLoc) {
501   void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
502   OMPTaskyieldDirective *Dir =
503       new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc);
504   return Dir;
505 }
506 
507 OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
508                                                           EmptyShell) {
509   void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
510   return new (Mem) OMPTaskyieldDirective();
511 }
512 
513 OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
514                                                  SourceLocation StartLoc,
515                                                  SourceLocation EndLoc) {
516   void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
517   OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc);
518   return Dir;
519 }
520 
521 OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
522                                                       EmptyShell) {
523   void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
524   return new (Mem) OMPBarrierDirective();
525 }
526 
527 OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C,
528                                                    SourceLocation StartLoc,
529                                                    SourceLocation EndLoc) {
530   void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
531   OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc);
532   return Dir;
533 }
534 
535 OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
536                                                         EmptyShell) {
537   void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
538   return new (Mem) OMPTaskwaitDirective();
539 }
540 
541 OMPTaskgroupDirective *OMPTaskgroupDirective::Create(const ASTContext &C,
542                                                      SourceLocation StartLoc,
543                                                      SourceLocation EndLoc,
544                                                      Stmt *AssociatedStmt) {
545   unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective), alignof(Stmt *));
546   void *Mem = C.Allocate(Size + sizeof(Stmt *));
547   OMPTaskgroupDirective *Dir =
548       new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc);
549   Dir->setAssociatedStmt(AssociatedStmt);
550   return Dir;
551 }
552 
553 OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
554                                                           EmptyShell) {
555   unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective), alignof(Stmt *));
556   void *Mem = C.Allocate(Size + sizeof(Stmt *));
557   return new (Mem) OMPTaskgroupDirective();
558 }
559 
560 OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
561     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
562     OpenMPDirectiveKind CancelRegion) {
563   unsigned Size =
564       llvm::alignTo(sizeof(OMPCancellationPointDirective), alignof(Stmt *));
565   void *Mem = C.Allocate(Size);
566   OMPCancellationPointDirective *Dir =
567       new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc);
568   Dir->setCancelRegion(CancelRegion);
569   return Dir;
570 }
571 
572 OMPCancellationPointDirective *
573 OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
574   unsigned Size =
575       llvm::alignTo(sizeof(OMPCancellationPointDirective), alignof(Stmt *));
576   void *Mem = C.Allocate(Size);
577   return new (Mem) OMPCancellationPointDirective();
578 }
579 
580 OMPCancelDirective *
581 OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
582                            SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
583                            OpenMPDirectiveKind CancelRegion) {
584   unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
585                                     sizeof(OMPClause *) * Clauses.size(),
586                                 alignof(Stmt *));
587   void *Mem = C.Allocate(Size);
588   OMPCancelDirective *Dir =
589       new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size());
590   Dir->setClauses(Clauses);
591   Dir->setCancelRegion(CancelRegion);
592   return Dir;
593 }
594 
595 OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
596                                                     unsigned NumClauses,
597                                                     EmptyShell) {
598   unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
599                                     sizeof(OMPClause *) * NumClauses,
600                                 alignof(Stmt *));
601   void *Mem = C.Allocate(Size);
602   return new (Mem) OMPCancelDirective(NumClauses);
603 }
604 
605 OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
606                                              SourceLocation StartLoc,
607                                              SourceLocation EndLoc,
608                                              ArrayRef<OMPClause *> Clauses) {
609   unsigned Size =
610       llvm::alignTo(sizeof(OMPFlushDirective), alignof(OMPClause *));
611   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
612   OMPFlushDirective *Dir =
613       new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size());
614   Dir->setClauses(Clauses);
615   return Dir;
616 }
617 
618 OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
619                                                   unsigned NumClauses,
620                                                   EmptyShell) {
621   unsigned Size =
622       llvm::alignTo(sizeof(OMPFlushDirective), alignof(OMPClause *));
623   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
624   return new (Mem) OMPFlushDirective(NumClauses);
625 }
626 
627 OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
628                                                  SourceLocation StartLoc,
629                                                  SourceLocation EndLoc,
630                                                  ArrayRef<OMPClause *> Clauses,
631                                                  Stmt *AssociatedStmt) {
632   unsigned Size =
633       llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
634   void *Mem =
635       C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size());
636   OMPOrderedDirective *Dir =
637       new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size());
638   Dir->setClauses(Clauses);
639   Dir->setAssociatedStmt(AssociatedStmt);
640   return Dir;
641 }
642 
643 OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
644                                                       unsigned NumClauses,
645                                                       EmptyShell) {
646   unsigned Size =
647       llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
648   void *Mem =
649       C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses);
650   return new (Mem) OMPOrderedDirective(NumClauses);
651 }
652 
653 OMPAtomicDirective *OMPAtomicDirective::Create(
654     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
655     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
656     Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) {
657   unsigned Size =
658       llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
659   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
660                          5 * sizeof(Stmt *));
661   OMPAtomicDirective *Dir =
662       new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size());
663   Dir->setClauses(Clauses);
664   Dir->setAssociatedStmt(AssociatedStmt);
665   Dir->setX(X);
666   Dir->setV(V);
667   Dir->setExpr(E);
668   Dir->setUpdateExpr(UE);
669   Dir->IsXLHSInRHSPart = IsXLHSInRHSPart;
670   Dir->IsPostfixUpdate = IsPostfixUpdate;
671   return Dir;
672 }
673 
674 OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
675                                                     unsigned NumClauses,
676                                                     EmptyShell) {
677   unsigned Size =
678       llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
679   void *Mem =
680       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *));
681   return new (Mem) OMPAtomicDirective(NumClauses);
682 }
683 
684 OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
685                                                SourceLocation StartLoc,
686                                                SourceLocation EndLoc,
687                                                ArrayRef<OMPClause *> Clauses,
688                                                Stmt *AssociatedStmt) {
689   unsigned Size =
690       llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
691   void *Mem =
692       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
693   OMPTargetDirective *Dir =
694       new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size());
695   Dir->setClauses(Clauses);
696   Dir->setAssociatedStmt(AssociatedStmt);
697   return Dir;
698 }
699 
700 OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
701                                                     unsigned NumClauses,
702                                                     EmptyShell) {
703   unsigned Size =
704       llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
705   void *Mem =
706       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
707   return new (Mem) OMPTargetDirective(NumClauses);
708 }
709 
710 OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
711     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
712     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
713   unsigned Size =
714       llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
715   void *Mem =
716       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
717   OMPTargetParallelDirective *Dir =
718       new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size());
719   Dir->setClauses(Clauses);
720   Dir->setAssociatedStmt(AssociatedStmt);
721   return Dir;
722 }
723 
724 OMPTargetParallelDirective *
725 OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
726                                         unsigned NumClauses, EmptyShell) {
727   unsigned Size =
728       llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
729   void *Mem =
730       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
731   return new (Mem) OMPTargetParallelDirective(NumClauses);
732 }
733 
734 OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
735     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
736     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
737     const HelperExprs &Exprs, bool HasCancel) {
738   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
739                                 alignof(OMPClause *));
740   void *Mem = C.Allocate(
741       Size + sizeof(OMPClause *) * Clauses.size() +
742       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
743   OMPTargetParallelForDirective *Dir = new (Mem) OMPTargetParallelForDirective(
744       StartLoc, EndLoc, CollapsedNum, Clauses.size());
745   Dir->setClauses(Clauses);
746   Dir->setAssociatedStmt(AssociatedStmt);
747   Dir->setIterationVariable(Exprs.IterationVarRef);
748   Dir->setLastIteration(Exprs.LastIteration);
749   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
750   Dir->setPreCond(Exprs.PreCond);
751   Dir->setCond(Exprs.Cond);
752   Dir->setInit(Exprs.Init);
753   Dir->setInc(Exprs.Inc);
754   Dir->setIsLastIterVariable(Exprs.IL);
755   Dir->setLowerBoundVariable(Exprs.LB);
756   Dir->setUpperBoundVariable(Exprs.UB);
757   Dir->setStrideVariable(Exprs.ST);
758   Dir->setEnsureUpperBound(Exprs.EUB);
759   Dir->setNextLowerBound(Exprs.NLB);
760   Dir->setNextUpperBound(Exprs.NUB);
761   Dir->setNumIterations(Exprs.NumIterations);
762   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
763   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
764   Dir->setDistInc(Exprs.DistInc);
765   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
766   Dir->setCounters(Exprs.Counters);
767   Dir->setPrivateCounters(Exprs.PrivateCounters);
768   Dir->setInits(Exprs.Inits);
769   Dir->setUpdates(Exprs.Updates);
770   Dir->setFinals(Exprs.Finals);
771   Dir->setPreInits(Exprs.PreInits);
772   Dir->setHasCancel(HasCancel);
773   return Dir;
774 }
775 
776 OMPTargetParallelForDirective *
777 OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
778                                            unsigned NumClauses,
779                                            unsigned CollapsedNum, EmptyShell) {
780   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
781                                 alignof(OMPClause *));
782   void *Mem = C.Allocate(
783       Size + sizeof(OMPClause *) * NumClauses +
784       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
785   return new (Mem) OMPTargetParallelForDirective(CollapsedNum, NumClauses);
786 }
787 
788 OMPTargetDataDirective *OMPTargetDataDirective::Create(
789     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
790     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
791   void *Mem = C.Allocate(
792       llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
793       sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
794   OMPTargetDataDirective *Dir =
795       new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size());
796   Dir->setClauses(Clauses);
797   Dir->setAssociatedStmt(AssociatedStmt);
798   return Dir;
799 }
800 
801 OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
802                                                             unsigned N,
803                                                             EmptyShell) {
804   void *Mem = C.Allocate(
805       llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
806       sizeof(OMPClause *) * N + sizeof(Stmt *));
807   return new (Mem) OMPTargetDataDirective(N);
808 }
809 
810 OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
811     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
812     ArrayRef<OMPClause *> Clauses) {
813   void *Mem = C.Allocate(
814       llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
815       sizeof(OMPClause *) * Clauses.size());
816   OMPTargetEnterDataDirective *Dir =
817       new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size());
818   Dir->setClauses(Clauses);
819   return Dir;
820 }
821 
822 OMPTargetEnterDataDirective *
823 OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
824                                          EmptyShell) {
825   void *Mem = C.Allocate(
826       llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
827       sizeof(OMPClause *) * N);
828   return new (Mem) OMPTargetEnterDataDirective(N);
829 }
830 
831 OMPTargetExitDataDirective *
832 OMPTargetExitDataDirective::Create(const ASTContext &C, SourceLocation StartLoc,
833                                    SourceLocation EndLoc,
834                                    ArrayRef<OMPClause *> Clauses) {
835   void *Mem = C.Allocate(
836       llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
837       sizeof(OMPClause *) * Clauses.size());
838   OMPTargetExitDataDirective *Dir =
839       new (Mem) OMPTargetExitDataDirective(StartLoc, EndLoc, Clauses.size());
840   Dir->setClauses(Clauses);
841   return Dir;
842 }
843 
844 OMPTargetExitDataDirective *
845 OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
846                                         EmptyShell) {
847   void *Mem = C.Allocate(
848       llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
849       sizeof(OMPClause *) * N);
850   return new (Mem) OMPTargetExitDataDirective(N);
851 }
852 
853 OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
854                                              SourceLocation StartLoc,
855                                              SourceLocation EndLoc,
856                                              ArrayRef<OMPClause *> Clauses,
857                                              Stmt *AssociatedStmt) {
858   unsigned Size =
859       llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
860   void *Mem =
861       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
862   OMPTeamsDirective *Dir =
863       new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size());
864   Dir->setClauses(Clauses);
865   Dir->setAssociatedStmt(AssociatedStmt);
866   return Dir;
867 }
868 
869 OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
870                                                   unsigned NumClauses,
871                                                   EmptyShell) {
872   unsigned Size =
873       llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
874   void *Mem =
875       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
876   return new (Mem) OMPTeamsDirective(NumClauses);
877 }
878 
879 OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
880     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
881     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
882     const HelperExprs &Exprs) {
883   unsigned Size =
884       llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
885   void *Mem =
886       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
887                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
888   OMPTaskLoopDirective *Dir = new (Mem)
889       OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
890   Dir->setClauses(Clauses);
891   Dir->setAssociatedStmt(AssociatedStmt);
892   Dir->setIterationVariable(Exprs.IterationVarRef);
893   Dir->setLastIteration(Exprs.LastIteration);
894   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
895   Dir->setPreCond(Exprs.PreCond);
896   Dir->setCond(Exprs.Cond);
897   Dir->setInit(Exprs.Init);
898   Dir->setInc(Exprs.Inc);
899   Dir->setIsLastIterVariable(Exprs.IL);
900   Dir->setLowerBoundVariable(Exprs.LB);
901   Dir->setUpperBoundVariable(Exprs.UB);
902   Dir->setStrideVariable(Exprs.ST);
903   Dir->setEnsureUpperBound(Exprs.EUB);
904   Dir->setNextLowerBound(Exprs.NLB);
905   Dir->setNextUpperBound(Exprs.NUB);
906   Dir->setNumIterations(Exprs.NumIterations);
907   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
908   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
909   Dir->setDistInc(Exprs.DistInc);
910   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
911   Dir->setCounters(Exprs.Counters);
912   Dir->setPrivateCounters(Exprs.PrivateCounters);
913   Dir->setInits(Exprs.Inits);
914   Dir->setUpdates(Exprs.Updates);
915   Dir->setFinals(Exprs.Finals);
916   Dir->setPreInits(Exprs.PreInits);
917   return Dir;
918 }
919 
920 OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
921                                                         unsigned NumClauses,
922                                                         unsigned CollapsedNum,
923                                                         EmptyShell) {
924   unsigned Size =
925       llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
926   void *Mem =
927       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
928                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
929   return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses);
930 }
931 
932 OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
933     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
934     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
935     const HelperExprs &Exprs) {
936   unsigned Size =
937       llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
938   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
939                          sizeof(Stmt *) *
940                              numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
941   OMPTaskLoopSimdDirective *Dir = new (Mem)
942       OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
943   Dir->setClauses(Clauses);
944   Dir->setAssociatedStmt(AssociatedStmt);
945   Dir->setIterationVariable(Exprs.IterationVarRef);
946   Dir->setLastIteration(Exprs.LastIteration);
947   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
948   Dir->setPreCond(Exprs.PreCond);
949   Dir->setCond(Exprs.Cond);
950   Dir->setInit(Exprs.Init);
951   Dir->setInc(Exprs.Inc);
952   Dir->setIsLastIterVariable(Exprs.IL);
953   Dir->setLowerBoundVariable(Exprs.LB);
954   Dir->setUpperBoundVariable(Exprs.UB);
955   Dir->setStrideVariable(Exprs.ST);
956   Dir->setEnsureUpperBound(Exprs.EUB);
957   Dir->setNextLowerBound(Exprs.NLB);
958   Dir->setNextUpperBound(Exprs.NUB);
959   Dir->setNumIterations(Exprs.NumIterations);
960   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
961   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
962   Dir->setDistInc(Exprs.DistInc);
963   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
964   Dir->setCounters(Exprs.Counters);
965   Dir->setPrivateCounters(Exprs.PrivateCounters);
966   Dir->setInits(Exprs.Inits);
967   Dir->setUpdates(Exprs.Updates);
968   Dir->setFinals(Exprs.Finals);
969   Dir->setPreInits(Exprs.PreInits);
970   return Dir;
971 }
972 
973 OMPTaskLoopSimdDirective *
974 OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
975                                       unsigned CollapsedNum, EmptyShell) {
976   unsigned Size =
977       llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
978   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
979                          sizeof(Stmt *) *
980                              numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
981   return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses);
982 }
983 
984 OMPDistributeDirective *OMPDistributeDirective::Create(
985     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
986     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
987     const HelperExprs &Exprs) {
988   unsigned Size =
989       llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
990   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
991                          sizeof(Stmt *) *
992                              numLoopChildren(CollapsedNum, OMPD_distribute));
993   OMPDistributeDirective *Dir = new (Mem)
994       OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
995   Dir->setClauses(Clauses);
996   Dir->setAssociatedStmt(AssociatedStmt);
997   Dir->setIterationVariable(Exprs.IterationVarRef);
998   Dir->setLastIteration(Exprs.LastIteration);
999   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1000   Dir->setPreCond(Exprs.PreCond);
1001   Dir->setCond(Exprs.Cond);
1002   Dir->setInit(Exprs.Init);
1003   Dir->setInc(Exprs.Inc);
1004   Dir->setIsLastIterVariable(Exprs.IL);
1005   Dir->setLowerBoundVariable(Exprs.LB);
1006   Dir->setUpperBoundVariable(Exprs.UB);
1007   Dir->setStrideVariable(Exprs.ST);
1008   Dir->setEnsureUpperBound(Exprs.EUB);
1009   Dir->setNextLowerBound(Exprs.NLB);
1010   Dir->setNextUpperBound(Exprs.NUB);
1011   Dir->setNumIterations(Exprs.NumIterations);
1012   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1013   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1014   Dir->setDistInc(Exprs.DistInc);
1015   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1016   Dir->setCounters(Exprs.Counters);
1017   Dir->setPrivateCounters(Exprs.PrivateCounters);
1018   Dir->setInits(Exprs.Inits);
1019   Dir->setUpdates(Exprs.Updates);
1020   Dir->setFinals(Exprs.Finals);
1021   Dir->setPreInits(Exprs.PreInits);
1022   return Dir;
1023 }
1024 
1025 OMPDistributeDirective *
1026 OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1027                                     unsigned CollapsedNum, EmptyShell) {
1028   unsigned Size =
1029       llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
1030   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1031                          sizeof(Stmt *) *
1032                              numLoopChildren(CollapsedNum, OMPD_distribute));
1033   return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
1034 }
1035 
1036 OMPTargetUpdateDirective *
1037 OMPTargetUpdateDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1038                                  SourceLocation EndLoc,
1039                                  ArrayRef<OMPClause *> Clauses) {
1040   unsigned Size =
1041       llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
1042   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
1043   OMPTargetUpdateDirective *Dir =
1044       new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
1045   Dir->setClauses(Clauses);
1046   return Dir;
1047 }
1048 
1049 OMPTargetUpdateDirective *
1050 OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1051                                       EmptyShell) {
1052   unsigned Size =
1053       llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
1054   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
1055   return new (Mem) OMPTargetUpdateDirective(NumClauses);
1056 }
1057 
1058 OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1059     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1060     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1061     const HelperExprs &Exprs) {
1062   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
1063                                 alignof(OMPClause *));
1064   void *Mem = C.Allocate(
1065       Size + sizeof(OMPClause *) * Clauses.size() +
1066       sizeof(Stmt *) *
1067           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1068   OMPDistributeParallelForDirective *Dir =
1069       new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc,
1070                                                   CollapsedNum, Clauses.size());
1071   Dir->setClauses(Clauses);
1072   Dir->setAssociatedStmt(AssociatedStmt);
1073   Dir->setIterationVariable(Exprs.IterationVarRef);
1074   Dir->setLastIteration(Exprs.LastIteration);
1075   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1076   Dir->setPreCond(Exprs.PreCond);
1077   Dir->setCond(Exprs.Cond);
1078   Dir->setInit(Exprs.Init);
1079   Dir->setInc(Exprs.Inc);
1080   Dir->setIsLastIterVariable(Exprs.IL);
1081   Dir->setLowerBoundVariable(Exprs.LB);
1082   Dir->setUpperBoundVariable(Exprs.UB);
1083   Dir->setStrideVariable(Exprs.ST);
1084   Dir->setEnsureUpperBound(Exprs.EUB);
1085   Dir->setNextLowerBound(Exprs.NLB);
1086   Dir->setNextUpperBound(Exprs.NUB);
1087   Dir->setNumIterations(Exprs.NumIterations);
1088   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1089   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1090   Dir->setDistInc(Exprs.DistInc);
1091   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1092   Dir->setCounters(Exprs.Counters);
1093   Dir->setPrivateCounters(Exprs.PrivateCounters);
1094   Dir->setInits(Exprs.Inits);
1095   Dir->setUpdates(Exprs.Updates);
1096   Dir->setFinals(Exprs.Finals);
1097   Dir->setPreInits(Exprs.PreInits);
1098   return Dir;
1099 }
1100 
1101 OMPDistributeParallelForDirective *
1102 OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1103                                                unsigned NumClauses,
1104                                                unsigned CollapsedNum,
1105                                                EmptyShell) {
1106   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
1107                                 alignof(OMPClause *));
1108   void *Mem = C.Allocate(
1109       Size + sizeof(OMPClause *) * NumClauses +
1110       sizeof(Stmt *) *
1111           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1112   return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses);
1113 }
1114 
1115 OMPDistributeParallelForSimdDirective *
1116 OMPDistributeParallelForSimdDirective::Create(
1117     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1118     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1119     const HelperExprs &Exprs) {
1120   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
1121                                 alignof(OMPClause *));
1122   void *Mem = C.Allocate(
1123       Size + sizeof(OMPClause *) * Clauses.size() +
1124       sizeof(Stmt *) *
1125           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1126   OMPDistributeParallelForSimdDirective *Dir = new (Mem)
1127       OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1128                                             Clauses.size());
1129   Dir->setClauses(Clauses);
1130   Dir->setAssociatedStmt(AssociatedStmt);
1131   Dir->setIterationVariable(Exprs.IterationVarRef);
1132   Dir->setLastIteration(Exprs.LastIteration);
1133   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1134   Dir->setPreCond(Exprs.PreCond);
1135   Dir->setCond(Exprs.Cond);
1136   Dir->setInit(Exprs.Init);
1137   Dir->setInc(Exprs.Inc);
1138   Dir->setIsLastIterVariable(Exprs.IL);
1139   Dir->setLowerBoundVariable(Exprs.LB);
1140   Dir->setUpperBoundVariable(Exprs.UB);
1141   Dir->setStrideVariable(Exprs.ST);
1142   Dir->setEnsureUpperBound(Exprs.EUB);
1143   Dir->setNextLowerBound(Exprs.NLB);
1144   Dir->setNextUpperBound(Exprs.NUB);
1145   Dir->setNumIterations(Exprs.NumIterations);
1146   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1147   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1148   Dir->setDistInc(Exprs.DistInc);
1149   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
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->setPreInits(Exprs.PreInits);
1156   return Dir;
1157 }
1158 
1159 OMPDistributeParallelForSimdDirective *
1160 OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1161                                                    unsigned NumClauses,
1162                                                    unsigned CollapsedNum,
1163                                                    EmptyShell) {
1164   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
1165                                 alignof(OMPClause *));
1166   void *Mem = C.Allocate(
1167       Size + sizeof(OMPClause *) * NumClauses +
1168       sizeof(Stmt *) *
1169           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1170   return new (Mem)
1171       OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1172 }
1173 
1174 OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1175     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1176     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1177     const HelperExprs &Exprs) {
1178   unsigned Size =
1179       llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
1180   void *Mem = C.Allocate(
1181       Size + sizeof(OMPClause *) * Clauses.size() +
1182       sizeof(Stmt *) *
1183           numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1184   OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective(
1185       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1186   Dir->setClauses(Clauses);
1187   Dir->setAssociatedStmt(AssociatedStmt);
1188   Dir->setIterationVariable(Exprs.IterationVarRef);
1189   Dir->setLastIteration(Exprs.LastIteration);
1190   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1191   Dir->setPreCond(Exprs.PreCond);
1192   Dir->setCond(Exprs.Cond);
1193   Dir->setInit(Exprs.Init);
1194   Dir->setInc(Exprs.Inc);
1195   Dir->setIsLastIterVariable(Exprs.IL);
1196   Dir->setLowerBoundVariable(Exprs.LB);
1197   Dir->setUpperBoundVariable(Exprs.UB);
1198   Dir->setStrideVariable(Exprs.ST);
1199   Dir->setEnsureUpperBound(Exprs.EUB);
1200   Dir->setNextLowerBound(Exprs.NLB);
1201   Dir->setNextUpperBound(Exprs.NUB);
1202   Dir->setNumIterations(Exprs.NumIterations);
1203   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1204   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1205   Dir->setDistInc(Exprs.DistInc);
1206   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1207   Dir->setCounters(Exprs.Counters);
1208   Dir->setPrivateCounters(Exprs.PrivateCounters);
1209   Dir->setInits(Exprs.Inits);
1210   Dir->setUpdates(Exprs.Updates);
1211   Dir->setFinals(Exprs.Finals);
1212   Dir->setPreInits(Exprs.PreInits);
1213   return Dir;
1214 }
1215 
1216 OMPDistributeSimdDirective *
1217 OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1218                                         unsigned NumClauses,
1219                                         unsigned CollapsedNum, EmptyShell) {
1220   unsigned Size =
1221       llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
1222   void *Mem = C.Allocate(
1223       Size + sizeof(OMPClause *) * NumClauses +
1224       sizeof(Stmt *) *
1225           numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1226   return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses);
1227 }
1228 
1229 OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1230     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1231     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1232     const HelperExprs &Exprs) {
1233   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
1234                                 alignof(OMPClause *));
1235   void *Mem = C.Allocate(
1236       Size + sizeof(OMPClause *) * Clauses.size() +
1237       sizeof(Stmt *) *
1238           numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1239   OMPTargetParallelForSimdDirective *Dir =
1240       new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
1241                                                   CollapsedNum, Clauses.size());
1242   Dir->setClauses(Clauses);
1243   Dir->setAssociatedStmt(AssociatedStmt);
1244   Dir->setIterationVariable(Exprs.IterationVarRef);
1245   Dir->setLastIteration(Exprs.LastIteration);
1246   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1247   Dir->setPreCond(Exprs.PreCond);
1248   Dir->setCond(Exprs.Cond);
1249   Dir->setInit(Exprs.Init);
1250   Dir->setInc(Exprs.Inc);
1251   Dir->setIsLastIterVariable(Exprs.IL);
1252   Dir->setLowerBoundVariable(Exprs.LB);
1253   Dir->setUpperBoundVariable(Exprs.UB);
1254   Dir->setStrideVariable(Exprs.ST);
1255   Dir->setEnsureUpperBound(Exprs.EUB);
1256   Dir->setNextLowerBound(Exprs.NLB);
1257   Dir->setNextUpperBound(Exprs.NUB);
1258   Dir->setNumIterations(Exprs.NumIterations);
1259   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1260   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1261   Dir->setDistInc(Exprs.DistInc);
1262   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1263   Dir->setCounters(Exprs.Counters);
1264   Dir->setPrivateCounters(Exprs.PrivateCounters);
1265   Dir->setInits(Exprs.Inits);
1266   Dir->setUpdates(Exprs.Updates);
1267   Dir->setFinals(Exprs.Finals);
1268   Dir->setPreInits(Exprs.PreInits);
1269   return Dir;
1270 }
1271 
1272 OMPTargetParallelForSimdDirective *
1273 OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1274                                                unsigned NumClauses,
1275                                                unsigned CollapsedNum,
1276                                                EmptyShell) {
1277   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
1278                                 alignof(OMPClause *));
1279   void *Mem = C.Allocate(
1280       Size + sizeof(OMPClause *) * NumClauses +
1281       sizeof(Stmt *) *
1282           numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1283   return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
1284 }
1285 
1286 OMPTargetSimdDirective *
1287 OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1288                                SourceLocation EndLoc, unsigned CollapsedNum,
1289                                ArrayRef<OMPClause *> Clauses,
1290                                Stmt *AssociatedStmt, const HelperExprs &Exprs) {
1291   unsigned Size =
1292       llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
1293   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1294                          sizeof(Stmt *) *
1295                              numLoopChildren(CollapsedNum, OMPD_target_simd));
1296   OMPTargetSimdDirective *Dir = new (Mem)
1297       OMPTargetSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1298   Dir->setClauses(Clauses);
1299   Dir->setAssociatedStmt(AssociatedStmt);
1300   Dir->setIterationVariable(Exprs.IterationVarRef);
1301   Dir->setLastIteration(Exprs.LastIteration);
1302   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1303   Dir->setPreCond(Exprs.PreCond);
1304   Dir->setCond(Exprs.Cond);
1305   Dir->setInit(Exprs.Init);
1306   Dir->setInc(Exprs.Inc);
1307   Dir->setCounters(Exprs.Counters);
1308   Dir->setPrivateCounters(Exprs.PrivateCounters);
1309   Dir->setInits(Exprs.Inits);
1310   Dir->setUpdates(Exprs.Updates);
1311   Dir->setFinals(Exprs.Finals);
1312   Dir->setPreInits(Exprs.PreInits);
1313   return Dir;
1314 }
1315 
1316 OMPTargetSimdDirective *
1317 OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1318                                     unsigned CollapsedNum, EmptyShell) {
1319   unsigned Size =
1320       llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
1321   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1322                          sizeof(Stmt *) *
1323                              numLoopChildren(CollapsedNum, OMPD_target_simd));
1324   return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses);
1325 }
1326 
1327 OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
1328     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1329     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1330     const HelperExprs &Exprs) {
1331   unsigned Size =
1332       llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
1333   void *Mem = C.Allocate(
1334       Size + sizeof(OMPClause *) * Clauses.size() +
1335       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1336   OMPTeamsDistributeDirective *Dir = new (Mem) OMPTeamsDistributeDirective(
1337       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1338   Dir->setClauses(Clauses);
1339   Dir->setAssociatedStmt(AssociatedStmt);
1340   Dir->setIterationVariable(Exprs.IterationVarRef);
1341   Dir->setLastIteration(Exprs.LastIteration);
1342   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1343   Dir->setPreCond(Exprs.PreCond);
1344   Dir->setCond(Exprs.Cond);
1345   Dir->setInit(Exprs.Init);
1346   Dir->setInc(Exprs.Inc);
1347   Dir->setIsLastIterVariable(Exprs.IL);
1348   Dir->setLowerBoundVariable(Exprs.LB);
1349   Dir->setUpperBoundVariable(Exprs.UB);
1350   Dir->setStrideVariable(Exprs.ST);
1351   Dir->setEnsureUpperBound(Exprs.EUB);
1352   Dir->setNextLowerBound(Exprs.NLB);
1353   Dir->setNextUpperBound(Exprs.NUB);
1354   Dir->setNumIterations(Exprs.NumIterations);
1355   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1356   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1357   Dir->setDistInc(Exprs.DistInc);
1358   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1359   Dir->setCounters(Exprs.Counters);
1360   Dir->setPrivateCounters(Exprs.PrivateCounters);
1361   Dir->setInits(Exprs.Inits);
1362   Dir->setUpdates(Exprs.Updates);
1363   Dir->setFinals(Exprs.Finals);
1364   Dir->setPreInits(Exprs.PreInits);
1365   return Dir;
1366 }
1367 
1368 OMPTeamsDistributeDirective *
1369 OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1370                                          unsigned NumClauses,
1371                                          unsigned CollapsedNum, EmptyShell) {
1372   unsigned Size =
1373       llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
1374   void *Mem = C.Allocate(
1375       Size + sizeof(OMPClause *) * NumClauses +
1376       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1377   return new (Mem) OMPTeamsDistributeDirective(CollapsedNum, NumClauses);
1378 }
1379 
1380 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
1381     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1382     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1383     const HelperExprs &Exprs) {
1384   unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1385                                 alignof(OMPClause *));
1386   void *Mem =
1387       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1388                  sizeof(Stmt *) *
1389                      numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1390   OMPTeamsDistributeSimdDirective *Dir =
1391       new (Mem) OMPTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
1392                                                 Clauses.size());
1393   Dir->setClauses(Clauses);
1394   Dir->setAssociatedStmt(AssociatedStmt);
1395   Dir->setIterationVariable(Exprs.IterationVarRef);
1396   Dir->setLastIteration(Exprs.LastIteration);
1397   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1398   Dir->setPreCond(Exprs.PreCond);
1399   Dir->setCond(Exprs.Cond);
1400   Dir->setInit(Exprs.Init);
1401   Dir->setInc(Exprs.Inc);
1402   Dir->setIsLastIterVariable(Exprs.IL);
1403   Dir->setLowerBoundVariable(Exprs.LB);
1404   Dir->setUpperBoundVariable(Exprs.UB);
1405   Dir->setStrideVariable(Exprs.ST);
1406   Dir->setEnsureUpperBound(Exprs.EUB);
1407   Dir->setNextLowerBound(Exprs.NLB);
1408   Dir->setNextUpperBound(Exprs.NUB);
1409   Dir->setNumIterations(Exprs.NumIterations);
1410   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1411   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1412   Dir->setDistInc(Exprs.DistInc);
1413   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1414   Dir->setCounters(Exprs.Counters);
1415   Dir->setPrivateCounters(Exprs.PrivateCounters);
1416   Dir->setInits(Exprs.Inits);
1417   Dir->setUpdates(Exprs.Updates);
1418   Dir->setFinals(Exprs.Finals);
1419   Dir->setPreInits(Exprs.PreInits);
1420   return Dir;
1421 }
1422 
1423 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
1424     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1425     EmptyShell) {
1426   unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1427                                 alignof(OMPClause *));
1428   void *Mem =
1429       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1430                  sizeof(Stmt *) *
1431                      numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1432   return new (Mem) OMPTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
1433 }
1434 
1435 OMPTeamsDistributeParallelForSimdDirective *
1436 OMPTeamsDistributeParallelForSimdDirective::Create(
1437     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1438     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1439     const HelperExprs &Exprs) {
1440   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1441                             alignof(OMPClause *));
1442   void *Mem =
1443       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1444                  sizeof(Stmt *) *
1445                      numLoopChildren(CollapsedNum,
1446                                      OMPD_teams_distribute_parallel_for_simd));
1447   OMPTeamsDistributeParallelForSimdDirective *Dir = new (Mem)
1448       OMPTeamsDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1449                                                  Clauses.size());
1450   Dir->setClauses(Clauses);
1451   Dir->setAssociatedStmt(AssociatedStmt);
1452   Dir->setIterationVariable(Exprs.IterationVarRef);
1453   Dir->setLastIteration(Exprs.LastIteration);
1454   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1455   Dir->setPreCond(Exprs.PreCond);
1456   Dir->setCond(Exprs.Cond);
1457   Dir->setInit(Exprs.Init);
1458   Dir->setInc(Exprs.Inc);
1459   Dir->setIsLastIterVariable(Exprs.IL);
1460   Dir->setLowerBoundVariable(Exprs.LB);
1461   Dir->setUpperBoundVariable(Exprs.UB);
1462   Dir->setStrideVariable(Exprs.ST);
1463   Dir->setEnsureUpperBound(Exprs.EUB);
1464   Dir->setNextLowerBound(Exprs.NLB);
1465   Dir->setNextUpperBound(Exprs.NUB);
1466   Dir->setNumIterations(Exprs.NumIterations);
1467   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1468   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1469   Dir->setDistInc(Exprs.DistInc);
1470   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1471   Dir->setCounters(Exprs.Counters);
1472   Dir->setPrivateCounters(Exprs.PrivateCounters);
1473   Dir->setInits(Exprs.Inits);
1474   Dir->setUpdates(Exprs.Updates);
1475   Dir->setFinals(Exprs.Finals);
1476   Dir->setPreInits(Exprs.PreInits);
1477   return Dir;
1478 }
1479 
1480 OMPTeamsDistributeParallelForSimdDirective *
1481 OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1482                                                         unsigned NumClauses,
1483                                                         unsigned CollapsedNum,
1484                                                         EmptyShell) {
1485   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1486                             alignof(OMPClause *));
1487   void *Mem =
1488       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1489                  sizeof(Stmt *) *
1490                      numLoopChildren(CollapsedNum,
1491                                      OMPD_teams_distribute_parallel_for_simd));
1492   return new (Mem)
1493       OMPTeamsDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1494 }
1495 
1496 OMPTeamsDistributeParallelForDirective *
1497 OMPTeamsDistributeParallelForDirective::Create(
1498     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1499     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1500     const HelperExprs &Exprs) {
1501   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1502                             alignof(OMPClause *));
1503   void *Mem = C.Allocate(
1504       Size + sizeof(OMPClause *) * Clauses.size() +
1505       sizeof(Stmt *) *
1506           numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1507   OMPTeamsDistributeParallelForDirective *Dir = new (Mem)
1508       OMPTeamsDistributeParallelForDirective(StartLoc, EndLoc, CollapsedNum,
1509                                              Clauses.size());
1510   Dir->setClauses(Clauses);
1511   Dir->setAssociatedStmt(AssociatedStmt);
1512   Dir->setIterationVariable(Exprs.IterationVarRef);
1513   Dir->setLastIteration(Exprs.LastIteration);
1514   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1515   Dir->setPreCond(Exprs.PreCond);
1516   Dir->setCond(Exprs.Cond);
1517   Dir->setInit(Exprs.Init);
1518   Dir->setInc(Exprs.Inc);
1519   Dir->setIsLastIterVariable(Exprs.IL);
1520   Dir->setLowerBoundVariable(Exprs.LB);
1521   Dir->setUpperBoundVariable(Exprs.UB);
1522   Dir->setStrideVariable(Exprs.ST);
1523   Dir->setEnsureUpperBound(Exprs.EUB);
1524   Dir->setNextLowerBound(Exprs.NLB);
1525   Dir->setNextUpperBound(Exprs.NUB);
1526   Dir->setNumIterations(Exprs.NumIterations);
1527   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1528   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1529   Dir->setDistInc(Exprs.DistInc);
1530   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1531   Dir->setCounters(Exprs.Counters);
1532   Dir->setPrivateCounters(Exprs.PrivateCounters);
1533   Dir->setInits(Exprs.Inits);
1534   Dir->setUpdates(Exprs.Updates);
1535   Dir->setFinals(Exprs.Finals);
1536   Dir->setPreInits(Exprs.PreInits);
1537   return Dir;
1538 }
1539 
1540 OMPTeamsDistributeParallelForDirective *
1541 OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1542                                                     unsigned NumClauses,
1543                                                     unsigned CollapsedNum,
1544                                                     EmptyShell) {
1545   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1546                             alignof(OMPClause *));
1547   void *Mem = C.Allocate(
1548       Size + sizeof(OMPClause *) * NumClauses +
1549       sizeof(Stmt *) *
1550           numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1551   return new (Mem)
1552       OMPTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
1553 }
1554 
1555 OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
1556     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1557     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1558   auto Size =
1559       llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
1560   void *Mem =
1561       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1562   OMPTargetTeamsDirective *Dir =
1563       new (Mem) OMPTargetTeamsDirective(StartLoc, EndLoc, Clauses.size());
1564   Dir->setClauses(Clauses);
1565   Dir->setAssociatedStmt(AssociatedStmt);
1566   return Dir;
1567 }
1568 
1569 OMPTargetTeamsDirective *
1570 OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1571                                      EmptyShell) {
1572   auto Size =
1573       llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
1574   void *Mem =
1575       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1576   return new (Mem) OMPTargetTeamsDirective(NumClauses);
1577 }
1578 
1579 OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
1580     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1581     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1582     const HelperExprs &Exprs) {
1583   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
1584                             alignof(OMPClause *));
1585   void *Mem = C.Allocate(
1586       Size + sizeof(OMPClause *) * Clauses.size() +
1587       sizeof(Stmt *) *
1588           numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
1589   OMPTargetTeamsDistributeDirective *Dir =
1590       new (Mem) OMPTargetTeamsDistributeDirective(StartLoc, EndLoc, CollapsedNum,
1591                                                   Clauses.size());
1592   Dir->setClauses(Clauses);
1593   Dir->setAssociatedStmt(AssociatedStmt);
1594   Dir->setIterationVariable(Exprs.IterationVarRef);
1595   Dir->setLastIteration(Exprs.LastIteration);
1596   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1597   Dir->setPreCond(Exprs.PreCond);
1598   Dir->setCond(Exprs.Cond);
1599   Dir->setInit(Exprs.Init);
1600   Dir->setInc(Exprs.Inc);
1601   Dir->setIsLastIterVariable(Exprs.IL);
1602   Dir->setLowerBoundVariable(Exprs.LB);
1603   Dir->setUpperBoundVariable(Exprs.UB);
1604   Dir->setStrideVariable(Exprs.ST);
1605   Dir->setEnsureUpperBound(Exprs.EUB);
1606   Dir->setNextLowerBound(Exprs.NLB);
1607   Dir->setNextUpperBound(Exprs.NUB);
1608   Dir->setNumIterations(Exprs.NumIterations);
1609   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1610   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1611   Dir->setDistInc(Exprs.DistInc);
1612   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1613   Dir->setCounters(Exprs.Counters);
1614   Dir->setPrivateCounters(Exprs.PrivateCounters);
1615   Dir->setInits(Exprs.Inits);
1616   Dir->setUpdates(Exprs.Updates);
1617   Dir->setFinals(Exprs.Finals);
1618   Dir->setPreInits(Exprs.PreInits);
1619   return Dir;
1620 }
1621 
1622 OMPTargetTeamsDistributeDirective *
1623 OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1624                                                unsigned NumClauses,
1625                                                unsigned CollapsedNum,
1626                                                EmptyShell) {
1627   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
1628                             alignof(OMPClause *));
1629   void *Mem = C.Allocate(
1630       Size + sizeof(OMPClause *) * NumClauses +
1631       sizeof(Stmt *) *
1632            numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
1633   return new (Mem) OMPTargetTeamsDistributeDirective(CollapsedNum, NumClauses);
1634 }
1635 
1636 OMPTargetTeamsDistributeParallelForDirective *
1637 OMPTargetTeamsDistributeParallelForDirective::Create(
1638     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1639     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1640     const HelperExprs &Exprs) {
1641   auto Size =
1642       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
1643                     alignof(OMPClause *));
1644   void *Mem = C.Allocate(
1645       Size + sizeof(OMPClause *) * Clauses.size() +
1646       sizeof(Stmt *) *
1647           numLoopChildren(CollapsedNum,
1648                           OMPD_target_teams_distribute_parallel_for));
1649   OMPTargetTeamsDistributeParallelForDirective *Dir =
1650       new (Mem) OMPTargetTeamsDistributeParallelForDirective(
1651            StartLoc, EndLoc, CollapsedNum, Clauses.size());
1652   Dir->setClauses(Clauses);
1653   Dir->setAssociatedStmt(AssociatedStmt);
1654   Dir->setIterationVariable(Exprs.IterationVarRef);
1655   Dir->setLastIteration(Exprs.LastIteration);
1656   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1657   Dir->setPreCond(Exprs.PreCond);
1658   Dir->setCond(Exprs.Cond);
1659   Dir->setInit(Exprs.Init);
1660   Dir->setInc(Exprs.Inc);
1661   Dir->setIsLastIterVariable(Exprs.IL);
1662   Dir->setLowerBoundVariable(Exprs.LB);
1663   Dir->setUpperBoundVariable(Exprs.UB);
1664   Dir->setStrideVariable(Exprs.ST);
1665   Dir->setEnsureUpperBound(Exprs.EUB);
1666   Dir->setNextLowerBound(Exprs.NLB);
1667   Dir->setNextUpperBound(Exprs.NUB);
1668   Dir->setNumIterations(Exprs.NumIterations);
1669   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1670   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1671   Dir->setDistInc(Exprs.DistInc);
1672   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1673   Dir->setCounters(Exprs.Counters);
1674   Dir->setPrivateCounters(Exprs.PrivateCounters);
1675   Dir->setInits(Exprs.Inits);
1676   Dir->setUpdates(Exprs.Updates);
1677   Dir->setFinals(Exprs.Finals);
1678   Dir->setPreInits(Exprs.PreInits);
1679   return Dir;
1680 }
1681 
1682 OMPTargetTeamsDistributeParallelForDirective *
1683 OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1684                                                           unsigned NumClauses,
1685                                                           unsigned CollapsedNum,
1686                                                           EmptyShell) {
1687   auto Size =
1688       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
1689                     alignof(OMPClause *));
1690   void *Mem = C.Allocate(
1691       Size + sizeof(OMPClause *) * NumClauses +
1692       sizeof(Stmt *) *
1693            numLoopChildren(CollapsedNum,
1694                            OMPD_target_teams_distribute_parallel_for));
1695   return new (Mem)
1696       OMPTargetTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
1697 }
1698 
1699 OMPTargetTeamsDistributeParallelForSimdDirective *
1700 OMPTargetTeamsDistributeParallelForSimdDirective::Create(
1701     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1702     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1703     const HelperExprs &Exprs) {
1704   auto Size =
1705       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
1706                     alignof(OMPClause *));
1707   void *Mem = C.Allocate(
1708       Size + sizeof(OMPClause *) * Clauses.size() +
1709       sizeof(Stmt *) *
1710           numLoopChildren(CollapsedNum,
1711                           OMPD_target_teams_distribute_parallel_for_simd));
1712   OMPTargetTeamsDistributeParallelForSimdDirective *Dir =
1713       new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
1714            StartLoc, EndLoc, CollapsedNum, Clauses.size());
1715   Dir->setClauses(Clauses);
1716   Dir->setAssociatedStmt(AssociatedStmt);
1717   Dir->setIterationVariable(Exprs.IterationVarRef);
1718   Dir->setLastIteration(Exprs.LastIteration);
1719   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1720   Dir->setPreCond(Exprs.PreCond);
1721   Dir->setCond(Exprs.Cond);
1722   Dir->setInit(Exprs.Init);
1723   Dir->setInc(Exprs.Inc);
1724   Dir->setIsLastIterVariable(Exprs.IL);
1725   Dir->setLowerBoundVariable(Exprs.LB);
1726   Dir->setUpperBoundVariable(Exprs.UB);
1727   Dir->setStrideVariable(Exprs.ST);
1728   Dir->setEnsureUpperBound(Exprs.EUB);
1729   Dir->setNextLowerBound(Exprs.NLB);
1730   Dir->setNextUpperBound(Exprs.NUB);
1731   Dir->setNumIterations(Exprs.NumIterations);
1732   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1733   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1734   Dir->setDistInc(Exprs.DistInc);
1735   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1736   Dir->setCounters(Exprs.Counters);
1737   Dir->setPrivateCounters(Exprs.PrivateCounters);
1738   Dir->setInits(Exprs.Inits);
1739   Dir->setUpdates(Exprs.Updates);
1740   Dir->setFinals(Exprs.Finals);
1741   Dir->setPreInits(Exprs.PreInits);
1742   return Dir;
1743 }
1744 
1745 OMPTargetTeamsDistributeParallelForSimdDirective *
1746 OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
1747     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1748     EmptyShell) {
1749   auto Size =
1750       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
1751                     alignof(OMPClause *));
1752   void *Mem = C.Allocate(
1753       Size + sizeof(OMPClause *) * NumClauses +
1754       sizeof(Stmt *) *
1755           numLoopChildren(CollapsedNum,
1756                           OMPD_target_teams_distribute_parallel_for_simd));
1757   return new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
1758       CollapsedNum, NumClauses);
1759 }
1760 
1761 OMPTargetTeamsDistributeSimdDirective *
1762 OMPTargetTeamsDistributeSimdDirective::Create(
1763     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1764     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1765     const HelperExprs &Exprs) {
1766   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
1767                             alignof(OMPClause *));
1768   void *Mem = C.Allocate(
1769       Size + sizeof(OMPClause *) * Clauses.size() +
1770       sizeof(Stmt *) *
1771           numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
1772   OMPTargetTeamsDistributeSimdDirective *Dir = new (Mem)
1773       OMPTargetTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
1774                                             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->setPrevLowerBoundVariable(Exprs.PrevLB);
1793   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1794   Dir->setDistInc(Exprs.DistInc);
1795   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1796   Dir->setCounters(Exprs.Counters);
1797   Dir->setPrivateCounters(Exprs.PrivateCounters);
1798   Dir->setInits(Exprs.Inits);
1799   Dir->setUpdates(Exprs.Updates);
1800   Dir->setFinals(Exprs.Finals);
1801   Dir->setPreInits(Exprs.PreInits);
1802   return Dir;
1803 }
1804 
1805 OMPTargetTeamsDistributeSimdDirective *
1806 OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1807                                                    unsigned NumClauses,
1808                                                    unsigned CollapsedNum,
1809                                                    EmptyShell) {
1810   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
1811                             alignof(OMPClause *));
1812   void *Mem = C.Allocate(
1813       Size + sizeof(OMPClause *) * NumClauses +
1814       sizeof(Stmt *) *
1815           numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
1816   return new (Mem)
1817       OMPTargetTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
1818 }
1819