Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/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/Attr.h"
16
#include "clang/AST/Decl.h"
17
#include "clang/AST/DeclOpenMP.h"
18
#include "clang/Basic/LLVM.h"
19
#include "clang/Basic/OpenMPKinds.h"
20
#include "clang/Basic/TargetInfo.h"
21
#include "llvm/ADT/SmallPtrSet.h"
22
#include "llvm/Support/Casting.h"
23
#include "llvm/Support/ErrorHandling.h"
24
#include <algorithm>
25
#include <cassert>
26
27
using namespace clang;
28
using namespace llvm;
29
using namespace omp;
30
31
82.7k
OMPClause::child_range OMPClause::children() {
32
82.7k
  switch (getClauseKind()) {
33
0
  default:
34
0
    break;
35
0
#define GEN_CLANG_CLAUSE_CLASS
36
0
#define CLAUSE_CLASS(Enum, Str, Class)                                         \
37
82.7k
  case Enum:                                                                   \
38
82.7k
    return static_cast<Class *>(this)->children();
39
82.7k
#include 
"llvm/Frontend/OpenMP/OMP.inc"0
40
82.7k
  }
41
0
  llvm_unreachable("unknown OMPClause");
42
0
}
43
44
98.3k
OMPClause::child_range OMPClause::used_children() {
45
98.3k
  switch (getClauseKind()) {
46
0
#define GEN_CLANG_CLAUSE_CLASS
47
0
#define CLAUSE_CLASS(Enum, Str, Class)                                         \
48
98.3k
  case Enum:                                                                   \
49
98.3k
    return static_cast<Class *>(this)->used_children();
50
0
#define CLAUSE_NO_CLASS(Enum, Str)                                             \
51
0
  case Enum:                                                                   \
52
0
    break;
53
98.3k
#include 
"llvm/Frontend/OpenMP/OMP.inc"0
54
98.3k
  }
55
0
  llvm_unreachable("unknown OMPClause");
56
0
}
57
58
81.9k
OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) {
59
81.9k
  auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
60
81.9k
  return Res ? 
const_cast<OMPClauseWithPreInit *>(Res)23.7k
:
nullptr58.2k
;
61
81.9k
}
62
63
243k
const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
64
243k
  switch (C->getClauseKind()) {
65
8.71k
  case OMPC_schedule:
66
8.71k
    return static_cast<const OMPScheduleClause *>(C);
67
4.67k
  case OMPC_dist_schedule:
68
4.67k
    return static_cast<const OMPDistScheduleClause *>(C);
69
65.1k
  case OMPC_firstprivate:
70
65.1k
    return static_cast<const OMPFirstprivateClause *>(C);
71
6.84k
  case OMPC_lastprivate:
72
6.84k
    return static_cast<const OMPLastprivateClause *>(C);
73
26.7k
  case OMPC_reduction:
74
26.7k
    return static_cast<const OMPReductionClause *>(C);
75
2.40k
  case OMPC_task_reduction:
76
2.40k
    return static_cast<const OMPTaskReductionClause *>(C);
77
1.72k
  case OMPC_in_reduction:
78
1.72k
    return static_cast<const OMPInReductionClause *>(C);
79
3.54k
  case OMPC_linear:
80
3.54k
    return static_cast<const OMPLinearClause *>(C);
81
29.8k
  case OMPC_if:
82
29.8k
    return static_cast<const OMPIfClause *>(C);
83
4.79k
  case OMPC_num_threads:
84
4.79k
    return static_cast<const OMPNumThreadsClause *>(C);
85
4.91k
  case OMPC_num_teams:
86
4.91k
    return static_cast<const OMPNumTeamsClause *>(C);
87
3.91k
  case OMPC_thread_limit:
88
3.91k
    return static_cast<const OMPThreadLimitClause *>(C);
89
3.24k
  case OMPC_device:
90
3.24k
    return static_cast<const OMPDeviceClause *>(C);
91
954
  case OMPC_grainsize:
92
954
    return static_cast<const OMPGrainsizeClause *>(C);
93
1.08k
  case OMPC_num_tasks:
94
1.08k
    return static_cast<const OMPNumTasksClause *>(C);
95
1.10k
  case OMPC_final:
96
1.10k
    return static_cast<const OMPFinalClause *>(C);
97
1.42k
  case OMPC_priority:
98
1.42k
    return static_cast<const OMPPriorityClause *>(C);
99
20
  case OMPC_novariants:
100
20
    return static_cast<const OMPNovariantsClause *>(C);
101
20
  case OMPC_nocontext:
102
20
    return static_cast<const OMPNocontextClause *>(C);
103
119
  case OMPC_filter:
104
119
    return static_cast<const OMPFilterClause *>(C);
105
1.83k
  case OMPC_default:
106
2.68k
  case OMPC_proc_bind:
107
5.30k
  case OMPC_safelen:
108
7.00k
  case OMPC_simdlen:
109
7.00k
  case OMPC_sizes:
110
7.00k
  case OMPC_allocator:
111
8.52k
  case OMPC_allocate:
112
12.8k
  case OMPC_collapse:
113
13.6k
  case OMPC_private:
114
17.0k
  case OMPC_shared:
115
18.3k
  case OMPC_aligned:
116
18.6k
  case OMPC_copyin:
117
18.7k
  case OMPC_copyprivate:
118
19.4k
  case OMPC_ordered:
119
21.9k
  case OMPC_nowait:
120
22.1k
  case OMPC_untied:
121
22.3k
  case OMPC_mergeable:
122
22.3k
  case OMPC_threadprivate:
123
22.3k
  case OMPC_flush:
124
22.3k
  case OMPC_depobj:
125
22.3k
  case OMPC_read:
126
22.3k
  case OMPC_write:
127
22.3k
  case OMPC_update:
128
22.3k
  case OMPC_capture:
129
22.3k
  case OMPC_compare:
130
22.3k
  case OMPC_seq_cst:
131
22.3k
  case OMPC_acq_rel:
132
22.3k
  case OMPC_acquire:
133
22.3k
  case OMPC_release:
134
22.3k
  case OMPC_relaxed:
135
25.7k
  case OMPC_depend:
136
25.7k
  case OMPC_threads:
137
25.8k
  case OMPC_simd:
138
60.7k
  case OMPC_map:
139
61.0k
  case OMPC_nogroup:
140
61.0k
  case OMPC_hint:
141
63.3k
  case OMPC_defaultmap:
142
63.3k
  case OMPC_unknown:
143
63.3k
  case OMPC_uniform:
144
66.2k
  case OMPC_to:
145
67.7k
  case OMPC_from:
146
67.9k
  case OMPC_use_device_ptr:
147
67.9k
  case OMPC_use_device_addr:
148
71.0k
  case OMPC_is_device_ptr:
149
71.0k
  case OMPC_unified_address:
150
71.0k
  case OMPC_unified_shared_memory:
151
71.0k
  case OMPC_reverse_offload:
152
71.0k
  case OMPC_dynamic_allocators:
153
71.0k
  case OMPC_atomic_default_mem_order:
154
71.0k
  case OMPC_device_type:
155
71.0k
  case OMPC_match:
156
71.5k
  case OMPC_nontemporal:
157
71.6k
  case OMPC_order:
158
71.6k
  case OMPC_destroy:
159
71.7k
  case OMPC_detach:
160
71.7k
  case OMPC_inclusive:
161
71.7k
  case OMPC_exclusive:
162
72.0k
  case OMPC_uses_allocators:
163
72.0k
  case OMPC_affinity:
164
72.0k
  case OMPC_when:
165
72.0k
  case OMPC_bind:
166
72.0k
    break;
167
0
  default:
168
0
    break;
169
243k
  }
170
171
72.0k
  return nullptr;
172
243k
}
173
174
81.9k
OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(OMPClause *C) {
175
81.9k
  auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
176
81.9k
  return Res ? 
const_cast<OMPClauseWithPostUpdate *>(Res)0
: nullptr;
177
81.9k
}
178
179
120k
const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) {
180
120k
  switch (C->getClauseKind()) {
181
6.25k
  case OMPC_lastprivate:
182
6.25k
    return static_cast<const OMPLastprivateClause *>(C);
183
25.6k
  case OMPC_reduction:
184
25.6k
    return static_cast<const OMPReductionClause *>(C);
185
2.35k
  case OMPC_task_reduction:
186
2.35k
    return static_cast<const OMPTaskReductionClause *>(C);
187
1.63k
  case OMPC_in_reduction:
188
1.63k
    return static_cast<const OMPInReductionClause *>(C);
189
2.98k
  case OMPC_linear:
190
2.98k
    return static_cast<const OMPLinearClause *>(C);
191
2.86k
  case OMPC_schedule:
192
4.30k
  case OMPC_dist_schedule:
193
4.30k
  case OMPC_firstprivate:
194
6.08k
  case OMPC_default:
195
6.82k
  case OMPC_proc_bind:
196
17.9k
  case OMPC_if:
197
18.4k
  case OMPC_final:
198
20.3k
  case OMPC_num_threads:
199
22.7k
  case OMPC_safelen:
200
24.2k
  case OMPC_simdlen:
201
24.2k
  case OMPC_sizes:
202
24.2k
  case OMPC_allocator:
203
25.7k
  case OMPC_allocate:
204
29.5k
  case OMPC_collapse:
205
29.5k
  case OMPC_private:
206
32.6k
  case OMPC_shared:
207
33.6k
  case OMPC_aligned:
208
33.9k
  case OMPC_copyin:
209
33.9k
  case OMPC_copyprivate:
210
34.5k
  case OMPC_ordered:
211
36.4k
  case OMPC_nowait:
212
36.6k
  case OMPC_untied:
213
36.8k
  case OMPC_mergeable:
214
36.8k
  case OMPC_threadprivate:
215
36.8k
  case OMPC_flush:
216
36.8k
  case OMPC_depobj:
217
36.8k
  case OMPC_read:
218
36.8k
  case OMPC_write:
219
36.8k
  case OMPC_update:
220
36.8k
  case OMPC_capture:
221
36.8k
  case OMPC_compare:
222
36.8k
  case OMPC_seq_cst:
223
36.8k
  case OMPC_acq_rel:
224
36.8k
  case OMPC_acquire:
225
36.8k
  case OMPC_release:
226
36.8k
  case OMPC_relaxed:
227
39.3k
  case OMPC_depend:
228
40.4k
  case OMPC_device:
229
40.4k
  case OMPC_threads:
230
40.4k
  case OMPC_simd:
231
67.2k
  case OMPC_map:
232
69.0k
  case OMPC_num_teams:
233
70.4k
  case OMPC_thread_limit:
234
71.1k
  case OMPC_priority:
235
71.5k
  case OMPC_grainsize:
236
71.7k
  case OMPC_nogroup:
237
72.2k
  case OMPC_num_tasks:
238
72.2k
  case OMPC_hint:
239
74.2k
  case OMPC_defaultmap:
240
74.2k
  case OMPC_unknown:
241
74.2k
  case OMPC_uniform:
242
76.8k
  case OMPC_to:
243
78.1k
  case OMPC_from:
244
78.1k
  case OMPC_use_device_ptr:
245
78.1k
  case OMPC_use_device_addr:
246
81.1k
  case OMPC_is_device_ptr:
247
81.1k
  case OMPC_unified_address:
248
81.1k
  case OMPC_unified_shared_memory:
249
81.1k
  case OMPC_reverse_offload:
250
81.1k
  case OMPC_dynamic_allocators:
251
81.1k
  case OMPC_atomic_default_mem_order:
252
81.1k
  case OMPC_device_type:
253
81.1k
  case OMPC_match:
254
81.4k
  case OMPC_nontemporal:
255
81.6k
  case OMPC_order:
256
81.6k
  case OMPC_destroy:
257
81.6k
  case OMPC_novariants:
258
81.6k
  case OMPC_nocontext:
259
81.7k
  case OMPC_detach:
260
81.7k
  case OMPC_inclusive:
261
81.7k
  case OMPC_exclusive:
262
81.9k
  case OMPC_uses_allocators:
263
81.9k
  case OMPC_affinity:
264
81.9k
  case OMPC_when:
265
81.9k
  case OMPC_bind:
266
81.9k
    break;
267
0
  default:
268
0
    break;
269
120k
  }
270
271
81.9k
  return nullptr;
272
120k
}
273
274
/// Gets the address of the original, non-captured, expression used in the
275
/// clause as the preinitializer.
276
12.9k
static Stmt **getAddrOfExprAsWritten(Stmt *S) {
277
12.9k
  if (!S)
278
9.91k
    return nullptr;
279
3.02k
  if (auto *DS = dyn_cast<DeclStmt>(S)) {
280
3.02k
    assert(DS->isSingleDecl() && "Only single expression must be captured.");
281
3.02k
    if (auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
282
3.02k
      return OED->getInitAddress();
283
3.02k
  }
284
0
  return nullptr;
285
3.02k
}
286
287
10.9k
OMPClause::child_range OMPIfClause::used_children() {
288
10.9k
  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
289
2.68k
    return child_range(C, C + 1);
290
8.26k
  return child_range(&Condition, &Condition + 1);
291
10.9k
}
292
293
360
OMPClause::child_range OMPGrainsizeClause::used_children() {
294
360
  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
295
24
    return child_range(C, C + 1);
296
336
  return child_range(&Grainsize, &Grainsize + 1);
297
360
}
298
299
504
OMPClause::child_range OMPNumTasksClause::used_children() {
300
504
  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
301
48
    return child_range(C, C + 1);
302
456
  return child_range(&NumTasks, &NumTasks + 1);
303
504
}
304
305
384
OMPClause::child_range OMPFinalClause::used_children() {
306
384
  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
307
144
    return child_range(C, C + 1);
308
240
  return child_range(&Condition, &Condition + 1);
309
384
}
310
311
744
OMPClause::child_range OMPPriorityClause::used_children() {
312
744
  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
313
120
    return child_range(C, C + 1);
314
624
  return child_range(&Priority, &Priority + 1);
315
744
}
316
317
0
OMPClause::child_range OMPNovariantsClause::used_children() {
318
0
  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
319
0
    return child_range(C, C + 1);
320
0
  return child_range(&Condition, &Condition + 1);
321
0
}
322
323
0
OMPClause::child_range OMPNocontextClause::used_children() {
324
0
  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
325
0
    return child_range(C, C + 1);
326
0
  return child_range(&Condition, &Condition + 1);
327
0
}
328
329
OMPOrderedClause *OMPOrderedClause::Create(const ASTContext &C, Expr *Num,
330
                                           unsigned NumLoops,
331
                                           SourceLocation StartLoc,
332
                                           SourceLocation LParenLoc,
333
1.18k
                                           SourceLocation EndLoc) {
334
1.18k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
335
1.18k
  auto *Clause =
336
1.18k
      new (Mem) OMPOrderedClause(Num, NumLoops, StartLoc, LParenLoc, EndLoc);
337
2.16k
  for (unsigned I = 0; I < NumLoops; 
++I987
) {
338
987
    Clause->setLoopNumIterations(I, nullptr);
339
987
    Clause->setLoopCounter(I, nullptr);
340
987
  }
341
1.18k
  return Clause;
342
1.18k
}
343
344
OMPOrderedClause *OMPOrderedClause::CreateEmpty(const ASTContext &C,
345
89
                                                unsigned NumLoops) {
346
89
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
347
89
  auto *Clause = new (Mem) OMPOrderedClause(NumLoops);
348
126
  for (unsigned I = 0; I < NumLoops; 
++I37
) {
349
37
    Clause->setLoopNumIterations(I, nullptr);
350
37
    Clause->setLoopCounter(I, nullptr);
351
37
  }
352
89
  return Clause;
353
89
}
354
355
void OMPOrderedClause::setLoopNumIterations(unsigned NumLoop,
356
1.46k
                                            Expr *NumIterations) {
357
1.46k
  assert(NumLoop < NumberOfLoops && "out of loops number.");
358
0
  getTrailingObjects<Expr *>()[NumLoop] = NumIterations;
359
1.46k
}
360
361
778
ArrayRef<Expr *> OMPOrderedClause::getLoopNumIterations() const {
362
778
  return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops);
363
778
}
364
365
1.46k
void OMPOrderedClause::setLoopCounter(unsigned NumLoop, Expr *Counter) {
366
1.46k
  assert(NumLoop < NumberOfLoops && "out of loops number.");
367
0
  getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter;
368
1.46k
}
369
370
37
Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) {
371
37
  assert(NumLoop < NumberOfLoops && "out of loops number.");
372
0
  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
373
37
}
374
375
16
const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) const {
376
16
  assert(NumLoop < NumberOfLoops && "out of loops number.");
377
0
  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
378
16
}
379
380
OMPUpdateClause *OMPUpdateClause::Create(const ASTContext &C,
381
                                         SourceLocation StartLoc,
382
517
                                         SourceLocation EndLoc) {
383
517
  return new (C) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/false);
