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