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