1 //===--- OpenMPClause.cpp - Classes for OpenMP clauses --------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the subclesses of Stmt class declared in OpenMPClause.h
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/OpenMPClause.h"
15 
16 #include "clang/AST/ASTContext.h"
17 
18 using namespace clang;
19 
20 OMPClause::child_range OMPClause::children() {
21   switch (getClauseKind()) {
22   default:
23     break;
24 #define OPENMP_CLAUSE(Name, Class)                                             \
25   case OMPC_##Name:                                                            \
26     return static_cast<Class *>(this)->children();
27 #include "clang/Basic/OpenMPKinds.def"
28   }
29   llvm_unreachable("unknown OMPClause");
30 }
31 
32 OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) {
33   auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
34   return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
35 }
36 
37 const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
38   switch (C->getClauseKind()) {
39   case OMPC_schedule:
40     return static_cast<const OMPScheduleClause *>(C);
41   case OMPC_dist_schedule:
42     return static_cast<const OMPDistScheduleClause *>(C);
43   case OMPC_firstprivate:
44     return static_cast<const OMPFirstprivateClause *>(C);
45   case OMPC_lastprivate:
46     return static_cast<const OMPLastprivateClause *>(C);
47   case OMPC_reduction:
48     return static_cast<const OMPReductionClause *>(C);
49   case OMPC_default:
50   case OMPC_proc_bind:
51   case OMPC_if:
52   case OMPC_final:
53   case OMPC_num_threads:
54   case OMPC_safelen:
55   case OMPC_simdlen:
56   case OMPC_collapse:
57   case OMPC_private:
58   case OMPC_shared:
59   case OMPC_linear:
60   case OMPC_aligned:
61   case OMPC_copyin:
62   case OMPC_copyprivate:
63   case OMPC_ordered:
64   case OMPC_nowait:
65   case OMPC_untied:
66   case OMPC_mergeable:
67   case OMPC_threadprivate:
68   case OMPC_flush:
69   case OMPC_read:
70   case OMPC_write:
71   case OMPC_update:
72   case OMPC_capture:
73   case OMPC_seq_cst:
74   case OMPC_depend:
75   case OMPC_device:
76   case OMPC_threads:
77   case OMPC_simd:
78   case OMPC_map:
79   case OMPC_num_teams:
80   case OMPC_thread_limit:
81   case OMPC_priority:
82   case OMPC_grainsize:
83   case OMPC_nogroup:
84   case OMPC_num_tasks:
85   case OMPC_hint:
86   case OMPC_defaultmap:
87   case OMPC_unknown:
88     break;
89   }
90 
91   return nullptr;
92 }
93 
94 OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(OMPClause *C) {
95   auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
96   return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr;
97 }
98 
99 const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) {
100   switch (C->getClauseKind()) {
101   case OMPC_lastprivate:
102     return static_cast<const OMPLastprivateClause *>(C);
103   case OMPC_reduction:
104     return static_cast<const OMPReductionClause *>(C);
105   case OMPC_schedule:
106   case OMPC_dist_schedule:
107   case OMPC_firstprivate:
108   case OMPC_default:
109   case OMPC_proc_bind:
110   case OMPC_if:
111   case OMPC_final:
112   case OMPC_num_threads:
113   case OMPC_safelen:
114   case OMPC_simdlen:
115   case OMPC_collapse:
116   case OMPC_private:
117   case OMPC_shared:
118   case OMPC_linear:
119   case OMPC_aligned:
120   case OMPC_copyin:
121   case OMPC_copyprivate:
122   case OMPC_ordered:
123   case OMPC_nowait:
124   case OMPC_untied:
125   case OMPC_mergeable:
126   case OMPC_threadprivate:
127   case OMPC_flush:
128   case OMPC_read:
129   case OMPC_write:
130   case OMPC_update:
131   case OMPC_capture:
132   case OMPC_seq_cst:
133   case OMPC_depend:
134   case OMPC_device:
135   case OMPC_threads:
136   case OMPC_simd:
137   case OMPC_map:
138   case OMPC_num_teams:
139   case OMPC_thread_limit:
140   case OMPC_priority:
141   case OMPC_grainsize:
142   case OMPC_nogroup:
143   case OMPC_num_tasks:
144   case OMPC_hint:
145   case OMPC_defaultmap:
146   case OMPC_unknown:
147     break;
148   }
149 
150   return nullptr;
151 }
152 
153 void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
154   assert(VL.size() == varlist_size() &&
155          "Number of private copies is not the same as the preallocated buffer");
156   std::copy(VL.begin(), VL.end(), varlist_end());
157 }
158 
159 OMPPrivateClause *
160 OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
161                          SourceLocation LParenLoc, SourceLocation EndLoc,
162                          ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
163   // Allocate space for private variables and initializer expressions.
164   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
165   OMPPrivateClause *Clause =
166       new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
167   Clause->setVarRefs(VL);
168   Clause->setPrivateCopies(PrivateVL);
169   return Clause;
170 }
171 
172 OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C,
173                                                 unsigned N) {
174   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
175   return new (Mem) OMPPrivateClause(N);
176 }
177 
178 void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
179   assert(VL.size() == varlist_size() &&
180          "Number of private copies is not the same as the preallocated buffer");
181   std::copy(VL.begin(), VL.end(), varlist_end());
182 }
183 
184 void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
185   assert(VL.size() == varlist_size() &&
186          "Number of inits is not the same as the preallocated buffer");
187   std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
188 }
189 
190 OMPFirstprivateClause *
191 OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
192                               SourceLocation LParenLoc, SourceLocation EndLoc,
193                               ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
194                               ArrayRef<Expr *> InitVL, Stmt *PreInit) {
195   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
196   OMPFirstprivateClause *Clause =
197       new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
198   Clause->setVarRefs(VL);
199   Clause->setPrivateCopies(PrivateVL);
200   Clause->setInits(InitVL);
201   Clause->setPreInitStmt(PreInit);
202   return Clause;
203 }
204 
205 OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C,
206                                                           unsigned N) {
207   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
208   return new (Mem) OMPFirstprivateClause(N);
209 }
210 
211 void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) {
212   assert(PrivateCopies.size() == varlist_size() &&
213          "Number of private copies is not the same as the preallocated buffer");
214   std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
215 }
216 
217 void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
218   assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
219                                               "not the same as the "
220                                               "preallocated buffer");
221   std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
222 }
223 
224 void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
225   assert(DstExprs.size() == varlist_size() && "Number of destination "
226                                               "expressions is not the same as "
227                                               "the preallocated buffer");
228   std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
229 }
230 
231 void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
232   assert(AssignmentOps.size() == varlist_size() &&
233          "Number of assignment expressions is not the same as the preallocated "
234          "buffer");
235   std::copy(AssignmentOps.begin(), AssignmentOps.end(),
236             getDestinationExprs().end());
237 }
238 
239 OMPLastprivateClause *OMPLastprivateClause::Create(
240     const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
241     SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
242     ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, Stmt *PreInit,
243     Expr *PostUpdate) {
244   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
245   OMPLastprivateClause *Clause =
246       new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
247   Clause->setVarRefs(VL);
248   Clause->setSourceExprs(SrcExprs);
249   Clause->setDestinationExprs(DstExprs);
250   Clause->setAssignmentOps(AssignmentOps);
251   Clause->setPreInitStmt(PreInit);
252   Clause->setPostUpdateExpr(PostUpdate);
253   return Clause;
254 }
255 
256 OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C,
257                                                         unsigned N) {
258   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
259   return new (Mem) OMPLastprivateClause(N);
260 }
261 
262 OMPSharedClause *OMPSharedClause::Create(const ASTContext &C,
263                                          SourceLocation StartLoc,
264                                          SourceLocation LParenLoc,
265                                          SourceLocation EndLoc,
266                                          ArrayRef<Expr *> VL) {
267   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
268   OMPSharedClause *Clause =
269       new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
270   Clause->setVarRefs(VL);
271   return Clause;
272 }
273 
274 OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) {
275   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
276   return new (Mem) OMPSharedClause(N);
277 }
278 
279 void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) {
280   assert(PL.size() == varlist_size() &&
281          "Number of privates is not the same as the preallocated buffer");
282   std::copy(PL.begin(), PL.end(), varlist_end());
283 }
284 
285 void OMPLinearClause::setInits(ArrayRef<Expr *> IL) {
286   assert(IL.size() == varlist_size() &&
287          "Number of inits is not the same as the preallocated buffer");
288   std::copy(IL.begin(), IL.end(), getPrivates().end());
289 }
290 
291 void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) {
292   assert(UL.size() == varlist_size() &&
293          "Number of updates is not the same as the preallocated buffer");
294   std::copy(UL.begin(), UL.end(), getInits().end());
295 }
296 
297 void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) {
298   assert(FL.size() == varlist_size() &&
299          "Number of final updates is not the same as the preallocated buffer");
300   std::copy(FL.begin(), FL.end(), getUpdates().end());
301 }
302 
303 OMPLinearClause *OMPLinearClause::Create(
304     const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
305     OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
306     SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
307     ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep) {
308   // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
309   // (Step and CalcStep).
310   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
311   OMPLinearClause *Clause = new (Mem) OMPLinearClause(
312       StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
313   Clause->setVarRefs(VL);
314   Clause->setPrivates(PL);
315   Clause->setInits(IL);
316   // Fill update and final expressions with zeroes, they are provided later,
317   // after the directive construction.
318   std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
319             nullptr);
320   std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
321             nullptr);
322   Clause->setStep(Step);
323   Clause->setCalcStep(CalcStep);
324   return Clause;
325 }
326 
327 OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C,
328                                               unsigned NumVars) {
329   // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
330   // (Step and CalcStep).
331   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
332   return new (Mem) OMPLinearClause(NumVars);
333 }
334 
335 OMPAlignedClause *
336 OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc,
337                          SourceLocation LParenLoc, SourceLocation ColonLoc,
338                          SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
339   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
340   OMPAlignedClause *Clause = new (Mem)
341       OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
342   Clause->setVarRefs(VL);
343   Clause->setAlignment(A);
344   return Clause;
345 }
346 
347 OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C,
348                                                 unsigned NumVars) {
349   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
350   return new (Mem) OMPAlignedClause(NumVars);
351 }
352 
353 void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
354   assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
355                                               "not the same as the "
356                                               "preallocated buffer");
357   std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
358 }
359 
360 void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
361   assert(DstExprs.size() == varlist_size() && "Number of destination "
362                                               "expressions is not the same as "
363                                               "the preallocated buffer");
364   std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
365 }
366 
367 void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
368   assert(AssignmentOps.size() == varlist_size() &&
369          "Number of assignment expressions is not the same as the preallocated "
370          "buffer");
371   std::copy(AssignmentOps.begin(), AssignmentOps.end(),
372             getDestinationExprs().end());
373 }
374 
375 OMPCopyinClause *OMPCopyinClause::Create(
376     const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
377     SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
378     ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
379   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
380   OMPCopyinClause *Clause =
381       new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
382   Clause->setVarRefs(VL);
383   Clause->setSourceExprs(SrcExprs);
384   Clause->setDestinationExprs(DstExprs);
385   Clause->setAssignmentOps(AssignmentOps);
386   return Clause;
387 }
388 
389 OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) {
390   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
391   return new (Mem) OMPCopyinClause(N);
392 }
393 
394 void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
395   assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
396                                               "not the same as the "
397                                               "preallocated buffer");
398   std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
399 }
400 
401 void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
402   assert(DstExprs.size() == varlist_size() && "Number of destination "
403                                               "expressions is not the same as "
404                                               "the preallocated buffer");
405   std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
406 }
407 
408 void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
409   assert(AssignmentOps.size() == varlist_size() &&
410          "Number of assignment expressions is not the same as the preallocated "
411          "buffer");
412   std::copy(AssignmentOps.begin(), AssignmentOps.end(),
413             getDestinationExprs().end());
414 }
415 
416 OMPCopyprivateClause *OMPCopyprivateClause::Create(
417     const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
418     SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
419     ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
420   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
421   OMPCopyprivateClause *Clause =
422       new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
423   Clause->setVarRefs(VL);
424   Clause->setSourceExprs(SrcExprs);
425   Clause->setDestinationExprs(DstExprs);
426   Clause->setAssignmentOps(AssignmentOps);
427   return Clause;
428 }
429 
430 OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C,
431                                                         unsigned N) {
432   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
433   return new (Mem) OMPCopyprivateClause(N);
434 }
435 
436 void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
437   assert(Privates.size() == varlist_size() &&
438          "Number of private copies is not the same as the preallocated buffer");
439   std::copy(Privates.begin(), Privates.end(), varlist_end());
440 }
441 
442 void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
443   assert(
444       LHSExprs.size() == varlist_size() &&
445       "Number of LHS expressions is not the same as the preallocated buffer");
446   std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
447 }
448 
449 void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
450   assert(
451       RHSExprs.size() == varlist_size() &&
452       "Number of RHS expressions is not the same as the preallocated buffer");
453   std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
454 }
455 
456 void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
457   assert(ReductionOps.size() == varlist_size() && "Number of reduction "
458                                                   "expressions is not the same "
459                                                   "as the preallocated buffer");
460   std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
461 }
462 
463 OMPReductionClause *OMPReductionClause::Create(
464     const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
465     SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
466     NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
467     ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
468     ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
469     Expr *PostUpdate) {
470   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
471   OMPReductionClause *Clause = new (Mem) OMPReductionClause(
472       StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
473   Clause->setVarRefs(VL);
474   Clause->setPrivates(Privates);
475   Clause->setLHSExprs(LHSExprs);
476   Clause->setRHSExprs(RHSExprs);
477   Clause->setReductionOps(ReductionOps);
478   Clause->setPreInitStmt(PreInit);
479   Clause->setPostUpdateExpr(PostUpdate);
480   return Clause;
481 }
482 
483 OMPReductionClause *OMPReductionClause::CreateEmpty(const ASTContext &C,
484                                                     unsigned N) {
485   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
486   return new (Mem) OMPReductionClause(N);
487 }
488 
489 OMPFlushClause *OMPFlushClause::Create(const ASTContext &C,
490                                        SourceLocation StartLoc,
491                                        SourceLocation LParenLoc,
492                                        SourceLocation EndLoc,
493                                        ArrayRef<Expr *> VL) {
494   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
495   OMPFlushClause *Clause =
496       new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
497   Clause->setVarRefs(VL);
498   return Clause;
499 }
500 
501 OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) {
502   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
503   return new (Mem) OMPFlushClause(N);
504 }
505 
506 OMPDependClause *
507 OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc,
508                         SourceLocation LParenLoc, SourceLocation EndLoc,
509                         OpenMPDependClauseKind DepKind, SourceLocation DepLoc,
510                         SourceLocation ColonLoc, ArrayRef<Expr *> VL) {
511   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
512   OMPDependClause *Clause =
513       new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size());
514   Clause->setVarRefs(VL);
515   Clause->setDependencyKind(DepKind);
516   Clause->setDependencyLoc(DepLoc);
517   Clause->setColonLoc(ColonLoc);
518   return Clause;
519 }
520 
521 OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N) {
522   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
523   return new (Mem) OMPDependClause(N);
524 }
525 
526 OMPMapClause *OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc,
527                                    SourceLocation LParenLoc,
528                                    SourceLocation EndLoc, ArrayRef<Expr *> VL,
529                                    OpenMPMapClauseKind TypeModifier,
530                                    OpenMPMapClauseKind Type,
531                                    bool TypeIsImplicit,
532                                    SourceLocation TypeLoc) {
533   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
534   OMPMapClause *Clause =
535       new (Mem) OMPMapClause(TypeModifier, Type, TypeIsImplicit, TypeLoc,
536                              StartLoc, LParenLoc, EndLoc, VL.size());
537   Clause->setVarRefs(VL);
538   Clause->setMapTypeModifier(TypeModifier);
539   Clause->setMapType(Type);
540   Clause->setMapLoc(TypeLoc);
541   return Clause;
542 }
543 
544 OMPMapClause *OMPMapClause::CreateEmpty(const ASTContext &C, unsigned N) {
545   void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
546   return new (Mem) OMPMapClause(N);
547 }
548