384
517
}
385
386
OMPUpdateClause *
387
OMPUpdateClause::Create(const ASTContext &C, SourceLocation StartLoc,
388
                        SourceLocation LParenLoc, SourceLocation ArgumentLoc,
389
28
                        OpenMPDependClauseKind DK, SourceLocation EndLoc) {
390
28
  void *Mem =
391
28
      C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
392
28
                 alignof(OMPUpdateClause));
393
28
  auto *Clause =
394
28
      new (Mem) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/true);
395
28
  Clause->setLParenLoc(LParenLoc);
396
28
  Clause->setArgumentLoc(ArgumentLoc);
397
28
  Clause->setDependencyKind(DK);
398
28
  return Clause;
399
28
}
400
401
OMPUpdateClause *OMPUpdateClause::CreateEmpty(const ASTContext &C,
402
88
                                              bool IsExtended) {
403
88
  if (!IsExtended)
404
80
    return new (C) OMPUpdateClause(/*IsExtended=*/false);
405
8
  void *Mem =
406
8
      C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
407
8
                 alignof(OMPUpdateClause));
408
8
  auto *Clause = new (Mem) OMPUpdateClause(/*IsExtended=*/true);
409
8
  Clause->IsExtended = true;
410
8
  return Clause;
411
88
}
412
413
14.3k
void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
414
14.3k
  assert(VL.size() == varlist_size() &&
415
14.3k
         "Number of private copies is not the same as the preallocated buffer");
416
0
  std::copy(VL.begin(), VL.end(), varlist_end());
417
14.3k
}
418
419
OMPPrivateClause *
420
OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
421
                         SourceLocation LParenLoc, SourceLocation EndLoc,
422
12.9k
                         ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
423
  // Allocate space for private variables and initializer expressions.
424
12.9k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
425
12.9k
  OMPPrivateClause *Clause =
426
12.9k
      new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
427
12.9k
  Clause->setVarRefs(VL);
428
12.9k
  Clause->setPrivateCopies(PrivateVL);
429
12.9k
  return Clause;
430
12.9k
}
431
432
OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C,
433
1.39k
                                                unsigned N) {
434
1.39k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
435
1.39k
  return new (Mem) OMPPrivateClause(N);
436
1.39k
}
437
438
54.3k
void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
439
54.3k
  assert(VL.size() == varlist_size() &&
440
54.3k
         "Number of private copies is not the same as the preallocated buffer");
441
0
  std::copy(VL.begin(), VL.end(), varlist_end());
442
54.3k
}
443
444
54.3k
void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
445
54.3k
  assert(VL.size() == varlist_size() &&
446
54.3k
         "Number of inits is not the same as the preallocated buffer");
447
0
  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
448
54.3k
}
449
450
OMPFirstprivateClause *
451
OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
452
                              SourceLocation LParenLoc, SourceLocation EndLoc,
453
                              ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
454
50.1k
                              ArrayRef<Expr *> InitVL, Stmt *PreInit) {
455
50.1k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
456
50.1k
  OMPFirstprivateClause *Clause =
457
50.1k
      new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
458
50.1k
  Clause->setVarRefs(VL);
459
50.1k
  Clause->setPrivateCopies(PrivateVL);
460
50.1k
  Clause->setInits(InitVL);
461
50.1k
  Clause->setPreInitStmt(PreInit);
462
50.1k
  return Clause;
463
50.1k
}
464
465
OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C,
466
4.22k
                                                          unsigned N) {
467
4.22k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
468
4.22k
  return new (Mem) OMPFirstprivateClause(N);
469
4.22k
}
470
471
6.24k
void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) {
472
6.24k
  assert(PrivateCopies.size() == varlist_size() &&
473
6.24k
         "Number of private copies is not the same as the preallocated buffer");
474
0
  std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
475
6.24k
}
476
477
6.25k
void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
478
6.25k
  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
479
6.25k
                                              "not the same as the "
480
6.25k
                                              "preallocated buffer");
481
0
  std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
482
6.25k
}
483
484
6.25k
void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
485
6.25k
  assert(DstExprs.size() == varlist_size() && "Number of destination "
486
6.25k
                                              "expressions is not the same as "
487
6.25k
                                              "the preallocated buffer");
488
0
  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
489
6.25k
}
490
491
6.25k
void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
492
6.25k
  assert(AssignmentOps.size() == varlist_size() &&
493
6.25k
         "Number of assignment expressions is not the same as the preallocated "
494
6.25k
         "buffer");
495
0
  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
496
6.25k
            getDestinationExprs().end());
497
6.25k
}
498
499
OMPLastprivateClause *OMPLastprivateClause::Create(
500
    const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
501
    SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
502
    ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
503
    OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
504
5.85k
    SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate) {
505
5.85k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
506
5.85k
  OMPLastprivateClause *Clause = new (Mem) OMPLastprivateClause(
507
5.85k
      StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size());
508
5.85k
  Clause->setVarRefs(VL);
509
5.85k
  Clause->setSourceExprs(SrcExprs);
510
5.85k
  Clause->setDestinationExprs(DstExprs);
511
5.85k
  Clause->setAssignmentOps(AssignmentOps);
512
5.85k
  Clause->setPreInitStmt(PreInit);
513
5.85k
  Clause->setPostUpdateExpr(PostUpdate);
514
5.85k
  return Clause;
515
5.85k
}
516
517
OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C,
518
398
                                                        unsigned N) {
519
398
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
520
398
  return new (Mem) OMPLastprivateClause(N);
521
398
}
522
523
OMPSharedClause *OMPSharedClause::Create(const ASTContext &C,
524
                                         SourceLocation StartLoc,
525
                                         SourceLocation LParenLoc,
526
                                         SourceLocation EndLoc,
527
3.93k
                                         ArrayRef<Expr *> VL) {
528
3.93k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
529
3.93k
  OMPSharedClause *Clause =
530
3.93k
      new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
531
3.93k
  Clause->setVarRefs(VL);
532
3.93k
  return Clause;
533
3.93k
}
534
535
402
OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) {
536
402
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
537
402
  return new (Mem) OMPSharedClause(N);
538
402
}
539
540
2.98k
void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) {
541
2.98k
  assert(PL.size() == varlist_size() &&
542
2.98k
         "Number of privates is not the same as the preallocated buffer");
543
0
  std::copy(PL.begin(), PL.end(), varlist_end());
544
2.98k
}
545
546
2.98k
void OMPLinearClause::setInits(ArrayRef<Expr *> IL) {
547
2.98k
  assert(IL.size() == varlist_size() &&
548
2.98k
         "Number of inits is not the same as the preallocated buffer");
549
0
  std::copy(IL.begin(), IL.end(), getPrivates().end());
550
2.98k
}
551
552
2.35k
void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) {
553
2.35k
  assert(UL.size() == varlist_size() &&
554
2.35k
         "Number of updates is not the same as the preallocated buffer");
555
0
  std::copy(UL.begin(), UL.end(), getInits().end());
556
2.35k
}
557
558
2.35k
void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) {
559
2.35k
  assert(FL.size() == varlist_size() &&
560
2.35k
         "Number of final updates is not the same as the preallocated buffer");
561
0
  std::copy(FL.begin(), FL.end(), getUpdates().end());
562
2.35k
}
563
564
2.35k
void OMPLinearClause::setUsedExprs(ArrayRef<Expr *> UE) {
565
2.35k
  assert(
566
2.35k
      UE.size() == varlist_size() + 1 &&
567
2.35k
      "Number of used expressions is not the same as the preallocated buffer");
568
0
  std::copy(UE.begin(), UE.end(), getFinals().end() + 2);
569
2.35k
}
570
571
OMPLinearClause *OMPLinearClause::Create(
572
    const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
573
    OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
574
    SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
575
    ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep,
576
2.61k
    Stmt *PreInit, Expr *PostUpdate) {
577
  // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
578
  // (Step and CalcStep), list of used expression + step.
579
2.61k
  void *Mem =
580
2.61k
      C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
581
2.61k
  OMPLinearClause *Clause = new (Mem) OMPLinearClause(
582
2.61k
      StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
583
2.61k
  Clause->setVarRefs(VL);
584
2.61k
  Clause->setPrivates(PL);
585
2.61k
  Clause->setInits(IL);
586
  // Fill update and final expressions with zeroes, they are provided later,
587
  // after the directive construction.
588
2.61k
  std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
589
2.61k
            nullptr);
590
2.61k
  std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
591
2.61k
            nullptr);
592
2.61k
  std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
593
2.61k
            nullptr);
594
2.61k
  Clause->setStep(Step);
595
2.61k
  Clause->setCalcStep(CalcStep);
596
2.61k
  Clause->setPreInitStmt(PreInit);
597
2.61k
  Clause->setPostUpdateExpr(PostUpdate);
598
2.61k
  return Clause;
599
2.61k
}
600
601
OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C,
602
374
                                              unsigned NumVars) {
603
  // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
604
  // (Step and CalcStep), list of used expression + step.
605
374
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars  +1));
606
374
  return new (Mem) OMPLinearClause(NumVars);
607
374
}
608
609
2.07k
OMPClause::child_range OMPLinearClause::used_children() {
610
  // Range includes only non-nullptr elements.
611
2.07k
  return child_range(
612
2.07k
      reinterpret_cast<Stmt **>(getUsedExprs().begin()),
613
2.07k
      reinterpret_cast<Stmt **>(llvm::find(getUsedExprs(), nullptr)));
614
2.07k
}
615
616
OMPAlignedClause *
617
OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc,
618
                         SourceLocation LParenLoc, SourceLocation ColonLoc,
619
1.69k
                         SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
620
1.69k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
621
1.69k
  OMPAlignedClause *Clause = new (Mem)
622
1.69k
      OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
623
1.69k
  Clause->setVarRefs(VL);
624
1.69k
  Clause->setAlignment(A);
625
1.69k
  return Clause;
626
1.69k
}
627
628
OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C,
629
250
                                                unsigned NumVars) {
630
250
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
631
250
  return new (Mem) OMPAlignedClause(NumVars);
632
250
}
633
634
OMPAlignClause *OMPAlignClause::Create(const ASTContext &C, Expr *A,
635
                                       SourceLocation StartLoc,
636
                                       SourceLocation LParenLoc,
637
61
                                       SourceLocation EndLoc) {
638
61
  return new (C) OMPAlignClause(A, StartLoc, LParenLoc, EndLoc);
639
61
}
640
641
502
void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
642
502
  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
643
502
                                              "not the same as the "
644
502
                                              "preallocated buffer");
645
0
  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
646
502
}
647
648
502
void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
649
502
  assert(DstExprs.size() == varlist_size() && "Number of destination "
650
502
                                              "expressions is not the same as "
651
502
                                              "the preallocated buffer");
652
0
  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
653
502
}
654
655
502
void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
656
502
  assert(AssignmentOps.size() == varlist_size() &&
657
502
         "Number of assignment expressions is not the same as the preallocated "
658
502
         "buffer");
659
0
  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
660
502
            getDestinationExprs().end());
661
502
}
662
663
OMPCopyinClause *OMPCopyinClause::Create(
664
    const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
665
    SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
666
424
    ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
667
424
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
668
424
  OMPCopyinClause *Clause =
669
424
      new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
670
424
  Clause->setVarRefs(VL);
671
424
  Clause->setSourceExprs(SrcExprs);
672
424
  Clause->setDestinationExprs(DstExprs);
673
424
  Clause->setAssignmentOps(AssignmentOps);
674
424
  return Clause;
675
424
}
676
677
78
OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) {
678
78
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
679
78
  return new (Mem) OMPCopyinClause(N);
680
78
}
681
682
181
void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
683
181
  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
684
181
                                              "not the same as the "
685
181
                                              "preallocated buffer");
686
0
  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
687
181
}
688
689
181
void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
690
181
  assert(DstExprs.size() == varlist_size() && "Number of destination "
691
181
                                              "expressions is not the same as "
692
181
                                              "the preallocated buffer");
693
0
  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
694
181
}
695
696
181
void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
697
181
  assert(AssignmentOps.size() == varlist_size() &&
698
181
         "Number of assignment expressions is not the same as the preallocated "
699
181
         "buffer");
700
0
  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
701
181
            getDestinationExprs().end());
702
181
}
703
704
OMPCopyprivateClause *OMPCopyprivateClause::Create(
705
    const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
706
    SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
707
158
    ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
708
158
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
709
158
  OMPCopyprivateClause *Clause =
710
158
      new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
711
158
  Clause->setVarRefs(VL);
712
158
  Clause->setSourceExprs(SrcExprs);
713
158
  Clause->setDestinationExprs(DstExprs);
714
158
  Clause->setAssignmentOps(AssignmentOps);
715
158
  return Clause;
716
158
}
717
718
OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C,
719
23
                                                        unsigned N) {
720
23
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
721
23
  return new (Mem) OMPCopyprivateClause(N);
722
23
}
723
724
25.6k
void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
725
25.6k
  assert(Privates.size() == varlist_size() &&
726
25.6k
         "Number of private copies is not the same as the preallocated buffer");
727
0
  std::copy(Privates.begin(), Privates.end(), varlist_end());
728
25.6k
}
729
730
25.6k
void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
731
25.6k
  assert(
732
25.6k
      LHSExprs.size() == varlist_size() &&
733
25.6k
      "Number of LHS expressions is not the same as the preallocated buffer");
734
0
  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
735
25.6k
}
736
737
25.6k
void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
738
25.6k
  assert(
739
25.6k
      RHSExprs.size() == varlist_size() &&
740
25.6k
      "Number of RHS expressions is not the same as the preallocated buffer");
741
0
  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
742
25.6k
}
743
744
25.6k
void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
745
25.6k
  assert(ReductionOps.size() == varlist_size() && "Number of reduction "
746
25.6k
                                                  "expressions is not the same "
747
25.6k
                                                  "as the preallocated buffer");
748
0
  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
749
25.6k
}
750
751
162
void OMPReductionClause::setInscanCopyOps(ArrayRef<Expr *> Ops) {
752
162
  assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
753
0
  assert(Ops.size() == varlist_size() && "Number of copy "
754
162
                                         "expressions is not the same "
755
162
                                         "as the preallocated buffer");
756
0
  llvm::copy(Ops, getReductionOps().end());
757
162
}
758
759
void OMPReductionClause::setInscanCopyArrayTemps(
760
162
    ArrayRef<Expr *> CopyArrayTemps) {
761
162
  assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
762
0
  assert(CopyArrayTemps.size() == varlist_size() &&
763
162
         "Number of copy temp expressions is not the same as the preallocated "
764
162
         "buffer");
765
0
  llvm::copy(CopyArrayTemps, getInscanCopyOps().end());
766
162
}
767
768
void OMPReductionClause::setInscanCopyArrayElems(
769
162
    ArrayRef<Expr *> CopyArrayElems) {
770
162
  assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
771
0
  assert(CopyArrayElems.size() == varlist_size() &&
772
162
         "Number of copy temp expressions is not the same as the preallocated "
773
162
         "buffer");
774
0
  llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end());
