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