Clang Project

clang_source_code/lib/AST/OpenMPClause.cpp
1//===- OpenMPClause.cpp - Classes for OpenMP clauses ----------------------===//
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 OpenMPClause.h
10//
11//===----------------------------------------------------------------------===//
12
13#include "clang/AST/OpenMPClause.h"
14#include "clang/AST/ASTContext.h"
15#include "clang/AST/Decl.h"
16#include "clang/AST/DeclOpenMP.h"
17#include "clang/Basic/LLVM.h"
18#include "llvm/ADT/SmallPtrSet.h"
19#include "llvm/Support/Casting.h"
20#include "llvm/Support/ErrorHandling.h"
21#include <algorithm>
22#include <cassert>
23
24using namespace clang;
25
26OMPClause::child_range OMPClause::children() {
27  switch (getClauseKind()) {
28  default:
29    break;
30#define OPENMP_CLAUSE(Name, Class)                                             \
31  case OMPC_##Name:                                                            \
32    return static_cast<Class *>(this)->children();
33#include "clang/Basic/OpenMPKinds.def"
34  }
35  llvm_unreachable("unknown OMPClause");
36}
37
38OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) {
39  auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
40  return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
41}
42
43const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
44  switch (C->getClauseKind()) {
45  case OMPC_schedule:
46    return static_cast<const OMPScheduleClause *>(C);
47  case OMPC_dist_schedule:
48    return static_cast<const OMPDistScheduleClause *>(C);
49  case OMPC_firstprivate:
50    return static_cast<const OMPFirstprivateClause *>(C);
51  case OMPC_lastprivate:
52    return static_cast<const OMPLastprivateClause *>(C);
53  case OMPC_reduction:
54    return static_cast<const OMPReductionClause *>(C);
55  case OMPC_task_reduction:
56    return static_cast<const OMPTaskReductionClause *>(C);
57  case OMPC_in_reduction:
58    return static_cast<const OMPInReductionClause *>(C);
59  case OMPC_linear:
60    return static_cast<const OMPLinearClause *>(C);
61  case OMPC_if:
62    return static_cast<const OMPIfClause *>(C);
63  case OMPC_num_threads:
64    return static_cast<const OMPNumThreadsClause *>(C);
65  case OMPC_num_teams:
66    return static_cast<const OMPNumTeamsClause *>(C);
67  case OMPC_thread_limit:
68    return static_cast<const OMPThreadLimitClause *>(C);
69  case OMPC_device:
70    return static_cast<const OMPDeviceClause *>(C);
71  case OMPC_default:
72  case OMPC_proc_bind:
73  case OMPC_final:
74  case OMPC_safelen:
75  case OMPC_simdlen:
76  case OMPC_allocator:
77  case OMPC_allocate:
78  case OMPC_collapse:
79  case OMPC_private:
80  case OMPC_shared:
81  case OMPC_aligned:
82  case OMPC_copyin:
83  case OMPC_copyprivate:
84  case OMPC_ordered:
85  case OMPC_nowait:
86  case OMPC_untied:
87  case OMPC_mergeable:
88  case OMPC_threadprivate:
89  case OMPC_flush:
90  case OMPC_read:
91  case OMPC_write:
92  case OMPC_update:
93  case OMPC_capture:
94  case OMPC_seq_cst:
95  case OMPC_depend:
96  case OMPC_threads:
97  case OMPC_simd:
98  case OMPC_map:
99  case OMPC_priority:
100  case OMPC_grainsize:
101  case OMPC_nogroup:
102  case OMPC_num_tasks:
103  case OMPC_hint:
104  case OMPC_defaultmap:
105  case OMPC_unknown:
106  case OMPC_uniform:
107  case OMPC_to:
108  case OMPC_from:
109  case OMPC_use_device_ptr:
110  case OMPC_is_device_ptr:
111  case OMPC_unified_address:
112  case OMPC_unified_shared_memory:
113  case OMPC_reverse_offload:
114  case OMPC_dynamic_allocators:
115  case OMPC_atomic_default_mem_order:
116    break;
117  }
118
119  return nullptr;
120}
121
122OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(OMPClause *C) {
123  auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
124  return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr;
125}
126
127const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) {
128  switch (C->getClauseKind()) {
129  case OMPC_lastprivate:
130    return static_cast<const OMPLastprivateClause *>(C);
131  case OMPC_reduction:
132    return static_cast<const OMPReductionClause *>(C);
133  case OMPC_task_reduction:
134    return static_cast<const OMPTaskReductionClause *>(C);
135  case OMPC_in_reduction:
136    return static_cast<const OMPInReductionClause *>(C);
137  case OMPC_linear:
138    return static_cast<const OMPLinearClause *>(C);
139  case OMPC_schedule:
140  case OMPC_dist_schedule:
141  case OMPC_firstprivate:
142  case OMPC_default:
143  case OMPC_proc_bind:
144  case OMPC_if:
145  case OMPC_final:
146  case OMPC_num_threads:
147  case OMPC_safelen:
148  case OMPC_simdlen:
149  case OMPC_allocator:
150  case OMPC_allocate:
151  case OMPC_collapse:
152  case OMPC_private:
153  case OMPC_shared:
154  case OMPC_aligned:
155  case OMPC_copyin:
156  case OMPC_copyprivate:
157  case OMPC_ordered:
158  case OMPC_nowait:
159  case OMPC_untied:
160  case OMPC_mergeable:
161  case OMPC_threadprivate:
162  case OMPC_flush:
163  case OMPC_read:
164  case OMPC_write:
165  case OMPC_update:
166  case OMPC_capture:
167  case OMPC_seq_cst:
168  case OMPC_depend:
169  case OMPC_device:
170  case OMPC_threads:
171  case OMPC_simd:
172  case OMPC_map:
173  case OMPC_num_teams:
174  case OMPC_thread_limit:
175  case OMPC_priority:
176  case OMPC_grainsize:
177  case OMPC_nogroup:
178  case OMPC_num_tasks:
179  case OMPC_hint:
180  case OMPC_defaultmap:
181  case OMPC_unknown:
182  case OMPC_uniform:
183  case OMPC_to:
184  case OMPC_from:
185  case OMPC_use_device_ptr:
186  case OMPC_is_device_ptr:
187  case OMPC_unified_address:
188  case OMPC_unified_shared_memory:
189  case OMPC_reverse_offload:
190  case OMPC_dynamic_allocators:
191  case OMPC_atomic_default_mem_order:
192    break;
193  }
194
195  return nullptr;
196}
197
198OMPOrderedClause *OMPOrderedClause::Create(const ASTContext &CExpr *Num,
199                                           unsigned NumLoops,
200                                           SourceLocation StartLoc,
201                                           SourceLocation LParenLoc,
202                                           SourceLocation EndLoc) {
203  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
204  auto *Clause =
205      new (MemOMPOrderedClause(NumNumLoopsStartLocLParenLocEndLoc);
206  for (unsigned I = 0I < NumLoops; ++I) {
207    Clause->setLoopNumIterations(Inullptr);
208    Clause->setLoopCounter(Inullptr);
209  }
210  return Clause;
211}
212
213OMPOrderedClause *OMPOrderedClause::CreateEmpty(const ASTContext &C,
214                                                unsigned NumLoops) {
215  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
216  auto *Clause = new (MemOMPOrderedClause(NumLoops);
217  for (unsigned I = 0I < NumLoops; ++I) {
218    Clause->setLoopNumIterations(Inullptr);
219    Clause->setLoopCounter(Inullptr);
220  }
221  return Clause;
222}
223
224void OMPOrderedClause::setLoopNumIterations(unsigned NumLoop,
225                                            Expr *NumIterations) {
226   (0) . __assert_fail ("NumLoop < NumberOfLoops && \"out of loops number.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 226, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(NumLoop < NumberOfLoops && "out of loops number.");
227  getTrailingObjects<Expr *>()[NumLoop] = NumIterations;
228}
229
230ArrayRef<Expr *> OMPOrderedClause::getLoopNumIterations() const {
231  return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops);
232}
233
234void OMPOrderedClause::setLoopCounter(unsigned NumLoopExpr *Counter) {
235   (0) . __assert_fail ("NumLoop < NumberOfLoops && \"out of loops number.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 235, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(NumLoop < NumberOfLoops && "out of loops number.");
236  getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter;
237}
238
239Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) {
240   (0) . __assert_fail ("NumLoop < NumberOfLoops && \"out of loops number.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 240, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(NumLoop < NumberOfLoops && "out of loops number.");
241  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
242}
243
244const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoopconst {
245   (0) . __assert_fail ("NumLoop < NumberOfLoops && \"out of loops number.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 245, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(NumLoop < NumberOfLoops && "out of loops number.");
246  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
247}
248
249void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
250   (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 251, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(VL.size() == varlist_size() &&
251 (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 251, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of private copies is not the same as the preallocated buffer");
252  std::copy(VL.begin(), VL.end(), varlist_end());
253}
254
255OMPPrivateClause *
256OMPPrivateClause::Create(const ASTContext &CSourceLocation StartLoc,
257                         SourceLocation LParenLocSourceLocation EndLoc,
258                         ArrayRef<Expr *> VLArrayRef<Expr *> PrivateVL) {
259  // Allocate space for private variables and initializer expressions.
260  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
261  OMPPrivateClause *Clause =
262      new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
263  Clause->setVarRefs(VL);
264  Clause->setPrivateCopies(PrivateVL);
265  return Clause;
266}
267
268OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C,
269                                                unsigned N) {
270  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
271  return new (MemOMPPrivateClause(N);
272}
273
274void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
275   (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 276, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(VL.size() == varlist_size() &&
276 (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 276, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of private copies is not the same as the preallocated buffer");
277  std::copy(VL.begin(), VL.end(), varlist_end());
278}
279
280void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
281   (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 282, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(VL.size() == varlist_size() &&
282 (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 282, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of inits is not the same as the preallocated buffer");
283  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
284}
285
286OMPFirstprivateClause *
287OMPFirstprivateClause::Create(const ASTContext &CSourceLocation StartLoc,
288                              SourceLocation LParenLocSourceLocation EndLoc,
289                              ArrayRef<Expr *> VLArrayRef<Expr *> PrivateVL,
290                              ArrayRef<Expr *> InitVLStmt *PreInit) {
291  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
292  OMPFirstprivateClause *Clause =
293      new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
294  Clause->setVarRefs(VL);
295  Clause->setPrivateCopies(PrivateVL);
296  Clause->setInits(InitVL);
297  Clause->setPreInitStmt(PreInit);
298  return Clause;
299}
300
301OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C,
302                                                          unsigned N) {
303  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
304  return new (MemOMPFirstprivateClause(N);
305}
306
307void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) {
308   (0) . __assert_fail ("PrivateCopies.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 309, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(PrivateCopies.size() == varlist_size() &&
309 (0) . __assert_fail ("PrivateCopies.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 309, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of private copies is not the same as the preallocated buffer");
310  std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
311}
312
313void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
314   (0) . __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 316, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
315 (0) . __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 316, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "not the same as the "
316 (0) . __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 316, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "preallocated buffer");
317  std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
318}
319
320void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
321   (0) . __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 323, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(DstExprs.size() == varlist_size() && "Number of destination "
322 (0) . __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 323, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "expressions is not the same as "
323 (0) . __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 323, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "the preallocated buffer");
324  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
325}
326
327void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
328   (0) . __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 330, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(AssignmentOps.size() == varlist_size() &&
329 (0) . __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 330, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of assignment expressions is not the same as the preallocated "
330 (0) . __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 330, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "buffer");
331  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
332            getDestinationExprs().end());
333}
334
335OMPLastprivateClause *OMPLastprivateClause::Create(
336    const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
337    SourceLocation EndLocArrayRef<Expr *> VLArrayRef<Expr *> SrcExprs,
338    ArrayRef<Expr *> DstExprsArrayRef<Expr *> AssignmentOpsStmt *PreInit,
339    Expr *PostUpdate) {
340  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
341  OMPLastprivateClause *Clause =
342      new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
343  Clause->setVarRefs(VL);
344  Clause->setSourceExprs(SrcExprs);
345  Clause->setDestinationExprs(DstExprs);
346  Clause->setAssignmentOps(AssignmentOps);
347  Clause->setPreInitStmt(PreInit);
348  Clause->setPostUpdateExpr(PostUpdate);
349  return Clause;
350}
351
352OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C,
353                                                        unsigned N) {
354  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
355  return new (MemOMPLastprivateClause(N);
356}
357
358OMPSharedClause *OMPSharedClause::Create(const ASTContext &C,
359                                         SourceLocation StartLoc,
360                                         SourceLocation LParenLoc,
361                                         SourceLocation EndLoc,
362                                         ArrayRef<Expr *> VL) {
363  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
364  OMPSharedClause *Clause =
365      new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
366  Clause->setVarRefs(VL);
367  return Clause;
368}
369
370OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &Cunsigned N) {
371  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
372  return new (MemOMPSharedClause(N);
373}
374
375void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) {
376   (0) . __assert_fail ("PL.size() == varlist_size() && \"Number of privates is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 377, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(PL.size() == varlist_size() &&
377 (0) . __assert_fail ("PL.size() == varlist_size() && \"Number of privates is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 377, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of privates is not the same as the preallocated buffer");
378  std::copy(PL.begin(), PL.end(), varlist_end());
379}
380
381void OMPLinearClause::setInits(ArrayRef<Expr *> IL) {
382   (0) . __assert_fail ("IL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 383, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(IL.size() == varlist_size() &&
383 (0) . __assert_fail ("IL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 383, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of inits is not the same as the preallocated buffer");
384  std::copy(IL.begin(), IL.end(), getPrivates().end());
385}
386
387void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) {
388   (0) . __assert_fail ("UL.size() == varlist_size() && \"Number of updates is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 389, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(UL.size() == varlist_size() &&
389 (0) . __assert_fail ("UL.size() == varlist_size() && \"Number of updates is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 389, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of updates is not the same as the preallocated buffer");
390  std::copy(UL.begin(), UL.end(), getInits().end());
391}
392
393void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) {
394   (0) . __assert_fail ("FL.size() == varlist_size() && \"Number of final updates is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 395, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(FL.size() == varlist_size() &&
395 (0) . __assert_fail ("FL.size() == varlist_size() && \"Number of final updates is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 395, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of final updates is not the same as the preallocated buffer");
396  std::copy(FL.begin(), FL.end(), getUpdates().end());
397}
398
399OMPLinearClause *OMPLinearClause::Create(
400    const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
401    OpenMPLinearClauseKind ModifierSourceLocation ModifierLoc,
402    SourceLocation ColonLocSourceLocation EndLocArrayRef<Expr *> VL,
403    ArrayRef<Expr *> PLArrayRef<Expr *> ILExpr *StepExpr *CalcStep,
404    Stmt *PreInitExpr *PostUpdate) {
405  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
406  // (Step and CalcStep).
407  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
408  OMPLinearClause *Clause = new (Mem) OMPLinearClause(
409      StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
410  Clause->setVarRefs(VL);
411  Clause->setPrivates(PL);
412  Clause->setInits(IL);
413  // Fill update and final expressions with zeroes, they are provided later,
414  // after the directive construction.
415  std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
416            nullptr);
417  std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
418            nullptr);
419  Clause->setStep(Step);
420  Clause->setCalcStep(CalcStep);
421  Clause->setPreInitStmt(PreInit);
422  Clause->setPostUpdateExpr(PostUpdate);
423  return Clause;
424}
425
426OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C,
427                                              unsigned NumVars) {
428  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
429  // (Step and CalcStep).
430  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
431  return new (MemOMPLinearClause(NumVars);
432}
433
434OMPAlignedClause *
435OMPAlignedClause::Create(const ASTContext &CSourceLocation StartLoc,
436                         SourceLocation LParenLocSourceLocation ColonLoc,
437                         SourceLocation EndLocArrayRef<Expr *> VLExpr *A) {
438  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
439  OMPAlignedClause *Clause = new (Mem)
440      OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
441  Clause->setVarRefs(VL);
442  Clause->setAlignment(A);
443  return Clause;
444}
445
446OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C,
447                                                unsigned NumVars) {
448  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
449  return new (MemOMPAlignedClause(NumVars);
450}
451
452void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
453   (0) . __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 455, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
454 (0) . __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 455, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "not the same as the "
455 (0) . __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 455, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "preallocated buffer");
456  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
457}
458
459void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
460   (0) . __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 462, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(DstExprs.size() == varlist_size() && "Number of destination "
461 (0) . __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 462, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "expressions is not the same as "
462 (0) . __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 462, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "the preallocated buffer");
463  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
464}
465
466void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
467   (0) . __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 469, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(AssignmentOps.size() == varlist_size() &&
468 (0) . __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 469, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of assignment expressions is not the same as the preallocated "
469 (0) . __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 469, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "buffer");
470  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
471            getDestinationExprs().end());
472}
473
474OMPCopyinClause *OMPCopyinClause::Create(
475    const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
476    SourceLocation EndLocArrayRef<Expr *> VLArrayRef<Expr *> SrcExprs,
477    ArrayRef<Expr *> DstExprsArrayRef<Expr *> AssignmentOps) {
478  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
479  OMPCopyinClause *Clause =
480      new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
481  Clause->setVarRefs(VL);
482  Clause->setSourceExprs(SrcExprs);
483  Clause->setDestinationExprs(DstExprs);
484  Clause->setAssignmentOps(AssignmentOps);
485  return Clause;
486}
487
488OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &Cunsigned N) {
489  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
490  return new (MemOMPCopyinClause(N);
491}
492
493void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
494   (0) . __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 496, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
495 (0) . __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 496, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "not the same as the "
496 (0) . __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 496, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "preallocated buffer");
497  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
498}
499
500void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
501   (0) . __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 503, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(DstExprs.size() == varlist_size() && "Number of destination "
502 (0) . __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 503, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "expressions is not the same as "
503 (0) . __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 503, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                              "the preallocated buffer");
504  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
505}
506
507void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
508   (0) . __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 510, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(AssignmentOps.size() == varlist_size() &&
509 (0) . __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 510, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of assignment expressions is not the same as the preallocated "
510 (0) . __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 510, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "buffer");
511  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
512            getDestinationExprs().end());
513}
514
515OMPCopyprivateClause *OMPCopyprivateClause::Create(
516    const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
517    SourceLocation EndLocArrayRef<Expr *> VLArrayRef<Expr *> SrcExprs,
518    ArrayRef<Expr *> DstExprsArrayRef<Expr *> AssignmentOps) {
519  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
520  OMPCopyprivateClause *Clause =
521      new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
522  Clause->setVarRefs(VL);
523  Clause->setSourceExprs(SrcExprs);
524  Clause->setDestinationExprs(DstExprs);
525  Clause->setAssignmentOps(AssignmentOps);
526  return Clause;
527}
528
529OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C,
530                                                        unsigned N) {
531  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
532  return new (MemOMPCopyprivateClause(N);
533}
534
535void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
536   (0) . __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 537, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Privates.size() == varlist_size() &&
537 (0) . __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 537, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of private copies is not the same as the preallocated buffer");
538  std::copy(Privates.begin(), Privates.end(), varlist_end());
539}
540
541void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
542   (0) . __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 544, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(
543 (0) . __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 544, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      LHSExprs.size() == varlist_size() &&
544 (0) . __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 544, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      "Number of LHS expressions is not the same as the preallocated buffer");
545  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
546}
547
548void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
549   (0) . __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 551, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(
550 (0) . __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 551, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      RHSExprs.size() == varlist_size() &&
551 (0) . __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 551, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      "Number of RHS expressions is not the same as the preallocated buffer");
552  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
553}
554
555void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
556   (0) . __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of reduction \" \"expressions is not the same \" \"as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 558, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(ReductionOps.size() == varlist_size() && "Number of reduction "
557 (0) . __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of reduction \" \"expressions is not the same \" \"as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 558, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                                  "expressions is not the same "
558 (0) . __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of reduction \" \"expressions is not the same \" \"as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 558, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                                  "as the preallocated buffer");
559  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
560}
561
562OMPReductionClause *OMPReductionClause::Create(
563    const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
564    SourceLocation EndLocSourceLocation ColonLocArrayRef<Expr *> VL,
565    NestedNameSpecifierLoc QualifierLocconst DeclarationNameInfo &NameInfo,
566    ArrayRef<Expr *> PrivatesArrayRef<Expr *> LHSExprs,
567    ArrayRef<Expr *> RHSExprsArrayRef<Expr *> ReductionOpsStmt *PreInit,
568    Expr *PostUpdate) {
569  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
570  OMPReductionClause *Clause = new (Mem) OMPReductionClause(
571      StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
572  Clause->setVarRefs(VL);
573  Clause->setPrivates(Privates);
574  Clause->setLHSExprs(LHSExprs);
575  Clause->setRHSExprs(RHSExprs);
576  Clause->setReductionOps(ReductionOps);
577  Clause->setPreInitStmt(PreInit);
578  Clause->setPostUpdateExpr(PostUpdate);
579  return Clause;
580}
581
582OMPReductionClause *OMPReductionClause::CreateEmpty(const ASTContext &C,
583                                                    unsigned N) {
584  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
585  return new (MemOMPReductionClause(N);
586}
587
588void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
589   (0) . __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 590, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Privates.size() == varlist_size() &&
590 (0) . __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 590, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of private copies is not the same as the preallocated buffer");
591  std::copy(Privates.begin(), Privates.end(), varlist_end());
592}
593
594void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
595   (0) . __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 597, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(
596 (0) . __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 597, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      LHSExprs.size() == varlist_size() &&
597 (0) . __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 597, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      "Number of LHS expressions is not the same as the preallocated buffer");
598  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
599}
600
601void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
602   (0) . __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 604, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(
603 (0) . __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 604, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      RHSExprs.size() == varlist_size() &&
604 (0) . __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 604, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      "Number of RHS expressions is not the same as the preallocated buffer");
605  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
606}
607
608void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
609   (0) . __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of task reduction \" \"expressions is not the same \" \"as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 611, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
610 (0) . __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of task reduction \" \"expressions is not the same \" \"as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 611, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                                  "expressions is not the same "
611 (0) . __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of task reduction \" \"expressions is not the same \" \"as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 611, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                                  "as the preallocated buffer");
612  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
613}
614
615OMPTaskReductionClause *OMPTaskReductionClause::Create(
616    const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
617    SourceLocation EndLocSourceLocation ColonLocArrayRef<Expr *> VL,
618    NestedNameSpecifierLoc QualifierLocconst DeclarationNameInfo &NameInfo,
619    ArrayRef<Expr *> PrivatesArrayRef<Expr *> LHSExprs,
620    ArrayRef<Expr *> RHSExprsArrayRef<Expr *> ReductionOpsStmt *PreInit,
621    Expr *PostUpdate) {
622  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
623  OMPTaskReductionClause *Clause = new (Mem) OMPTaskReductionClause(
624      StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
625  Clause->setVarRefs(VL);
626  Clause->setPrivates(Privates);
627  Clause->setLHSExprs(LHSExprs);
628  Clause->setRHSExprs(RHSExprs);
629  Clause->setReductionOps(ReductionOps);
630  Clause->setPreInitStmt(PreInit);
631  Clause->setPostUpdateExpr(PostUpdate);
632  return Clause;
633}
634
635OMPTaskReductionClause *OMPTaskReductionClause::CreateEmpty(const ASTContext &C,
636                                                            unsigned N) {
637  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
638  return new (MemOMPTaskReductionClause(N);
639}
640
641void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
642   (0) . __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 643, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Privates.size() == varlist_size() &&
643 (0) . __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 643, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of private copies is not the same as the preallocated buffer");
644  std::copy(Privates.begin(), Privates.end(), varlist_end());
645}
646
647void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
648   (0) . __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 650, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(
649 (0) . __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 650, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      LHSExprs.size() == varlist_size() &&
650 (0) . __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 650, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      "Number of LHS expressions is not the same as the preallocated buffer");
651  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
652}
653
654void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
655   (0) . __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 657, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(
656 (0) . __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 657, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      RHSExprs.size() == varlist_size() &&
657 (0) . __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 657, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">      "Number of RHS expressions is not the same as the preallocated buffer");
658  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
659}
660
661void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
662   (0) . __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of in reduction \" \"expressions is not the same \" \"as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 664, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(ReductionOps.size() == varlist_size() && "Number of in reduction "
663 (0) . __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of in reduction \" \"expressions is not the same \" \"as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 664, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                                  "expressions is not the same "
664 (0) . __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of in reduction \" \"expressions is not the same \" \"as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 664, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">                                                  "as the preallocated buffer");
665  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
666}
667
668void OMPInReductionClause::setTaskgroupDescriptors(
669    ArrayRef<Expr *> TaskgroupDescriptors) {
670   (0) . __assert_fail ("TaskgroupDescriptors.size() == varlist_size() && \"Number of in reduction descriptors is not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 672, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(TaskgroupDescriptors.size() == varlist_size() &&
671 (0) . __assert_fail ("TaskgroupDescriptors.size() == varlist_size() && \"Number of in reduction descriptors is not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 672, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of in reduction descriptors is not the same as the "
672 (0) . __assert_fail ("TaskgroupDescriptors.size() == varlist_size() && \"Number of in reduction descriptors is not the same as the \" \"preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 672, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "preallocated buffer");
673  std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
674            getReductionOps().end());
675}
676
677OMPInReductionClause *OMPInReductionClause::Create(
678    const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
679    SourceLocation EndLocSourceLocation ColonLocArrayRef<Expr *> VL,
680    NestedNameSpecifierLoc QualifierLocconst DeclarationNameInfo &NameInfo,
681    ArrayRef<Expr *> PrivatesArrayRef<Expr *> LHSExprs,
682    ArrayRef<Expr *> RHSExprsArrayRef<Expr *> ReductionOps,
683    ArrayRef<Expr *> TaskgroupDescriptorsStmt *PreInitExpr *PostUpdate) {
684  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
685  OMPInReductionClause *Clause = new (Mem) OMPInReductionClause(
686      StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
687  Clause->setVarRefs(VL);
688  Clause->setPrivates(Privates);
689  Clause->setLHSExprs(LHSExprs);
690  Clause->setRHSExprs(RHSExprs);
691  Clause->setReductionOps(ReductionOps);
692  Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
693  Clause->setPreInitStmt(PreInit);
694  Clause->setPostUpdateExpr(PostUpdate);
695  return Clause;
696}
697
698OMPInReductionClause *OMPInReductionClause::CreateEmpty(const ASTContext &C,
699                                                        unsigned N) {
700  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
701  return new (MemOMPInReductionClause(N);
702}
703
704OMPAllocateClause *
705OMPAllocateClause::Create(const ASTContext &CSourceLocation StartLoc,
706                          SourceLocation LParenLocExpr *Allocator,
707                          SourceLocation ColonLocSourceLocation EndLoc,
708                          ArrayRef<Expr *> VL) {
709  // Allocate space for private variables and initializer expressions.
710  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
711  auto *Clause = new (Mem) OMPAllocateClause(StartLoc, LParenLoc, Allocator,
712                                             ColonLoc, EndLoc, VL.size());
713  Clause->setVarRefs(VL);
714  return Clause;
715}
716
717OMPAllocateClause *OMPAllocateClause::CreateEmpty(const ASTContext &C,
718                                                  unsigned N) {
719  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
720  return new (MemOMPAllocateClause(N);
721}
722
723OMPFlushClause *OMPFlushClause::Create(const ASTContext &C,
724                                       SourceLocation StartLoc,
725                                       SourceLocation LParenLoc,
726                                       SourceLocation EndLoc,
727                                       ArrayRef<Expr *> VL) {
728  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
729  OMPFlushClause *Clause =
730      new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
731  Clause->setVarRefs(VL);
732  return Clause;
733}
734
735OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &Cunsigned N) {
736  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
737  return new (MemOMPFlushClause(N);
738}
739
740OMPDependClause *
741OMPDependClause::Create(const ASTContext &CSourceLocation StartLoc,
742                        SourceLocation LParenLocSourceLocation EndLoc,
743                        OpenMPDependClauseKind DepKindSourceLocation DepLoc,
744                        SourceLocation ColonLocArrayRef<Expr *> VL,
745                        unsigned NumLoops) {
746  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops));
747  OMPDependClause *Clause = new (Mem)
748      OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
749  Clause->setVarRefs(VL);
750  Clause->setDependencyKind(DepKind);
751  Clause->setDependencyLoc(DepLoc);
752  Clause->setColonLoc(ColonLoc);
753  for (unsigned I = 0 ; I < NumLoops; ++I)
754    Clause->setLoopData(Inullptr);
755  return Clause;
756}
757
758OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &Cunsigned N,
759                                              unsigned NumLoops) {
760  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + NumLoops));
761  return new (MemOMPDependClause(NNumLoops);
762}
763
764void OMPDependClause::setLoopData(unsigned NumLoopExpr *Cnt) {
765   (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 769, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert((getDependencyKind() == OMPC_DEPEND_sink ||
766 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 769, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">          getDependencyKind() == OMPC_DEPEND_source) &&
767 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 769, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         NumLoop < NumLoops &&
768 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 769, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Expected sink or source depend + loop index must be less number of "
769 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 769, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "loops.");
770  auto It = std::next(getVarRefs().end(), NumLoop);
771  *It = Cnt;
772}
773
774Expr *OMPDependClause::getLoopData(unsigned NumLoop) {
775   (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 779, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert((getDependencyKind() == OMPC_DEPEND_sink ||
776 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 779, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">          getDependencyKind() == OMPC_DEPEND_source) &&
777 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 779, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         NumLoop < NumLoops &&
778 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 779, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Expected sink or source depend + loop index must be less number of "
779 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 779, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "loops.");
780  auto It = std::next(getVarRefs().end(), NumLoop);
781  return *It;
782}
783
784const Expr *OMPDependClause::getLoopData(unsigned NumLoopconst {
785   (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 789, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert((getDependencyKind() == OMPC_DEPEND_sink ||
786 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 789, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">          getDependencyKind() == OMPC_DEPEND_source) &&
787 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 789, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         NumLoop < NumLoops &&
788 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 789, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Expected sink or source depend + loop index must be less number of "
789 (0) . __assert_fail ("(getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source) && NumLoop < NumLoops && \"Expected sink or source depend + loop index must be less number of \" \"loops.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 789, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "loops.");
790  auto It = std::next(getVarRefs().end(), NumLoop);
791  return *It;
792}
793
794unsigned OMPClauseMappableExprCommon::getComponentsTotalNumber(
795    MappableExprComponentListsRef ComponentLists) {
796  unsigned TotalNum = 0u;
797  for (auto &C : ComponentLists)
798    TotalNum += C.size();
799  return TotalNum;
800}
801
802unsigned OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber(
803    ArrayRef<const ValueDecl *> Declarations) {
804  unsigned TotalNum = 0u;
805  llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
806  for (const ValueDecl *D : Declarations) {
807    const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
808    if (Cache.count(VD))
809      continue;
810    ++TotalNum;
811    Cache.insert(VD);
812  }
813  return TotalNum;
814}
815
816OMPMapClause *OMPMapClause::Create(
817    const ASTContext &Cconst OMPVarListLocTy &LocsArrayRef<Expr *> Vars,
818    ArrayRef<ValueDecl *> Declarations,
819    MappableExprComponentListsRef ComponentListsArrayRef<Expr *> UDMapperRefs,
820    ArrayRef<OpenMPMapModifierKindMapModifiers,
821    ArrayRef<SourceLocationMapModifiersLoc,
822    NestedNameSpecifierLoc UDMQualifierLocDeclarationNameInfo MapperId,
823    OpenMPMapClauseKind Typebool TypeIsImplicitSourceLocation TypeLoc) {
824  OMPMappableExprListSizeTy Sizes;
825  Sizes.NumVars = Vars.size();
826  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
827  Sizes.NumComponentLists = ComponentLists.size();
828  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
829
830  // We need to allocate:
831  // 2 x NumVars x Expr* - we have an original list expression and an associated
832  // user-defined mapper for each clause list entry.
833  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
834  // with each component list.
835  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
836  // number of lists for each unique declaration and the size of each component
837  // list.
838  // NumComponents x MappableComponent - the total of all the components in all
839  // the lists.
840  void *Mem = C.Allocate(
841      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
842                       OMPClauseMappableExprCommon::MappableComponent>(
843          2 * Sizes.NumVarsSizes.NumUniqueDeclarations,
844          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
845          Sizes.NumComponents));
846  OMPMapClause *Clause = new (Mem)
847      OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
848                   Type, TypeIsImplicit, TypeLoc, Locs, Sizes);
849
850  Clause->setVarRefs(Vars);
851  Clause->setUDMapperRefs(UDMapperRefs);
852  Clause->setClauseInfo(Declarations, ComponentLists);
853  Clause->setMapType(Type);
854  Clause->setMapLoc(TypeLoc);
855  return Clause;
856}
857
858OMPMapClause *
859OMPMapClause::CreateEmpty(const ASTContext &C,
860                          const OMPMappableExprListSizeTy &Sizes) {
861  void *Mem = C.Allocate(
862      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
863                       OMPClauseMappableExprCommon::MappableComponent>(
864          2 * Sizes.NumVarsSizes.NumUniqueDeclarations,
865          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
866          Sizes.NumComponents));
867  return new (MemOMPMapClause(Sizes);
868}
869
870OMPToClause *OMPToClause::Create(
871    const ASTContext &Cconst OMPVarListLocTy &LocsArrayRef<Expr *> Vars,
872    ArrayRef<ValueDecl *> Declarations,
873    MappableExprComponentListsRef ComponentListsArrayRef<Expr *> UDMapperRefs,
874    NestedNameSpecifierLoc UDMQualifierLocDeclarationNameInfo MapperId) {
875  OMPMappableExprListSizeTy Sizes;
876  Sizes.NumVars = Vars.size();
877  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
878  Sizes.NumComponentLists = ComponentLists.size();
879  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
880
881  // We need to allocate:
882  // 2 x NumVars x Expr* - we have an original list expression and an associated
883  // user-defined mapper for each clause list entry.
884  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
885  // with each component list.
886  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
887  // number of lists for each unique declaration and the size of each component
888  // list.
889  // NumComponents x MappableComponent - the total of all the components in all
890  // the lists.
891  void *Mem = C.Allocate(
892      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
893                       OMPClauseMappableExprCommon::MappableComponent>(
894          2 * Sizes.NumVarsSizes.NumUniqueDeclarations,
895          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
896          Sizes.NumComponents));
897
898  auto *Clause = new (MemOMPToClause(UDMQualifierLocMapperIdLocsSizes);
899
900  Clause->setVarRefs(Vars);
901  Clause->setUDMapperRefs(UDMapperRefs);
902  Clause->setClauseInfo(Declarations, ComponentLists);
903  return Clause;
904}
905
906OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C,
907                                      const OMPMappableExprListSizeTy &Sizes) {
908  void *Mem = C.Allocate(
909      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
910                       OMPClauseMappableExprCommon::MappableComponent>(
911          2 * Sizes.NumVarsSizes.NumUniqueDeclarations,
912          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
913          Sizes.NumComponents));
914  return new (MemOMPToClause(Sizes);
915}
916
917OMPFromClause *OMPFromClause::Create(
918    const ASTContext &Cconst OMPVarListLocTy &LocsArrayRef<Expr *> Vars,
919    ArrayRef<ValueDecl *> Declarations,
920    MappableExprComponentListsRef ComponentListsArrayRef<Expr *> UDMapperRefs,
921    NestedNameSpecifierLoc UDMQualifierLocDeclarationNameInfo MapperId) {
922  OMPMappableExprListSizeTy Sizes;
923  Sizes.NumVars = Vars.size();
924  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
925  Sizes.NumComponentLists = ComponentLists.size();
926  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
927
928  // We need to allocate:
929  // 2 x NumVars x Expr* - we have an original list expression and an associated
930  // user-defined mapper for each clause list entry.
931  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
932  // with each component list.
933  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
934  // number of lists for each unique declaration and the size of each component
935  // list.
936  // NumComponents x MappableComponent - the total of all the components in all
937  // the lists.
938  void *Mem = C.Allocate(
939      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
940                       OMPClauseMappableExprCommon::MappableComponent>(
941          2 * Sizes.NumVarsSizes.NumUniqueDeclarations,
942          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
943          Sizes.NumComponents));
944
945  auto *Clause =
946      new (MemOMPFromClause(UDMQualifierLocMapperIdLocsSizes);
947
948  Clause->setVarRefs(Vars);
949  Clause->setUDMapperRefs(UDMapperRefs);
950  Clause->setClauseInfo(Declarations, ComponentLists);
951  return Clause;
952}
953
954OMPFromClause *
955OMPFromClause::CreateEmpty(const ASTContext &C,
956                           const OMPMappableExprListSizeTy &Sizes) {
957  void *Mem = C.Allocate(
958      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
959                       OMPClauseMappableExprCommon::MappableComponent>(
960          2 * Sizes.NumVarsSizes.NumUniqueDeclarations,
961          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
962          Sizes.NumComponents));
963  return new (MemOMPFromClause(Sizes);
964}
965
966void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
967   (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 968, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(VL.size() == varlist_size() &&
968 (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 968, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of private copies is not the same as the preallocated buffer");
969  std::copy(VL.begin(), VL.end(), varlist_end());
970}
971
972void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
973   (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 974, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(VL.size() == varlist_size() &&
974 (0) . __assert_fail ("VL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 974, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">         "Number of inits is not the same as the preallocated buffer");
975  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
976}
977
978OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create(
979    const ASTContext &Cconst OMPVarListLocTy &LocsArrayRef<Expr *> Vars,
980    ArrayRef<Expr *> PrivateVarsArrayRef<Expr *> Inits,
981    ArrayRef<ValueDecl *> Declarations,
982    MappableExprComponentListsRef ComponentLists) {
983  OMPMappableExprListSizeTy Sizes;
984  Sizes.NumVars = Vars.size();
985  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
986  Sizes.NumComponentLists = ComponentLists.size();
987  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
988
989  // We need to allocate:
990  // 3 x NumVars x Expr* - we have an original list expression for each clause
991  // list entry and an equal number of private copies and inits.
992  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
993  // with each component list.
994  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
995  // number of lists for each unique declaration and the size of each component
996  // list.
997  // NumComponents x MappableComponent - the total of all the components in all
998  // the lists.
999  void *Mem = C.Allocate(
1000      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1001                       OMPClauseMappableExprCommon::MappableComponent>(
1002          3 * Sizes.NumVarsSizes.NumUniqueDeclarations,
1003          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1004          Sizes.NumComponents));
1005
1006  OMPUseDevicePtrClause *Clause = new (MemOMPUseDevicePtrClause(LocsSizes);
1007
1008  Clause->setVarRefs(Vars);
1009  Clause->setPrivateCopies(PrivateVars);
1010  Clause->setInits(Inits);
1011  Clause->setClauseInfo(Declarations, ComponentLists);
1012  return Clause;
1013}
1014
1015OMPUseDevicePtrClause *
1016OMPUseDevicePtrClause::CreateEmpty(const ASTContext &C,
1017                                   const OMPMappableExprListSizeTy &Sizes) {
1018  void *Mem = C.Allocate(
1019      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1020                       OMPClauseMappableExprCommon::MappableComponent>(
1021          3 * Sizes.NumVarsSizes.NumUniqueDeclarations,
1022          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1023          Sizes.NumComponents));
1024  return new (MemOMPUseDevicePtrClause(Sizes);
1025}
1026
1027OMPIsDevicePtrClause *
1028OMPIsDevicePtrClause::Create(const ASTContext &Cconst OMPVarListLocTy &Locs,
1029                             ArrayRef<Expr *> Vars,
1030                             ArrayRef<ValueDecl *> Declarations,
1031                             MappableExprComponentListsRef ComponentLists) {
1032  OMPMappableExprListSizeTy Sizes;
1033  Sizes.NumVars = Vars.size();
1034  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1035  Sizes.NumComponentLists = ComponentLists.size();
1036  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1037
1038  // We need to allocate:
1039  // NumVars x Expr* - we have an original list expression for each clause list
1040  // entry.
1041  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1042  // with each component list.
1043  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1044  // number of lists for each unique declaration and the size of each component
1045  // list.
1046  // NumComponents x MappableComponent - the total of all the components in all
1047  // the lists.
1048  void *Mem = C.Allocate(
1049      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1050                       OMPClauseMappableExprCommon::MappableComponent>(
1051          Sizes.NumVarsSizes.NumUniqueDeclarations,
1052          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1053          Sizes.NumComponents));
1054
1055  OMPIsDevicePtrClause *Clause = new (MemOMPIsDevicePtrClause(LocsSizes);
1056
1057  Clause->setVarRefs(Vars);
1058  Clause->setClauseInfo(Declarations, ComponentLists);
1059  return Clause;
1060}
1061
1062OMPIsDevicePtrClause *
1063OMPIsDevicePtrClause::CreateEmpty(const ASTContext &C,
1064                                  const OMPMappableExprListSizeTy &Sizes) {
1065  void *Mem = C.Allocate(
1066      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1067                       OMPClauseMappableExprCommon::MappableComponent>(
1068          Sizes.NumVarsSizes.NumUniqueDeclarations,
1069          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1070          Sizes.NumComponents));
1071  return new (MemOMPIsDevicePtrClause(Sizes);
1072}
1073
1074//===----------------------------------------------------------------------===//
1075//  OpenMP clauses printing methods
1076//===----------------------------------------------------------------------===//
1077
1078void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
1079  OS << "if(";
1080  if (Node->getNameModifier() != OMPD_unknown)
1081    OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": ";
1082  Node->getCondition()->printPretty(OSnullptrPolicy0);
1083  OS << ")";
1084}
1085
1086void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) {
1087  OS << "final(";
1088  Node->getCondition()->printPretty(OSnullptrPolicy0);
1089  OS << ")";
1090}
1091
1092void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) {
1093  OS << "num_threads(";
1094  Node->getNumThreads()->printPretty(OSnullptrPolicy0);
1095  OS << ")";
1096}
1097
1098void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) {
1099  OS << "safelen(";
1100  Node->getSafelen()->printPretty(OSnullptrPolicy0);
1101  OS << ")";
1102}
1103
1104void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) {
1105  OS << "simdlen(";
1106  Node->getSimdlen()->printPretty(OSnullptrPolicy0);
1107  OS << ")";
1108}
1109
1110void OMPClausePrinter::VisitOMPAllocatorClause(OMPAllocatorClause *Node) {
1111  OS << "allocator(";
1112  Node->getAllocator()->printPretty(OSnullptrPolicy0);
1113  OS << ")";
1114}
1115
1116void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) {
1117  OS << "collapse(";
1118  Node->getNumForLoops()->printPretty(OSnullptrPolicy0);
1119  OS << ")";
1120}
1121
1122void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
1123  OS << "default("
1124     << getOpenMPSimpleClauseTypeName(OMPC_defaultNode->getDefaultKind())
1125     << ")";
1126}
1127
1128void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
1129  OS << "proc_bind("
1130     << getOpenMPSimpleClauseTypeName(OMPC_proc_bindNode->getProcBindKind())
1131     << ")";
1132}
1133
1134void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {
1135  OS << "unified_address";
1136}
1137
1138void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
1139    OMPUnifiedSharedMemoryClause *) {
1140  OS << "unified_shared_memory";
1141}
1142
1143void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
1144  OS << "reverse_offload";
1145}
1146
1147void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
1148    OMPDynamicAllocatorsClause *) {
1149  OS << "dynamic_allocators";
1150}
1151
1152void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
1153    OMPAtomicDefaultMemOrderClause *Node) {
1154  OS << "atomic_default_mem_order("
1155     << getOpenMPSimpleClauseTypeName(OMPC_atomic_default_mem_order,
1156                                      Node->getAtomicDefaultMemOrderKind())
1157     << ")";
1158}
1159
1160void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
1161  OS << "schedule(";
1162  if (Node->getFirstScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
1163    OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1164                                        Node->getFirstScheduleModifier());
1165    if (Node->getSecondScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
1166      OS << ", ";
1167      OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1168                                          Node->getSecondScheduleModifier());
1169    }
1170    OS << ": ";
1171  }
1172  OS << getOpenMPSimpleClauseTypeName(OMPC_scheduleNode->getScheduleKind());
1173  if (auto *E = Node->getChunkSize()) {
1174    OS << ", ";
1175    E->printPretty(OSnullptrPolicy);
1176  }
1177  OS << ")";
1178}
1179
1180void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) {
1181  OS << "ordered";
1182  if (auto *Num = Node->getNumForLoops()) {
1183    OS << "(";
1184    Num->printPretty(OSnullptrPolicy0);
1185    OS << ")";
1186  }
1187}
1188
1189void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) {
1190  OS << "nowait";
1191}
1192
1193void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
1194  OS << "untied";
1195}
1196
1197void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) {
1198  OS << "nogroup";
1199}
1200
1201void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
1202  OS << "mergeable";
1203}
1204
1205void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; }
1206
1207void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; }
1208
1209void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *) {
1210  OS << "update";
1211}
1212
1213void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
1214  OS << "capture";
1215}
1216
1217void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
1218  OS << "seq_cst";
1219}
1220
1221void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
1222  OS << "threads";
1223}
1224
1225void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; }
1226
1227void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
1228  OS << "device(";
1229  Node->getDevice()->printPretty(OSnullptrPolicy0);
1230  OS << ")";
1231}
1232
1233void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) {
1234  OS << "num_teams(";
1235  Node->getNumTeams()->printPretty(OSnullptrPolicy0);
1236  OS << ")";
1237}
1238
1239void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) {
1240  OS << "thread_limit(";
1241  Node->getThreadLimit()->printPretty(OSnullptrPolicy0);
1242  OS << ")";
1243}
1244
1245void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) {
1246  OS << "priority(";
1247  Node->getPriority()->printPretty(OSnullptrPolicy0);
1248  OS << ")";
1249}
1250
1251void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
1252  OS << "grainsize(";
1253  Node->getGrainsize()->printPretty(OSnullptrPolicy0);
1254  OS << ")";
1255}
1256
1257void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
1258  OS << "num_tasks(";
1259  Node->getNumTasks()->printPretty(OSnullptrPolicy0);
1260  OS << ")";
1261}
1262
1263void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) {
1264  OS << "hint(";
1265  Node->getHint()->printPretty(OSnullptrPolicy0);
1266  OS << ")";
1267}
1268
1269template<typename T>
1270void OMPClausePrinter::VisitOMPClauseList(T *Nodechar StartSym) {
1271  for (typename T::varlist_iterator I = Node->varlist_begin(),
1272                                    E = Node->varlist_end();
1273       I != E; ++I) {
1274     (0) . __assert_fail ("*I && \"Expected non-null Stmt\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/OpenMPClause.cpp", 1274, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(*I && "Expected non-null Stmt");
1275    OS << (I == Node->varlist_begin() ? StartSym : ',');
1276    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1277      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1278        DRE->printPretty(OSnullptrPolicy0);
1279      else
1280        DRE->getDecl()->printQualifiedName(OS);
1281    } else
1282      (*I)->printPretty(OSnullptrPolicy0);
1283  }
1284}
1285
1286void OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) {
1287  if (Node->varlist_empty())
1288    return;
1289  OS << "allocate";
1290  if (Expr *Allocator = Node->getAllocator()) {
1291    OS << "(";
1292    Allocator->printPretty(OSnullptrPolicy0);
1293    OS << ":";
1294    VisitOMPClauseList(Node' ');
1295  } else {
1296    VisitOMPClauseList(Node'(');
1297  }
1298  OS << ")";
1299}
1300
1301void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
1302  if (!Node->varlist_empty()) {
1303    OS << "private";
1304    VisitOMPClauseList(Node'(');
1305    OS << ")";
1306  }
1307}
1308
1309void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
1310  if (!Node->varlist_empty()) {
1311    OS << "firstprivate";
1312    VisitOMPClauseList(Node'(');
1313    OS << ")";
1314  }
1315}
1316
1317void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
1318  if (!Node->varlist_empty()) {
1319    OS << "lastprivate";
1320    VisitOMPClauseList(Node'(');
1321    OS << ")";
1322  }
1323}
1324
1325void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
1326  if (!Node->varlist_empty()) {
1327    OS << "shared";
1328    VisitOMPClauseList(Node'(');
1329    OS << ")";
1330  }
1331}
1332
1333void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
1334  if (!Node->varlist_empty()) {
1335    OS << "reduction(";
1336    NestedNameSpecifier *QualifierLoc =
1337        Node->getQualifierLoc().getNestedNameSpecifier();
1338    OverloadedOperatorKind OOK =
1339        Node->getNameInfo().getName().getCXXOverloadedOperator();
1340    if (QualifierLoc == nullptr && OOK != OO_None) {
1341      // Print reduction identifier in C format
1342      OS << getOperatorSpelling(OOK);
1343    } else {
1344      // Use C++ format
1345      if (QualifierLoc != nullptr)
1346        QualifierLoc->print(OSPolicy);
1347      OS << Node->getNameInfo();
1348    }
1349    OS << ":";
1350    VisitOMPClauseList(Node' ');
1351    OS << ")";
1352  }
1353}
1354
1355void OMPClausePrinter::VisitOMPTaskReductionClause(
1356    OMPTaskReductionClause *Node) {
1357  if (!Node->varlist_empty()) {
1358    OS << "task_reduction(";
1359    NestedNameSpecifier *QualifierLoc =
1360        Node->getQualifierLoc().getNestedNameSpecifier();
1361    OverloadedOperatorKind OOK =
1362        Node->getNameInfo().getName().getCXXOverloadedOperator();
1363    if (QualifierLoc == nullptr && OOK != OO_None) {
1364      // Print reduction identifier in C format
1365      OS << getOperatorSpelling(OOK);
1366    } else {
1367      // Use C++ format
1368      if (QualifierLoc != nullptr)
1369        QualifierLoc->print(OSPolicy);
1370      OS << Node->getNameInfo();
1371    }
1372    OS << ":";
1373    VisitOMPClauseList(Node' ');
1374    OS << ")";
1375  }
1376}
1377
1378void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) {
1379  if (!Node->varlist_empty()) {
1380    OS << "in_reduction(";
1381    NestedNameSpecifier *QualifierLoc =
1382        Node->getQualifierLoc().getNestedNameSpecifier();
1383    OverloadedOperatorKind OOK =
1384        Node->getNameInfo().getName().getCXXOverloadedOperator();
1385    if (QualifierLoc == nullptr && OOK != OO_None) {
1386      // Print reduction identifier in C format
1387      OS << getOperatorSpelling(OOK);
1388    } else {
1389      // Use C++ format
1390      if (QualifierLoc != nullptr)
1391        QualifierLoc->print(OSPolicy);
1392      OS << Node->getNameInfo();
1393    }
1394    OS << ":";
1395    VisitOMPClauseList(Node' ');
1396    OS << ")";
1397  }
1398}
1399
1400void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
1401  if (!Node->varlist_empty()) {
1402    OS << "linear";
1403    if (Node->getModifierLoc().isValid()) {
1404      OS << '('
1405         << getOpenMPSimpleClauseTypeName(OMPC_linearNode->getModifier());
1406    }
1407    VisitOMPClauseList(Node'(');
1408    if (Node->getModifierLoc().isValid())
1409      OS << ')';
1410    if (Node->getStep() != nullptr) {
1411      OS << ": ";
1412      Node->getStep()->printPretty(OSnullptrPolicy0);
1413    }
1414    OS << ")";
1415  }
1416}
1417
1418void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
1419  if (!Node->varlist_empty()) {
1420    OS << "aligned";
1421    VisitOMPClauseList(Node'(');
1422    if (Node->getAlignment() != nullptr) {
1423      OS << ": ";
1424      Node->getAlignment()->printPretty(OSnullptrPolicy0);
1425    }
1426    OS << ")";
1427  }
1428}
1429
1430void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
1431  if (!Node->varlist_empty()) {
1432    OS << "copyin";
1433    VisitOMPClauseList(Node'(');
1434    OS << ")";
1435  }
1436}
1437
1438void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
1439  if (!Node->varlist_empty()) {
1440    OS << "copyprivate";
1441    VisitOMPClauseList(Node'(');
1442    OS << ")";
1443  }
1444}
1445
1446void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
1447  if (!Node->varlist_empty()) {
1448    VisitOMPClauseList(Node'(');
1449    OS << ")";
1450  }
1451}
1452
1453void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
1454  OS << "depend(";
1455  OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
1456                                      Node->getDependencyKind());
1457  if (!Node->varlist_empty()) {
1458    OS << " :";
1459    VisitOMPClauseList(Node' ');
1460  }
1461  OS << ")";
1462}
1463
1464void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
1465  if (!Node->varlist_empty()) {
1466    OS << "map(";
1467    if (Node->getMapType() != OMPC_MAP_unknown) {
1468      for (unsigned I = 0I < OMPMapClause::NumberOfModifiers; ++I) {
1469        if (Node->getMapTypeModifier(I) != OMPC_MAP_MODIFIER_unknown) {
1470          OS << getOpenMPSimpleClauseTypeName(OMPC_map,
1471                                              Node->getMapTypeModifier(I));
1472          if (Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_mapper) {
1473            OS << '(';
1474            NestedNameSpecifier *MapperNNS =
1475                Node->getMapperQualifierLoc().getNestedNameSpecifier();
1476            if (MapperNNS)
1477              MapperNNS->print(OSPolicy);
1478            OS << Node->getMapperIdInfo() << ')';
1479          }
1480          OS << ',';
1481        }
1482      }
1483      OS << getOpenMPSimpleClauseTypeName(OMPC_mapNode->getMapType());
1484      OS << ':';
1485    }
1486    VisitOMPClauseList(Node' ');
1487    OS << ")";
1488  }
1489}
1490
1491void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) {
1492  if (!Node->varlist_empty()) {
1493    OS << "to";
1494    DeclarationNameInfo MapperId = Node->getMapperIdInfo();
1495    if (MapperId.getName() && !MapperId.getName().isEmpty()) {
1496      OS << '(';
1497      OS << "mapper(";
1498      NestedNameSpecifier *MapperNNS =
1499          Node->getMapperQualifierLoc().getNestedNameSpecifier();
1500      if (MapperNNS)
1501        MapperNNS->print(OSPolicy);
1502      OS << MapperId << "):";
1503      VisitOMPClauseList(Node' ');
1504    } else {
1505      VisitOMPClauseList(Node'(');
1506    }
1507    OS << ")";
1508  }
1509}
1510
1511void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) {
1512  if (!Node->varlist_empty()) {
1513    OS << "from";
1514    DeclarationNameInfo MapperId = Node->getMapperIdInfo();
1515    if (MapperId.getName() && !MapperId.getName().isEmpty()) {
1516      OS << '(';
1517      OS << "mapper(";
1518      NestedNameSpecifier *MapperNNS =
1519          Node->getMapperQualifierLoc().getNestedNameSpecifier();
1520      if (MapperNNS)
1521        MapperNNS->print(OSPolicy);
1522      OS << MapperId << "):";
1523      VisitOMPClauseList(Node' ');
1524    } else {
1525      VisitOMPClauseList(Node'(');
1526    }
1527    OS << ")";
1528  }
1529}
1530
1531void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) {
1532  OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName(
1533                           OMPC_dist_scheduleNode->getDistScheduleKind());
1534  if (auto *E = Node->getChunkSize()) {
1535    OS << ", ";
1536    E->printPretty(OSnullptrPolicy);
1537  }
1538  OS << ")";
1539}
1540
1541void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
1542  OS << "defaultmap(";
1543  OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
1544                                      Node->getDefaultmapModifier());
1545  OS << ": ";
1546  OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
1547    Node->getDefaultmapKind());
1548  OS << ")";
1549}
1550
1551void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) {
1552  if (!Node->varlist_empty()) {
1553    OS << "use_device_ptr";
1554    VisitOMPClauseList(Node'(');
1555    OS << ")";
1556  }
1557}
1558
1559void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) {
1560  if (!Node->varlist_empty()) {
1561    OS << "is_device_ptr";
1562    VisitOMPClauseList(Node'(');
1563    OS << ")";
1564  }
1565}
1566
1567
clang::OMPClause::children
clang::OMPClauseWithPreInit::get
clang::OMPClauseWithPreInit::get
clang::OMPClauseWithPostUpdate::get
clang::OMPClauseWithPostUpdate::get
clang::OMPOrderedClause::Create
clang::OMPOrderedClause::CreateEmpty
clang::OMPOrderedClause::setLoopNumIterations
clang::OMPOrderedClause::getLoopNumIterations
clang::OMPOrderedClause::setLoopCounter
clang::OMPOrderedClause::getLoopCounter
clang::OMPOrderedClause::getLoopCounter
clang::OMPPrivateClause::setPrivateCopies
clang::OMPPrivateClause::Create
clang::OMPPrivateClause::CreateEmpty
clang::OMPFirstprivateClause::setPrivateCopies
clang::OMPFirstprivateClause::setInits
clang::OMPFirstprivateClause::Create
clang::OMPFirstprivateClause::CreateEmpty
clang::OMPLastprivateClause::setPrivateCopies
clang::OMPLastprivateClause::setSourceExprs
clang::OMPLastprivateClause::setDestinationExprs
clang::OMPLastprivateClause::setAssignmentOps
clang::OMPLastprivateClause::Create
clang::OMPLastprivateClause::CreateEmpty
clang::OMPSharedClause::Create
clang::OMPSharedClause::CreateEmpty
clang::OMPLinearClause::setPrivates
clang::OMPLinearClause::setInits
clang::OMPLinearClause::setUpdates
clang::OMPLinearClause::setFinals
clang::OMPLinearClause::Create
clang::OMPLinearClause::CreateEmpty
clang::OMPAlignedClause::Create
clang::OMPAlignedClause::CreateEmpty
clang::OMPCopyinClause::setSourceExprs
clang::OMPCopyinClause::setDestinationExprs
clang::OMPCopyinClause::setAssignmentOps
clang::OMPCopyinClause::Create
clang::OMPCopyinClause::CreateEmpty
clang::OMPCopyprivateClause::setSourceExprs
clang::OMPCopyprivateClause::setDestinationExprs
clang::OMPCopyprivateClause::setAssignmentOps
clang::OMPCopyprivateClause::Create
clang::OMPCopyprivateClause::CreateEmpty
clang::OMPReductionClause::setPrivates
clang::OMPReductionClause::setLHSExprs
clang::OMPReductionClause::setRHSExprs
clang::OMPReductionClause::setReductionOps
clang::OMPReductionClause::Create
clang::OMPReductionClause::CreateEmpty
clang::OMPTaskReductionClause::setPrivates
clang::OMPTaskReductionClause::setLHSExprs
clang::OMPTaskReductionClause::setRHSExprs
clang::OMPTaskReductionClause::setReductionOps
clang::OMPTaskReductionClause::Create
clang::OMPTaskReductionClause::CreateEmpty
clang::OMPInReductionClause::setPrivates
clang::OMPInReductionClause::setLHSExprs
clang::OMPInReductionClause::setRHSExprs
clang::OMPInReductionClause::setReductionOps
clang::OMPInReductionClause::setTaskgroupDescriptors
clang::OMPInReductionClause::Create
clang::OMPInReductionClause::CreateEmpty
clang::OMPAllocateClause::Create
clang::OMPAllocateClause::CreateEmpty
clang::OMPFlushClause::Create
clang::OMPFlushClause::CreateEmpty
clang::OMPDependClause::Create
clang::OMPDependClause::CreateEmpty
clang::OMPDependClause::setLoopData
clang::OMPDependClause::getLoopData
clang::OMPDependClause::getLoopData
clang::OMPClauseMappableExprCommon::getComponentsTotalNumber
clang::OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber
clang::OMPMapClause::Create
clang::OMPMapClause::CreateEmpty
clang::OMPToClause::Create
clang::OMPToClause::CreateEmpty
clang::OMPFromClause::Create
clang::OMPFromClause::CreateEmpty
clang::OMPUseDevicePtrClause::setPrivateCopies
clang::OMPUseDevicePtrClause::setInits
clang::OMPUseDevicePtrClause::Create
clang::OMPUseDevicePtrClause::CreateEmpty
clang::OMPIsDevicePtrClause::Create
clang::OMPIsDevicePtrClause::CreateEmpty
clang::OMPClausePrinter::VisitOMPIfClause
clang::OMPClausePrinter::VisitOMPFinalClause
clang::OMPClausePrinter::VisitOMPNumThreadsClause
clang::OMPClausePrinter::VisitOMPSafelenClause
clang::OMPClausePrinter::VisitOMPSimdlenClause
clang::OMPClausePrinter::VisitOMPAllocatorClause
clang::OMPClausePrinter::VisitOMPCollapseClause
clang::OMPClausePrinter::VisitOMPDefaultClause
clang::OMPClausePrinter::VisitOMPProcBindClause
clang::OMPClausePrinter::VisitOMPUnifiedAddressClause
clang::OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause
clang::OMPClausePrinter::VisitOMPReverseOffloadClause
clang::OMPClausePrinter::VisitOMPDynamicAllocatorsClause
clang::OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause
clang::OMPClausePrinter::VisitOMPScheduleClause
clang::OMPClausePrinter::VisitOMPOrderedClause
clang::OMPClausePrinter::VisitOMPNowaitClause
clang::OMPClausePrinter::VisitOMPUntiedClause
clang::OMPClausePrinter::VisitOMPNogroupClause
clang::OMPClausePrinter::VisitOMPMergeableClause
clang::OMPClausePrinter::VisitOMPReadClause
clang::OMPClausePrinter::VisitOMPWriteClause
clang::OMPClausePrinter::VisitOMPUpdateClause
clang::OMPClausePrinter::VisitOMPCaptureClause
clang::OMPClausePrinter::VisitOMPSeqCstClause
clang::OMPClausePrinter::VisitOMPThreadsClause
clang::OMPClausePrinter::VisitOMPSIMDClause
clang::OMPClausePrinter::VisitOMPDeviceClause
clang::OMPClausePrinter::VisitOMPNumTeamsClause
clang::OMPClausePrinter::VisitOMPThreadLimitClause
clang::OMPClausePrinter::VisitOMPPriorityClause
clang::OMPClausePrinter::VisitOMPGrainsizeClause
clang::OMPClausePrinter::VisitOMPNumTasksClause
clang::OMPClausePrinter::VisitOMPHintClause
clang::OMPClausePrinter::VisitOMPClauseList
clang::OMPClausePrinter::VisitOMPAllocateClause
clang::OMPClausePrinter::VisitOMPPrivateClause
clang::OMPClausePrinter::VisitOMPFirstprivateClause
clang::OMPClausePrinter::VisitOMPLastprivateClause
clang::OMPClausePrinter::VisitOMPSharedClause
clang::OMPClausePrinter::VisitOMPReductionClause
clang::OMPClausePrinter::VisitOMPTaskReductionClause
clang::OMPClausePrinter::VisitOMPInReductionClause
clang::OMPClausePrinter::VisitOMPLinearClause
clang::OMPClausePrinter::VisitOMPAlignedClause
clang::OMPClausePrinter::VisitOMPCopyinClause
clang::OMPClausePrinter::VisitOMPCopyprivateClause
clang::OMPClausePrinter::VisitOMPFlushClause
clang::OMPClausePrinter::VisitOMPDependClause
clang::OMPClausePrinter::VisitOMPMapClause
clang::OMPClausePrinter::VisitOMPToClause
clang::OMPClausePrinter::VisitOMPFromClause
clang::OMPClausePrinter::VisitOMPDistScheduleClause
clang::OMPClausePrinter::VisitOMPDefaultmapClause
clang::OMPClausePrinter::VisitOMPUseDevicePtrClause
clang::OMPClausePrinter::VisitOMPIsDevicePtrClause