775
162
}
776
777
OMPReductionClause *OMPReductionClause::Create(
778
    const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
779
    SourceLocation ModifierLoc, SourceLocation EndLoc, SourceLocation ColonLoc,
780
    OpenMPReductionClauseModifier Modifier, ArrayRef<Expr *> VL,
781
    NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
782
    ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
783
    ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
784
    ArrayRef<Expr *> CopyOps, ArrayRef<Expr *> CopyArrayTemps,
785
24.7k
    ArrayRef<Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate) {
786
24.7k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
787
24.7k
      (Modifier == OMPC_REDUCTION_inscan ? 
8138
:
524.6k
) * VL.size()));
788
24.7k
  auto *Clause = new (Mem)
789
24.7k
      OMPReductionClause(StartLoc, LParenLoc, ModifierLoc, EndLoc, ColonLoc,
790
24.7k
                         Modifier, VL.size(), QualifierLoc, NameInfo);
791
24.7k
  Clause->setVarRefs(VL);
792
24.7k
  Clause->setPrivates(Privates);
793
24.7k
  Clause->setLHSExprs(LHSExprs);
794
24.7k
  Clause->setRHSExprs(RHSExprs);
795
24.7k
  Clause->setReductionOps(ReductionOps);
796
24.7k
  Clause->setPreInitStmt(PreInit);
797
24.7k
  Clause->setPostUpdateExpr(PostUpdate);
798
24.7k
  if (Modifier == OMPC_REDUCTION_inscan) {
799
138
    Clause->setInscanCopyOps(CopyOps);
800
138
    Clause->setInscanCopyArrayTemps(CopyArrayTemps);
801
138
    Clause->setInscanCopyArrayElems(CopyArrayElems);
802
24.6k
  } else {
803
24.6k
    assert(CopyOps.empty() &&
804
24.6k
           "copy operations are expected in inscan reductions only.");
805
0
    assert(CopyArrayTemps.empty() &&
806
24.6k
           "copy array temps are expected in inscan reductions only.");
807
0
    assert(CopyArrayElems.empty() &&
808
24.6k
           "copy array temps are expected in inscan reductions only.");
809
24.6k
  }
810
0
  return Clause;
811
24.7k
}
812
813
OMPReductionClause *
814
OMPReductionClause::CreateEmpty(const ASTContext &C, unsigned N,
815
920
                                OpenMPReductionClauseModifier Modifier) {
816
920
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
817
920
      (Modifier == OMPC_REDUCTION_inscan ? 
824
:
5896
) * N));
818
920
  auto *Clause = new (Mem) OMPReductionClause(N);
819
920
  Clause->setModifier(Modifier);
820
920
  return Clause;
821
920
}
822
823
2.35k
void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
824
2.35k
  assert(Privates.size() == varlist_size() &&
825
2.35k
         "Number of private copies is not the same as the preallocated buffer");
826
0
  std::copy(Privates.begin(), Privates.end(), varlist_end());
827
2.35k
}
828
829
2.35k
void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
830
2.35k
  assert(
831
2.35k
      LHSExprs.size() == varlist_size() &&
832
2.35k
      "Number of LHS expressions is not the same as the preallocated buffer");
833
0
  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
834
2.35k
}
835
836
2.35k
void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
837
2.35k
  assert(
838
2.35k
      RHSExprs.size() == varlist_size() &&
839
2.35k
      "Number of RHS expressions is not the same as the preallocated buffer");
840
0
  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
841
2.35k
}
842
843
2.35k
void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
844
2.35k
  assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
845
2.35k
                                                  "expressions is not the same "
846
2.35k
                                                  "as the preallocated buffer");
847
0
  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
848
2.35k
}
849
850
OMPTaskReductionClause *OMPTaskReductionClause::Create(
851
    const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
852
    SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
853
    NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
854
    ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
855
    ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
856
2.26k
    Expr *PostUpdate) {
857
2.26k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
858
2.26k
  OMPTaskReductionClause *Clause = new (Mem) OMPTaskReductionClause(
859
2.26k
      StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
860
2.26k
  Clause->setVarRefs(VL);
861
2.26k
  Clause->setPrivates(Privates);
862
2.26k
  Clause->setLHSExprs(LHSExprs);
863
2.26k
  Clause->setRHSExprs(RHSExprs);
864
2.26k
  Clause->setReductionOps(ReductionOps);
865
2.26k
  Clause->setPreInitStmt(PreInit);
866
2.26k
  Clause->setPostUpdateExpr(PostUpdate);
867
2.26k
  return Clause;
868
2.26k
}
869
870
OMPTaskReductionClause *OMPTaskReductionClause::CreateEmpty(const ASTContext &C,
871
86
                                                            unsigned N) {
872
86
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
873
86
  return new (Mem) OMPTaskReductionClause(N);
874
86
}
875
876
1.63k
void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
877
1.63k
  assert(Privates.size() == varlist_size() &&
878
1.63k
         "Number of private copies is not the same as the preallocated buffer");
879
0
  std::copy(Privates.begin(), Privates.end(), varlist_end());
880
1.63k
}
881
882
1.63k
void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
883
1.63k
  assert(
884
1.63k
      LHSExprs.size() == varlist_size() &&
885
1.63k
      "Number of LHS expressions is not the same as the preallocated buffer");
886
0
  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
887
1.63k
}
888
889
1.63k
void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
890
1.63k
  assert(
891
1.63k
      RHSExprs.size() == varlist_size() &&
892
1.63k
      "Number of RHS expressions is not the same as the preallocated buffer");
893
0
  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
894
1.63k
}
895
896
1.63k
void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
897
1.63k
  assert(ReductionOps.size() == varlist_size() && "Number of in reduction "
898
1.63k
                                                  "expressions is not the same "
899
1.63k
                                                  "as the preallocated buffer");
900
0
  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
901
1.63k
}
902
903
void OMPInReductionClause::setTaskgroupDescriptors(
904
1.63k
    ArrayRef<Expr *> TaskgroupDescriptors) {
905
1.63k
  assert(TaskgroupDescriptors.size() == varlist_size() &&
906
1.63k
         "Number of in reduction descriptors is not the same as the "
907
1.63k
         "preallocated buffer");
908
0
  std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
909
1.63k
            getReductionOps().end());
910
1.63k
}
911
912
OMPInReductionClause *OMPInReductionClause::Create(
913
    const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
914
    SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
915
    NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
916
    ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
917
    ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
918
1.56k
    ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) {
919
1.56k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
920
1.56k
  OMPInReductionClause *Clause = new (Mem) OMPInReductionClause(
921
1.56k
      StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
922
1.56k
  Clause->setVarRefs(VL);
923
1.56k
  Clause->setPrivates(Privates);
924
1.56k
  Clause->setLHSExprs(LHSExprs);
925
1.56k
  Clause->setRHSExprs(RHSExprs);
926
1.56k
  Clause->setReductionOps(ReductionOps);
927
1.56k
  Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
928
1.56k
  Clause->setPreInitStmt(PreInit);
929
1.56k
  Clause->setPostUpdateExpr(PostUpdate);
930
1.56k
  return Clause;
931
1.56k
}
932
933
OMPInReductionClause *OMPInReductionClause::CreateEmpty(const ASTContext &C,
934
78
                                                        unsigned N) {
935
78
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
936
78
  return new (Mem) OMPInReductionClause(N);
937
78
}
938
939
OMPSizesClause *OMPSizesClause::Create(const ASTContext &C,
940
                                       SourceLocation StartLoc,
941
                                       SourceLocation LParenLoc,
942
                                       SourceLocation EndLoc,
943
80
                                       ArrayRef<Expr *> Sizes) {
944
80
  OMPSizesClause *Clause = CreateEmpty(C, Sizes.size());
945
80
  Clause->setLocStart(StartLoc);
946
80
  Clause->setLParenLoc(LParenLoc);
947
80
  Clause->setLocEnd(EndLoc);
948
80
  Clause->setSizesRefs(Sizes);
949
80
  return Clause;
950
80
}
951
952
OMPSizesClause *OMPSizesClause::CreateEmpty(const ASTContext &C,
953
106
                                            unsigned NumSizes) {
954
106
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumSizes));
955
106
  return new (Mem) OMPSizesClause(NumSizes);
956
106
}
957
958
OMPFullClause *OMPFullClause::Create(const ASTContext &C,
959
                                     SourceLocation StartLoc,
960
15
                                     SourceLocation EndLoc) {
961
15
  OMPFullClause *Clause = CreateEmpty(C);
962
15
  Clause->setLocStart(StartLoc);
963
15
  Clause->setLocEnd(EndLoc);
964
15
  return Clause;
965
15
}
966
967
18
OMPFullClause *OMPFullClause::CreateEmpty(const ASTContext &C) {
968
18
  return new (C) OMPFullClause();
969
18
}
970
971
OMPPartialClause *OMPPartialClause::Create(const ASTContext &C,
972
                                           SourceLocation StartLoc,
973
                                           SourceLocation LParenLoc,
974
                                           SourceLocation EndLoc,
975
69
                                           Expr *Factor) {
976
69
  OMPPartialClause *Clause = CreateEmpty(C);
977
69
  Clause->setLocStart(StartLoc);
978
69
  Clause->setLParenLoc(LParenLoc);
979
69
  Clause->setLocEnd(EndLoc);
980
69
  Clause->setFactor(Factor);
981
69
  return Clause;
982
69
}
983
984
89
OMPPartialClause *OMPPartialClause::CreateEmpty(const ASTContext &C) {
985
89
  return new (C) OMPPartialClause();
986
89
}
987
988
OMPAllocateClause *
989
OMPAllocateClause::Create(const ASTContext &C, SourceLocation StartLoc,
990
                          SourceLocation LParenLoc, Expr *Allocator,
991
                          SourceLocation ColonLoc, SourceLocation EndLoc,
992
1.75k
                          ArrayRef<Expr *> VL) {
993
  // Allocate space for private variables and initializer expressions.
994
1.75k
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
995
1.75k
  auto *Clause = new (Mem) OMPAllocateClause(StartLoc, LParenLoc, Allocator,
996
1.75k
                                             ColonLoc, EndLoc, VL.size());
997
1.75k
  Clause->setVarRefs(VL);
998
1.75k
  return Clause;
999
1.75k
}
1000
1001
OMPAllocateClause *OMPAllocateClause::CreateEmpty(const ASTContext &C,
1002
237
                                                  unsigned N) {
1003
237
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1004
237
  return new (Mem) OMPAllocateClause(N);
1005
237
}
1006
1007
OMPFlushClause *OMPFlushClause::Create(const ASTContext &C,
1008
                                       SourceLocation StartLoc,
1009
                                       SourceLocation LParenLoc,
1010
                                       SourceLocation EndLoc,
1011
86
                                       ArrayRef<Expr *> VL) {
1012
86
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
1013
86
  OMPFlushClause *Clause =
1014
86
      new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
1015
86
  Clause->setVarRefs(VL);
1016
86
  return Clause;
1017
86
}
1018
1019
10
OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) {
1020
10
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1021
10
  return new (Mem) OMPFlushClause(N);
1022
10
}
1023
1024
OMPDepobjClause *OMPDepobjClause::Create(const ASTContext &C,
1025
                                         SourceLocation StartLoc,
1026
                                         SourceLocation LParenLoc,
1027
                                         SourceLocation RParenLoc,
1028
248
                                         Expr *Depobj) {
1029
248
  auto *Clause = new (C) OMPDepobjClause(StartLoc, LParenLoc, RParenLoc);
1030
248
  Clause->setDepobj(Depobj);
1031
248
  return Clause;
1032
248
}
1033
1034
28
OMPDepobjClause *OMPDepobjClause::CreateEmpty(const ASTContext &C) {
1035
28
  return new (C) OMPDepobjClause();
1036
28
}
1037
1038
OMPDependClause *
1039
OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc,
1040
                        SourceLocation LParenLoc, SourceLocation EndLoc,
1041
                        Expr *DepModifier, OpenMPDependClauseKind DepKind,
1042
                        SourceLocation DepLoc, SourceLocation ColonLoc,
1043
3.23k
                        ArrayRef<Expr *> VL, unsigned NumLoops) {
1044
3.23k
  void *Mem = C.Allocate(
1045
3.23k
      totalSizeToAlloc<Expr *>(VL.size() + /*depend-modifier*/ 1 + NumLoops),
1046
3.23k
      alignof(OMPDependClause));
1047
3.23k
  OMPDependClause *Clause = new (Mem)
1048
3.23k
      OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1049
3.23k
  Clause->setVarRefs(VL);
1050
3.23k
  Clause->setDependencyKind(DepKind);
1051
3.23k
  Clause->setDependencyLoc(DepLoc);
1052
3.23k
  Clause->setColonLoc(ColonLoc);
1053
3.23k
  Clause->setModifier(DepModifier);
1054
4.12k
  for (unsigned I = 0 ; I < NumLoops; 
++I889
)
1055
889
    Clause->setLoopData(I, nullptr);
1056
3.23k
  return Clause;
1057
3.23k
}
1058
1059
OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N,
1060
695
                                              unsigned NumLoops) {
1061
695
  void *Mem =
1062
695
      C.Allocate(totalSizeToAlloc<Expr *>(N + /*depend-modifier*/ 1 + NumLoops),
1063
695
                 alignof(OMPDependClause));
1064
695
  return new (Mem) OMPDependClause(N, NumLoops);
1065
695
}
1066
1067
1.49k
void OMPDependClause::setLoopData(unsigned NumLoop, Expr *Cnt) {
1068
1.49k
  assert((getDependencyKind() == OMPC_DEPEND_sink ||
1069
1.49k
          getDependencyKind() == OMPC_DEPEND_source) &&
1070
1.49k
         NumLoop < NumLoops &&
1071
1.49k
         "Expected sink or source depend + loop index must be less number of "
1072
1.49k
         "loops.");
1073
0
  auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1074
1.49k
  *It = Cnt;
1075
1.49k
}
1076
1077
44
Expr *OMPDependClause::getLoopData(unsigned NumLoop) {
1078
44
  assert((getDependencyKind() == OMPC_DEPEND_sink ||
1079
44
          getDependencyKind() == OMPC_DEPEND_source) &&
1080
44
         NumLoop < NumLoops &&
1081
44
         "Expected sink or source depend + loop index must be less number of "
1082
44
         "loops.");
1083
0
  auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1084
44
  return *It;
1085
44
}
1086
1087
48
const Expr *OMPDependClause::getLoopData(unsigned NumLoop) const {
1088
48
  assert((getDependencyKind() == OMPC_DEPEND_sink ||
1089
48
          getDependencyKind() == OMPC_DEPEND_source) &&
1090
48
         NumLoop < NumLoops &&
1091
48
         "Expected sink or source depend + loop index must be less number of "
1092
48
         "loops.");
1093
0
  const auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1094
48
  return *It;
1095
48
}
1096
1097
3.92k
void OMPDependClause::setModifier(Expr *DepModifier) {
1098
3.92k
  *getVarRefs().end() = DepModifier;
1099
3.92k
}
1100
2.66k
Expr *OMPDependClause::getModifier() { return *getVarRefs().end(); }
1101
1102
unsigned OMPClauseMappableExprCommon::getComponentsTotalNumber(
1103
101k
    MappableExprComponentListsRef ComponentLists) {
1104
101k
  unsigned TotalNum = 0u;
1105
101k
  for (auto &C : ComponentLists)
1106
101k
    TotalNum += C.size();
1107
101k
  return TotalNum;
1108
101k
}
1109
1110
unsigned OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber(
1111
101k
    ArrayRef<const ValueDecl *> Declarations) {
1112
101k
  unsigned TotalNum = 0u;
1113
101k
  llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
1114
101k
  for (const ValueDecl *D : Declarations) {
1115
101k
    const ValueDecl *VD = D ? 
cast<ValueDecl>(D->getCanonicalDecl())93.6k
:
nullptr7.79k
;
1116
101k
    if (Cache.count(VD))
1117
1.86k
      continue;
1118
99.6k
    ++TotalNum;
1119
99.6k
    Cache.insert(VD);
1120
99.6k
  }
1121
101k
  return TotalNum;
1122
101k
}
1123
1124
OMPMapClause *OMPMapClause::Create(
1125
    const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1126
    ArrayRef<ValueDecl *> Declarations,
1127
    MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1128
    ArrayRef<OpenMPMapModifierKind> MapModifiers,
1129
    ArrayRef<SourceLocation> MapModifiersLoc,
1130
    NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
1131
43.3k
    OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc) {
1132
43.3k
  OMPMappableExprListSizeTy Sizes;
1133
43.3k
  Sizes.NumVars = Vars.size();
1134
43.3k
  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1135
43.3k
  Sizes.NumComponentLists = ComponentLists.size();
1136
43.3k
  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1137
1138
  // We need to allocate:
1139
  // 2 x NumVars x Expr* - we have an original list expression and an associated
1140
  // user-defined mapper for each clause list entry.
1141
  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1142
  // with each component list.
1143
  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1144
  // number of lists for each unique declaration and the size of each component
1145
  // list.
1146
  // NumComponents x MappableComponent - the total of all the components in all
1147
  // the lists.
1148
43.3k
  void *Mem = C.Allocate(
1149
43.3k
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1150
43.3k
                       OMPClauseMappableExprCommon::MappableComponent>(
1151
43.3k
          2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1152
43.3k
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1153
43.3k
          Sizes.NumComponents));
1154
43.3k
  OMPMapClause *Clause = new (Mem)
1155
43.3k
      OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
1156
43.3k
                   Type, TypeIsImplicit, TypeLoc, Locs, Sizes);
