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