blob: 284ef81e80df5b249dfe420d98ffde27a5eeeb1b [file] [log] [blame]
James Y Knightb8bfd962015-10-02 13:41:04 +00001//===--- 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
18using namespace clang;
19
20OMPClause::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
Alexey Bataev3392d762016-02-16 11:18:12 +000032OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) {
33 auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
34 return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
35}
36
37const 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_default:
44 case OMPC_proc_bind:
45 case OMPC_if:
46 case OMPC_final:
47 case OMPC_num_threads:
48 case OMPC_safelen:
49 case OMPC_simdlen:
50 case OMPC_collapse:
51 case OMPC_private:
52 case OMPC_firstprivate:
53 case OMPC_lastprivate:
54 case OMPC_shared:
55 case OMPC_reduction:
56 case OMPC_linear:
57 case OMPC_aligned:
58 case OMPC_copyin:
59 case OMPC_copyprivate:
60 case OMPC_ordered:
61 case OMPC_nowait:
62 case OMPC_untied:
63 case OMPC_mergeable:
64 case OMPC_threadprivate:
65 case OMPC_flush:
66 case OMPC_read:
67 case OMPC_write:
68 case OMPC_update:
69 case OMPC_capture:
70 case OMPC_seq_cst:
71 case OMPC_depend:
72 case OMPC_device:
73 case OMPC_threads:
74 case OMPC_simd:
75 case OMPC_map:
76 case OMPC_num_teams:
77 case OMPC_thread_limit:
78 case OMPC_priority:
79 case OMPC_grainsize:
80 case OMPC_nogroup:
81 case OMPC_num_tasks:
82 case OMPC_hint:
83 case OMPC_defaultmap:
84 case OMPC_unknown:
85 break;
86 }
87
88 return nullptr;
89}
90
James Y Knightb8bfd962015-10-02 13:41:04 +000091void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
92 assert(VL.size() == varlist_size() &&
93 "Number of private copies is not the same as the preallocated buffer");
94 std::copy(VL.begin(), VL.end(), varlist_end());
95}
96
97OMPPrivateClause *
98OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
99 SourceLocation LParenLoc, SourceLocation EndLoc,
100 ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
101 // Allocate space for private variables and initializer expressions.
James Y Knight374fd202016-01-01 00:38:24 +0000102 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
James Y Knightb8bfd962015-10-02 13:41:04 +0000103 OMPPrivateClause *Clause =
104 new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
105 Clause->setVarRefs(VL);
106 Clause->setPrivateCopies(PrivateVL);
107 return Clause;
108}
109
110OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C,
111 unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000112 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
James Y Knightb8bfd962015-10-02 13:41:04 +0000113 return new (Mem) OMPPrivateClause(N);
114}
115
116void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
117 assert(VL.size() == varlist_size() &&
118 "Number of private copies is not the same as the preallocated buffer");
119 std::copy(VL.begin(), VL.end(), varlist_end());
120}
121
122void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
123 assert(VL.size() == varlist_size() &&
124 "Number of inits is not the same as the preallocated buffer");
125 std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
126}
127
128OMPFirstprivateClause *
129OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
130 SourceLocation LParenLoc, SourceLocation EndLoc,
131 ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
132 ArrayRef<Expr *> InitVL) {
James Y Knight374fd202016-01-01 00:38:24 +0000133 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
James Y Knightb8bfd962015-10-02 13:41:04 +0000134 OMPFirstprivateClause *Clause =
135 new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
136 Clause->setVarRefs(VL);
137 Clause->setPrivateCopies(PrivateVL);
138 Clause->setInits(InitVL);
139 return Clause;
140}
141
142OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C,
143 unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000144 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
James Y Knightb8bfd962015-10-02 13:41:04 +0000145 return new (Mem) OMPFirstprivateClause(N);
146}
147
148void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) {
149 assert(PrivateCopies.size() == varlist_size() &&
150 "Number of private copies is not the same as the preallocated buffer");
151 std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
152}
153
154void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
155 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
156 "not the same as the "
157 "preallocated buffer");
158 std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
159}
160
161void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
162 assert(DstExprs.size() == varlist_size() && "Number of destination "
163 "expressions is not the same as "
164 "the preallocated buffer");
165 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
166}
167
168void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
169 assert(AssignmentOps.size() == varlist_size() &&
170 "Number of assignment expressions is not the same as the preallocated "
171 "buffer");
172 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
173 getDestinationExprs().end());
174}
175
176OMPLastprivateClause *OMPLastprivateClause::Create(
177 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
178 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
179 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
James Y Knight374fd202016-01-01 00:38:24 +0000180 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
James Y Knightb8bfd962015-10-02 13:41:04 +0000181 OMPLastprivateClause *Clause =
182 new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
183 Clause->setVarRefs(VL);
184 Clause->setSourceExprs(SrcExprs);
185 Clause->setDestinationExprs(DstExprs);
186 Clause->setAssignmentOps(AssignmentOps);
187 return Clause;
188}
189
190OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C,
191 unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000192 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
James Y Knightb8bfd962015-10-02 13:41:04 +0000193 return new (Mem) OMPLastprivateClause(N);
194}
195
196OMPSharedClause *OMPSharedClause::Create(const ASTContext &C,
197 SourceLocation StartLoc,
198 SourceLocation LParenLoc,
199 SourceLocation EndLoc,
200 ArrayRef<Expr *> VL) {
James Y Knight374fd202016-01-01 00:38:24 +0000201 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
James Y Knightb8bfd962015-10-02 13:41:04 +0000202 OMPSharedClause *Clause =
203 new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
204 Clause->setVarRefs(VL);
205 return Clause;
206}
207
208OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000209 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
James Y Knightb8bfd962015-10-02 13:41:04 +0000210 return new (Mem) OMPSharedClause(N);
211}
212
213void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) {
214 assert(PL.size() == varlist_size() &&
215 "Number of privates is not the same as the preallocated buffer");
216 std::copy(PL.begin(), PL.end(), varlist_end());
217}
218
219void OMPLinearClause::setInits(ArrayRef<Expr *> IL) {
220 assert(IL.size() == varlist_size() &&
221 "Number of inits is not the same as the preallocated buffer");
222 std::copy(IL.begin(), IL.end(), getPrivates().end());
223}
224
225void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) {
226 assert(UL.size() == varlist_size() &&
227 "Number of updates is not the same as the preallocated buffer");
228 std::copy(UL.begin(), UL.end(), getInits().end());
229}
230
231void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) {
232 assert(FL.size() == varlist_size() &&
233 "Number of final updates is not the same as the preallocated buffer");
234 std::copy(FL.begin(), FL.end(), getUpdates().end());
235}
236
237OMPLinearClause *OMPLinearClause::Create(
238 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
239 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
240 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
241 ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep) {
242 // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
243 // (Step and CalcStep).
James Y Knight374fd202016-01-01 00:38:24 +0000244 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
James Y Knightb8bfd962015-10-02 13:41:04 +0000245 OMPLinearClause *Clause = new (Mem) OMPLinearClause(
246 StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
247 Clause->setVarRefs(VL);
248 Clause->setPrivates(PL);
249 Clause->setInits(IL);
250 // Fill update and final expressions with zeroes, they are provided later,
251 // after the directive construction.
252 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
253 nullptr);
254 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
255 nullptr);
256 Clause->setStep(Step);
257 Clause->setCalcStep(CalcStep);
258 return Clause;
259}
260
261OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C,
262 unsigned NumVars) {
263 // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
264 // (Step and CalcStep).
James Y Knight374fd202016-01-01 00:38:24 +0000265 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
James Y Knightb8bfd962015-10-02 13:41:04 +0000266 return new (Mem) OMPLinearClause(NumVars);
267}
268
269OMPAlignedClause *
270OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc,
271 SourceLocation LParenLoc, SourceLocation ColonLoc,
272 SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
James Y Knight374fd202016-01-01 00:38:24 +0000273 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
James Y Knightb8bfd962015-10-02 13:41:04 +0000274 OMPAlignedClause *Clause = new (Mem)
275 OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
276 Clause->setVarRefs(VL);
277 Clause->setAlignment(A);
278 return Clause;
279}
280
281OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C,
282 unsigned NumVars) {
James Y Knight374fd202016-01-01 00:38:24 +0000283 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
James Y Knightb8bfd962015-10-02 13:41:04 +0000284 return new (Mem) OMPAlignedClause(NumVars);
285}
286
287void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
288 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
289 "not the same as the "
290 "preallocated buffer");
291 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
292}
293
294void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
295 assert(DstExprs.size() == varlist_size() && "Number of destination "
296 "expressions is not the same as "
297 "the preallocated buffer");
298 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
299}
300
301void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
302 assert(AssignmentOps.size() == varlist_size() &&
303 "Number of assignment expressions is not the same as the preallocated "
304 "buffer");
305 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
306 getDestinationExprs().end());
307}
308
309OMPCopyinClause *OMPCopyinClause::Create(
310 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
311 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
312 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
James Y Knight374fd202016-01-01 00:38:24 +0000313 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
James Y Knightb8bfd962015-10-02 13:41:04 +0000314 OMPCopyinClause *Clause =
315 new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
316 Clause->setVarRefs(VL);
317 Clause->setSourceExprs(SrcExprs);
318 Clause->setDestinationExprs(DstExprs);
319 Clause->setAssignmentOps(AssignmentOps);
320 return Clause;
321}
322
323OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000324 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
James Y Knightb8bfd962015-10-02 13:41:04 +0000325 return new (Mem) OMPCopyinClause(N);
326}
327
328void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
329 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
330 "not the same as the "
331 "preallocated buffer");
332 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
333}
334
335void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
336 assert(DstExprs.size() == varlist_size() && "Number of destination "
337 "expressions is not the same as "
338 "the preallocated buffer");
339 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
340}
341
342void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
343 assert(AssignmentOps.size() == varlist_size() &&
344 "Number of assignment expressions is not the same as the preallocated "
345 "buffer");
346 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
347 getDestinationExprs().end());
348}
349
350OMPCopyprivateClause *OMPCopyprivateClause::Create(
351 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
352 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
353 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
James Y Knight374fd202016-01-01 00:38:24 +0000354 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
James Y Knightb8bfd962015-10-02 13:41:04 +0000355 OMPCopyprivateClause *Clause =
356 new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
357 Clause->setVarRefs(VL);
358 Clause->setSourceExprs(SrcExprs);
359 Clause->setDestinationExprs(DstExprs);
360 Clause->setAssignmentOps(AssignmentOps);
361 return Clause;
362}
363
364OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C,
365 unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000366 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
James Y Knightb8bfd962015-10-02 13:41:04 +0000367 return new (Mem) OMPCopyprivateClause(N);
368}
369
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000370void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
371 assert(Privates.size() == varlist_size() &&
372 "Number of private copies is not the same as the preallocated buffer");
373 std::copy(Privates.begin(), Privates.end(), varlist_end());
374}
375
James Y Knightb8bfd962015-10-02 13:41:04 +0000376void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
377 assert(
378 LHSExprs.size() == varlist_size() &&
379 "Number of LHS expressions is not the same as the preallocated buffer");
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000380 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
James Y Knightb8bfd962015-10-02 13:41:04 +0000381}
382
383void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
384 assert(
385 RHSExprs.size() == varlist_size() &&
386 "Number of RHS expressions is not the same as the preallocated buffer");
387 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
388}
389
390void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
391 assert(ReductionOps.size() == varlist_size() && "Number of reduction "
392 "expressions is not the same "
393 "as the preallocated buffer");
394 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
395}
396
397OMPReductionClause *OMPReductionClause::Create(
398 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
399 SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
400 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000401 ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
402 ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps) {
James Y Knight374fd202016-01-01 00:38:24 +0000403 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
James Y Knightb8bfd962015-10-02 13:41:04 +0000404 OMPReductionClause *Clause = new (Mem) OMPReductionClause(
405 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
406 Clause->setVarRefs(VL);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000407 Clause->setPrivates(Privates);
James Y Knightb8bfd962015-10-02 13:41:04 +0000408 Clause->setLHSExprs(LHSExprs);
409 Clause->setRHSExprs(RHSExprs);
410 Clause->setReductionOps(ReductionOps);
411 return Clause;
412}
413
414OMPReductionClause *OMPReductionClause::CreateEmpty(const ASTContext &C,
415 unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000416 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
James Y Knightb8bfd962015-10-02 13:41:04 +0000417 return new (Mem) OMPReductionClause(N);
418}
419
420OMPFlushClause *OMPFlushClause::Create(const ASTContext &C,
421 SourceLocation StartLoc,
422 SourceLocation LParenLoc,
423 SourceLocation EndLoc,
424 ArrayRef<Expr *> VL) {
James Y Knight374fd202016-01-01 00:38:24 +0000425 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
James Y Knightb8bfd962015-10-02 13:41:04 +0000426 OMPFlushClause *Clause =
427 new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
428 Clause->setVarRefs(VL);
429 return Clause;
430}
431
432OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000433 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
James Y Knightb8bfd962015-10-02 13:41:04 +0000434 return new (Mem) OMPFlushClause(N);
435}
436
437OMPDependClause *
438OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc,
439 SourceLocation LParenLoc, SourceLocation EndLoc,
440 OpenMPDependClauseKind DepKind, SourceLocation DepLoc,
441 SourceLocation ColonLoc, ArrayRef<Expr *> VL) {
James Y Knight374fd202016-01-01 00:38:24 +0000442 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
James Y Knightb8bfd962015-10-02 13:41:04 +0000443 OMPDependClause *Clause =
444 new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size());
445 Clause->setVarRefs(VL);
446 Clause->setDependencyKind(DepKind);
447 Clause->setDependencyLoc(DepLoc);
448 Clause->setColonLoc(ColonLoc);
449 return Clause;
450}
451
452OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000453 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
James Y Knightb8bfd962015-10-02 13:41:04 +0000454 return new (Mem) OMPDependClause(N);
455}
Kelvin Li0bff7af2015-11-23 05:32:03 +0000456
457OMPMapClause *OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc,
458 SourceLocation LParenLoc,
459 SourceLocation EndLoc, ArrayRef<Expr *> VL,
460 OpenMPMapClauseKind TypeModifier,
461 OpenMPMapClauseKind Type,
Samuel Antao23abd722016-01-19 20:40:49 +0000462 bool TypeIsImplicit,
Kelvin Li0bff7af2015-11-23 05:32:03 +0000463 SourceLocation TypeLoc) {
James Y Knight374fd202016-01-01 00:38:24 +0000464 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
Samuel Antao23abd722016-01-19 20:40:49 +0000465 OMPMapClause *Clause =
466 new (Mem) OMPMapClause(TypeModifier, Type, TypeIsImplicit, TypeLoc,
467 StartLoc, LParenLoc, EndLoc, VL.size());
Kelvin Li0bff7af2015-11-23 05:32:03 +0000468 Clause->setVarRefs(VL);
469 Clause->setMapTypeModifier(TypeModifier);
470 Clause->setMapType(Type);
471 Clause->setMapLoc(TypeLoc);
472 return Clause;
473}
474
475OMPMapClause *OMPMapClause::CreateEmpty(const ASTContext &C, unsigned N) {
James Y Knight374fd202016-01-01 00:38:24 +0000476 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
Kelvin Li0bff7af2015-11-23 05:32:03 +0000477 return new (Mem) OMPMapClause(N);
478}