1157
1158
43.3k
  Clause->setVarRefs(Vars);
1159
43.3k
  Clause->setUDMapperRefs(UDMapperRefs);
1160
43.3k
  Clause->setClauseInfo(Declarations, ComponentLists);
1161
43.3k
  Clause->setMapType(Type);
1162
43.3k
  Clause->setMapLoc(TypeLoc);
1163
43.3k
  return Clause;
1164
43.3k
}
1165
1166
OMPMapClause *
1167
OMPMapClause::CreateEmpty(const ASTContext &C,
1168
4.15k
                          const OMPMappableExprListSizeTy &Sizes) {
1169
4.15k
  void *Mem = C.Allocate(
1170
4.15k
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1171
4.15k
                       OMPClauseMappableExprCommon::MappableComponent>(
1172
4.15k
          2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1173
4.15k
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1174
4.15k
          Sizes.NumComponents));
1175
4.15k
  return new (Mem) OMPMapClause(Sizes);
1176
4.15k
}
1177
1178
OMPToClause *OMPToClause::Create(
1179
    const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1180
    ArrayRef<ValueDecl *> Declarations,
1181
    MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1182
    ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
1183
    ArrayRef<SourceLocation> MotionModifiersLoc,
1184
2.61k
    NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
1185
2.61k
  OMPMappableExprListSizeTy Sizes;
1186
2.61k
  Sizes.NumVars = Vars.size();
1187
2.61k
  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1188
2.61k
  Sizes.NumComponentLists = ComponentLists.size();
1189
2.61k
  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1190
1191
  // We need to allocate:
1192
  // 2 x NumVars x Expr* - we have an original list expression and an associated
1193
  // user-defined mapper for each clause list entry.
1194
  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1195
  // with each component list.
1196
  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1197
  // number of lists for each unique declaration and the size of each component
1198
  // list.
1199
  // NumComponents x MappableComponent - the total of all the components in all
1200
  // the lists.
1201
2.61k
  void *Mem = C.Allocate(
1202
2.61k
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1203
2.61k
                       OMPClauseMappableExprCommon::MappableComponent>(
1204
2.61k
          2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1205
2.61k
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1206
2.61k
          Sizes.NumComponents));
1207
1208
2.61k
  auto *Clause = new (Mem) OMPToClause(MotionModifiers, MotionModifiersLoc,
1209
2.61k
                                       UDMQualifierLoc, MapperId, Locs, Sizes);
1210
1211
2.61k
  Clause->setVarRefs(Vars);
1212
2.61k
  Clause->setUDMapperRefs(UDMapperRefs);
1213
2.61k
  Clause->setClauseInfo(Declarations, ComponentLists);
1214
2.61k
  return Clause;
1215
2.61k
}
1216
1217
OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C,
1218
216
                                      const OMPMappableExprListSizeTy &Sizes) {
1219
216
  void *Mem = C.Allocate(
1220
216
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1221
216
                       OMPClauseMappableExprCommon::MappableComponent>(
1222
216
          2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1223
216
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1224
216
          Sizes.NumComponents));
1225
216
  return new (Mem) OMPToClause(Sizes);
1226
216
}
1227
1228
OMPFromClause *OMPFromClause::Create(
1229
    const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1230
    ArrayRef<ValueDecl *> Declarations,
1231
    MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1232
    ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
1233
    ArrayRef<SourceLocation> MotionModifiersLoc,
1234
1.31k
    NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
1235
1.31k
  OMPMappableExprListSizeTy Sizes;
1236
1.31k
  Sizes.NumVars = Vars.size();
1237
1.31k
  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1238
1.31k
  Sizes.NumComponentLists = ComponentLists.size();
1239
1.31k
  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1240
1241
  // We need to allocate:
1242
  // 2 x NumVars x Expr* - we have an original list expression and an associated
1243
  // user-defined mapper for each clause list entry.
1244
  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1245
  // with each component list.
1246
  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1247
  // number of lists for each unique declaration and the size of each component
1248
  // list.
1249
  // NumComponents x MappableComponent - the total of all the components in all
1250
  // the lists.
1251
1.31k
  void *Mem = C.Allocate(
1252
1.31k
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1253
1.31k
                       OMPClauseMappableExprCommon::MappableComponent>(
1254
1.31k
          2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1255
1.31k
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1256
1.31k
          Sizes.NumComponents));
1257
1258
1.31k
  auto *Clause =
1259
1.31k
      new (Mem) OMPFromClause(MotionModifiers, MotionModifiersLoc,
1260
1.31k
                              UDMQualifierLoc, MapperId, Locs, Sizes);
1261
1262
1.31k
  Clause->setVarRefs(Vars);
1263
1.31k
  Clause->setUDMapperRefs(UDMapperRefs);
1264
1.31k
  Clause->setClauseInfo(Declarations, ComponentLists);
1265
1.31k
  return Clause;
1266
1.31k
}
1267
1268
OMPFromClause *
1269
OMPFromClause::CreateEmpty(const ASTContext &C,
1270
196
                           const OMPMappableExprListSizeTy &Sizes) {
1271
196
  void *Mem = C.Allocate(
1272
196
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1273
196
                       OMPClauseMappableExprCommon::MappableComponent>(
1274
196
          2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1275
196
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1276
196
          Sizes.NumComponents));
1277
196
  return new (Mem) OMPFromClause(Sizes);
1278
196
}
1279
1280
502
void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
1281
502
  assert(VL.size() == varlist_size() &&
1282
502
         "Number of private copies is not the same as the preallocated buffer");
1283
0
  std::copy(VL.begin(), VL.end(), varlist_end());
1284
502
}
1285
1286
502
void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
1287
502
  assert(VL.size() == varlist_size() &&
1288
502
         "Number of inits is not the same as the preallocated buffer");
1289
0
  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
1290
502
}
1291
1292
OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create(
1293
    const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1294
    ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *> Inits,
1295
    ArrayRef<ValueDecl *> Declarations,
1296
412
    MappableExprComponentListsRef ComponentLists) {
1297
412
  OMPMappableExprListSizeTy Sizes;
1298
412
  Sizes.NumVars = Vars.size();
1299
412
  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1300
412
  Sizes.NumComponentLists = ComponentLists.size();
1301
412
  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1302
1303
  // We need to allocate:
1304
  // NumVars x Expr* - we have an original list expression for each clause
1305
  // list entry.
1306
  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1307
  // with each component list.
1308
  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1309
  // number of lists for each unique declaration and the size of each component
1310
  // list.
1311
  // NumComponents x MappableComponent - the total of all the components in all
1312
  // the lists.
1313
412
  void *Mem = C.Allocate(
1314
412
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1315
412
                       OMPClauseMappableExprCommon::MappableComponent>(
1316
412
          3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1317
412
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1318
412
          Sizes.NumComponents));
1319
1320
412
  OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(Locs, Sizes);
1321
1322
412
  Clause->setVarRefs(Vars);
1323
412
  Clause->setPrivateCopies(PrivateVars);
1324
412
  Clause->setInits(Inits);
1325
412
  Clause->setClauseInfo(Declarations, ComponentLists);
1326
412
  return Clause;
1327
412
}
1328
1329
OMPUseDevicePtrClause *
1330
OMPUseDevicePtrClause::CreateEmpty(const ASTContext &C,
1331
90
                                   const OMPMappableExprListSizeTy &Sizes) {
1332
90
  void *Mem = C.Allocate(
1333
90
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1334
90
                       OMPClauseMappableExprCommon::MappableComponent>(
1335
90
          3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1336
90
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1337
90
          Sizes.NumComponents));
1338
90
  return new (Mem) OMPUseDevicePtrClause(Sizes);
1339
90
}
1340
1341
OMPUseDeviceAddrClause *
1342
OMPUseDeviceAddrClause::Create(const ASTContext &C, const OMPVarListLocTy &Locs,
1343
                               ArrayRef<Expr *> Vars,
1344
                               ArrayRef<ValueDecl *> Declarations,
1345
116
                               MappableExprComponentListsRef ComponentLists) {
1346
116
  OMPMappableExprListSizeTy Sizes;
1347
116
  Sizes.NumVars = Vars.size();
1348
116
  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1349
116
  Sizes.NumComponentLists = ComponentLists.size();
1350
116
  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1351
1352
  // We need to allocate:
1353
  // 3 x NumVars x Expr* - we have an original list expression for each clause
1354
  // list entry and an equal number of private copies and inits.
1355
  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1356
  // with each component list.
1357
  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1358
  // number of lists for each unique declaration and the size of each component
1359
  // list.
1360
  // NumComponents x MappableComponent - the total of all the components in all
1361
  // the lists.
1362
116
  void *Mem = C.Allocate(
1363
116
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1364
116
                       OMPClauseMappableExprCommon::MappableComponent>(
1365
116
          Sizes.NumVars, Sizes.NumUniqueDeclarations,
1366
116
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1367
116
          Sizes.NumComponents));
1368
1369
116
  auto *Clause = new (Mem) OMPUseDeviceAddrClause(Locs, Sizes);
1370
1371
116
  Clause->setVarRefs(Vars);
1372
116
  Clause->setClauseInfo(Declarations, ComponentLists);
1373
116
  return Clause;
1374
116
}
1375
1376
OMPUseDeviceAddrClause *
1377
OMPUseDeviceAddrClause::CreateEmpty(const ASTContext &C,
1378
14
                                    const OMPMappableExprListSizeTy &Sizes) {
1379
14
  void *Mem = C.Allocate(
1380
14
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1381
14
                       OMPClauseMappableExprCommon::MappableComponent>(
1382
14
          Sizes.NumVars, Sizes.NumUniqueDeclarations,
1383
14
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1384
14
          Sizes.NumComponents));
1385
14
  return new (Mem) OMPUseDeviceAddrClause(Sizes);
1386
14
}
1387
1388
OMPIsDevicePtrClause *
1389
OMPIsDevicePtrClause::Create(const ASTContext &C, const OMPVarListLocTy &Locs,
1390
                             ArrayRef<Expr *> Vars,
1391
                             ArrayRef<ValueDecl *> Declarations,
1392
2.98k
                             MappableExprComponentListsRef ComponentLists) {
1393
2.98k
  OMPMappableExprListSizeTy Sizes;
1394
2.98k
  Sizes.NumVars = Vars.size();
1395
2.98k
  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1396
2.98k
  Sizes.NumComponentLists = ComponentLists.size();
1397
2.98k
  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1398
1399
  // We need to allocate:
1400
  // NumVars x Expr* - we have an original list expression for each clause list
1401
  // entry.
1402
  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1403
  // with each component list.
1404
  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1405
  // number of lists for each unique declaration and the size of each component
1406
  // list.
1407
  // NumComponents x MappableComponent - the total of all the components in all
1408
  // the lists.
1409
2.98k
  void *Mem = C.Allocate(
1410
2.98k
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1411
2.98k
                       OMPClauseMappableExprCommon::MappableComponent>(
1412
2.98k
          Sizes.NumVars, Sizes.NumUniqueDeclarations,
1413
2.98k
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1414
2.98k
          Sizes.NumComponents));
1415
1416
2.98k
  OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(Locs, Sizes);
1417
1418
2.98k
  Clause->setVarRefs(Vars);
1419
2.98k
  Clause->setClauseInfo(Declarations, ComponentLists);
1420
2.98k
  return Clause;
1421
2.98k
}
1422
1423
OMPIsDevicePtrClause *
1424
OMPIsDevicePtrClause::CreateEmpty(const ASTContext &C,
1425
442
                                  const OMPMappableExprListSizeTy &Sizes) {
1426
442
  void *Mem = C.Allocate(
1427
442
      totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1428
442
                       OMPClauseMappableExprCommon::MappableComponent>(
1429
442
          Sizes.NumVars, Sizes.NumUniqueDeclarations,
1430
442
          Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
1431
442
          Sizes.NumComponents));
1432
442
  return new (Mem) OMPIsDevicePtrClause(Sizes);
1433
442
}
1434
1435
OMPNontemporalClause *OMPNontemporalClause::Create(const ASTContext &C,
1436
                                                   SourceLocation StartLoc,
1437
                                                   SourceLocation LParenLoc,
1438
                                                   SourceLocation EndLoc,
1439
438
                                                   ArrayRef<Expr *> VL) {
1440
  // Allocate space for nontemporal variables + private references.
1441
438
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
1442
438
  auto *Clause =
1443
438
      new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size());
1444
438
  Clause->setVarRefs(VL);
1445
438
  return Clause;
