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