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