Coverage Report

Created: 2019-07-24 05:18

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