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