Coverage Report

Created: 2020-09-22 08:39

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