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