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 OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
785                                                  SourceLocation StartLoc,
786                                                  SourceLocation EndLoc,
787                                                  ArrayRef<OMPClause *> Clauses,
788                                                  Stmt *AssociatedStmt) {
789   unsigned Size =
790       llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
791   void *Mem =
792       C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size());
793   OMPOrderedDirective *Dir =
794       new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size());
795   Dir->setClauses(Clauses);
796   Dir->setAssociatedStmt(AssociatedStmt);
797   return Dir;
798 }
799 
800 OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
801                                                       unsigned NumClauses,
802                                                       EmptyShell) {
803   unsigned Size =
804       llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
805   void *Mem =
806       C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses);
807   return new (Mem) OMPOrderedDirective(NumClauses);
808 }
809 
810 OMPAtomicDirective *OMPAtomicDirective::Create(
811     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
812     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
813     Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) {
814   unsigned Size =
815       llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
816   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
817                          5 * sizeof(Stmt *));
818   OMPAtomicDirective *Dir =
819       new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size());
820   Dir->setClauses(Clauses);
821   Dir->setAssociatedStmt(AssociatedStmt);
822   Dir->setX(X);
823   Dir->setV(V);
824   Dir->setExpr(E);
825   Dir->setUpdateExpr(UE);
826   Dir->IsXLHSInRHSPart = IsXLHSInRHSPart;
827   Dir->IsPostfixUpdate = IsPostfixUpdate;
828   return Dir;
829 }
830 
831 OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
832                                                     unsigned NumClauses,
833                                                     EmptyShell) {
834   unsigned Size =
835       llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
836   void *Mem =
837       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *));
838   return new (Mem) OMPAtomicDirective(NumClauses);
839 }
840 
841 OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
842                                                SourceLocation StartLoc,
843                                                SourceLocation EndLoc,
844                                                ArrayRef<OMPClause *> Clauses,
845                                                Stmt *AssociatedStmt) {
846   unsigned Size =
847       llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
848   void *Mem =
849       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
850   OMPTargetDirective *Dir =
851       new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size());
852   Dir->setClauses(Clauses);
853   Dir->setAssociatedStmt(AssociatedStmt);
854   return Dir;
855 }
856 
857 OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
858                                                     unsigned NumClauses,
859                                                     EmptyShell) {
860   unsigned Size =
861       llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
862   void *Mem =
863       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
864   return new (Mem) OMPTargetDirective(NumClauses);
865 }
866 
867 OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
868     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
869     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
870   unsigned Size =
871       llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
872   void *Mem =
873       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
874   OMPTargetParallelDirective *Dir =
875       new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size());
876   Dir->setClauses(Clauses);
877   Dir->setAssociatedStmt(AssociatedStmt);
878   return Dir;
879 }
880 
881 OMPTargetParallelDirective *
882 OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
883                                         unsigned NumClauses, EmptyShell) {
884   unsigned Size =
885       llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
886   void *Mem =
887       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
888   return new (Mem) OMPTargetParallelDirective(NumClauses);
889 }
890 
891 OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
892     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
893     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
894     const HelperExprs &Exprs, bool HasCancel) {
895   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
896                                 alignof(OMPClause *));
897   void *Mem = C.Allocate(
898       Size + sizeof(OMPClause *) * Clauses.size() +
899       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
900   OMPTargetParallelForDirective *Dir = new (Mem) OMPTargetParallelForDirective(
901       StartLoc, EndLoc, CollapsedNum, Clauses.size());
902   Dir->setClauses(Clauses);
903   Dir->setAssociatedStmt(AssociatedStmt);
904   Dir->setIterationVariable(Exprs.IterationVarRef);
905   Dir->setLastIteration(Exprs.LastIteration);
906   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
907   Dir->setPreCond(Exprs.PreCond);
908   Dir->setCond(Exprs.Cond);
909   Dir->setInit(Exprs.Init);
910   Dir->setInc(Exprs.Inc);
911   Dir->setIsLastIterVariable(Exprs.IL);
912   Dir->setLowerBoundVariable(Exprs.LB);
913   Dir->setUpperBoundVariable(Exprs.UB);
914   Dir->setStrideVariable(Exprs.ST);
915   Dir->setEnsureUpperBound(Exprs.EUB);
916   Dir->setNextLowerBound(Exprs.NLB);
917   Dir->setNextUpperBound(Exprs.NUB);
918   Dir->setNumIterations(Exprs.NumIterations);
919   Dir->setCounters(Exprs.Counters);
920   Dir->setPrivateCounters(Exprs.PrivateCounters);
921   Dir->setInits(Exprs.Inits);
922   Dir->setUpdates(Exprs.Updates);
923   Dir->setFinals(Exprs.Finals);
924   Dir->setDependentCounters(Exprs.DependentCounters);
925   Dir->setDependentInits(Exprs.DependentInits);
926   Dir->setFinalsConditions(Exprs.FinalsConditions);
927   Dir->setPreInits(Exprs.PreInits);
928   Dir->setHasCancel(HasCancel);
929   return Dir;
930 }
931 
932 OMPTargetParallelForDirective *
933 OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
934                                            unsigned NumClauses,
935                                            unsigned CollapsedNum, EmptyShell) {
936   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
937                                 alignof(OMPClause *));
938   void *Mem = C.Allocate(
939       Size + sizeof(OMPClause *) * NumClauses +
940       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
941   return new (Mem) OMPTargetParallelForDirective(CollapsedNum, NumClauses);
942 }
943 
944 OMPTargetDataDirective *OMPTargetDataDirective::Create(
945     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
946     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
947   void *Mem = C.Allocate(
948       llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
949       sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
950   OMPTargetDataDirective *Dir =
951       new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size());
952   Dir->setClauses(Clauses);
953   Dir->setAssociatedStmt(AssociatedStmt);
954   return Dir;
955 }
956 
957 OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
958                                                             unsigned N,
959                                                             EmptyShell) {
960   void *Mem = C.Allocate(
961       llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
962       sizeof(OMPClause *) * N + sizeof(Stmt *));
963   return new (Mem) OMPTargetDataDirective(N);
964 }
965 
966 OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
967     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
968     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
969   void *Mem = C.Allocate(
970       llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
971       sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
972   OMPTargetEnterDataDirective *Dir =
973       new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size());
974   Dir->setClauses(Clauses);
975   Dir->setAssociatedStmt(AssociatedStmt);
976   return Dir;
977 }
978 
979 OMPTargetEnterDataDirective *
980 OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
981                                          EmptyShell) {
982   void *Mem = C.Allocate(
983       llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
984       sizeof(OMPClause *) * N + sizeof(Stmt *));
985   return new (Mem) OMPTargetEnterDataDirective(N);
986 }
987 
988 OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create(
989     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
990     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
991   void *Mem = C.Allocate(
992       llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
993       sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
994   OMPTargetExitDataDirective *Dir =
995       new (Mem) OMPTargetExitDataDirective(StartLoc, EndLoc, Clauses.size());
996   Dir->setClauses(Clauses);
997   Dir->setAssociatedStmt(AssociatedStmt);
998   return Dir;
999 }
1000 
1001 OMPTargetExitDataDirective *
1002 OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
1003                                         EmptyShell) {
1004   void *Mem = C.Allocate(
1005       llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
1006       sizeof(OMPClause *) * N + sizeof(Stmt *));
1007   return new (Mem) OMPTargetExitDataDirective(N);
1008 }
1009 
1010 OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
1011                                              SourceLocation StartLoc,
1012                                              SourceLocation EndLoc,
1013                                              ArrayRef<OMPClause *> Clauses,
1014                                              Stmt *AssociatedStmt) {
1015   unsigned Size =
1016       llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
1017   void *Mem =
1018       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1019   OMPTeamsDirective *Dir =
1020       new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size());
1021   Dir->setClauses(Clauses);
1022   Dir->setAssociatedStmt(AssociatedStmt);
1023   return Dir;
1024 }
1025 
1026 OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
1027                                                   unsigned NumClauses,
1028                                                   EmptyShell) {
1029   unsigned Size =
1030       llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
1031   void *Mem =
1032       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1033   return new (Mem) OMPTeamsDirective(NumClauses);
1034 }
1035 
1036 OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
1037     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1038     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1039     const HelperExprs &Exprs, bool HasCancel) {
1040   unsigned Size =
1041       llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
1042   void *Mem =
1043       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1044                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
1045   OMPTaskLoopDirective *Dir = new (Mem)
1046       OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1047   Dir->setClauses(Clauses);
1048   Dir->setAssociatedStmt(AssociatedStmt);
1049   Dir->setIterationVariable(Exprs.IterationVarRef);
1050   Dir->setLastIteration(Exprs.LastIteration);
1051   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1052   Dir->setPreCond(Exprs.PreCond);
1053   Dir->setCond(Exprs.Cond);
1054   Dir->setInit(Exprs.Init);
1055   Dir->setInc(Exprs.Inc);
1056   Dir->setIsLastIterVariable(Exprs.IL);
1057   Dir->setLowerBoundVariable(Exprs.LB);
1058   Dir->setUpperBoundVariable(Exprs.UB);
1059   Dir->setStrideVariable(Exprs.ST);
1060   Dir->setEnsureUpperBound(Exprs.EUB);
1061   Dir->setNextLowerBound(Exprs.NLB);
1062   Dir->setNextUpperBound(Exprs.NUB);
1063   Dir->setNumIterations(Exprs.NumIterations);
1064   Dir->setCounters(Exprs.Counters);
1065   Dir->setPrivateCounters(Exprs.PrivateCounters);
1066   Dir->setInits(Exprs.Inits);
1067   Dir->setUpdates(Exprs.Updates);
1068   Dir->setFinals(Exprs.Finals);
1069   Dir->setDependentCounters(Exprs.DependentCounters);
1070   Dir->setDependentInits(Exprs.DependentInits);
1071   Dir->setFinalsConditions(Exprs.FinalsConditions);
1072   Dir->setPreInits(Exprs.PreInits);
1073   Dir->setHasCancel(HasCancel);
1074   return Dir;
1075 }
1076 
1077 OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
1078                                                         unsigned NumClauses,
1079                                                         unsigned CollapsedNum,
1080                                                         EmptyShell) {
1081   unsigned Size =
1082       llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
1083   void *Mem =
1084       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1085                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
1086   return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses);
1087 }
1088 
1089 OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
1090     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1091     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1092     const HelperExprs &Exprs) {
1093   unsigned Size =
1094       llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
1095   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1096                          sizeof(Stmt *) *
1097                              numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
1098   OMPTaskLoopSimdDirective *Dir = new (Mem)
1099       OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1100   Dir->setClauses(Clauses);
1101   Dir->setAssociatedStmt(AssociatedStmt);
1102   Dir->setIterationVariable(Exprs.IterationVarRef);
1103   Dir->setLastIteration(Exprs.LastIteration);
1104   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1105   Dir->setPreCond(Exprs.PreCond);
1106   Dir->setCond(Exprs.Cond);
1107   Dir->setInit(Exprs.Init);
1108   Dir->setInc(Exprs.Inc);
1109   Dir->setIsLastIterVariable(Exprs.IL);
1110   Dir->setLowerBoundVariable(Exprs.LB);
1111   Dir->setUpperBoundVariable(Exprs.UB);
1112   Dir->setStrideVariable(Exprs.ST);
1113   Dir->setEnsureUpperBound(Exprs.EUB);
1114   Dir->setNextLowerBound(Exprs.NLB);
1115   Dir->setNextUpperBound(Exprs.NUB);
1116   Dir->setNumIterations(Exprs.NumIterations);
1117   Dir->setCounters(Exprs.Counters);
1118   Dir->setPrivateCounters(Exprs.PrivateCounters);
1119   Dir->setInits(Exprs.Inits);
1120   Dir->setUpdates(Exprs.Updates);
1121   Dir->setFinals(Exprs.Finals);
1122   Dir->setDependentCounters(Exprs.DependentCounters);
1123   Dir->setDependentInits(Exprs.DependentInits);
1124   Dir->setFinalsConditions(Exprs.FinalsConditions);
1125   Dir->setPreInits(Exprs.PreInits);
1126   return Dir;
1127 }
1128 
1129 OMPTaskLoopSimdDirective *
1130 OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1131                                       unsigned CollapsedNum, EmptyShell) {
1132   unsigned Size =
1133       llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
1134   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1135                          sizeof(Stmt *) *
1136                              numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
1137   return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses);
1138 }
1139 
1140 OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create(
1141     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1142     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1143     const HelperExprs &Exprs, bool HasCancel) {
1144   unsigned Size =
1145       llvm::alignTo(sizeof(OMPMasterTaskLoopDirective), alignof(OMPClause *));
1146   void *Mem = C.Allocate(
1147       Size + sizeof(OMPClause *) * Clauses.size() +
1148       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_master_taskloop));
1149   OMPMasterTaskLoopDirective *Dir = new (Mem) OMPMasterTaskLoopDirective(
1150       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1151   Dir->setClauses(Clauses);
1152   Dir->setAssociatedStmt(AssociatedStmt);
1153   Dir->setIterationVariable(Exprs.IterationVarRef);
1154   Dir->setLastIteration(Exprs.LastIteration);
1155   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1156   Dir->setPreCond(Exprs.PreCond);
1157   Dir->setCond(Exprs.Cond);
1158   Dir->setInit(Exprs.Init);
1159   Dir->setInc(Exprs.Inc);
1160   Dir->setIsLastIterVariable(Exprs.IL);
1161   Dir->setLowerBoundVariable(Exprs.LB);
1162   Dir->setUpperBoundVariable(Exprs.UB);
1163   Dir->setStrideVariable(Exprs.ST);
1164   Dir->setEnsureUpperBound(Exprs.EUB);
1165   Dir->setNextLowerBound(Exprs.NLB);
1166   Dir->setNextUpperBound(Exprs.NUB);
1167   Dir->setNumIterations(Exprs.NumIterations);
1168   Dir->setCounters(Exprs.Counters);
1169   Dir->setPrivateCounters(Exprs.PrivateCounters);
1170   Dir->setInits(Exprs.Inits);
1171   Dir->setUpdates(Exprs.Updates);
1172   Dir->setFinals(Exprs.Finals);
1173   Dir->setDependentCounters(Exprs.DependentCounters);
1174   Dir->setDependentInits(Exprs.DependentInits);
1175   Dir->setFinalsConditions(Exprs.FinalsConditions);
1176   Dir->setPreInits(Exprs.PreInits);
1177   Dir->setHasCancel(HasCancel);
1178   return Dir;
1179 }
1180 
1181 OMPMasterTaskLoopDirective *
1182 OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1183                                         unsigned NumClauses,
1184                                         unsigned CollapsedNum, EmptyShell) {
1185   unsigned Size =
1186       llvm::alignTo(sizeof(OMPMasterTaskLoopDirective), alignof(OMPClause *));
1187   void *Mem = C.Allocate(
1188       Size + sizeof(OMPClause *) * NumClauses +
1189       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_master_taskloop));
1190   return new (Mem) OMPMasterTaskLoopDirective(CollapsedNum, NumClauses);
1191 }
1192 
1193 OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create(
1194     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1195     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1196     const HelperExprs &Exprs) {
1197   unsigned Size = llvm::alignTo(sizeof(OMPMasterTaskLoopSimdDirective),
1198                                 alignof(OMPClause *));
1199   void *Mem =
1200       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1201                  sizeof(Stmt *) *
1202                      numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd));
1203   auto *Dir = new (Mem) OMPMasterTaskLoopSimdDirective(
1204       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1205   Dir->setClauses(Clauses);
1206   Dir->setAssociatedStmt(AssociatedStmt);
1207   Dir->setIterationVariable(Exprs.IterationVarRef);
1208   Dir->setLastIteration(Exprs.LastIteration);
1209   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1210   Dir->setPreCond(Exprs.PreCond);
1211   Dir->setCond(Exprs.Cond);
1212   Dir->setInit(Exprs.Init);
1213   Dir->setInc(Exprs.Inc);
1214   Dir->setIsLastIterVariable(Exprs.IL);
1215   Dir->setLowerBoundVariable(Exprs.LB);
1216   Dir->setUpperBoundVariable(Exprs.UB);
1217   Dir->setStrideVariable(Exprs.ST);
1218   Dir->setEnsureUpperBound(Exprs.EUB);
1219   Dir->setNextLowerBound(Exprs.NLB);
1220   Dir->setNextUpperBound(Exprs.NUB);
1221   Dir->setNumIterations(Exprs.NumIterations);
1222   Dir->setCounters(Exprs.Counters);
1223   Dir->setPrivateCounters(Exprs.PrivateCounters);
1224   Dir->setInits(Exprs.Inits);
1225   Dir->setUpdates(Exprs.Updates);
1226   Dir->setFinals(Exprs.Finals);
1227   Dir->setDependentCounters(Exprs.DependentCounters);
1228   Dir->setDependentInits(Exprs.DependentInits);
1229   Dir->setFinalsConditions(Exprs.FinalsConditions);
1230   Dir->setPreInits(Exprs.PreInits);
1231   return Dir;
1232 }
1233 
1234 OMPMasterTaskLoopSimdDirective *
1235 OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1236                                             unsigned NumClauses,
1237                                             unsigned CollapsedNum, EmptyShell) {
1238   unsigned Size = llvm::alignTo(sizeof(OMPMasterTaskLoopSimdDirective),
1239                                 alignof(OMPClause *));
1240   void *Mem =
1241       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1242                  sizeof(Stmt *) *
1243                      numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd));
1244   return new (Mem) OMPMasterTaskLoopSimdDirective(CollapsedNum, NumClauses);
1245 }
1246 
1247 OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create(
1248     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1249     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1250     const HelperExprs &Exprs, bool HasCancel) {
1251   unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopDirective),
1252                                 alignof(OMPClause *));
1253   void *Mem = C.Allocate(
1254       Size + sizeof(OMPClause *) * Clauses.size() +
1255       sizeof(Stmt *) *
1256           numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop));
1257   auto *Dir = new (Mem) OMPParallelMasterTaskLoopDirective(
1258       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1259   Dir->setClauses(Clauses);
1260   Dir->setAssociatedStmt(AssociatedStmt);
1261   Dir->setIterationVariable(Exprs.IterationVarRef);
1262   Dir->setLastIteration(Exprs.LastIteration);
1263   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1264   Dir->setPreCond(Exprs.PreCond);
1265   Dir->setCond(Exprs.Cond);
1266   Dir->setInit(Exprs.Init);
1267   Dir->setInc(Exprs.Inc);
1268   Dir->setIsLastIterVariable(Exprs.IL);
1269   Dir->setLowerBoundVariable(Exprs.LB);
1270   Dir->setUpperBoundVariable(Exprs.UB);
1271   Dir->setStrideVariable(Exprs.ST);
1272   Dir->setEnsureUpperBound(Exprs.EUB);
1273   Dir->setNextLowerBound(Exprs.NLB);
1274   Dir->setNextUpperBound(Exprs.NUB);
1275   Dir->setNumIterations(Exprs.NumIterations);
1276   Dir->setCounters(Exprs.Counters);
1277   Dir->setPrivateCounters(Exprs.PrivateCounters);
1278   Dir->setInits(Exprs.Inits);
1279   Dir->setUpdates(Exprs.Updates);
1280   Dir->setFinals(Exprs.Finals);
1281   Dir->setDependentCounters(Exprs.DependentCounters);
1282   Dir->setDependentInits(Exprs.DependentInits);
1283   Dir->setFinalsConditions(Exprs.FinalsConditions);
1284   Dir->setPreInits(Exprs.PreInits);
1285   Dir->setHasCancel(HasCancel);
1286   return Dir;
1287 }
1288 
1289 OMPParallelMasterTaskLoopDirective *
1290 OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1291                                                 unsigned NumClauses,
1292                                                 unsigned CollapsedNum,
1293                                                 EmptyShell) {
1294   unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopDirective),
1295                                 alignof(OMPClause *));
1296   void *Mem = C.Allocate(
1297       Size + sizeof(OMPClause *) * NumClauses +
1298       sizeof(Stmt *) *
1299           numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop));
1300   return new (Mem) OMPParallelMasterTaskLoopDirective(CollapsedNum, NumClauses);
1301 }
1302 
1303 OMPParallelMasterTaskLoopSimdDirective *
1304 OMPParallelMasterTaskLoopSimdDirective::Create(
1305     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1306     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1307     const HelperExprs &Exprs) {
1308   unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopSimdDirective),
1309                                 alignof(OMPClause *));
1310   void *Mem = C.Allocate(
1311       Size + sizeof(OMPClause *) * Clauses.size() +
1312       sizeof(Stmt *) *
1313           numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd));
1314   auto *Dir = new (Mem) OMPParallelMasterTaskLoopSimdDirective(
1315       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1316   Dir->setClauses(Clauses);
1317   Dir->setAssociatedStmt(AssociatedStmt);
1318   Dir->setIterationVariable(Exprs.IterationVarRef);
1319   Dir->setLastIteration(Exprs.LastIteration);
1320   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1321   Dir->setPreCond(Exprs.PreCond);
1322   Dir->setCond(Exprs.Cond);
1323   Dir->setInit(Exprs.Init);
1324   Dir->setInc(Exprs.Inc);
1325   Dir->setIsLastIterVariable(Exprs.IL);
1326   Dir->setLowerBoundVariable(Exprs.LB);
1327   Dir->setUpperBoundVariable(Exprs.UB);
1328   Dir->setStrideVariable(Exprs.ST);
1329   Dir->setEnsureUpperBound(Exprs.EUB);
1330   Dir->setNextLowerBound(Exprs.NLB);
1331   Dir->setNextUpperBound(Exprs.NUB);
1332   Dir->setNumIterations(Exprs.NumIterations);
1333   Dir->setCounters(Exprs.Counters);
1334   Dir->setPrivateCounters(Exprs.PrivateCounters);
1335   Dir->setInits(Exprs.Inits);
1336   Dir->setUpdates(Exprs.Updates);
1337   Dir->setFinals(Exprs.Finals);
1338   Dir->setDependentCounters(Exprs.DependentCounters);
1339   Dir->setDependentInits(Exprs.DependentInits);
1340   Dir->setFinalsConditions(Exprs.FinalsConditions);
1341   Dir->setPreInits(Exprs.PreInits);
1342   return Dir;
1343 }
1344 
1345 OMPParallelMasterTaskLoopSimdDirective *
1346 OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1347                                                     unsigned NumClauses,
1348                                                     unsigned CollapsedNum,
1349                                                     EmptyShell) {
1350   unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopSimdDirective),
1351                                 alignof(OMPClause *));
1352   void *Mem = C.Allocate(
1353       Size + sizeof(OMPClause *) * NumClauses +
1354       sizeof(Stmt *) *
1355           numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd));
1356   return new (Mem)
1357       OMPParallelMasterTaskLoopSimdDirective(CollapsedNum, NumClauses);
1358 }
1359 
1360 OMPDistributeDirective *OMPDistributeDirective::Create(
1361     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1362     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1363     const HelperExprs &Exprs) {
1364   unsigned Size =
1365       llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
1366   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1367                          sizeof(Stmt *) *
1368                              numLoopChildren(CollapsedNum, OMPD_distribute));
1369   OMPDistributeDirective *Dir = new (Mem)
1370       OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1371   Dir->setClauses(Clauses);
1372   Dir->setAssociatedStmt(AssociatedStmt);
1373   Dir->setIterationVariable(Exprs.IterationVarRef);
1374   Dir->setLastIteration(Exprs.LastIteration);
1375   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1376   Dir->setPreCond(Exprs.PreCond);
1377   Dir->setCond(Exprs.Cond);
1378   Dir->setInit(Exprs.Init);
1379   Dir->setInc(Exprs.Inc);
1380   Dir->setIsLastIterVariable(Exprs.IL);
1381   Dir->setLowerBoundVariable(Exprs.LB);
1382   Dir->setUpperBoundVariable(Exprs.UB);
1383   Dir->setStrideVariable(Exprs.ST);
1384   Dir->setEnsureUpperBound(Exprs.EUB);
1385   Dir->setNextLowerBound(Exprs.NLB);
1386   Dir->setNextUpperBound(Exprs.NUB);
1387   Dir->setNumIterations(Exprs.NumIterations);
1388   Dir->setCounters(Exprs.Counters);
1389   Dir->setPrivateCounters(Exprs.PrivateCounters);
1390   Dir->setInits(Exprs.Inits);
1391   Dir->setUpdates(Exprs.Updates);
1392   Dir->setFinals(Exprs.Finals);
1393   Dir->setDependentCounters(Exprs.DependentCounters);
1394   Dir->setDependentInits(Exprs.DependentInits);
1395   Dir->setFinalsConditions(Exprs.FinalsConditions);
1396   Dir->setPreInits(Exprs.PreInits);
1397   return Dir;
1398 }
1399 
1400 OMPDistributeDirective *
1401 OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1402                                     unsigned CollapsedNum, EmptyShell) {
1403   unsigned Size =
1404       llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
1405   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1406                          sizeof(Stmt *) *
1407                              numLoopChildren(CollapsedNum, OMPD_distribute));
1408   return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
1409 }
1410 
1411 OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
1412     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1413     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1414   unsigned Size =
1415       llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
1416   void *Mem =
1417       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1418   OMPTargetUpdateDirective *Dir =
1419       new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
1420   Dir->setClauses(Clauses);
1421   Dir->setAssociatedStmt(AssociatedStmt);
1422   return Dir;
1423 }
1424 
1425 OMPTargetUpdateDirective *
1426 OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1427                                       EmptyShell) {
1428   unsigned Size =
1429       llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
1430   void *Mem =
1431       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1432   return new (Mem) OMPTargetUpdateDirective(NumClauses);
1433 }
1434 
1435 OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1436     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1437     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1438     const HelperExprs &Exprs, bool HasCancel) {
1439   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
1440                                 alignof(OMPClause *));
1441   void *Mem = C.Allocate(
1442       Size + sizeof(OMPClause *) * Clauses.size() +
1443       sizeof(Stmt *) *
1444           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1445   OMPDistributeParallelForDirective *Dir =
1446       new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc,
1447                                                   CollapsedNum, Clauses.size());
1448   Dir->setClauses(Clauses);
1449   Dir->setAssociatedStmt(AssociatedStmt);
1450   Dir->setIterationVariable(Exprs.IterationVarRef);
1451   Dir->setLastIteration(Exprs.LastIteration);
1452   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1453   Dir->setPreCond(Exprs.PreCond);
1454   Dir->setCond(Exprs.Cond);
1455   Dir->setInit(Exprs.Init);
1456   Dir->setInc(Exprs.Inc);
1457   Dir->setIsLastIterVariable(Exprs.IL);
1458   Dir->setLowerBoundVariable(Exprs.LB);
1459   Dir->setUpperBoundVariable(Exprs.UB);
1460   Dir->setStrideVariable(Exprs.ST);
1461   Dir->setEnsureUpperBound(Exprs.EUB);
1462   Dir->setNextLowerBound(Exprs.NLB);
1463   Dir->setNextUpperBound(Exprs.NUB);
1464   Dir->setNumIterations(Exprs.NumIterations);
1465   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1466   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1467   Dir->setDistInc(Exprs.DistInc);
1468   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1469   Dir->setCounters(Exprs.Counters);
1470   Dir->setPrivateCounters(Exprs.PrivateCounters);
1471   Dir->setInits(Exprs.Inits);
1472   Dir->setUpdates(Exprs.Updates);
1473   Dir->setFinals(Exprs.Finals);
1474   Dir->setDependentCounters(Exprs.DependentCounters);
1475   Dir->setDependentInits(Exprs.DependentInits);
1476   Dir->setFinalsConditions(Exprs.FinalsConditions);
1477   Dir->setPreInits(Exprs.PreInits);
1478   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1479   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1480   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1481   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1482   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1483   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1484   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1485   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1486   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1487   Dir->HasCancel = HasCancel;
1488   return Dir;
1489 }
1490 
1491 OMPDistributeParallelForDirective *
1492 OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1493                                                unsigned NumClauses,
1494                                                unsigned CollapsedNum,
1495                                                EmptyShell) {
1496   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
1497                                 alignof(OMPClause *));
1498   void *Mem = C.Allocate(
1499       Size + sizeof(OMPClause *) * NumClauses +
1500       sizeof(Stmt *) *
1501           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1502   return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses);
1503 }
1504 
1505 OMPDistributeParallelForSimdDirective *
1506 OMPDistributeParallelForSimdDirective::Create(
1507     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1508     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1509     const HelperExprs &Exprs) {
1510   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
1511                                 alignof(OMPClause *));
1512   void *Mem = C.Allocate(
1513       Size + sizeof(OMPClause *) * Clauses.size() +
1514       sizeof(Stmt *) *
1515           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1516   OMPDistributeParallelForSimdDirective *Dir = new (Mem)
1517       OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1518                                             Clauses.size());
1519   Dir->setClauses(Clauses);
1520   Dir->setAssociatedStmt(AssociatedStmt);
1521   Dir->setIterationVariable(Exprs.IterationVarRef);
1522   Dir->setLastIteration(Exprs.LastIteration);
1523   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1524   Dir->setPreCond(Exprs.PreCond);
1525   Dir->setCond(Exprs.Cond);
1526   Dir->setInit(Exprs.Init);
1527   Dir->setInc(Exprs.Inc);
1528   Dir->setIsLastIterVariable(Exprs.IL);
1529   Dir->setLowerBoundVariable(Exprs.LB);
1530   Dir->setUpperBoundVariable(Exprs.UB);
1531   Dir->setStrideVariable(Exprs.ST);
1532   Dir->setEnsureUpperBound(Exprs.EUB);
1533   Dir->setNextLowerBound(Exprs.NLB);
1534   Dir->setNextUpperBound(Exprs.NUB);
1535   Dir->setNumIterations(Exprs.NumIterations);
1536   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1537   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1538   Dir->setDistInc(Exprs.DistInc);
1539   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1540   Dir->setCounters(Exprs.Counters);
1541   Dir->setPrivateCounters(Exprs.PrivateCounters);
1542   Dir->setInits(Exprs.Inits);
1543   Dir->setUpdates(Exprs.Updates);
1544   Dir->setFinals(Exprs.Finals);
1545   Dir->setDependentCounters(Exprs.DependentCounters);
1546   Dir->setDependentInits(Exprs.DependentInits);
1547   Dir->setFinalsConditions(Exprs.FinalsConditions);
1548   Dir->setPreInits(Exprs.PreInits);
1549   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1550   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1551   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1552   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1553   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1554   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1555   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1556   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1557   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1558   return Dir;
1559 }
1560 
1561 OMPDistributeParallelForSimdDirective *
1562 OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1563                                                    unsigned NumClauses,
1564                                                    unsigned CollapsedNum,
1565                                                    EmptyShell) {
1566   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
1567                                 alignof(OMPClause *));
1568   void *Mem = C.Allocate(
1569       Size + sizeof(OMPClause *) * NumClauses +
1570       sizeof(Stmt *) *
1571           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1572   return new (Mem)
1573       OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1574 }
1575 
1576 OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1577     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1578     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1579     const HelperExprs &Exprs) {
1580   unsigned Size =
1581       llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
1582   void *Mem = C.Allocate(
1583       Size + sizeof(OMPClause *) * Clauses.size() +
1584       sizeof(Stmt *) *
1585           numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1586   OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective(
1587       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1588   Dir->setClauses(Clauses);
1589   Dir->setAssociatedStmt(AssociatedStmt);
1590   Dir->setIterationVariable(Exprs.IterationVarRef);
1591   Dir->setLastIteration(Exprs.LastIteration);
1592   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1593   Dir->setPreCond(Exprs.PreCond);
1594   Dir->setCond(Exprs.Cond);
1595   Dir->setInit(Exprs.Init);
1596   Dir->setInc(Exprs.Inc);
1597   Dir->setIsLastIterVariable(Exprs.IL);
1598   Dir->setLowerBoundVariable(Exprs.LB);
1599   Dir->setUpperBoundVariable(Exprs.UB);
1600   Dir->setStrideVariable(Exprs.ST);
1601   Dir->setEnsureUpperBound(Exprs.EUB);
1602   Dir->setNextLowerBound(Exprs.NLB);
1603   Dir->setNextUpperBound(Exprs.NUB);
1604   Dir->setNumIterations(Exprs.NumIterations);
1605   Dir->setCounters(Exprs.Counters);
1606   Dir->setPrivateCounters(Exprs.PrivateCounters);
1607   Dir->setInits(Exprs.Inits);
1608   Dir->setUpdates(Exprs.Updates);
1609   Dir->setFinals(Exprs.Finals);
1610   Dir->setDependentCounters(Exprs.DependentCounters);
1611   Dir->setDependentInits(Exprs.DependentInits);
1612   Dir->setFinalsConditions(Exprs.FinalsConditions);
1613   Dir->setPreInits(Exprs.PreInits);
1614   return Dir;
1615 }
1616 
1617 OMPDistributeSimdDirective *
1618 OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1619                                         unsigned NumClauses,
1620                                         unsigned CollapsedNum, EmptyShell) {
1621   unsigned Size =
1622       llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
1623   void *Mem = C.Allocate(
1624       Size + sizeof(OMPClause *) * NumClauses +
1625       sizeof(Stmt *) *
1626           numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1627   return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses);
1628 }
1629 
1630 OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1631     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1632     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1633     const HelperExprs &Exprs) {
1634   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
1635                                 alignof(OMPClause *));
1636   void *Mem = C.Allocate(
1637       Size + sizeof(OMPClause *) * Clauses.size() +
1638       sizeof(Stmt *) *
1639           numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1640   OMPTargetParallelForSimdDirective *Dir =
1641       new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
1642                                                   CollapsedNum, Clauses.size());
1643   Dir->setClauses(Clauses);
1644   Dir->setAssociatedStmt(AssociatedStmt);
1645   Dir->setIterationVariable(Exprs.IterationVarRef);
1646   Dir->setLastIteration(Exprs.LastIteration);
1647   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1648   Dir->setPreCond(Exprs.PreCond);
1649   Dir->setCond(Exprs.Cond);
1650   Dir->setInit(Exprs.Init);
1651   Dir->setInc(Exprs.Inc);
1652   Dir->setIsLastIterVariable(Exprs.IL);
1653   Dir->setLowerBoundVariable(Exprs.LB);
1654   Dir->setUpperBoundVariable(Exprs.UB);
1655   Dir->setStrideVariable(Exprs.ST);
1656   Dir->setEnsureUpperBound(Exprs.EUB);
1657   Dir->setNextLowerBound(Exprs.NLB);
1658   Dir->setNextUpperBound(Exprs.NUB);
1659   Dir->setNumIterations(Exprs.NumIterations);
1660   Dir->setCounters(Exprs.Counters);
1661   Dir->setPrivateCounters(Exprs.PrivateCounters);
1662   Dir->setInits(Exprs.Inits);
1663   Dir->setUpdates(Exprs.Updates);
1664   Dir->setFinals(Exprs.Finals);
1665   Dir->setDependentCounters(Exprs.DependentCounters);
1666   Dir->setDependentInits(Exprs.DependentInits);
1667   Dir->setFinalsConditions(Exprs.FinalsConditions);
1668   Dir->setPreInits(Exprs.PreInits);
1669   return Dir;
1670 }
1671 
1672 OMPTargetParallelForSimdDirective *
1673 OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1674                                                unsigned NumClauses,
1675                                                unsigned CollapsedNum,
1676                                                EmptyShell) {
1677   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
1678                                 alignof(OMPClause *));
1679   void *Mem = C.Allocate(
1680       Size + sizeof(OMPClause *) * NumClauses +
1681       sizeof(Stmt *) *
1682           numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1683   return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
1684 }
1685 
1686 OMPTargetSimdDirective *
1687 OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1688                                SourceLocation EndLoc, unsigned CollapsedNum,
1689                                ArrayRef<OMPClause *> Clauses,
1690                                Stmt *AssociatedStmt, const HelperExprs &Exprs) {
1691   unsigned Size =
1692       llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
1693   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1694                          sizeof(Stmt *) *
1695                              numLoopChildren(CollapsedNum, OMPD_target_simd));
1696   OMPTargetSimdDirective *Dir = new (Mem)
1697       OMPTargetSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1698   Dir->setClauses(Clauses);
1699   Dir->setAssociatedStmt(AssociatedStmt);
1700   Dir->setIterationVariable(Exprs.IterationVarRef);
1701   Dir->setLastIteration(Exprs.LastIteration);
1702   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1703   Dir->setPreCond(Exprs.PreCond);
1704   Dir->setCond(Exprs.Cond);
1705   Dir->setInit(Exprs.Init);
1706   Dir->setInc(Exprs.Inc);
1707   Dir->setCounters(Exprs.Counters);
1708   Dir->setPrivateCounters(Exprs.PrivateCounters);
1709   Dir->setInits(Exprs.Inits);
1710   Dir->setUpdates(Exprs.Updates);
1711   Dir->setFinals(Exprs.Finals);
1712   Dir->setDependentCounters(Exprs.DependentCounters);
1713   Dir->setDependentInits(Exprs.DependentInits);
1714   Dir->setFinalsConditions(Exprs.FinalsConditions);
1715   Dir->setPreInits(Exprs.PreInits);
1716   return Dir;
1717 }
1718 
1719 OMPTargetSimdDirective *
1720 OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1721                                     unsigned CollapsedNum, EmptyShell) {
1722   unsigned Size =
1723       llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
1724   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1725                          sizeof(Stmt *) *
1726                              numLoopChildren(CollapsedNum, OMPD_target_simd));
1727   return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses);
1728 }
1729 
1730 OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
1731     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1732     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1733     const HelperExprs &Exprs) {
1734   unsigned Size =
1735       llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
1736   void *Mem = C.Allocate(
1737       Size + sizeof(OMPClause *) * Clauses.size() +
1738       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1739   OMPTeamsDistributeDirective *Dir = new (Mem) OMPTeamsDistributeDirective(
1740       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1741   Dir->setClauses(Clauses);
1742   Dir->setAssociatedStmt(AssociatedStmt);
1743   Dir->setIterationVariable(Exprs.IterationVarRef);
1744   Dir->setLastIteration(Exprs.LastIteration);
1745   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1746   Dir->setPreCond(Exprs.PreCond);
1747   Dir->setCond(Exprs.Cond);
1748   Dir->setInit(Exprs.Init);
1749   Dir->setInc(Exprs.Inc);
1750   Dir->setIsLastIterVariable(Exprs.IL);
1751   Dir->setLowerBoundVariable(Exprs.LB);
1752   Dir->setUpperBoundVariable(Exprs.UB);
1753   Dir->setStrideVariable(Exprs.ST);
1754   Dir->setEnsureUpperBound(Exprs.EUB);
1755   Dir->setNextLowerBound(Exprs.NLB);
1756   Dir->setNextUpperBound(Exprs.NUB);
1757   Dir->setNumIterations(Exprs.NumIterations);
1758   Dir->setCounters(Exprs.Counters);
1759   Dir->setPrivateCounters(Exprs.PrivateCounters);
1760   Dir->setInits(Exprs.Inits);
1761   Dir->setUpdates(Exprs.Updates);
1762   Dir->setFinals(Exprs.Finals);
1763   Dir->setDependentCounters(Exprs.DependentCounters);
1764   Dir->setDependentInits(Exprs.DependentInits);
1765   Dir->setFinalsConditions(Exprs.FinalsConditions);
1766   Dir->setPreInits(Exprs.PreInits);
1767   return Dir;
1768 }
1769 
1770 OMPTeamsDistributeDirective *
1771 OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1772                                          unsigned NumClauses,
1773                                          unsigned CollapsedNum, EmptyShell) {
1774   unsigned Size =
1775       llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
1776   void *Mem = C.Allocate(
1777       Size + sizeof(OMPClause *) * NumClauses +
1778       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1779   return new (Mem) OMPTeamsDistributeDirective(CollapsedNum, NumClauses);
1780 }
1781 
1782 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
1783     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1784     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1785     const HelperExprs &Exprs) {
1786   unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1787                                 alignof(OMPClause *));
1788   void *Mem =
1789       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1790                  sizeof(Stmt *) *
1791                      numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1792   OMPTeamsDistributeSimdDirective *Dir =
1793       new (Mem) OMPTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
1794                                                 Clauses.size());
1795   Dir->setClauses(Clauses);
1796   Dir->setAssociatedStmt(AssociatedStmt);
1797   Dir->setIterationVariable(Exprs.IterationVarRef);
1798   Dir->setLastIteration(Exprs.LastIteration);
1799   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1800   Dir->setPreCond(Exprs.PreCond);
1801   Dir->setCond(Exprs.Cond);
1802   Dir->setInit(Exprs.Init);
1803   Dir->setInc(Exprs.Inc);
1804   Dir->setIsLastIterVariable(Exprs.IL);
1805   Dir->setLowerBoundVariable(Exprs.LB);
1806   Dir->setUpperBoundVariable(Exprs.UB);
1807   Dir->setStrideVariable(Exprs.ST);
1808   Dir->setEnsureUpperBound(Exprs.EUB);
1809   Dir->setNextLowerBound(Exprs.NLB);
1810   Dir->setNextUpperBound(Exprs.NUB);
1811   Dir->setNumIterations(Exprs.NumIterations);
1812   Dir->setCounters(Exprs.Counters);
1813   Dir->setPrivateCounters(Exprs.PrivateCounters);
1814   Dir->setInits(Exprs.Inits);
1815   Dir->setUpdates(Exprs.Updates);
1816   Dir->setFinals(Exprs.Finals);
1817   Dir->setDependentCounters(Exprs.DependentCounters);
1818   Dir->setDependentInits(Exprs.DependentInits);
1819   Dir->setFinalsConditions(Exprs.FinalsConditions);
1820   Dir->setPreInits(Exprs.PreInits);
1821   return Dir;
1822 }
1823 
1824 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
1825     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1826     EmptyShell) {
1827   unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1828                                 alignof(OMPClause *));
1829   void *Mem =
1830       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1831                  sizeof(Stmt *) *
1832                      numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1833   return new (Mem) OMPTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
1834 }
1835 
1836 OMPTeamsDistributeParallelForSimdDirective *
1837 OMPTeamsDistributeParallelForSimdDirective::Create(
1838     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1839     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1840     const HelperExprs &Exprs) {
1841   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1842                             alignof(OMPClause *));
1843   void *Mem =
1844       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1845                  sizeof(Stmt *) *
1846                      numLoopChildren(CollapsedNum,
1847                                      OMPD_teams_distribute_parallel_for_simd));
1848   OMPTeamsDistributeParallelForSimdDirective *Dir = new (Mem)
1849       OMPTeamsDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1850                                                  Clauses.size());
1851   Dir->setClauses(Clauses);
1852   Dir->setAssociatedStmt(AssociatedStmt);
1853   Dir->setIterationVariable(Exprs.IterationVarRef);
1854   Dir->setLastIteration(Exprs.LastIteration);
1855   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1856   Dir->setPreCond(Exprs.PreCond);
1857   Dir->setCond(Exprs.Cond);
1858   Dir->setInit(Exprs.Init);
1859   Dir->setInc(Exprs.Inc);
1860   Dir->setIsLastIterVariable(Exprs.IL);
1861   Dir->setLowerBoundVariable(Exprs.LB);
1862   Dir->setUpperBoundVariable(Exprs.UB);
1863   Dir->setStrideVariable(Exprs.ST);
1864   Dir->setEnsureUpperBound(Exprs.EUB);
1865   Dir->setNextLowerBound(Exprs.NLB);
1866   Dir->setNextUpperBound(Exprs.NUB);
1867   Dir->setNumIterations(Exprs.NumIterations);
1868   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1869   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1870   Dir->setDistInc(Exprs.DistInc);
1871   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1872   Dir->setCounters(Exprs.Counters);
1873   Dir->setPrivateCounters(Exprs.PrivateCounters);
1874   Dir->setInits(Exprs.Inits);
1875   Dir->setUpdates(Exprs.Updates);
1876   Dir->setFinals(Exprs.Finals);
1877   Dir->setDependentCounters(Exprs.DependentCounters);
1878   Dir->setDependentInits(Exprs.DependentInits);
1879   Dir->setFinalsConditions(Exprs.FinalsConditions);
1880   Dir->setPreInits(Exprs.PreInits);
1881   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1882   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1883   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1884   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1885   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1886   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1887   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1888   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1889   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1890   return Dir;
1891 }
1892 
1893 OMPTeamsDistributeParallelForSimdDirective *
1894 OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1895                                                         unsigned NumClauses,
1896                                                         unsigned CollapsedNum,
1897                                                         EmptyShell) {
1898   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1899                             alignof(OMPClause *));
1900   void *Mem =
1901       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1902                  sizeof(Stmt *) *
1903                      numLoopChildren(CollapsedNum,
1904                                      OMPD_teams_distribute_parallel_for_simd));
1905   return new (Mem)
1906       OMPTeamsDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1907 }
1908 
1909 OMPTeamsDistributeParallelForDirective *
1910 OMPTeamsDistributeParallelForDirective::Create(
1911     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1912     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1913     const HelperExprs &Exprs, bool HasCancel) {
1914   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1915                             alignof(OMPClause *));
1916   void *Mem = C.Allocate(
1917       Size + sizeof(OMPClause *) * Clauses.size() +
1918       sizeof(Stmt *) *
1919           numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1920   OMPTeamsDistributeParallelForDirective *Dir = new (Mem)
1921       OMPTeamsDistributeParallelForDirective(StartLoc, EndLoc, CollapsedNum,
1922                                              Clauses.size());
1923   Dir->setClauses(Clauses);
1924   Dir->setAssociatedStmt(AssociatedStmt);
1925   Dir->setIterationVariable(Exprs.IterationVarRef);
1926   Dir->setLastIteration(Exprs.LastIteration);
1927   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1928   Dir->setPreCond(Exprs.PreCond);
1929   Dir->setCond(Exprs.Cond);
1930   Dir->setInit(Exprs.Init);
1931   Dir->setInc(Exprs.Inc);
1932   Dir->setIsLastIterVariable(Exprs.IL);
1933   Dir->setLowerBoundVariable(Exprs.LB);
1934   Dir->setUpperBoundVariable(Exprs.UB);
1935   Dir->setStrideVariable(Exprs.ST);
1936   Dir->setEnsureUpperBound(Exprs.EUB);
1937   Dir->setNextLowerBound(Exprs.NLB);
1938   Dir->setNextUpperBound(Exprs.NUB);
1939   Dir->setNumIterations(Exprs.NumIterations);
1940   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1941   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1942   Dir->setDistInc(Exprs.DistInc);
1943   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1944   Dir->setCounters(Exprs.Counters);
1945   Dir->setPrivateCounters(Exprs.PrivateCounters);
1946   Dir->setInits(Exprs.Inits);
1947   Dir->setUpdates(Exprs.Updates);
1948   Dir->setFinals(Exprs.Finals);
1949   Dir->setDependentCounters(Exprs.DependentCounters);
1950   Dir->setDependentInits(Exprs.DependentInits);
1951   Dir->setFinalsConditions(Exprs.FinalsConditions);
1952   Dir->setPreInits(Exprs.PreInits);
1953   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1954   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1955   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1956   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1957   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1958   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1959   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1960   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1961   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1962   Dir->HasCancel = HasCancel;
1963   return Dir;
1964 }
1965 
1966 OMPTeamsDistributeParallelForDirective *
1967 OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1968                                                     unsigned NumClauses,
1969                                                     unsigned CollapsedNum,
1970                                                     EmptyShell) {
1971   auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1972                             alignof(OMPClause *));
1973   void *Mem = C.Allocate(
1974       Size + sizeof(OMPClause *) * NumClauses +
1975       sizeof(Stmt *) *
1976           numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1977   return new (Mem)
1978       OMPTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
1979 }
1980 
1981 OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
1982     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1983     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1984   auto Size =
1985       llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
1986   void *Mem =
1987       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1988   OMPTargetTeamsDirective *Dir =
1989       new (Mem) OMPTargetTeamsDirective(StartLoc, EndLoc, Clauses.size());
1990   Dir->setClauses(Clauses);
1991   Dir->setAssociatedStmt(AssociatedStmt);
1992   return Dir;
1993 }
1994 
1995 OMPTargetTeamsDirective *
1996 OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1997                                      EmptyShell) {
1998   auto Size =
1999       llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
2000   void *Mem =
2001       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
2002   return new (Mem) OMPTargetTeamsDirective(NumClauses);
2003 }
2004 
2005 OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
2006     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2007     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2008     const HelperExprs &Exprs) {
2009   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
2010                             alignof(OMPClause *));
2011   void *Mem = C.Allocate(
2012       Size + sizeof(OMPClause *) * Clauses.size() +
2013       sizeof(Stmt *) *
2014           numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
2015   OMPTargetTeamsDistributeDirective *Dir =
2016       new (Mem) OMPTargetTeamsDistributeDirective(StartLoc, EndLoc, CollapsedNum,
2017                                                   Clauses.size());
2018   Dir->setClauses(Clauses);
2019   Dir->setAssociatedStmt(AssociatedStmt);
2020   Dir->setIterationVariable(Exprs.IterationVarRef);
2021   Dir->setLastIteration(Exprs.LastIteration);
2022   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2023   Dir->setPreCond(Exprs.PreCond);
2024   Dir->setCond(Exprs.Cond);
2025   Dir->setInit(Exprs.Init);
2026   Dir->setInc(Exprs.Inc);
2027   Dir->setIsLastIterVariable(Exprs.IL);
2028   Dir->setLowerBoundVariable(Exprs.LB);
2029   Dir->setUpperBoundVariable(Exprs.UB);
2030   Dir->setStrideVariable(Exprs.ST);
2031   Dir->setEnsureUpperBound(Exprs.EUB);
2032   Dir->setNextLowerBound(Exprs.NLB);
2033   Dir->setNextUpperBound(Exprs.NUB);
2034   Dir->setNumIterations(Exprs.NumIterations);
2035   Dir->setCounters(Exprs.Counters);
2036   Dir->setPrivateCounters(Exprs.PrivateCounters);
2037   Dir->setInits(Exprs.Inits);
2038   Dir->setUpdates(Exprs.Updates);
2039   Dir->setFinals(Exprs.Finals);
2040   Dir->setDependentCounters(Exprs.DependentCounters);
2041   Dir->setDependentInits(Exprs.DependentInits);
2042   Dir->setFinalsConditions(Exprs.FinalsConditions);
2043   Dir->setPreInits(Exprs.PreInits);
2044   return Dir;
2045 }
2046 
2047 OMPTargetTeamsDistributeDirective *
2048 OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
2049                                                unsigned NumClauses,
2050                                                unsigned CollapsedNum,
2051                                                EmptyShell) {
2052   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
2053                             alignof(OMPClause *));
2054   void *Mem = C.Allocate(
2055       Size + sizeof(OMPClause *) * NumClauses +
2056       sizeof(Stmt *) *
2057            numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
2058   return new (Mem) OMPTargetTeamsDistributeDirective(CollapsedNum, NumClauses);
2059 }
2060 
2061 OMPTargetTeamsDistributeParallelForDirective *
2062 OMPTargetTeamsDistributeParallelForDirective::Create(
2063     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2064     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2065     const HelperExprs &Exprs, bool HasCancel) {
2066   auto Size =
2067       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
2068                     alignof(OMPClause *));
2069   void *Mem = C.Allocate(
2070       Size + sizeof(OMPClause *) * Clauses.size() +
2071       sizeof(Stmt *) *
2072           numLoopChildren(CollapsedNum,
2073                           OMPD_target_teams_distribute_parallel_for));
2074   OMPTargetTeamsDistributeParallelForDirective *Dir =
2075       new (Mem) OMPTargetTeamsDistributeParallelForDirective(
2076            StartLoc, EndLoc, CollapsedNum, Clauses.size());
2077   Dir->setClauses(Clauses);
2078   Dir->setAssociatedStmt(AssociatedStmt);
2079   Dir->setIterationVariable(Exprs.IterationVarRef);
2080   Dir->setLastIteration(Exprs.LastIteration);
2081   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2082   Dir->setPreCond(Exprs.PreCond);
2083   Dir->setCond(Exprs.Cond);
2084   Dir->setInit(Exprs.Init);
2085   Dir->setInc(Exprs.Inc);
2086   Dir->setIsLastIterVariable(Exprs.IL);
2087   Dir->setLowerBoundVariable(Exprs.LB);
2088   Dir->setUpperBoundVariable(Exprs.UB);
2089   Dir->setStrideVariable(Exprs.ST);
2090   Dir->setEnsureUpperBound(Exprs.EUB);
2091   Dir->setNextLowerBound(Exprs.NLB);
2092   Dir->setNextUpperBound(Exprs.NUB);
2093   Dir->setNumIterations(Exprs.NumIterations);
2094   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
2095   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
2096   Dir->setDistInc(Exprs.DistInc);
2097   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
2098   Dir->setCounters(Exprs.Counters);
2099   Dir->setPrivateCounters(Exprs.PrivateCounters);
2100   Dir->setInits(Exprs.Inits);
2101   Dir->setUpdates(Exprs.Updates);
2102   Dir->setFinals(Exprs.Finals);
2103   Dir->setDependentCounters(Exprs.DependentCounters);
2104   Dir->setDependentInits(Exprs.DependentInits);
2105   Dir->setFinalsConditions(Exprs.FinalsConditions);
2106   Dir->setPreInits(Exprs.PreInits);
2107   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2108   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2109   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2110   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2111   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2112   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2113   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2114   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2115   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2116   Dir->HasCancel = HasCancel;
2117   return Dir;
2118 }
2119 
2120 OMPTargetTeamsDistributeParallelForDirective *
2121 OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
2122                                                           unsigned NumClauses,
2123                                                           unsigned CollapsedNum,
2124                                                           EmptyShell) {
2125   auto Size =
2126       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
2127                     alignof(OMPClause *));
2128   void *Mem = C.Allocate(
2129       Size + sizeof(OMPClause *) * NumClauses +
2130       sizeof(Stmt *) *
2131            numLoopChildren(CollapsedNum,
2132                            OMPD_target_teams_distribute_parallel_for));
2133   return new (Mem)
2134       OMPTargetTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
2135 }
2136 
2137 OMPTargetTeamsDistributeParallelForSimdDirective *
2138 OMPTargetTeamsDistributeParallelForSimdDirective::Create(
2139     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2140     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2141     const HelperExprs &Exprs) {
2142   auto Size =
2143       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
2144                     alignof(OMPClause *));
2145   void *Mem = C.Allocate(
2146       Size + sizeof(OMPClause *) * Clauses.size() +
2147       sizeof(Stmt *) *
2148           numLoopChildren(CollapsedNum,
2149                           OMPD_target_teams_distribute_parallel_for_simd));
2150   OMPTargetTeamsDistributeParallelForSimdDirective *Dir =
2151       new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
2152            StartLoc, EndLoc, CollapsedNum, Clauses.size());
2153   Dir->setClauses(Clauses);
2154   Dir->setAssociatedStmt(AssociatedStmt);
2155   Dir->setIterationVariable(Exprs.IterationVarRef);
2156   Dir->setLastIteration(Exprs.LastIteration);
2157   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2158   Dir->setPreCond(Exprs.PreCond);
2159   Dir->setCond(Exprs.Cond);
2160   Dir->setInit(Exprs.Init);
2161   Dir->setInc(Exprs.Inc);
2162   Dir->setIsLastIterVariable(Exprs.IL);
2163   Dir->setLowerBoundVariable(Exprs.LB);
2164   Dir->setUpperBoundVariable(Exprs.UB);
2165   Dir->setStrideVariable(Exprs.ST);
2166   Dir->setEnsureUpperBound(Exprs.EUB);
2167   Dir->setNextLowerBound(Exprs.NLB);
2168   Dir->setNextUpperBound(Exprs.NUB);
2169   Dir->setNumIterations(Exprs.NumIterations);
2170   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
2171   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
2172   Dir->setDistInc(Exprs.DistInc);
2173   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
2174   Dir->setCounters(Exprs.Counters);
2175   Dir->setPrivateCounters(Exprs.PrivateCounters);
2176   Dir->setInits(Exprs.Inits);
2177   Dir->setUpdates(Exprs.Updates);
2178   Dir->setFinals(Exprs.Finals);
2179   Dir->setDependentCounters(Exprs.DependentCounters);
2180   Dir->setDependentInits(Exprs.DependentInits);
2181   Dir->setFinalsConditions(Exprs.FinalsConditions);
2182   Dir->setPreInits(Exprs.PreInits);
2183   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2184   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2185   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2186   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2187   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2188   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2189   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2190   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2191   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2192   return Dir;
2193 }
2194 
2195 OMPTargetTeamsDistributeParallelForSimdDirective *
2196 OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
2197     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
2198     EmptyShell) {
2199   auto Size =
2200       llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
2201                     alignof(OMPClause *));
2202   void *Mem = C.Allocate(
2203       Size + sizeof(OMPClause *) * NumClauses +
2204       sizeof(Stmt *) *
2205           numLoopChildren(CollapsedNum,
2206                           OMPD_target_teams_distribute_parallel_for_simd));
2207   return new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
2208       CollapsedNum, NumClauses);
2209 }
2210 
2211 OMPTargetTeamsDistributeSimdDirective *
2212 OMPTargetTeamsDistributeSimdDirective::Create(
2213     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2214     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2215     const HelperExprs &Exprs) {
2216   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
2217                             alignof(OMPClause *));
2218   void *Mem = C.Allocate(
2219       Size + sizeof(OMPClause *) * Clauses.size() +
2220       sizeof(Stmt *) *
2221           numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
2222   OMPTargetTeamsDistributeSimdDirective *Dir = new (Mem)
2223       OMPTargetTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
2224                                             Clauses.size());
2225   Dir->setClauses(Clauses);
2226   Dir->setAssociatedStmt(AssociatedStmt);
2227   Dir->setIterationVariable(Exprs.IterationVarRef);
2228   Dir->setLastIteration(Exprs.LastIteration);
2229   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2230   Dir->setPreCond(Exprs.PreCond);
2231   Dir->setCond(Exprs.Cond);
2232   Dir->setInit(Exprs.Init);
2233   Dir->setInc(Exprs.Inc);
2234   Dir->setIsLastIterVariable(Exprs.IL);
2235   Dir->setLowerBoundVariable(Exprs.LB);
2236   Dir->setUpperBoundVariable(Exprs.UB);
2237   Dir->setStrideVariable(Exprs.ST);
2238   Dir->setEnsureUpperBound(Exprs.EUB);
2239   Dir->setNextLowerBound(Exprs.NLB);
2240   Dir->setNextUpperBound(Exprs.NUB);
2241   Dir->setNumIterations(Exprs.NumIterations);
2242   Dir->setCounters(Exprs.Counters);
2243   Dir->setPrivateCounters(Exprs.PrivateCounters);
2244   Dir->setInits(Exprs.Inits);
2245   Dir->setUpdates(Exprs.Updates);
2246   Dir->setFinals(Exprs.Finals);
2247   Dir->setDependentCounters(Exprs.DependentCounters);
2248   Dir->setDependentInits(Exprs.DependentInits);
2249   Dir->setFinalsConditions(Exprs.FinalsConditions);
2250   Dir->setPreInits(Exprs.PreInits);
2251   return Dir;
2252 }
2253 
2254 OMPTargetTeamsDistributeSimdDirective *
2255 OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
2256                                                    unsigned NumClauses,
2257                                                    unsigned CollapsedNum,
2258                                                    EmptyShell) {
2259   auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
2260                             alignof(OMPClause *));
2261   void *Mem = C.Allocate(
2262       Size + sizeof(OMPClause *) * NumClauses +
2263       sizeof(Stmt *) *
2264           numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
2265   return new (Mem)
2266       OMPTargetTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
2267 }
2268