1446
438
}
1447
1448
OMPNontemporalClause *OMPNontemporalClause::CreateEmpty(const ASTContext &C,
1449
90
                                                        unsigned N) {
1450
90
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
1451
90
  return new (Mem) OMPNontemporalClause(N);
1452
90
}
1453
1454
528
void OMPNontemporalClause::setPrivateRefs(ArrayRef<Expr *> VL) {
1455
528
  assert(VL.size() == varlist_size() && "Number of private references is not "
1456
528
                                        "the same as the preallocated buffer");
1457
0
  std::copy(VL.begin(), VL.end(), varlist_end());
1458
528
}
1459
1460
OMPInclusiveClause *OMPInclusiveClause::Create(const ASTContext &C,
1461
                                               SourceLocation StartLoc,
1462
                                               SourceLocation LParenLoc,
1463
                                               SourceLocation EndLoc,
1464
104
                                               ArrayRef<Expr *> VL) {
1465
104
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1466
104
  auto *Clause =
1467
104
      new (Mem) OMPInclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1468
104
  Clause->setVarRefs(VL);
1469
104
  return Clause;
1470
104
}
1471
1472
OMPInclusiveClause *OMPInclusiveClause::CreateEmpty(const ASTContext &C,
1473
12
                                                    unsigned N) {
1474
12
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1475
12
  return new (Mem) OMPInclusiveClause(N);
1476
12
}
1477
1478
OMPExclusiveClause *OMPExclusiveClause::Create(const ASTContext &C,
1479
                                               SourceLocation StartLoc,
1480
                                               SourceLocation LParenLoc,
1481
                                               SourceLocation EndLoc,
1482
70
                                               ArrayRef<Expr *> VL) {
1483
70
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1484
70
  auto *Clause =
1485
70
      new (Mem) OMPExclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1486
70
  Clause->setVarRefs(VL);
1487
70
  return Clause;
1488
70
}
1489
1490
OMPExclusiveClause *OMPExclusiveClause::CreateEmpty(const ASTContext &C,
1491
12
                                                    unsigned N) {
1492
12
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1493
12
  return new (Mem) OMPExclusiveClause(N);
1494
12
}
1495
1496
void OMPUsesAllocatorsClause::setAllocatorsData(
1497
276
    ArrayRef<OMPUsesAllocatorsClause::Data> Data) {
1498
276
  assert(Data.size() == NumOfAllocators &&
1499
276
         "Size of allocators data is not the same as the preallocated buffer.");
1500
612
  for (unsigned I = 0, E = Data.size(); I < E; 
++I336
) {
1501
336
    const OMPUsesAllocatorsClause::Data &D = Data[I];
1502
336
    getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1503
336
                                 static_cast<int>(ExprOffsets::Allocator)] =
1504
336
        D.Allocator;
1505
336
    getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1506
336
                                 static_cast<int>(
1507
336
                                     ExprOffsets::AllocatorTraits)] =
1508
336
        D.AllocatorTraits;
1509
336
    getTrailingObjects<
1510
336
        SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1511
336
                          static_cast<int>(ParenLocsOffsets::LParen)] =
1512
336
        D.LParenLoc;
1513
336
    getTrailingObjects<
1514
336
        SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1515
336
                          static_cast<int>(ParenLocsOffsets::RParen)] =
1516
336
        D.RParenLoc;
1517
336
  }
1518
276
}
1519
1520
OMPUsesAllocatorsClause::Data
1521
910
OMPUsesAllocatorsClause::getAllocatorData(unsigned I) const {
1522
910
  OMPUsesAllocatorsClause::Data Data;
1523
910
  Data.Allocator =
1524
910
      getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1525
910
                                   static_cast<int>(ExprOffsets::Allocator)];
1526
910
  Data.AllocatorTraits =
1527
910
      getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1528
910
                                   static_cast<int>(
1529
910
                                       ExprOffsets::AllocatorTraits)];
1530
910
  Data.LParenLoc = getTrailingObjects<
1531
910
      SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1532
910
                        static_cast<int>(ParenLocsOffsets::LParen)];
1533
910
  Data.RParenLoc = getTrailingObjects<
1534
910
      SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1535
910
                        static_cast<int>(ParenLocsOffsets::RParen)];
1536
910
  return Data;
1537
910
}
1538
1539
OMPUsesAllocatorsClause *
1540
OMPUsesAllocatorsClause::Create(const ASTContext &C, SourceLocation StartLoc,
1541
                                SourceLocation LParenLoc, SourceLocation EndLoc,
1542
246
                                ArrayRef<OMPUsesAllocatorsClause::Data> Data) {
1543
246
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1544
246
      static_cast<int>(ExprOffsets::Total) * Data.size(),
1545
246
      static_cast<int>(ParenLocsOffsets::Total) * Data.size()));
1546
246
  auto *Clause = new (Mem)
1547
246
      OMPUsesAllocatorsClause(StartLoc, LParenLoc, EndLoc, Data.size());
1548
246
  Clause->setAllocatorsData(Data);
1549
246
  return Clause;
1550
246
}
1551
1552
OMPUsesAllocatorsClause *
1553
30
OMPUsesAllocatorsClause::CreateEmpty(const ASTContext &C, unsigned N) {
1554
30
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1555
30
      static_cast<int>(ExprOffsets::Total) * N,
1556
30
      static_cast<int>(ParenLocsOffsets::Total) * N));
1557
30
  return new (Mem) OMPUsesAllocatorsClause(N);
1558
30
}
1559
1560
OMPAffinityClause *
1561
OMPAffinityClause::Create(const ASTContext &C, SourceLocation StartLoc,
1562
                          SourceLocation LParenLoc, SourceLocation ColonLoc,
1563
                          SourceLocation EndLoc, Expr *Modifier,
1564
58
                          ArrayRef<Expr *> Locators) {
1565
58
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1));
1566
58
  auto *Clause = new (Mem)
1567
58
      OMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, Locators.size());
1568
58
  Clause->setModifier(Modifier);
1569
58
  Clause->setVarRefs(Locators);
1570
58
  return Clause;
1571
58
}
1572
1573
OMPAffinityClause *OMPAffinityClause::CreateEmpty(const ASTContext &C,
1574
10
                                                  unsigned N) {
1575
10
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
1576
10
  return new (Mem) OMPAffinityClause(N);
1577
10
}
1578
1579
OMPInitClause *OMPInitClause::Create(const ASTContext &C, Expr *InteropVar,
1580
                                     ArrayRef<Expr *> PrefExprs, bool IsTarget,
1581
                                     bool IsTargetSync, SourceLocation StartLoc,
1582
                                     SourceLocation LParenLoc,
1583
                                     SourceLocation VarLoc,
1584
83
                                     SourceLocation EndLoc) {
1585
1586
83
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(PrefExprs.size() + 1));
1587
83
  auto *Clause =
1588
83
      new (Mem) OMPInitClause(IsTarget, IsTargetSync, StartLoc, LParenLoc,
1589
83
                              VarLoc, EndLoc, PrefExprs.size() + 1);
1590
83
  Clause->setInteropVar(InteropVar);
1591
83
  llvm::copy(PrefExprs, Clause->getTrailingObjects<Expr *>() + 1);
1592
83
  return Clause;
1593
83
}
1594
1595
26
OMPInitClause *OMPInitClause::CreateEmpty(const ASTContext &C, unsigned N) {
1596
26
  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1597
26
  return new (Mem) OMPInitClause(N);
1598
26
}
1599
1600
OMPBindClause *
1601
OMPBindClause::Create(const ASTContext &C, OpenMPBindClauseKind K,
1602
                      SourceLocation KLoc, SourceLocation StartLoc,
1603
41
                      SourceLocation LParenLoc, SourceLocation EndLoc) {
1604
41
  return new (C) OMPBindClause(K, KLoc, StartLoc, LParenLoc, EndLoc);
1605
41
}
1606
1607
8
OMPBindClause *OMPBindClause::CreateEmpty(const ASTContext &C) {
1608
8
  return new (C) OMPBindClause();
1609
8
}
1610
//===----------------------------------------------------------------------===//
1611
//  OpenMP clauses printing methods
1612
//===----------------------------------------------------------------------===//
1613
1614
1.93k
void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
1615
1.93k
  OS << "if(";
1616
1.93k
  if (Node->getNameModifier() != OMPD_unknown)
1617
917
    OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": ";
1618
1.93k
  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
1619
1.93k
  OS << ")";
1620
1.93k
}
1621
1622
160
void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) {
1623
160
  OS << "final(";
1624
160
  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
1625
160
  OS << ")";
1626
160
}
1627
1628
368
void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) {
1629
368
  OS << "num_threads(";
1630
368
  Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0);
1631
368
  OS << ")";
1632
368
}
1633
1634
8
void OMPClausePrinter::VisitOMPAlignClause(OMPAlignClause *Node) {
1635
8
  OS << "align(";
1636
8
  Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
1637
8
  OS << ")";
1638
8
}
1639
1640
384
void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) {
1641
384
  OS << "safelen(";
1642
384
  Node->getSafelen()->printPretty(OS, nullptr, Policy, 0);
1643
384
  OS << ")";
1644
384
}
1645
1646
384
void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) {
1647
384
  OS << "simdlen(";
1648
384
  Node->getSimdlen()->printPretty(OS, nullptr, Policy, 0);
1649
384
  OS << ")";
1650
384
}
1651
1652
18
void OMPClausePrinter::VisitOMPSizesClause(OMPSizesClause *Node) {
1653
18
  OS << "sizes(";
1654
18
  bool First = true;
1655
24
  for (auto Size : Node->getSizesRefs()) {
1656
24
    if (!First)
1657
6
      OS << ", ";
1658
24
    Size->printPretty(OS, nullptr, Policy, 0);
1659
24
    First = false;
1660
24
  }
1661
18
  OS << ")";
1662
18
}
1663
1664
2
void OMPClausePrinter::VisitOMPFullClause(OMPFullClause *Node) { OS << "full"; }
1665
1666
14
void OMPClausePrinter::VisitOMPPartialClause(OMPPartialClause *Node) {
1667
14
  OS << "partial";
1668
1669
14
  if (Expr *Factor = Node->getFactor()) {
1670
12
    OS << '(';
1671
12
    Factor->printPretty(OS, nullptr, Policy, 0);
1672
12
    OS << ')';
1673
12
  }
1674
14
}
1675
1676
90
void OMPClausePrinter::VisitOMPAllocatorClause(OMPAllocatorClause *Node) {
1677
90
  OS << "allocator(";
1678
90
  Node->getAllocator()->printPretty(OS, nullptr, Policy, 0);
1679
90
  OS << ")";
1680
90
}
1681
1682
506
void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) {
1683
506
  OS << "collapse(";
1684
506
  Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0);
1685
506
  OS << ")";
1686
506
}
1687
1688
24
void OMPClausePrinter::VisitOMPDetachClause(OMPDetachClause *Node) {
1689
24
  OS << "detach(";
1690
24
  Node->getEventHandler()->printPretty(OS, nullptr, Policy, 0);
1691
24
  OS << ")";
1692
24
}
1693
1694
728
void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
1695
728
  OS << "default("
1696
728
     << getOpenMPSimpleClauseTypeName(OMPC_default,
1697
728
                                      unsigned(Node->getDefaultKind()))
1698
728
     << ")";
1699
728
}
1700
1701
240
void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
1702
240
  OS << "proc_bind("
1703
240
     << getOpenMPSimpleClauseTypeName(OMPC_proc_bind,
1704
240
                                      unsigned(Node->getProcBindKind()))
1705
240
     << ")";
1706
240
}
1707
1708
4
void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {
1709
4
  OS << "unified_address";
1710
4
}
1711
1712
void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
1713
4
    OMPUnifiedSharedMemoryClause *) {
1714
4
  OS << "unified_shared_memory";
1715
4
}
1716
1717
4
void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
1718
4
  OS << "reverse_offload";
1719
4
}
1720
1721
void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
1722
4
    OMPDynamicAllocatorsClause *) {
1723
4
  OS << "dynamic_allocators";
1724
4
}
1725
1726
void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
1727
12
    OMPAtomicDefaultMemOrderClause *Node) {
1728
12
  OS << "atomic_default_mem_order("
1729
12
     << getOpenMPSimpleClauseTypeName(OMPC_atomic_default_mem_order,
1730
12
                                      Node->getAtomicDefaultMemOrderKind())
1731
12
     << ")";
1732
12
}
1733
1734
416
void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
1735
416
  OS << "schedule(";
1736
416
  if (Node->getFirstScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
1737
120
    OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1738
120
                                        Node->getFirstScheduleModifier());
1739
120
    if (Node->getSecondScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
1740
0
      OS << ", ";
1741
0
      OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1742
0
                                          Node->getSecondScheduleModifier());
1743
0
    }
1744
120
    OS << ": ";
1745
120
  }
1746
416
  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind());
1747
416
  if (auto *E = Node->getChunkSize()) {
1748
144
    OS << ", ";
1749
144
    E->printPretty(OS, nullptr, Policy);
1750
144
  }
1751
416
  OS << ")";
1752
416
}
1753
1754
137
void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) {
1755
137
  OS << "ordered";
1756
137
  if (auto *Num = Node->getNumForLoops()) {
1757
48
    OS << "(";
1758
48
    Num->printPretty(OS, nullptr, Policy, 0);
1759
48
    OS << ")";
1760
48
  }
1761
137
}
1762
1763
1.25k
void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) {
1764
1.25k
  OS << "nowait";
1765
1.25k
}
1766
1767
124
void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
1768
124
  OS << "untied";
1769
124
}
1770
1771
108
void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) {
1772
108
  OS << "nogroup";
1773
108
}
1774
1775
160
void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
1776
160
  OS << "mergeable";
1777
160
}
1778
1779
85
void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; }
1780
1781
84
void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; }
1782
1783
96
void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *Node) {
1784
96
  OS << "update";
1785
96
  if (Node->isExtended()) {
1786
12
    OS << "(";
1787
12
    OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
1788
12
                                        Node->getDependencyKind());
1789
12
    OS << ")";
1790
12
  }
1791
96
}
1792
1793
168
void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
1794
168
  OS << "capture";
1795
168
}
1796
1797
0
void OMPClausePrinter::VisitOMPCompareClause(OMPCompareClause *) {
1798
0
  OS << "compare";
1799
0
}
1800
1801
72
void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
1802
72
  OS << "seq_cst";
1803
72
}
1804
1805
40
void OMPClausePrinter::VisitOMPAcqRelClause(OMPAcqRelClause *) {
1806
40
  OS << "acq_rel";
1807
40
}
1808
1809
52
void OMPClausePrinter::VisitOMPAcquireClause(OMPAcquireClause *) {
1810
52
  OS << "acquire";
1811
52
}
1812
1813
76
void OMPClausePrinter::VisitOMPReleaseClause(OMPReleaseClause *) {
1814
76
  OS << "release";
1815
76
}
1816
1817
60
void OMPClausePrinter::VisitOMPRelaxedClause(OMPRelaxedClause *) {
1818
60
  OS << "relaxed";
1819
60
}
1820
1821
12
void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
1822
12
  OS << "threads";
1823
12
}
1824
1825
36
void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; }
1826
1827
108
void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
1828
108
  OS << "device(";
1829
108
  OpenMPDeviceClauseModifier Modifier = Node->getModifier();
1830
108
  if (Modifier != OMPC_DEVICE_unknown) {
1831
24
    OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), Modifier)
1832
24
       << ": ";
1833
24
  }
1834
108
  Node->getDevice()->printPretty(OS, nullptr, Policy, 0);
1835
108
  OS << ")";
1836
108
}
1837
1838
216
void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) {
1839
216
  OS << "num_teams(";
1840
216
  Node->getNumTeams()->printPretty(OS, nullptr, Policy, 0);
1841
216
  OS << ")";
1842
216
}
1843
1844
216
void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) {
1845
216
  OS << "thread_limit(";
1846
216
  Node->getThreadLimit()->printPretty(OS, nullptr, Policy, 0);
1847
216
  OS << ")";
1848
216
}
1849
1850
320
void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) {
1851
320
  OS << "priority(";
1852
320
  Node->getPriority()->printPretty(OS, nullptr, Policy, 0);
1853
320
  OS << ")";
1854
320
}
1855
1856
144
void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
1857
144
  OS << "grainsize(";
1858
144
  Node->getGrainsize()->printPretty(OS, nullptr, Policy, 0);
1859
144
  OS << ")";
1860
144
}
1861
1862
144
void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
1863
144
  OS << "num_tasks(";
1864
144
  Node->getNumTasks()->printPretty(OS, nullptr, Policy, 0);
