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