1865
144
  OS << ")";
1866
144
}
1867
1868
84
void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) {
1869
84
  OS << "hint(";
1870
84
  Node->getHint()->printPretty(OS, nullptr, Policy, 0);
1871
84
  OS << ")";
1872
84
}
1873
1874
30
void OMPClausePrinter::VisitOMPInitClause(OMPInitClause *Node) {
1875
30
  OS << "init(";
1876
30
  bool First = true;
1877
58
  for (const Expr *E : Node->prefs()) {
1878
58
    if (First)
1879
16
      OS << "prefer_type(";
1880
42
    else
1881
42
      OS << ",";
1882
58
    E->printPretty(OS, nullptr, Policy);
1883
58
    First = false;
1884
58
  }
1885
30
  if (!First)
1886
16
    OS << "), ";
1887
30
  if (Node->getIsTarget())
1888
18
    OS << "target";
1889
30
  if (Node->getIsTargetSync()) {
1890
12
    if (Node->getIsTarget())
1891
0
      OS << ", ";
1892
12
    OS << "targetsync";
1893
12
  }
1894
30
  OS << " : ";
1895
30
  Node->getInteropVar()->printPretty(OS, nullptr, Policy);
1896
30
  OS << ")";
1897
30
}
1898
1899
20
void OMPClausePrinter::VisitOMPUseClause(OMPUseClause *Node) {
1900
20
  OS << "use(";
1901
20
  Node->getInteropVar()->printPretty(OS, nullptr, Policy);
1902
20
  OS << ")";
1903
20
}
1904
1905
30
void OMPClausePrinter::VisitOMPDestroyClause(OMPDestroyClause *Node) {
1906
30
  OS << "destroy";
1907
30
  if (Expr *E = Node->getInteropVar()) {
1908
18
    OS << "(";
1909
18
    E->printPretty(OS, nullptr, Policy);
1910
18
    OS << ")";
1911
18
  }
1912
30
}
1913
1914
4
void OMPClausePrinter::VisitOMPNovariantsClause(OMPNovariantsClause *Node) {
1915
4
  OS << "novariants";
1916
4
  if (Expr *E = Node->getCondition()) {
1917
4
    OS << "(";
1918
4
    E->printPretty(OS, nullptr, Policy, 0);
1919
4
    OS << ")";
1920
4
  }
1921
4
}
1922
1923
4
void OMPClausePrinter::VisitOMPNocontextClause(OMPNocontextClause *Node) {
1924
4
  OS << "nocontext";
1925
4
  if (Expr *E = Node->getCondition()) {
1926
4
    OS << "(";
1927
4
    E->printPretty(OS, nullptr, Policy, 0);
1928
4
    OS << ")";
1929
4
  }
1930
4
}
1931
1932
template<typename T>
1933
15.4k
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
15.4k
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
15.4k
                                    E = Node->varlist_end();
1936
35.3k
       I != E; 
++I19.9k
) {
1937
19.9k
    assert(*I && "Expected non-null Stmt");
1938
19.9k
    OS << (I == Node->varlist_begin() ? 
StartSym15.4k
:
','4.41k
);
1939
19.9k
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
15.3k
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
1.34k
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
13.9k
      else
1943
13.9k
        DRE->getDecl()->printQualifiedName(OS);
1944
15.3k
    } else
1945
4.60k
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
19.9k
  }
1947
15.4k
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPAllocateClause>(clang::OMPAllocateClause*, char)
Line
Count
Source
1933
840
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
840
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
840
                                    E = Node->varlist_end();
1936
1.68k
       I != E; 
++I840
) {
1937
840
    assert(*I && "Expected non-null Stmt");
1938
840
    OS << (I == Node->varlist_begin() ? StartSym : 
','0
);
1939
840
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
792
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
24
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
768
      else
1943
768
        DRE->getDecl()->printQualifiedName(OS);
1944
792
    } else
1945
48
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
840
  }
1947
840
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPPrivateClause>(clang::OMPPrivateClause*, char)
Line
Count
Source
1933
2.76k
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
2.76k
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
2.76k
                                    E = Node->varlist_end();
1936
6.27k
       I != E; 
++I3.51k
) {
1937
3.51k
    assert(*I && "Expected non-null Stmt");
1938
3.51k
    OS << (I == Node->varlist_begin() ? 
StartSym2.76k
:
','748
);
1939
3.51k
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
2.85k
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
1.05k
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
1.79k
      else
1943
1.79k
        DRE->getDecl()->printQualifiedName(OS);
1944
2.85k
    } else
1945
660
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
3.51k
  }
1947
2.76k
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPFirstprivateClause>(clang::OMPFirstprivateClause*, char)
Line
Count
Source
1933
1.17k
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
1.17k
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
1.17k
                                    E = Node->varlist_end();
1936
2.85k
       I != E; 
++I1.67k
) {
1937
1.67k
    assert(*I && "Expected non-null Stmt");
1938
1.67k
    OS << (I == Node->varlist_begin() ? 
StartSym1.17k
:
','500
);
1939
1.67k
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
1.61k
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
116
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
1.49k
      else
1943
1.49k
        DRE->getDecl()->printQualifiedName(OS);
1944
1.61k
    } else
1945
64
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
1.67k
  }
1947
1.17k
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPLastprivateClause>(clang::OMPLastprivateClause*, char)
Line
Count
Source
1933
506
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
506
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
506
                                    E = Node->varlist_end();
1936
1.37k
       I != E; 
++I866
) {
1937
866
    assert(*I && "Expected non-null Stmt");
1938
866
    OS << (I == Node->varlist_begin() ? 
StartSym506
:
','360
);
1939
866
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
846
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
32
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
814
      else
1943
814
        DRE->getDecl()->printQualifiedName(OS);
1944
846
    } else
1945
20
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
866
  }
1947
506
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPSharedClause>(clang::OMPSharedClause*, char)
Line
Count
Source
1933
838
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
838
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
838
                                    E = Node->varlist_end();
1936
1.70k
       I != E; 
++I866
) {
1937
866
    assert(*I && "Expected non-null Stmt");
1938
866
    OS << (I == Node->varlist_begin() ? 
StartSym838
:
','28
);
1939
866
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
710
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
710
      else
1943
710
        DRE->getDecl()->printQualifiedName(OS);
1944
710
    } else
1945
156
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
866
  }
1947
838
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPReductionClause>(clang::OMPReductionClause*, char)
Line
Count
Source
1933
1.69k
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
1.69k
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
1.69k
                                    E = Node->varlist_end();
1936
4.02k
       I != E; 
++I2.32k
) {
1937
2.32k
    assert(*I && "Expected non-null Stmt");
1938
2.32k
    OS << (I == Node->varlist_begin() ? 
StartSym1.69k
:
','632
);
1939
2.32k
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
1.84k
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
36
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
1.80k
      else
1943
1.80k
        DRE->getDecl()->printQualifiedName(OS);
1944
1.84k
    } else
1945
484
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
2.32k
  }
1947
1.69k
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPTaskReductionClause>(clang::OMPTaskReductionClause*, char)
Line
Count
Source
1933
216
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
216
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
216
                                    E = Node->varlist_end();
1936
432
       I != E; 
++I216
) {
1937
216
    assert(*I && "Expected non-null Stmt");
1938
216
    OS << (I == Node->varlist_begin() ? StartSym : 
','0
);
1939
216
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
184
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
16
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
168
      else
1943
168
        DRE->getDecl()->printQualifiedName(OS);
1944
184
    } else
1945
32
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
216
  }
1947
216
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPInReductionClause>(clang::OMPInReductionClause*, char)
Line
Count
Source
1933
128
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
128
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
128
                                    E = Node->varlist_end();
1936
256
       I != E; 
++I128
) {
1937
128
    assert(*I && "Expected non-null Stmt");
1938
128
    OS << (I == Node->varlist_begin() ? StartSym : 
','0
);
1939
128
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
124
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
4
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
120
      else
1943
120
        DRE->getDecl()->printQualifiedName(OS);
1944
124
    } else
1945
4
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
128
  }
1947
128
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPLinearClause>(clang::OMPLinearClause*, char)
Line
Count
Source
1933
417
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
417
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
417
                                    E = Node->varlist_end();
1936
882
       I != E; 
++I465
) {
1937
465
    assert(*I && "Expected non-null Stmt");
1938
465
    OS << (I == Node->varlist_begin() ? 
StartSym417
:
','48
);
1939
465
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
457
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
12
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
445
      else
1943
445
        DRE->getDecl()->printQualifiedName(OS);
1944
457
    } else
1945
8
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
465
  }
1947
417
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPAlignedClause>(clang::OMPAlignedClause*, char)
Line
Count
Source
1933
408
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
408
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
408
                                    E = Node->varlist_end();
1936
816
       I != E; 
++I408
) {
1937
408
    assert(*I && "Expected non-null Stmt");
1938
408
    OS << (I == Node->varlist_begin() ? StartSym : 
','0
);
1939
408
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
208
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
208
      else
1943
208
        DRE->getDecl()->printQualifiedName(OS);
1944
208
    } else
1945
200
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
408
  }
1947
408
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPCopyinClause>(clang::OMPCopyinClause*, char)
Line
Count
Source
1933
180
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
180
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
180
                                    E = Node->varlist_end();
1936
408
       I != E; 
++I228
) {
1937
228
    assert(*I && "Expected non-null Stmt");
1938
228
    OS << (I == Node->varlist_begin() ? 
StartSym180
:
','48
);
1939
228
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
208
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
208
      else
1943
208
        DRE->getDecl()->printQualifiedName(OS);
1944
208
    } else
1945
20
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
228
  }
1947
180
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPCopyprivateClause>(clang::OMPCopyprivateClause*, char)
Line
Count
Source
1933
32
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
32
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
32
                                    E = Node->varlist_end();
1936
72
       I != E; 
++I40
) {
1937
40
    assert(*I && "Expected non-null Stmt");
1938
40
    OS << (I == Node->varlist_begin() ? 
StartSym32
:
','8
);
1939
40
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
36
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
20
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
16
      else
1943
16
        DRE->getDecl()->printQualifiedName(OS);
1944
36
    } else
1945
4
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
40
  }
1947
32
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPFlushClause>(clang::OMPFlushClause*, char)
Line
Count
Source
1933
16
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
16
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
16
                                    E = Node->varlist_end();
1936
32
       I != E; 
++I16
) {
1937
16
    assert(*I && "Expected non-null Stmt");
1938
16
    OS << (I == Node->varlist_begin() ? StartSym : 
','0
);
1939
16
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
16
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
16
      else
1943
16
        DRE->getDecl()->printQualifiedName(OS);
1944
16
    } else
1945
0
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
16
  }
1947
16
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPDependClause>(clang::OMPDependClause*, char)
Line
Count
Source
1933
805
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
805
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
805
                                    E = Node->varlist_end();
1936
2.97k
       I != E; 
++I2.16k
) {
1937
2.16k
    assert(*I && "Expected non-null Stmt");
1938
2.16k
    OS << (I == Node->varlist_begin() ? 
StartSym805
:
','1.36k
);
1939
2.16k
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
789
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
789
      else
1943
789
        DRE->getDecl()->printQualifiedName(OS);
1944
789
    } else
1945
1.37k
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
2.16k
  }
1947
805
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPMapClause>(clang::OMPMapClause*, char)
Line
Count
Source
1933
3.44k
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
3.44k
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
3.44k
                                    E = Node->varlist_end();
1936
7.31k
       I != E; 
++I3.86k
) {
1937
3.86k
    assert(*I && "Expected non-null Stmt");
1938
3.86k
    OS << (I == Node->varlist_begin() ? 
StartSym3.44k
:
','416
);
1939
3.86k
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
3.25k
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
3.25k
      else
1943
3.25k
        DRE->getDecl()->printQualifiedName(OS);
1944
3.25k
    } else
1945
608
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
3.86k
  }
1947
3.44k
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPToClause>(clang::OMPToClause*, char)
Line
Count
Source
1933
353
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
353
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
353
                                    E = Node->varlist_end();
1936
730
       I != E; 
++I377
) {
1937
377
    assert(*I && "Expected non-null Stmt");
1938
377
    OS << (I == Node->varlist_begin() ? 
StartSym353
:
','24
);
1939
377
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
65
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
65
      else
1943
65
        DRE->getDecl()->printQualifiedName(OS);
1944
65
    } else
1945
312
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
377
  }
1947
353
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPFromClause>(clang::OMPFromClause*, char)
Line
Count
Source
1933
352
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
352
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
352
                                    E = Node->varlist_end();
1936
744
       I != E; 
++I392
) {
1937
392
    assert(*I && "Expected non-null Stmt");
1938
392
    OS << (I == Node->varlist_begin() ? 
StartSym352
:
','40
);
1939
392
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
64
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
64
      else
1943
64
        DRE->getDecl()->printQualifiedName(OS);
1944
64
    } else
1945
328
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
392
  }
1947
352
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPUseDevicePtrClause>(clang::OMPUseDevicePtrClause*, char)
Line
Count
Source
1933
40
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
40
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
40
                                    E = Node->varlist_end();
1936
80
       I != E; 
++I40
) {
1937
40
    assert(*I && "Expected non-null Stmt");
1938
40
    OS << (I == Node->varlist_begin() ? StartSym : 
','0
);
1939
40
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
40
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
8
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
32
      else
1943
32
        DRE->getDecl()->printQualifiedName(OS);
1944
40
    } else
1945
0
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
40
  }
1947
40
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPUseDeviceAddrClause>(clang::OMPUseDeviceAddrClause*, char)
Line
Count
Source
1933
16
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
16
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
16
                                    E = Node->varlist_end();
1936
52
       I != E; 
++I36
) {
1937
36
    assert(*I && "Expected non-null Stmt");
1938
36
    OS << (I == Node->varlist_begin() ? 
StartSym16
:
','20
);
1939
36
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
32
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
16
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
16
      else
1943
16
        DRE->getDecl()->printQualifiedName(OS);
1944
32
    } else
1945
4
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
36
  }
1947
16
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPIsDevicePtrClause>(clang::OMPIsDevicePtrClause*, char)
Line
Count
Source
1933
1.16k
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
1.16k
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
1.16k
                                    E = Node->varlist_end();
1936
2.32k
       I != E; 
++I1.16k
) {
1937
1.16k
    assert(*I && "Expected non-null Stmt");
1938
1.16k
    OS << (I == Node->varlist_begin() ? StartSym : 
','0
);
1939
1.16k
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
938
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
938
      else
1943
938
        DRE->getDecl()->printQualifiedName(OS);
1944
938
    } else
1945
224
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
1.16k
  }
1947
1.16k
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPNontemporalClause>(clang::OMPNontemporalClause*, char)
Line
Count
Source
1933
68
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
68
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
68
                                    E = Node->varlist_end();
1936
268
       I != E; 
++I200
) {
1937
200
    assert(*I && "Expected non-null Stmt");
1938
200
    OS << (I == Node->varlist_begin() ? 
StartSym68
:
','132
);
1939
200
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
200
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
200
      else
1943
200
        DRE->getDecl()->printQualifiedName(OS);
1944
200
    } else
1945
0
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
200
  }
1947
68
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPInclusiveClause>(clang::OMPInclusiveClause*, char)
Line
Count
Source
1933
12
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
12
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
12
                                    E = Node->varlist_end();
1936
24
       I != E; 
++I12
) {
1937
12
    assert(*I && "Expected non-null Stmt");
1938
12
    OS << (I == Node->varlist_begin() ? StartSym : 
','0
);
1939
12
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
12
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
12
      else
1943
12
        DRE->getDecl()->printQualifiedName(OS);
1944
12
    } else
1945
0
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
12
  }
1947
12
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPExclusiveClause>(clang::OMPExclusiveClause*, char)
Line
Count
Source
1933
4
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
4
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
4
                                    E = Node->varlist_end();
1936
12
       I != E; 
++I8
) {
1937
8
    assert(*I && "Expected non-null Stmt");
1938
8
    OS << (I == Node->varlist_begin() ? 
StartSym4
:
','4
);
1939
8
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
8
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
8
      else
1943
8
        DRE->getDecl()->printQualifiedName(OS);
1944
8
    } else
1945
0
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
8
  }
1947
4
}
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPAffinityClause>(clang::OMPAffinityClause*, char)
Line
Count
Source
1933
20
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1934
20
  for (typename T::varlist_iterator I = Node->varlist_begin(),
1935
20
                                    E = Node->varlist_end();
1936
84
       I != E; 
++I64
) {
1937
64
    assert(*I && "Expected non-null Stmt");
1938
64
    OS << (I == Node->varlist_begin() ? 
StartSym20
:
','44
);
1939
64
    if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1940
12
      if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1941
0
        DRE->printPretty(OS, nullptr, Policy, 0);
1942
12
      else
1943
12
        DRE->getDecl()->printQualifiedName(OS);
1944
12
    } else
1945
52
      (*I)->printPretty(OS, nullptr, Policy, 0);
1946
64
  }
1947
20
}
1948
1949
840
void OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) {
1950
840
  if (Node->varlist_empty())
1951
0
    return;
1952
840
  OS << "allocate";
1953
840
  if (Expr *Allocator = Node->getAllocator()) {
1954
80
    OS << "(";
1955
80
    Allocator->printPretty(OS, nullptr, Policy, 0);
1956
80
    OS << ":";
1957
80
    VisitOMPClauseList(Node, ' ');
1958
760
  } else {
1959
760
    VisitOMPClauseList(Node, '(');
1960
760
  }
1961
840
  OS << ")";
1962
840
}
1963
1964
2.76k
void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
1965
2.76k
  if (!Node->varlist_empty()) {
1966
2.76k
    OS << "private";
1967
2.76k
    VisitOMPClauseList(Node, '(');
1968
2.76k
    OS << ")";
1969
2.76k
  }
1970
2.76k
}
1971
1972
1.17k
void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
1973
1.17k
  if (!Node->varlist_empty()) {
1974
1.17k
    OS << "firstprivate";
1975
1.17k
    VisitOMPClauseList(Node, '(');
1976
1.17k
    OS << ")";
1977
1.17k
  }
1978
1.17k
}
1979
1980
506
void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
1981
506
  if (!Node->varlist_empty()) {
1982
506
    OS << "lastprivate";
1983
506
    OpenMPLastprivateModifier LPKind = Node->getKind();
1984
506
    if (LPKind != OMPC_LASTPRIVATE_unknown) {
1985
24
      OS << "("
1986
24
         << getOpenMPSimpleClauseTypeName(OMPC_lastprivate, Node->getKind())
1987
24
         << ":";
1988
24
    }
1989
506
    VisitOMPClauseList(Node, LPKind == OMPC_LASTPRIVATE_unknown ? 
'('482
:
' '24
);
1990
506
    OS << ")";
1991
506
  }
1992
506
}
1993
1994
838
void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
1995
838
  if (!Node->varlist_empty()) {
1996
838
    OS << "shared";
1997
838
    VisitOMPClauseList(Node, '(');
1998
838
    OS << ")";
1999
838
  }
2000
838
}
2001
2002
1.69k
void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
2003
1.69k
  if (!Node->varlist_empty()) {
2004
1.69k
    OS << "reduction(";
2005
1.69k
    if (Node->getModifierLoc().isValid())
2006
140
      OS << getOpenMPSimpleClauseTypeName(OMPC_reduction, Node->getModifier())
2007
140
         << ", ";
2008
1.69k
    NestedNameSpecifier *QualifierLoc =
2009
1.69k
        Node->getQualifierLoc().getNestedNameSpecifier();
2010
1.69k
    OverloadedOperatorKind OOK =
2011
1.69k
        Node->getNameInfo().getName().getCXXOverloadedOperator();
2012
1.69k
    if (QualifierLoc == nullptr && OOK != OO_None) {
2013
      // Print reduction identifier in C format
2014
1.31k
      OS << getOperatorSpelling(OOK);
2015
1.31k
    } else {
2016
      // Use C++ format
2017
384
      if (QualifierLoc != nullptr)
2018
0
        QualifierLoc->print(OS, Policy);
2019
384
      OS << Node->getNameInfo();
2020
384
    }
2021
1.69k
    OS << ":";
2022
1.69k
    VisitOMPClauseList(Node, ' ');
2023
1.69k
    OS << ")";
2024
1.69k
  }
2025
1.69k
}
2026
2027
void OMPClausePrinter::VisitOMPTaskReductionClause(
2028
216
    OMPTaskReductionClause *Node) {
2029
216
  if (!Node->varlist_empty()) {
2030
216
    OS << "task_reduction(";
2031
216
    NestedNameSpecifier *QualifierLoc =
2032
216
        Node->getQualifierLoc().getNestedNameSpecifier();
2033
216
    OverloadedOperatorKind OOK =
2034
216
        Node->getNameInfo().getName().getCXXOverloadedOperator();
2035
216
    if (QualifierLoc == nullptr && OOK != OO_None) {
2036
      // Print reduction identifier in C format
2037
204
      OS << getOperatorSpelling(OOK);
2038
204
    } else {
2039
      // Use C++ format
2040
12
      if (QualifierLoc != nullptr)
2041
0
        QualifierLoc->print(OS, Policy);
2042
12
      OS << Node->getNameInfo();
2043
12
    }
2044
216
    OS << ":";
2045
216
    VisitOMPClauseList(Node, ' ');
2046
216
    OS << ")";
2047
216
  }
2048
216
}
2049
2050
128
void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) {
2051
128
  if (!Node->varlist_empty()) {
2052
128
    OS << "in_reduction(";
2053
128
    NestedNameSpecifier *QualifierLoc =
2054
128
        Node->getQualifierLoc().getNestedNameSpecifier();
2055
128
    OverloadedOperatorKind OOK =
2056
128
        Node->getNameInfo().getName().getCXXOverloadedOperator();
2057
128
    if (QualifierLoc == nullptr && OOK != OO_None) {
2058
      // Print reduction identifier in C format
2059
120
      OS << getOperatorSpelling(OOK);
2060
120
    } else {
2061
      // Use C++ format
2062
8
      if (QualifierLoc != nullptr)
2063
0
        QualifierLoc->print(OS, Policy);
2064
8
      OS << Node->getNameInfo();
2065
8
    }
2066
128
    OS << ":";
2067
128
    VisitOMPClauseList(Node, ' ');
2068
128
    OS << ")";
2069
128
  }
2070
128
}
2071
2072
417
void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
2073
417
  if (!Node->varlist_empty()) {
2074
417
    OS << "linear";
2075
417
    if (Node->getModifierLoc().isValid()) {
2076
40
      OS << '('
2077
40
         << getOpenMPSimpleClauseTypeName(OMPC_linear, Node->getModifier());
2078
40
    }
2079
417
    VisitOMPClauseList(Node, '(');
2080
417
    if (Node->getModifierLoc().isValid())
2081
40
      OS << ')';
2082
417
    if (Node->getStep() != nullptr) {
2083
165
      OS << ": ";
2084
165
      Node->getStep()->printPretty(OS, nullptr, Policy, 0);
2085
165
    }
2086
417
    OS << ")";
2087
417
  }
2088
417
}
2089
2090
408
void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
2091
408
  if (!Node->varlist_empty()) {
2092
408
    OS << "aligned";
2093
408
    VisitOMPClauseList(Node, '(');
2094
408
    if (Node->getAlignment() != nullptr) {
2095
296
      OS << ": ";
2096
296
      Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
2097
296
    }
2098
408
    OS << ")";
2099
408
  }
2100
408
}
2101
2102
180
void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
2103
180
  if (!Node->varlist_empty()) {
2104
180
    OS << "copyin";
2105
180
    VisitOMPClauseList(Node, '(');
2106
180
    OS << ")";
2107
180
  }
2108
180
}
2109
2110
32
void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
2111
32
  if (!Node->varlist_empty()) {
2112
32
    OS << "copyprivate";
2113
32
    VisitOMPClauseList(Node, '(');
2114
32
    OS << ")";
2115
32
  }
2116
32
}
2117
2118
16
void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
2119
16
  if (!Node->varlist_empty()) {
2120
16
    VisitOMPClauseList(Node, '(');
2121
16
    OS << ")";
2122
16
  }
2123
16
}
2124
2125
44
void OMPClausePrinter::VisitOMPDepobjClause(OMPDepobjClause *Node) {
2126
44
  OS << "(";
2127
44
  Node->getDepobj()->printPretty(OS, nullptr, Policy, 0);
2128
44
  OS << ")";
2129
44
}
2130
2131
817
void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
2132
817
  OS << "depend(";
2133
817
  if (Expr *DepModifier = Node->getModifier()) {
2134
24
    DepModifier->printPretty(OS, nullptr, Policy);
2135
24
    OS << ", ";
2136
24
  }
2137
817
  OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
2138
817
                                      Node->getDependencyKind());
2139
817
  if (!Node->varlist_empty()) {
2140
805
    OS << " :";
2141
805
    VisitOMPClauseList(Node, ' ');
2142
805
  }
2143
817
  OS << ")";
2144
817
}
2145
2146
template <typename T>
2147
static void PrintMapper(raw_ostream &OS, T *Node,
2148
128
                        const PrintingPolicy &Policy) {
2149
128
  OS << '(';
2150
128
  NestedNameSpecifier *MapperNNS =
2151
128
      Node->getMapperQualifierLoc().getNestedNameSpecifier();
2152
128
  if (MapperNNS)
2153
28
    MapperNNS->print(OS, Policy);
2154
128
  OS << Node->getMapperIdInfo() << ')';
2155
128
}
OpenMPClause.cpp:void PrintMapper<clang::OMPMapClause>(llvm::raw_ostream&, clang::OMPMapClause*, clang::PrintingPolicy const&)
Line
Count
Source
2148
48
                        const PrintingPolicy &Policy) {
2149
48
  OS << '(';
2150
48
  NestedNameSpecifier *MapperNNS =
2151
48
      Node->getMapperQualifierLoc().getNestedNameSpecifier();
2152
48
  if (MapperNNS)
2153
12
    MapperNNS->print(OS, Policy);
2154
48
  OS << Node->getMapperIdInfo() << ')';
2155
48
}
OpenMPClause.cpp:void PrintMapper<clang::OMPToClause>(llvm::raw_ostream&, clang::OMPToClause*, clang::PrintingPolicy const&)
Line
Count
Source
2148
40
                        const PrintingPolicy &Policy) {
2149
40
  OS << '(';
2150
40
  NestedNameSpecifier *MapperNNS =
2151
40
      Node->getMapperQualifierLoc().getNestedNameSpecifier();
2152
40
  if (MapperNNS)
2153
8
    MapperNNS->print(OS, Policy);
2154
40
  OS << Node->getMapperIdInfo() << ')';
2155
40
}
OpenMPClause.cpp:void PrintMapper<clang::OMPFromClause>(llvm::raw_ostream&, clang::OMPFromClause*, clang::PrintingPolicy const&)
Line
Count
Source
2148
40
                        const PrintingPolicy &Policy) {
2149
40
  OS << '(';
2150
40
  NestedNameSpecifier *MapperNNS =
2151
40
      Node->getMapperQualifierLoc().getNestedNameSpecifier();
2152
40
  if (MapperNNS)
2153
8
    MapperNNS->print(OS, Policy);
2154
40
  OS << Node->getMapperIdInfo() << ')';
2155
40
}
2156
2157
3.44k
void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
2158
3.44k
  if (!Node->varlist_empty()) {
2159
3.44k
    OS << "map(";
2160
3.44k
    if (Node->getMapType() != OMPC_MAP_unknown) {
2161
20.6k
      for (unsigned I = 0; I < NumberOfOMPMapClauseModifiers; 
++I17.2k
) {
2162
17.2k
        if (Node->getMapTypeModifier(I) != OMPC_MAP_MODIFIER_unknown) {
2163
704
          OS << getOpenMPSimpleClauseTypeName(OMPC_map,
2164
704
                                              Node->getMapTypeModifier(I));
2165
704
          if (Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_mapper)
2166
48
            PrintMapper(OS, Node, Policy);
2167
704
          OS << ',';
2168
704
        }
2169
17.2k
      }
2170
3.44k
      OS << getOpenMPSimpleClauseTypeName(OMPC_map, Node->getMapType());
2171
3.44k
      OS << ':';
2172
3.44k
    }
2173
3.44k
    VisitOMPClauseList(Node, ' ');
2174
3.44k
    OS << ")";
2175
3.44k
  }
2176
3.44k
}
2177
2178
705
template <typename T> void OMPClausePrinter::VisitOMPMotionClause(T *Node) {
2179
705
  if (Node->varlist_empty())
2180
0
    return;
2181
705
  OS << getOpenMPClauseName(Node->getClauseKind());
2182
705
  unsigned ModifierCount = 0;
2183
2.11k
  for (unsigned I = 0; I < NumberOfOMPMotionModifiers; 
++I1.41k
) {
2184
1.41k
    if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown)
2185
124
      ++ModifierCount;
2186
1.41k
  }
2187
705
  if (ModifierCount) {
2188
108
    OS << '(';
2189
324
    for (unsigned I = 0; I < NumberOfOMPMotionModifiers; 
++I216
) {
2190
216
      if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) {
2191
124
        OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
2192
124
                                            Node->getMotionModifier(I));
2193
124
        if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
2194
80
          PrintMapper(OS, Node, Policy);
2195
124
        if (I < ModifierCount - 1)
2196
16
          OS << ", ";
2197
124
      }
2198
216
    }
2199
108
    OS << ':';
2200
108
    VisitOMPClauseList(Node, ' ');
2201
597
  } else {
2202
597
    VisitOMPClauseList(Node, '(');
2203
597
  }
2204
705
  OS << ")";
2205
705
}
void clang::OMPClausePrinter::VisitOMPMotionClause<clang::OMPToClause>(clang::OMPToClause*)
Line
Count
Source
2178
353
template <typename T> void OMPClausePrinter::VisitOMPMotionClause(T *Node) {
2179
353
  if (Node->varlist_empty())
2180
0
    return;
2181
353
  OS << getOpenMPClauseName(Node->getClauseKind());
2182
353
  unsigned ModifierCount = 0;
2183
1.05k
  for (unsigned I = 0; I < NumberOfOMPMotionModifiers; 
++I706
) {
2184
706
    if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown)
2185
64
      ++ModifierCount;
2186
706
  }
2187
353
  if (ModifierCount) {
2188
56
    OS << '(';
2189
168
    for (unsigned I = 0; I < NumberOfOMPMotionModifiers; 
++I112
) {
2190
112
      if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) {
2191
64
        OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
2192
64
                                            Node->getMotionModifier(I));
2193
64
        if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
2194
40
          PrintMapper(OS, Node, Policy);
2195
64
        if (I < ModifierCount - 1)
2196
8
          OS << ", ";
2197
64
      }
2198
112
    }
2199
56
    OS << ':';
2200
56
    VisitOMPClauseList(Node, ' ');
2201
297
  } else {
2202
297
    VisitOMPClauseList(Node, '(');
2203
297
  }
2204
353
  OS << ")";
2205
353
}
void clang::OMPClausePrinter::VisitOMPMotionClause<clang::OMPFromClause>(clang::OMPFromClause*)
Line
Count
Source
2178
352
template <typename T> void OMPClausePrinter::VisitOMPMotionClause(T *Node) {
2179
352
  if (Node->varlist_empty())
2180
0
    return;
2181
352
  OS << getOpenMPClauseName(Node->getClauseKind());
2182
352
  unsigned ModifierCount = 0;
2183
1.05k
  for (unsigned I = 0; I < NumberOfOMPMotionModifiers; 
++I704
) {
2184
704
    if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown)
2185
60
      ++ModifierCount;
2186
704
  }
2187
352
  if (ModifierCount) {
2188
52
    OS << '(';
2189
156
    for (unsigned I = 0; I < NumberOfOMPMotionModifiers; 
++I104
) {
2190
104
      if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) {
2191
60
        OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
2192
60
                                            Node->getMotionModifier(I));
2193
60
        if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
2194
40
          PrintMapper(OS, Node, Policy);
2195
60
        if (I < ModifierCount - 1)
2196
8
          OS << ", ";
2197
60
      }
2198
104
    }
2199
52
    OS << ':';
2200
52
    VisitOMPClauseList(Node, ' ');
2201
300
  } else {
2202
300
    VisitOMPClauseList(Node, '(');
2203
300
  }
2204
352
  OS << ")";
2205
352
}
2206
2207
353
void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) {
2208
353
  VisitOMPMotionClause(Node);
2209
353
}
2210
2211
352
void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) {
2212
352
  VisitOMPMotionClause(Node);
2213
352
}
2214
2215
272
void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) {
2216
272
  OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName(
2217
272
                           OMPC_dist_schedule, Node->getDistScheduleKind());
2218
272
  if (auto *E = Node->getChunkSize()) {
2219
272
    OS << ", ";
2220
272
    E->printPretty(OS, nullptr, Policy);
2221
272
  }
2222
272
  OS << ")";
2223
272
}
2224
2225
772
void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
2226
772
  OS << "defaultmap(";
2227
772
  OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
2228
772
                                      Node->getDefaultmapModifier());
2229
772
  if (Node->getDefaultmapKind() != OMPC_DEFAULTMAP_unknown) {
2230
768
    OS << ": ";
2231
768
    OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
2232
768
                                        Node->getDefaultmapKind());
2233
768
  }
2234
772
  OS << ")";
2235
772
}
2236
2237
40
void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) {
2238
40
  if (!Node->varlist_empty()) {
2239
40
    OS << "use_device_ptr";
2240
40
    VisitOMPClauseList(Node, '(');
2241
40
    OS << ")";
2242
40
  }
2243
40
}
2244
2245
void OMPClausePrinter::VisitOMPUseDeviceAddrClause(
2246
16
    OMPUseDeviceAddrClause *Node) {
2247
16
  if (!Node->varlist_empty()) {
2248
16
    OS << "use_device_addr";
2249
16
    VisitOMPClauseList(Node, '(');
2250
16
    OS << ")";
2251
16
  }
2252
16
}
2253
2254
1.16k
void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) {
2255
1.16k
  if (!Node->varlist_empty()) {
2256
1.16k
    OS << "is_device_ptr";
2257
1.16k
    VisitOMPClauseList(Node, '(');
2258
1.16k
    OS << ")";
2259
1.16k
  }
2260
1.16k
}
2261
2262
68
void OMPClausePrinter::VisitOMPNontemporalClause(OMPNontemporalClause *Node) {
2263
68
  if (!Node->varlist_empty()) {
2264
68
    OS << "nontemporal";
2265
68
    VisitOMPClauseList(Node, '(');
2266
68
    OS << ")";
2267
68
  }
2268
68
}
2269
2270
114
void OMPClausePrinter::VisitOMPOrderClause(OMPOrderClause *Node) {
2271
114
  OS << "order(" << getOpenMPSimpleClauseTypeName(OMPC_order, Node->getKind())
2272
114
     << ")";
2273
114
}
2274
2275
12
void OMPClausePrinter::VisitOMPInclusiveClause(OMPInclusiveClause *Node) {
2276
12
  if (!Node->varlist_empty()) {
2277
12
    OS << "inclusive";
2278
12
    VisitOMPClauseList(Node, '(');
2279
12
    OS << ")";
2280
12
  }
2281
12
}
2282
2283
4
void OMPClausePrinter::VisitOMPExclusiveClause(OMPExclusiveClause *Node) {
2284
4
  if (!Node->varlist_empty()) {
2285
4
    OS << "exclusive";
2286
4
    VisitOMPClauseList(Node, '(');
2287
4
    OS << ")";
2288
4
  }
2289
4
}
2290
2291
void OMPClausePrinter::VisitOMPUsesAllocatorsClause(
2292
68
    OMPUsesAllocatorsClause *Node) {
2293
68
  if (Node->getNumberOfAllocators() == 0)
2294
0
    return;
2295
68
  OS << "uses_allocators(";
2296
140
  for (unsigned I = 0, E = Node->getNumberOfAllocators(); I < E; 
++I72
) {
2297
72
    OMPUsesAllocatorsClause::Data Data = Node->getAllocatorData(I);
2298
72
    Data.Allocator->printPretty(OS, nullptr, Policy);
2299
72
    if (Data.AllocatorTraits) {
2300
12
      OS << "(";
2301
12
      Data.AllocatorTraits->printPretty(OS, nullptr, Policy);
2302
12
      OS << ")";
2303
12
    }
2304
72
    if (I < E - 1)
2305
4
      OS << ",";
2306
72
  }
2307
68
  OS << ")";
2308
68
}
2309
2310
20
void OMPClausePrinter::VisitOMPAffinityClause(OMPAffinityClause *Node) {
2311
20
  if (Node->varlist_empty())
2312
0
    return;
2313
20
  OS << "affinity";
2314
20
  char StartSym = '(';
2315
20
  if (Expr *Modifier = Node->getModifier()) {
2316
8
    OS << "(";
2317
8
    Modifier->printPretty(OS, nullptr, Policy);
2318
8
    OS << " :";
2319
8
    StartSym = ' ';
2320
8
  }
2321
20
  VisitOMPClauseList(Node, StartSym);
2322
20
  OS << ")";
2323
20
}
2324
2325
8
void OMPClausePrinter::VisitOMPFilterClause(OMPFilterClause *Node) {
2326
8
  OS << "filter(";
2327
8
  Node->getThreadID()->printPretty(OS, nullptr, Policy, 0);
2328
8
  OS << ")";
2329
8
}
2330
2331
10
void OMPClausePrinter::VisitOMPBindClause(OMPBindClause *Node) {
2332
10
  OS << "bind("
2333
10
     << getOpenMPSimpleClauseTypeName(OMPC_bind, unsigned(Node->getBindKind()))
2334
10
     << ")";
2335
10
}
2336
2337
void OMPTraitInfo::getAsVariantMatchInfo(ASTContext &ASTCtx,
2338
3.53k
                                         VariantMatchInfo &VMI) const {
2339
4.73k
  for (const OMPTraitSet &Set : Sets) {
2340
5.02k
    for (const OMPTraitSelector &Selector : Set.Selectors) {
2341
2342
      // User conditions are special as we evaluate the condition here.
2343
5.02k
      if (Selector.Kind == TraitSelector::user_condition) {
2344
50
        assert(Selector.ScoreOrCondition &&
2345
50
               "Ill-formed user condition, expected condition expression!");
2346
0
        assert(Selector.Properties.size() == 1 &&
2347
50
               Selector.Properties.front().Kind ==
2348
50
                   TraitProperty::user_condition_unknown &&
2349
50
               "Ill-formed user condition, expected unknown trait property!");
2350
2351
50
        if (Optional<APSInt> CondVal =
2352
50
                Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
2353
46
          VMI.addTrait(CondVal->isZero() ? 
TraitProperty::user_condition_false6
2354
46
                                         : 
TraitProperty::user_condition_true40
,
2355
46
                       "<condition>");
2356
4
        else
2357
4
          VMI.addTrait(TraitProperty::user_condition_false, "<condition>");
2358
50
        continue;
2359
50
      }
2360
2361
4.97k
      Optional<llvm::APSInt> Score;
2362
4.97k
      llvm::APInt *ScorePtr = nullptr;
2363
4.97k
      if (Selector.ScoreOrCondition) {
2364
121
        if ((Score = Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
2365
115
          ScorePtr = &*Score;
2366
6
        else
2367
6
          VMI.addTrait(TraitProperty::user_condition_false,
2368
6
                       "<non-constant-score>");
2369
121
      }
2370
2371
4.97k
      for (const OMPTraitProperty &Property : Selector.Properties)
2372
6.45k
        VMI.addTrait(Set.Kind, Property.Kind, Property.RawString, ScorePtr);
2373
2374
4.97k
      if (Set.Kind != TraitSet::construct)
2375
4.24k
        continue;
2376
2377
      // TODO: This might not hold once we implement SIMD properly.
2378
733
      assert(Selector.Properties.size() == 1 &&
2379
733
             Selector.Properties.front().Kind ==
2380
733
                 getOpenMPContextTraitPropertyForSelector(
2381
733
                     Selector.Kind) &&
2382
733
             "Ill-formed construct selector!");
2383
733
    }
2384
4.73k
  }
2385
3.53k
}
2386
2387
void OMPTraitInfo::print(llvm::raw_ostream &OS,
2388
770
                         const PrintingPolicy &Policy) const {
2389
770
  bool FirstSet = true;
2390
954
  for (const OMPTraitSet &Set : Sets) {
2391
954
    if (!FirstSet)
2392
184
      OS << ", ";
2393
954
    FirstSet = false;
2394
954
    OS << getOpenMPContextTraitSetName(Set.Kind) << "={";
2395
2396
954
    bool FirstSelector = true;
2397
1.00k
    for (const OMPTraitSelector &Selector : Set.Selectors) {
2398
1.00k
      if (!FirstSelector)
2399
52
        OS << ", ";
2400
1.00k
      FirstSelector = false;
2401
1.00k
      OS << getOpenMPContextTraitSelectorName(Selector.Kind);
2402
2403
1.00k
      bool AllowsTraitScore = false;
2404
1.00k
      bool RequiresProperty = false;
2405
1.00k
      isValidTraitSelectorForTraitSet(
2406
1.00k
          Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
2407
2408
1.00k
      if (!RequiresProperty)
2409
126
        continue;
2410
2411
880
      OS << "(";
2412
880
      if (Selector.Kind == TraitSelector::user_condition) {
2413
56
        if (Selector.ScoreOrCondition)
2414
28
          Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy);
2415
28
        else
2416
28
          OS << "...";
2417
824
      } else {
2418
2419
824
        if (Selector.ScoreOrCondition) {
2420
55
          OS << "score(";
2421
55
          Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy);
2422
55
          OS << "): ";
2423
55
        }
2424
2425
824
        bool FirstProperty = true;
2426
928
        for (const OMPTraitProperty &Property : Selector.Properties) {
2427
928
          if (!FirstProperty)
2428
104
            OS << ", ";
2429
928
          FirstProperty = false;
2430
928
          OS << getOpenMPContextTraitPropertyName(Property.Kind,
2431
928
                                                  Property.RawString);
2432
928
        }
2433
824
      }
2434
880
      OS << ")";
2435
880
    }
2436
954
    OS << "}";
2437
954
  }
2438
770
}
2439
2440
246
std::string OMPTraitInfo::getMangledName() const {
2441
246
  std::string MangledName;
2442
246
  llvm::raw_string_ostream OS(MangledName);
2443
253
  for (const OMPTraitSet &Set : Sets) {
2444
253
    OS << '$' << 'S' << unsigned(Set.Kind);
2445
269
    for (const OMPTraitSelector &Selector : Set.Selectors) {
2446
2447
269
      bool AllowsTraitScore = false;
2448
269
      bool RequiresProperty = false;
2449
269
      isValidTraitSelectorForTraitSet(
2450
269
          Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
2451
269
      OS << '$' << 's' << unsigned(Selector.Kind);
2452
2453
269
      if (!RequiresProperty ||
2454
269
          
Selector.Kind == TraitSelector::user_condition267
)
2455
17
        continue;
2456
2457
252
      for (const OMPTraitProperty &Property : Selector.Properties)
2458
313
        OS << '$' << 'P'
2459
313
           << getOpenMPContextTraitPropertyName(Property.Kind,
2460
313
                                                Property.RawString);
2461
252
    }
2462
253
  }
2463
246
  return MangledName;
2464
246
}
2465
2466
400
OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
2467
400
  unsigned long U;
2468
840
  do {
2469
840
    if (!MangledName.consume_front("$S"))
2470
400
      break;
2471
440
    if (MangledName.consumeInteger(10, U))
2472
0
      break;
2473
440
    Sets.push_back(OMPTraitSet());
2474
440
    OMPTraitSet &Set = Sets.back();
2475
440
    Set.Kind = TraitSet(U);
2476
908
    do {
2477
908
      if (!MangledName.consume_front("$s"))
2478
440
        break;
2479
468
      if (MangledName.consumeInteger(10, U))
2480
0
        break;
2481
468
      Set.Selectors.push_back(OMPTraitSelector());
2482
468
      OMPTraitSelector &Selector = Set.Selectors.back();
2483
468
      Selector.Kind = TraitSelector(U);
2484
934
      do {
2485
934
        if (!MangledName.consume_front("$P"))
2486
468
          break;
2487
466
        Selector.Properties.push_back(OMPTraitProperty());
2488
466
        OMPTraitProperty &Property = Selector.Properties.back();
2489
466
        std::pair<StringRef, StringRef> PropRestPair = MangledName.split('$');
2490
466
        Property.RawString = PropRestPair.first;
2491
466
        Property.Kind = getOpenMPContextTraitPropertyKind(
2492
466
            Set.Kind, Selector.Kind, PropRestPair.first);
2493
466
        MangledName = MangledName.drop_front(PropRestPair.first.size());
2494
466
      } while (true);
2495
468
    } while (true);
2496
440
  } while (true);
2497
400
}
2498
2499
llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
2500
770
                                     const OMPTraitInfo &TI) {
2501
770
  LangOptions LO;
2502
770
  PrintingPolicy Policy(LO);
2503
770
  TI.print(OS, Policy);
2504
770
  return OS;
2505
770
}
2506
llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
2507
370
                                     const OMPTraitInfo *TI) {
2508
370
  return TI ? OS << *TI : 
OS0
;
2509
370
}
2510
2511
TargetOMPContext::TargetOMPContext(
2512
    ASTContext &ASTCtx, std::function<void(StringRef)> &&DiagUnknownTrait,
2513
    const FunctionDecl *CurrentFunctionDecl,
2514
    ArrayRef<llvm::omp::TraitProperty> ConstructTraits)
2515
    : OMPContext(ASTCtx.getLangOpts().OpenMPIsDevice,
2516
                 ASTCtx.getTargetInfo().getTriple()),
2517
13
      FeatureValidityCheck([&](StringRef FeatureName) {
2518
13
        return ASTCtx.getTargetInfo().isValidFeatureName(FeatureName);
2519
13
      }),
2520
2.90k
      DiagUnknownTrait(std::move(DiagUnknownTrait)) {
2521
2.90k
  ASTCtx.getFunctionFeatureMap(FeatureMap, CurrentFunctionDecl);
2522
2523
2.90k
  for (llvm::omp::TraitProperty Property : ConstructTraits)
2524
438
    addTrait(Property);
2525
2.90k
}
2526
2527
42
bool TargetOMPContext::matchesISATrait(StringRef RawString) const {
2528
42
  auto It = FeatureMap.find(RawString);
2529
42
  if (It != FeatureMap.end())
2530
29
    return It->second;
2531
13
  if (!FeatureValidityCheck(RawString))
2532
9
    DiagUnknownTrait(RawString);
2533
13
  return false;
2534
42
}