clang 22.0.0git
OpenMPClause.h
Go to the documentation of this file.
1//===- OpenMPClause.h - Classes for OpenMP clauses --------------*- C++ -*-===//
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/// \file
10/// This file defines OpenMP AST classes for clauses.
11/// There are clauses for executable directives, clauses for declarative
12/// directives and clauses which can be used in both kinds of directives.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_CLANG_AST_OPENMPCLAUSE_H
17#define LLVM_CLANG_AST_OPENMPCLAUSE_H
18
19#include "clang/AST/ASTFwd.h"
20#include "clang/AST/Decl.h"
22#include "clang/AST/Expr.h"
24#include "clang/AST/Stmt.h"
26#include "clang/Basic/LLVM.h"
29#include "llvm/ADT/ArrayRef.h"
30#include "llvm/ADT/MapVector.h"
31#include "llvm/ADT/PointerIntPair.h"
32#include "llvm/ADT/SmallVector.h"
33#include "llvm/ADT/iterator.h"
34#include "llvm/ADT/iterator_range.h"
35#include "llvm/Frontend/OpenMP/OMPAssume.h"
36#include "llvm/Frontend/OpenMP/OMPConstants.h"
37#include "llvm/Frontend/OpenMP/OMPContext.h"
38#include "llvm/Support/Casting.h"
39#include "llvm/Support/Compiler.h"
40#include "llvm/Support/TrailingObjects.h"
41#include <cassert>
42#include <cstddef>
43#include <iterator>
44#include <utility>
45
46namespace clang {
47
48class ASTContext;
49
50//===----------------------------------------------------------------------===//
51// AST classes for clauses.
52//===----------------------------------------------------------------------===//
53
54/// This is a basic class for representing single OpenMP clause.
55class OMPClause {
56 /// Starting location of the clause (the clause keyword).
57 SourceLocation StartLoc;
58
59 /// Ending location of the clause.
60 SourceLocation EndLoc;
61
62 /// Kind of the clause.
64
65protected:
67 : StartLoc(StartLoc), EndLoc(EndLoc), Kind(K) {}
68
69public:
70 /// Returns the starting location of the clause.
71 SourceLocation getBeginLoc() const { return StartLoc; }
72
73 /// Returns the ending location of the clause.
74 SourceLocation getEndLoc() const { return EndLoc; }
75
76 /// Sets the starting location of the clause.
77 void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
78
79 /// Sets the ending location of the clause.
80 void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
81
82 /// Returns kind of OpenMP clause (private, shared, reduction, etc.).
83 OpenMPClauseKind getClauseKind() const { return Kind; }
84
85 bool isImplicit() const { return StartLoc.isInvalid(); }
86
89 using child_range = llvm::iterator_range<child_iterator>;
90 using const_child_range = llvm::iterator_range<const_child_iterator>;
91
94 return const_cast<OMPClause *>(this)->children();
95 }
96
97 /// Get the iterator range for the expressions used in the clauses. Used
98 /// expressions include only the children that must be evaluated at the
99 /// runtime before entering the construct.
102 return const_cast<OMPClause *>(this)->children();
103 }
104
105 static bool classof(const OMPClause *) { return true; }
106};
107
108template <OpenMPClauseKind ClauseKind>
110 /// Build '\p ClauseKind' clause.
111 ///
112 /// \param StartLoc Starting location of the clause.
113 /// \param EndLoc Ending location of the clause.
115 : OMPClause(ClauseKind, StartLoc, EndLoc) {}
116
117 /// Build an empty clause.
120
124
128
135
136 static bool classof(const OMPClause *T) {
137 return T->getClauseKind() == ClauseKind;
138 }
139};
140
141template <OpenMPClauseKind ClauseKind, class Base>
142class OMPOneStmtClause : public Base {
143
144 /// Location of '('.
145 SourceLocation LParenLoc;
146
147 /// Sub-expression.
148 Stmt *S = nullptr;
149
150protected:
151 void setStmt(Stmt *S) { this->S = S; }
152
153public:
155 SourceLocation EndLoc)
156 : Base(ClauseKind, StartLoc, EndLoc), LParenLoc(LParenLoc), S(S) {}
157
159
160 /// Return the associated statement, potentially casted to \p T.
161 template <typename T> T *getStmtAs() const { return cast_or_null<T>(S); }
162
163 /// Sets the location of '('.
164 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
165
166 /// Returns the location of '('.
167 SourceLocation getLParenLoc() const { return LParenLoc; }
168
171 using child_range = llvm::iterator_range<child_iterator>;
172 using const_child_range = llvm::iterator_range<const_child_iterator>;
173
174 child_range children() { return child_range(&S, &S + 1); }
175
176 const_child_range children() const { return const_child_range(&S, &S + 1); }
177
178 // TODO: Consider making the getAddrOfExprAsWritten version the default.
185
186 static bool classof(const OMPClause *T) {
187 return T->getClauseKind() == ClauseKind;
188 }
189};
190
191/// Class that handles pre-initialization statement for some clauses, like
192/// 'schedule', 'firstprivate' etc.
194 friend class OMPClauseReader;
195
196 /// Pre-initialization statement for the clause.
197 Stmt *PreInit = nullptr;
198
199 /// Region that captures the associated stmt.
200 OpenMPDirectiveKind CaptureRegion = llvm::omp::OMPD_unknown;
201
202protected:
204 assert(get(This) && "get is not tuned for pre-init.");
205 }
206
207 /// Set pre-initialization statement for the clause.
208 void
210 OpenMPDirectiveKind ThisRegion = llvm::omp::OMPD_unknown) {
211 PreInit = S;
212 CaptureRegion = ThisRegion;
213 }
214
215public:
216 /// Get pre-initialization statement for the clause.
217 const Stmt *getPreInitStmt() const { return PreInit; }
218
219 /// Get pre-initialization statement for the clause.
220 Stmt *getPreInitStmt() { return PreInit; }
221
222 /// Get capture region for the stmt in the clause.
223 OpenMPDirectiveKind getCaptureRegion() const { return CaptureRegion; }
224
226 static const OMPClauseWithPreInit *get(const OMPClause *C);
227};
228
229/// Class that handles post-update expression for some clauses, like
230/// 'lastprivate', 'reduction' etc.
232 friend class OMPClauseReader;
233
234 /// Post-update expression for the clause.
235 Expr *PostUpdate = nullptr;
236
237protected:
239 assert(get(This) && "get is not tuned for post-update.");
240 }
241
242 /// Set pre-initialization statement for the clause.
243 void setPostUpdateExpr(Expr *S) { PostUpdate = S; }
244
245public:
246 /// Get post-update expression for the clause.
247 const Expr *getPostUpdateExpr() const { return PostUpdate; }
248
249 /// Get post-update expression for the clause.
250 Expr *getPostUpdateExpr() { return PostUpdate; }
251
253 static const OMPClauseWithPostUpdate *get(const OMPClause *C);
254};
255
256/// This structure contains most locations needed for by an OMPVarListClause.
258 /// Starting location of the clause (the clause keyword).
260 /// Location of '('.
262 /// Ending location of the clause.
264 OMPVarListLocTy() = default;
268};
269
270/// This represents clauses with the list of variables like 'private',
271/// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
272/// '#pragma omp ...' directives.
273template <class T> class OMPVarListClause : public OMPClause {
274 friend class OMPClauseReader;
275
276 /// Location of '('.
277 SourceLocation LParenLoc;
278
279 /// Number of variables in the list.
280 unsigned NumVars;
281
282protected:
283 /// Build a clause with \a N variables
284 ///
285 /// \param K Kind of the clause.
286 /// \param StartLoc Starting location of the clause (the clause keyword).
287 /// \param LParenLoc Location of '('.
288 /// \param EndLoc Ending location of the clause.
289 /// \param N Number of the variables in the clause.
291 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
292 : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {}
293
294 /// Fetches list of variables associated with this clause.
296 return static_cast<T *>(this)->template getTrailingObjectsNonStrict<Expr *>(
297 NumVars);
298 }
299
300 /// Sets the list of variables for this clause.
302 assert(VL.size() == NumVars &&
303 "Number of variables is not the same as the preallocated buffer");
304 llvm::copy(VL, getVarRefs().begin());
305 }
306
307public:
310 using varlist_range = llvm::iterator_range<varlist_iterator>;
311 using varlist_const_range = llvm::iterator_range<varlist_const_iterator>;
312
313 unsigned varlist_size() const { return NumVars; }
314 bool varlist_empty() const { return NumVars == 0; }
315
318
321 varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
323
324 /// Sets the location of '('.
325 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
326
327 /// Returns the location of '('.
328 SourceLocation getLParenLoc() const { return LParenLoc; }
329
330 /// Fetches list of all variables in the clause.
332 return static_cast<const T *>(this)
333 ->template getTrailingObjectsNonStrict<Expr *>(NumVars);
334 }
335};
336
337/// Class that represents a list of directive kinds (parallel, target, etc.)
338/// as used in \c absent, \c contains clauses.
339template <class T> class OMPDirectiveListClause : public OMPClause {
340 /// Location of '('.
341 SourceLocation LParenLoc;
342
343protected:
344 /// Number of directive kinds listed in the clause
345 unsigned NumKinds;
346
347public:
348 /// Build a clause with \a NumKinds directive kinds.
349 ///
350 /// \param K The clause kind.
351 /// \param StartLoc Starting location of the clause (the clause keyword).
352 /// \param LParenLoc Location of '('.
353 /// \param EndLoc Ending location of the clause.
354 /// \param NumKinds Number of directive kinds listed in the clause.
356 SourceLocation LParenLoc, SourceLocation EndLoc,
357 unsigned NumKinds)
358 : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc),
360
364
368
375
377 return static_cast<T *>(this)
378 ->template getTrailingObjectsNonStrict<OpenMPDirectiveKind>(NumKinds);
379 }
380
382 assert(
383 DK.size() == NumKinds &&
384 "Number of directive kinds is not the same as the preallocated buffer");
385 llvm::copy(DK, getDirectiveKinds().begin());
386 }
387
388 SourceLocation getLParenLoc() { return LParenLoc; }
389
390 void setLParenLoc(SourceLocation S) { LParenLoc = S; }
391};
392
393/// This represents 'allocator' clause in the '#pragma omp ...'
394/// directive.
395///
396/// \code
397/// #pragma omp allocate(a) allocator(omp_default_mem_alloc)
398/// \endcode
399/// In this example directive '#pragma omp allocate' has simple 'allocator'
400/// clause with the allocator 'omp_default_mem_alloc'.
402 : public OMPOneStmtClause<llvm::omp::OMPC_allocator, OMPClause> {
403 friend class OMPClauseReader;
404
405 /// Set allocator.
406 void setAllocator(Expr *A) { setStmt(A); }
407
408public:
409 /// Build 'allocator' clause with the given allocator.
410 ///
411 /// \param A Allocator.
412 /// \param StartLoc Starting location of the clause.
413 /// \param LParenLoc Location of '('.
414 /// \param EndLoc Ending location of the clause.
416 SourceLocation EndLoc)
417 : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
418
419 /// Build an empty clause.
421
422 /// Returns allocator.
423 Expr *getAllocator() const { return getStmtAs<Expr>(); }
424};
425
426/// This represents the 'align' clause in the '#pragma omp allocate'
427/// directive.
428///
429/// \code
430/// #pragma omp allocate(a) allocator(omp_default_mem_alloc) align(8)
431/// \endcode
432/// In this example directive '#pragma omp allocate' has simple 'allocator'
433/// clause with the allocator 'omp_default_mem_alloc' and align clause with
434/// value of 8.
435class OMPAlignClause final
436 : public OMPOneStmtClause<llvm::omp::OMPC_align, OMPClause> {
437 friend class OMPClauseReader;
438
439 /// Set alignment value.
440 void setAlignment(Expr *A) { setStmt(A); }
441
442 /// Build 'align' clause with the given alignment
443 ///
444 /// \param A Alignment value.
445 /// \param StartLoc Starting location of the clause.
446 /// \param LParenLoc Location of '('.
447 /// \param EndLoc Ending location of the clause.
448 OMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc,
449 SourceLocation EndLoc)
450 : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
451
452 /// Build an empty clause.
453 OMPAlignClause() : OMPOneStmtClause() {}
454
455public:
456 /// Build 'align' clause with the given alignment
457 ///
458 /// \param A Alignment value.
459 /// \param StartLoc Starting location of the clause.
460 /// \param LParenLoc Location of '('.
461 /// \param EndLoc Ending location of the clause.
462 static OMPAlignClause *Create(const ASTContext &C, Expr *A,
463 SourceLocation StartLoc,
464 SourceLocation LParenLoc,
465 SourceLocation EndLoc);
466
467 /// Returns alignment
468 Expr *getAlignment() const { return getStmtAs<Expr>(); }
469};
470
471/// This represents clause 'allocate' in the '#pragma omp ...' directives.
472///
473/// \code
474/// #pragma omp parallel private(a) allocate(omp_default_mem_alloc :a)
475/// \endcode
476/// In this example directive '#pragma omp parallel' has clause 'private'
477/// and clause 'allocate' for the variable 'a', which specifies an explicit
478/// memory allocator.
479class OMPAllocateClause final
480 : public OMPVarListClause<OMPAllocateClause>,
481 private llvm::TrailingObjects<OMPAllocateClause, Expr *> {
482 friend class OMPClauseReader;
483 friend OMPVarListClause;
484 friend TrailingObjects;
485
486 /// Allocator specified in the clause, or 'nullptr' if the default one is
487 /// used.
488 Expr *Allocator = nullptr;
489 /// Alignment specified in the clause, or 'nullptr' if the default one is
490 /// used.
491 Expr *Alignment = nullptr;
492 /// Position of the ':' delimiter in the clause;
493 SourceLocation ColonLoc;
494 /// Modifier of 'allocate' clause.
496 /// Location of allocator modifier if any.
497 SourceLocation AllocatorModifierLoc;
498
499 // ----------------------------------------------------------------------------
500
501 /// Modifiers for 'allocate' clause.
502 enum { FIRST, SECOND, NUM_MODIFIERS };
503 OpenMPAllocateClauseModifier Modifiers[NUM_MODIFIERS];
504
505 /// Locations of modifiers.
506 SourceLocation ModifiersLoc[NUM_MODIFIERS];
507
508 /// Set the first allocate modifier.
509 ///
510 /// \param M Allocate modifier.
511 void setFirstAllocateModifier(OpenMPAllocateClauseModifier M) {
512 Modifiers[FIRST] = M;
513 }
514
515 /// Set the second allocate modifier.
516 ///
517 /// \param M Allocate modifier.
518 void setSecondAllocateModifier(OpenMPAllocateClauseModifier M) {
519 Modifiers[SECOND] = M;
520 }
521
522 /// Set location of the first allocate modifier.
523 void setFirstAllocateModifierLoc(SourceLocation Loc) {
524 ModifiersLoc[FIRST] = Loc;
525 }
526
527 /// Set location of the second allocate modifier.
528 void setSecondAllocateModifierLoc(SourceLocation Loc) {
529 ModifiersLoc[SECOND] = Loc;
530 }
531
532 // ----------------------------------------------------------------------------
533
534 /// Build clause with number of variables \a N.
535 ///
536 /// \param StartLoc Starting location of the clause.
537 /// \param LParenLoc Location of '('.
538 /// \param Allocator Allocator expression.
539 /// \param ColonLoc Location of ':' delimiter.
540 /// \param EndLoc Ending location of the clause.
541 /// \param N Number of the variables in the clause.
542 OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
543 Expr *Allocator, Expr *Alignment, SourceLocation ColonLoc,
545 SourceLocation Modifier1Loc,
547 SourceLocation Modifier2Loc, SourceLocation EndLoc,
548 unsigned N)
549 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate, StartLoc,
550 LParenLoc, EndLoc, N),
551 Allocator(Allocator), Alignment(Alignment), ColonLoc(ColonLoc) {
552 Modifiers[FIRST] = Modifier1;
553 Modifiers[SECOND] = Modifier2;
554 ModifiersLoc[FIRST] = Modifier1Loc;
555 ModifiersLoc[SECOND] = Modifier2Loc;
556 }
557
558 /// Build an empty clause.
559 ///
560 /// \param N Number of variables.
561 explicit OMPAllocateClause(unsigned N)
562 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate,
563 SourceLocation(), SourceLocation(),
564 SourceLocation(), N) {
565 Modifiers[FIRST] = OMPC_ALLOCATE_unknown;
566 Modifiers[SECOND] = OMPC_ALLOCATE_unknown;
567 }
568
569 /// Sets location of ':' symbol in clause.
570 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
571
572 void setAllocator(Expr *A) { Allocator = A; }
573 void setAllocatorModifier(OpenMPAllocateClauseModifier AM) {
574 AllocatorModifier = AM;
575 }
576 void setAlignment(Expr *A) { Alignment = A; }
577
578public:
579 /// Creates clause with a list of variables \a VL.
580 ///
581 /// \param C AST context.
582 /// \param StartLoc Starting location of the clause.
583 /// \param LParenLoc Location of '('.
584 /// \param Allocator Allocator expression.
585 /// \param ColonLoc Location of ':' delimiter.
586 /// \param AllocatorModifier Allocator modifier.
587 /// \param SourceLocation Allocator modifier location.
588 /// \param EndLoc Ending location of the clause.
589 /// \param VL List of references to the variables.
590 static OMPAllocateClause *
591 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
592 Expr *Allocator, Expr *Alignment, SourceLocation ColonLoc,
593 OpenMPAllocateClauseModifier Modifier1, SourceLocation Modifier1Loc,
594 OpenMPAllocateClauseModifier Modifier2, SourceLocation Modifier2Loc,
595 SourceLocation EndLoc, ArrayRef<Expr *> VL);
596
597 /// Returns the allocator expression or nullptr, if no allocator is specified.
598 Expr *getAllocator() const { return Allocator; }
599
600 /// Returns the alignment expression or nullptr, if no alignment specified.
601 Expr *getAlignment() const { return Alignment; }
602
603 /// Return 'allocate' modifier.
605 return AllocatorModifier;
606 }
607
608 /// Get the first modifier of the clause.
610 return Modifiers[FIRST];
611 }
612
613 /// Get location of first modifier of the clause.
615 return ModifiersLoc[FIRST];
616 }
617
618 /// Get the second modifier of the clause.
620 return Modifiers[SECOND];
621 }
622
623 /// Get location of second modifier of the clause.
625 return ModifiersLoc[SECOND];
626 }
627
628 /// Returns the location of the ':' delimiter.
629 SourceLocation getColonLoc() const { return ColonLoc; }
630 /// Return the location of the modifier.
632 return AllocatorModifierLoc;
633 }
634
635 /// Creates an empty clause with the place for \a N variables.
636 ///
637 /// \param C AST context.
638 /// \param N The number of variables.
639 static OMPAllocateClause *CreateEmpty(const ASTContext &C, unsigned N);
640
642 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
643 reinterpret_cast<Stmt **>(varlist_end()));
644 }
645
647 return const_cast<OMPAllocateClause *>(this)->children();
648 }
649
656
657 static bool classof(const OMPClause *T) {
658 return T->getClauseKind() == llvm::omp::OMPC_allocate;
659 }
660};
661
662/// This represents 'if' clause in the '#pragma omp ...' directive.
663///
664/// \code
665/// #pragma omp parallel if(parallel:a > 5)
666/// \endcode
667/// In this example directive '#pragma omp parallel' has simple 'if' clause with
668/// condition 'a > 5' and directive name modifier 'parallel'.
670 friend class OMPClauseReader;
671
672 /// Location of '('.
673 SourceLocation LParenLoc;
674
675 /// Condition of the 'if' clause.
676 Stmt *Condition = nullptr;
677
678 /// Location of ':' (if any).
679 SourceLocation ColonLoc;
680
681 /// Directive name modifier for the clause.
682 OpenMPDirectiveKind NameModifier = llvm::omp::OMPD_unknown;
683
684 /// Name modifier location.
685 SourceLocation NameModifierLoc;
686
687 /// Set condition.
688 void setCondition(Expr *Cond) { Condition = Cond; }
689
690 /// Set directive name modifier for the clause.
691 void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
692
693 /// Set location of directive name modifier for the clause.
694 void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
695
696 /// Set location of ':'.
697 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
698
699public:
700 /// Build 'if' clause with condition \a Cond.
701 ///
702 /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
703 /// \param Cond Condition of the clause.
704 /// \param HelperCond Helper condition for the clause.
705 /// \param CaptureRegion Innermost OpenMP region where expressions in this
706 /// clause must be captured.
707 /// \param StartLoc Starting location of the clause.
708 /// \param LParenLoc Location of '('.
709 /// \param NameModifierLoc Location of directive name modifier.
710 /// \param ColonLoc [OpenMP 4.1] Location of ':'.
711 /// \param EndLoc Ending location of the clause.
712 OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond,
713 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
714 SourceLocation LParenLoc, SourceLocation NameModifierLoc,
715 SourceLocation ColonLoc, SourceLocation EndLoc)
716 : OMPClause(llvm::omp::OMPC_if, StartLoc, EndLoc),
717 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond),
718 ColonLoc(ColonLoc), NameModifier(NameModifier),
719 NameModifierLoc(NameModifierLoc) {
720 setPreInitStmt(HelperCond, CaptureRegion);
721 }
722
723 /// Build an empty clause.
727
728 /// Sets the location of '('.
729 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
730
731 /// Returns the location of '('.
732 SourceLocation getLParenLoc() const { return LParenLoc; }
733
734 /// Return the location of ':'.
735 SourceLocation getColonLoc() const { return ColonLoc; }
736
737 /// Returns condition.
738 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
739
740 /// Return directive name modifier associated with the clause.
741 OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
742
743 /// Return the location of directive name modifier.
744 SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
745
746 child_range children() { return child_range(&Condition, &Condition + 1); }
747
749 return const_child_range(&Condition, &Condition + 1);
750 }
751
754 return const_cast<OMPIfClause *>(this)->used_children();
755 }
756
757 static bool classof(const OMPClause *T) {
758 return T->getClauseKind() == llvm::omp::OMPC_if;
759 }
760};
761
762/// This represents 'final' clause in the '#pragma omp ...' directive.
763///
764/// \code
765/// #pragma omp task final(a > 5)
766/// \endcode
767/// In this example directive '#pragma omp task' has simple 'final'
768/// clause with condition 'a > 5'.
769class OMPFinalClause final
770 : public OMPOneStmtClause<llvm::omp::OMPC_final, OMPClause>,
771 public OMPClauseWithPreInit {
772 friend class OMPClauseReader;
773
774 /// Set condition.
775 void setCondition(Expr *Cond) { setStmt(Cond); }
776
777public:
778 /// Build 'final' clause with condition \a Cond.
779 ///
780 /// \param Cond Condition of the clause.
781 /// \param HelperCond Helper condition for the construct.
782 /// \param CaptureRegion Innermost OpenMP region where expressions in this
783 /// clause must be captured.
784 /// \param StartLoc Starting location of the clause.
785 /// \param LParenLoc Location of '('.
786 /// \param EndLoc Ending location of the clause.
788 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
789 SourceLocation LParenLoc, SourceLocation EndLoc)
790 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
792 setPreInitStmt(HelperCond, CaptureRegion);
793 }
794
795 /// Build an empty clause.
797
798 /// Returns condition.
799 Expr *getCondition() const { return getStmtAs<Expr>(); }
800
803 return const_cast<OMPFinalClause *>(this)->used_children();
804 }
805};
806/// This represents 'num_threads' clause in the '#pragma omp ...'
807/// directive.
808///
809/// \code
810/// #pragma omp parallel num_threads(6)
811/// \endcode
812/// In this example directive '#pragma omp parallel' has simple 'num_threads'
813/// clause with number of threads '6'.
815 : public OMPOneStmtClause<llvm::omp::OMPC_num_threads, OMPClause>,
816 public OMPClauseWithPreInit {
817 friend class OMPClauseReader;
818
819 /// Modifiers for 'num_threads' clause.
821
822 /// Location of the modifier.
823 SourceLocation ModifierLoc;
824
825 /// Sets modifier.
826 void setModifier(OpenMPNumThreadsClauseModifier M) { Modifier = M; }
827
828 /// Sets modifier location.
829 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
830
831 /// Set condition.
832 void setNumThreads(Expr *NThreads) { setStmt(NThreads); }
833
834public:
835 /// Build 'num_threads' clause with condition \a NumThreads.
836 ///
837 /// \param Modifier Clause modifier.
838 /// \param NumThreads Number of threads for the construct.
839 /// \param HelperNumThreads Helper Number of threads for the construct.
840 /// \param CaptureRegion Innermost OpenMP region where expressions in this
841 /// clause must be captured.
842 /// \param StartLoc Starting location of the clause.
843 /// \param LParenLoc Location of '('.
844 /// \param ModifierLoc Modifier location.
845 /// \param EndLoc Ending location of the clause.
847 Stmt *HelperNumThreads, OpenMPDirectiveKind CaptureRegion,
848 SourceLocation StartLoc, SourceLocation LParenLoc,
849 SourceLocation ModifierLoc, SourceLocation EndLoc)
850 : OMPOneStmtClause(NumThreads, StartLoc, LParenLoc, EndLoc),
851 OMPClauseWithPreInit(this), Modifier(Modifier),
852 ModifierLoc(ModifierLoc) {
853 setPreInitStmt(HelperNumThreads, CaptureRegion);
854 }
855
856 /// Build an empty clause.
858
859 /// Gets modifier.
860 OpenMPNumThreadsClauseModifier getModifier() const { return Modifier; }
861
862 /// Gets modifier location.
863 SourceLocation getModifierLoc() const { return ModifierLoc; }
864
865 /// Returns number of threads.
866 Expr *getNumThreads() const { return getStmtAs<Expr>(); }
867};
868
869/// This represents 'safelen' clause in the '#pragma omp ...'
870/// directive.
871///
872/// \code
873/// #pragma omp simd safelen(4)
874/// \endcode
875/// In this example directive '#pragma omp simd' has clause 'safelen'
876/// with single expression '4'.
877/// If the safelen clause is used then no two iterations executed
878/// concurrently with SIMD instructions can have a greater distance
879/// in the logical iteration space than its value. The parameter of
880/// the safelen clause must be a constant positive integer expression.
882 : public OMPOneStmtClause<llvm::omp::OMPC_safelen, OMPClause> {
883 friend class OMPClauseReader;
884
885 /// Set safelen.
886 void setSafelen(Expr *Len) { setStmt(Len); }
887
888public:
889 /// Build 'safelen' clause.
890 ///
891 /// \param Len Expression associated with this clause.
892 /// \param StartLoc Starting location of the clause.
893 /// \param EndLoc Ending location of the clause.
895 SourceLocation EndLoc)
896 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
897
898 /// Build an empty clause.
900
901 /// Return safe iteration space distance.
902 Expr *getSafelen() const { return getStmtAs<Expr>(); }
903};
904
905/// This represents 'simdlen' clause in the '#pragma omp ...'
906/// directive.
907///
908/// \code
909/// #pragma omp simd simdlen(4)
910/// \endcode
911/// In this example directive '#pragma omp simd' has clause 'simdlen'
912/// with single expression '4'.
913/// If the 'simdlen' clause is used then it specifies the preferred number of
914/// iterations to be executed concurrently. The parameter of the 'simdlen'
915/// clause must be a constant positive integer expression.
917 : public OMPOneStmtClause<llvm::omp::OMPC_simdlen, OMPClause> {
918 friend class OMPClauseReader;
919
920 /// Set simdlen.
921 void setSimdlen(Expr *Len) { setStmt(Len); }
922
923public:
924 /// Build 'simdlen' clause.
925 ///
926 /// \param Len Expression associated with this clause.
927 /// \param StartLoc Starting location of the clause.
928 /// \param EndLoc Ending location of the clause.
930 SourceLocation EndLoc)
931 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
932
933 /// Build an empty clause.
935
936 /// Return safe iteration space distance.
937 Expr *getSimdlen() const { return getStmtAs<Expr>(); }
938};
939
940/// This represents the 'sizes' clause in the '#pragma omp tile' directive.
941///
942/// \code
943/// #pragma omp tile sizes(5,5)
944/// for (int i = 0; i < 64; ++i)
945/// for (int j = 0; j < 64; ++j)
946/// \endcode
947class OMPSizesClause final
948 : public OMPClause,
949 private llvm::TrailingObjects<OMPSizesClause, Expr *> {
950 friend class OMPClauseReader;
951 friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
952
953 /// Location of '('.
954 SourceLocation LParenLoc;
955
956 /// Number of tile sizes in the clause.
957 unsigned NumSizes;
958
959 /// Build an empty clause.
960 explicit OMPSizesClause(int NumSizes)
961 : OMPClause(llvm::omp::OMPC_sizes, SourceLocation(), SourceLocation()),
962 NumSizes(NumSizes) {}
963
964public:
965 /// Build a 'sizes' AST node.
966 ///
967 /// \param C Context of the AST.
968 /// \param StartLoc Location of the 'sizes' identifier.
969 /// \param LParenLoc Location of '('.
970 /// \param EndLoc Location of ')'.
971 /// \param Sizes Content of the clause.
972 static OMPSizesClause *Create(const ASTContext &C, SourceLocation StartLoc,
973 SourceLocation LParenLoc, SourceLocation EndLoc,
974 ArrayRef<Expr *> Sizes);
975
976 /// Build an empty 'sizes' AST node for deserialization.
977 ///
978 /// \param C Context of the AST.
979 /// \param NumSizes Number of items in the clause.
980 static OMPSizesClause *CreateEmpty(const ASTContext &C, unsigned NumSizes);
981
982 /// Sets the location of '('.
983 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
984
985 /// Returns the location of '('.
986 SourceLocation getLParenLoc() const { return LParenLoc; }
987
988 /// Returns the number of list items.
989 unsigned getNumSizes() const { return NumSizes; }
990
991 /// Returns the tile size expressions.
993 return getTrailingObjects(NumSizes);
994 }
995 ArrayRef<Expr *> getSizesRefs() const { return getTrailingObjects(NumSizes); }
996
997 /// Sets the tile size expressions.
999 assert(VL.size() == NumSizes);
1000 llvm::copy(VL, getSizesRefs().begin());
1001 }
1002
1005 return child_range(reinterpret_cast<Stmt **>(Sizes.begin()),
1006 reinterpret_cast<Stmt **>(Sizes.end()));
1007 }
1010 return const_child_range(reinterpret_cast<Stmt *const *>(Sizes.begin()),
1011 reinterpret_cast<Stmt *const *>(Sizes.end()));
1012 }
1013
1020
1021 static bool classof(const OMPClause *T) {
1022 return T->getClauseKind() == llvm::omp::OMPC_sizes;
1023 }
1024};
1025
1026/// This class represents the 'permutation' clause in the
1027/// '#pragma omp interchange' directive.
1028///
1029/// \code{.c}
1030/// #pragma omp interchange permutation(2,1)
1031/// for (int i = 0; i < 64; ++i)
1032/// for (int j = 0; j < 64; ++j)
1033/// \endcode
1034class OMPPermutationClause final
1035 : public OMPClause,
1036 private llvm::TrailingObjects<OMPSizesClause, Expr *> {
1037 friend class OMPClauseReader;
1038 friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
1039
1040 /// Location of '('.
1041 SourceLocation LParenLoc;
1042
1043 /// Number of arguments in the clause, and hence also the number of loops to
1044 /// be permuted.
1045 unsigned NumLoops;
1046
1047 /// Sets the permutation index expressions.
1048 void setArgRefs(ArrayRef<Expr *> VL) {
1049 assert(VL.size() == NumLoops && "Expecting one expression per loop");
1050 llvm::copy(VL, getTrailingObjects());
1051 }
1052
1053 /// Build an empty clause.
1054 explicit OMPPermutationClause(int NumLoops)
1055 : OMPClause(llvm::omp::OMPC_permutation, SourceLocation(),
1056 SourceLocation()),
1057 NumLoops(NumLoops) {}
1058
1059public:
1060 /// Build a 'permutation' clause AST node.
1061 ///
1062 /// \param C Context of the AST.
1063 /// \param StartLoc Location of the 'permutation' identifier.
1064 /// \param LParenLoc Location of '('.
1065 /// \param EndLoc Location of ')'.
1066 /// \param Args Content of the clause.
1067 static OMPPermutationClause *
1068 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1069 SourceLocation EndLoc, ArrayRef<Expr *> Args);
1070
1071 /// Build an empty 'permutation' AST node for deserialization.
1072 ///
1073 /// \param C Context of the AST.
1074 /// \param NumLoops Number of arguments in the clause.
1075 static OMPPermutationClause *CreateEmpty(const ASTContext &C,
1076 unsigned NumLoops);
1077
1078 /// Sets the location of '('.
1079 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1080
1081 /// Returns the location of '('.
1082 SourceLocation getLParenLoc() const { return LParenLoc; }
1083
1084 /// Returns the number of list items.
1085 unsigned getNumLoops() const { return NumLoops; }
1086
1087 /// Returns the permutation index expressions.
1088 ///@{
1089 MutableArrayRef<Expr *> getArgsRefs() { return getTrailingObjects(NumLoops); }
1090 ArrayRef<Expr *> getArgsRefs() const { return getTrailingObjects(NumLoops); }
1091 ///@}
1092
1095 return child_range(reinterpret_cast<Stmt **>(Args.begin()),
1096 reinterpret_cast<Stmt **>(Args.end()));
1097 }
1100 return const_child_range(reinterpret_cast<Stmt *const *>(Args.begin()),
1101 reinterpret_cast<Stmt *const *>(Args.end()));
1102 }
1103
1110
1111 static bool classof(const OMPClause *T) {
1112 return T->getClauseKind() == llvm::omp::OMPC_permutation;
1113 }
1114};
1115
1116/// Representation of the 'full' clause of the '#pragma omp unroll' directive.
1117///
1118/// \code
1119/// #pragma omp unroll full
1120/// for (int i = 0; i < 64; ++i)
1121/// \endcode
1122class OMPFullClause final : public OMPNoChildClause<llvm::omp::OMPC_full> {
1123 friend class OMPClauseReader;
1124
1125 /// Build an empty clause.
1126 explicit OMPFullClause() : OMPNoChildClause() {}
1127
1128public:
1129 /// Build an AST node for a 'full' clause.
1130 ///
1131 /// \param C Context of the AST.
1132 /// \param StartLoc Starting location of the clause.
1133 /// \param EndLoc Ending location of the clause.
1134 static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc,
1135 SourceLocation EndLoc);
1136
1137 /// Build an empty 'full' AST node for deserialization.
1138 ///
1139 /// \param C Context of the AST.
1140 static OMPFullClause *CreateEmpty(const ASTContext &C);
1141};
1142
1143/// This class represents the 'looprange' clause in the
1144/// '#pragma omp fuse' directive
1145///
1146/// \code {c}
1147/// #pragma omp fuse looprange(1,2)
1148/// {
1149/// for(int i = 0; i < 64; ++i)
1150/// for(int j = 0; j < 256; j+=2)
1151/// for(int k = 127; k >= 0; --k)
1152/// \endcode
1153class OMPLoopRangeClause final : public OMPClause {
1154 friend class OMPClauseReader;
1155 /// Location of '('
1156 SourceLocation LParenLoc;
1157
1158 /// Location of first and count expressions
1159 SourceLocation FirstLoc, CountLoc;
1160
1161 /// Number of looprange arguments (always 2: first, count)
1162 enum { FirstExpr, CountExpr, NumArgs };
1163 Stmt *Args[NumArgs] = {nullptr, nullptr};
1164
1165 /// Set looprange 'first' expression
1166 void setFirst(Expr *E) { Args[FirstExpr] = E; }
1167
1168 /// Set looprange 'count' expression
1169 void setCount(Expr *E) { Args[CountExpr] = E; }
1170
1171 /// Build an empty clause for deserialization.
1172 explicit OMPLoopRangeClause()
1173 : OMPClause(llvm::omp::OMPC_looprange, {}, {}) {}
1174
1175public:
1176 /// Build a 'looprange' clause AST node.
1177 static OMPLoopRangeClause *
1178 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1179 SourceLocation FirstLoc, SourceLocation CountLoc,
1180 SourceLocation EndLoc, Expr *First, Expr *Count);
1181
1182 /// Build an empty 'looprange' clause node.
1183 static OMPLoopRangeClause *CreateEmpty(const ASTContext &C);
1184
1185 // Location getters/setters
1186 SourceLocation getLParenLoc() const { return LParenLoc; }
1187 SourceLocation getFirstLoc() const { return FirstLoc; }
1188 SourceLocation getCountLoc() const { return CountLoc; }
1189
1190 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1191 void setFirstLoc(SourceLocation Loc) { FirstLoc = Loc; }
1192 void setCountLoc(SourceLocation Loc) { CountLoc = Loc; }
1193
1194 /// Get looprange 'first' expression
1195 Expr *getFirst() const { return cast_or_null<Expr>(Args[FirstExpr]); }
1196
1197 /// Get looprange 'count' expression
1198 Expr *getCount() const { return cast_or_null<Expr>(Args[CountExpr]); }
1199
1200 child_range children() { return child_range(Args, Args + NumArgs); }
1202 return const_child_range(Args, Args + NumArgs);
1203 }
1204
1211
1212 static bool classof(const OMPClause *T) {
1213 return T->getClauseKind() == llvm::omp::OMPC_looprange;
1214 }
1215};
1216
1217/// Representation of the 'partial' clause of the '#pragma omp unroll'
1218/// directive.
1219///
1220/// \code
1221/// #pragma omp unroll partial(4)
1222/// for (int i = start; i < end; ++i)
1223/// \endcode
1224class OMPPartialClause final : public OMPClause {
1225 friend class OMPClauseReader;
1226
1227 /// Location of '('.
1228 SourceLocation LParenLoc;
1229
1230 /// Optional argument to the clause (unroll factor).
1231 Stmt *Factor;
1232
1233 /// Build an empty clause.
1234 explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {}
1235
1236 /// Set the unroll factor.
1237 void setFactor(Expr *E) { Factor = E; }
1238
1239 /// Sets the location of '('.
1240 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1241
1242public:
1243 /// Build an AST node for a 'partial' clause.
1244 ///
1245 /// \param C Context of the AST.
1246 /// \param StartLoc Location of the 'partial' identifier.
1247 /// \param LParenLoc Location of '('.
1248 /// \param EndLoc Location of ')'.
1249 /// \param Factor Clause argument.
1250 static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc,
1251 SourceLocation LParenLoc,
1252 SourceLocation EndLoc, Expr *Factor);
1253
1254 /// Build an empty 'partial' AST node for deserialization.
1255 ///
1256 /// \param C Context of the AST.
1257 static OMPPartialClause *CreateEmpty(const ASTContext &C);
1258
1259 /// Returns the location of '('.
1260 SourceLocation getLParenLoc() const { return LParenLoc; }
1261
1262 /// Returns the argument of the clause or nullptr if not set.
1263 Expr *getFactor() const { return cast_or_null<Expr>(Factor); }
1264
1265 child_range children() { return child_range(&Factor, &Factor + 1); }
1267 return const_child_range(&Factor, &Factor + 1);
1268 }
1269
1276
1277 static bool classof(const OMPClause *T) {
1278 return T->getClauseKind() == llvm::omp::OMPC_partial;
1279 }
1280};
1281
1282/// This represents 'collapse' clause in the '#pragma omp ...'
1283/// directive.
1284///
1285/// \code
1286/// #pragma omp simd collapse(3)
1287/// \endcode
1288/// In this example directive '#pragma omp simd' has clause 'collapse'
1289/// with single expression '3'.
1290/// The parameter must be a constant positive integer expression, it specifies
1291/// the number of nested loops that should be collapsed into a single iteration
1292/// space.
1294 : public OMPOneStmtClause<llvm::omp::OMPC_collapse, OMPClause> {
1295 friend class OMPClauseReader;
1296
1297 /// Set the number of associated for-loops.
1298 void setNumForLoops(Expr *Num) { setStmt(Num); }
1299
1300public:
1301 /// Build 'collapse' clause.
1302 ///
1303 /// \param Num Expression associated with this clause.
1304 /// \param StartLoc Starting location of the clause.
1305 /// \param LParenLoc Location of '('.
1306 /// \param EndLoc Ending location of the clause.
1308 SourceLocation LParenLoc, SourceLocation EndLoc)
1309 : OMPOneStmtClause(Num, StartLoc, LParenLoc, EndLoc) {}
1310
1311 /// Build an empty clause.
1313
1314 /// Return the number of associated for-loops.
1315 Expr *getNumForLoops() const { return getStmtAs<Expr>(); }
1316};
1317
1318/// This represents 'default' clause in the '#pragma omp ...' directive.
1319///
1320/// \code
1321/// #pragma omp parallel default(shared)
1322/// \endcode
1323/// In this example directive '#pragma omp parallel' has simple 'default'
1324/// clause with kind 'shared'.
1326 friend class OMPClauseReader;
1327
1328 /// Location of '('.
1329 SourceLocation LParenLoc;
1330
1331 /// A kind of the 'default' clause.
1332 llvm::omp::DefaultKind Kind = llvm::omp::OMP_DEFAULT_unknown;
1333
1334 /// Start location of the kind in source code.
1335 SourceLocation KindKwLoc;
1336
1337 /// Variable-Category to indicate where Kind is applied
1338 OpenMPDefaultClauseVariableCategory VC = OMPC_DEFAULT_VC_all;
1339
1340 /// Start location of Variable-Category
1341 SourceLocation VCLoc;
1342
1343 /// Set kind of the clauses.
1344 ///
1345 /// \param K Argument of clause.
1346 void setDefaultKind(llvm::omp::DefaultKind K) { Kind = K; }
1347
1348 /// Set argument location.
1349 ///
1350 /// \param KLoc Argument location.
1351 void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1352
1353 /// Set Variable Category used with the Kind Clause (Default Modifier)
1354 void setDefaultVariableCategory(OpenMPDefaultClauseVariableCategory VC) {
1355 this->VC = VC;
1356 }
1357
1358 void setDefaultVariableCategoryLocation(SourceLocation VCLoc) {
1359 this->VCLoc = VCLoc;
1360 }
1361
1362public:
1363 /// Build 'default' clause with argument \a A ('none' or 'shared').
1364 ///
1365 /// \param A Argument of the clause ('none' or 'shared').
1366 /// \param ALoc Starting location of the argument.
1367 /// \param StartLoc Starting location of the clause.
1368 /// \param LParenLoc Location of '('.
1369 /// \param EndLoc Ending location of the clause.
1370 OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc,
1372 SourceLocation StartLoc, SourceLocation LParenLoc,
1373 SourceLocation EndLoc)
1374 : OMPClause(llvm::omp::OMPC_default, StartLoc, EndLoc),
1375 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), VC(VC), VCLoc(VCLoc) {}
1376
1377 /// Build an empty clause.
1379 : OMPClause(llvm::omp::OMPC_default, SourceLocation(), SourceLocation()) {
1380 }
1381
1382 /// Sets the location of '('.
1383 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1384
1385 /// Returns the location of '('.
1386 SourceLocation getLParenLoc() const { return LParenLoc; }
1387
1388 /// Returns kind of the clause.
1389 llvm::omp::DefaultKind getDefaultKind() const { return Kind; }
1390
1391 /// Returns location of clause kind.
1392 SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
1393
1395
1396 SourceLocation getDefaultVCLoc() const { return VCLoc; }
1397
1401
1405
1412
1413 static bool classof(const OMPClause *T) {
1414 return T->getClauseKind() == llvm::omp::OMPC_default;
1415 }
1416};
1417
1418/// This represents 'threadset' clause in the '#pragma omp task ...' directive.
1419///
1420/// \code
1421/// #pragma omp task threadset(omp_pool)
1422/// \endcode
1423/// In this example directive '#pragma omp task' has simple 'threadset'
1424/// clause with kind 'omp_pool'.
1425class OMPThreadsetClause final : public OMPClause {
1426 friend class OMPClauseReader;
1427
1428 /// Location of '('.
1429 SourceLocation LParenLoc;
1430
1431 /// A kind of the 'threadset' clause.
1433
1434 /// Start location of the kind in source code.
1435 SourceLocation KindLoc;
1436
1437 /// Set kind of the clauses.
1438 ///
1439 /// \param K Argument of clause.
1440 void setThreadsetKind(OpenMPThreadsetKind K) { Kind = K; }
1441
1442 /// Set argument location.
1443 ///
1444 /// \param KLoc Argument location.
1445 void setThreadsetKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
1446
1447public:
1448 /// Build 'threadset' clause with argument \a A ('omp_team' or 'omp_pool').
1449 ///
1450 /// \param A Argument of the clause ('omp_team' or 'omp_pool').
1451 /// \param ALoc Starting location of the argument.
1452 /// \param StartLoc Starting location of the clause.
1453 /// \param LParenLoc Location of '('.
1454 /// \param EndLoc Ending location of the clause.
1456 SourceLocation StartLoc, SourceLocation LParenLoc,
1457 SourceLocation EndLoc)
1458 : OMPClause(llvm::omp::OMPC_threadset, StartLoc, EndLoc),
1459 LParenLoc(LParenLoc), Kind(A), KindLoc(ALoc) {}
1460
1461 /// Build an empty clause.
1463 : OMPClause(llvm::omp::OMPC_threadset, SourceLocation(),
1464 SourceLocation()) {}
1465
1466 /// Sets the location of '('.
1467 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1468
1469 /// Returns the location of '('.
1470 SourceLocation getLParenLoc() const { return LParenLoc; }
1471
1472 /// Returns kind of the clause.
1473 OpenMPThreadsetKind getThreadsetKind() const { return Kind; }
1474
1475 /// Returns location of clause kind.
1476 SourceLocation getThreadsetKindLoc() const { return KindLoc; }
1477
1481
1485
1492
1493 static bool classof(const OMPClause *T) {
1494 return T->getClauseKind() == llvm::omp::OMPC_threadset;
1495 }
1496};
1497
1498/// This represents 'proc_bind' clause in the '#pragma omp ...'
1499/// directive.
1500///
1501/// \code
1502/// #pragma omp parallel proc_bind(master)
1503/// \endcode
1504/// In this example directive '#pragma omp parallel' has simple 'proc_bind'
1505/// clause with kind 'master'.
1507 friend class OMPClauseReader;
1508
1509 /// Location of '('.
1510 SourceLocation LParenLoc;
1511
1512 /// A kind of the 'proc_bind' clause.
1513 llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown;
1514
1515 /// Start location of the kind in source code.
1516 SourceLocation KindKwLoc;
1517
1518 /// Set kind of the clause.
1519 ///
1520 /// \param K Kind of clause.
1521 void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; }
1522
1523 /// Set clause kind location.
1524 ///
1525 /// \param KLoc Kind location.
1526 void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1527
1528public:
1529 /// Build 'proc_bind' clause with argument \a A ('master', 'close' or
1530 /// 'spread').
1531 ///
1532 /// \param A Argument of the clause ('master', 'close' or 'spread').
1533 /// \param ALoc Starting location of the argument.
1534 /// \param StartLoc Starting location of the clause.
1535 /// \param LParenLoc Location of '('.
1536 /// \param EndLoc Ending location of the clause.
1537 OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc,
1538 SourceLocation StartLoc, SourceLocation LParenLoc,
1539 SourceLocation EndLoc)
1540 : OMPClause(llvm::omp::OMPC_proc_bind, StartLoc, EndLoc),
1541 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1542
1543 /// Build an empty clause.
1545 : OMPClause(llvm::omp::OMPC_proc_bind, SourceLocation(),
1546 SourceLocation()) {}
1547
1548 /// Sets the location of '('.
1549 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1550
1551 /// Returns the location of '('.
1552 SourceLocation getLParenLoc() const { return LParenLoc; }
1553
1554 /// Returns kind of the clause.
1555 llvm::omp::ProcBindKind getProcBindKind() const { return Kind; }
1556
1557 /// Returns location of clause kind.
1558 SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
1559
1563
1567
1574
1575 static bool classof(const OMPClause *T) {
1576 return T->getClauseKind() == llvm::omp::OMPC_proc_bind;
1577 }
1578};
1579
1580/// This represents 'unified_address' clause in the '#pragma omp requires'
1581/// directive.
1582///
1583/// \code
1584/// #pragma omp requires unified_address
1585/// \endcode
1586/// In this example directive '#pragma omp requires' has 'unified_address'
1587/// clause.
1589 : public OMPNoChildClause<llvm::omp::OMPC_unified_address> {
1590public:
1591 friend class OMPClauseReader;
1592 /// Build 'unified_address' clause.
1593 ///
1594 /// \param StartLoc Starting location of the clause.
1595 /// \param EndLoc Ending location of the clause.
1597 : OMPNoChildClause(StartLoc, EndLoc) {}
1598
1599 /// Build an empty clause.
1601};
1602
1603/// This represents 'unified_shared_memory' clause in the '#pragma omp requires'
1604/// directive.
1605///
1606/// \code
1607/// #pragma omp requires unified_shared_memory
1608/// \endcode
1609/// In this example directive '#pragma omp requires' has 'unified_shared_memory'
1610/// clause.
1612public:
1613 friend class OMPClauseReader;
1614 /// Build 'unified_shared_memory' clause.
1615 ///
1616 /// \param StartLoc Starting location of the clause.
1617 /// \param EndLoc Ending location of the clause.
1619 : OMPClause(llvm::omp::OMPC_unified_shared_memory, StartLoc, EndLoc) {}
1620
1621 /// Build an empty clause.
1623 : OMPClause(llvm::omp::OMPC_unified_shared_memory, SourceLocation(),
1624 SourceLocation()) {}
1625
1629
1633
1640
1641 static bool classof(const OMPClause *T) {
1642 return T->getClauseKind() == llvm::omp::OMPC_unified_shared_memory;
1643 }
1644};
1645
1646/// This represents 'reverse_offload' clause in the '#pragma omp requires'
1647/// directive.
1648///
1649/// \code
1650/// #pragma omp requires reverse_offload
1651/// \endcode
1652/// In this example directive '#pragma omp requires' has 'reverse_offload'
1653/// clause.
1655public:
1656 friend class OMPClauseReader;
1657 /// Build 'reverse_offload' clause.
1658 ///
1659 /// \param StartLoc Starting location of the clause.
1660 /// \param EndLoc Ending location of the clause.
1662 : OMPClause(llvm::omp::OMPC_reverse_offload, StartLoc, EndLoc) {}
1663
1664 /// Build an empty clause.
1666 : OMPClause(llvm::omp::OMPC_reverse_offload, SourceLocation(),
1667 SourceLocation()) {}
1668
1672
1676
1683
1684 static bool classof(const OMPClause *T) {
1685 return T->getClauseKind() == llvm::omp::OMPC_reverse_offload;
1686 }
1687};
1688
1689/// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
1690/// directive.
1691///
1692/// \code
1693/// #pragma omp requires dynamic_allocators
1694/// \endcode
1695/// In this example directive '#pragma omp requires' has 'dynamic_allocators'
1696/// clause.
1698public:
1699 friend class OMPClauseReader;
1700 /// Build 'dynamic_allocators' clause.
1701 ///
1702 /// \param StartLoc Starting location of the clause.
1703 /// \param EndLoc Ending location of the clause.
1705 : OMPClause(llvm::omp::OMPC_dynamic_allocators, StartLoc, EndLoc) {}
1706
1707 /// Build an empty clause.
1709 : OMPClause(llvm::omp::OMPC_dynamic_allocators, SourceLocation(),
1710 SourceLocation()) {}
1711
1715
1719
1726
1727 static bool classof(const OMPClause *T) {
1728 return T->getClauseKind() == llvm::omp::OMPC_dynamic_allocators;
1729 }
1730};
1731
1732/// This represents 'atomic_default_mem_order' clause in the '#pragma omp
1733/// requires' directive.
1734///
1735/// \code
1736/// #pragma omp requires atomic_default_mem_order(seq_cst)
1737/// \endcode
1738/// In this example directive '#pragma omp requires' has simple
1739/// atomic_default_mem_order' clause with kind 'seq_cst'.
1741 friend class OMPClauseReader;
1742
1743 /// Location of '('
1744 SourceLocation LParenLoc;
1745
1746 /// A kind of the 'atomic_default_mem_order' clause.
1749
1750 /// Start location of the kind in source code.
1751 SourceLocation KindKwLoc;
1752
1753 /// Set kind of the clause.
1754 ///
1755 /// \param K Kind of clause.
1756 void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) {
1757 Kind = K;
1758 }
1759
1760 /// Set clause kind location.
1761 ///
1762 /// \param KLoc Kind location.
1763 void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) {
1764 KindKwLoc = KLoc;
1765 }
1766
1767public:
1768 /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst',
1769 /// 'acq_rel' or 'relaxed').
1770 ///
1771 /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed').
1772 /// \param ALoc Starting location of the argument.
1773 /// \param StartLoc Starting location of the clause.
1774 /// \param LParenLoc Location of '('.
1775 /// \param EndLoc Ending location of the clause.
1777 SourceLocation ALoc, SourceLocation StartLoc,
1778 SourceLocation LParenLoc,
1779 SourceLocation EndLoc)
1780 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, StartLoc, EndLoc),
1781 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1782
1783 /// Build an empty clause.
1785 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, SourceLocation(),
1786 SourceLocation()) {}
1787
1788 /// Sets the location of '('.
1789 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1790
1791 /// Returns the locaiton of '('.
1792 SourceLocation getLParenLoc() const { return LParenLoc; }
1793
1794 /// Returns kind of the clause.
1798
1799 /// Returns location of clause kind.
1801
1805
1809
1816
1817 static bool classof(const OMPClause *T) {
1818 return T->getClauseKind() == llvm::omp::OMPC_atomic_default_mem_order;
1819 }
1820};
1821
1822/// This represents 'self_maps' clause in the '#pragma omp requires'
1823/// directive.
1824///
1825/// \code
1826/// #pragma omp requires self_maps
1827/// \endcode
1828/// In this example directive '#pragma omp requires' has 'self_maps'
1829/// clause.
1830class OMPSelfMapsClause final : public OMPClause {
1831public:
1832 friend class OMPClauseReader;
1833 /// Build 'self_maps' clause.
1834 ///
1835 /// \param StartLoc Starting location of the clause.
1836 /// \param EndLoc Ending location of the clause.
1838 : OMPClause(llvm::omp::OMPC_self_maps, StartLoc, EndLoc) {}
1839
1840 /// Build an empty clause.
1842 : OMPClause(llvm::omp::OMPC_self_maps, SourceLocation(),
1843 SourceLocation()) {}
1844
1848
1852
1859
1860 static bool classof(const OMPClause *T) {
1861 return T->getClauseKind() == llvm::omp::OMPC_self_maps;
1862 }
1863};
1864
1865/// This represents 'at' clause in the '#pragma omp error' directive
1866///
1867/// \code
1868/// #pragma omp error at(compilation)
1869/// \endcode
1870/// In this example directive '#pragma omp error' has simple
1871/// 'at' clause with kind 'complilation'.
1872class OMPAtClause final : public OMPClause {
1873 friend class OMPClauseReader;
1874
1875 /// Location of '('
1876 SourceLocation LParenLoc;
1877
1878 /// A kind of the 'at' clause.
1880
1881 /// Start location of the kind in source code.
1882 SourceLocation KindKwLoc;
1883
1884 /// Set kind of the clause.
1885 ///
1886 /// \param K Kind of clause.
1887 void setAtKind(OpenMPAtClauseKind K) { Kind = K; }
1888
1889 /// Set clause kind location.
1890 ///
1891 /// \param KLoc Kind location.
1892 void setAtKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1893
1894 /// Sets the location of '('.
1895 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1896
1897public:
1898 /// Build 'at' clause with argument \a A ('compilation' or 'execution').
1899 ///
1900 /// \param A Argument of the clause ('compilation' or 'execution').
1901 /// \param ALoc Starting location of the argument.
1902 /// \param StartLoc Starting location of the clause.
1903 /// \param LParenLoc Location of '('.
1904 /// \param EndLoc Ending location of the clause.
1906 SourceLocation StartLoc, SourceLocation LParenLoc,
1907 SourceLocation EndLoc)
1908 : OMPClause(llvm::omp::OMPC_at, StartLoc, EndLoc), LParenLoc(LParenLoc),
1909 Kind(A), KindKwLoc(ALoc) {}
1910
1911 /// Build an empty clause.
1913 : OMPClause(llvm::omp::OMPC_at, SourceLocation(), SourceLocation()) {}
1914
1915 /// Returns the locaiton of '('.
1916 SourceLocation getLParenLoc() const { return LParenLoc; }
1917
1918 /// Returns kind of the clause.
1919 OpenMPAtClauseKind getAtKind() const { return Kind; }
1920
1921 /// Returns location of clause kind.
1922 SourceLocation getAtKindKwLoc() const { return KindKwLoc; }
1923
1927
1931
1938
1939 static bool classof(const OMPClause *T) {
1940 return T->getClauseKind() == llvm::omp::OMPC_at;
1941 }
1942};
1943
1944/// This represents the 'severity' clause in the '#pragma omp error' and the
1945/// '#pragma omp parallel' directives.
1946///
1947/// \code
1948/// #pragma omp error severity(fatal)
1949/// \endcode
1950/// In this example directive '#pragma omp error' has simple
1951/// 'severity' clause with kind 'fatal'.
1952class OMPSeverityClause final : public OMPClause {
1953 friend class OMPClauseReader;
1954
1955 /// Location of '('
1956 SourceLocation LParenLoc;
1957
1958 /// A kind of the 'severity' clause.
1960
1961 /// Start location of the kind in source code.
1962 SourceLocation KindKwLoc;
1963
1964 /// Set kind of the clause.
1965 ///
1966 /// \param K Kind of clause.
1967 void setSeverityKind(OpenMPSeverityClauseKind K) { Kind = K; }
1968
1969 /// Set clause kind location.
1970 ///
1971 /// \param KLoc Kind location.
1972 void setSeverityKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1973
1974 /// Sets the location of '('.
1975 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1976
1977public:
1978 /// Build 'severity' clause with argument \a A ('fatal' or 'warning').
1979 ///
1980 /// \param A Argument of the clause ('fatal' or 'warning').
1981 /// \param ALoc Starting location of the argument.
1982 /// \param StartLoc Starting location of the clause.
1983 /// \param LParenLoc Location of '('.
1984 /// \param EndLoc Ending location of the clause.
1986 SourceLocation StartLoc, SourceLocation LParenLoc,
1987 SourceLocation EndLoc)
1988 : OMPClause(llvm::omp::OMPC_severity, StartLoc, EndLoc),
1989 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1990
1991 /// Build an empty clause.
1993 : OMPClause(llvm::omp::OMPC_severity, SourceLocation(),
1994 SourceLocation()) {}
1995
1996 /// Returns the locaiton of '('.
1997 SourceLocation getLParenLoc() const { return LParenLoc; }
1998
1999 /// Returns kind of the clause.
2001
2002 /// Returns location of clause kind.
2003 SourceLocation getSeverityKindKwLoc() const { return KindKwLoc; }
2004
2008
2012
2019
2020 static bool classof(const OMPClause *T) {
2021 return T->getClauseKind() == llvm::omp::OMPC_severity;
2022 }
2023};
2024
2025/// This represents the 'message' clause in the '#pragma omp error' and the
2026/// '#pragma omp parallel' directives.
2027///
2028/// \code
2029/// #pragma omp error message("GNU compiler required.")
2030/// \endcode
2031/// In this example directive '#pragma omp error' has simple
2032/// 'message' clause with user error message of "GNU compiler required.".
2034 : public OMPOneStmtClause<llvm::omp::OMPC_message, OMPClause>,
2035 public OMPClauseWithPreInit {
2036 friend class OMPClauseReader;
2037
2038 /// Set message string of the clause.
2039 void setMessageString(Expr *MS) { setStmt(MS); }
2040
2041public:
2042 /// Build 'message' clause with message string argument
2043 ///
2044 /// \param MS Argument of the clause (message string).
2045 /// \param HelperMS Helper statement for the construct.
2046 /// \param CaptureRegion Innermost OpenMP region where expressions in this
2047 /// clause must be captured.
2048 /// \param StartLoc Starting location of the clause.
2049 /// \param LParenLoc Location of '('.
2050 /// \param EndLoc Ending location of the clause.
2051 OMPMessageClause(Expr *MS, Stmt *HelperMS, OpenMPDirectiveKind CaptureRegion,
2052 SourceLocation StartLoc, SourceLocation LParenLoc,
2053 SourceLocation EndLoc)
2054 : OMPOneStmtClause(MS, StartLoc, LParenLoc, EndLoc),
2055 OMPClauseWithPreInit(this) {
2056 setPreInitStmt(HelperMS, CaptureRegion);
2057 }
2058
2059 /// Build an empty clause.
2061
2062 /// Returns message string of the clause.
2064
2065 /// Try to evaluate the message string at compile time.
2066 std::optional<std::string> tryEvaluateString(ASTContext &Ctx) const {
2067 if (Expr *MessageExpr = getMessageString())
2068 return MessageExpr->tryEvaluateString(Ctx);
2069 return std::nullopt;
2070 }
2071};
2072
2073/// This represents 'schedule' clause in the '#pragma omp ...' directive.
2074///
2075/// \code
2076/// #pragma omp for schedule(static, 3)
2077/// \endcode
2078/// In this example directive '#pragma omp for' has 'schedule' clause with
2079/// arguments 'static' and '3'.
2081 friend class OMPClauseReader;
2082
2083 /// Location of '('.
2084 SourceLocation LParenLoc;
2085
2086 /// A kind of the 'schedule' clause.
2088
2089 /// Modifiers for 'schedule' clause.
2090 enum {FIRST, SECOND, NUM_MODIFIERS};
2091 OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
2092
2093 /// Locations of modifiers.
2094 SourceLocation ModifiersLoc[NUM_MODIFIERS];
2095
2096 /// Start location of the schedule ind in source code.
2097 SourceLocation KindLoc;
2098
2099 /// Location of ',' (if any).
2100 SourceLocation CommaLoc;
2101
2102 /// Chunk size.
2103 Expr *ChunkSize = nullptr;
2104
2105 /// Set schedule kind.
2106 ///
2107 /// \param K Schedule kind.
2108 void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
2109
2110 /// Set the first schedule modifier.
2111 ///
2112 /// \param M Schedule modifier.
2113 void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
2114 Modifiers[FIRST] = M;
2115 }
2116
2117 /// Set the second schedule modifier.
2118 ///
2119 /// \param M Schedule modifier.
2120 void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
2121 Modifiers[SECOND] = M;
2122 }
2123
2124 /// Set location of the first schedule modifier.
2125 void setFirstScheduleModifierLoc(SourceLocation Loc) {
2126 ModifiersLoc[FIRST] = Loc;
2127 }
2128
2129 /// Set location of the second schedule modifier.
2130 void setSecondScheduleModifierLoc(SourceLocation Loc) {
2131 ModifiersLoc[SECOND] = Loc;
2132 }
2133
2134 /// Set schedule modifier location.
2135 ///
2136 /// \param M Schedule modifier location.
2137 void setScheduleModifer(OpenMPScheduleClauseModifier M) {
2138 if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
2139 Modifiers[FIRST] = M;
2140 else {
2141 assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
2142 Modifiers[SECOND] = M;
2143 }
2144 }
2145
2146 /// Sets the location of '('.
2147 ///
2148 /// \param Loc Location of '('.
2149 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2150
2151 /// Set schedule kind start location.
2152 ///
2153 /// \param KLoc Schedule kind location.
2154 void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
2155
2156 /// Set location of ','.
2157 ///
2158 /// \param Loc Location of ','.
2159 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
2160
2161 /// Set chunk size.
2162 ///
2163 /// \param E Chunk size.
2164 void setChunkSize(Expr *E) { ChunkSize = E; }
2165
2166public:
2167 /// Build 'schedule' clause with schedule kind \a Kind and chunk size
2168 /// expression \a ChunkSize.
2169 ///
2170 /// \param StartLoc Starting location of the clause.
2171 /// \param LParenLoc Location of '('.
2172 /// \param KLoc Starting location of the argument.
2173 /// \param CommaLoc Location of ','.
2174 /// \param EndLoc Ending location of the clause.
2175 /// \param Kind Schedule kind.
2176 /// \param ChunkSize Chunk size.
2177 /// \param HelperChunkSize Helper chunk size for combined directives.
2178 /// \param M1 The first modifier applied to 'schedule' clause.
2179 /// \param M1Loc Location of the first modifier
2180 /// \param M2 The second modifier applied to 'schedule' clause.
2181 /// \param M2Loc Location of the second modifier
2183 SourceLocation KLoc, SourceLocation CommaLoc,
2185 Expr *ChunkSize, Stmt *HelperChunkSize,
2188 : OMPClause(llvm::omp::OMPC_schedule, StartLoc, EndLoc),
2189 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
2190 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
2191 setPreInitStmt(HelperChunkSize);
2192 Modifiers[FIRST] = M1;
2193 Modifiers[SECOND] = M2;
2194 ModifiersLoc[FIRST] = M1Loc;
2195 ModifiersLoc[SECOND] = M2Loc;
2196 }
2197
2198 /// Build an empty clause.
2200 : OMPClause(llvm::omp::OMPC_schedule, SourceLocation(), SourceLocation()),
2201 OMPClauseWithPreInit(this) {
2202 Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
2203 Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
2204 }
2205
2206 /// Get kind of the clause.
2208
2209 /// Get the first modifier of the clause.
2211 return Modifiers[FIRST];
2212 }
2213
2214 /// Get the second modifier of the clause.
2216 return Modifiers[SECOND];
2217 }
2218
2219 /// Get location of '('.
2220 SourceLocation getLParenLoc() { return LParenLoc; }
2221
2222 /// Get kind location.
2224
2225 /// Get the first modifier location.
2227 return ModifiersLoc[FIRST];
2228 }
2229
2230 /// Get the second modifier location.
2232 return ModifiersLoc[SECOND];
2233 }
2234
2235 /// Get location of ','.
2236 SourceLocation getCommaLoc() { return CommaLoc; }
2237
2238 /// Get chunk size.
2239 Expr *getChunkSize() { return ChunkSize; }
2240
2241 /// Get chunk size.
2242 const Expr *getChunkSize() const { return ChunkSize; }
2243
2245 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
2246 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
2247 }
2248
2250 return const_cast<OMPScheduleClause *>(this)->children();
2251 }
2252
2259
2260 static bool classof(const OMPClause *T) {
2261 return T->getClauseKind() == llvm::omp::OMPC_schedule;
2262 }
2263};
2264
2265/// This represents 'ordered' clause in the '#pragma omp ...' directive.
2266///
2267/// \code
2268/// #pragma omp for ordered (2)
2269/// \endcode
2270/// In this example directive '#pragma omp for' has 'ordered' clause with
2271/// parameter 2.
2272class OMPOrderedClause final
2273 : public OMPClause,
2274 private llvm::TrailingObjects<OMPOrderedClause, Expr *> {
2275 friend class OMPClauseReader;
2276 friend TrailingObjects;
2277
2278 /// Location of '('.
2279 SourceLocation LParenLoc;
2280
2281 /// Number of for-loops.
2282 Stmt *NumForLoops = nullptr;
2283
2284 /// Real number of loops.
2285 unsigned NumberOfLoops = 0;
2286
2287 /// Build 'ordered' clause.
2288 ///
2289 /// \param Num Expression, possibly associated with this clause.
2290 /// \param NumLoops Number of loops, associated with this clause.
2291 /// \param StartLoc Starting location of the clause.
2292 /// \param LParenLoc Location of '('.
2293 /// \param EndLoc Ending location of the clause.
2294 OMPOrderedClause(Expr *Num, unsigned NumLoops, SourceLocation StartLoc,
2295 SourceLocation LParenLoc, SourceLocation EndLoc)
2296 : OMPClause(llvm::omp::OMPC_ordered, StartLoc, EndLoc),
2297 LParenLoc(LParenLoc), NumForLoops(Num), NumberOfLoops(NumLoops) {}
2298
2299 /// Build an empty clause.
2300 explicit OMPOrderedClause(unsigned NumLoops)
2301 : OMPClause(llvm::omp::OMPC_ordered, SourceLocation(), SourceLocation()),
2302 NumberOfLoops(NumLoops) {}
2303
2304 /// Set the number of associated for-loops.
2305 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
2306
2307public:
2308 /// Build 'ordered' clause.
2309 ///
2310 /// \param Num Expression, possibly associated with this clause.
2311 /// \param NumLoops Number of loops, associated with this clause.
2312 /// \param StartLoc Starting location of the clause.
2313 /// \param LParenLoc Location of '('.
2314 /// \param EndLoc Ending location of the clause.
2315 static OMPOrderedClause *Create(const ASTContext &C, Expr *Num,
2316 unsigned NumLoops, SourceLocation StartLoc,
2317 SourceLocation LParenLoc,
2318 SourceLocation EndLoc);
2319
2320 /// Build an empty clause.
2321 static OMPOrderedClause* CreateEmpty(const ASTContext &C, unsigned NumLoops);
2322
2323 /// Sets the location of '('.
2324 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2325
2326 /// Returns the location of '('.
2327 SourceLocation getLParenLoc() const { return LParenLoc; }
2328
2329 /// Return the number of associated for-loops.
2330 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
2331
2332 /// Set number of iterations for the specified loop.
2333 void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations);
2334 /// Get number of iterations for all the loops.
2336
2337 /// Set loop counter for the specified loop.
2338 void setLoopCounter(unsigned NumLoop, Expr *Counter);
2339 /// Get loops counter for the specified loop.
2340 Expr *getLoopCounter(unsigned NumLoop);
2341 const Expr *getLoopCounter(unsigned NumLoop) const;
2342
2343 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
2344
2346 return const_child_range(&NumForLoops, &NumForLoops + 1);
2347 }
2348
2355
2356 static bool classof(const OMPClause *T) {
2357 return T->getClauseKind() == llvm::omp::OMPC_ordered;
2358 }
2359};
2360
2361/// This represents 'nowait' clause in the '#pragma omp ...' directive.
2362///
2363/// \code
2364/// #pragma omp for nowait (cond)
2365/// \endcode
2366/// In this example directive '#pragma omp for' has simple 'nowait' clause with
2367/// condition 'cond'.
2368class OMPNowaitClause final : public OMPClause {
2369 friend class OMPClauseReader;
2370
2371 /// Location of '('.
2372 SourceLocation LParenLoc;
2373
2374 /// Condition of the 'nowait' clause.
2375 Stmt *Condition = nullptr;
2376
2377 /// Set condition.
2378 void setCondition(Expr *Cond) { Condition = Cond; }
2379
2380public:
2381 /// Build 'nowait' clause with condition \a Cond.
2382 ///
2383 /// \param Cond Condition of the clause.
2384 /// \param StartLoc Starting location of the clause.
2385 /// \param LParenLoc Location of '('.
2386 /// \param EndLoc Ending location of the clause.
2388 SourceLocation EndLoc)
2389 : OMPClause(llvm::omp::OMPC_nowait, StartLoc, EndLoc),
2390 LParenLoc(LParenLoc), Condition(Cond) {}
2391
2392 /// Build an empty clause.
2394 : OMPClause(llvm::omp::OMPC_nowait, SourceLocation(), SourceLocation()) {}
2395
2396 /// Sets the location of '('.
2397 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2398
2399 /// Returns the location of '('.
2400 SourceLocation getLParenLoc() const { return LParenLoc; }
2401
2402 /// Returns condition.
2403 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
2404
2406 if (Condition)
2407 return child_range(&Condition, &Condition + 1);
2409 }
2410
2412 if (Condition)
2413 return const_child_range(&Condition, &Condition + 1);
2415 }
2416
2419 return const_cast<OMPNowaitClause *>(this)->used_children();
2420 }
2421
2422 static bool classof(const OMPClause *T) {
2423 return T->getClauseKind() == llvm::omp::OMPC_nowait;
2424 }
2425};
2426
2427/// This represents 'untied' clause in the '#pragma omp ...' directive.
2428///
2429/// \code
2430/// #pragma omp task untied
2431/// \endcode
2432/// In this example directive '#pragma omp task' has 'untied' clause.
2434public:
2435 /// Build 'untied' clause.
2436 ///
2437 /// \param StartLoc Starting location of the clause.
2438 /// \param EndLoc Ending location of the clause.
2440 : OMPClause(llvm::omp::OMPC_untied, StartLoc, EndLoc) {}
2441
2442 /// Build an empty clause.
2444 : OMPClause(llvm::omp::OMPC_untied, SourceLocation(), SourceLocation()) {}
2445
2449
2453
2460
2461 static bool classof(const OMPClause *T) {
2462 return T->getClauseKind() == llvm::omp::OMPC_untied;
2463 }
2464};
2465
2466/// This represents 'mergeable' clause in the '#pragma omp ...'
2467/// directive.
2468///
2469/// \code
2470/// #pragma omp task mergeable
2471/// \endcode
2472/// In this example directive '#pragma omp task' has 'mergeable' clause.
2474public:
2475 /// Build 'mergeable' clause.
2476 ///
2477 /// \param StartLoc Starting location of the clause.
2478 /// \param EndLoc Ending location of the clause.
2480 : OMPClause(llvm::omp::OMPC_mergeable, StartLoc, EndLoc) {}
2481
2482 /// Build an empty clause.
2484 : OMPClause(llvm::omp::OMPC_mergeable, SourceLocation(),
2485 SourceLocation()) {}
2486
2490
2494
2501
2502 static bool classof(const OMPClause *T) {
2503 return T->getClauseKind() == llvm::omp::OMPC_mergeable;
2504 }
2505};
2506
2507/// This represents the 'absent' clause in the '#pragma omp assume'
2508/// directive.
2509///
2510/// \code
2511/// #pragma omp assume absent(<directive-name list>)
2512/// \endcode
2513/// In this example directive '#pragma omp assume' has an 'absent' clause.
2514class OMPAbsentClause final
2515 : public OMPDirectiveListClause<OMPAbsentClause>,
2516 private llvm::TrailingObjects<OMPAbsentClause, OpenMPDirectiveKind> {
2517 friend OMPDirectiveListClause;
2518 friend TrailingObjects;
2519
2520 /// Build 'absent' clause.
2521 ///
2522 /// \param StartLoc Starting location of the clause.
2523 /// \param LParenLoc Location of '('.
2524 /// \param EndLoc Ending location of the clause.
2525 /// \param NumKinds Number of directive kinds listed in the clause.
2526 OMPAbsentClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2527 SourceLocation EndLoc, unsigned NumKinds)
2528 : OMPDirectiveListClause<OMPAbsentClause>(
2529 llvm::omp::OMPC_absent, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2530
2531 /// Build an empty clause.
2532 OMPAbsentClause(unsigned NumKinds)
2533 : OMPDirectiveListClause<OMPAbsentClause>(
2534 llvm::omp::OMPC_absent, SourceLocation(), SourceLocation(),
2536
2537public:
2538 static OMPAbsentClause *Create(const ASTContext &C,
2541 SourceLocation RLoc);
2542
2543 static OMPAbsentClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2544
2545 static bool classof(const OMPClause *C) {
2546 return C->getClauseKind() == llvm::omp::OMPC_absent;
2547 }
2548};
2549
2550/// This represents the 'contains' clause in the '#pragma omp assume'
2551/// directive.
2552///
2553/// \code
2554/// #pragma omp assume contains(<directive-name list>)
2555/// \endcode
2556/// In this example directive '#pragma omp assume' has a 'contains' clause.
2557class OMPContainsClause final
2558 : public OMPDirectiveListClause<OMPContainsClause>,
2559 private llvm::TrailingObjects<OMPContainsClause, OpenMPDirectiveKind> {
2560 friend OMPDirectiveListClause;
2561 friend TrailingObjects;
2562
2563 /// Build 'contains' clause.
2564 ///
2565 /// \param StartLoc Starting location of the clause.
2566 /// \param LParenLoc Location of '('.
2567 /// \param EndLoc Ending location of the clause.
2568 /// \param NumKinds Number of directive kinds listed in the clause.
2569 OMPContainsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2570 SourceLocation EndLoc, unsigned NumKinds)
2571 : OMPDirectiveListClause<OMPContainsClause>(
2572 llvm::omp::OMPC_contains, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2573
2574 /// Build an empty clause.
2575 OMPContainsClause(unsigned NumKinds)
2576 : OMPDirectiveListClause<OMPContainsClause>(
2577 llvm::omp::OMPC_contains, SourceLocation(), SourceLocation(),
2579
2580public:
2581 static OMPContainsClause *Create(const ASTContext &C,
2584 SourceLocation RLoc);
2585
2586 static OMPContainsClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2587
2588 static bool classof(const OMPClause *C) {
2589 return C->getClauseKind() == llvm::omp::OMPC_contains;
2590 }
2591};
2592
2593/// This represents the 'holds' clause in the '#pragma omp assume'
2594/// directive.
2595///
2596/// \code
2597/// #pragma omp assume holds(<expr>)
2598/// \endcode
2599/// In this example directive '#pragma omp assume' has a 'holds' clause.
2601 : public OMPOneStmtClause<llvm::omp::OMPC_holds, OMPClause> {
2602 friend class OMPClauseReader;
2603
2604public:
2605 /// Build 'holds' clause.
2606 ///
2607 /// \param StartLoc Starting location of the clause.
2608 /// \param EndLoc Ending location of the clause.
2610 SourceLocation EndLoc)
2611 : OMPOneStmtClause(E, StartLoc, LParenLoc, EndLoc) {}
2612
2613 /// Build an empty clause.
2615
2616 Expr *getExpr() const { return getStmtAs<Expr>(); }
2617 void setExpr(Expr *E) { setStmt(E); }
2618};
2619
2620/// This represents the 'no_openmp' clause in the '#pragma omp assume'
2621/// directive.
2622///
2623/// \code
2624/// #pragma omp assume no_openmp
2625/// \endcode
2626/// In this example directive '#pragma omp assume' has a 'no_openmp' clause.
2628 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp> {
2629public:
2630 /// Build 'no_openmp' clause.
2631 ///
2632 /// \param StartLoc Starting location of the clause.
2633 /// \param EndLoc Ending location of the clause.
2635 : OMPNoChildClause(StartLoc, EndLoc) {}
2636
2637 /// Build an empty clause.
2639};
2640
2641/// This represents the 'no_openmp_routines' clause in the '#pragma omp assume'
2642/// directive.
2643///
2644/// \code
2645/// #pragma omp assume no_openmp_routines
2646/// \endcode
2647/// In this example directive '#pragma omp assume' has a 'no_openmp_routines'
2648/// clause.
2650 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp_routines> {
2651public:
2652 /// Build 'no_openmp_routines' clause.
2653 ///
2654 /// \param StartLoc Starting location of the clause.
2655 /// \param EndLoc Ending location of the clause.
2657 : OMPNoChildClause(StartLoc, EndLoc) {}
2658
2659 /// Build an empty clause.
2661};
2662
2663/// This represents the 'no_openmp_constructs' clause in the
2664//// '#pragma omp assume' directive.
2665///
2666/// \code
2667/// #pragma omp assume no_openmp_constructs
2668/// \endcode
2669/// In this example directive '#pragma omp assume' has a 'no_openmp_constructs'
2670/// clause.
2672 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp_constructs> {
2673public:
2674 /// Build 'no_openmp_constructs' clause.
2675 ///
2676 /// \param StartLoc Starting location of the clause.
2677 /// \param EndLoc Ending location of the clause.
2679 : OMPNoChildClause(StartLoc, EndLoc) {}
2680
2681 /// Build an empty clause.
2683};
2684
2685/// This represents the 'no_parallelism' clause in the '#pragma omp assume'
2686/// directive.
2687///
2688/// \code
2689/// #pragma omp assume no_parallelism
2690/// \endcode
2691/// In this example directive '#pragma omp assume' has a 'no_parallelism'
2692/// clause.
2694 : public OMPNoChildClause<llvm::omp::OMPC_no_parallelism> {
2695public:
2696 /// Build 'no_parallelism' clause.
2697 ///
2698 /// \param StartLoc Starting location of the clause.
2699 /// \param EndLoc Ending location of the clause.
2701 : OMPNoChildClause(StartLoc, EndLoc) {}
2702
2703 /// Build an empty clause.
2705};
2706
2707/// This represents 'read' clause in the '#pragma omp atomic' directive.
2708///
2709/// \code
2710/// #pragma omp atomic read
2711/// \endcode
2712/// In this example directive '#pragma omp atomic' has 'read' clause.
2713class OMPReadClause : public OMPClause {
2714public:
2715 /// Build 'read' clause.
2716 ///
2717 /// \param StartLoc Starting location of the clause.
2718 /// \param EndLoc Ending location of the clause.
2720 : OMPClause(llvm::omp::OMPC_read, StartLoc, EndLoc) {}
2721
2722 /// Build an empty clause.
2724 : OMPClause(llvm::omp::OMPC_read, SourceLocation(), SourceLocation()) {}
2725
2729
2733
2740
2741 static bool classof(const OMPClause *T) {
2742 return T->getClauseKind() == llvm::omp::OMPC_read;
2743 }
2744};
2745
2746/// This represents 'write' clause in the '#pragma omp atomic' directive.
2747///
2748/// \code
2749/// #pragma omp atomic write
2750/// \endcode
2751/// In this example directive '#pragma omp atomic' has 'write' clause.
2753public:
2754 /// Build 'write' clause.
2755 ///
2756 /// \param StartLoc Starting location of the clause.
2757 /// \param EndLoc Ending location of the clause.
2759 : OMPClause(llvm::omp::OMPC_write, StartLoc, EndLoc) {}
2760
2761 /// Build an empty clause.
2763 : OMPClause(llvm::omp::OMPC_write, SourceLocation(), SourceLocation()) {}
2764
2768
2772
2779
2780 static bool classof(const OMPClause *T) {
2781 return T->getClauseKind() == llvm::omp::OMPC_write;
2782 }
2783};
2784
2785/// This represents 'update' clause in the '#pragma omp atomic'
2786/// directive.
2787///
2788/// \code
2789/// #pragma omp atomic update
2790/// \endcode
2791/// In this example directive '#pragma omp atomic' has 'update' clause.
2792/// Also, this class represents 'update' clause in '#pragma omp depobj'
2793/// directive.
2794///
2795/// \code
2796/// #pragma omp depobj(a) update(in)
2797/// \endcode
2798/// In this example directive '#pragma omp depobj' has 'update' clause with 'in'
2799/// dependence kind.
2800class OMPUpdateClause final
2801 : public OMPClause,
2802 private llvm::TrailingObjects<OMPUpdateClause, SourceLocation,
2803 OpenMPDependClauseKind> {
2804 friend class OMPClauseReader;
2805 friend TrailingObjects;
2806
2807 /// true if extended version of the clause for 'depobj' directive.
2808 bool IsExtended = false;
2809
2810 /// Define the sizes of each trailing object array except the last one. This
2811 /// is required for TrailingObjects to work properly.
2812 size_t numTrailingObjects(OverloadToken<SourceLocation>) const {
2813 // 2 locations: for '(' and argument location.
2814 return IsExtended ? 2 : 0;
2815 }
2816
2817 /// Sets the location of '(' in clause for 'depobj' directive.
2818 void setLParenLoc(SourceLocation Loc) {
2819 assert(IsExtended && "Expected extended clause.");
2820 *getTrailingObjects<SourceLocation>() = Loc;
2821 }
2822
2823 /// Sets the location of '(' in clause for 'depobj' directive.
2824 void setArgumentLoc(SourceLocation Loc) {
2825 assert(IsExtended && "Expected extended clause.");
2826 *std::next(getTrailingObjects<SourceLocation>(), 1) = Loc;
2827 }
2828
2829 /// Sets the dependence kind for the clause for 'depobj' directive.
2830 void setDependencyKind(OpenMPDependClauseKind DK) {
2831 assert(IsExtended && "Expected extended clause.");
2832 *getTrailingObjects<OpenMPDependClauseKind>() = DK;
2833 }
2834
2835 /// Build 'update' clause.
2836 ///
2837 /// \param StartLoc Starting location of the clause.
2838 /// \param EndLoc Ending location of the clause.
2839 OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc,
2840 bool IsExtended)
2841 : OMPClause(llvm::omp::OMPC_update, StartLoc, EndLoc),
2842 IsExtended(IsExtended) {}
2843
2844 /// Build an empty clause.
2845 OMPUpdateClause(bool IsExtended)
2846 : OMPClause(llvm::omp::OMPC_update, SourceLocation(), SourceLocation()),
2847 IsExtended(IsExtended) {}
2848
2849public:
2850 /// Creates clause for 'atomic' directive.
2851 ///
2852 /// \param C AST context.
2853 /// \param StartLoc Starting location of the clause.
2854 /// \param EndLoc Ending location of the clause.
2855 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2856 SourceLocation EndLoc);
2857
2858 /// Creates clause for 'depobj' directive.
2859 ///
2860 /// \param C AST context.
2861 /// \param StartLoc Starting location of the clause.
2862 /// \param LParenLoc Location of '('.
2863 /// \param ArgumentLoc Location of the argument.
2864 /// \param DK Dependence kind.
2865 /// \param EndLoc Ending location of the clause.
2866 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2867 SourceLocation LParenLoc,
2868 SourceLocation ArgumentLoc,
2870 SourceLocation EndLoc);
2871
2872 /// Creates an empty clause with the place for \a N variables.
2873 ///
2874 /// \param C AST context.
2875 /// \param IsExtended true if extended clause for 'depobj' directive must be
2876 /// created.
2877 static OMPUpdateClause *CreateEmpty(const ASTContext &C, bool IsExtended);
2878
2879 /// Checks if the clause is the extended clauses for 'depobj' directive.
2880 bool isExtended() const { return IsExtended; }
2881
2885
2889
2896
2897 /// Gets the location of '(' in clause for 'depobj' directive.
2899 assert(IsExtended && "Expected extended clause.");
2900 return *getTrailingObjects<SourceLocation>();
2901 }
2902
2903 /// Gets the location of argument in clause for 'depobj' directive.
2905 assert(IsExtended && "Expected extended clause.");
2906 return *std::next(getTrailingObjects<SourceLocation>(), 1);
2907 }
2908
2909 /// Gets the dependence kind in clause for 'depobj' directive.
2911 assert(IsExtended && "Expected extended clause.");
2912 return *getTrailingObjects<OpenMPDependClauseKind>();
2913 }
2914
2915 static bool classof(const OMPClause *T) {
2916 return T->getClauseKind() == llvm::omp::OMPC_update;
2917 }
2918};
2919
2920/// This represents 'capture' clause in the '#pragma omp atomic'
2921/// directive.
2922///
2923/// \code
2924/// #pragma omp atomic capture
2925/// \endcode
2926/// In this example directive '#pragma omp atomic' has 'capture' clause.
2928public:
2929 /// Build 'capture' clause.
2930 ///
2931 /// \param StartLoc Starting location of the clause.
2932 /// \param EndLoc Ending location of the clause.
2934 : OMPClause(llvm::omp::OMPC_capture, StartLoc, EndLoc) {}
2935
2936 /// Build an empty clause.
2938 : OMPClause(llvm::omp::OMPC_capture, SourceLocation(), SourceLocation()) {
2939 }
2940
2944
2948
2955
2956 static bool classof(const OMPClause *T) {
2957 return T->getClauseKind() == llvm::omp::OMPC_capture;
2958 }
2959};
2960
2961/// This represents 'compare' clause in the '#pragma omp atomic'
2962/// directive.
2963///
2964/// \code
2965/// #pragma omp atomic compare
2966/// \endcode
2967/// In this example directive '#pragma omp atomic' has 'compare' clause.
2968class OMPCompareClause final : public OMPClause {
2969public:
2970 /// Build 'compare' clause.
2971 ///
2972 /// \param StartLoc Starting location of the clause.
2973 /// \param EndLoc Ending location of the clause.
2975 : OMPClause(llvm::omp::OMPC_compare, StartLoc, EndLoc) {}
2976
2977 /// Build an empty clause.
2979 : OMPClause(llvm::omp::OMPC_compare, SourceLocation(), SourceLocation()) {
2980 }
2981
2985
2989
2996
2997 static bool classof(const OMPClause *T) {
2998 return T->getClauseKind() == llvm::omp::OMPC_compare;
2999 }
3000};
3001
3002/// This represents 'seq_cst' clause in the '#pragma omp atomic|flush'
3003/// directives.
3004///
3005/// \code
3006/// #pragma omp atomic seq_cst
3007/// \endcode
3008/// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
3010public:
3011 /// Build 'seq_cst' clause.
3012 ///
3013 /// \param StartLoc Starting location of the clause.
3014 /// \param EndLoc Ending location of the clause.
3016 : OMPClause(llvm::omp::OMPC_seq_cst, StartLoc, EndLoc) {}
3017
3018 /// Build an empty clause.
3020 : OMPClause(llvm::omp::OMPC_seq_cst, SourceLocation(), SourceLocation()) {
3021 }
3022
3026
3030
3037
3038 static bool classof(const OMPClause *T) {
3039 return T->getClauseKind() == llvm::omp::OMPC_seq_cst;
3040 }
3041};
3042
3043/// This represents 'acq_rel' clause in the '#pragma omp atomic|flush'
3044/// directives.
3045///
3046/// \code
3047/// #pragma omp flush acq_rel
3048/// \endcode
3049/// In this example directive '#pragma omp flush' has 'acq_rel' clause.
3050class OMPAcqRelClause final : public OMPClause {
3051public:
3052 /// Build 'ack_rel' clause.
3053 ///
3054 /// \param StartLoc Starting location of the clause.
3055 /// \param EndLoc Ending location of the clause.
3057 : OMPClause(llvm::omp::OMPC_acq_rel, StartLoc, EndLoc) {}
3058
3059 /// Build an empty clause.
3061 : OMPClause(llvm::omp::OMPC_acq_rel, SourceLocation(), SourceLocation()) {
3062 }
3063
3067
3071
3078
3079 static bool classof(const OMPClause *T) {
3080 return T->getClauseKind() == llvm::omp::OMPC_acq_rel;
3081 }
3082};
3083
3084/// This represents 'acquire' clause in the '#pragma omp atomic|flush'
3085/// directives.
3086///
3087/// \code
3088/// #pragma omp flush acquire
3089/// \endcode
3090/// In this example directive '#pragma omp flush' has 'acquire' clause.
3091class OMPAcquireClause final : public OMPClause {
3092public:
3093 /// Build 'acquire' clause.
3094 ///
3095 /// \param StartLoc Starting location of the clause.
3096 /// \param EndLoc Ending location of the clause.
3098 : OMPClause(llvm::omp::OMPC_acquire, StartLoc, EndLoc) {}
3099
3100 /// Build an empty clause.
3102 : OMPClause(llvm::omp::OMPC_acquire, SourceLocation(), SourceLocation()) {
3103 }
3104
3108
3112
3119
3120 static bool classof(const OMPClause *T) {
3121 return T->getClauseKind() == llvm::omp::OMPC_acquire;
3122 }
3123};
3124
3125/// This represents 'release' clause in the '#pragma omp atomic|flush'
3126/// directives.
3127///
3128/// \code
3129/// #pragma omp flush release
3130/// \endcode
3131/// In this example directive '#pragma omp flush' has 'release' clause.
3132class OMPReleaseClause final : public OMPClause {
3133public:
3134 /// Build 'release' clause.
3135 ///
3136 /// \param StartLoc Starting location of the clause.
3137 /// \param EndLoc Ending location of the clause.
3139 : OMPClause(llvm::omp::OMPC_release, StartLoc, EndLoc) {}
3140
3141 /// Build an empty clause.
3143 : OMPClause(llvm::omp::OMPC_release, SourceLocation(), SourceLocation()) {
3144 }
3145
3149
3153
3160
3161 static bool classof(const OMPClause *T) {
3162 return T->getClauseKind() == llvm::omp::OMPC_release;
3163 }
3164};
3165
3166/// This represents 'relaxed' clause in the '#pragma omp atomic'
3167/// directives.
3168///
3169/// \code
3170/// #pragma omp atomic relaxed
3171/// \endcode
3172/// In this example directive '#pragma omp atomic' has 'relaxed' clause.
3173class OMPRelaxedClause final : public OMPClause {
3174public:
3175 /// Build 'relaxed' clause.
3176 ///
3177 /// \param StartLoc Starting location of the clause.
3178 /// \param EndLoc Ending location of the clause.
3180 : OMPClause(llvm::omp::OMPC_relaxed, StartLoc, EndLoc) {}
3181
3182 /// Build an empty clause.
3184 : OMPClause(llvm::omp::OMPC_relaxed, SourceLocation(), SourceLocation()) {
3185 }
3186
3190
3194
3201
3202 static bool classof(const OMPClause *T) {
3203 return T->getClauseKind() == llvm::omp::OMPC_relaxed;
3204 }
3205};
3206
3207/// This represents 'weak' clause in the '#pragma omp atomic'
3208/// directives.
3209///
3210/// \code
3211/// #pragma omp atomic compare weak
3212/// \endcode
3213/// In this example directive '#pragma omp atomic' has 'weak' clause.
3214class OMPWeakClause final : public OMPClause {
3215public:
3216 /// Build 'weak' clause.
3217 ///
3218 /// \param StartLoc Starting location of the clause.
3219 /// \param EndLoc Ending location of the clause.
3221 : OMPClause(llvm::omp::OMPC_weak, StartLoc, EndLoc) {}
3222
3223 /// Build an empty clause.
3225 : OMPClause(llvm::omp::OMPC_weak, SourceLocation(), SourceLocation()) {}
3226
3230
3234
3241
3242 static bool classof(const OMPClause *T) {
3243 return T->getClauseKind() == llvm::omp::OMPC_weak;
3244 }
3245};
3246
3247/// This represents 'fail' clause in the '#pragma omp atomic'
3248/// directive.
3249///
3250/// \code
3251/// #pragma omp atomic compare fail
3252/// \endcode
3253/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
3254class OMPFailClause final : public OMPClause {
3255
3256 // FailParameter is a memory-order-clause. Storing the ClauseKind is
3257 // sufficient for our purpose.
3258 OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
3259 SourceLocation FailParameterLoc;
3260 SourceLocation LParenLoc;
3261
3262 friend class OMPClauseReader;
3263
3264 /// Sets the location of '(' in fail clause.
3265 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3266
3267 /// Sets the location of memoryOrder clause argument in fail clause.
3268 void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
3269
3270 /// Sets the mem_order clause for 'atomic compare fail' directive.
3271 void setFailParameter(OpenMPClauseKind FailParameter) {
3272 this->FailParameter = FailParameter;
3273 assert(checkFailClauseParameter(FailParameter) &&
3274 "Invalid fail clause parameter");
3275 }
3276
3277public:
3278 /// Build 'fail' clause.
3279 ///
3280 /// \param StartLoc Starting location of the clause.
3281 /// \param EndLoc Ending location of the clause.
3283 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
3284
3285 OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation FailParameterLoc,
3286 SourceLocation StartLoc, SourceLocation LParenLoc,
3287 SourceLocation EndLoc)
3288 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
3289 FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
3290
3291 setFailParameter(FailParameter);
3292 }
3293
3294 /// Build an empty clause.
3296 : OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
3297
3301
3305
3312
3313 static bool classof(const OMPClause *T) {
3314 return T->getClauseKind() == llvm::omp::OMPC_fail;
3315 }
3316
3317 /// Gets the location of '(' (for the parameter) in fail clause.
3319 return LParenLoc;
3320 }
3321
3322 /// Gets the location of Fail Parameter (type memory-order-clause) in
3323 /// fail clause.
3324 SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
3325
3326 /// Gets the parameter (type memory-order-clause) in Fail clause.
3327 OpenMPClauseKind getFailParameter() const { return FailParameter; }
3328};
3329
3330/// This represents clause 'private' in the '#pragma omp ...' directives.
3331///
3332/// \code
3333/// #pragma omp parallel private(a,b)
3334/// \endcode
3335/// In this example directive '#pragma omp parallel' has clause 'private'
3336/// with the variables 'a' and 'b'.
3337class OMPPrivateClause final
3338 : public OMPVarListClause<OMPPrivateClause>,
3339 private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
3340 friend class OMPClauseReader;
3341 friend OMPVarListClause;
3342 friend TrailingObjects;
3343
3344 /// Build clause with number of variables \a N.
3345 ///
3346 /// \param StartLoc Starting location of the clause.
3347 /// \param LParenLoc Location of '('.
3348 /// \param EndLoc Ending location of the clause.
3349 /// \param N Number of the variables in the clause.
3350 OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3351 SourceLocation EndLoc, unsigned N)
3352 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private, StartLoc,
3353 LParenLoc, EndLoc, N) {}
3354
3355 /// Build an empty clause.
3356 ///
3357 /// \param N Number of variables.
3358 explicit OMPPrivateClause(unsigned N)
3359 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private,
3361 SourceLocation(), N) {}
3362
3363 /// Sets the list of references to private copies with initializers for
3364 /// new private variables.
3365 /// \param VL List of references.
3366 void setPrivateCopies(ArrayRef<Expr *> VL);
3367
3368 /// Gets the list of references to private copies with initializers for
3369 /// new private variables.
3370 MutableArrayRef<Expr *> getPrivateCopies() {
3371 return {varlist_end(), varlist_size()};
3372 }
3373 ArrayRef<const Expr *> getPrivateCopies() const {
3374 return {varlist_end(), varlist_size()};
3375 }
3376
3377public:
3378 /// Creates clause with a list of variables \a VL.
3379 ///
3380 /// \param C AST context.
3381 /// \param StartLoc Starting location of the clause.
3382 /// \param LParenLoc Location of '('.
3383 /// \param EndLoc Ending location of the clause.
3384 /// \param VL List of references to the variables.
3385 /// \param PrivateVL List of references to private copies with initializers.
3386 static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
3387 SourceLocation LParenLoc,
3388 SourceLocation EndLoc, ArrayRef<Expr *> VL,
3389 ArrayRef<Expr *> PrivateVL);
3390
3391 /// Creates an empty clause with the place for \a N variables.
3392 ///
3393 /// \param C AST context.
3394 /// \param N The number of variables.
3395 static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3396
3399 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
3401 llvm::iterator_range<private_copies_const_iterator>;
3402
3403 private_copies_range private_copies() { return getPrivateCopies(); }
3404
3406 return getPrivateCopies();
3407 }
3408
3410 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3411 reinterpret_cast<Stmt **>(varlist_end()));
3412 }
3413
3415 return const_cast<OMPPrivateClause *>(this)->children();
3416 }
3417
3424
3425 static bool classof(const OMPClause *T) {
3426 return T->getClauseKind() == llvm::omp::OMPC_private;
3427 }
3428};
3429
3430/// This represents clause 'firstprivate' in the '#pragma omp ...'
3431/// directives.
3432///
3433/// \code
3434/// #pragma omp parallel firstprivate(a,b)
3435/// \endcode
3436/// In this example directive '#pragma omp parallel' has clause 'firstprivate'
3437/// with the variables 'a' and 'b'.
3438class OMPFirstprivateClause final
3439 : public OMPVarListClause<OMPFirstprivateClause>,
3440 public OMPClauseWithPreInit,
3441 private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
3442 friend class OMPClauseReader;
3443 friend OMPVarListClause;
3444 friend TrailingObjects;
3445
3446 /// Build clause with number of variables \a N.
3447 ///
3448 /// \param StartLoc Starting location of the clause.
3449 /// \param LParenLoc Location of '('.
3450 /// \param EndLoc Ending location of the clause.
3451 /// \param N Number of the variables in the clause.
3452 OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3453 SourceLocation EndLoc, unsigned N)
3454 : OMPVarListClause<OMPFirstprivateClause>(llvm::omp::OMPC_firstprivate,
3455 StartLoc, LParenLoc, EndLoc, N),
3456 OMPClauseWithPreInit(this) {}
3457
3458 /// Build an empty clause.
3459 ///
3460 /// \param N Number of variables.
3461 explicit OMPFirstprivateClause(unsigned N)
3463 llvm::omp::OMPC_firstprivate, SourceLocation(), SourceLocation(),
3464 SourceLocation(), N),
3465 OMPClauseWithPreInit(this) {}
3466
3467 /// Sets the list of references to private copies with initializers for
3468 /// new private variables.
3469 /// \param VL List of references.
3470 void setPrivateCopies(ArrayRef<Expr *> VL);
3471
3472 /// Gets the list of references to private copies with initializers for
3473 /// new private variables.
3474 MutableArrayRef<Expr *> getPrivateCopies() {
3475 return {varlist_end(), varlist_size()};
3476 }
3477 ArrayRef<const Expr *> getPrivateCopies() const {
3478 return {varlist_end(), varlist_size()};
3479 }
3480
3481 /// Sets the list of references to initializer variables for new
3482 /// private variables.
3483 /// \param VL List of references.
3484 void setInits(ArrayRef<Expr *> VL);
3485
3486 /// Gets the list of references to initializer variables for new
3487 /// private variables.
3488 MutableArrayRef<Expr *> getInits() {
3489 return {getPrivateCopies().end(), varlist_size()};
3490 }
3491 ArrayRef<const Expr *> getInits() const {
3492 return {getPrivateCopies().end(), varlist_size()};
3493 }
3494
3495public:
3496 /// Creates clause with a list of variables \a VL.
3497 ///
3498 /// \param C AST context.
3499 /// \param StartLoc Starting location of the clause.
3500 /// \param LParenLoc Location of '('.
3501 /// \param EndLoc Ending location of the clause.
3502 /// \param VL List of references to the original variables.
3503 /// \param PrivateVL List of references to private copies with initializers.
3504 /// \param InitVL List of references to auto generated variables used for
3505 /// initialization of a single array element. Used if firstprivate variable is
3506 /// of array type.
3507 /// \param PreInit Statement that must be executed before entering the OpenMP
3508 /// region with this clause.
3509 static OMPFirstprivateClause *
3510 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3511 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
3512 ArrayRef<Expr *> InitVL, Stmt *PreInit);
3513
3514 /// Creates an empty clause with the place for \a N variables.
3515 ///
3516 /// \param C AST context.
3517 /// \param N The number of variables.
3518 static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3519
3522 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
3524 llvm::iterator_range<private_copies_const_iterator>;
3525
3526 private_copies_range private_copies() { return getPrivateCopies(); }
3528 return getPrivateCopies();
3529 }
3530
3533 using inits_range = llvm::iterator_range<inits_iterator>;
3534 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
3535
3536 inits_range inits() { return getInits(); }
3537 inits_const_range inits() const { return getInits(); }
3538
3540 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3541 reinterpret_cast<Stmt **>(varlist_end()));
3542 }
3543
3545 return const_cast<OMPFirstprivateClause *>(this)->children();
3546 }
3547
3549 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3550 reinterpret_cast<Stmt **>(varlist_end()));
3551 }
3553 return const_cast<OMPFirstprivateClause *>(this)->used_children();
3554 }
3555
3556 static bool classof(const OMPClause *T) {
3557 return T->getClauseKind() == llvm::omp::OMPC_firstprivate;
3558 }
3559};
3560
3561/// This represents clause 'lastprivate' in the '#pragma omp ...'
3562/// directives.
3563///
3564/// \code
3565/// #pragma omp simd lastprivate(a,b)
3566/// \endcode
3567/// In this example directive '#pragma omp simd' has clause 'lastprivate'
3568/// with the variables 'a' and 'b'.
3569class OMPLastprivateClause final
3570 : public OMPVarListClause<OMPLastprivateClause>,
3572 private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
3573 // There are 4 additional tail-allocated arrays at the end of the class:
3574 // 1. Contains list of pseudo variables with the default initialization for
3575 // each non-firstprivate variables. Used in codegen for initialization of
3576 // lastprivate copies.
3577 // 2. List of helper expressions for proper generation of assignment operation
3578 // required for lastprivate clause. This list represents private variables
3579 // (for arrays, single array element).
3580 // 3. List of helper expressions for proper generation of assignment operation
3581 // required for lastprivate clause. This list represents original variables
3582 // (for arrays, single array element).
3583 // 4. List of helper expressions that represents assignment operation:
3584 // \code
3585 // DstExprs = SrcExprs;
3586 // \endcode
3587 // Required for proper codegen of final assignment performed by the
3588 // lastprivate clause.
3589 friend class OMPClauseReader;
3590 friend OMPVarListClause;
3591 friend TrailingObjects;
3592
3593 /// Optional lastprivate kind, e.g. 'conditional', if specified by user.
3595 /// Optional location of the lasptrivate kind, if specified by user.
3596 SourceLocation LPKindLoc;
3597 /// Optional colon location, if specified by user.
3598 SourceLocation ColonLoc;
3599
3600 /// Build clause with number of variables \a N.
3601 ///
3602 /// \param StartLoc Starting location of the clause.
3603 /// \param LParenLoc Location of '('.
3604 /// \param EndLoc Ending location of the clause.
3605 /// \param N Number of the variables in the clause.
3606 OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3608 SourceLocation LPKindLoc, SourceLocation ColonLoc,
3609 unsigned N)
3610 : OMPVarListClause<OMPLastprivateClause>(llvm::omp::OMPC_lastprivate,
3611 StartLoc, LParenLoc, EndLoc, N),
3612 OMPClauseWithPostUpdate(this), LPKind(LPKind), LPKindLoc(LPKindLoc),
3613 ColonLoc(ColonLoc) {}
3614
3615 /// Build an empty clause.
3616 ///
3617 /// \param N Number of variables.
3618 explicit OMPLastprivateClause(unsigned N)
3620 llvm::omp::OMPC_lastprivate, SourceLocation(), SourceLocation(),
3621 SourceLocation(), N),
3623
3624 /// Get the list of helper expressions for initialization of private
3625 /// copies for lastprivate variables.
3626 MutableArrayRef<Expr *> getPrivateCopies() {
3627 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3628 }
3629 ArrayRef<const Expr *> getPrivateCopies() const {
3630 return {varlist_end(), varlist_size()};
3631 }
3632
3633 /// Set list of helper expressions, required for proper codegen of the
3634 /// clause. These expressions represent private variables (for arrays, single
3635 /// array element) in the final assignment statement performed by the
3636 /// lastprivate clause.
3637 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
3638
3639 /// Get the list of helper source expressions.
3640 MutableArrayRef<Expr *> getSourceExprs() {
3641 return {getPrivateCopies().end(), varlist_size()};
3642 }
3643 ArrayRef<const Expr *> getSourceExprs() const {
3644 return {getPrivateCopies().end(), varlist_size()};
3645 }
3646
3647 /// Set list of helper expressions, required for proper codegen of the
3648 /// clause. These expressions represent original variables (for arrays, single
3649 /// array element) in the final assignment statement performed by the
3650 /// lastprivate clause.
3651 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
3652
3653 /// Get the list of helper destination expressions.
3654 MutableArrayRef<Expr *> getDestinationExprs() {
3655 return {getSourceExprs().end(), varlist_size()};
3656 }
3657 ArrayRef<const Expr *> getDestinationExprs() const {
3658 return {getSourceExprs().end(), varlist_size()};
3659 }
3660
3661 /// Set list of helper assignment expressions, required for proper
3662 /// codegen of the clause. These expressions are assignment expressions that
3663 /// assign private copy of the variable to original variable.
3664 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
3665
3666 /// Get the list of helper assignment expressions.
3667 MutableArrayRef<Expr *> getAssignmentOps() {
3668 return {getDestinationExprs().end(), varlist_size()};
3669 }
3670 ArrayRef<const Expr *> getAssignmentOps() const {
3671 return {getDestinationExprs().end(), varlist_size()};
3672 }
3673
3674 /// Sets lastprivate kind.
3675 void setKind(OpenMPLastprivateModifier Kind) { LPKind = Kind; }
3676 /// Sets location of the lastprivate kind.
3677 void setKindLoc(SourceLocation Loc) { LPKindLoc = Loc; }
3678 /// Sets colon symbol location.
3679 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3680
3681public:
3682 /// Creates clause with a list of variables \a VL.
3683 ///
3684 /// \param C AST context.
3685 /// \param StartLoc Starting location of the clause.
3686 /// \param LParenLoc Location of '('.
3687 /// \param EndLoc Ending location of the clause.
3688 /// \param VL List of references to the variables.
3689 /// \param SrcExprs List of helper expressions for proper generation of
3690 /// assignment operation required for lastprivate clause. This list represents
3691 /// private variables (for arrays, single array element).
3692 /// \param DstExprs List of helper expressions for proper generation of
3693 /// assignment operation required for lastprivate clause. This list represents
3694 /// original variables (for arrays, single array element).
3695 /// \param AssignmentOps List of helper expressions that represents assignment
3696 /// operation:
3697 /// \code
3698 /// DstExprs = SrcExprs;
3699 /// \endcode
3700 /// Required for proper codegen of final assignment performed by the
3701 /// lastprivate clause.
3702 /// \param LPKind Lastprivate kind, e.g. 'conditional'.
3703 /// \param LPKindLoc Location of the lastprivate kind.
3704 /// \param ColonLoc Location of the ':' symbol if lastprivate kind is used.
3705 /// \param PreInit Statement that must be executed before entering the OpenMP
3706 /// region with this clause.
3707 /// \param PostUpdate Expression that must be executed after exit from the
3708 /// OpenMP region with this clause.
3709 static OMPLastprivateClause *
3710 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3711 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
3712 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
3713 OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
3714 SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate);
3715
3716 /// Creates an empty clause with the place for \a N variables.
3717 ///
3718 /// \param C AST context.
3719 /// \param N The number of variables.
3720 static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3721
3722 /// Lastprivate kind.
3723 OpenMPLastprivateModifier getKind() const { return LPKind; }
3724 /// Returns the location of the lastprivate kind.
3725 SourceLocation getKindLoc() const { return LPKindLoc; }
3726 /// Returns the location of the ':' symbol, if any.
3727 SourceLocation getColonLoc() const { return ColonLoc; }
3728
3731 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3733 llvm::iterator_range<helper_expr_const_iterator>;
3734
3735 /// Set list of helper expressions, required for generation of private
3736 /// copies of original lastprivate variables.
3737 void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
3738
3739 helper_expr_const_range private_copies() const { return getPrivateCopies(); }
3740
3741 helper_expr_range private_copies() { return getPrivateCopies(); }
3742
3743 helper_expr_const_range source_exprs() const { return getSourceExprs(); }
3744
3745 helper_expr_range source_exprs() { return getSourceExprs(); }
3746
3748 return getDestinationExprs();
3749 }
3750
3751 helper_expr_range destination_exprs() { return getDestinationExprs(); }
3752
3753 helper_expr_const_range assignment_ops() const { return getAssignmentOps(); }
3754
3755 helper_expr_range assignment_ops() { return getAssignmentOps(); }
3756
3758 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3759 reinterpret_cast<Stmt **>(varlist_end()));
3760 }
3761
3763 return const_cast<OMPLastprivateClause *>(this)->children();
3764 }
3765
3772
3773 static bool classof(const OMPClause *T) {
3774 return T->getClauseKind() == llvm::omp::OMPC_lastprivate;
3775 }
3776};
3777
3778/// This represents clause 'shared' in the '#pragma omp ...' directives.
3779///
3780/// \code
3781/// #pragma omp parallel shared(a,b)
3782/// \endcode
3783/// In this example directive '#pragma omp parallel' has clause 'shared'
3784/// with the variables 'a' and 'b'.
3785class OMPSharedClause final
3786 : public OMPVarListClause<OMPSharedClause>,
3787 private llvm::TrailingObjects<OMPSharedClause, Expr *> {
3788 friend OMPVarListClause;
3789 friend TrailingObjects;
3790
3791 /// Build clause with number of variables \a N.
3792 ///
3793 /// \param StartLoc Starting location of the clause.
3794 /// \param LParenLoc Location of '('.
3795 /// \param EndLoc Ending location of the clause.
3796 /// \param N Number of the variables in the clause.
3797 OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3798 SourceLocation EndLoc, unsigned N)
3799 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared, StartLoc,
3800 LParenLoc, EndLoc, N) {}
3801
3802 /// Build an empty clause.
3803 ///
3804 /// \param N Number of variables.
3805 explicit OMPSharedClause(unsigned N)
3806 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared,
3808 SourceLocation(), N) {}
3809
3810public:
3811 /// Creates clause with a list of variables \a VL.
3812 ///
3813 /// \param C AST context.
3814 /// \param StartLoc Starting location of the clause.
3815 /// \param LParenLoc Location of '('.
3816 /// \param EndLoc Ending location of the clause.
3817 /// \param VL List of references to the variables.
3818 static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
3819 SourceLocation LParenLoc,
3820 SourceLocation EndLoc, ArrayRef<Expr *> VL);
3821
3822 /// Creates an empty clause with \a N variables.
3823 ///
3824 /// \param C AST context.
3825 /// \param N The number of variables.
3826 static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
3827
3829 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3830 reinterpret_cast<Stmt **>(varlist_end()));
3831 }
3832
3834 return const_cast<OMPSharedClause *>(this)->children();
3835 }
3836
3843
3844 static bool classof(const OMPClause *T) {
3845 return T->getClauseKind() == llvm::omp::OMPC_shared;
3846 }
3847};
3848
3849/// This represents clause 'reduction' in the '#pragma omp ...'
3850/// directives.
3851///
3852/// \code
3853/// #pragma omp parallel reduction(+:a,b)
3854/// \endcode
3855/// In this example directive '#pragma omp parallel' has clause 'reduction'
3856/// with operator '+' and the variables 'a' and 'b'.
3857class OMPReductionClause final
3858 : public OMPVarListClause<OMPReductionClause>,
3860 private llvm::TrailingObjects<OMPReductionClause, Expr *, bool> {
3861 friend class OMPClauseReader;
3862 friend OMPVarListClause;
3863 friend TrailingObjects;
3864
3865 /// Reduction modifier.
3867
3868 /// Original Sharing modifier.
3869 OpenMPOriginalSharingModifier OriginalSharingModifier =
3870 OMPC_ORIGINAL_SHARING_default;
3871
3872 /// Reduction modifier location.
3873 SourceLocation ModifierLoc;
3874
3875 /// Location of ':'.
3876 SourceLocation ColonLoc;
3877
3878 /// Nested name specifier for C++.
3879 NestedNameSpecifierLoc QualifierLoc;
3880
3881 /// Name of custom operator.
3882 DeclarationNameInfo NameInfo;
3883
3884 /// Build clause with number of variables \a N.
3885 ///
3886 /// \param StartLoc Starting location of the clause.
3887 /// \param LParenLoc Location of '('.
3888 /// \param ModifierLoc Modifier location.
3889 /// \param ColonLoc Location of ':'.
3890 /// \param EndLoc Ending location of the clause.
3891 /// \param N Number of the variables in the clause.
3892 /// \param QualifierLoc The nested-name qualifier with location information
3893 /// \param NameInfo The full name info for reduction identifier.
3894 OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3895 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3896 SourceLocation EndLoc,
3898 OpenMPOriginalSharingModifier OriginalSharingModifier,
3899 unsigned N, NestedNameSpecifierLoc QualifierLoc,
3900 const DeclarationNameInfo &NameInfo)
3901 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3902 StartLoc, LParenLoc, EndLoc, N),
3903 OMPClauseWithPostUpdate(this), Modifier(Modifier),
3904 OriginalSharingModifier(OriginalSharingModifier),
3905 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
3906 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3907
3908 /// Build an empty clause.
3909 ///
3910 /// \param N Number of variables.
3911 explicit OMPReductionClause(unsigned N)
3912 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3914 SourceLocation(), N),
3916
3917 /// Sets reduction modifier.
3918 void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; }
3919
3920 /// Sets Original Sharing modifier.
3921 void setOriginalSharingModifier(OpenMPOriginalSharingModifier M) {
3922 OriginalSharingModifier = M;
3923 }
3924
3925 /// Sets location of the modifier.
3926 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
3927
3928 /// Sets location of ':' symbol in clause.
3929 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3930
3931 /// Sets the name info for specified reduction identifier.
3932 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3933
3934 /// Sets the nested name specifier.
3935 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3936
3937 /// Set list of helper expressions, required for proper codegen of the
3938 /// clause. These expressions represent private copy of the reduction
3939 /// variable.
3940 void setPrivates(ArrayRef<Expr *> Privates);
3941
3942 /// Get the list of helper privates.
3943 MutableArrayRef<Expr *> getPrivates() {
3944 return {varlist_end(), varlist_size()};
3945 }
3946 ArrayRef<const Expr *> getPrivates() const {
3947 return {varlist_end(), varlist_size()};
3948 }
3949
3950 /// Set list of helper expressions, required for proper codegen of the
3951 /// clause. These expressions represent LHS expression in the final
3952 /// reduction expression performed by the reduction clause.
3953 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3954
3955 /// Get the list of helper LHS expressions.
3956 MutableArrayRef<Expr *> getLHSExprs() {
3957 return {getPrivates().end(), varlist_size()};
3958 }
3959 ArrayRef<const Expr *> getLHSExprs() const {
3960 return {getPrivates().end(), varlist_size()};
3961 }
3962
3963 /// Set list of helper expressions, required for proper codegen of the
3964 /// clause. These expressions represent RHS expression in the final
3965 /// reduction expression performed by the reduction clause.
3966 /// Also, variables in these expressions are used for proper initialization of
3967 /// reduction copies.
3968 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3969
3970 /// Set the list private reduction flags
3971 void setPrivateVariableReductionFlags(ArrayRef<bool> Flags) {
3972 assert(Flags.size() == varlist_size() &&
3973 "Number of private flags does not match vars");
3974 llvm::copy(Flags, getTrailingObjects<bool>());
3975 }
3976
3977 /// Get the list of help private variable reduction flags
3978 MutableArrayRef<bool> getPrivateVariableReductionFlags() {
3979 return getTrailingObjects<bool>(varlist_size());
3980 }
3981 ArrayRef<bool> getPrivateVariableReductionFlags() const {
3982 return getTrailingObjects<bool>(varlist_size());
3983 }
3984
3985 /// Returns the number of Expr* objects in trailing storage
3986 size_t numTrailingObjects(OverloadToken<Expr *>) const {
3987 return varlist_size() * (Modifier == OMPC_REDUCTION_inscan ? 8 : 5);
3988 }
3989
3990 /// Returns the number of bool flags in trailing storage
3991 size_t numTrailingObjects(OverloadToken<bool>) const {
3992 return varlist_size();
3993 }
3994
3995 /// Get the list of helper destination expressions.
3996 MutableArrayRef<Expr *> getRHSExprs() {
3997 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3998 }
3999 ArrayRef<const Expr *> getRHSExprs() const {
4000 return {getLHSExprs().end(), varlist_size()};
4001 }
4002
4003 /// Set list of helper reduction expressions, required for proper
4004 /// codegen of the clause. These expressions are binary expressions or
4005 /// operator/custom reduction call that calculates new value from source
4006 /// helper expressions to destination helper expressions.
4007 void setReductionOps(ArrayRef<Expr *> ReductionOps);
4008
4009 /// Get the list of helper reduction expressions.
4010 MutableArrayRef<Expr *> getReductionOps() {
4011 return {getRHSExprs().end(), varlist_size()};
4012 }
4013 ArrayRef<const Expr *> getReductionOps() const {
4014 return {getRHSExprs().end(), varlist_size()};
4015 }
4016
4017 /// Set list of helper copy operations for inscan reductions.
4018 /// The form is: Temps[i] = LHS[i];
4019 void setInscanCopyOps(ArrayRef<Expr *> Ops);
4020
4021 /// Get the list of helper inscan copy operations.
4022 MutableArrayRef<Expr *> getInscanCopyOps() {
4023 return {getReductionOps().end(), varlist_size()};
4024 }
4025 ArrayRef<const Expr *> getInscanCopyOps() const {
4026 return {getReductionOps().end(), varlist_size()};
4027 }
4028
4029 /// Set list of helper temp vars for inscan copy array operations.
4030 void setInscanCopyArrayTemps(ArrayRef<Expr *> CopyArrayTemps);
4031
4032 /// Get the list of helper inscan copy temps.
4033 MutableArrayRef<Expr *> getInscanCopyArrayTemps() {
4034 return {getInscanCopyOps().end(), varlist_size()};
4035 }
4036 ArrayRef<const Expr *> getInscanCopyArrayTemps() const {
4037 return {getInscanCopyOps().end(), varlist_size()};
4038 }
4039
4040 /// Set list of helper temp elements vars for inscan copy array operations.
4041 void setInscanCopyArrayElems(ArrayRef<Expr *> CopyArrayElems);
4042
4043 /// Get the list of helper inscan copy temps.
4044 MutableArrayRef<Expr *> getInscanCopyArrayElems() {
4045 return {getInscanCopyArrayTemps().end(), varlist_size()};
4046 }
4047 ArrayRef<const Expr *> getInscanCopyArrayElems() const {
4048 return {getInscanCopyArrayTemps().end(), varlist_size()};
4049 }
4050
4051public:
4052 /// Creates clause with a list of variables \a VL.
4053 ///
4054 /// \param StartLoc Starting location of the clause.
4055 /// \param LParenLoc Location of '('.
4056 /// \param ModifierLoc Modifier location.
4057 /// \param ColonLoc Location of ':'.
4058 /// \param EndLoc Ending location of the clause.
4059 /// \param VL The variables in the clause.
4060 /// \param QualifierLoc The nested-name qualifier with location information
4061 /// \param NameInfo The full name info for reduction identifier.
4062 /// \param Privates List of helper expressions for proper generation of
4063 /// private copies.
4064 /// \param LHSExprs List of helper expressions for proper generation of
4065 /// assignment operation required for copyprivate clause. This list represents
4066 /// LHSs of the reduction expressions.
4067 /// \param RHSExprs List of helper expressions for proper generation of
4068 /// assignment operation required for copyprivate clause. This list represents
4069 /// RHSs of the reduction expressions.
4070 /// Also, variables in these expressions are used for proper initialization of
4071 /// reduction copies.
4072 /// \param ReductionOps List of helper expressions that represents reduction
4073 /// expressions:
4074 /// \code
4075 /// LHSExprs binop RHSExprs;
4076 /// operator binop(LHSExpr, RHSExpr);
4077 /// <CutomReduction>(LHSExpr, RHSExpr);
4078 /// \endcode
4079 /// Required for proper codegen of final reduction operation performed by the
4080 /// reduction clause.
4081 /// \param CopyOps List of copy operations for inscan reductions:
4082 /// \code
4083 /// TempExprs = LHSExprs;
4084 /// \endcode
4085 /// \param CopyArrayTemps Temp arrays for prefix sums.
4086 /// \param CopyArrayElems Temp arrays for prefix sums.
4087 /// \param PreInit Statement that must be executed before entering the OpenMP
4088 /// region with this clause.
4089 /// \param PostUpdate Expression that must be executed after exit from the
4090 /// OpenMP region with this clause.
4091 /// \param IsPrivateVarReduction array for private variable reduction flags
4092 static OMPReductionClause *
4093 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4094 SourceLocation ModifierLoc, SourceLocation ColonLoc,
4095 SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier,
4096 ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc,
4097 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4098 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4099 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps,
4100 ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems,
4101 Stmt *PreInit, Expr *PostUpdate, ArrayRef<bool> IsPrivateVarReduction,
4102 OpenMPOriginalSharingModifier OriginalSharingModifier);
4103
4104 /// Creates an empty clause with the place for \a N variables.
4105 ///
4106 /// \param C AST context.
4107 /// \param N The number of variables.
4108 /// \param Modifier Reduction modifier.
4109 static OMPReductionClause *
4110 CreateEmpty(const ASTContext &C, unsigned N,
4112
4113 /// Returns modifier.
4114 OpenMPReductionClauseModifier getModifier() const { return Modifier; }
4115
4116 /// Returns Original Sharing Modifier.
4118 return OriginalSharingModifier;
4119 }
4120
4121 /// Returns modifier location.
4122 SourceLocation getModifierLoc() const { return ModifierLoc; }
4123
4124 /// Gets location of ':' symbol in clause.
4125 SourceLocation getColonLoc() const { return ColonLoc; }
4126
4127 /// Gets the name info for specified reduction identifier.
4128 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4129
4130 /// Gets the nested name specifier.
4131 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4132
4135 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4137 llvm::iterator_range<helper_expr_const_iterator>;
4140 using helper_flag_range = llvm::iterator_range<helper_flag_iterator>;
4142 llvm::iterator_range<helper_flag_const_iterator>;
4143
4144 helper_expr_const_range privates() const { return getPrivates(); }
4145
4146 helper_expr_range privates() { return getPrivates(); }
4147
4148 helper_expr_const_range lhs_exprs() const { return getLHSExprs(); }
4149
4150 helper_expr_range lhs_exprs() { return getLHSExprs(); }
4151
4152 helper_expr_const_range rhs_exprs() const { return getRHSExprs(); }
4153
4154 helper_expr_range rhs_exprs() { return getRHSExprs(); }
4155
4157 return getPrivateVariableReductionFlags();
4158 }
4159
4161 return getPrivateVariableReductionFlags();
4162 }
4163
4164 helper_expr_const_range reduction_ops() const { return getReductionOps(); }
4165
4166 helper_expr_range reduction_ops() { return getReductionOps(); }
4167
4168 helper_expr_const_range copy_ops() const { return getInscanCopyOps(); }
4169
4170 helper_expr_range copy_ops() { return getInscanCopyOps(); }
4171
4173 return getInscanCopyArrayTemps();
4174 }
4175
4176 helper_expr_range copy_array_temps() { return getInscanCopyArrayTemps(); }
4177
4179 return getInscanCopyArrayElems();
4180 }
4181
4182 helper_expr_range copy_array_elems() { return getInscanCopyArrayElems(); }
4183
4185 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4186 reinterpret_cast<Stmt **>(varlist_end()));
4187 }
4188
4190 return const_cast<OMPReductionClause *>(this)->children();
4191 }
4192
4194 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4195 reinterpret_cast<Stmt **>(varlist_end()));
4196 }
4198 return const_cast<OMPReductionClause *>(this)->used_children();
4199 }
4200
4201 static bool classof(const OMPClause *T) {
4202 return T->getClauseKind() == llvm::omp::OMPC_reduction;
4203 }
4204};
4205
4206/// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
4207/// directives.
4208///
4209/// \code
4210/// #pragma omp taskgroup task_reduction(+:a,b)
4211/// \endcode
4212/// In this example directive '#pragma omp taskgroup' has clause
4213/// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
4214class OMPTaskReductionClause final
4215 : public OMPVarListClause<OMPTaskReductionClause>,
4217 private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> {
4218 friend class OMPClauseReader;
4219 friend OMPVarListClause;
4220 friend TrailingObjects;
4221
4222 /// Location of ':'.
4223 SourceLocation ColonLoc;
4224
4225 /// Nested name specifier for C++.
4226 NestedNameSpecifierLoc QualifierLoc;
4227
4228 /// Name of custom operator.
4229 DeclarationNameInfo NameInfo;
4230
4231 /// Build clause with number of variables \a N.
4232 ///
4233 /// \param StartLoc Starting location of the clause.
4234 /// \param LParenLoc Location of '('.
4235 /// \param EndLoc Ending location of the clause.
4236 /// \param ColonLoc Location of ':'.
4237 /// \param N Number of the variables in the clause.
4238 /// \param QualifierLoc The nested-name qualifier with location information
4239 /// \param NameInfo The full name info for reduction identifier.
4240 OMPTaskReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4241 SourceLocation ColonLoc, SourceLocation EndLoc,
4242 unsigned N, NestedNameSpecifierLoc QualifierLoc,
4243 const DeclarationNameInfo &NameInfo)
4244 : OMPVarListClause<OMPTaskReductionClause>(
4245 llvm::omp::OMPC_task_reduction, StartLoc, LParenLoc, EndLoc, N),
4246 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
4247 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
4248
4249 /// Build an empty clause.
4250 ///
4251 /// \param N Number of variables.
4252 explicit OMPTaskReductionClause(unsigned N)
4254 llvm::omp::OMPC_task_reduction, SourceLocation(), SourceLocation(),
4255 SourceLocation(), N),
4257
4258 /// Sets location of ':' symbol in clause.
4259 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
4260
4261 /// Sets the name info for specified reduction identifier.
4262 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
4263
4264 /// Sets the nested name specifier.
4265 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
4266
4267 /// Set list of helper expressions, required for proper codegen of the clause.
4268 /// These expressions represent private copy of the reduction variable.
4269 void setPrivates(ArrayRef<Expr *> Privates);
4270
4271 /// Get the list of helper privates.
4272 MutableArrayRef<Expr *> getPrivates() {
4273 return {varlist_end(), varlist_size()};
4274 }
4275 ArrayRef<const Expr *> getPrivates() const {
4276 return {varlist_end(), varlist_size()};
4277 }
4278
4279 /// Set list of helper expressions, required for proper codegen of the clause.
4280 /// These expressions represent LHS expression in the final reduction
4281 /// expression performed by the reduction clause.
4282 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
4283
4284 /// Get the list of helper LHS expressions.
4285 MutableArrayRef<Expr *> getLHSExprs() {
4286 return {getPrivates().end(), varlist_size()};
4287 }
4288 ArrayRef<const Expr *> getLHSExprs() const {
4289 return {getPrivates().end(), varlist_size()};
4290 }
4291
4292 /// Set list of helper expressions, required for proper codegen of the clause.
4293 /// These expressions represent RHS expression in the final reduction
4294 /// expression performed by the reduction clause. Also, variables in these
4295 /// expressions are used for proper initialization of reduction copies.
4296 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
4297
4298 /// Get the list of helper destination expressions.
4299 MutableArrayRef<Expr *> getRHSExprs() {
4300 return {getLHSExprs().end(), varlist_size()};
4301 }
4302 ArrayRef<const Expr *> getRHSExprs() const {
4303 return {getLHSExprs().end(), varlist_size()};
4304 }
4305
4306 /// Set list of helper reduction expressions, required for proper
4307 /// codegen of the clause. These expressions are binary expressions or
4308 /// operator/custom reduction call that calculates new value from source
4309 /// helper expressions to destination helper expressions.
4310 void setReductionOps(ArrayRef<Expr *> ReductionOps);
4311
4312 /// Get the list of helper reduction expressions.
4313 MutableArrayRef<Expr *> getReductionOps() {
4314 return {getRHSExprs().end(), varlist_size()};
4315 }
4316 ArrayRef<const Expr *> getReductionOps() const {
4317 return {getRHSExprs().end(), varlist_size()};
4318 }
4319
4320public:
4321 /// Creates clause with a list of variables \a VL.
4322 ///
4323 /// \param StartLoc Starting location of the clause.
4324 /// \param LParenLoc Location of '('.
4325 /// \param ColonLoc Location of ':'.
4326 /// \param EndLoc Ending location of the clause.
4327 /// \param VL The variables in the clause.
4328 /// \param QualifierLoc The nested-name qualifier with location information
4329 /// \param NameInfo The full name info for reduction identifier.
4330 /// \param Privates List of helper expressions for proper generation of
4331 /// private copies.
4332 /// \param LHSExprs List of helper expressions for proper generation of
4333 /// assignment operation required for copyprivate clause. This list represents
4334 /// LHSs of the reduction expressions.
4335 /// \param RHSExprs List of helper expressions for proper generation of
4336 /// assignment operation required for copyprivate clause. This list represents
4337 /// RHSs of the reduction expressions.
4338 /// Also, variables in these expressions are used for proper initialization of
4339 /// reduction copies.
4340 /// \param ReductionOps List of helper expressions that represents reduction
4341 /// expressions:
4342 /// \code
4343 /// LHSExprs binop RHSExprs;
4344 /// operator binop(LHSExpr, RHSExpr);
4345 /// <CutomReduction>(LHSExpr, RHSExpr);
4346 /// \endcode
4347 /// Required for proper codegen of final reduction operation performed by the
4348 /// reduction clause.
4349 /// \param PreInit Statement that must be executed before entering the OpenMP
4350 /// region with this clause.
4351 /// \param PostUpdate Expression that must be executed after exit from the
4352 /// OpenMP region with this clause.
4353 static OMPTaskReductionClause *
4354 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4355 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
4356 NestedNameSpecifierLoc QualifierLoc,
4357 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4358 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4359 ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
4360
4361 /// Creates an empty clause with the place for \a N variables.
4362 ///
4363 /// \param C AST context.
4364 /// \param N The number of variables.
4365 static OMPTaskReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
4366
4367 /// Gets location of ':' symbol in clause.
4368 SourceLocation getColonLoc() const { return ColonLoc; }
4369
4370 /// Gets the name info for specified reduction identifier.
4371 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4372
4373 /// Gets the nested name specifier.
4374 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4375
4378 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4380 llvm::iterator_range<helper_expr_const_iterator>;
4381
4382 helper_expr_const_range privates() const { return getPrivates(); }
4383
4384 helper_expr_range privates() { return getPrivates(); }
4385
4386 helper_expr_const_range lhs_exprs() const { return getLHSExprs(); }
4387
4388 helper_expr_range lhs_exprs() { return getLHSExprs(); }
4389
4390 helper_expr_const_range rhs_exprs() const { return getRHSExprs(); }
4391
4392 helper_expr_range rhs_exprs() { return getRHSExprs(); }
4393
4394 helper_expr_const_range reduction_ops() const { return getReductionOps(); }
4395
4396 helper_expr_range reduction_ops() { return getReductionOps(); }
4397
4399 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4400 reinterpret_cast<Stmt **>(varlist_end()));
4401 }
4402
4404 return const_cast<OMPTaskReductionClause *>(this)->children();
4405 }
4406
4413
4414 static bool classof(const OMPClause *T) {
4415 return T->getClauseKind() == llvm::omp::OMPC_task_reduction;
4416 }
4417};
4418
4419/// This represents clause 'in_reduction' in the '#pragma omp task' directives.
4420///
4421/// \code
4422/// #pragma omp task in_reduction(+:a,b)
4423/// \endcode
4424/// In this example directive '#pragma omp task' has clause 'in_reduction' with
4425/// operator '+' and the variables 'a' and 'b'.
4426class OMPInReductionClause final
4427 : public OMPVarListClause<OMPInReductionClause>,
4429 private llvm::TrailingObjects<OMPInReductionClause, Expr *> {
4430 friend class OMPClauseReader;
4431 friend OMPVarListClause;
4432 friend TrailingObjects;
4433
4434 /// Location of ':'.
4435 SourceLocation ColonLoc;
4436
4437 /// Nested name specifier for C++.
4438 NestedNameSpecifierLoc QualifierLoc;
4439
4440 /// Name of custom operator.
4441 DeclarationNameInfo NameInfo;
4442
4443 /// Build clause with number of variables \a N.
4444 ///
4445 /// \param StartLoc Starting location of the clause.
4446 /// \param LParenLoc Location of '('.
4447 /// \param EndLoc Ending location of the clause.
4448 /// \param ColonLoc Location of ':'.
4449 /// \param N Number of the variables in the clause.
4450 /// \param QualifierLoc The nested-name qualifier with location information
4451 /// \param NameInfo The full name info for reduction identifier.
4452 OMPInReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4453 SourceLocation ColonLoc, SourceLocation EndLoc,
4454 unsigned N, NestedNameSpecifierLoc QualifierLoc,
4455 const DeclarationNameInfo &NameInfo)
4456 : OMPVarListClause<OMPInReductionClause>(llvm::omp::OMPC_in_reduction,
4457 StartLoc, LParenLoc, EndLoc, N),
4458 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
4459 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
4460
4461 /// Build an empty clause.
4462 ///
4463 /// \param N Number of variables.
4464 explicit OMPInReductionClause(unsigned N)
4466 llvm::omp::OMPC_in_reduction, SourceLocation(), SourceLocation(),
4467 SourceLocation(), N),
4469
4470 /// Sets location of ':' symbol in clause.
4471 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
4472
4473 /// Sets the name info for specified reduction identifier.
4474 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
4475
4476 /// Sets the nested name specifier.
4477 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
4478
4479 /// Set list of helper expressions, required for proper codegen of the clause.
4480 /// These expressions represent private copy of the reduction variable.
4481 void setPrivates(ArrayRef<Expr *> Privates);
4482
4483 /// Get the list of helper privates.
4484 MutableArrayRef<Expr *> getPrivates() {
4485 return {varlist_end(), varlist_size()};
4486 }
4487 ArrayRef<const Expr *> getPrivates() const {
4488 return {varlist_end(), varlist_size()};
4489 }
4490
4491 /// Set list of helper expressions, required for proper codegen of the clause.
4492 /// These expressions represent LHS expression in the final reduction
4493 /// expression performed by the reduction clause.
4494 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
4495
4496 /// Get the list of helper LHS expressions.
4497 MutableArrayRef<Expr *> getLHSExprs() {
4498 return {getPrivates().end(), varlist_size()};
4499 }
4500 ArrayRef<const Expr *> getLHSExprs() const {
4501 return {getPrivates().end(), varlist_size()};
4502 }
4503
4504 /// Set list of helper expressions, required for proper codegen of the clause.
4505 /// These expressions represent RHS expression in the final reduction
4506 /// expression performed by the reduction clause. Also, variables in these
4507 /// expressions are used for proper initialization of reduction copies.
4508 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
4509
4510 /// Get the list of helper destination expressions.
4511 MutableArrayRef<Expr *> getRHSExprs() {
4512 return {getLHSExprs().end(), varlist_size()};
4513 }
4514 ArrayRef<const Expr *> getRHSExprs() const {
4515 return {getLHSExprs().end(), varlist_size()};
4516 }
4517
4518 /// Set list of helper reduction expressions, required for proper
4519 /// codegen of the clause. These expressions are binary expressions or
4520 /// operator/custom reduction call that calculates new value from source
4521 /// helper expressions to destination helper expressions.
4522 void setReductionOps(ArrayRef<Expr *> ReductionOps);
4523
4524 /// Get the list of helper reduction expressions.
4525 MutableArrayRef<Expr *> getReductionOps() {
4526 return {getRHSExprs().end(), varlist_size()};
4527 }
4528 ArrayRef<const Expr *> getReductionOps() const {
4529 return {getRHSExprs().end(), varlist_size()};
4530 }
4531
4532 /// Set list of helper reduction taskgroup descriptors.
4533 void setTaskgroupDescriptors(ArrayRef<Expr *> ReductionOps);
4534
4535 /// Get the list of helper reduction taskgroup descriptors.
4536 MutableArrayRef<Expr *> getTaskgroupDescriptors() {
4537 return {getReductionOps().end(), varlist_size()};
4538 }
4539 ArrayRef<const Expr *> getTaskgroupDescriptors() const {
4540 return {getReductionOps().end(), varlist_size()};
4541 }
4542
4543public:
4544 /// Creates clause with a list of variables \a VL.
4545 ///
4546 /// \param StartLoc Starting location of the clause.
4547 /// \param LParenLoc Location of '('.
4548 /// \param ColonLoc Location of ':'.
4549 /// \param EndLoc Ending location of the clause.
4550 /// \param VL The variables in the clause.
4551 /// \param QualifierLoc The nested-name qualifier with location information
4552 /// \param NameInfo The full name info for reduction identifier.
4553 /// \param Privates List of helper expressions for proper generation of
4554 /// private copies.
4555 /// \param LHSExprs List of helper expressions for proper generation of
4556 /// assignment operation required for copyprivate clause. This list represents
4557 /// LHSs of the reduction expressions.
4558 /// \param RHSExprs List of helper expressions for proper generation of
4559 /// assignment operation required for copyprivate clause. This list represents
4560 /// RHSs of the reduction expressions.
4561 /// Also, variables in these expressions are used for proper initialization of
4562 /// reduction copies.
4563 /// \param ReductionOps List of helper expressions that represents reduction
4564 /// expressions:
4565 /// \code
4566 /// LHSExprs binop RHSExprs;
4567 /// operator binop(LHSExpr, RHSExpr);
4568 /// <CutomReduction>(LHSExpr, RHSExpr);
4569 /// \endcode
4570 /// Required for proper codegen of final reduction operation performed by the
4571 /// reduction clause.
4572 /// \param TaskgroupDescriptors List of helper taskgroup descriptors for
4573 /// corresponding items in parent taskgroup task_reduction clause.
4574 /// \param PreInit Statement that must be executed before entering the OpenMP
4575 /// region with this clause.
4576 /// \param PostUpdate Expression that must be executed after exit from the
4577 /// OpenMP region with this clause.
4578 static OMPInReductionClause *
4579 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4580 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
4581 NestedNameSpecifierLoc QualifierLoc,
4582 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4583 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4584 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> TaskgroupDescriptors,
4585 Stmt *PreInit, Expr *PostUpdate);
4586
4587 /// Creates an empty clause with the place for \a N variables.
4588 ///
4589 /// \param C AST context.
4590 /// \param N The number of variables.
4591 static OMPInReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
4592
4593 /// Gets location of ':' symbol in clause.
4594 SourceLocation getColonLoc() const { return ColonLoc; }
4595
4596 /// Gets the name info for specified reduction identifier.
4597 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4598
4599 /// Gets the nested name specifier.
4600 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4601
4604 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4606 llvm::iterator_range<helper_expr_const_iterator>;
4607
4608 helper_expr_const_range privates() const { return getPrivates(); }
4609
4610 helper_expr_range privates() { return getPrivates(); }
4611
4612 helper_expr_const_range lhs_exprs() const { return getLHSExprs(); }
4613
4614 helper_expr_range lhs_exprs() { return getLHSExprs(); }
4615
4616 helper_expr_const_range rhs_exprs() const { return getRHSExprs(); }
4617
4618 helper_expr_range rhs_exprs() { return getRHSExprs(); }
4619
4620 helper_expr_const_range reduction_ops() const { return getReductionOps(); }
4621
4622 helper_expr_range reduction_ops() { return getReductionOps(); }
4623
4625 return getTaskgroupDescriptors();
4626 }
4627
4629 return getTaskgroupDescriptors();
4630 }
4631
4633 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4634 reinterpret_cast<Stmt **>(varlist_end()));
4635 }
4636
4638 return const_cast<OMPInReductionClause *>(this)->children();
4639 }
4640
4647
4648 static bool classof(const OMPClause *T) {
4649 return T->getClauseKind() == llvm::omp::OMPC_in_reduction;
4650 }
4651};
4652
4653/// This represents clause 'linear' in the '#pragma omp ...'
4654/// directives.
4655///
4656/// \code
4657/// #pragma omp simd linear(a,b : 2)
4658/// \endcode
4659/// In this example directive '#pragma omp simd' has clause 'linear'
4660/// with variables 'a', 'b' and linear step '2'.
4661class OMPLinearClause final
4662 : public OMPVarListClause<OMPLinearClause>,
4664 private llvm::TrailingObjects<OMPLinearClause, Expr *> {
4665 friend class OMPClauseReader;
4666 friend OMPVarListClause;
4667 friend TrailingObjects;
4668
4669 /// Modifier of 'linear' clause.
4670 OpenMPLinearClauseKind Modifier = OMPC_LINEAR_val;
4671
4672 /// Location of linear modifier if any.
4673 SourceLocation ModifierLoc;
4674
4675 /// Location of ':'.
4676 SourceLocation ColonLoc;
4677
4678 /// Location of 'step' modifier.
4679 SourceLocation StepModifierLoc;
4680
4681 /// Sets the linear step for clause.
4682 void setStep(Expr *Step) { *(getFinals().end()) = Step; }
4683
4684 /// Sets the expression to calculate linear step for clause.
4685 void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
4686
4687 /// Build 'linear' clause with given number of variables \a NumVars.
4688 ///
4689 /// \param StartLoc Starting location of the clause.
4690 /// \param LParenLoc Location of '('.
4691 /// \param ColonLoc Location of ':'.
4692 /// \param StepModifierLoc Location of 'step' modifier.
4693 /// \param EndLoc Ending location of the clause.
4694 /// \param NumVars Number of variables.
4695 OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4696 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4697 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4698 SourceLocation EndLoc, unsigned NumVars)
4699 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear, StartLoc,
4700 LParenLoc, EndLoc, NumVars),
4701 OMPClauseWithPostUpdate(this), Modifier(Modifier),
4702 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
4703 StepModifierLoc(StepModifierLoc) {}
4704
4705 /// Build an empty clause.
4706 ///
4707 /// \param NumVars Number of variables.
4708 explicit OMPLinearClause(unsigned NumVars)
4709 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear,
4710 SourceLocation(), SourceLocation(),
4711 SourceLocation(), NumVars),
4713
4714 /// Gets the list of initial values for linear variables.
4715 ///
4716 /// There are NumVars expressions with initial values allocated after the
4717 /// varlist, they are followed by NumVars update expressions (used to update
4718 /// the linear variable's value on current iteration) and they are followed by
4719 /// NumVars final expressions (used to calculate the linear variable's
4720 /// value after the loop body). After these lists, there are 2 helper
4721 /// expressions - linear step and a helper to calculate it before the
4722 /// loop body (used when the linear step is not constant):
4723 ///
4724 /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
4725 /// Finals[]; Step; CalcStep; }
4726 MutableArrayRef<Expr *> getPrivates() {
4727 return {varlist_end(), varlist_size()};
4728 }
4729 ArrayRef<const Expr *> getPrivates() const {
4730 return {varlist_end(), varlist_size()};
4731 }
4732
4733 MutableArrayRef<Expr *> getInits() {
4734 return {getPrivates().end(), varlist_size()};
4735 }
4736 ArrayRef<const Expr *> getInits() const {
4737 return {getPrivates().end(), varlist_size()};
4738 }
4739
4740 /// Sets the list of update expressions for linear variables.
4741 MutableArrayRef<Expr *> getUpdates() {
4742 return {getInits().end(), varlist_size()};
4743 }
4744 ArrayRef<const Expr *> getUpdates() const {
4745 return {getInits().end(), varlist_size()};
4746 }
4747
4748 /// Sets the list of final update expressions for linear variables.
4749 MutableArrayRef<Expr *> getFinals() {
4750 return {getUpdates().end(), varlist_size()};
4751 }
4752 ArrayRef<const Expr *> getFinals() const {
4753 return {getUpdates().end(), varlist_size()};
4754 }
4755
4756 /// Gets the list of used expressions for linear variables.
4757 MutableArrayRef<Expr *> getUsedExprs() {
4758 return {getFinals().end() + 2, varlist_size() + 1};
4759 }
4760 ArrayRef<const Expr *> getUsedExprs() const {
4761 return {getFinals().end() + 2, varlist_size() + 1};
4762 }
4763
4764 /// Sets the list of the copies of original linear variables.
4765 /// \param PL List of expressions.
4766 void setPrivates(ArrayRef<Expr *> PL);
4767
4768 /// Sets the list of the initial values for linear variables.
4769 /// \param IL List of expressions.
4770 void setInits(ArrayRef<Expr *> IL);
4771
4772public:
4773 /// Creates clause with a list of variables \a VL and a linear step
4774 /// \a Step.
4775 ///
4776 /// \param C AST Context.
4777 /// \param StartLoc Starting location of the clause.
4778 /// \param LParenLoc Location of '('.
4779 /// \param Modifier Modifier of 'linear' clause.
4780 /// \param ModifierLoc Modifier location.
4781 /// \param ColonLoc Location of ':'.
4782 /// \param StepModifierLoc Location of 'step' modifier.
4783 /// \param EndLoc Ending location of the clause.
4784 /// \param VL List of references to the variables.
4785 /// \param PL List of private copies of original variables.
4786 /// \param IL List of initial values for the variables.
4787 /// \param Step Linear step.
4788 /// \param CalcStep Calculation of the linear step.
4789 /// \param PreInit Statement that must be executed before entering the OpenMP
4790 /// region with this clause.
4791 /// \param PostUpdate Expression that must be executed after exit from the
4792 /// OpenMP region with this clause.
4793 static OMPLinearClause *
4794 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4795 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4796 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4797 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PL,
4798 ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit,
4799 Expr *PostUpdate);
4800
4801 /// Creates an empty clause with the place for \a NumVars variables.
4802 ///
4803 /// \param C AST context.
4804 /// \param NumVars Number of variables.
4805 static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4806
4807 /// Set modifier.
4808 void setModifier(OpenMPLinearClauseKind Kind) { Modifier = Kind; }
4809
4810 /// Return modifier.
4811 OpenMPLinearClauseKind getModifier() const { return Modifier; }
4812
4813 /// Set modifier location.
4814 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
4815
4816 /// Return modifier location.
4817 SourceLocation getModifierLoc() const { return ModifierLoc; }
4818
4819 /// Sets the location of ':'.
4820 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4821
4822 /// Sets the location of 'step' modifier.
4823 void setStepModifierLoc(SourceLocation Loc) { StepModifierLoc = Loc; }
4824
4825 /// Returns the location of ':'.
4826 SourceLocation getColonLoc() const { return ColonLoc; }
4827
4828 /// Returns the location of 'step' modifier.
4829 SourceLocation getStepModifierLoc() const { return StepModifierLoc; }
4830
4831 /// Returns linear step.
4832 Expr *getStep() { return *(getFinals().end()); }
4833
4834 /// Returns linear step.
4835 const Expr *getStep() const { return *(getFinals().end()); }
4836
4837 /// Returns expression to calculate linear step.
4838 Expr *getCalcStep() { return *(getFinals().end() + 1); }
4839
4840 /// Returns expression to calculate linear step.
4841 const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
4842
4843 /// Sets the list of update expressions for linear variables.
4844 /// \param UL List of expressions.
4846
4847 /// Sets the list of final update expressions for linear variables.
4848 /// \param FL List of expressions.
4849 void setFinals(ArrayRef<Expr *> FL);
4850
4851 /// Sets the list of used expressions for the linear clause.
4853
4856 using privates_range = llvm::iterator_range<privates_iterator>;
4857 using privates_const_range = llvm::iterator_range<privates_const_iterator>;
4858
4859 privates_range privates() { return getPrivates(); }
4860
4861 privates_const_range privates() const { return getPrivates(); }
4862
4865 using inits_range = llvm::iterator_range<inits_iterator>;
4866 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
4867
4868 inits_range inits() { return getInits(); }
4869
4870 inits_const_range inits() const { return getInits(); }
4871
4874 using updates_range = llvm::iterator_range<updates_iterator>;
4875 using updates_const_range = llvm::iterator_range<updates_const_iterator>;
4876
4877 updates_range updates() { return getUpdates(); }
4878
4879 updates_const_range updates() const { return getUpdates(); }
4880
4883 using finals_range = llvm::iterator_range<finals_iterator>;
4884 using finals_const_range = llvm::iterator_range<finals_const_iterator>;
4885
4886 finals_range finals() { return getFinals(); }
4887
4888 finals_const_range finals() const { return getFinals(); }
4889
4893 llvm::iterator_range<used_expressions_iterator>;
4895 llvm::iterator_range<used_expressions_const_iterator>;
4896
4898 return finals_range(getUsedExprs().begin(), getUsedExprs().end());
4899 }
4900
4902 return finals_const_range(getUsedExprs().begin(), getUsedExprs().end());
4903 }
4904
4906 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4907 reinterpret_cast<Stmt **>(varlist_end()));
4908 }
4909
4911 return const_cast<OMPLinearClause *>(this)->children();
4912 }
4913
4915
4917 return const_cast<OMPLinearClause *>(this)->used_children();
4918 }
4919
4920 static bool classof(const OMPClause *T) {
4921 return T->getClauseKind() == llvm::omp::OMPC_linear;
4922 }
4923};
4924
4925/// This represents clause 'aligned' in the '#pragma omp ...'
4926/// directives.
4927///
4928/// \code
4929/// #pragma omp simd aligned(a,b : 8)
4930/// \endcode
4931/// In this example directive '#pragma omp simd' has clause 'aligned'
4932/// with variables 'a', 'b' and alignment '8'.
4933class OMPAlignedClause final
4934 : public OMPVarListClause<OMPAlignedClause>,
4935 private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
4936 friend class OMPClauseReader;
4937 friend OMPVarListClause;
4938 friend TrailingObjects;
4939
4940 /// Location of ':'.
4941 SourceLocation ColonLoc;
4942
4943 /// Sets the alignment for clause.
4944 void setAlignment(Expr *A) { *varlist_end() = A; }
4945
4946 /// Build 'aligned' clause with given number of variables \a NumVars.
4947 ///
4948 /// \param StartLoc Starting location of the clause.
4949 /// \param LParenLoc Location of '('.
4950 /// \param ColonLoc Location of ':'.
4951 /// \param EndLoc Ending location of the clause.
4952 /// \param NumVars Number of variables.
4954 SourceLocation ColonLoc, SourceLocation EndLoc,
4955 unsigned NumVars)
4956 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned, StartLoc,
4957 LParenLoc, EndLoc, NumVars),
4958 ColonLoc(ColonLoc) {}
4959
4960 /// Build an empty clause.
4961 ///
4962 /// \param NumVars Number of variables.
4963 explicit OMPAlignedClause(unsigned NumVars)
4964 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned,
4965 SourceLocation(), SourceLocation(),
4966 SourceLocation(), NumVars) {}
4967
4968public:
4969 /// Creates clause with a list of variables \a VL and alignment \a A.
4970 ///
4971 /// \param C AST Context.
4972 /// \param StartLoc Starting location of the clause.
4973 /// \param LParenLoc Location of '('.
4974 /// \param ColonLoc Location of ':'.
4975 /// \param EndLoc Ending location of the clause.
4976 /// \param VL List of references to the variables.
4977 /// \param A Alignment.
4978 static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
4979 SourceLocation LParenLoc,
4980 SourceLocation ColonLoc,
4981 SourceLocation EndLoc, ArrayRef<Expr *> VL,
4982 Expr *A);
4983
4984 /// Creates an empty clause with the place for \a NumVars variables.
4985 ///
4986 /// \param C AST context.
4987 /// \param NumVars Number of variables.
4988 static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4989
4990 /// Sets the location of ':'.
4991 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4992
4993 /// Returns the location of ':'.
4994 SourceLocation getColonLoc() const { return ColonLoc; }
4995
4996 /// Returns alignment.
4998
4999 /// Returns alignment.
5000 const Expr *getAlignment() const { return *varlist_end(); }
5001
5003 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5004 reinterpret_cast<Stmt **>(varlist_end()));
5005 }
5006
5008 return const_cast<OMPAlignedClause *>(this)->children();
5009 }
5010
5017
5018 static bool classof(const OMPClause *T) {
5019 return T->getClauseKind() == llvm::omp::OMPC_aligned;
5020 }
5021};
5022
5023/// This represents clause 'copyin' in the '#pragma omp ...' directives.
5024///
5025/// \code
5026/// #pragma omp parallel copyin(a,b)
5027/// \endcode
5028/// In this example directive '#pragma omp parallel' has clause 'copyin'
5029/// with the variables 'a' and 'b'.
5030class OMPCopyinClause final
5031 : public OMPVarListClause<OMPCopyinClause>,
5032 private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
5033 // Class has 3 additional tail allocated arrays:
5034 // 1. List of helper expressions for proper generation of assignment operation
5035 // required for copyin clause. This list represents sources.
5036 // 2. List of helper expressions for proper generation of assignment operation
5037 // required for copyin clause. This list represents destinations.
5038 // 3. List of helper expressions that represents assignment operation:
5039 // \code
5040 // DstExprs = SrcExprs;
5041 // \endcode
5042 // Required for proper codegen of propagation of master's thread values of
5043 // threadprivate variables to local instances of that variables in other
5044 // implicit threads.
5045
5046 friend class OMPClauseReader;
5047 friend OMPVarListClause;
5048 friend TrailingObjects;
5049
5050 /// Build clause with number of variables \a N.
5051 ///
5052 /// \param StartLoc Starting location of the clause.
5053 /// \param LParenLoc Location of '('.
5054 /// \param EndLoc Ending location of the clause.
5055 /// \param N Number of the variables in the clause.
5056 OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5057 SourceLocation EndLoc, unsigned N)
5058 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin, StartLoc,
5059 LParenLoc, EndLoc, N) {}
5060
5061 /// Build an empty clause.
5062 ///
5063 /// \param N Number of variables.
5064 explicit OMPCopyinClause(unsigned N)
5065 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin,
5067 SourceLocation(), N) {}
5068
5069 /// Set list of helper expressions, required for proper codegen of the
5070 /// clause. These expressions represent source expression in the final
5071 /// assignment statement performed by the copyin clause.
5072 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
5073
5074 /// Get the list of helper source expressions.
5075 MutableArrayRef<Expr *> getSourceExprs() {
5076 return {varlist_end(), varlist_size()};
5077 }
5078 ArrayRef<const Expr *> getSourceExprs() const {
5079 return {varlist_end(), varlist_size()};
5080 }
5081
5082 /// Set list of helper expressions, required for proper codegen of the
5083 /// clause. These expressions represent destination expression in the final
5084 /// assignment statement performed by the copyin clause.
5085 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
5086
5087 /// Get the list of helper destination expressions.
5088 MutableArrayRef<Expr *> getDestinationExprs() {
5089 return {getSourceExprs().end(), varlist_size()};
5090 }
5091 ArrayRef<const Expr *> getDestinationExprs() const {
5092 return {getSourceExprs().end(), varlist_size()};
5093 }
5094
5095 /// Set list of helper assignment expressions, required for proper
5096 /// codegen of the clause. These expressions are assignment expressions that
5097 /// assign source helper expressions to destination helper expressions
5098 /// correspondingly.
5099 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
5100
5101 /// Get the list of helper assignment expressions.
5102 MutableArrayRef<Expr *> getAssignmentOps() {
5103 return {getDestinationExprs().end(), varlist_size()};
5104 }
5105 ArrayRef<const Expr *> getAssignmentOps() const {
5106 return {getDestinationExprs().end(), varlist_size()};
5107 }
5108
5109public:
5110 /// Creates clause with a list of variables \a VL.
5111 ///
5112 /// \param C AST context.
5113 /// \param StartLoc Starting location of the clause.
5114 /// \param LParenLoc Location of '('.
5115 /// \param EndLoc Ending location of the clause.
5116 /// \param VL List of references to the variables.
5117 /// \param SrcExprs List of helper expressions for proper generation of
5118 /// assignment operation required for copyin clause. This list represents
5119 /// sources.
5120 /// \param DstExprs List of helper expressions for proper generation of
5121 /// assignment operation required for copyin clause. This list represents
5122 /// destinations.
5123 /// \param AssignmentOps List of helper expressions that represents assignment
5124 /// operation:
5125 /// \code
5126 /// DstExprs = SrcExprs;
5127 /// \endcode
5128 /// Required for proper codegen of propagation of master's thread values of
5129 /// threadprivate variables to local instances of that variables in other
5130 /// implicit threads.
5131 static OMPCopyinClause *
5132 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
5133 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
5134 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
5135
5136 /// Creates an empty clause with \a N variables.
5137 ///
5138 /// \param C AST context.
5139 /// \param N The number of variables.
5140 static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
5141
5144 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
5146 llvm::iterator_range<helper_expr_const_iterator>;
5147
5148 helper_expr_const_range source_exprs() const { return getSourceExprs(); }
5149
5150 helper_expr_range source_exprs() { return getSourceExprs(); }
5151
5153 return getDestinationExprs();
5154 }
5155
5156 helper_expr_range destination_exprs() { return getDestinationExprs(); }
5157
5158 helper_expr_const_range assignment_ops() const { return getAssignmentOps(); }
5159
5160 helper_expr_range assignment_ops() { return getAssignmentOps(); }
5161
5163 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5164 reinterpret_cast<Stmt **>(varlist_end()));
5165 }
5166
5168 return const_cast<OMPCopyinClause *>(this)->children();
5169 }
5170
5177
5178 static bool classof(const OMPClause *T) {
5179 return T->getClauseKind() == llvm::omp::OMPC_copyin;
5180 }
5181};
5182
5183/// This represents clause 'copyprivate' in the '#pragma omp ...'
5184/// directives.
5185///
5186/// \code
5187/// #pragma omp single copyprivate(a,b)
5188/// \endcode
5189/// In this example directive '#pragma omp single' has clause 'copyprivate'
5190/// with the variables 'a' and 'b'.
5191class OMPCopyprivateClause final
5192 : public OMPVarListClause<OMPCopyprivateClause>,
5193 private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
5194 friend class OMPClauseReader;
5195 friend OMPVarListClause;
5196 friend TrailingObjects;
5197
5198 /// Build clause with number of variables \a N.
5199 ///
5200 /// \param StartLoc Starting location of the clause.
5201 /// \param LParenLoc Location of '('.
5202 /// \param EndLoc Ending location of the clause.
5203 /// \param N Number of the variables in the clause.
5204 OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5205 SourceLocation EndLoc, unsigned N)
5206 : OMPVarListClause<OMPCopyprivateClause>(llvm::omp::OMPC_copyprivate,
5207 StartLoc, LParenLoc, EndLoc, N) {
5208 }
5209
5210 /// Build an empty clause.
5211 ///
5212 /// \param N Number of variables.
5213 explicit OMPCopyprivateClause(unsigned N)
5215 llvm::omp::OMPC_copyprivate, SourceLocation(), SourceLocation(),
5216 SourceLocation(), N) {}
5217
5218 /// Set list of helper expressions, required for proper codegen of the
5219 /// clause. These expressions represent source expression in the final
5220 /// assignment statement performed by the copyprivate clause.
5221 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
5222
5223 /// Get the list of helper source expressions.
5224 MutableArrayRef<Expr *> getSourceExprs() {
5225 return {varlist_end(), varlist_size()};
5226 }
5227 ArrayRef<const Expr *> getSourceExprs() const {
5228 return {varlist_end(), varlist_size()};
5229 }
5230
5231 /// Set list of helper expressions, required for proper codegen of the
5232 /// clause. These expressions represent destination expression in the final
5233 /// assignment statement performed by the copyprivate clause.
5234 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
5235
5236 /// Get the list of helper destination expressions.
5237 MutableArrayRef<Expr *> getDestinationExprs() {
5238 return {getSourceExprs().end(), varlist_size()};
5239 }
5240 ArrayRef<const Expr *> getDestinationExprs() const {
5241 return {getSourceExprs().end(), varlist_size()};
5242 }
5243
5244 /// Set list of helper assignment expressions, required for proper
5245 /// codegen of the clause. These expressions are assignment expressions that
5246 /// assign source helper expressions to destination helper expressions
5247 /// correspondingly.
5248 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
5249
5250 /// Get the list of helper assignment expressions.
5251 MutableArrayRef<Expr *> getAssignmentOps() {
5252 return {getDestinationExprs().end(), varlist_size()};
5253 }
5254 ArrayRef<const Expr *> getAssignmentOps() const {
5255 return {getDestinationExprs().end(), varlist_size()};
5256 }
5257
5258public:
5259 /// Creates clause with a list of variables \a VL.
5260 ///
5261 /// \param C AST context.
5262 /// \param StartLoc Starting location of the clause.
5263 /// \param LParenLoc Location of '('.
5264 /// \param EndLoc Ending location of the clause.
5265 /// \param VL List of references to the variables.
5266 /// \param SrcExprs List of helper expressions for proper generation of
5267 /// assignment operation required for copyprivate clause. This list represents
5268 /// sources.
5269 /// \param DstExprs List of helper expressions for proper generation of
5270 /// assignment operation required for copyprivate clause. This list represents
5271 /// destinations.
5272 /// \param AssignmentOps List of helper expressions that represents assignment
5273 /// operation:
5274 /// \code
5275 /// DstExprs = SrcExprs;
5276 /// \endcode
5277 /// Required for proper codegen of final assignment performed by the
5278 /// copyprivate clause.
5279 static OMPCopyprivateClause *
5280 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
5281 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
5282 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
5283
5284 /// Creates an empty clause with \a N variables.
5285 ///
5286 /// \param C AST context.
5287 /// \param N The number of variables.
5288 static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
5289
5292 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
5294 llvm::iterator_range<helper_expr_const_iterator>;
5295
5296 helper_expr_const_range source_exprs() const { return getSourceExprs(); }
5297
5298 helper_expr_range source_exprs() { return getSourceExprs(); }
5299
5301 return getDestinationExprs();
5302 }
5303
5304 helper_expr_range destination_exprs() { return getDestinationExprs(); }
5305
5306 helper_expr_const_range assignment_ops() const { return getAssignmentOps(); }
5307
5308 helper_expr_range assignment_ops() { return getAssignmentOps(); }
5309
5311 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5312 reinterpret_cast<Stmt **>(varlist_end()));
5313 }
5314
5316 return const_cast<OMPCopyprivateClause *>(this)->children();
5317 }
5318
5325
5326 static bool classof(const OMPClause *T) {
5327 return T->getClauseKind() == llvm::omp::OMPC_copyprivate;
5328 }
5329};
5330
5331/// This represents implicit clause 'flush' for the '#pragma omp flush'
5332/// directive.
5333/// This clause does not exist by itself, it can be only as a part of 'omp
5334/// flush' directive. This clause is introduced to keep the original structure
5335/// of \a OMPExecutableDirective class and its derivatives and to use the
5336/// existing infrastructure of clauses with the list of variables.
5337///
5338/// \code
5339/// #pragma omp flush(a,b)
5340/// \endcode
5341/// In this example directive '#pragma omp flush' has implicit clause 'flush'
5342/// with the variables 'a' and 'b'.
5343class OMPFlushClause final
5344 : public OMPVarListClause<OMPFlushClause>,
5345 private llvm::TrailingObjects<OMPFlushClause, Expr *> {
5346 friend OMPVarListClause;
5347 friend TrailingObjects;
5348
5349 /// Build clause with number of variables \a N.
5350 ///
5351 /// \param StartLoc Starting location of the clause.
5352 /// \param LParenLoc Location of '('.
5353 /// \param EndLoc Ending location of the clause.
5354 /// \param N Number of the variables in the clause.
5355 OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5356 SourceLocation EndLoc, unsigned N)
5357 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush, StartLoc,
5358 LParenLoc, EndLoc, N) {}
5359
5360 /// Build an empty clause.
5361 ///
5362 /// \param N Number of variables.
5363 explicit OMPFlushClause(unsigned N)
5364 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush,
5366 SourceLocation(), N) {}
5367
5368public:
5369 /// Creates clause with a list of variables \a VL.
5370 ///
5371 /// \param C AST context.
5372 /// \param StartLoc Starting location of the clause.
5373 /// \param LParenLoc Location of '('.
5374 /// \param EndLoc Ending location of the clause.
5375 /// \param VL List of references to the variables.
5376 static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
5377 SourceLocation LParenLoc, SourceLocation EndLoc,
5378 ArrayRef<Expr *> VL);
5379
5380 /// Creates an empty clause with \a N variables.
5381 ///
5382 /// \param C AST context.
5383 /// \param N The number of variables.
5384 static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
5385
5387 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5388 reinterpret_cast<Stmt **>(varlist_end()));
5389 }
5390
5392 return const_cast<OMPFlushClause *>(this)->children();
5393 }
5394
5401
5402 static bool classof(const OMPClause *T) {
5403 return T->getClauseKind() == llvm::omp::OMPC_flush;
5404 }
5405};
5406
5407/// This represents implicit clause 'depobj' for the '#pragma omp depobj'
5408/// directive.
5409/// This clause does not exist by itself, it can be only as a part of 'omp
5410/// depobj' directive. This clause is introduced to keep the original structure
5411/// of \a OMPExecutableDirective class and its derivatives and to use the
5412/// existing infrastructure of clauses with the list of variables.
5413///
5414/// \code
5415/// #pragma omp depobj(a) destroy
5416/// \endcode
5417/// In this example directive '#pragma omp depobj' has implicit clause 'depobj'
5418/// with the depobj 'a'.
5419class OMPDepobjClause final : public OMPClause {
5420 friend class OMPClauseReader;
5421
5422 /// Location of '('.
5423 SourceLocation LParenLoc;
5424
5425 /// Chunk size.
5426 Expr *Depobj = nullptr;
5427
5428 /// Build clause with number of variables \a N.
5429 ///
5430 /// \param StartLoc Starting location of the clause.
5431 /// \param LParenLoc Location of '('.
5432 /// \param EndLoc Ending location of the clause.
5433 OMPDepobjClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5434 SourceLocation EndLoc)
5435 : OMPClause(llvm::omp::OMPC_depobj, StartLoc, EndLoc),
5436 LParenLoc(LParenLoc) {}
5437
5438 /// Build an empty clause.
5439 ///
5440 explicit OMPDepobjClause()
5441 : OMPClause(llvm::omp::OMPC_depobj, SourceLocation(), SourceLocation()) {}
5442
5443 void setDepobj(Expr *E) { Depobj = E; }
5444
5445 /// Sets the location of '('.
5446 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5447
5448public:
5449 /// Creates clause.
5450 ///
5451 /// \param C AST context.
5452 /// \param StartLoc Starting location of the clause.
5453 /// \param LParenLoc Location of '('.
5454 /// \param EndLoc Ending location of the clause.
5455 /// \param Depobj depobj expression associated with the 'depobj' directive.
5456 static OMPDepobjClause *Create(const ASTContext &C, SourceLocation StartLoc,
5457 SourceLocation LParenLoc,
5458 SourceLocation EndLoc, Expr *Depobj);
5459
5460 /// Creates an empty clause.
5461 ///
5462 /// \param C AST context.
5463 static OMPDepobjClause *CreateEmpty(const ASTContext &C);
5464
5465 /// Returns depobj expression associated with the clause.
5466 Expr *getDepobj() { return Depobj; }
5467 const Expr *getDepobj() const { return Depobj; }
5468
5469 /// Returns the location of '('.
5470 SourceLocation getLParenLoc() const { return LParenLoc; }
5471
5473 return child_range(reinterpret_cast<Stmt **>(&Depobj),
5474 reinterpret_cast<Stmt **>(&Depobj) + 1);
5475 }
5476
5478 return const_cast<OMPDepobjClause *>(this)->children();
5479 }
5480
5487
5488 static bool classof(const OMPClause *T) {
5489 return T->getClauseKind() == llvm::omp::OMPC_depobj;
5490 }
5491};
5492
5493/// This represents implicit clause 'depend' for the '#pragma omp task'
5494/// directive.
5495///
5496/// \code
5497/// #pragma omp task depend(in:a,b)
5498/// \endcode
5499/// In this example directive '#pragma omp task' with clause 'depend' with the
5500/// variables 'a' and 'b' with dependency 'in'.
5501class OMPDependClause final
5502 : public OMPVarListClause<OMPDependClause>,
5503 private llvm::TrailingObjects<OMPDependClause, Expr *> {
5504 friend class OMPClauseReader;
5505 friend OMPVarListClause;
5506 friend TrailingObjects;
5507
5508public:
5509 struct DependDataTy final {
5510 /// Dependency type (one of in, out, inout).
5512
5513 /// Dependency type location.
5515
5516 /// Colon location.
5518
5519 /// Location of 'omp_all_memory'.
5521 };
5522
5523private:
5524 /// Dependency type and source locations.
5525 DependDataTy Data;
5526
5527 /// Number of loops, associated with the depend clause.
5528 unsigned NumLoops = 0;
5529
5530 /// Build clause with number of variables \a N.
5531 ///
5532 /// \param StartLoc Starting location of the clause.
5533 /// \param LParenLoc Location of '('.
5534 /// \param EndLoc Ending location of the clause.
5535 /// \param N Number of the variables in the clause.
5536 /// \param NumLoops Number of loops that is associated with this depend
5537 /// clause.
5538 OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5539 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
5540 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend, StartLoc,
5541 LParenLoc, EndLoc, N),
5542 NumLoops(NumLoops) {}
5543
5544 /// Build an empty clause.
5545 ///
5546 /// \param N Number of variables.
5547 /// \param NumLoops Number of loops that is associated with this depend
5548 /// clause.
5549 explicit OMPDependClause(unsigned N, unsigned NumLoops)
5550 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend,
5552 SourceLocation(), N),
5553 NumLoops(NumLoops) {}
5554
5555 /// Set dependency kind.
5556 void setDependencyKind(OpenMPDependClauseKind K) { Data.DepKind = K; }
5557
5558 /// Set dependency kind and its location.
5559 void setDependencyLoc(SourceLocation Loc) { Data.DepLoc = Loc; }
5560
5561 /// Set colon location.
5562 void setColonLoc(SourceLocation Loc) { Data.ColonLoc = Loc; }
5563
5564 /// Set the 'omp_all_memory' location.
5565 void setOmpAllMemoryLoc(SourceLocation Loc) { Data.OmpAllMemoryLoc = Loc; }
5566
5567 /// Sets optional dependency modifier.
5568 void setModifier(Expr *DepModifier);
5569
5570public:
5571 /// Creates clause with a list of variables \a VL.
5572 ///
5573 /// \param C AST context.
5574 /// \param StartLoc Starting location of the clause.
5575 /// \param LParenLoc Location of '('.
5576 /// \param EndLoc Ending location of the clause.
5577 /// \param Data Dependency type and source locations.
5578 /// \param VL List of references to the variables.
5579 /// \param NumLoops Number of loops that is associated with this depend
5580 /// clause.
5581 static OMPDependClause *Create(const ASTContext &C, SourceLocation StartLoc,
5582 SourceLocation LParenLoc,
5583 SourceLocation EndLoc, DependDataTy Data,
5584 Expr *DepModifier, ArrayRef<Expr *> VL,
5585 unsigned NumLoops);
5586
5587 /// Creates an empty clause with \a N variables.
5588 ///
5589 /// \param C AST context.
5590 /// \param N The number of variables.
5591 /// \param NumLoops Number of loops that is associated with this depend
5592 /// clause.
5593 static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N,
5594 unsigned NumLoops);
5595
5596 /// Get dependency type.
5597 OpenMPDependClauseKind getDependencyKind() const { return Data.DepKind; }
5598
5599 /// Get dependency type location.
5600 SourceLocation getDependencyLoc() const { return Data.DepLoc; }
5601
5602 /// Get colon location.
5603 SourceLocation getColonLoc() const { return Data.ColonLoc; }
5604
5605 /// Get 'omp_all_memory' location.
5606 SourceLocation getOmpAllMemoryLoc() const { return Data.OmpAllMemoryLoc; }
5607
5608 /// Return optional depend modifier.
5609 Expr *getModifier();
5610 const Expr *getModifier() const {
5611 return const_cast<OMPDependClause *>(this)->getModifier();
5612 }
5613
5614 /// Get number of loops associated with the clause.
5615 unsigned getNumLoops() const { return NumLoops; }
5616
5617 /// Set the loop data for the depend clauses with 'sink|source' kind of
5618 /// dependency.
5619 void setLoopData(unsigned NumLoop, Expr *Cnt);
5620
5621 /// Get the loop data.
5622 Expr *getLoopData(unsigned NumLoop);
5623 const Expr *getLoopData(unsigned NumLoop) const;
5624
5626 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5627 reinterpret_cast<Stmt **>(varlist_end()));
5628 }
5629
5631 return const_cast<OMPDependClause *>(this)->children();
5632 }
5633
5640
5641 static bool classof(const OMPClause *T) {
5642 return T->getClauseKind() == llvm::omp::OMPC_depend;
5643 }
5644};
5645
5646/// This represents 'device' clause in the '#pragma omp ...'
5647/// directive.
5648///
5649/// \code
5650/// #pragma omp target device(a)
5651/// \endcode
5652/// In this example directive '#pragma omp target' has clause 'device'
5653/// with single expression 'a'.
5655 friend class OMPClauseReader;
5656
5657 /// Location of '('.
5658 SourceLocation LParenLoc;
5659
5660 /// Device clause modifier.
5662
5663 /// Location of the modifier.
5664 SourceLocation ModifierLoc;
5665
5666 /// Device number.
5667 Stmt *Device = nullptr;
5668
5669 /// Set the device number.
5670 ///
5671 /// \param E Device number.
5672 void setDevice(Expr *E) { Device = E; }
5673
5674 /// Sets modifier.
5675 void setModifier(OpenMPDeviceClauseModifier M) { Modifier = M; }
5676
5677 /// Setst modifier location.
5678 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
5679
5680public:
5681 /// Build 'device' clause.
5682 ///
5683 /// \param Modifier Clause modifier.
5684 /// \param E Expression associated with this clause.
5685 /// \param CaptureRegion Innermost OpenMP region where expressions in this
5686 /// clause must be captured.
5687 /// \param StartLoc Starting location of the clause.
5688 /// \param ModifierLoc Modifier location.
5689 /// \param LParenLoc Location of '('.
5690 /// \param EndLoc Ending location of the clause.
5692 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
5693 SourceLocation LParenLoc, SourceLocation ModifierLoc,
5694 SourceLocation EndLoc)
5695 : OMPClause(llvm::omp::OMPC_device, StartLoc, EndLoc),
5696 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
5697 ModifierLoc(ModifierLoc), Device(E) {
5698 setPreInitStmt(HelperE, CaptureRegion);
5699 }
5700
5701 /// Build an empty clause.
5703 : OMPClause(llvm::omp::OMPC_device, SourceLocation(), SourceLocation()),
5704 OMPClauseWithPreInit(this) {}
5705
5706 /// Sets the location of '('.
5707 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5708
5709 /// Returns the location of '('.
5710 SourceLocation getLParenLoc() const { return LParenLoc; }
5711
5712 /// Return device number.
5713 Expr *getDevice() { return cast<Expr>(Device); }
5714
5715 /// Return device number.
5716 Expr *getDevice() const { return cast<Expr>(Device); }
5717
5718 /// Gets modifier.
5719 OpenMPDeviceClauseModifier getModifier() const { return Modifier; }
5720
5721 /// Gets modifier location.
5722 SourceLocation getModifierLoc() const { return ModifierLoc; }
5723
5724 child_range children() { return child_range(&Device, &Device + 1); }
5725
5727 return const_child_range(&Device, &Device + 1);
5728 }
5729
5736
5737 static bool classof(const OMPClause *T) {
5738 return T->getClauseKind() == llvm::omp::OMPC_device;
5739 }
5740};
5741
5742/// This represents 'threads' clause in the '#pragma omp ...' directive.
5743///
5744/// \code
5745/// #pragma omp ordered threads
5746/// \endcode
5747/// In this example directive '#pragma omp ordered' has simple 'threads' clause.
5749 : public OMPNoChildClause<llvm::omp::OMPC_threads> {
5750public:
5751 /// Build 'threads' clause.
5752 ///
5753 /// \param StartLoc Starting location of the clause.
5754 /// \param EndLoc Ending location of the clause.
5756 : OMPNoChildClause(StartLoc, EndLoc) {}
5757
5758 /// Build an empty clause.
5760};
5761
5762/// This represents 'simd' clause in the '#pragma omp ...' directive.
5763///
5764/// \code
5765/// #pragma omp ordered simd
5766/// \endcode
5767/// In this example directive '#pragma omp ordered' has simple 'simd' clause.
5768class OMPSIMDClause : public OMPClause {
5769public:
5770 /// Build 'simd' clause.
5771 ///
5772 /// \param StartLoc Starting location of the clause.
5773 /// \param EndLoc Ending location of the clause.
5775 : OMPClause(llvm::omp::OMPC_simd, StartLoc, EndLoc) {}
5776
5777 /// Build an empty clause.
5779 : OMPClause(llvm::omp::OMPC_simd, SourceLocation(), SourceLocation()) {}
5780
5784
5788
5795
5796 static bool classof(const OMPClause *T) {
5797 return T->getClauseKind() == llvm::omp::OMPC_simd;
5798 }
5799};
5800
5801/// Struct that defines common infrastructure to handle mappable
5802/// expressions used in OpenMP clauses.
5804public:
5805 /// Class that represents a component of a mappable expression. E.g.
5806 /// for an expression S.a, the first component is a declaration reference
5807 /// expression associated with 'S' and the second is a member expression
5808 /// associated with the field declaration 'a'. If the expression is an array
5809 /// subscript it may not have any associated declaration. In that case the
5810 /// associated declaration is set to nullptr.
5812 /// Pair of Expression and Non-contiguous pair associated with the
5813 /// component.
5814 llvm::PointerIntPair<Expr *, 1, bool> AssociatedExpressionNonContiguousPr;
5815
5816 /// Declaration associated with the declaration. If the component does
5817 /// not have a declaration (e.g. array subscripts or section), this is set
5818 /// to nullptr.
5819 ValueDecl *AssociatedDeclaration = nullptr;
5820
5821 public:
5822 explicit MappableComponent() = default;
5823 explicit MappableComponent(Expr *AssociatedExpression,
5824 ValueDecl *AssociatedDeclaration,
5825 bool IsNonContiguous)
5826 : AssociatedExpressionNonContiguousPr(AssociatedExpression,
5827 IsNonContiguous),
5828 AssociatedDeclaration(
5829 AssociatedDeclaration
5830 ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
5831 : nullptr) {}
5832
5834 return AssociatedExpressionNonContiguousPr.getPointer();
5835 }
5836
5837 bool isNonContiguous() const {
5838 return AssociatedExpressionNonContiguousPr.getInt();
5839 }
5840
5842 return AssociatedDeclaration;
5843 }
5844
5846 return AssociatedExpressionNonContiguousPr ==
5847 Other.AssociatedExpressionNonContiguousPr &&
5848 AssociatedDeclaration == Other.AssociatedDeclaration;
5849 }
5850 };
5851
5852 // List of components of an expression. This first one is the whole
5853 // expression and the last one is the base expression.
5856
5857 // List of all component lists associated to the same base declaration.
5858 // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
5859 // their component list but the same base declaration 'S'.
5862
5863 // Hash function to allow usage as DenseMap keys.
5864 friend llvm::hash_code hash_value(const MappableComponent &MC) {
5865 return llvm::hash_combine(MC.getAssociatedExpression(),
5867 MC.isNonContiguous());
5868 }
5869
5870public:
5871 /// Get the type of an element of a ComponentList Expr \p Exp.
5872 ///
5873 /// For something like the following:
5874 /// ```c
5875 /// int *p, **p;
5876 /// ```
5877 /// The types for the following Exprs would be:
5878 /// Expr | Type
5879 /// ---------|-----------
5880 /// p | int *
5881 /// *p | int
5882 /// p[0] | int
5883 /// p[0:1] | int
5884 /// pp | int **
5885 /// pp[0] | int *
5886 /// pp[0:1] | int *
5887 /// Note: this assumes that if \p Exp is an array-section, it is contiguous.
5888 static QualType getComponentExprElementType(const Expr *Exp);
5889
5890 /// Find the attach pointer expression from a list of mappable expression
5891 /// components.
5892 ///
5893 /// This function traverses the component list to find the first
5894 /// expression that has a pointer type, which represents the attach
5895 /// base pointer expr for the current component-list.
5896 ///
5897 /// For example, given the following:
5898 ///
5899 /// ```c
5900 /// struct S {
5901 /// int a;
5902 /// int b[10];
5903 /// int c[10][10];
5904 /// int *p;
5905 /// int **pp;
5906 /// }
5907 /// S s, *ps, **pps, *(pas[10]), ***ppps;
5908 /// int i;
5909 /// ```
5910 ///
5911 /// The base-pointers for the following map operands would be:
5912 /// map list-item | attach base-pointer | attach base-pointer
5913 /// | for directives except | target_update (if
5914 /// | target_update | different)
5915 /// ----------------|-----------------------|---------------------
5916 /// s | N/A |
5917 /// s.a | N/A |
5918 /// s.p | N/A |
5919 /// ps | N/A |
5920 /// ps->p | ps |
5921 /// ps[1] | ps |
5922 /// *(ps + 1) | ps |
5923 /// (ps + 1)[1] | ps |
5924 /// ps[1:10] | ps |
5925 /// ps->b[10] | ps |
5926 /// ps->p[10] | ps->p |
5927 /// ps->c[1][2] | ps |
5928 /// ps->c[1:2][2] | (error diagnostic) | N/A, TODO: ps
5929 /// ps->c[1:1][2] | ps | N/A, TODO: ps
5930 /// pps[1][2] | pps[1] |
5931 /// pps[1:1][2] | pps[1:1] | N/A, TODO: pps[1:1]
5932 /// pps[1:i][2] | pps[1:i] | N/A, TODO: pps[1:i]
5933 /// pps[1:2][2] | (error diagnostic) | N/A
5934 /// pps[1]->p | pps[1] |
5935 /// pps[1]->p[10] | pps[1] |
5936 /// pas[1] | N/A |
5937 /// pas[1][2] | pas[1] |
5938 /// ppps[1][2] | ppps[1] |
5939 /// ppps[1][2][3] | ppps[1][2] |
5940 /// ppps[1][2:1][3] | ppps[1][2:1] | N/A, TODO: ppps[1][2:1]
5941 /// ppps[1][2:2][3] | (error diagnostic) | N/A
5942 /// Returns a pair of the attach pointer expression and its depth in the
5943 /// component list.
5944 /// TODO: This may need to be updated to handle ref_ptr/ptee cases for byref
5945 /// map operands.
5946 /// TODO: Handle cases for target-update, where the list-item is a
5947 /// non-contiguous array-section that still has a base-pointer.
5948 static std::pair<const Expr *, std::optional<size_t>>
5950 OpenMPDirectiveKind CurDirKind);
5951
5952protected:
5953 // Return the total number of elements in a list of component lists.
5954 static unsigned
5956
5957 // Return the total number of elements in a list of declarations. All
5958 // declarations are expected to be canonical.
5959 static unsigned
5961};
5962
5963/// This structure contains all sizes needed for by an
5964/// OMPMappableExprListClause.
5966 /// Number of expressions listed.
5967 unsigned NumVars;
5968 /// Number of unique base declarations.
5970 /// Number of component lists.
5972 /// Total number of expression components.
5979};
5980
5981/// This represents clauses with a list of expressions that are mappable.
5982/// Examples of these clauses are 'map' in
5983/// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
5984/// in '#pragma omp target update...' directives.
5985template <class T>
5988 friend class OMPClauseReader;
5989
5990 /// Number of unique declarations in this clause.
5991 unsigned NumUniqueDeclarations;
5992
5993 /// Number of component lists in this clause.
5994 unsigned NumComponentLists;
5995
5996 /// Total number of components in this clause.
5997 unsigned NumComponents;
5998
5999 /// Whether this clause is possible to have user-defined mappers associated.
6000 /// It should be true for map, to, and from clauses, and false for
6001 /// use_device_ptr and is_device_ptr.
6002 const bool SupportsMapper;
6003
6004 /// C++ nested name specifier for the associated user-defined mapper.
6005 NestedNameSpecifierLoc MapperQualifierLoc;
6006
6007 /// The associated user-defined mapper identifier information.
6008 DeclarationNameInfo MapperIdInfo;
6009
6010protected:
6011 /// Build a clause for \a NumUniqueDeclarations declarations, \a
6012 /// NumComponentLists total component lists, and \a NumComponents total
6013 /// components.
6014 ///
6015 /// \param K Kind of the clause.
6016 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6017 /// StartLoc: starting location of the clause (the clause keyword); 2)
6018 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6019 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6020 /// NumVars: number of expressions listed in this clause; 2)
6021 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6022 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6023 /// NumComponents: total number of expression components in the clause.
6024 /// \param SupportsMapper Indicates whether this clause is possible to have
6025 /// user-defined mappers associated.
6026 /// \param MapperQualifierLocPtr C++ nested name specifier for the associated
6027 /// user-defined mapper.
6028 /// \param MapperIdInfoPtr The identifier of associated user-defined mapper.
6030 OpenMPClauseKind K, const OMPVarListLocTy &Locs,
6031 const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false,
6032 NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr,
6033 DeclarationNameInfo *MapperIdInfoPtr = nullptr)
6034 : OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc,
6035 Sizes.NumVars),
6036 NumUniqueDeclarations(Sizes.NumUniqueDeclarations),
6037 NumComponentLists(Sizes.NumComponentLists),
6038 NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) {
6039 if (MapperQualifierLocPtr)
6040 MapperQualifierLoc = *MapperQualifierLocPtr;
6041 if (MapperIdInfoPtr)
6042 MapperIdInfo = *MapperIdInfoPtr;
6043 }
6044
6045 /// Get the unique declarations that are in the trailing objects of the
6046 /// class.
6048 return static_cast<T *>(this)
6049 ->template getTrailingObjectsNonStrict<ValueDecl *>(
6050 NumUniqueDeclarations);
6051 }
6052
6053 /// Get the unique declarations that are in the trailing objects of the
6054 /// class.
6056 return static_cast<const T *>(this)
6057 ->template getTrailingObjectsNonStrict<ValueDecl *>(
6058 NumUniqueDeclarations);
6059 }
6060
6061 /// Set the unique declarations that are in the trailing objects of the
6062 /// class.
6064 assert(UDs.size() == NumUniqueDeclarations &&
6065 "Unexpected amount of unique declarations.");
6066 llvm::copy(UDs, getUniqueDeclsRef().begin());
6067 }
6068
6069 /// Get the number of lists per declaration that are in the trailing
6070 /// objects of the class.
6072 return static_cast<T *>(this)
6073 ->template getTrailingObjectsNonStrict<unsigned>(NumUniqueDeclarations);
6074 }
6075
6076 /// Get the number of lists per declaration that are in the trailing
6077 /// objects of the class.
6079 return static_cast<const T *>(this)
6080 ->template getTrailingObjectsNonStrict<unsigned>(NumUniqueDeclarations);
6081 }
6082
6083 /// Set the number of lists per declaration that are in the trailing
6084 /// objects of the class.
6086 assert(DNLs.size() == NumUniqueDeclarations &&
6087 "Unexpected amount of list numbers.");
6088 llvm::copy(DNLs, getDeclNumListsRef().begin());
6089 }
6090
6091 /// Get the cumulative component lists sizes that are in the trailing
6092 /// objects of the class. They are appended after the number of lists.
6095 static_cast<T *>(this)
6096 ->template getTrailingObjectsNonStrict<unsigned>() +
6097 NumUniqueDeclarations,
6098 NumComponentLists);
6099 }
6100
6101 /// Get the cumulative component lists sizes that are in the trailing
6102 /// objects of the class. They are appended after the number of lists.
6104 return ArrayRef<unsigned>(
6105 static_cast<const T *>(this)
6106 ->template getTrailingObjectsNonStrict<unsigned>() +
6107 NumUniqueDeclarations,
6108 NumComponentLists);
6109 }
6110
6111 /// Set the cumulative component lists sizes that are in the trailing
6112 /// objects of the class.
6114 assert(CLSs.size() == NumComponentLists &&
6115 "Unexpected amount of component lists.");
6116 llvm::copy(CLSs, getComponentListSizesRef().begin());
6117 }
6118
6119 /// Get the components that are in the trailing objects of the class.
6121 return static_cast<T *>(this)
6122 ->template getTrailingObjectsNonStrict<MappableComponent>(
6123 NumComponents);
6124 }
6125
6126 /// Get the components that are in the trailing objects of the class.
6128 return static_cast<const T *>(this)
6129 ->template getTrailingObjectsNonStrict<MappableComponent>(
6130 NumComponents);
6131 }
6132
6133 /// Set the components that are in the trailing objects of the class.
6134 /// This requires the list sizes so that it can also fill the original
6135 /// expressions, which are the first component of each list.
6137 ArrayRef<unsigned> CLSs) {
6138 assert(Components.size() == NumComponents &&
6139 "Unexpected amount of component lists.");
6140 assert(CLSs.size() == NumComponentLists &&
6141 "Unexpected amount of list sizes.");
6142 llvm::copy(Components, getComponentsRef().begin());
6143 }
6144
6145 /// Fill the clause information from the list of declarations and
6146 /// associated component lists.
6148 MappableExprComponentListsRef ComponentLists) {
6149 // Perform some checks to make sure the data sizes are consistent with the
6150 // information available when the clause was created.
6151 assert(getUniqueDeclarationsTotalNumber(Declarations) ==
6152 NumUniqueDeclarations &&
6153 "Unexpected number of mappable expression info entries!");
6154 assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
6155 "Unexpected total number of components!");
6156 assert(Declarations.size() == ComponentLists.size() &&
6157 "Declaration and component lists size is not consistent!");
6158 assert(Declarations.size() == NumComponentLists &&
6159 "Unexpected declaration and component lists size!");
6160
6161 // Organize the components by declaration and retrieve the original
6162 // expression. Original expressions are always the first component of the
6163 // mappable component list.
6164 llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
6165 ComponentListMap;
6166 {
6167 auto CI = ComponentLists.begin();
6168 for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
6169 ++DI, ++CI) {
6170 assert(!CI->empty() && "Invalid component list!");
6171 ComponentListMap[*DI].push_back(*CI);
6172 }
6173 }
6174
6175 // Iterators of the target storage.
6176 auto UniqueDeclarations = getUniqueDeclsRef();
6177 auto UDI = UniqueDeclarations.begin();
6178
6179 auto DeclNumLists = getDeclNumListsRef();
6180 auto DNLI = DeclNumLists.begin();
6181
6182 auto ComponentListSizes = getComponentListSizesRef();
6183 auto CLSI = ComponentListSizes.begin();
6184
6185 auto Components = getComponentsRef();
6186 auto CI = Components.begin();
6187
6188 // Variable to compute the accumulation of the number of components.
6189 unsigned PrevSize = 0u;
6190
6191 // Scan all the declarations and associated component lists.
6192 for (auto &M : ComponentListMap) {
6193 // The declaration.
6194 auto *D = M.first;
6195 // The component lists.
6196 auto CL = M.second;
6197
6198 // Initialize the entry.
6199 *UDI = D;
6200 ++UDI;
6201
6202 *DNLI = CL.size();
6203 ++DNLI;
6204
6205 // Obtain the cumulative sizes and concatenate all the components in the
6206 // reserved storage.
6207 for (auto C : CL) {
6208 // Accumulate with the previous size.
6209 PrevSize += C.size();
6210
6211 // Save the size.
6212 *CLSI = PrevSize;
6213 ++CLSI;
6214
6215 // Append components after the current components iterator.
6216 CI = llvm::copy(C, CI);
6217 }
6218 }
6219 }
6220
6221 /// Set the nested name specifier of associated user-defined mapper.
6223 MapperQualifierLoc = NNSL;
6224 }
6225
6226 /// Set the name of associated user-defined mapper.
6228 MapperIdInfo = MapperId;
6229 }
6230
6231 /// Get the user-defined mapper references that are in the trailing objects of
6232 /// the class.
6234 assert(SupportsMapper &&
6235 "Must be a clause that is possible to have user-defined mappers");
6237 static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
6240 }
6241
6242 /// Get the user-defined mappers references that are in the trailing objects
6243 /// of the class.
6245 assert(SupportsMapper &&
6246 "Must be a clause that is possible to have user-defined mappers");
6247 return ArrayRef<Expr *>(
6248 static_cast<const T *>(this)->template getTrailingObjects<Expr *>() +
6251 }
6252
6253 /// Set the user-defined mappers that are in the trailing objects of the
6254 /// class.
6256 assert(DMDs.size() == OMPVarListClause<T>::varlist_size() &&
6257 "Unexpected number of user-defined mappers.");
6258 assert(SupportsMapper &&
6259 "Must be a clause that is possible to have user-defined mappers");
6260 llvm::copy(DMDs, getUDMapperRefs().begin());
6261 }
6262
6263public:
6264 /// Return the number of unique base declarations in this clause.
6265 unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
6266
6267 /// Return the number of lists derived from the clause expressions.
6268 unsigned getTotalComponentListNum() const { return NumComponentLists; }
6269
6270 /// Return the total number of components in all lists derived from the
6271 /// clause.
6272 unsigned getTotalComponentsNum() const { return NumComponents; }
6273
6274 /// Gets the nested name specifier for associated user-defined mapper.
6276 return MapperQualifierLoc;
6277 }
6278
6279 /// Gets the name info for associated user-defined mapper.
6280 const DeclarationNameInfo &getMapperIdInfo() const { return MapperIdInfo; }
6281
6282 /// Iterator that browse the components by lists. It also allows
6283 /// browsing components of a single declaration.
6285 : public llvm::iterator_adaptor_base<
6286 const_component_lists_iterator,
6287 MappableExprComponentListRef::const_iterator,
6288 std::forward_iterator_tag, MappableComponent, ptrdiff_t,
6289 MappableComponent, MappableComponent> {
6290 // The declaration the iterator currently refers to.
6292
6293 // The list number associated with the current declaration.
6294 ArrayRef<unsigned>::iterator NumListsCur;
6295
6296 // Whether this clause is possible to have user-defined mappers associated.
6297 const bool SupportsMapper;
6298
6299 // The user-defined mapper associated with the current declaration.
6301
6302 // Remaining lists for the current declaration.
6303 unsigned RemainingLists = 0;
6304
6305 // The cumulative size of the previous list, or zero if there is no previous
6306 // list.
6307 unsigned PrevListSize = 0;
6308
6309 // The cumulative sizes of the current list - it will delimit the remaining
6310 // range of interest.
6313
6314 // Iterator to the end of the components storage.
6315 MappableExprComponentListRef::const_iterator End;
6316
6317 public:
6318 /// Construct an iterator that scans all lists.
6320 ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
6321 ArrayRef<unsigned> CumulativeListSizes,
6322 MappableExprComponentListRef Components, bool SupportsMapper,
6323 ArrayRef<Expr *> Mappers)
6324 : const_component_lists_iterator::iterator_adaptor_base(
6325 Components.begin()),
6326 DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
6327 SupportsMapper(SupportsMapper),
6328 ListSizeCur(CumulativeListSizes.begin()),
6329 ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
6330 assert(UniqueDecls.size() == DeclsListNum.size() &&
6331 "Inconsistent number of declarations and list sizes!");
6332 if (!DeclsListNum.empty())
6333 RemainingLists = *NumListsCur;
6334 if (SupportsMapper)
6335 MapperCur = Mappers.begin();
6336 }
6337
6338 /// Construct an iterator that scan lists for a given declaration \a
6339 /// Declaration.
6341 const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
6342 ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
6343 MappableExprComponentListRef Components, bool SupportsMapper,
6344 ArrayRef<Expr *> Mappers)
6345 : const_component_lists_iterator(UniqueDecls, DeclsListNum,
6346 CumulativeListSizes, Components,
6347 SupportsMapper, Mappers) {
6348 // Look for the desired declaration. While we are looking for it, we
6349 // update the state so that we know the component where a given list
6350 // starts.
6351 for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
6352 if (*DeclCur == Declaration)
6353 break;
6354
6355 assert(*NumListsCur > 0 && "No lists associated with declaration??");
6356
6357 // Skip the lists associated with the current declaration, but save the
6358 // last list size that was skipped.
6359 std::advance(ListSizeCur, *NumListsCur - 1);
6360 PrevListSize = *ListSizeCur;
6361 ++ListSizeCur;
6362
6363 if (SupportsMapper)
6364 ++MapperCur;
6365 }
6366
6367 // If we didn't find any declaration, advance the iterator to after the
6368 // last component and set remaining lists to zero.
6369 if (ListSizeCur == CumulativeListSizes.end()) {
6370 this->I = End;
6371 RemainingLists = 0u;
6372 return;
6373 }
6374
6375 // Set the remaining lists with the total number of lists of the current
6376 // declaration.
6377 RemainingLists = *NumListsCur;
6378
6379 // Adjust the list size end iterator to the end of the relevant range.
6380 ListSizeEnd = ListSizeCur;
6381 std::advance(ListSizeEnd, RemainingLists);
6382
6383 // Given that the list sizes are cumulative, the index of the component
6384 // that start the list is the size of the previous list.
6385 std::advance(this->I, PrevListSize);
6386 }
6387
6388 // Return the array with the current list. The sizes are cumulative, so the
6389 // array size is the difference between the current size and previous one.
6390 std::tuple<const ValueDecl *, MappableExprComponentListRef,
6391 const ValueDecl *>
6392 operator*() const {
6393 assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
6394 const ValueDecl *Mapper = nullptr;
6395 if (SupportsMapper && *MapperCur)
6396 Mapper = cast<ValueDecl>(cast<DeclRefExpr>(*MapperCur)->getDecl());
6397 return std::make_tuple(
6398 *DeclCur,
6399 MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize),
6400 Mapper);
6401 }
6402 std::tuple<const ValueDecl *, MappableExprComponentListRef,
6403 const ValueDecl *>
6404 operator->() const {
6405 return **this;
6406 }
6407
6408 // Skip the components of the current list.
6410 assert(ListSizeCur != ListSizeEnd && RemainingLists &&
6411 "Invalid iterator!");
6412
6413 // If we don't have more lists just skip all the components. Otherwise,
6414 // advance the iterator by the number of components in the current list.
6415 if (std::next(ListSizeCur) == ListSizeEnd) {
6416 this->I = End;
6417 RemainingLists = 0;
6418 } else {
6419 std::advance(this->I, *ListSizeCur - PrevListSize);
6420 PrevListSize = *ListSizeCur;
6421
6422 // We are done with a declaration, move to the next one.
6423 if (!(--RemainingLists)) {
6424 ++DeclCur;
6425 ++NumListsCur;
6426 RemainingLists = *NumListsCur;
6427 assert(RemainingLists && "No lists in the following declaration??");
6428 }
6429 }
6430
6431 ++ListSizeCur;
6432 if (SupportsMapper)
6433 ++MapperCur;
6434 return *this;
6435 }
6436 };
6437
6439 llvm::iterator_range<const_component_lists_iterator>;
6440
6441 /// Iterators for all component lists.
6458
6459 /// Iterators for component lists associated with the provided
6460 /// declaration.
6461 const_component_lists_iterator
6465 getComponentListSizesRef(), getComponentsRef(), SupportsMapper,
6466 SupportsMapper ? getUDMapperRefs() : ArrayRef<Expr *>());
6467 }
6474
6475 /// Iterators to access all the declarations, number of lists, list sizes, and
6476 /// components.
6478 using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>;
6479
6481
6484 llvm::iterator_range<const_all_num_lists_iterator>;
6485
6489
6492 llvm::iterator_range<const_all_lists_sizes_iterator>;
6493
6497
6500 llvm::iterator_range<const_all_components_iterator>;
6501
6505
6508 using mapperlist_range = llvm::iterator_range<mapperlist_iterator>;
6510 llvm::iterator_range<mapperlist_const_iterator>;
6511
6515 return getUDMapperRefs().begin();
6516 }
6518 return getUDMapperRefs().end();
6519 }
6526};
6527
6528/// This represents clause 'map' in the '#pragma omp ...'
6529/// directives.
6530///
6531/// \code
6532/// #pragma omp target map(a,b)
6533/// \endcode
6534/// In this example directive '#pragma omp target' has clause 'map'
6535/// with the variables 'a' and 'b'.
6536class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
6537 private llvm::TrailingObjects<
6538 OMPMapClause, Expr *, ValueDecl *, unsigned,
6539 OMPClauseMappableExprCommon::MappableComponent> {
6540 friend class OMPClauseReader;
6541 friend OMPMappableExprListClause;
6542 friend OMPVarListClause;
6543 friend TrailingObjects;
6544
6545 /// Define the sizes of each trailing object array except the last one. This
6546 /// is required for TrailingObjects to work properly.
6547 size_t numTrailingObjects(OverloadToken<Expr *>) const {
6548 // There are varlist_size() of expressions, and varlist_size() of
6549 // user-defined mappers.
6550 return 2 * varlist_size() + 1;
6551 }
6552 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
6553 return getUniqueDeclarationsNum();
6554 }
6555 size_t numTrailingObjects(OverloadToken<unsigned>) const {
6557 }
6558
6559private:
6560 /// Map-type-modifiers for the 'map' clause.
6566
6567 /// Location of map-type-modifiers for the 'map' clause.
6568 SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers];
6569
6570 /// Map type for the 'map' clause.
6572
6573 /// Is this an implicit map type or not.
6574 bool MapTypeIsImplicit = false;
6575
6576 /// Location of the map type.
6577 SourceLocation MapLoc;
6578
6579 /// Colon location.
6580 SourceLocation ColonLoc;
6581
6582 /// Build a clause for \a NumVars listed expressions, \a
6583 /// NumUniqueDeclarations declarations, \a NumComponentLists total component
6584 /// lists, and \a NumComponents total expression components.
6585 ///
6586 /// \param MapModifiers Map-type-modifiers.
6587 /// \param MapModifiersLoc Locations of map-type-modifiers.
6588 /// \param MapperQualifierLoc C++ nested name specifier for the associated
6589 /// user-defined mapper.
6590 /// \param MapperIdInfo The identifier of associated user-defined mapper.
6591 /// \param MapType Map type.
6592 /// \param MapTypeIsImplicit Map type is inferred implicitly.
6593 /// \param MapLoc Location of the map type.
6594 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6595 /// StartLoc: starting location of the clause (the clause keyword); 2)
6596 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6597 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6598 /// NumVars: number of expressions listed in this clause; 2)
6599 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6600 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6601 /// NumComponents: total number of expression components in the clause.
6602 explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers,
6603 ArrayRef<SourceLocation> MapModifiersLoc,
6604 NestedNameSpecifierLoc MapperQualifierLoc,
6605 DeclarationNameInfo MapperIdInfo,
6606 OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
6607 SourceLocation MapLoc, const OMPVarListLocTy &Locs,
6608 const OMPMappableExprListSizeTy &Sizes)
6609 : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes,
6610 /*SupportsMapper=*/true, &MapperQualifierLoc,
6611 &MapperIdInfo),
6612 MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {
6613 assert(std::size(MapTypeModifiers) == MapModifiers.size() &&
6614 "Unexpected number of map type modifiers.");
6615 llvm::copy(MapModifiers, std::begin(MapTypeModifiers));
6616
6617 assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() &&
6618 "Unexpected number of map type modifier locations.");
6619 llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc));
6620 }
6621
6622 /// Build an empty clause.
6623 ///
6624 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6625 /// NumVars: number of expressions listed in this clause; 2)
6626 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6627 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6628 /// NumComponents: total number of expression components in the clause.
6629 explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes)
6630 : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes,
6631 /*SupportsMapper=*/true) {}
6632
6633 /// Set map-type-modifier for the clause.
6634 ///
6635 /// \param I index for map-type-modifier.
6636 /// \param T map-type-modifier for the clause.
6637 void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) {
6638 assert(I < NumberOfOMPMapClauseModifiers &&
6639 "Unexpected index to store map type modifier, exceeds array size.");
6640 MapTypeModifiers[I] = T;
6641 }
6642
6643 /// Set location for the map-type-modifier.
6644 ///
6645 /// \param I index for map-type-modifier location.
6646 /// \param TLoc map-type-modifier location.
6647 void setMapTypeModifierLoc(unsigned I, SourceLocation TLoc) {
6648 assert(I < NumberOfOMPMapClauseModifiers &&
6649 "Index to store map type modifier location exceeds array size.");
6650 MapTypeModifiersLoc[I] = TLoc;
6651 }
6652
6653 /// Set type for the clause.
6654 ///
6655 /// \param T Type for the clause.
6656 void setMapType(OpenMPMapClauseKind T) { MapType = T; }
6657
6658 /// Set type location.
6659 ///
6660 /// \param TLoc Type location.
6661 void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
6662
6663 /// Set colon location.
6664 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
6665
6666 /// Set iterator modifier.
6667 void setIteratorModifier(Expr *IteratorModifier) {
6668 getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier;
6669 }
6670
6671public:
6672 /// Creates clause with a list of variables \a VL.
6673 ///
6674 /// \param C AST context.
6675 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6676 /// StartLoc: starting location of the clause (the clause keyword); 2)
6677 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6678 /// \param Vars The original expression used in the clause.
6679 /// \param Declarations Declarations used in the clause.
6680 /// \param ComponentLists Component lists used in the clause.
6681 /// \param UDMapperRefs References to user-defined mappers associated with
6682 /// expressions used in the clause.
6683 /// \param IteratorModifier Iterator modifier.
6684 /// \param MapModifiers Map-type-modifiers.
6685 /// \param MapModifiersLoc Location of map-type-modifiers.
6686 /// \param UDMQualifierLoc C++ nested name specifier for the associated
6687 /// user-defined mapper.
6688 /// \param MapperId The identifier of associated user-defined mapper.
6689 /// \param Type Map type.
6690 /// \param TypeIsImplicit Map type is inferred implicitly.
6691 /// \param TypeLoc Location of the map type.
6692 static OMPMapClause *
6693 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
6694 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
6695 MappableExprComponentListsRef ComponentLists,
6696 ArrayRef<Expr *> UDMapperRefs, Expr *IteratorModifier,
6697 ArrayRef<OpenMPMapModifierKind> MapModifiers,
6698 ArrayRef<SourceLocation> MapModifiersLoc,
6699 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
6700 OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc);
6701
6702 /// Creates an empty clause with the place for \a NumVars original
6703 /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
6704 /// lists, and \a NumComponents expression components.
6705 ///
6706 /// \param C AST context.
6707 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6708 /// NumVars: number of expressions listed in this clause; 2)
6709 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6710 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6711 /// NumComponents: total number of expression components in the clause.
6712 static OMPMapClause *CreateEmpty(const ASTContext &C,
6713 const OMPMappableExprListSizeTy &Sizes);
6714
6715 /// Fetches Expr * of iterator modifier.
6717 return getTrailingObjects<Expr *>()[2 * varlist_size()];
6718 }
6719
6720 /// Fetches mapping kind for the clause.
6721 OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
6722
6723 /// Is this an implicit map type?
6724 /// We have to capture 'IsMapTypeImplicit' from the parser for more
6725 /// informative error messages. It helps distinguish map(r) from
6726 /// map(tofrom: r), which is important to print more helpful error
6727 /// messages for some target directives.
6728 bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
6729
6730 /// Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
6731 ///
6732 /// \param Cnt index for map-type-modifier.
6733 OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY {
6734 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6735 "Requested modifier exceeds the total number of modifiers.");
6736 return MapTypeModifiers[Cnt];
6737 }
6738
6739 /// Fetches the map-type-modifier location at 'Cnt' index of array of
6740 /// modifiers' locations.
6741 ///
6742 /// \param Cnt index for map-type-modifier location.
6743 SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY {
6744 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6745 "Requested modifier location exceeds total number of modifiers.");
6746 return MapTypeModifiersLoc[Cnt];
6747 }
6748
6749 /// Fetches ArrayRef of map-type-modifiers.
6751 return MapTypeModifiers;
6752 }
6753
6754 /// Fetches ArrayRef of location of map-type-modifiers.
6756 return MapTypeModifiersLoc;
6757 }
6758
6759 /// Fetches location of clause mapping kind.
6760 SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
6761
6762 /// Get colon location.
6763 SourceLocation getColonLoc() const { return ColonLoc; }
6764
6766 return child_range(
6767 reinterpret_cast<Stmt **>(varlist_begin()),
6768 reinterpret_cast<Stmt **>(varlist_end()));
6769 }
6770
6772 return const_cast<OMPMapClause *>(this)->children();
6773 }
6774
6776 if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom)
6777 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6778 reinterpret_cast<Stmt **>(varlist_end()));
6780 }
6782 return const_cast<OMPMapClause *>(this)->used_children();
6783 }
6784
6785
6786 static bool classof(const OMPClause *T) {
6787 return T->getClauseKind() == llvm::omp::OMPC_map;
6788 }
6789};
6790
6791/// This represents 'num_teams' clause in the '#pragma omp ...'
6792/// directive.
6793///
6794/// \code
6795/// #pragma omp teams num_teams(n)
6796/// \endcode
6797/// In this example directive '#pragma omp teams' has clause 'num_teams'
6798/// with single expression 'n'.
6799///
6800/// When 'ompx_bare' clause exists on a 'target' directive, 'num_teams' clause
6801/// can accept up to three expressions.
6802///
6803/// \code
6804/// #pragma omp target teams ompx_bare num_teams(x, y, z)
6805/// \endcode
6806class OMPNumTeamsClause final
6807 : public OMPVarListClause<OMPNumTeamsClause>,
6808 public OMPClauseWithPreInit,
6809 private llvm::TrailingObjects<OMPNumTeamsClause, Expr *> {
6810 friend OMPVarListClause;
6811 friend TrailingObjects;
6812
6813 /// Location of '('.
6814 SourceLocation LParenLoc;
6815
6816 OMPNumTeamsClause(const ASTContext &C, SourceLocation StartLoc,
6817 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
6818 : OMPVarListClause(llvm::omp::OMPC_num_teams, StartLoc, LParenLoc, EndLoc,
6819 N),
6820 OMPClauseWithPreInit(this) {}
6821
6822 /// Build an empty clause.
6823 OMPNumTeamsClause(unsigned N)
6824 : OMPVarListClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6826 OMPClauseWithPreInit(this) {}
6827
6828public:
6829 /// Creates clause with a list of variables \a VL.
6830 ///
6831 /// \param C AST context.
6832 /// \param StartLoc Starting location of the clause.
6833 /// \param LParenLoc Location of '('.
6834 /// \param EndLoc Ending location of the clause.
6835 /// \param VL List of references to the variables.
6836 /// \param PreInit
6837 static OMPNumTeamsClause *
6838 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6839 SourceLocation StartLoc, SourceLocation LParenLoc,
6840 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6841
6842 /// Creates an empty clause with \a N variables.
6843 ///
6844 /// \param C AST context.
6845 /// \param N The number of variables.
6846 static OMPNumTeamsClause *CreateEmpty(const ASTContext &C, unsigned N);
6847
6848 /// Sets the location of '('.
6849 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6850
6851 /// Returns the location of '('.
6852 SourceLocation getLParenLoc() const { return LParenLoc; }
6853
6854 /// Return NumTeams expressions.
6856
6857 /// Return NumTeams expressions.
6859 return const_cast<OMPNumTeamsClause *>(this)->getNumTeams();
6860 }
6861
6863 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6864 reinterpret_cast<Stmt **>(varlist_end()));
6865 }
6866
6868 return const_cast<OMPNumTeamsClause *>(this)->children();
6869 }
6870
6877
6878 static bool classof(const OMPClause *T) {
6879 return T->getClauseKind() == llvm::omp::OMPC_num_teams;
6880 }
6881};
6882
6883/// This represents 'thread_limit' clause in the '#pragma omp ...'
6884/// directive.
6885///
6886/// \code
6887/// #pragma omp teams thread_limit(n)
6888/// \endcode
6889/// In this example directive '#pragma omp teams' has clause 'thread_limit'
6890/// with single expression 'n'.
6891///
6892/// When 'ompx_bare' clause exists on a 'target' directive, 'thread_limit'
6893/// clause can accept up to three expressions.
6894///
6895/// \code
6896/// #pragma omp target teams ompx_bare thread_limit(x, y, z)
6897/// \endcode
6898class OMPThreadLimitClause final
6899 : public OMPVarListClause<OMPThreadLimitClause>,
6900 public OMPClauseWithPreInit,
6901 private llvm::TrailingObjects<OMPThreadLimitClause, Expr *> {
6902 friend OMPVarListClause;
6903 friend TrailingObjects;
6904
6905 /// Location of '('.
6906 SourceLocation LParenLoc;
6907
6908 OMPThreadLimitClause(const ASTContext &C, SourceLocation StartLoc,
6909 SourceLocation LParenLoc, SourceLocation EndLoc,
6910 unsigned N)
6911 : OMPVarListClause(llvm::omp::OMPC_thread_limit, StartLoc, LParenLoc,
6912 EndLoc, N),
6913 OMPClauseWithPreInit(this) {}
6914
6915 /// Build an empty clause.
6916 OMPThreadLimitClause(unsigned N)
6917 : OMPVarListClause(llvm::omp::OMPC_thread_limit, SourceLocation(),
6919 OMPClauseWithPreInit(this) {}
6920
6921public:
6922 /// Creates clause with a list of variables \a VL.
6923 ///
6924 /// \param C AST context.
6925 /// \param StartLoc Starting location of the clause.
6926 /// \param LParenLoc Location of '('.
6927 /// \param EndLoc Ending location of the clause.
6928 /// \param VL List of references to the variables.
6929 /// \param PreInit
6930 static OMPThreadLimitClause *
6931 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6932 SourceLocation StartLoc, SourceLocation LParenLoc,
6933 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6934
6935 /// Creates an empty clause with \a N variables.
6936 ///
6937 /// \param C AST context.
6938 /// \param N The number of variables.
6939 static OMPThreadLimitClause *CreateEmpty(const ASTContext &C, unsigned N);
6940
6941 /// Sets the location of '('.
6942 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6943
6944 /// Returns the location of '('.
6945 SourceLocation getLParenLoc() const { return LParenLoc; }
6946
6947 /// Return ThreadLimit expressions.
6949
6950 /// Return ThreadLimit expressions.
6952 return const_cast<OMPThreadLimitClause *>(this)->getThreadLimit();
6953 }
6954
6956 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6957 reinterpret_cast<Stmt **>(varlist_end()));
6958 }
6959
6961 return const_cast<OMPThreadLimitClause *>(this)->children();
6962 }
6963
6970
6971 static bool classof(const OMPClause *T) {
6972 return T->getClauseKind() == llvm::omp::OMPC_thread_limit;
6973 }
6974};
6975
6976/// This represents 'priority' clause in the '#pragma omp ...'
6977/// directive.
6978///
6979/// \code
6980/// #pragma omp task priority(n)
6981/// \endcode
6982/// In this example directive '#pragma omp teams' has clause 'priority' with
6983/// single expression 'n'.
6985 friend class OMPClauseReader;
6986
6987 /// Location of '('.
6988 SourceLocation LParenLoc;
6989
6990 /// Priority number.
6991 Stmt *Priority = nullptr;
6992
6993 /// Set the Priority number.
6994 ///
6995 /// \param E Priority number.
6996 void setPriority(Expr *E) { Priority = E; }
6997
6998public:
6999 /// Build 'priority' clause.
7000 ///
7001 /// \param Priority Expression associated with this clause.
7002 /// \param HelperPriority Helper priority for the construct.
7003 /// \param CaptureRegion Innermost OpenMP region where expressions in this
7004 /// clause must be captured.
7005 /// \param StartLoc Starting location of the clause.
7006 /// \param LParenLoc Location of '('.
7007 /// \param EndLoc Ending location of the clause.
7008 OMPPriorityClause(Expr *Priority, Stmt *HelperPriority,
7009 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
7010 SourceLocation LParenLoc, SourceLocation EndLoc)
7011 : OMPClause(llvm::omp::OMPC_priority, StartLoc, EndLoc),
7012 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Priority(Priority) {
7013 setPreInitStmt(HelperPriority, CaptureRegion);
7014 }
7015
7016 /// Build an empty clause.
7018 : OMPClause(llvm::omp::OMPC_priority, SourceLocation(), SourceLocation()),
7019 OMPClauseWithPreInit(this) {}
7020
7021 /// Sets the location of '('.
7022 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7023
7024 /// Returns the location of '('.
7025 SourceLocation getLParenLoc() const { return LParenLoc; }
7026
7027 /// Return Priority number.
7028 Expr *getPriority() { return cast<Expr>(Priority); }
7029
7030 /// Return Priority number.
7031 Expr *getPriority() const { return cast<Expr>(Priority); }
7032
7033 child_range children() { return child_range(&Priority, &Priority + 1); }
7034
7036 return const_child_range(&Priority, &Priority + 1);
7037 }
7038
7041 return const_cast<OMPPriorityClause *>(this)->used_children();
7042 }
7043
7044 static bool classof(const OMPClause *T) {
7045 return T->getClauseKind() == llvm::omp::OMPC_priority;
7046 }
7047};
7048
7049/// This represents 'grainsize' clause in the '#pragma omp ...'
7050/// directive.
7051///
7052/// \code
7053/// #pragma omp taskloop grainsize(4)
7054/// \endcode
7055/// In this example directive '#pragma omp taskloop' has clause 'grainsize'
7056/// with single expression '4'.
7058 friend class OMPClauseReader;
7059
7060 /// Location of '('.
7061 SourceLocation LParenLoc;
7062
7063 /// Modifiers for 'grainsize' clause.
7065
7066 /// Location of the modifier.
7067 SourceLocation ModifierLoc;
7068
7069 /// Safe iteration space distance.
7070 Stmt *Grainsize = nullptr;
7071
7072 /// Set safelen.
7073 void setGrainsize(Expr *Size) { Grainsize = Size; }
7074
7075 /// Sets modifier.
7076 void setModifier(OpenMPGrainsizeClauseModifier M) { Modifier = M; }
7077
7078 /// Sets modifier location.
7079 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
7080
7081public:
7082 /// Build 'grainsize' clause.
7083 ///
7084 /// \param Modifier Clause modifier.
7085 /// \param Size Expression associated with this clause.
7086 /// \param HelperSize Helper grainsize for the construct.
7087 /// \param CaptureRegion Innermost OpenMP region where expressions in this
7088 /// clause must be captured.
7089 /// \param StartLoc Starting location of the clause.
7090 /// \param ModifierLoc Modifier location.
7091 /// \param LParenLoc Location of '('.
7092 /// \param EndLoc Ending location of the clause.
7094 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
7095 SourceLocation StartLoc, SourceLocation LParenLoc,
7096 SourceLocation ModifierLoc, SourceLocation EndLoc)
7097 : OMPClause(llvm::omp::OMPC_grainsize, StartLoc, EndLoc),
7098 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
7099 ModifierLoc(ModifierLoc), Grainsize(Size) {
7100 setPreInitStmt(HelperSize, CaptureRegion);
7101 }
7102
7103 /// Build an empty clause.
7105 : OMPClause(llvm::omp::OMPC_grainsize, SourceLocation(),
7106 SourceLocation()),
7107 OMPClauseWithPreInit(this) {}
7108
7109 /// Sets the location of '('.
7110 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7111
7112 /// Returns the location of '('.
7113 SourceLocation getLParenLoc() const { return LParenLoc; }
7114
7115 /// Return safe iteration space distance.
7116 Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
7117
7118 /// Gets modifier.
7119 OpenMPGrainsizeClauseModifier getModifier() const { return Modifier; }
7120
7121 /// Gets modifier location.
7122 SourceLocation getModifierLoc() const { return ModifierLoc; }
7123
7124 child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
7125
7127 return const_child_range(&Grainsize, &Grainsize + 1);
7128 }
7129
7132 return const_cast<OMPGrainsizeClause *>(this)->used_children();
7133 }
7134
7135 static bool classof(const OMPClause *T) {
7136 return T->getClauseKind() == llvm::omp::OMPC_grainsize;
7137 }
7138};
7139
7140/// This represents 'nogroup' clause in the '#pragma omp ...' directive.
7141///
7142/// \code
7143/// #pragma omp taskloop nogroup
7144/// \endcode
7145/// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
7147public:
7148 /// Build 'nogroup' clause.
7149 ///
7150 /// \param StartLoc Starting location of the clause.
7151 /// \param EndLoc Ending location of the clause.
7153 : OMPClause(llvm::omp::OMPC_nogroup, StartLoc, EndLoc) {}
7154
7155 /// Build an empty clause.
7157 : OMPClause(llvm::omp::OMPC_nogroup, SourceLocation(), SourceLocation()) {
7158 }
7159
7163
7167
7174
7175 static bool classof(const OMPClause *T) {
7176 return T->getClauseKind() == llvm::omp::OMPC_nogroup;
7177 }
7178};
7179
7180/// This represents 'num_tasks' clause in the '#pragma omp ...'
7181/// directive.
7182///
7183/// \code
7184/// #pragma omp taskloop num_tasks(4)
7185/// \endcode
7186/// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
7187/// with single expression '4'.
7189 friend class OMPClauseReader;
7190
7191 /// Location of '('.
7192 SourceLocation LParenLoc;
7193
7194 /// Modifiers for 'num_tasks' clause.
7196
7197 /// Location of the modifier.
7198 SourceLocation ModifierLoc;
7199
7200 /// Safe iteration space distance.
7201 Stmt *NumTasks = nullptr;
7202
7203 /// Set safelen.
7204 void setNumTasks(Expr *Size) { NumTasks = Size; }
7205
7206 /// Sets modifier.
7207 void setModifier(OpenMPNumTasksClauseModifier M) { Modifier = M; }
7208
7209 /// Sets modifier location.
7210 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
7211
7212public:
7213 /// Build 'num_tasks' clause.
7214 ///
7215 /// \param Modifier Clause modifier.
7216 /// \param Size Expression associated with this clause.
7217 /// \param HelperSize Helper grainsize for the construct.
7218 /// \param CaptureRegion Innermost OpenMP region where expressions in this
7219 /// clause must be captured.
7220 /// \param StartLoc Starting location of the clause.
7221 /// \param EndLoc Ending location of the clause.
7222 /// \param ModifierLoc Modifier location.
7223 /// \param LParenLoc Location of '('.
7225 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
7226 SourceLocation StartLoc, SourceLocation LParenLoc,
7227 SourceLocation ModifierLoc, SourceLocation EndLoc)
7228 : OMPClause(llvm::omp::OMPC_num_tasks, StartLoc, EndLoc),
7229 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
7230 ModifierLoc(ModifierLoc), NumTasks(Size) {
7231 setPreInitStmt(HelperSize, CaptureRegion);
7232 }
7233
7234 /// Build an empty clause.
7236 : OMPClause(llvm::omp::OMPC_num_tasks, SourceLocation(),
7237 SourceLocation()),
7238 OMPClauseWithPreInit(this) {}
7239
7240 /// Sets the location of '('.
7241 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7242
7243 /// Returns the location of '('.
7244 SourceLocation getLParenLoc() const { return LParenLoc; }
7245
7246 /// Return safe iteration space distance.
7247 Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
7248
7249 /// Gets modifier.
7250 OpenMPNumTasksClauseModifier getModifier() const { return Modifier; }
7251
7252 /// Gets modifier location.
7253 SourceLocation getModifierLoc() const { return ModifierLoc; }
7254
7255 child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
7256
7258 return const_child_range(&NumTasks, &NumTasks + 1);
7259 }
7260
7263 return const_cast<OMPNumTasksClause *>(this)->used_children();
7264 }
7265
7266 static bool classof(const OMPClause *T) {
7267 return T->getClauseKind() == llvm::omp::OMPC_num_tasks;
7268 }
7269};
7270
7271/// This represents 'hint' clause in the '#pragma omp ...' directive.
7272///
7273/// \code
7274/// #pragma omp critical (name) hint(6)
7275/// \endcode
7276/// In this example directive '#pragma omp critical' has name 'name' and clause
7277/// 'hint' with argument '6'.
7278class OMPHintClause : public OMPClause {
7279 friend class OMPClauseReader;
7280
7281 /// Location of '('.
7282 SourceLocation LParenLoc;
7283
7284 /// Hint expression of the 'hint' clause.
7285 Stmt *Hint = nullptr;
7286
7287 /// Set hint expression.
7288 void setHint(Expr *H) { Hint = H; }
7289
7290public:
7291 /// Build 'hint' clause with expression \a Hint.
7292 ///
7293 /// \param Hint Hint expression.
7294 /// \param StartLoc Starting location of the clause.
7295 /// \param LParenLoc Location of '('.
7296 /// \param EndLoc Ending location of the clause.
7298 SourceLocation EndLoc)
7299 : OMPClause(llvm::omp::OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
7300 Hint(Hint) {}
7301
7302 /// Build an empty clause.
7304 : OMPClause(llvm::omp::OMPC_hint, SourceLocation(), SourceLocation()) {}
7305
7306 /// Sets the location of '('.
7307 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7308
7309 /// Returns the location of '('.
7310 SourceLocation getLParenLoc() const { return LParenLoc; }
7311
7312 /// Returns number of threads.
7313 Expr *getHint() const { return cast_or_null<Expr>(Hint); }
7314
7315 child_range children() { return child_range(&Hint, &Hint + 1); }
7316
7318 return const_child_range(&Hint, &Hint + 1);
7319 }
7320
7327
7328 static bool classof(const OMPClause *T) {
7329 return T->getClauseKind() == llvm::omp::OMPC_hint;
7330 }
7331};
7332
7333/// This represents 'dist_schedule' clause in the '#pragma omp ...'
7334/// directive.
7335///
7336/// \code
7337/// #pragma omp distribute dist_schedule(static, 3)
7338/// \endcode
7339/// In this example directive '#pragma omp distribute' has 'dist_schedule'
7340/// clause with arguments 'static' and '3'.
7342 friend class OMPClauseReader;
7343
7344 /// Location of '('.
7345 SourceLocation LParenLoc;
7346
7347 /// A kind of the 'schedule' clause.
7349
7350 /// Start location of the schedule kind in source code.
7351 SourceLocation KindLoc;
7352
7353 /// Location of ',' (if any).
7354 SourceLocation CommaLoc;
7355
7356 /// Chunk size.
7357 Expr *ChunkSize = nullptr;
7358
7359 /// Set schedule kind.
7360 ///
7361 /// \param K Schedule kind.
7362 void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
7363
7364 /// Sets the location of '('.
7365 ///
7366 /// \param Loc Location of '('.
7367 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7368
7369 /// Set schedule kind start location.
7370 ///
7371 /// \param KLoc Schedule kind location.
7372 void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
7373
7374 /// Set location of ','.
7375 ///
7376 /// \param Loc Location of ','.
7377 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
7378
7379 /// Set chunk size.
7380 ///
7381 /// \param E Chunk size.
7382 void setChunkSize(Expr *E) { ChunkSize = E; }
7383
7384public:
7385 /// Build 'dist_schedule' clause with schedule kind \a Kind and chunk
7386 /// size expression \a ChunkSize.
7387 ///
7388 /// \param StartLoc Starting location of the clause.
7389 /// \param LParenLoc Location of '('.
7390 /// \param KLoc Starting location of the argument.
7391 /// \param CommaLoc Location of ','.
7392 /// \param EndLoc Ending location of the clause.
7393 /// \param Kind DistSchedule kind.
7394 /// \param ChunkSize Chunk size.
7395 /// \param HelperChunkSize Helper chunk size for combined directives.
7397 SourceLocation KLoc, SourceLocation CommaLoc,
7398 SourceLocation EndLoc,
7399 OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
7400 Stmt *HelperChunkSize)
7401 : OMPClause(llvm::omp::OMPC_dist_schedule, StartLoc, EndLoc),
7402 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
7403 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
7404 setPreInitStmt(HelperChunkSize);
7405 }
7406
7407 /// Build an empty clause.
7409 : OMPClause(llvm::omp::OMPC_dist_schedule, SourceLocation(),
7410 SourceLocation()),
7411 OMPClauseWithPreInit(this) {}
7412
7413 /// Get kind of the clause.
7415
7416 /// Get location of '('.
7417 SourceLocation getLParenLoc() { return LParenLoc; }
7418
7419 /// Get kind location.
7421
7422 /// Get location of ','.
7423 SourceLocation getCommaLoc() { return CommaLoc; }
7424
7425 /// Get chunk size.
7426 Expr *getChunkSize() { return ChunkSize; }
7427
7428 /// Get chunk size.
7429 const Expr *getChunkSize() const { return ChunkSize; }
7430
7432 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
7433 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
7434 }
7435
7437 return const_cast<OMPDistScheduleClause *>(this)->children();
7438 }
7439
7446
7447 static bool classof(const OMPClause *T) {
7448 return T->getClauseKind() == llvm::omp::OMPC_dist_schedule;
7449 }
7450};
7451
7452/// This represents 'defaultmap' clause in the '#pragma omp ...' directive.
7453///
7454/// \code
7455/// #pragma omp target defaultmap(tofrom: scalar)
7456/// \endcode
7457/// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
7458/// 'scalar' with modifier 'tofrom'.
7460 friend class OMPClauseReader;
7461
7462 /// Location of '('.
7463 SourceLocation LParenLoc;
7464
7465 /// Modifiers for 'defaultmap' clause.
7467
7468 /// Locations of modifiers.
7469 SourceLocation ModifierLoc;
7470
7471 /// A kind of the 'defaultmap' clause.
7473
7474 /// Start location of the defaultmap kind in source code.
7475 SourceLocation KindLoc;
7476
7477 /// Set defaultmap kind.
7478 ///
7479 /// \param K Defaultmap kind.
7480 void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
7481
7482 /// Set the defaultmap modifier.
7483 ///
7484 /// \param M Defaultmap modifier.
7485 void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
7486 Modifier = M;
7487 }
7488
7489 /// Set location of the defaultmap modifier.
7490 void setDefaultmapModifierLoc(SourceLocation Loc) {
7491 ModifierLoc = Loc;
7492 }
7493
7494 /// Sets the location of '('.
7495 ///
7496 /// \param Loc Location of '('.
7497 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7498
7499 /// Set defaultmap kind start location.
7500 ///
7501 /// \param KLoc Defaultmap kind location.
7502 void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
7503
7504public:
7505 /// Build 'defaultmap' clause with defaultmap kind \a Kind
7506 ///
7507 /// \param StartLoc Starting location of the clause.
7508 /// \param LParenLoc Location of '('.
7509 /// \param KLoc Starting location of the argument.
7510 /// \param EndLoc Ending location of the clause.
7511 /// \param Kind Defaultmap kind.
7512 /// \param M The modifier applied to 'defaultmap' clause.
7513 /// \param MLoc Location of the modifier
7515 SourceLocation MLoc, SourceLocation KLoc,
7518 : OMPClause(llvm::omp::OMPC_defaultmap, StartLoc, EndLoc),
7519 LParenLoc(LParenLoc), Modifier(M), ModifierLoc(MLoc), Kind(Kind),
7520 KindLoc(KLoc) {}
7521
7522 /// Build an empty clause.
7524 : OMPClause(llvm::omp::OMPC_defaultmap, SourceLocation(),
7525 SourceLocation()) {}
7526
7527 /// Get kind of the clause.
7529
7530 /// Get the modifier of the clause.
7532 return Modifier;
7533 }
7534
7535 /// Get location of '('.
7536 SourceLocation getLParenLoc() { return LParenLoc; }
7537
7538 /// Get kind location.
7540
7541 /// Get the modifier location.
7543 return ModifierLoc;
7544 }
7545
7549
7553
7560
7561 static bool classof(const OMPClause *T) {
7562 return T->getClauseKind() == llvm::omp::OMPC_defaultmap;
7563 }
7564};
7565
7566/// This represents clause 'to' in the '#pragma omp ...'
7567/// directives.
7568///
7569/// \code
7570/// #pragma omp target update to(a,b)
7571/// \endcode
7572/// In this example directive '#pragma omp target update' has clause 'to'
7573/// with the variables 'a' and 'b'.
7574class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
7575 private llvm::TrailingObjects<
7576 OMPToClause, Expr *, ValueDecl *, unsigned,
7577 OMPClauseMappableExprCommon::MappableComponent> {
7578 friend class OMPClauseReader;
7579 friend OMPMappableExprListClause;
7580 friend OMPVarListClause;
7581 friend TrailingObjects;
7582
7583 /// Motion-modifiers for the 'to' clause.
7587
7588 /// Location of motion-modifiers for the 'to' clause.
7589 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7590
7591 /// Colon location.
7592 SourceLocation ColonLoc;
7593
7594 /// Build clause with number of variables \a NumVars.
7595 ///
7596 /// \param TheMotionModifiers Motion-modifiers.
7597 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7598 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7599 /// user-defined mapper.
7600 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7601 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7602 /// StartLoc: starting location of the clause (the clause keyword); 2)
7603 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7604 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7605 /// NumVars: number of expressions listed in this clause; 2)
7606 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7607 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7608 /// NumComponents: total number of expression components in the clause.
7609 explicit OMPToClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7610 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7611 NestedNameSpecifierLoc MapperQualifierLoc,
7612 DeclarationNameInfo MapperIdInfo,
7613 const OMPVarListLocTy &Locs,
7614 const OMPMappableExprListSizeTy &Sizes)
7615 : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
7616 /*SupportsMapper=*/true, &MapperQualifierLoc,
7617 &MapperIdInfo) {
7618 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7619 "Unexpected number of motion modifiers.");
7620 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7621
7622 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7623 "Unexpected number of motion modifier locations.");
7624 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7625 }
7626
7627 /// Build an empty clause.
7628 ///
7629 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7630 /// NumVars: number of expressions listed in this clause; 2)
7631 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7632 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7633 /// NumComponents: total number of expression components in the clause.
7634 explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes)
7635 : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
7636 /*SupportsMapper=*/true) {}
7637
7638 /// Set motion-modifier for the clause.
7639 ///
7640 /// \param I index for motion-modifier.
7641 /// \param T motion-modifier for the clause.
7642 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7643 assert(I < NumberOfOMPMotionModifiers &&
7644 "Unexpected index to store motion modifier, exceeds array size.");
7645 MotionModifiers[I] = T;
7646 }
7647
7648 /// Set location for the motion-modifier.
7649 ///
7650 /// \param I index for motion-modifier location.
7651 /// \param TLoc motion-modifier location.
7652 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7653 assert(I < NumberOfOMPMotionModifiers &&
7654 "Index to store motion modifier location exceeds array size.");
7655 MotionModifiersLoc[I] = TLoc;
7656 }
7657
7658 void setIteratorModifier(Expr *IteratorModifier) {
7659 getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier;
7660 }
7661 /// Set colon location.
7662 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7663
7664 /// Define the sizes of each trailing object array except the last one. This
7665 /// is required for TrailingObjects to work properly.
7666 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7667 // There are varlist_size() of expressions, and varlist_size() of
7668 // user-defined mappers.
7669 return 2 * varlist_size() + 1;
7670 }
7671 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7672 return getUniqueDeclarationsNum();
7673 }
7674 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7676 }
7677
7678public:
7679 /// Creates clause with a list of variables \a Vars.
7680 ///
7681 /// \param C AST context.
7682 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7683 /// StartLoc: starting location of the clause (the clause keyword); 2)
7684 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7685 /// \param Vars The original expression used in the clause.
7686 /// \param Declarations Declarations used in the clause.
7687 /// \param ComponentLists Component lists used in the clause.
7688 /// \param MotionModifiers Motion-modifiers.
7689 /// \param MotionModifiersLoc Location of motion-modifiers.
7690 /// \param UDMapperRefs References to user-defined mappers associated with
7691 /// expressions used in the clause.
7692 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7693 /// user-defined mapper.
7694 /// \param MapperId The identifier of associated user-defined mapper.
7695 static OMPToClause *
7696 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7697 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7698 MappableExprComponentListsRef ComponentLists,
7699 ArrayRef<Expr *> UDMapperRefs, Expr *IteratorModifier,
7700 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7701 ArrayRef<SourceLocation> MotionModifiersLoc,
7702 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId);
7703
7704 /// Creates an empty clause with the place for \a NumVars variables.
7705 ///
7706 /// \param C AST context.
7707 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7708 /// NumVars: number of expressions listed in this clause; 2)
7709 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7710 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7711 /// NumComponents: total number of expression components in the clause.
7712 static OMPToClause *CreateEmpty(const ASTContext &C,
7713 const OMPMappableExprListSizeTy &Sizes);
7714
7715 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7716 ///
7717 /// \param Cnt index for motion-modifier.
7718 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7719 assert(Cnt < NumberOfOMPMotionModifiers &&
7720 "Requested modifier exceeds the total number of modifiers.");
7721 return MotionModifiers[Cnt];
7722 }
7724 return getTrailingObjects<Expr *>()[2 * varlist_size()];
7725 }
7726 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7727 /// locations.
7728 ///
7729 /// \param Cnt index for motion-modifier location.
7730 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7731 assert(Cnt < NumberOfOMPMotionModifiers &&
7732 "Requested modifier location exceeds total number of modifiers.");
7733 return MotionModifiersLoc[Cnt];
7734 }
7735
7736 /// Fetches ArrayRef of motion-modifiers.
7738 return MotionModifiers;
7739 }
7740
7741 /// Fetches ArrayRef of location of motion-modifiers.
7743 return MotionModifiersLoc;
7744 }
7745
7746 /// Get colon location.
7747 SourceLocation getColonLoc() const { return ColonLoc; }
7748
7750 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7751 reinterpret_cast<Stmt **>(varlist_end()));
7752 }
7753
7755 return const_cast<OMPToClause *>(this)->children();
7756 }
7757
7764
7765 static bool classof(const OMPClause *T) {
7766 return T->getClauseKind() == llvm::omp::OMPC_to;
7767 }
7768};
7769
7770/// This represents clause 'from' in the '#pragma omp ...'
7771/// directives.
7772///
7773/// \code
7774/// #pragma omp target update from(a,b)
7775/// \endcode
7776/// In this example directive '#pragma omp target update' has clause 'from'
7777/// with the variables 'a' and 'b'.
7778class OMPFromClause final
7779 : public OMPMappableExprListClause<OMPFromClause>,
7780 private llvm::TrailingObjects<
7781 OMPFromClause, Expr *, ValueDecl *, unsigned,
7782 OMPClauseMappableExprCommon::MappableComponent> {
7783 friend class OMPClauseReader;
7784 friend OMPMappableExprListClause;
7785 friend OMPVarListClause;
7786 friend TrailingObjects;
7787
7788 /// Motion-modifiers for the 'from' clause.
7792
7793 /// Location of motion-modifiers for the 'from' clause.
7794 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7795
7796 /// Colon location.
7797 SourceLocation ColonLoc;
7798
7799 /// Build clause with number of variables \a NumVars.
7800 ///
7801 /// \param TheMotionModifiers Motion-modifiers.
7802 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7803 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7804 /// user-defined mapper.
7805 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7806 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7807 /// StartLoc: starting location of the clause (the clause keyword); 2)
7808 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7809 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7810 /// NumVars: number of expressions listed in this clause; 2)
7811 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7812 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7813 /// NumComponents: total number of expression components in the clause.
7814 explicit OMPFromClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7815 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7816 NestedNameSpecifierLoc MapperQualifierLoc,
7817 DeclarationNameInfo MapperIdInfo,
7818 const OMPVarListLocTy &Locs,
7819 const OMPMappableExprListSizeTy &Sizes)
7820 : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes,
7821 /*SupportsMapper=*/true, &MapperQualifierLoc,
7822 &MapperIdInfo) {
7823 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7824 "Unexpected number of motion modifiers.");
7825 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7826
7827 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7828 "Unexpected number of motion modifier locations.");
7829 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7830 }
7831
7832 /// Build an empty clause.
7833 ///
7834 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7835 /// NumVars: number of expressions listed in this clause; 2)
7836 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7837 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7838 /// NumComponents: total number of expression components in the clause.
7839 explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes)
7840 : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(),
7841 Sizes, /*SupportsMapper=*/true) {}
7842
7843 /// Set motion-modifier for the clause.
7844 ///
7845 /// \param I index for motion-modifier.
7846 /// \param T motion-modifier for the clause.
7847 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7848 assert(I < NumberOfOMPMotionModifiers &&
7849 "Unexpected index to store motion modifier, exceeds array size.");
7850 MotionModifiers[I] = T;
7851 }
7852 void setIteratorModifier(Expr *IteratorModifier) {
7853 getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier;
7854 }
7855 /// Set location for the motion-modifier.
7856 ///
7857 /// \param I index for motion-modifier location.
7858 /// \param TLoc motion-modifier location.
7859 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7860 assert(I < NumberOfOMPMotionModifiers &&
7861 "Index to store motion modifier location exceeds array size.");
7862 MotionModifiersLoc[I] = TLoc;
7863 }
7864
7865 /// Set colon location.
7866 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7867
7868 /// Define the sizes of each trailing object array except the last one. This
7869 /// is required for TrailingObjects to work properly.
7870 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7871 // There are varlist_size() of expressions, and varlist_size() of
7872 // user-defined mappers.
7873 return 2 * varlist_size() + 1;
7874 }
7875 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7876 return getUniqueDeclarationsNum();
7877 }
7878 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7880 }
7881
7882public:
7883 /// Creates clause with a list of variables \a Vars.
7884 ///
7885 /// \param C AST context.
7886 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7887 /// StartLoc: starting location of the clause (the clause keyword); 2)
7888 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7889 /// \param Vars The original expression used in the clause.
7890 /// \param Declarations Declarations used in the clause.
7891 /// \param ComponentLists Component lists used in the clause.
7892 /// \param MotionModifiers Motion-modifiers.
7893 /// \param MotionModifiersLoc Location of motion-modifiers.
7894 /// \param UDMapperRefs References to user-defined mappers associated with
7895 /// expressions used in the clause.
7896 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7897 /// user-defined mapper.
7898 /// \param MapperId The identifier of associated user-defined mapper.
7899 static OMPFromClause *
7900 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7901 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7902 MappableExprComponentListsRef ComponentLists,
7903 ArrayRef<Expr *> UDMapperRefs, Expr *IteratorExpr,
7904 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7905 ArrayRef<SourceLocation> MotionModifiersLoc,
7906 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId);
7907
7908 /// Creates an empty clause with the place for \a NumVars variables.
7909 ///
7910 /// \param C AST context.
7911 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7912 /// NumVars: number of expressions listed in this clause; 2)
7913 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7914 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7915 /// NumComponents: total number of expression components in the clause.
7916 static OMPFromClause *CreateEmpty(const ASTContext &C,
7917 const OMPMappableExprListSizeTy &Sizes);
7918
7919 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7920 ///
7921 /// \param Cnt index for motion-modifier.
7922 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7923 assert(Cnt < NumberOfOMPMotionModifiers &&
7924 "Requested modifier exceeds the total number of modifiers.");
7925 return MotionModifiers[Cnt];
7926 }
7928 return getTrailingObjects<Expr *>()[2 * varlist_size()];
7929 }
7930 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7931 /// locations.
7932 ///
7933 /// \param Cnt index for motion-modifier location.
7934 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7935 assert(Cnt < NumberOfOMPMotionModifiers &&
7936 "Requested modifier location exceeds total number of modifiers.");
7937 return MotionModifiersLoc[Cnt];
7938 }
7939
7940 /// Fetches ArrayRef of motion-modifiers.
7942 return MotionModifiers;
7943 }
7944
7945 /// Fetches ArrayRef of location of motion-modifiers.
7947 return MotionModifiersLoc;
7948 }
7949
7950 /// Get colon location.
7951 SourceLocation getColonLoc() const { return ColonLoc; }
7952
7954 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7955 reinterpret_cast<Stmt **>(varlist_end()));
7956 }
7957
7959 return const_cast<OMPFromClause *>(this)->children();
7960 }
7961
7968
7969 static bool classof(const OMPClause *T) {
7970 return T->getClauseKind() == llvm::omp::OMPC_from;
7971 }
7972};
7973
7974/// This represents clause 'use_device_ptr' in the '#pragma omp ...'
7975/// directives.
7976///
7977/// \code
7978/// #pragma omp target data use_device_ptr(a,b)
7979/// \endcode
7980/// In this example directive '#pragma omp target data' has clause
7981/// 'use_device_ptr' with the variables 'a' and 'b'.
7982class OMPUseDevicePtrClause final
7983 : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
7984 private llvm::TrailingObjects<
7985 OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
7986 OMPClauseMappableExprCommon::MappableComponent> {
7987 friend class OMPClauseReader;
7988 friend OMPMappableExprListClause;
7989 friend OMPVarListClause;
7990 friend TrailingObjects;
7991
7992 /// Build clause with number of variables \a NumVars.
7993 ///
7994 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7995 /// StartLoc: starting location of the clause (the clause keyword); 2)
7996 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7997 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7998 /// NumVars: number of expressions listed in this clause; 2)
7999 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8000 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8001 /// NumComponents: total number of expression components in the clause.
8002 explicit OMPUseDevicePtrClause(const OMPVarListLocTy &Locs,
8003 const OMPMappableExprListSizeTy &Sizes)
8004 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr, Locs, Sizes) {
8005 }
8006
8007 /// Build an empty clause.
8008 ///
8009 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8010 /// NumVars: number of expressions listed in this clause; 2)
8011 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8012 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8013 /// NumComponents: total number of expression components in the clause.
8015 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr,
8016 OMPVarListLocTy(), Sizes) {}
8017
8018 /// Define the sizes of each trailing object array except the last one. This
8019 /// is required for TrailingObjects to work properly.
8020 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8021 return 3 * varlist_size();
8022 }
8023 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8024 return getUniqueDeclarationsNum();
8025 }
8026 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8028 }
8029
8030 /// Sets the list of references to private copies with initializers for new
8031 /// private variables.
8032 /// \param VL List of references.
8033 void setPrivateCopies(ArrayRef<Expr *> VL);
8034
8035 /// Gets the list of references to private copies with initializers for new
8036 /// private variables.
8037 MutableArrayRef<Expr *> getPrivateCopies() {
8038 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
8039 }
8040 ArrayRef<const Expr *> getPrivateCopies() const {
8041 return {varlist_end(), varlist_size()};
8042 }
8043
8044 /// Sets the list of references to initializer variables for new private
8045 /// variables.
8046 /// \param VL List of references.
8047 void setInits(ArrayRef<Expr *> VL);
8048
8049 /// Gets the list of references to initializer variables for new private
8050 /// variables.
8051 MutableArrayRef<Expr *> getInits() {
8052 return {getPrivateCopies().end(), varlist_size()};
8053 }
8054 ArrayRef<const Expr *> getInits() const {
8055 return {getPrivateCopies().end(), varlist_size()};
8056 }
8057
8058public:
8059 /// Creates clause with a list of variables \a Vars.
8060 ///
8061 /// \param C AST context.
8062 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8063 /// StartLoc: starting location of the clause (the clause keyword); 2)
8064 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8065 /// \param Vars The original expression used in the clause.
8066 /// \param PrivateVars Expressions referring to private copies.
8067 /// \param Inits Expressions referring to private copy initializers.
8068 /// \param Declarations Declarations used in the clause.
8069 /// \param ComponentLists Component lists used in the clause.
8070 static OMPUseDevicePtrClause *
8071 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8072 ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
8073 ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
8074 MappableExprComponentListsRef ComponentLists);
8075
8076 /// Creates an empty clause with the place for \a NumVars variables.
8077 ///
8078 /// \param C AST context.
8079 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8080 /// NumVars: number of expressions listed in this clause; 2)
8081 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8082 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8083 /// NumComponents: total number of expression components in the clause.
8084 static OMPUseDevicePtrClause *
8085 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8086
8089 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
8091 llvm::iterator_range<private_copies_const_iterator>;
8092
8093 private_copies_range private_copies() { return getPrivateCopies(); }
8094
8096 return getPrivateCopies();
8097 }
8098
8101 using inits_range = llvm::iterator_range<inits_iterator>;
8102 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
8103
8104 inits_range inits() { return getInits(); }
8105
8106 inits_const_range inits() const { return getInits(); }
8107
8109 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8110 reinterpret_cast<Stmt **>(varlist_end()));
8111 }
8112
8114 return const_cast<OMPUseDevicePtrClause *>(this)->children();
8115 }
8116
8123
8124 static bool classof(const OMPClause *T) {
8125 return T->getClauseKind() == llvm::omp::OMPC_use_device_ptr;
8126 }
8127};
8128
8129/// This represents clause 'use_device_addr' in the '#pragma omp ...'
8130/// directives.
8131///
8132/// \code
8133/// #pragma omp target data use_device_addr(a,b)
8134/// \endcode
8135/// In this example directive '#pragma omp target data' has clause
8136/// 'use_device_addr' with the variables 'a' and 'b'.
8137class OMPUseDeviceAddrClause final
8138 : public OMPMappableExprListClause<OMPUseDeviceAddrClause>,
8139 private llvm::TrailingObjects<
8140 OMPUseDeviceAddrClause, Expr *, ValueDecl *, unsigned,
8141 OMPClauseMappableExprCommon::MappableComponent> {
8142 friend class OMPClauseReader;
8143 friend OMPMappableExprListClause;
8144 friend OMPVarListClause;
8145 friend TrailingObjects;
8146
8147 /// Build clause with number of variables \a NumVars.
8148 ///
8149 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8150 /// StartLoc: starting location of the clause (the clause keyword); 2)
8151 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8152 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8153 /// NumVars: number of expressions listed in this clause; 2)
8154 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8155 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8156 /// NumComponents: total number of expression components in the clause.
8157 explicit OMPUseDeviceAddrClause(const OMPVarListLocTy &Locs,
8158 const OMPMappableExprListSizeTy &Sizes)
8159 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr, Locs,
8160 Sizes) {}
8161
8162 /// Build an empty clause.
8163 ///
8164 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8165 /// NumVars: number of expressions listed in this clause; 2)
8166 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8167 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8168 /// NumComponents: total number of expression components in the clause.
8170 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr,
8171 OMPVarListLocTy(), Sizes) {}
8172
8173 /// Define the sizes of each trailing object array except the last one. This
8174 /// is required for TrailingObjects to work properly.
8175 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8176 return varlist_size();
8177 }
8178 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8179 return getUniqueDeclarationsNum();
8180 }
8181 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8183 }
8184
8185public:
8186 /// Creates clause with a list of variables \a Vars.
8187 ///
8188 /// \param C AST context.
8189 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8190 /// StartLoc: starting location of the clause (the clause keyword); 2)
8191 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8192 /// \param Vars The original expression used in the clause.
8193 /// \param Declarations Declarations used in the clause.
8194 /// \param ComponentLists Component lists used in the clause.
8195 static OMPUseDeviceAddrClause *
8196 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8197 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8198 MappableExprComponentListsRef ComponentLists);
8199
8200 /// Creates an empty clause with the place for \a NumVars variables.
8201 ///
8202 /// \param C AST context.
8203 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8204 /// NumVars: number of expressions listed in this clause; 2)
8205 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8206 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8207 /// NumComponents: total number of expression components in the clause.
8208 static OMPUseDeviceAddrClause *
8209 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8210
8212 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8213 reinterpret_cast<Stmt **>(varlist_end()));
8214 }
8215
8217 return const_cast<OMPUseDeviceAddrClause *>(this)->children();
8218 }
8219
8226
8227 static bool classof(const OMPClause *T) {
8228 return T->getClauseKind() == llvm::omp::OMPC_use_device_addr;
8229 }
8230};
8231
8232/// This represents clause 'is_device_ptr' in the '#pragma omp ...'
8233/// directives.
8234///
8235/// \code
8236/// #pragma omp target is_device_ptr(a,b)
8237/// \endcode
8238/// In this example directive '#pragma omp target' has clause
8239/// 'is_device_ptr' with the variables 'a' and 'b'.
8240class OMPIsDevicePtrClause final
8241 : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
8242 private llvm::TrailingObjects<
8243 OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
8244 OMPClauseMappableExprCommon::MappableComponent> {
8245 friend class OMPClauseReader;
8246 friend OMPMappableExprListClause;
8247 friend OMPVarListClause;
8248 friend TrailingObjects;
8249
8250 /// Build clause with number of variables \a NumVars.
8251 ///
8252 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8253 /// StartLoc: starting location of the clause (the clause keyword); 2)
8254 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8255 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8256 /// NumVars: number of expressions listed in this clause; 2)
8257 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8258 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8259 /// NumComponents: total number of expression components in the clause.
8260 explicit OMPIsDevicePtrClause(const OMPVarListLocTy &Locs,
8261 const OMPMappableExprListSizeTy &Sizes)
8262 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr, Locs, Sizes) {}
8263
8264 /// Build an empty clause.
8265 ///
8266 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8267 /// NumVars: number of expressions listed in this clause; 2)
8268 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8269 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8270 /// NumComponents: total number of expression components in the clause.
8271 explicit OMPIsDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
8272 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr,
8273 OMPVarListLocTy(), Sizes) {}
8274
8275 /// Define the sizes of each trailing object array except the last one. This
8276 /// is required for TrailingObjects to work properly.
8277 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8278 return varlist_size();
8279 }
8280 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8281 return getUniqueDeclarationsNum();
8282 }
8283 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8285 }
8286
8287public:
8288 /// Creates clause with a list of variables \a Vars.
8289 ///
8290 /// \param C AST context.
8291 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8292 /// StartLoc: starting location of the clause (the clause keyword); 2)
8293 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8294 /// \param Vars The original expression used in the clause.
8295 /// \param Declarations Declarations used in the clause.
8296 /// \param ComponentLists Component lists used in the clause.
8297 static OMPIsDevicePtrClause *
8298 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8299 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8300 MappableExprComponentListsRef ComponentLists);
8301
8302 /// Creates an empty clause with the place for \a NumVars variables.
8303 ///
8304 /// \param C AST context.
8305 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8306 /// NumVars: number of expressions listed in this clause; 2)
8307 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8308 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8309 /// NumComponents: total number of expression components in the clause.
8310 static OMPIsDevicePtrClause *
8311 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8312
8314 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8315 reinterpret_cast<Stmt **>(varlist_end()));
8316 }
8317
8319 return const_cast<OMPIsDevicePtrClause *>(this)->children();
8320 }
8321
8328
8329 static bool classof(const OMPClause *T) {
8330 return T->getClauseKind() == llvm::omp::OMPC_is_device_ptr;
8331 }
8332};
8333
8334/// This represents clause 'has_device_ptr' in the '#pragma omp ...'
8335/// directives.
8336///
8337/// \code
8338/// #pragma omp target has_device_addr(a,b)
8339/// \endcode
8340/// In this example directive '#pragma omp target' has clause
8341/// 'has_device_ptr' with the variables 'a' and 'b'.
8342class OMPHasDeviceAddrClause final
8343 : public OMPMappableExprListClause<OMPHasDeviceAddrClause>,
8344 private llvm::TrailingObjects<
8345 OMPHasDeviceAddrClause, Expr *, ValueDecl *, unsigned,
8346 OMPClauseMappableExprCommon::MappableComponent> {
8347 friend class OMPClauseReader;
8348 friend OMPMappableExprListClause;
8349 friend OMPVarListClause;
8350 friend TrailingObjects;
8351
8352 /// Build clause with number of variables \a NumVars.
8353 ///
8354 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8355 /// StartLoc: starting location of the clause (the clause keyword); 2)
8356 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8357 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8358 /// NumVars: number of expressions listed in this clause; 2)
8359 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8360 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8361 /// NumComponents: total number of expression components in the clause.
8362 explicit OMPHasDeviceAddrClause(const OMPVarListLocTy &Locs,
8363 const OMPMappableExprListSizeTy &Sizes)
8364 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, Locs,
8365 Sizes) {}
8366
8367 /// Build an empty clause.
8368 ///
8369 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8370 /// NumVars: number of expressions listed in this clause; 2)
8371 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8372 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8373 /// NumComponents: total number of expression components in the clause.
8375 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr,
8376 OMPVarListLocTy(), Sizes) {}
8377
8378 /// Define the sizes of each trailing object array except the last one. This
8379 /// is required for TrailingObjects to work properly.
8380 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8381 return varlist_size();
8382 }
8383 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8384 return getUniqueDeclarationsNum();
8385 }
8386 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8388 }
8389
8390public:
8391 /// Creates clause with a list of variables \a Vars.
8392 ///
8393 /// \param C AST context.
8394 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8395 /// StartLoc: starting location of the clause (the clause keyword); 2)
8396 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8397 /// \param Vars The original expression used in the clause.
8398 /// \param Declarations Declarations used in the clause.
8399 /// \param ComponentLists Component lists used in the clause.
8400 static OMPHasDeviceAddrClause *
8401 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8402 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8403 MappableExprComponentListsRef ComponentLists);
8404
8405 /// Creates an empty clause with the place for \a NumVars variables.
8406 ///
8407 /// \param C AST context.
8408 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8409 /// NumVars: number of expressions listed in this clause; 2)
8410 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8411 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8412 /// NumComponents: total number of expression components in the clause.
8413 static OMPHasDeviceAddrClause *
8414 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8415
8417 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8418 reinterpret_cast<Stmt **>(varlist_end()));
8419 }
8420
8422 return const_cast<OMPHasDeviceAddrClause *>(this)->children();
8423 }
8424
8431
8432 static bool classof(const OMPClause *T) {
8433 return T->getClauseKind() == llvm::omp::OMPC_has_device_addr;
8434 }
8435};
8436
8437/// This represents clause 'nontemporal' in the '#pragma omp ...' directives.
8438///
8439/// \code
8440/// #pragma omp simd nontemporal(a)
8441/// \endcode
8442/// In this example directive '#pragma omp simd' has clause 'nontemporal' for
8443/// the variable 'a'.
8444class OMPNontemporalClause final
8445 : public OMPVarListClause<OMPNontemporalClause>,
8446 private llvm::TrailingObjects<OMPNontemporalClause, Expr *> {
8447 friend class OMPClauseReader;
8448 friend OMPVarListClause;
8449 friend TrailingObjects;
8450
8451 /// Build clause with number of variables \a N.
8452 ///
8453 /// \param StartLoc Starting location of the clause.
8454 /// \param LParenLoc Location of '('.
8455 /// \param EndLoc Ending location of the clause.
8456 /// \param N Number of the variables in the clause.
8457 OMPNontemporalClause(SourceLocation StartLoc, SourceLocation LParenLoc,
8458 SourceLocation EndLoc, unsigned N)
8459 : OMPVarListClause<OMPNontemporalClause>(llvm::omp::OMPC_nontemporal,
8460 StartLoc, LParenLoc, EndLoc, N) {
8461 }
8462
8463 /// Build an empty clause.
8464 ///
8465 /// \param N Number of variables.
8466 explicit OMPNontemporalClause(unsigned N)
8468 llvm::omp::OMPC_nontemporal, SourceLocation(), SourceLocation(),
8469 SourceLocation(), N) {}
8470
8471 /// Get the list of privatied copies if the member expression was captured by
8472 /// one of the privatization clauses.
8473 MutableArrayRef<Expr *> getPrivateRefs() {
8474 return {varlist_end(), varlist_size()};
8475 }
8476 ArrayRef<const Expr *> getPrivateRefs() const {
8477 return {varlist_end(), varlist_size()};
8478 }
8479
8480public:
8481 /// Creates clause with a list of variables \a VL.
8482 ///
8483 /// \param C AST context.
8484 /// \param StartLoc Starting location of the clause.
8485 /// \param LParenLoc Location of '('.
8486 /// \param EndLoc Ending location of the clause.
8487 /// \param VL List of references to the variables.
8488 static OMPNontemporalClause *
8489 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
8490 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8491
8492 /// Creates an empty clause with the place for \a N variables.
8493 ///
8494 /// \param C AST context.
8495 /// \param N The number of variables.
8496 static OMPNontemporalClause *CreateEmpty(const ASTContext &C, unsigned N);
8497
8498 /// Sets the list of references to private copies created in private clauses.
8499 /// \param VL List of references.
8500 void setPrivateRefs(ArrayRef<Expr *> VL);
8501
8503 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8504 reinterpret_cast<Stmt **>(varlist_end()));
8505 }
8506
8508 return const_cast<OMPNontemporalClause *>(this)->children();
8509 }
8510
8512 return child_range(reinterpret_cast<Stmt **>(getPrivateRefs().begin()),
8513 reinterpret_cast<Stmt **>(getPrivateRefs().end()));
8514 }
8515
8517 return const_cast<OMPNontemporalClause *>(this)->private_refs();
8518 }
8519
8526
8527 static bool classof(const OMPClause *T) {
8528 return T->getClauseKind() == llvm::omp::OMPC_nontemporal;
8529 }
8530};
8531
8532/// This represents 'order' clause in the '#pragma omp ...' directive.
8533///
8534/// \code
8535/// #pragma omp simd order(concurrent)
8536/// \endcode
8537/// In this example directive '#pragma omp parallel' has simple 'order'
8538/// clause with kind 'concurrent'.
8539class OMPOrderClause final : public OMPClause {
8540 friend class OMPClauseReader;
8541
8542 /// Location of '('.
8543 SourceLocation LParenLoc;
8544
8545 /// A kind of the 'order' clause.
8547
8548 /// Start location of the kind in source code.
8549 SourceLocation KindKwLoc;
8550
8551 /// A modifier for order clause
8553
8554 /// Start location of the modifier in source code.
8555 SourceLocation ModifierKwLoc;
8556
8557 /// Set kind of the clause.
8558 ///
8559 /// \param K Argument of clause.
8560 void setKind(OpenMPOrderClauseKind K) { Kind = K; }
8561
8562 /// Set argument location.
8563 ///
8564 /// \param KLoc Argument location.
8565 void setKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
8566
8567 /// Set modifier of the clause.
8568 ///
8569 /// \param M Argument of clause.
8570 void setModifier(OpenMPOrderClauseModifier M) { Modifier = M; }
8571
8572 /// Set modifier location.
8573 ///
8574 /// \param MLoc Modifier keyword location.
8575 void setModifierKwLoc(SourceLocation MLoc) { ModifierKwLoc = MLoc; }
8576
8577public:
8578 /// Build 'order' clause with argument \p A ('concurrent').
8579 ///
8580 /// \param A Argument of the clause ('concurrent').
8581 /// \param ALoc Starting location of the argument.
8582 /// \param StartLoc Starting location of the clause.
8583 /// \param LParenLoc Location of '('.
8584 /// \param EndLoc Ending location of the clause.
8585 /// \param Modifier The modifier applied to 'order' clause.
8586 /// \param MLoc Location of the modifier
8588 SourceLocation StartLoc, SourceLocation LParenLoc,
8590 SourceLocation MLoc)
8591 : OMPClause(llvm::omp::OMPC_order, StartLoc, EndLoc),
8592 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), Modifier(Modifier),
8593 ModifierKwLoc(MLoc) {}
8594
8595 /// Build an empty clause.
8597 : OMPClause(llvm::omp::OMPC_order, SourceLocation(), SourceLocation()) {}
8598
8599 /// Sets the location of '('.
8600 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8601
8602 /// Returns the location of '('.
8603 SourceLocation getLParenLoc() const { return LParenLoc; }
8604
8605 /// Returns kind of the clause.
8606 OpenMPOrderClauseKind getKind() const { return Kind; }
8607
8608 /// Returns location of clause kind.
8609 SourceLocation getKindKwLoc() const { return KindKwLoc; }
8610
8611 /// Returns Modifier of the clause.
8612 OpenMPOrderClauseModifier getModifier() const { return Modifier; }
8613
8614 /// Returns location of clause modifier.
8615 SourceLocation getModifierKwLoc() const { return ModifierKwLoc; }
8616
8620
8624
8631
8632 static bool classof(const OMPClause *T) {
8633 return T->getClauseKind() == llvm::omp::OMPC_order;
8634 }
8635};
8636
8637/// This represents the 'init' clause in '#pragma omp ...' directives.
8638///
8639/// \code
8640/// #pragma omp interop init(target:obj)
8641/// \endcode
8642class OMPInitClause final
8643 : public OMPVarListClause<OMPInitClause>,
8644 private llvm::TrailingObjects<OMPInitClause, Expr *> {
8645 friend class OMPClauseReader;
8646 friend OMPVarListClause;
8647 friend TrailingObjects;
8648
8649 /// Location of interop variable.
8650 SourceLocation VarLoc;
8651
8652 bool IsTarget = false;
8653 bool IsTargetSync = false;
8654
8655 void setInteropVar(Expr *E) { varlist_begin()[0] = E; }
8656
8657 void setIsTarget(bool V) { IsTarget = V; }
8658
8659 void setIsTargetSync(bool V) { IsTargetSync = V; }
8660
8661 /// Sets the location of the interop variable.
8662 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8663
8664 /// Build 'init' clause.
8665 ///
8666 /// \param IsTarget Uses the 'target' interop-type.
8667 /// \param IsTargetSync Uses the 'targetsync' interop-type.
8668 /// \param StartLoc Starting location of the clause.
8669 /// \param LParenLoc Location of '('.
8670 /// \param VarLoc Location of the interop variable.
8671 /// \param EndLoc Ending location of the clause.
8672 /// \param N Number of expressions.
8673 OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc,
8674 SourceLocation LParenLoc, SourceLocation VarLoc,
8675 SourceLocation EndLoc, unsigned N)
8676 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc,
8677 LParenLoc, EndLoc, N),
8678 VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {}
8679
8680 /// Build an empty clause.
8681 OMPInitClause(unsigned N)
8682 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(),
8683 SourceLocation(), SourceLocation(), N) {
8684 }
8685
8686public:
8687 /// Creates a fully specified clause.
8688 ///
8689 /// \param C AST context.
8690 /// \param InteropVar The interop variable.
8691 /// \param InteropInfo The interop-type and prefer_type list.
8692 /// \param StartLoc Starting location of the clause.
8693 /// \param LParenLoc Location of '('.
8694 /// \param VarLoc Location of the interop variable.
8695 /// \param EndLoc Ending location of the clause.
8696 static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar,
8697 OMPInteropInfo &InteropInfo,
8698 SourceLocation StartLoc,
8699 SourceLocation LParenLoc, SourceLocation VarLoc,
8700 SourceLocation EndLoc);
8701
8702 /// Creates an empty clause with \a N expressions.
8703 ///
8704 /// \param C AST context.
8705 /// \param N Number of expression items.
8706 static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N);
8707
8708 /// Returns the location of the interop variable.
8709 SourceLocation getVarLoc() const { return VarLoc; }
8710
8711 /// Returns the interop variable.
8713 const Expr *getInteropVar() const { return varlist_begin()[0]; }
8714
8715 /// Returns true is interop-type 'target' is used.
8716 bool getIsTarget() const { return IsTarget; }
8717
8718 /// Returns true is interop-type 'targetsync' is used.
8719 bool getIsTargetSync() const { return IsTargetSync; }
8720
8722 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8723 reinterpret_cast<Stmt **>(varlist_end()));
8724 }
8725
8727 return const_cast<OMPInitClause *>(this)->children();
8728 }
8729
8736
8739 using prefs_range = llvm::iterator_range<prefs_iterator>;
8740 using const_prefs_range = llvm::iterator_range<const_prefs_iterator>;
8741
8743 return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())),
8744 reinterpret_cast<Expr **>(varlist_end()));
8745 }
8746
8748 return const_prefs_range(const_cast<OMPInitClause *>(this)->prefs());
8749 }
8750
8751 static bool classof(const OMPClause *T) {
8752 return T->getClauseKind() == llvm::omp::OMPC_init;
8753 }
8754};
8755
8756/// This represents the 'use' clause in '#pragma omp ...' directives.
8757///
8758/// \code
8759/// #pragma omp interop use(obj)
8760/// \endcode
8761class OMPUseClause final : public OMPClause {
8762 friend class OMPClauseReader;
8763
8764 /// Location of '('.
8765 SourceLocation LParenLoc;
8766
8767 /// Location of interop variable.
8768 SourceLocation VarLoc;
8769
8770 /// The interop variable.
8771 Stmt *InteropVar = nullptr;
8772
8773 /// Set the interop variable.
8774 void setInteropVar(Expr *E) { InteropVar = E; }
8775
8776 /// Sets the location of '('.
8777 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8778
8779 /// Sets the location of the interop variable.
8780 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8781
8782public:
8783 /// Build 'use' clause with and interop variable expression \a InteropVar.
8784 ///
8785 /// \param InteropVar The interop variable.
8786 /// \param StartLoc Starting location of the clause.
8787 /// \param LParenLoc Location of '('.
8788 /// \param VarLoc Location of the interop variable.
8789 /// \param EndLoc Ending location of the clause.
8790 OMPUseClause(Expr *InteropVar, SourceLocation StartLoc,
8791 SourceLocation LParenLoc, SourceLocation VarLoc,
8792 SourceLocation EndLoc)
8793 : OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc),
8794 VarLoc(VarLoc), InteropVar(InteropVar) {}
8795
8796 /// Build an empty clause.
8798 : OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {}
8799
8800 /// Returns the location of '('.
8801 SourceLocation getLParenLoc() const { return LParenLoc; }
8802
8803 /// Returns the location of the interop variable.
8804 SourceLocation getVarLoc() const { return VarLoc; }
8805
8806 /// Returns the interop variable.
8807 Expr *getInteropVar() const { return cast<Expr>(InteropVar); }
8808
8809 child_range children() { return child_range(&InteropVar, &InteropVar + 1); }
8810
8812 return const_child_range(&InteropVar, &InteropVar + 1);
8813 }
8814
8821
8822 static bool classof(const OMPClause *T) {
8823 return T->getClauseKind() == llvm::omp::OMPC_use;
8824 }
8825};
8826
8827/// This represents 'destroy' clause in the '#pragma omp depobj'
8828/// directive or the '#pragma omp interop' directive..
8829///
8830/// \code
8831/// #pragma omp depobj(a) destroy
8832/// #pragma omp interop destroy(obj)
8833/// \endcode
8834/// In these examples directive '#pragma omp depobj' and '#pragma omp interop'
8835/// have a 'destroy' clause. The 'interop' directive includes an object.
8836class OMPDestroyClause final : public OMPClause {
8837 friend class OMPClauseReader;
8838
8839 /// Location of '('.
8840 SourceLocation LParenLoc;
8841
8842 /// Location of interop variable.
8843 SourceLocation VarLoc;
8844
8845 /// The interop variable.
8846 Stmt *InteropVar = nullptr;
8847
8848 /// Set the interop variable.
8849 void setInteropVar(Expr *E) { InteropVar = E; }
8850
8851 /// Sets the location of '('.
8852 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8853
8854 /// Sets the location of the interop variable.
8855 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8856
8857public:
8858 /// Build 'destroy' clause with an interop variable expression \a InteropVar.
8859 ///
8860 /// \param InteropVar The interop variable.
8861 /// \param StartLoc Starting location of the clause.
8862 /// \param LParenLoc Location of '('.
8863 /// \param VarLoc Location of the interop variable.
8864 /// \param EndLoc Ending location of the clause.
8865 OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc,
8866 SourceLocation LParenLoc, SourceLocation VarLoc,
8867 SourceLocation EndLoc)
8868 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc),
8869 LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {}
8870
8871 /// Build 'destroy' clause.
8872 ///
8873 /// \param StartLoc Starting location of the clause.
8874 /// \param EndLoc Ending location of the clause.
8876 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc) {}
8877
8878 /// Build an empty clause.
8880 : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) {
8881 }
8882
8883 /// Returns the location of '('.
8884 SourceLocation getLParenLoc() const { return LParenLoc; }
8885
8886 /// Returns the location of the interop variable.
8887 SourceLocation getVarLoc() const { return VarLoc; }
8888
8889 /// Returns the interop variable.
8890 Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); }
8891
8893 if (InteropVar)
8894 return child_range(&InteropVar, &InteropVar + 1);
8896 }
8897
8899 if (InteropVar)
8900 return const_child_range(&InteropVar, &InteropVar + 1);
8902 }
8903
8910
8911 static bool classof(const OMPClause *T) {
8912 return T->getClauseKind() == llvm::omp::OMPC_destroy;
8913 }
8914};
8915
8916/// This represents 'novariants' clause in the '#pragma omp ...' directive.
8917///
8918/// \code
8919/// #pragma omp dispatch novariants(a > 5)
8920/// \endcode
8921/// In this example directive '#pragma omp dispatch' has simple 'novariants'
8922/// clause with condition 'a > 5'.
8924 : public OMPOneStmtClause<llvm::omp::OMPC_novariants, OMPClause>,
8925 public OMPClauseWithPreInit {
8926 friend class OMPClauseReader;
8927
8928 /// Set condition.
8929 void setCondition(Expr *Cond) { setStmt(Cond); }
8930
8931public:
8932 /// Build 'novariants' clause with condition \a Cond.
8933 ///
8934 /// \param Cond Condition of the clause.
8935 /// \param HelperCond Helper condition for the construct.
8936 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8937 /// clause must be captured.
8938 /// \param StartLoc Starting location of the clause.
8939 /// \param LParenLoc Location of '('.
8940 /// \param EndLoc Ending location of the clause.
8942 OpenMPDirectiveKind CaptureRegion,
8943 SourceLocation StartLoc, SourceLocation LParenLoc,
8944 SourceLocation EndLoc)
8945 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8946 OMPClauseWithPreInit(this) {
8947 setPreInitStmt(HelperCond, CaptureRegion);
8948 }
8949
8950 /// Build an empty clause.
8952
8953 /// Returns condition.
8954 Expr *getCondition() const { return getStmtAs<Expr>(); }
8955
8958 return const_cast<OMPNovariantsClause *>(this)->used_children();
8959 }
8960};
8961
8962/// This represents 'nocontext' clause in the '#pragma omp ...' directive.
8963///
8964/// \code
8965/// #pragma omp dispatch nocontext(a > 5)
8966/// \endcode
8967/// In this example directive '#pragma omp dispatch' has simple 'nocontext'
8968/// clause with condition 'a > 5'.
8970 : public OMPOneStmtClause<llvm::omp::OMPC_nocontext, OMPClause>,
8971 public OMPClauseWithPreInit {
8972 friend class OMPClauseReader;
8973
8974 /// Set condition.
8975 void setCondition(Expr *Cond) { setStmt(Cond); }
8976
8977public:
8978 /// Build 'nocontext' clause with condition \a Cond.
8979 ///
8980 /// \param Cond Condition of the clause.
8981 /// \param HelperCond Helper condition for the construct.
8982 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8983 /// clause must be captured.
8984 /// \param StartLoc Starting location of the clause.
8985 /// \param LParenLoc Location of '('.
8986 /// \param EndLoc Ending location of the clause.
8988 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
8989 SourceLocation LParenLoc, SourceLocation EndLoc)
8990 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8991 OMPClauseWithPreInit(this) {
8992 setPreInitStmt(HelperCond, CaptureRegion);
8993 }
8994
8995 /// Build an empty clause.
8997
8998 /// Returns condition.
8999 Expr *getCondition() const { return getStmtAs<Expr>(); }
9000
9003 return const_cast<OMPNocontextClause *>(this)->used_children();
9004 }
9005};
9006
9007/// This represents 'detach' clause in the '#pragma omp task' directive.
9008///
9009/// \code
9010/// #pragma omp task detach(evt)
9011/// \endcode
9012/// In this example directive '#pragma omp detach' has simple 'detach' clause
9013/// with the variable 'evt'.
9015 : public OMPOneStmtClause<llvm::omp::OMPC_detach, OMPClause> {
9016 friend class OMPClauseReader;
9017
9018 /// Set condition.
9019 void setEventHandler(Expr *E) { setStmt(E); }
9020
9021public:
9022 /// Build 'detach' clause with event-handler \a Evt.
9023 ///
9024 /// \param Evt Event handler expression.
9025 /// \param StartLoc Starting location of the clause.
9026 /// \param LParenLoc Location of '('.
9027 /// \param EndLoc Ending location of the clause.
9029 SourceLocation EndLoc)
9030 : OMPOneStmtClause(Evt, StartLoc, LParenLoc, EndLoc) {}
9031
9032 /// Build an empty clause.
9034
9035 /// Returns event-handler expression.
9036 Expr *getEventHandler() const { return getStmtAs<Expr>(); }
9037};
9038
9039/// This represents clause 'inclusive' in the '#pragma omp scan' directive.
9040///
9041/// \code
9042/// #pragma omp scan inclusive(a,b)
9043/// \endcode
9044/// In this example directive '#pragma omp scan' has clause 'inclusive'
9045/// with the variables 'a' and 'b'.
9046class OMPInclusiveClause final
9047 : public OMPVarListClause<OMPInclusiveClause>,
9048 private llvm::TrailingObjects<OMPInclusiveClause, Expr *> {
9049 friend class OMPClauseReader;
9050 friend OMPVarListClause;
9051 friend TrailingObjects;
9052
9053 /// Build clause with number of variables \a N.
9054 ///
9055 /// \param StartLoc Starting location of the clause.
9056 /// \param LParenLoc Location of '('.
9057 /// \param EndLoc Ending location of the clause.
9058 /// \param N Number of the variables in the clause.
9059 OMPInclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9060 SourceLocation EndLoc, unsigned N)
9061 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
9062 StartLoc, LParenLoc, EndLoc, N) {}
9063
9064 /// Build an empty clause.
9065 ///
9066 /// \param N Number of variables.
9067 explicit OMPInclusiveClause(unsigned N)
9068 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
9070 SourceLocation(), N) {}
9071
9072public:
9073 /// Creates clause with a list of variables \a VL.
9074 ///
9075 /// \param C AST context.
9076 /// \param StartLoc Starting location of the clause.
9077 /// \param LParenLoc Location of '('.
9078 /// \param EndLoc Ending location of the clause.
9079 /// \param VL List of references to the original variables.
9080 static OMPInclusiveClause *Create(const ASTContext &C,
9081 SourceLocation StartLoc,
9082 SourceLocation LParenLoc,
9083 SourceLocation EndLoc, ArrayRef<Expr *> VL);
9084
9085 /// Creates an empty clause with the place for \a N variables.
9086 ///
9087 /// \param C AST context.
9088 /// \param N The number of variables.
9089 static OMPInclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
9090
9092 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9093 reinterpret_cast<Stmt **>(varlist_end()));
9094 }
9095
9097 return const_cast<OMPInclusiveClause *>(this)->children();
9098 }
9099
9106
9107 static bool classof(const OMPClause *T) {
9108 return T->getClauseKind() == llvm::omp::OMPC_inclusive;
9109 }
9110};
9111
9112/// This represents clause 'exclusive' in the '#pragma omp scan' directive.
9113///
9114/// \code
9115/// #pragma omp scan exclusive(a,b)
9116/// \endcode
9117/// In this example directive '#pragma omp scan' has clause 'exclusive'
9118/// with the variables 'a' and 'b'.
9119class OMPExclusiveClause final
9120 : public OMPVarListClause<OMPExclusiveClause>,
9121 private llvm::TrailingObjects<OMPExclusiveClause, Expr *> {
9122 friend class OMPClauseReader;
9123 friend OMPVarListClause;
9124 friend TrailingObjects;
9125
9126 /// Build clause with number of variables \a N.
9127 ///
9128 /// \param StartLoc Starting location of the clause.
9129 /// \param LParenLoc Location of '('.
9130 /// \param EndLoc Ending location of the clause.
9131 /// \param N Number of the variables in the clause.
9132 OMPExclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9133 SourceLocation EndLoc, unsigned N)
9134 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
9135 StartLoc, LParenLoc, EndLoc, N) {}
9136
9137 /// Build an empty clause.
9138 ///
9139 /// \param N Number of variables.
9140 explicit OMPExclusiveClause(unsigned N)
9141 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
9143 SourceLocation(), N) {}
9144
9145public:
9146 /// Creates clause with a list of variables \a VL.
9147 ///
9148 /// \param C AST context.
9149 /// \param StartLoc Starting location of the clause.
9150 /// \param LParenLoc Location of '('.
9151 /// \param EndLoc Ending location of the clause.
9152 /// \param VL List of references to the original variables.
9153 static OMPExclusiveClause *Create(const ASTContext &C,
9154 SourceLocation StartLoc,
9155 SourceLocation LParenLoc,
9156 SourceLocation EndLoc, ArrayRef<Expr *> VL);
9157
9158 /// Creates an empty clause with the place for \a N variables.
9159 ///
9160 /// \param C AST context.
9161 /// \param N The number of variables.
9162 static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
9163
9165 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9166 reinterpret_cast<Stmt **>(varlist_end()));
9167 }
9168
9170 return const_cast<OMPExclusiveClause *>(this)->children();
9171 }
9172
9179
9180 static bool classof(const OMPClause *T) {
9181 return T->getClauseKind() == llvm::omp::OMPC_exclusive;
9182 }
9183};
9184
9185/// This represents clause 'uses_allocators' in the '#pragma omp target'-based
9186/// directives.
9187///
9188/// \code
9189/// #pragma omp target uses_allocators(default_allocator, my_allocator(traits))
9190/// \endcode
9191/// In this example directive '#pragma omp target' has clause 'uses_allocators'
9192/// with the allocators 'default_allocator' and user-defined 'my_allocator'.
9193class OMPUsesAllocatorsClause final
9194 : public OMPClause,
9195 private llvm::TrailingObjects<OMPUsesAllocatorsClause, Expr *,
9196 SourceLocation> {
9197public:
9198 /// Data for list of allocators.
9199 struct Data {
9200 /// Allocator.
9201 Expr *Allocator = nullptr;
9202 /// Allocator traits.
9204 /// Locations of '(' and ')' symbols.
9206 };
9207
9208private:
9209 friend class OMPClauseReader;
9210 friend TrailingObjects;
9211
9212 enum class ExprOffsets {
9213 Allocator,
9214 AllocatorTraits,
9215 Total,
9216 };
9217
9218 enum class ParenLocsOffsets {
9219 LParen,
9220 RParen,
9221 Total,
9222 };
9223
9224 /// Location of '('.
9225 SourceLocation LParenLoc;
9226 /// Total number of allocators in the clause.
9227 unsigned NumOfAllocators = 0;
9228
9229 /// Build clause.
9230 ///
9231 /// \param StartLoc Starting location of the clause.
9232 /// \param LParenLoc Location of '('.
9233 /// \param EndLoc Ending location of the clause.
9234 /// \param N Number of allocators associated with the clause.
9235 OMPUsesAllocatorsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9236 SourceLocation EndLoc, unsigned N)
9237 : OMPClause(llvm::omp::OMPC_uses_allocators, StartLoc, EndLoc),
9238 LParenLoc(LParenLoc), NumOfAllocators(N) {}
9239
9240 /// Build an empty clause.
9241 /// \param N Number of allocators associated with the clause.
9242 ///
9243 explicit OMPUsesAllocatorsClause(unsigned N)
9244 : OMPClause(llvm::omp::OMPC_uses_allocators, SourceLocation(),
9245 SourceLocation()),
9246 NumOfAllocators(N) {}
9247
9248 unsigned numTrailingObjects(OverloadToken<Expr *>) const {
9249 return NumOfAllocators * static_cast<int>(ExprOffsets::Total);
9250 }
9251
9252 /// Sets the location of '('.
9253 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9254
9255 /// Sets the allocators data for the clause.
9256 void setAllocatorsData(ArrayRef<OMPUsesAllocatorsClause::Data> Data);
9257
9258public:
9259 /// Creates clause with a list of allocators \p Data.
9260 ///
9261 /// \param C AST context.
9262 /// \param StartLoc Starting location of the clause.
9263 /// \param LParenLoc Location of '('.
9264 /// \param EndLoc Ending location of the clause.
9265 /// \param Data List of allocators.
9266 static OMPUsesAllocatorsClause *
9267 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
9268 SourceLocation EndLoc, ArrayRef<OMPUsesAllocatorsClause::Data> Data);
9269
9270 /// Creates an empty clause with the place for \p N allocators.
9271 ///
9272 /// \param C AST context.
9273 /// \param N The number of allocators.
9274 static OMPUsesAllocatorsClause *CreateEmpty(const ASTContext &C, unsigned N);
9275
9276 /// Returns the location of '('.
9277 SourceLocation getLParenLoc() const { return LParenLoc; }
9278
9279 /// Returns number of allocators associated with the clause.
9280 unsigned getNumberOfAllocators() const { return NumOfAllocators; }
9281
9282 /// Returns data for the specified allocator.
9284
9285 // Iterators
9287 Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
9288 return child_range(Begin, Begin + NumOfAllocators *
9289 static_cast<int>(ExprOffsets::Total));
9290 }
9292 Stmt *const *Begin =
9293 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
9294 return const_child_range(
9295 Begin, Begin + NumOfAllocators * static_cast<int>(ExprOffsets::Total));
9296 }
9297
9304
9305 static bool classof(const OMPClause *T) {
9306 return T->getClauseKind() == llvm::omp::OMPC_uses_allocators;
9307 }
9308};
9309
9310/// This represents clause 'affinity' in the '#pragma omp task'-based
9311/// directives.
9312///
9313/// \code
9314/// #pragma omp task affinity(iterator(i = 0:n) : ([3][n])a, b[:n], c[i])
9315/// \endcode
9316/// In this example directive '#pragma omp task' has clause 'affinity' with the
9317/// affinity modifer 'iterator(i = 0:n)' and locator items '([3][n])a', 'b[:n]'
9318/// and 'c[i]'.
9319class OMPAffinityClause final
9320 : public OMPVarListClause<OMPAffinityClause>,
9321 private llvm::TrailingObjects<OMPAffinityClause, Expr *> {
9322 friend class OMPClauseReader;
9323 friend OMPVarListClause;
9324 friend TrailingObjects;
9325
9326 /// Location of ':' symbol.
9327 SourceLocation ColonLoc;
9328
9329 /// Build clause.
9330 ///
9331 /// \param StartLoc Starting location of the clause.
9332 /// \param LParenLoc Location of '('.
9333 /// \param ColonLoc Location of ':'.
9334 /// \param EndLoc Ending location of the clause.
9335 /// \param N Number of locators associated with the clause.
9336 OMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9337 SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N)
9338 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, StartLoc,
9339 LParenLoc, EndLoc, N) {}
9340
9341 /// Build an empty clause.
9342 /// \param N Number of locators associated with the clause.
9343 ///
9344 explicit OMPAffinityClause(unsigned N)
9345 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity,
9347 SourceLocation(), N) {}
9348
9349 /// Sets the affinity modifier for the clause, if any.
9350 void setModifier(Expr *E) { getTrailingObjects()[varlist_size()] = E; }
9351
9352 /// Sets the location of ':' symbol.
9353 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
9354
9355public:
9356 /// Creates clause with a modifier a list of locator items.
9357 ///
9358 /// \param C AST context.
9359 /// \param StartLoc Starting location of the clause.
9360 /// \param LParenLoc Location of '('.
9361 /// \param ColonLoc Location of ':'.
9362 /// \param EndLoc Ending location of the clause.
9363 /// \param Locators List of locator items.
9364 static OMPAffinityClause *Create(const ASTContext &C, SourceLocation StartLoc,
9365 SourceLocation LParenLoc,
9366 SourceLocation ColonLoc,
9367 SourceLocation EndLoc, Expr *Modifier,
9368 ArrayRef<Expr *> Locators);
9369
9370 /// Creates an empty clause with the place for \p N locator items.
9371 ///
9372 /// \param C AST context.
9373 /// \param N The number of locator items.
9374 static OMPAffinityClause *CreateEmpty(const ASTContext &C, unsigned N);
9375
9376 /// Gets affinity modifier.
9377 Expr *getModifier() { return getTrailingObjects()[varlist_size()]; }
9378 Expr *getModifier() const { return getTrailingObjects()[varlist_size()]; }
9379
9380 /// Gets the location of ':' symbol.
9381 SourceLocation getColonLoc() const { return ColonLoc; }
9382
9383 // Iterators
9385 int Offset = getModifier() ? 1 : 0;
9386 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9387 reinterpret_cast<Stmt **>(varlist_end() + Offset));
9388 }
9389
9391 return const_cast<OMPAffinityClause *>(this)->children();
9392 }
9393
9400
9401 static bool classof(const OMPClause *T) {
9402 return T->getClauseKind() == llvm::omp::OMPC_affinity;
9403 }
9404};
9405
9406/// This represents 'filter' clause in the '#pragma omp ...' directive.
9407///
9408/// \code
9409/// #pragma omp masked filter(tid)
9410/// \endcode
9411/// In this example directive '#pragma omp masked' has 'filter' clause with
9412/// thread id.
9414 : public OMPOneStmtClause<llvm::omp::OMPC_filter, OMPClause>,
9415 public OMPClauseWithPreInit {
9416 friend class OMPClauseReader;
9417
9418 /// Sets the thread identifier.
9419 void setThreadID(Expr *TID) { setStmt(TID); }
9420
9421public:
9422 /// Build 'filter' clause with thread-id \a ThreadID.
9423 ///
9424 /// \param ThreadID Thread identifier.
9425 /// \param HelperE Helper expression associated with this clause.
9426 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9427 /// clause must be captured.
9428 /// \param StartLoc Starting location of the clause.
9429 /// \param LParenLoc Location of '('.
9430 /// \param EndLoc Ending location of the clause.
9431 OMPFilterClause(Expr *ThreadID, Stmt *HelperE,
9432 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
9433 SourceLocation LParenLoc, SourceLocation EndLoc)
9434 : OMPOneStmtClause(ThreadID, StartLoc, LParenLoc, EndLoc),
9435 OMPClauseWithPreInit(this) {
9436 setPreInitStmt(HelperE, CaptureRegion);
9437 }
9438
9439 /// Build an empty clause.
9441
9442 /// Return thread identifier.
9443 Expr *getThreadID() const { return getStmtAs<Expr>(); }
9444
9445 /// Return thread identifier.
9447};
9448
9449/// This represents 'bind' clause in the '#pragma omp ...' directives.
9450///
9451/// \code
9452/// #pragma omp loop bind(parallel)
9453/// \endcode
9454class OMPBindClause final : public OMPNoChildClause<llvm::omp::OMPC_bind> {
9455 friend class OMPClauseReader;
9456
9457 /// Location of '('.
9458 SourceLocation LParenLoc;
9459
9460 /// The binding kind of 'bind' clause.
9462
9463 /// Start location of the kind in source code.
9464 SourceLocation KindLoc;
9465
9466 /// Sets the location of '('.
9467 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9468
9469 /// Set the binding kind.
9470 void setBindKind(OpenMPBindClauseKind K) { Kind = K; }
9471
9472 /// Set the binding kind location.
9473 void setBindKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
9474
9475 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9476 ///
9477 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9478 /// \param KLoc Starting location of the binding kind.
9479 /// \param StartLoc Starting location of the clause.
9480 /// \param LParenLoc Location of '('.
9481 /// \param EndLoc Ending location of the clause.
9482 OMPBindClause(OpenMPBindClauseKind K, SourceLocation KLoc,
9483 SourceLocation StartLoc, SourceLocation LParenLoc,
9484 SourceLocation EndLoc)
9485 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Kind(K),
9486 KindLoc(KLoc) {}
9487
9488 /// Build an empty clause.
9489 OMPBindClause() : OMPNoChildClause() {}
9490
9491public:
9492 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9493 ///
9494 /// \param C AST context
9495 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9496 /// \param KLoc Starting location of the binding kind.
9497 /// \param StartLoc Starting location of the clause.
9498 /// \param LParenLoc Location of '('.
9499 /// \param EndLoc Ending location of the clause.
9500 static OMPBindClause *Create(const ASTContext &C, OpenMPBindClauseKind K,
9501 SourceLocation KLoc, SourceLocation StartLoc,
9502 SourceLocation LParenLoc, SourceLocation EndLoc);
9503
9504 /// Build an empty 'bind' clause.
9505 ///
9506 /// \param C AST context
9507 static OMPBindClause *CreateEmpty(const ASTContext &C);
9508
9509 /// Returns the location of '('.
9510 SourceLocation getLParenLoc() const { return LParenLoc; }
9511
9512 /// Returns kind of the clause.
9513 OpenMPBindClauseKind getBindKind() const { return Kind; }
9514
9515 /// Returns location of clause kind.
9516 SourceLocation getBindKindLoc() const { return KindLoc; }
9517};
9518
9519/// This class implements a simple visitor for OMPClause
9520/// subclasses.
9521template<class ImplClass, template <typename> class Ptr, typename RetTy>
9523public:
9524#define PTR(CLASS) Ptr<CLASS>
9525#define DISPATCH(CLASS) \
9526 return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S))
9527
9528#define GEN_CLANG_CLAUSE_CLASS
9529#define CLAUSE_CLASS(Enum, Str, Class) \
9530 RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
9531#include "llvm/Frontend/OpenMP/OMP.inc"
9532
9533 RetTy Visit(PTR(OMPClause) S) {
9534 // Top switch clause: visit each OMPClause.
9535 switch (S->getClauseKind()) {
9536#define GEN_CLANG_CLAUSE_CLASS
9537#define CLAUSE_CLASS(Enum, Str, Class) \
9538 case llvm::omp::Clause::Enum: \
9539 return Visit##Class(static_cast<PTR(Class)>(S));
9540#define CLAUSE_NO_CLASS(Enum, Str) \
9541 case llvm::omp::Clause::Enum: \
9542 break;
9543#include "llvm/Frontend/OpenMP/OMP.inc"
9544 }
9545 }
9546 // Base case, ignore it. :)
9547 RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); }
9548#undef PTR
9549#undef DISPATCH
9550};
9551
9552template <typename T> using const_ptr = std::add_pointer_t<std::add_const_t<T>>;
9553
9554template <class ImplClass, typename RetTy = void>
9556 : public OMPClauseVisitorBase<ImplClass, std::add_pointer_t, RetTy> {};
9557template<class ImplClass, typename RetTy = void>
9559 public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {};
9560
9561class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
9562 raw_ostream &OS;
9563 const PrintingPolicy &Policy;
9564 unsigned Version;
9565
9566 /// Process clauses with list of variables.
9567 template <typename T> void VisitOMPClauseList(T *Node, char StartSym);
9568 /// Process motion clauses.
9569 template <typename T> void VisitOMPMotionClause(T *Node);
9570
9571public:
9572 OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy,
9573 unsigned OpenMPVersion)
9574 : OS(OS), Policy(Policy), Version(OpenMPVersion) {}
9575
9576#define GEN_CLANG_CLAUSE_CLASS
9577#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
9578#include "llvm/Frontend/OpenMP/OMP.inc"
9579};
9580
9582 llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
9583
9584 /// The raw string as we parsed it. This is needed for the `isa` trait set
9585 /// (which accepts anything) and (later) extensions.
9586 StringRef RawString;
9587};
9588
9591 llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
9593};
9594
9596 llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
9598};
9599
9600/// Helper data structure representing the traits in a match clause of an
9601/// `declare variant` or `metadirective`. The outer level is an ordered
9602/// collection of selector sets, each with an associated kind and an ordered
9603/// collection of selectors. A selector has a kind, an optional score/condition,
9604/// and an ordered collection of properties.
9605class OMPTraitInfo {
9606 /// Private constructor accesible only by ASTContext.
9607 OMPTraitInfo() {}
9608 friend class ASTContext;
9609
9610public:
9611 /// Reconstruct a (partial) OMPTraitInfo object from a mangled name.
9612 OMPTraitInfo(StringRef MangledName);
9613
9614 /// The outermost level of selector sets.
9616
9618 llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) {
9619 return llvm::any_of(Sets, [&](OMPTraitSet &Set) {
9620 return llvm::any_of(
9621 Set.Selectors, [&](OMPTraitSelector &Selector) {
9622 return Cond(Selector.ScoreOrCondition,
9623 /* IsScore */ Selector.Kind !=
9624 llvm::omp::TraitSelector::user_condition);
9625 });
9626 });
9627 }
9628
9629 /// Create a variant match info object from this trait info object. While the
9630 /// former is a flat representation the actual main difference is that the
9631 /// latter uses clang::Expr to store the score/condition while the former is
9632 /// independent of clang. Thus, expressions and conditions are evaluated in
9633 /// this method.
9634 void getAsVariantMatchInfo(ASTContext &ASTCtx,
9635 llvm::omp::VariantMatchInfo &VMI) const;
9636
9637 /// Return a string representation identifying this context selector.
9638 std::string getMangledName() const;
9639
9640 /// Check the extension trait \p TP is active.
9641 bool isExtensionActive(llvm::omp::TraitProperty TP) {
9642 for (const OMPTraitSet &Set : Sets) {
9643 if (Set.Kind != llvm::omp::TraitSet::implementation)
9644 continue;
9645 for (const OMPTraitSelector &Selector : Set.Selectors) {
9646 if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
9647 continue;
9648 for (const OMPTraitProperty &Property : Selector.Properties) {
9649 if (Property.Kind == TP)
9650 return true;
9651 }
9652 }
9653 }
9654 return false;
9655 }
9656
9657 /// Print a human readable representation into \p OS.
9658 void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
9659};
9660llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
9661llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
9662
9663/// Clang specific specialization of the OMPContext to lookup target features.
9666 std::function<void(StringRef)> &&DiagUnknownTrait,
9667 const FunctionDecl *CurrentFunctionDecl,
9668 ArrayRef<llvm::omp::TraitProperty> ConstructTraits,
9669 int DeviceNum);
9670
9671 virtual ~TargetOMPContext() = default;
9672
9673 /// See llvm::omp::OMPContext::matchesISATrait
9674 bool matchesISATrait(StringRef RawString) const override;
9675
9676private:
9677 std::function<bool(StringRef)> FeatureValidityCheck;
9678 std::function<void(StringRef)> DiagUnknownTrait;
9679 llvm::StringMap<bool> FeatureMap;
9680};
9681
9682/// Contains data for OpenMP directives: clauses, children
9683/// expressions/statements (helpers for codegen) and associated statement, if
9684/// any.
9685class OMPChildren final
9686 : private llvm::TrailingObjects<OMPChildren, OMPClause *, Stmt *> {
9687 friend TrailingObjects;
9688 friend class OMPClauseReader;
9690 template <typename T> friend class OMPDeclarativeDirective;
9691
9692 /// Numbers of clauses.
9693 unsigned NumClauses = 0;
9694 /// Number of child expressions/stmts.
9695 unsigned NumChildren = 0;
9696 /// true if the directive has associated statement.
9697 bool HasAssociatedStmt = false;
9698
9699 /// Define the sizes of each trailing object array except the last one. This
9700 /// is required for TrailingObjects to work properly.
9701 size_t numTrailingObjects(OverloadToken<OMPClause *>) const {
9702 return NumClauses;
9703 }
9704
9705 OMPChildren() = delete;
9706
9707 OMPChildren(unsigned NumClauses, unsigned NumChildren, bool HasAssociatedStmt)
9708 : NumClauses(NumClauses), NumChildren(NumChildren),
9709 HasAssociatedStmt(HasAssociatedStmt) {}
9710
9711 static size_t size(unsigned NumClauses, bool HasAssociatedStmt,
9712 unsigned NumChildren);
9713
9714 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses);
9715 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses, Stmt *S,
9716 unsigned NumChildren = 0);
9717 static OMPChildren *CreateEmpty(void *Mem, unsigned NumClauses,
9718 bool HasAssociatedStmt = false,
9719 unsigned NumChildren = 0);
9720
9721public:
9722 unsigned getNumClauses() const { return NumClauses; }
9723 unsigned getNumChildren() const { return NumChildren; }
9724 bool hasAssociatedStmt() const { return HasAssociatedStmt; }
9725
9726 /// Set associated statement.
9728 getTrailingObjects<Stmt *>()[NumChildren] = S;
9729 }
9730
9732
9733 /// Sets the list of variables for this clause.
9734 ///
9735 /// \param Clauses The list of clauses for the directive.
9736 ///
9737 void setClauses(ArrayRef<OMPClause *> Clauses);
9738
9739 /// Returns statement associated with the directive.
9740 const Stmt *getAssociatedStmt() const {
9741 return const_cast<OMPChildren *>(this)->getAssociatedStmt();
9742 }
9744 assert(HasAssociatedStmt &&
9745 "Expected directive with the associated statement.");
9746 return getTrailingObjects<Stmt *>()[NumChildren];
9747 }
9748
9749 /// Get the clauses storage.
9751 return getTrailingObjects<OMPClause *>(NumClauses);
9752 }
9754 return const_cast<OMPChildren *>(this)->getClauses();
9755 }
9756
9757 /// Returns the captured statement associated with the
9758 /// component region within the (combined) directive.
9759 ///
9760 /// \param RegionKind Component region kind.
9761 const CapturedStmt *
9763 ArrayRef<OpenMPDirectiveKind> CaptureRegions) const {
9764 assert(llvm::is_contained(CaptureRegions, RegionKind) &&
9765 "RegionKind not found in OpenMP CaptureRegions.");
9767 for (auto ThisCaptureRegion : CaptureRegions) {
9768 if (ThisCaptureRegion == RegionKind)
9769 return CS;
9770 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9771 }
9772 llvm_unreachable("Incorrect RegionKind specified for directive.");
9773 }
9774
9775 /// Get innermost captured statement for the construct.
9776 CapturedStmt *
9778 assert(hasAssociatedStmt() && "Must have associated captured statement.");
9779 assert(!CaptureRegions.empty() &&
9780 "At least one captured statement must be provided.");
9782 for (unsigned Level = CaptureRegions.size(); Level > 1; --Level)
9783 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9784 return CS;
9785 }
9786
9787 const CapturedStmt *
9789 return const_cast<OMPChildren *>(this)->getInnermostCapturedStmt(
9790 CaptureRegions);
9791 }
9792
9795 return const_cast<OMPChildren *>(this)->getChildren();
9796 }
9797
9799 assert(HasAssociatedStmt &&
9800 "Expected directive with the associated statement.");
9801 if (auto *CS = dyn_cast<CapturedStmt>(getAssociatedStmt())) {
9802 Stmt *S = nullptr;
9803 do {
9804 S = CS->getCapturedStmt();
9805 CS = dyn_cast<CapturedStmt>(S);
9806 } while (CS);
9807 return S;
9808 }
9809 return getAssociatedStmt();
9810 }
9811 const Stmt *getRawStmt() const {
9812 return const_cast<OMPChildren *>(this)->getRawStmt();
9813 }
9814
9816 if (!HasAssociatedStmt)
9818 return Stmt::child_range(&getTrailingObjects<Stmt *>()[NumChildren],
9819 &getTrailingObjects<Stmt *>()[NumChildren + 1]);
9820 }
9821};
9822
9823/// This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...'
9824/// directive.
9825///
9826/// \code
9827/// #pragma omp target [...] ompx_dyn_cgroup_mem(N)
9828/// \endcode
9830 : public OMPOneStmtClause<llvm::omp::OMPC_ompx_dyn_cgroup_mem, OMPClause>,
9831 public OMPClauseWithPreInit {
9832 friend class OMPClauseReader;
9833
9834 /// Set size.
9835 void setSize(Expr *E) { setStmt(E); }
9836
9837public:
9838 /// Build 'ompx_dyn_cgroup_mem' clause.
9839 ///
9840 /// \param Size Size expression.
9841 /// \param HelperSize Helper Size expression
9842 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9843 /// \param StartLoc Starting location of the clause.
9844 /// \param LParenLoc Location of '('.
9845 /// \param EndLoc Ending location of the clause.
9847 OpenMPDirectiveKind CaptureRegion,
9848 SourceLocation StartLoc, SourceLocation LParenLoc,
9849 SourceLocation EndLoc)
9850 : OMPOneStmtClause(Size, StartLoc, LParenLoc, EndLoc),
9851 OMPClauseWithPreInit(this) {
9852 setPreInitStmt(HelperSize, CaptureRegion);
9853 }
9854
9855 /// Build an empty clause.
9857
9858 /// Return the size expression.
9860
9861 /// Return the size expression.
9862 Expr *getSize() const { return getStmtAs<Expr>(); }
9863};
9864
9865/// This represents 'dyn_groupprivate' clause in '#pragma omp target ...'
9866/// and '#pragma omp teams ...' directives.
9867///
9868/// \code
9869/// #pragma omp target [...] dyn_groupprivate(a,b: N)
9870/// \endcode
9872 friend class OMPClauseReader;
9873
9874 /// Location of '('.
9875 SourceLocation LParenLoc;
9876
9877 /// Modifiers for 'dyn_groupprivate' clause.
9878 enum { SIMPLE, FALLBACK, NUM_MODIFIERS };
9879 unsigned Modifiers[NUM_MODIFIERS];
9880
9881 /// Locations of modifiers.
9882 SourceLocation ModifiersLoc[NUM_MODIFIERS];
9883
9884 /// The size of the dyn_groupprivate.
9885 Expr *Size = nullptr;
9886
9887 /// Set the first dyn_groupprivate modifier.
9888 ///
9889 /// \param M The modifier.
9890 void setDynGroupprivateModifier(OpenMPDynGroupprivateClauseModifier M) {
9891 Modifiers[SIMPLE] = M;
9892 }
9893
9894 /// Set the second dyn_groupprivate modifier.
9895 ///
9896 /// \param M The modifier.
9897 void setDynGroupprivateFallbackModifier(
9899 Modifiers[FALLBACK] = M;
9900 }
9901
9902 /// Set location of the first dyn_groupprivate modifier.
9903 void setDynGroupprivateModifierLoc(SourceLocation Loc) {
9904 ModifiersLoc[SIMPLE] = Loc;
9905 }
9906
9907 /// Set location of the second dyn_groupprivate modifier.
9908 void setDynGroupprivateFallbackModifierLoc(SourceLocation Loc) {
9909 ModifiersLoc[FALLBACK] = Loc;
9910 }
9911
9912 /// Sets the location of '('.
9913 ///
9914 /// \param Loc Location of '('.
9915 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9916
9917 /// Set size.
9918 ///
9919 /// \param E Size.
9920 void setSize(Expr *E) { Size = E; }
9921
9922public:
9923 /// Build 'dyn_groupprivate' clause with a size expression \a Size.
9924 ///
9925 /// \param StartLoc Starting location of the clause.
9926 /// \param LParenLoc Location of '('.
9927 /// \param EndLoc Ending location of the clause.
9928 /// \param Size Size.
9929 /// \param M1 The first modifier applied to 'dyn_groupprivate' clause.
9930 /// \param M1Loc Location of the first modifier.
9931 /// \param M2 The second modifier applied to 'dyn_groupprivate' clause.
9932 /// \param M2Loc Location of the second modifier.
9934 SourceLocation EndLoc, Expr *Size, Stmt *HelperSize,
9935 OpenMPDirectiveKind CaptureRegion,
9937 SourceLocation M1Loc,
9939 SourceLocation M2Loc)
9940 : OMPClause(llvm::omp::OMPC_dyn_groupprivate, StartLoc, EndLoc),
9941 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Size(Size) {
9942 setPreInitStmt(HelperSize, CaptureRegion);
9943 Modifiers[SIMPLE] = M1;
9944 Modifiers[FALLBACK] = M2;
9945 ModifiersLoc[SIMPLE] = M1Loc;
9946 ModifiersLoc[FALLBACK] = M2Loc;
9947 }
9948
9949 /// Build an empty clause.
9951 : OMPClause(llvm::omp::OMPC_dyn_groupprivate, SourceLocation(),
9952 SourceLocation()),
9953 OMPClauseWithPreInit(this) {
9954 Modifiers[SIMPLE] = OMPC_DYN_GROUPPRIVATE_unknown;
9955 Modifiers[FALLBACK] = OMPC_DYN_GROUPPRIVATE_FALLBACK_unknown;
9956 }
9957
9958 /// Get the first modifier of the clause.
9962
9963 /// Get the second modifier of the clause.
9967 Modifiers[FALLBACK]);
9968 }
9969
9970 /// Get location of '('.
9971 SourceLocation getLParenLoc() { return LParenLoc; }
9972
9973 /// Get the first modifier location.
9975 return ModifiersLoc[SIMPLE];
9976 }
9977
9978 /// Get the second modifier location.
9980 return ModifiersLoc[FALLBACK];
9981 }
9982
9983 /// Get size.
9984 Expr *getSize() { return Size; }
9985
9986 /// Get size.
9987 const Expr *getSize() const { return Size; }
9988
9990 return child_range(reinterpret_cast<Stmt **>(&Size),
9991 reinterpret_cast<Stmt **>(&Size) + 1);
9992 }
9993
9995 return const_cast<OMPDynGroupprivateClause *>(this)->children();
9996 }
9997
10004
10005 static bool classof(const OMPClause *T) {
10006 return T->getClauseKind() == llvm::omp::OMPC_dyn_groupprivate;
10007 }
10008};
10009
10010/// This represents the 'doacross' clause for the '#pragma omp ordered'
10011/// directive.
10012///
10013/// \code
10014/// #pragma omp ordered doacross(sink: i-1, j-1)
10015/// \endcode
10016/// In this example directive '#pragma omp ordered' with clause 'doacross' with
10017/// a dependence-type 'sink' and loop-iteration vector expressions i-1 and j-1.
10018class OMPDoacrossClause final
10019 : public OMPVarListClause<OMPDoacrossClause>,
10020 private llvm::TrailingObjects<OMPDoacrossClause, Expr *> {
10021 friend class OMPClauseReader;
10022 friend OMPVarListClause;
10023 friend TrailingObjects;
10024
10025 /// Dependence type (sink or source).
10027
10028 /// Dependence type location.
10029 SourceLocation DepLoc;
10030
10031 /// Colon location.
10032 SourceLocation ColonLoc;
10033
10034 /// Number of loops, associated with the doacross clause.
10035 unsigned NumLoops = 0;
10036
10037 /// Build clause with number of expressions \a N.
10038 ///
10039 /// \param StartLoc Starting location of the clause.
10040 /// \param LParenLoc Location of '('.
10041 /// \param EndLoc Ending location of the clause.
10042 /// \param N Number of expressions in the clause.
10043 /// \param NumLoops Number of loops associated with the clause.
10044 OMPDoacrossClause(SourceLocation StartLoc, SourceLocation LParenLoc,
10045 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
10046 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross, StartLoc,
10047 LParenLoc, EndLoc, N),
10048 NumLoops(NumLoops) {}
10049
10050 /// Build an empty clause.
10051 ///
10052 /// \param N Number of expressions in the clause.
10053 /// \param NumLoops Number of loops associated with the clause.
10054 explicit OMPDoacrossClause(unsigned N, unsigned NumLoops)
10055 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross,
10057 SourceLocation(), N),
10058 NumLoops(NumLoops) {}
10059
10060 /// Set dependence type.
10061 void setDependenceType(OpenMPDoacrossClauseModifier M) { DepType = M; }
10062
10063 /// Set dependence type location.
10064 void setDependenceLoc(SourceLocation Loc) { DepLoc = Loc; }
10065
10066 /// Set colon location.
10067 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
10068
10069public:
10070 /// Creates clause with a list of expressions \a VL.
10071 ///
10072 /// \param C AST context.
10073 /// \param StartLoc Starting location of the clause.
10074 /// \param LParenLoc Location of '('.
10075 /// \param EndLoc Ending location of the clause.
10076 /// \param DepType The dependence type.
10077 /// \param DepLoc Location of the dependence type.
10078 /// \param ColonLoc Location of ':'.
10079 /// \param VL List of references to the expressions.
10080 /// \param NumLoops Number of loops that associated with the clause.
10081 static OMPDoacrossClause *
10082 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
10083 SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType,
10084 SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
10085 unsigned NumLoops);
10086
10087 /// Creates an empty clause with \a N expressions.
10088 ///
10089 /// \param C AST context.
10090 /// \param N The number of expressions.
10091 /// \param NumLoops Number of loops that is associated with this clause.
10092 static OMPDoacrossClause *CreateEmpty(const ASTContext &C, unsigned N,
10093 unsigned NumLoops);
10094
10095 /// Get dependence type.
10097
10098 /// Get dependence type location.
10099 SourceLocation getDependenceLoc() const { return DepLoc; }
10100
10101 /// Get colon location.
10102 SourceLocation getColonLoc() const { return ColonLoc; }
10103
10104 /// Get number of loops associated with the clause.
10105 unsigned getNumLoops() const { return NumLoops; }
10106
10107 /// Set the loop data.
10108 void setLoopData(unsigned NumLoop, Expr *Cnt);
10109
10110 /// Get the loop data.
10111 Expr *getLoopData(unsigned NumLoop);
10112 const Expr *getLoopData(unsigned NumLoop) const;
10113
10115 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
10116 reinterpret_cast<Stmt **>(varlist_end()));
10117 }
10118
10120 return const_cast<OMPDoacrossClause *>(this)->children();
10121 }
10122
10129
10130 static bool classof(const OMPClause *T) {
10131 return T->getClauseKind() == llvm::omp::OMPC_doacross;
10132 }
10133};
10134
10135/// This represents 'ompx_attribute' clause in a directive that might generate
10136/// an outlined function. An example is given below.
10137///
10138/// \code
10139/// #pragma omp target [...] ompx_attribute(flatten)
10140/// \endcode
10142 : public OMPNoChildClause<llvm::omp::OMPC_ompx_attribute> {
10143 friend class OMPClauseReader;
10144
10145 /// Location of '('.
10146 SourceLocation LParenLoc;
10147
10148 /// The parsed attributes (clause arguments)
10150
10151public:
10152 /// Build 'ompx_attribute' clause.
10153 ///
10154 /// \param Attrs The parsed attributes (clause arguments)
10155 /// \param StartLoc Starting location of the clause.
10156 /// \param LParenLoc Location of '('.
10157 /// \param EndLoc Ending location of the clause.
10159 SourceLocation LParenLoc, SourceLocation EndLoc)
10160 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Attrs(Attrs) {
10161 }
10162
10163 /// Build an empty clause.
10165
10166 /// Sets the location of '('.
10167 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
10168
10169 /// Returns the location of '('.
10170 SourceLocation getLParenLoc() const { return LParenLoc; }
10171
10172 /// Returned the attributes parsed from this clause.
10173 ArrayRef<const Attr *> getAttrs() const { return Attrs; }
10174
10175private:
10176 /// Replace the attributes with \p NewAttrs.
10177 void setAttrs(ArrayRef<Attr *> NewAttrs) {
10178 Attrs.clear();
10179 Attrs.append(NewAttrs.begin(), NewAttrs.end());
10180 }
10181};
10182
10183/// This represents 'ompx_bare' clause in the '#pragma omp target teams ...'
10184/// directive.
10185///
10186/// \code
10187/// #pragma omp target teams ompx_bare
10188/// \endcode
10189/// In this example directive '#pragma omp target teams' has a 'ompx_bare'
10190/// clause.
10191class OMPXBareClause : public OMPNoChildClause<llvm::omp::OMPC_ompx_bare> {
10192public:
10193 /// Build 'ompx_bare' clause.
10194 ///
10195 /// \param StartLoc Starting location of the clause.
10196 /// \param EndLoc Ending location of the clause.
10198 : OMPNoChildClause(StartLoc, EndLoc) {}
10199
10200 /// Build an empty clause.
10201 OMPXBareClause() = default;
10202};
10203
10204} // namespace clang
10205
10206#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
#define V(N, I)
Forward declaration of all AST node types.
#define PTR(CLASS)
Definition AttrVisitor.h:27
SmallVector< AnnotatedLine *, 1 > Children
If this token starts a block, this contains all the unwrapped lines in it.
static const Decl * getCanonicalDecl(const Decl *D)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines some OpenMP-specific enums and functions.
Defines the clang::SourceLocation class and associated facilities.
static OMPAtomicDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:220
a trap message and trap category.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:220
This captures a statement into a function.
Definition Stmt.h:3917
This represents one expression.
Definition Expr.h:112
Represents a function declaration or definition.
Definition Decl.h:2000
A C++ nested-name-specifier augmented with source location information.
static OMPAbsentClause * CreateEmpty(const ASTContext &C, unsigned NumKinds)
static bool classof(const OMPClause *C)
static bool classof(const OMPClause *T)
OMPAcqRelClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'ack_rel' clause.
const_child_range used_children() const
child_range used_children()
const_child_range children() const
OMPAcqRelClause()
Build an empty clause.
static bool classof(const OMPClause *T)
const_child_range children() const
OMPAcquireClause()
Build an empty clause.
child_range used_children()
const_child_range used_children() const
OMPAcquireClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'acquire' clause.
This represents clause 'affinity' in the 'pragma omp task'-based directives.
Expr * getModifier()
Gets affinity modifier.
const_child_range children() const
static OMPAffinityClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N locator items.
SourceLocation getColonLoc() const
Gets the location of ':' symbol.
const_child_range used_children() const
static bool classof(const OMPClause *T)
This represents the 'align' clause in the 'pragma omp allocate' directive.
friend class OMPClauseReader
Expr * getAlignment() const
Returns alignment.
This represents clause 'aligned' in the 'pragma omp ...' directives.
Expr * getAlignment()
Returns alignment.
const Expr * getAlignment() const
Returns alignment.
void setColonLoc(SourceLocation Loc)
Sets the location of ':'.
const_child_range used_children() const
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
const_child_range children() const
SourceLocation getColonLoc() const
Returns the location of ':'.
static bool classof(const OMPClause *T)
child_range used_children()
This represents clause 'allocate' in the 'pragma omp ...' directives.
const_child_range children() const
SourceLocation getAllocatorModifierLoc() const
Return the location of the modifier.
const_child_range used_children() const
OpenMPAllocateClauseModifier getAllocatorModifier() const
Return 'allocate' modifier.
OpenMPAllocateClauseModifier getSecondAllocateModifier() const
Get the second modifier of the clause.
SourceLocation getColonLoc() const
Returns the location of the ':' delimiter.
Expr * getAlignment() const
Returns the alignment expression or nullptr, if no alignment specified.
OpenMPAllocateClauseModifier getFirstAllocateModifier() const
Get the first modifier of the clause.
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
SourceLocation getSecondAllocateModifierLoc() const
Get location of second modifier of the clause.
child_range used_children()
SourceLocation getFirstAllocateModifierLoc() const
Get location of first modifier of the clause.
static OMPAllocateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static bool classof(const OMPClause *T)
OMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'allocator' clause with the given allocator.
OMPAllocatorClause()
Build an empty clause.
Expr * getAllocator() const
Returns allocator.
friend class OMPClauseReader
OMPAtClause(OpenMPAtClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'at' clause with argument A ('compilation' or 'execution').
SourceLocation getAtKindKwLoc() const
Returns location of clause kind.
child_range children()
static bool classof(const OMPClause *T)
OpenMPAtClauseKind getAtKind() const
Returns kind of the clause.
const_child_range used_children() const
child_range used_children()
SourceLocation getLParenLoc() const
Returns the locaiton of '('.
OMPAtClause()
Build an empty clause.
const_child_range children() const
const_child_range used_children() const
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the locaiton of '('.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const
Returns kind of the clause.
OMPAtomicDefaultMemOrderClause(OpenMPAtomicDefaultMemOrderClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'atomic_default_mem_order' clause with argument A ('seq_cst', 'acq_rel' or 'relaxed').
const_child_range children() const
OMPAtomicDefaultMemOrderClause()
Build an empty clause.
SourceLocation getAtomicDefaultMemOrderKindKwLoc() const
Returns location of clause kind.
OpenMPBindClauseKind getBindKind() const
Returns kind of the clause.
friend class OMPClauseReader
SourceLocation getLParenLoc() const
Returns the location of '('.
SourceLocation getBindKindLoc() const
Returns location of clause kind.
static OMPBindClause * CreateEmpty(const ASTContext &C)
Build an empty 'bind' clause.
OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'capture' clause.
const_child_range used_children() const
child_range used_children()
const_child_range children() const
static bool classof(const OMPClause *T)
OMPCaptureClause()
Build an empty clause.
Contains data for OpenMP directives: clauses, children expressions/statements (helpers for codegen) a...
unsigned getNumClauses() const
const CapturedStmt * getCapturedStmt(OpenMPDirectiveKind RegionKind, ArrayRef< OpenMPDirectiveKind > CaptureRegions) const
Returns the captured statement associated with the component region within the (combined) directive.
friend class OMPClauseReader
bool hasAssociatedStmt() const
Stmt::child_range getAssociatedStmtAsRange()
void setClauses(ArrayRef< OMPClause * > Clauses)
Sets the list of variables for this clause.
friend class OMPDeclarativeDirective
unsigned getNumChildren() const
const Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
void setChildren(ArrayRef< Stmt * > Children)
ArrayRef< Stmt * > getChildren() const
MutableArrayRef< OMPClause * > getClauses()
Get the clauses storage.
friend class OMPExecutableDirective
MutableArrayRef< Stmt * > getChildren()
const Stmt * getRawStmt() const
void setAssociatedStmt(Stmt *S)
Set associated statement.
CapturedStmt * getInnermostCapturedStmt(ArrayRef< OpenMPDirectiveKind > CaptureRegions)
Get innermost captured statement for the construct.
ArrayRef< OMPClause * > getClauses() const
const CapturedStmt * getInnermostCapturedStmt(ArrayRef< OpenMPDirectiveKind > CaptureRegions) const
Class that represents a component of a mappable expression.
bool operator==(const MappableComponent &Other) const
MappableComponent(Expr *AssociatedExpression, ValueDecl *AssociatedDeclaration, bool IsNonContiguous)
Struct that defines common infrastructure to handle mappable expressions used in OpenMP clauses.
ArrayRef< MappableExprComponentList > MappableExprComponentListsRef
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< const ValueDecl * > Declarations)
static unsigned getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists)
ArrayRef< MappableComponent > MappableExprComponentListRef
SmallVector< MappableComponent, 8 > MappableExprComponentList
friend llvm::hash_code hash_value(const MappableComponent &MC)
SmallVector< MappableExprComponentList, 8 > MappableExprComponentLists
static std::pair< const Expr *, std::optional< size_t > > findAttachPtrExpr(MappableExprComponentListRef Components, OpenMPDirectiveKind CurDirKind)
Find the attach pointer expression from a list of mappable expression components.
static QualType getComponentExprElementType(const Expr *Exp)
Get the type of an element of a ComponentList Expr Exp.
OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy, unsigned OpenMPVersion)
This class implements a simple visitor for OMPClause subclasses.
RetTy VisitOMPClause(PTR(OMPClause) Node)
RetTy Visit(PTR(OMPClause) S)
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc.
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
static OMPClauseWithPostUpdate * get(OMPClause *C)
Expr * getPostUpdateExpr()
Get post-update expression for the clause.
OMPClauseWithPostUpdate(const OMPClause *This)
const Expr * getPostUpdateExpr() const
Get post-update expression for the clause.
Class that handles pre-initialization statement for some clauses, like 'schedule',...
const Stmt * getPreInitStmt() const
Get pre-initialization statement for the clause.
OMPClauseWithPreInit(const OMPClause *This)
OpenMPDirectiveKind getCaptureRegion() const
Get capture region for the stmt in the clause.
Stmt * getPreInitStmt()
Get pre-initialization statement for the clause.
static OMPClauseWithPreInit * get(OMPClause *C)
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=llvm::omp::OMPD_unknown)
Set pre-initialization statement for the clause.
This is a basic class for representing single OpenMP clause.
const_child_range children() const
void setLocStart(SourceLocation Loc)
Sets the starting location of the clause.
static bool classof(const OMPClause *)
SourceLocation getBeginLoc() const
Returns the starting location of the clause.
llvm::iterator_range< const_child_iterator > const_child_range
ConstStmtIterator const_child_iterator
child_range used_children()
Get the iterator range for the expressions used in the clauses.
llvm::iterator_range< child_iterator > child_range
OMPClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation EndLoc)
void setLocEnd(SourceLocation Loc)
Sets the ending location of the clause.
bool isImplicit() const
StmtIterator child_iterator
SourceLocation getEndLoc() const
Returns the ending location of the clause.
child_range children()
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
const_child_range used_children() const
OMPCollapseClause()
Build an empty clause.
Expr * getNumForLoops() const
Return the number of associated for-loops.
OMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'collapse' clause.
const_child_range used_children() const
OMPCompareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'compare' clause.
child_range used_children()
const_child_range children() const
OMPCompareClause()
Build an empty clause.
static bool classof(const OMPClause *T)
static OMPContainsClause * CreateEmpty(const ASTContext &C, unsigned NumKinds)
static bool classof(const OMPClause *C)
This represents clause 'copyin' in the 'pragma omp ...' directives.
friend class OMPClauseReader
helper_expr_range assignment_ops()
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
MutableArrayRef< Expr * >::iterator helper_expr_iterator
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
const_child_range children() const
helper_expr_const_range source_exprs() const
llvm::iterator_range< helper_expr_iterator > helper_expr_range
helper_expr_range source_exprs()
static bool classof(const OMPClause *T)
const_child_range used_children() const
child_range used_children()
helper_expr_const_range destination_exprs() const
helper_expr_range destination_exprs()
helper_expr_const_range assignment_ops() const
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents clause 'copyprivate' in the 'pragma omp ...' directives.
helper_expr_range source_exprs()
MutableArrayRef< Expr * >::iterator helper_expr_iterator
llvm::iterator_range< helper_expr_iterator > helper_expr_range
helper_expr_const_range destination_exprs() const
helper_expr_range destination_exprs()
const_child_range children() const
static bool classof(const OMPClause *T)
const_child_range used_children() const
helper_expr_const_range source_exprs() const
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
helper_expr_range assignment_ops()
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
helper_expr_const_range assignment_ops() const
const_child_range used_children() const
OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc, OpenMPDefaultClauseVariableCategory VC, SourceLocation VCLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'default' clause with argument A ('none' or 'shared').
SourceLocation getLParenLoc() const
Returns the location of '('.
llvm::omp::DefaultKind getDefaultKind() const
Returns kind of the clause.
SourceLocation getDefaultKindKwLoc() const
Returns location of clause kind.
OpenMPDefaultClauseVariableCategory getDefaultVC() const
static bool classof(const OMPClause *T)
child_range used_children()
const_child_range children() const
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OMPDefaultClause()
Build an empty clause.
SourceLocation getDefaultVCLoc() const
const_child_range children() const
SourceLocation getDefaultmapKindLoc()
Get kind location.
static bool classof(const OMPClause *T)
OMPDefaultmapClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KLoc, SourceLocation EndLoc, OpenMPDefaultmapClauseKind Kind, OpenMPDefaultmapClauseModifier M)
Build 'defaultmap' clause with defaultmap kind Kind.
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
OMPDefaultmapClause()
Build an empty clause.
SourceLocation getDefaultmapModifierLoc() const
Get the modifier location.
const_child_range used_children() const
SourceLocation getLParenLoc()
Get location of '('.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
This represents implicit clause 'depend' for the 'pragma omp task' directive.
SourceLocation getDependencyLoc() const
Get dependency type location.
friend class OMPClauseReader
static bool classof(const OMPClause *T)
unsigned getNumLoops() const
Get number of loops associated with the clause.
Expr * getModifier()
Return optional depend modifier.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
SourceLocation getOmpAllMemoryLoc() const
Get 'omp_all_memory' location.
const_child_range used_children() const
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with 'sink|source' kind of dependency.
const_child_range children() const
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
const Expr * getModifier() const
child_range used_children()
SourceLocation getColonLoc() const
Get colon location.
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
This represents implicit clause 'depobj' for the 'pragma omp depobj' directive.
SourceLocation getLParenLoc() const
Returns the location of '('.
static bool classof(const OMPClause *T)
friend class OMPClauseReader
const_child_range used_children() const
const_child_range children() const
static OMPDepobjClause * CreateEmpty(const ASTContext &C)
Creates an empty clause.
Expr * getDepobj()
Returns depobj expression associated with the clause.
child_range used_children()
const Expr * getDepobj() const
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPDestroyClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'destroy' clause.
child_range used_children()
const_child_range children() const
OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build 'destroy' clause with an interop variable expression InteropVar.
SourceLocation getVarLoc() const
Returns the location of the interop variable.
Expr * getInteropVar() const
Returns the interop variable.
OMPDestroyClause()
Build an empty clause.
const_child_range used_children() const
OMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'detach' clause with event-handler Evt.
friend class OMPClauseReader
OMPDetachClause()
Build an empty clause.
Expr * getEventHandler() const
Returns event-handler expression.
OMPDeviceClause()
Build an empty clause.
const_child_range used_children() const
friend class OMPClauseReader
OpenMPDeviceClauseModifier getModifier() const
Gets modifier.
child_range used_children()
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
const_child_range children() const
Expr * getDevice()
Return device number.
Expr * getDevice() const
Return device number.
OMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build 'device' clause.
SourceLocation getModifierLoc() const
Gets modifier location.
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the location of '('.
MutableArrayRef< OpenMPDirectiveKind > getDirectiveKinds()
void setDirectiveKinds(ArrayRef< OpenMPDirectiveKind > DK)
const_child_range children() const
unsigned NumKinds
Number of directive kinds listed in the clause.
void setLParenLoc(SourceLocation S)
const_child_range used_children() const
OMPDirectiveListClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, unsigned NumKinds)
Build a clause with NumKinds directive kinds.
OMPDistScheduleClause()
Build an empty clause.
const_child_range used_children() const
SourceLocation getCommaLoc()
Get location of ','.
const_child_range children() const
SourceLocation getDistScheduleKindLoc()
Get kind location.
OMPDistScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KLoc, SourceLocation CommaLoc, SourceLocation EndLoc, OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, Stmt *HelperChunkSize)
Build 'dist_schedule' clause with schedule kind Kind and chunk size expression ChunkSize.
const Expr * getChunkSize() const
Get chunk size.
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
Expr * getChunkSize()
Get chunk size.
SourceLocation getLParenLoc()
Get location of '('.
static bool classof(const OMPClause *T)
This represents the 'doacross' clause for the 'pragma omp ordered' directive.
const_child_range children() const
const_child_range used_children() const
static bool classof(const OMPClause *T)
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
SourceLocation getColonLoc() const
Get colon location.
unsigned getNumLoops() const
Get number of loops associated with the clause.
static OMPDoacrossClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N expressions.
OpenMPDoacrossClauseModifier getDependenceType() const
Get dependence type.
SourceLocation getDependenceLoc() const
Get dependence type location.
const_child_range used_children() const
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc()
Get location of '('.
OMPDynGroupprivateClause()
Build an empty clause.
const Expr * getSize() const
Get size.
SourceLocation getDynGroupprivateModifierLoc() const
Get the first modifier location.
OMPDynGroupprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *Size, Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion, OpenMPDynGroupprivateClauseModifier M1, SourceLocation M1Loc, OpenMPDynGroupprivateClauseFallbackModifier M2, SourceLocation M2Loc)
Build 'dyn_groupprivate' clause with a size expression Size.
OpenMPDynGroupprivateClauseFallbackModifier getDynGroupprivateFallbackModifier() const
Get the second modifier of the clause.
OpenMPDynGroupprivateClauseModifier getDynGroupprivateModifier() const
Get the first modifier of the clause.
const_child_range children() const
SourceLocation getDynGroupprivateFallbackModifierLoc() const
Get the second modifier location.
OMPDynamicAllocatorsClause()
Build an empty clause.
OMPDynamicAllocatorsClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'dynamic_allocators' clause.
const_child_range children() const
const_child_range used_children() const
static bool classof(const OMPClause *T)
This represents clause 'exclusive' in the 'pragma omp scan' directive.
const_child_range used_children() const
static OMPExclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
const_child_range children() const
static bool classof(const OMPClause *T)
friend class OMPClauseReader
OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation FailParameterLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
child_range used_children()
OMPFailClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'fail' clause.
static bool classof(const OMPClause *T)
child_range children()
const_child_range used_children() const
SourceLocation getLParenLoc() const
Gets the location of '(' (for the parameter) in fail clause.
const_child_range children() const
SourceLocation getFailParameterLoc() const
Gets the location of Fail Parameter (type memory-order-clause) in fail clause.
OMPFailClause()
Build an empty clause.
OpenMPClauseKind getFailParameter() const
Gets the parameter (type memory-order-clause) in Fail clause.
friend class OMPClauseReader
Expr * getThreadID() const
Return thread identifier.
Expr * getThreadID()
Return thread identifier.
OMPFilterClause(Expr *ThreadID, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'filter' clause with thread-id ThreadID.
OMPFilterClause()
Build an empty clause.
child_range used_children()
friend class OMPClauseReader
Expr * getCondition() const
Returns condition.
OMPFinalClause(Expr *Cond, Stmt *HelperCond, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'final' clause with condition Cond.
OMPFinalClause()
Build an empty clause.
const_child_range used_children() const
This represents clause 'firstprivate' in the 'pragma omp ...' directives.
MutableArrayRef< Expr * >::iterator private_copies_iterator
const_child_range children() const
static bool classof(const OMPClause *T)
inits_const_range inits() const
llvm::iterator_range< inits_const_iterator > inits_const_range
ArrayRef< const Expr * >::iterator inits_const_iterator
private_copies_const_range private_copies() const
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
llvm::iterator_range< inits_iterator > inits_range
llvm::iterator_range< private_copies_iterator > private_copies_range
const_child_range used_children() const
private_copies_range private_copies()
ArrayRef< const Expr * >::iterator private_copies_const_iterator
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
MutableArrayRef< Expr * >::iterator inits_iterator
child_range used_children()
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
const_child_range children() const
static bool classof(const OMPClause *T)
const_child_range used_children() const
This represents clause 'from' in the 'pragma omp ...' directives.
const_child_range used_children() const
friend class OMPClauseReader
SourceLocation getColonLoc() const
Get colon location.
OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY
Fetches the motion-modifier at 'Cnt' index of array of modifiers.
child_range children()
ArrayRef< SourceLocation > getMotionModifiersLoc() const LLVM_READONLY
Fetches ArrayRef of location of motion-modifiers.
static bool classof(const OMPClause *T)
Expr * getIteratorModifier() const
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
ArrayRef< OpenMPMotionModifierKind > getMotionModifiers() const LLVM_READONLY
Fetches ArrayRef of motion-modifiers.
child_range used_children()
SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY
Fetches the motion-modifier location at 'Cnt' index of array of modifiers' locations.
const_child_range children() const
Representation of the 'full' clause of the 'pragma omp unroll' directive.
friend class OMPClauseReader
static OMPFullClause * CreateEmpty(const ASTContext &C)
Build an empty 'full' AST node for deserialization.
const_child_range children() const
Expr * getGrainsize() const
Return safe iteration space distance.
SourceLocation getLParenLoc() const
Returns the location of '('.
SourceLocation getModifierLoc() const
Gets modifier location.
OMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size, Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build 'grainsize' clause.
static bool classof(const OMPClause *T)
const_child_range used_children() const
OMPGrainsizeClause()
Build an empty clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OpenMPGrainsizeClauseModifier getModifier() const
Gets modifier.
This represents clause 'has_device_ptr' in the 'pragma omp ...' directives.
const_child_range used_children() const
const_child_range children() const
static bool classof(const OMPClause *T)
static OMPHasDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
friend class OMPClauseReader
static bool classof(const OMPClause *T)
Expr * getHint() const
Returns number of threads.
const_child_range children() const
child_range children()
OMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'hint' clause with expression Hint.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range used_children() const
OMPHintClause()
Build an empty clause.
child_range used_children()
friend class OMPClauseReader
OMPHoldsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'holds' clause.
OMPHoldsClause()
Build an empty clause.
Expr * getExpr() const
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
friend class OMPClauseReader
const_child_range used_children() const
SourceLocation getLParenLoc() const
Returns the location of '('.
SourceLocation getColonLoc() const
Return the location of ':'.
static bool classof(const OMPClause *T)
child_range used_children()
Expr * getCondition() const
Returns condition.
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
OMPIfClause()
Build an empty clause.
child_range children()
const_child_range children() const
OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build 'if' clause with condition Cond.
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
This represents clause 'in_reduction' in the 'pragma omp task' directives.
static OMPInReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static bool classof(const OMPClause *T)
helper_expr_const_range rhs_exprs() const
helper_expr_range taskgroup_descriptors()
MutableArrayRef< Expr * >::iterator helper_expr_iterator
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
llvm::iterator_range< helper_expr_iterator > helper_expr_range
helper_expr_const_range lhs_exprs() const
helper_expr_const_range reduction_ops() const
helper_expr_const_range privates() const
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
helper_expr_const_range taskgroup_descriptors() const
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
helper_expr_range reduction_ops()
const_child_range used_children() const
helper_expr_range rhs_exprs()
const_child_range children() const
helper_expr_range lhs_exprs()
helper_expr_range privates()
This represents clause 'inclusive' in the 'pragma omp scan' directive.
const_child_range children() const
static bool classof(const OMPClause *T)
static OMPInclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
const_child_range used_children() const
bool getIsTarget() const
Returns true is interop-type 'target' is used.
child_range used_children()
const_child_range children() const
friend class OMPClauseReader
child_range children()
const_prefs_range prefs() const
llvm::iterator_range< prefs_iterator > prefs_range
const Expr * getInteropVar() const
static bool classof(const OMPClause *T)
ArrayRef< const Expr * >::iterator const_prefs_iterator
SourceLocation getVarLoc() const
Returns the location of the interop variable.
bool getIsTargetSync() const
Returns true is interop-type 'targetsync' is used.
static OMPInitClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N expressions.
MutableArrayRef< Expr * >::iterator prefs_iterator
const_child_range used_children() const
Expr * getInteropVar()
Returns the interop variable.
llvm::iterator_range< const_prefs_iterator > const_prefs_range
This represents clause 'is_device_ptr' in the 'pragma omp ...' directives.
const_child_range used_children() const
const_child_range children() const
static bool classof(const OMPClause *T)
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'lastprivate' in the 'pragma omp ...' directives.
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
helper_expr_range assignment_ops()
void setPrivateCopies(ArrayRef< Expr * > PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
SourceLocation getKindLoc() const
Returns the location of the lastprivate kind.
const_child_range used_children() const
helper_expr_const_range destination_exprs() const
helper_expr_const_range source_exprs() const
helper_expr_range destination_exprs()
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
static bool classof(const OMPClause *T)
helper_expr_range source_exprs()
const_child_range children() const
helper_expr_const_range assignment_ops() const
helper_expr_range private_copies()
MutableArrayRef< Expr * >::iterator helper_expr_iterator
SourceLocation getColonLoc() const
Returns the location of the ':' symbol, if any.
OpenMPLastprivateModifier getKind() const
Lastprivate kind.
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
llvm::iterator_range< helper_expr_iterator > helper_expr_range
helper_expr_const_range private_copies() const
static bool classof(const OMPClause *T)
void setStepModifierLoc(SourceLocation Loc)
Sets the location of 'step' modifier.
updates_const_range updates() const
child_range used_children()
SourceLocation getModifierLoc() const
Return modifier location.
friend class OMPClauseReader
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
Expr * getStep()
Returns linear step.
void setUpdates(ArrayRef< Expr * > UL)
Sets the list of update expressions for linear variables.
privates_range privates()
void setFinals(ArrayRef< Expr * > FL)
Sets the list of final update expressions for linear variables.
privates_const_range privates() const
void setUsedExprs(ArrayRef< Expr * > UE)
Sets the list of used expressions for the linear clause.
const Expr * getStep() const
Returns linear step.
ArrayRef< const Expr * >::iterator used_expressions_const_iterator
llvm::iterator_range< finals_iterator > finals_range
llvm::iterator_range< updates_iterator > updates_range
MutableArrayRef< Expr * >::iterator inits_iterator
ArrayRef< const Expr * >::iterator finals_const_iterator
void setModifierLoc(SourceLocation Loc)
Set modifier location.
MutableArrayRef< Expr * >::iterator used_expressions_iterator
llvm::iterator_range< finals_const_iterator > finals_const_range
llvm::iterator_range< privates_iterator > privates_range
updates_range updates()
inits_const_range inits() const
const_child_range children() const
Expr * getCalcStep()
Returns expression to calculate linear step.
MutableArrayRef< Expr * >::iterator finals_iterator
ArrayRef< const Expr * >::iterator updates_const_iterator
void setColonLoc(SourceLocation Loc)
Sets the location of ':'.
const Expr * getCalcStep() const
Returns expression to calculate linear step.
llvm::iterator_range< used_expressions_iterator > used_expressions_range
ArrayRef< const Expr * >::iterator inits_const_iterator
llvm::iterator_range< used_expressions_const_iterator > used_expressions_const_range
llvm::iterator_range< updates_const_iterator > updates_const_range
SourceLocation getStepModifierLoc() const
Returns the location of 'step' modifier.
used_expressions_const_range used_expressions() const
used_expressions_range used_expressions()
llvm::iterator_range< privates_const_iterator > privates_const_range
finals_const_range finals() const
const_child_range used_children() const
void setModifier(OpenMPLinearClauseKind Kind)
Set modifier.
llvm::iterator_range< inits_const_iterator > inits_const_range
MutableArrayRef< Expr * >::iterator updates_iterator
llvm::iterator_range< inits_iterator > inits_range
ArrayRef< const Expr * >::iterator privates_const_iterator
OpenMPLinearClauseKind getModifier() const
Return modifier.
SourceLocation getColonLoc() const
Returns the location of ':'.
MutableArrayRef< Expr * >::iterator privates_iterator
Expr * getFirst() const
Get looprange 'first' expression.
static OMPLoopRangeClause * CreateEmpty(const ASTContext &C)
Build an empty 'looprange' clause node.
const_child_range used_children() const
void setFirstLoc(SourceLocation Loc)
void setCountLoc(SourceLocation Loc)
SourceLocation getFirstLoc() const
SourceLocation getLParenLoc() const
static bool classof(const OMPClause *T)
SourceLocation getCountLoc() const
const_child_range children() const
Expr * getCount() const
Get looprange 'count' expression.
void setLParenLoc(SourceLocation Loc)
child_range children()
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
friend class OMPClauseReader
ArrayRef< SourceLocation > getMapTypeModifiersLoc() const LLVM_READONLY
Fetches ArrayRef of location of map-type-modifiers.
Expr * getIteratorModifier()
Fetches Expr * of iterator modifier.
child_range used_children()
bool isImplicitMapType() const LLVM_READONLY
Is this an implicit map type?
static bool classof(const OMPClause *T)
SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY
Fetches the map-type-modifier location at 'Cnt' index of array of modifiers' locations.
const_child_range children() const
ArrayRef< OpenMPMapModifierKind > getMapTypeModifiers() const LLVM_READONLY
Fetches ArrayRef of map-type-modifiers.
SourceLocation getColonLoc() const
Get colon location.
const_child_range used_children() const
SourceLocation getMapLoc() const LLVM_READONLY
Fetches location of clause mapping kind.
static OMPMapClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY
Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
Iterator that browse the components by lists.
std::tuple< const ValueDecl *, MappableExprComponentListRef, const ValueDecl * > operator->() const
std::tuple< const ValueDecl *, MappableExprComponentListRef, const ValueDecl * > operator*() const
const_component_lists_iterator(ArrayRef< ValueDecl * > UniqueDecls, ArrayRef< unsigned > DeclsListNum, ArrayRef< unsigned > CumulativeListSizes, MappableExprComponentListRef Components, bool SupportsMapper, ArrayRef< Expr * > Mappers)
Construct an iterator that scans all lists.
const_component_lists_iterator(const ValueDecl *Declaration, ArrayRef< ValueDecl * > UniqueDecls, ArrayRef< unsigned > DeclsListNum, ArrayRef< unsigned > CumulativeListSizes, MappableExprComponentListRef Components, bool SupportsMapper, ArrayRef< Expr * > Mappers)
Construct an iterator that scan lists for a given declaration Declaration.
This represents clauses with a list of expressions that are mappable.
const_component_lists_range component_lists() const
ArrayRef< MappableComponent > getComponentsRef() const
Get the components that are in the trailing objects of the class.
OMPMappableExprListClause(OpenMPClauseKind K, const OMPVarListLocTy &Locs, const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper=false, NestedNameSpecifierLoc *MapperQualifierLocPtr=nullptr, DeclarationNameInfo *MapperIdInfoPtr=nullptr)
Build a clause for NumUniqueDeclarations declarations, NumComponentLists total component lists,...
llvm::iterator_range< mapperlist_iterator > mapperlist_range
MutableArrayRef< ValueDecl * > getUniqueDeclsRef()
Get the unique declarations that are in the trailing objects of the class.
MutableArrayRef< MappableComponent > getComponentsRef()
Get the components that are in the trailing objects of the class.
void setUDMapperRefs(ArrayRef< Expr * > DMDs)
Set the user-defined mappers that are in the trailing objects of the class.
ArrayRef< unsigned >::iterator const_all_lists_sizes_iterator
mapperlist_iterator mapperlist_end()
llvm::iterator_range< const_all_num_lists_iterator > const_all_num_lists_range
const_all_decls_range all_decls() const
mapperlist_const_range mapperlists() const
void setDeclNumLists(ArrayRef< unsigned > DNLs)
Set the number of lists per declaration that are in the trailing objects of the class.
const_component_lists_iterator decl_component_lists_begin(const ValueDecl *VD) const
Iterators for component lists associated with the provided declaration.
void setMapperQualifierLoc(NestedNameSpecifierLoc NNSL)
Set the nested name specifier of associated user-defined mapper.
llvm::iterator_range< const_component_lists_iterator > const_component_lists_range
unsigned getTotalComponentsNum() const
Return the total number of components in all lists derived from the clause.
MutableArrayRef< unsigned > getComponentListSizesRef()
Get the cumulative component lists sizes that are in the trailing objects of the class.
ArrayRef< Expr * > getUDMapperRefs() const
Get the user-defined mappers references that are in the trailing objects of the class.
unsigned getUniqueDeclarationsNum() const
Return the number of unique base declarations in this clause.
ArrayRef< unsigned > getComponentListSizesRef() const
Get the cumulative component lists sizes that are in the trailing objects of the class.
ArrayRef< unsigned > getDeclNumListsRef() const
Get the number of lists per declaration that are in the trailing objects of the class.
const_all_lists_sizes_range all_lists_sizes() const
void setUniqueDecls(ArrayRef< ValueDecl * > UDs)
Set the unique declarations that are in the trailing objects of the class.
llvm::iterator_range< const_all_decls_iterator > const_all_decls_range
const DeclarationNameInfo & getMapperIdInfo() const
Gets the name info for associated user-defined mapper.
const_component_lists_iterator decl_component_lists_end() const
mapperlist_iterator mapperlist_begin()
ArrayRef< unsigned >::iterator const_all_num_lists_iterator
void setComponents(ArrayRef< MappableComponent > Components, ArrayRef< unsigned > CLSs)
Set the components that are in the trailing objects of the class.
MutableArrayRef< Expr * >::iterator mapperlist_iterator
MutableArrayRef< Expr * > getUDMapperRefs()
Get the user-defined mapper references that are in the trailing objects of the class.
mapperlist_const_iterator mapperlist_begin() const
ArrayRef< const Expr * >::iterator mapperlist_const_iterator
const_all_num_lists_range all_num_lists() const
llvm::iterator_range< mapperlist_const_iterator > mapperlist_const_range
llvm::iterator_range< const_all_components_iterator > const_all_components_range
void setClauseInfo(ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Fill the clause information from the list of declarations and associated component lists.
unsigned getTotalComponentListNum() const
Return the number of lists derived from the clause expressions.
const_component_lists_range decl_component_lists(const ValueDecl *VD) const
void setComponentListSizes(ArrayRef< unsigned > CLSs)
Set the cumulative component lists sizes that are in the trailing objects of the class.
NestedNameSpecifierLoc getMapperQualifierLoc() const
Gets the nested name specifier for associated user-defined mapper.
ArrayRef< ValueDecl * > getUniqueDeclsRef() const
Get the unique declarations that are in the trailing objects of the class.
llvm::iterator_range< const_all_lists_sizes_iterator > const_all_lists_sizes_range
MutableArrayRef< unsigned > getDeclNumListsRef()
Get the number of lists per declaration that are in the trailing objects of the class.
const_component_lists_iterator component_lists_end() const
const_component_lists_iterator component_lists_begin() const
Iterators for all component lists.
ArrayRef< MappableComponent >::iterator const_all_components_iterator
mapperlist_const_iterator mapperlist_end() const
const_all_components_range all_components() const
void setMapperIdInfo(DeclarationNameInfo MapperId)
Set the name of associated user-defined mapper.
ArrayRef< ValueDecl * >::iterator const_all_decls_iterator
Iterators to access all the declarations, number of lists, list sizes, and components.
OMPMergeableClause()
Build an empty clause.
OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'mergeable' clause.
const_child_range children() const
const_child_range used_children() const
static bool classof(const OMPClause *T)
Expr * getMessageString() const
Returns message string of the clause.
OMPMessageClause(Expr *MS, Stmt *HelperMS, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'message' clause with message string argument.
std::optional< std::string > tryEvaluateString(ASTContext &Ctx) const
Try to evaluate the message string at compile time.
OMPMessageClause()
Build an empty clause.
OMPNoOpenMPClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'no_openmp' clause.
OMPNoOpenMPClause()
Build an empty clause.
OMPNoOpenMPConstructsClause()
Build an empty clause.
OMPNoOpenMPConstructsClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'no_openmp_constructs' clause.
OMPNoOpenMPRoutinesClause()
Build an empty clause.
OMPNoOpenMPRoutinesClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'no_openmp_routines' clause.
OMPNoParallelismClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'no_parallelism' clause.
OMPNoParallelismClause()
Build an empty clause.
OMPNocontextClause(Expr *Cond, Stmt *HelperCond, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'nocontext' clause with condition Cond.
const_child_range used_children() const
OMPNocontextClause()
Build an empty clause.
Expr * getCondition() const
Returns condition.
OMPNogroupClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'nogroup' clause.
static bool classof(const OMPClause *T)
OMPNogroupClause()
Build an empty clause.
const_child_range children() const
child_range used_children()
const_child_range used_children() const
This represents clause 'nontemporal' in the 'pragma omp ...' directives.
static OMPNontemporalClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
const_child_range private_refs() const
static bool classof(const OMPClause *T)
void setPrivateRefs(ArrayRef< Expr * > VL)
Sets the list of references to private copies created in private clauses.
const_child_range children() const
const_child_range used_children() const
const_child_range used_children() const
OMPNovariantsClause()
Build an empty clause.
OMPNovariantsClause(Expr *Cond, Stmt *HelperCond, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'novariants' clause with condition Cond.
Expr * getCondition() const
Returns condition.
friend class OMPClauseReader
static bool classof(const OMPClause *T)
Expr * getCondition() const
Returns condition.
const_child_range children() const
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
const_child_range used_children() const
OMPNowaitClause()
Build an empty clause.
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPNowaitClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'nowait' clause with condition Cond.
child_range used_children()
const_child_range children() const
Expr * getNumTasks() const
Return safe iteration space distance.
SourceLocation getModifierLoc() const
Gets modifier location.
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *Size, Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build 'num_tasks' clause.
static bool classof(const OMPClause *T)
const_child_range used_children() const
OMPNumTasksClause()
Build an empty clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OpenMPNumTasksClauseModifier getModifier() const
Gets modifier.
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range children() const
const_child_range used_children() const
static bool classof(const OMPClause *T)
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
ArrayRef< Expr * > getNumTeams() const
Return NumTeams expressions.
static OMPNumTeamsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
ArrayRef< Expr * > getNumTeams()
Return NumTeams expressions.
OpenMPNumThreadsClauseModifier getModifier() const
Gets modifier.
SourceLocation getModifierLoc() const
Gets modifier location.
OMPNumThreadsClause()
Build an empty clause.
OMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, Stmt *HelperNumThreads, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build 'num_threads' clause with condition NumThreads.
Expr * getNumThreads() const
Returns number of threads.
const_child_range used_children() const
child_range used_children()
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OMPOneStmtClause(Stmt *S, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static bool classof(const OMPClause *T)
ConstStmtIterator const_child_iterator
const_child_range children() const
StmtIterator child_iterator
llvm::iterator_range< child_iterator > child_range
SourceLocation getLParenLoc() const
Returns the location of '('.
llvm::iterator_range< const_child_iterator > const_child_range
T * getStmtAs() const
Return the associated statement, potentially casted to T.
OMPOrderClause(OpenMPOrderClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPOrderClauseModifier Modifier, SourceLocation MLoc)
Build 'order' clause with argument A ('concurrent').
friend class OMPClauseReader
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range children() const
const_child_range used_children() const
SourceLocation getKindKwLoc() const
Returns location of clause kind.
static bool classof(const OMPClause *T)
SourceLocation getModifierKwLoc() const
Returns location of clause modifier.
OpenMPOrderClauseKind getKind() const
Returns kind of the clause.
child_range used_children()
OMPOrderClause()
Build an empty clause.
OpenMPOrderClauseModifier getModifier() const
Returns Modifier of the clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
This represents 'ordered' clause in the 'pragma omp ...' directive.
const_child_range children() const
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
static bool classof(const OMPClause *T)
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Expr * getNumForLoops() const
Return the number of associated for-loops.
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range used_children() const
ArrayRef< Expr * > getLoopNumIterations() const
Get number of iterations for all the loops.
child_range used_children()
static OMPOrderedClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty clause.
Expr * getLoopCounter(unsigned NumLoop)
Get loops counter for the specified loop.
child_range used_children()
static OMPPartialClause * CreateEmpty(const ASTContext &C)
Build an empty 'partial' AST node for deserialization.
const_child_range used_children() const
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range children() const
static bool classof(const OMPClause *T)
Expr * getFactor() const
Returns the argument of the clause or nullptr if not set.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
static bool classof(const OMPClause *T)
ArrayRef< Expr * > getArgsRefs() const
unsigned getNumLoops() const
Returns the number of list items.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
SourceLocation getLParenLoc() const
Returns the location of '('.
MutableArrayRef< Expr * > getArgsRefs()
Returns the permutation index expressions.
static OMPPermutationClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty 'permutation' AST node for deserialization.
const_child_range used_children() const
const_child_range children() const
OMPPriorityClause(Expr *Priority, Stmt *HelperPriority, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'priority' clause.
Expr * getPriority() const
Return Priority number.
const_child_range used_children() const
static bool classof(const OMPClause *T)
const_child_range children() const
OMPPriorityClause()
Build an empty clause.
SourceLocation getLParenLoc() const
Returns the location of '('.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Expr * getPriority()
Return Priority number.
This represents clause 'private' in the 'pragma omp ...' directives.
const_child_range children() const
private_copies_range private_copies()
static bool classof(const OMPClause *T)
const_child_range used_children() const
child_range used_children()
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
llvm::iterator_range< private_copies_iterator > private_copies_range
ArrayRef< const Expr * >::iterator private_copies_const_iterator
private_copies_const_range private_copies() const
MutableArrayRef< Expr * >::iterator private_copies_iterator
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
const_child_range used_children() const
SourceLocation getProcBindKindKwLoc() const
Returns location of clause kind.
const_child_range children() const
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPProcBindClause()
Build an empty clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'proc_bind' clause with argument A ('master', 'close' or 'spread').
llvm::omp::ProcBindKind getProcBindKind() const
Returns kind of the clause.
static bool classof(const OMPClause *T)
child_range children()
static bool classof(const OMPClause *T)
child_range used_children()
const_child_range children() const
const_child_range used_children() const
OMPReadClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'read' clause.
OMPReadClause()
Build an empty clause.
This represents clause 'reduction' in the 'pragma omp ...' directives.
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
OpenMPOriginalSharingModifier getOriginalSharingModifier() const
Returns Original Sharing Modifier.
MutableArrayRef< Expr * >::iterator helper_expr_iterator
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
helper_expr_const_range rhs_exprs() const
llvm::iterator_range< helper_expr_iterator > helper_expr_range
helper_expr_const_range lhs_exprs() const
helper_expr_range copy_array_temps()
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N, OpenMPReductionClauseModifier Modifier)
Creates an empty clause with the place for N variables.
helper_expr_range rhs_exprs()
helper_expr_range copy_array_elems()
helper_expr_range lhs_exprs()
helper_expr_const_range copy_array_temps() const
const_child_range used_children() const
helper_expr_const_range reduction_ops() const
helper_expr_range privates()
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
ArrayRef< bool >::iterator helper_flag_const_iterator
helper_expr_const_range privates() const
MutableArrayRef< bool >::iterator helper_flag_iterator
llvm::iterator_range< helper_flag_const_iterator > helper_flag_const_range
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
static bool classof(const OMPClause *T)
helper_expr_const_range copy_array_elems() const
helper_expr_const_range copy_ops() const
helper_flag_const_range private_var_reduction_flags() const
OpenMPReductionClauseModifier getModifier() const
Returns modifier.
SourceLocation getModifierLoc() const
Returns modifier location.
helper_expr_range copy_ops()
const_child_range children() const
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
llvm::iterator_range< helper_flag_iterator > helper_flag_range
helper_expr_range reduction_ops()
helper_flag_range private_var_reduction_flags()
static bool classof(const OMPClause *T)
const_child_range used_children() const
child_range used_children()
OMPRelaxedClause()
Build an empty clause.
const_child_range children() const
OMPRelaxedClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'relaxed' clause.
const_child_range children() const
child_range used_children()
OMPReleaseClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'release' clause.
OMPReleaseClause()
Build an empty clause.
static bool classof(const OMPClause *T)
const_child_range used_children() const
const_child_range children() const
const_child_range used_children() const
OMPReverseOffloadClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'reverse_offload' clause.
static bool classof(const OMPClause *T)
OMPReverseOffloadClause()
Build an empty clause.
OMPSIMDClause()
Build an empty clause.
const_child_range children() const
const_child_range used_children() const
child_range used_children()
child_range children()
static bool classof(const OMPClause *T)
OMPSIMDClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'simd' clause.
friend class OMPClauseReader
OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'safelen' clause.
Expr * getSafelen() const
Return safe iteration space distance.
OMPSafelenClause()
Build an empty clause.
static bool classof(const OMPClause *T)
SourceLocation getFirstScheduleModifierLoc() const
Get the first modifier location.
OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KLoc, SourceLocation CommaLoc, SourceLocation EndLoc, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, Stmt *HelperChunkSize, OpenMPScheduleClauseModifier M1, SourceLocation M1Loc, OpenMPScheduleClauseModifier M2, SourceLocation M2Loc)
Build 'schedule' clause with schedule kind Kind and chunk size expression ChunkSize.
SourceLocation getScheduleKindLoc()
Get kind location.
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
SourceLocation getLParenLoc()
Get location of '('.
const Expr * getChunkSize() const
Get chunk size.
OMPScheduleClause()
Build an empty clause.
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
SourceLocation getCommaLoc()
Get location of ','.
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
SourceLocation getSecondScheduleModifierLoc() const
Get the second modifier location.
const_child_range children() const
const_child_range used_children() const
Expr * getChunkSize()
Get chunk size.
static bool classof(const OMPClause *T)
OMPSelfMapsClause()
Build an empty clause.
OMPSelfMapsClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'self_maps' clause.
const_child_range used_children() const
const_child_range children() const
OMPSeqCstClause()
Build an empty clause.
const_child_range used_children() const
OMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'seq_cst' clause.
child_range used_children()
const_child_range children() const
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the locaiton of '('.
const_child_range children() const
static bool classof(const OMPClause *T)
OMPSeverityClause()
Build an empty clause.
OMPSeverityClause(OpenMPSeverityClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'severity' clause with argument A ('fatal' or 'warning').
OpenMPSeverityClauseKind getSeverityKind() const
Returns kind of the clause.
const_child_range used_children() const
SourceLocation getSeverityKindKwLoc() const
Returns location of clause kind.
child_range used_children()
const_child_range used_children() const
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
const_child_range children() const
static bool classof(const OMPClause *T)
friend class OMPClauseReader
OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'simdlen' clause.
Expr * getSimdlen() const
Return safe iteration space distance.
OMPSimdlenClause()
Build an empty clause.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
SourceLocation getLParenLoc() const
Returns the location of '('.
friend class OMPClauseReader
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
static bool classof(const OMPClause *T)
const_child_range used_children() const
void setSizesRefs(ArrayRef< Expr * > VL)
Sets the tile size expressions.
unsigned getNumSizes() const
Returns the number of list items.
child_range used_children()
MutableArrayRef< Expr * > getSizesRefs()
Returns the tile size expressions.
ArrayRef< Expr * > getSizesRefs() const
const_child_range children() const
static OMPSizesClause * CreateEmpty(const ASTContext &C, unsigned NumSizes)
Build an empty 'sizes' AST node for deserialization.
This represents clause 'task_reduction' in the 'pragma omp taskgroup' directives.
helper_expr_const_range rhs_exprs() const
llvm::iterator_range< helper_expr_iterator > helper_expr_range
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
helper_expr_const_range lhs_exprs() const
const_child_range used_children() const
helper_expr_const_range reduction_ops() const
helper_expr_range privates()
const_child_range children() const
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
MutableArrayRef< Expr * >::iterator helper_expr_iterator
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
helper_expr_range rhs_exprs()
helper_expr_range lhs_exprs()
helper_expr_range reduction_ops()
helper_expr_const_range privates() const
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static bool classof(const OMPClause *T)
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
ArrayRef< Expr * > getThreadLimit()
Return ThreadLimit expressions.
const_child_range children() const
ArrayRef< Expr * > getThreadLimit() const
Return ThreadLimit expressions.
SourceLocation getLParenLoc() const
Returns the location of '('.
static OMPThreadLimitClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
const_child_range used_children() const
static bool classof(const OMPClause *T)
OMPThreadsClause()
Build an empty clause.
OMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'threads' clause.
static bool classof(const OMPClause *T)
OpenMPThreadsetKind getThreadsetKind() const
Returns kind of the clause.
const_child_range children() const
OMPThreadsetClause(OpenMPThreadsetKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'threadset' clause with argument A ('omp_team' or 'omp_pool').
const_child_range used_children() const
SourceLocation getThreadsetKindLoc() const
Returns location of clause kind.
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPThreadsetClause()
Build an empty clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
This represents clause 'to' in the 'pragma omp ...' directives.
friend class OMPClauseReader
static OMPToClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
const_child_range used_children() const
SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY
Fetches the motion-modifier location at 'Cnt' index of array of modifiers' locations.
ArrayRef< OpenMPMotionModifierKind > getMotionModifiers() const LLVM_READONLY
Fetches ArrayRef of motion-modifiers.
child_range children()
ArrayRef< SourceLocation > getMotionModifiersLoc() const LLVM_READONLY
Fetches ArrayRef of location of motion-modifiers.
Expr * getIteratorModifier() const
const_child_range children() const
SourceLocation getColonLoc() const
Get colon location.
static bool classof(const OMPClause *T)
child_range used_children()
OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY
Fetches the motion-modifier at 'Cnt' index of array of modifiers.
bool isExtensionActive(llvm::omp::TraitProperty TP)
Check the extension trait TP is active.
bool anyScoreOrCondition(llvm::function_ref< bool(Expr *&, bool)> Cond)
std::string getMangledName() const
Return a string representation identifying this context selector.
friend class ASTContext
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Print a human readable representation into OS.
void getAsVariantMatchInfo(ASTContext &ASTCtx, llvm::omp::VariantMatchInfo &VMI) const
Create a variant match info object from this trait info object.
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
OMPUnifiedAddressClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'unified_address' clause.
OMPUnifiedAddressClause()
Build an empty clause.
OMPUnifiedSharedMemoryClause()
Build an empty clause.
static bool classof(const OMPClause *T)
const_child_range children() const
OMPUnifiedSharedMemoryClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'unified_shared_memory' clause.
const_child_range used_children() const
child_range used_children()
OMPUntiedClause()
Build an empty clause.
OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'untied' clause.
static bool classof(const OMPClause *T)
const_child_range used_children() const
const_child_range children() const
friend class OMPClauseReader
const_child_range used_children() const
const_child_range children() const
OpenMPDependClauseKind getDependencyKind() const
Gets the dependence kind in clause for 'depobj' directive.
static OMPUpdateClause * CreateEmpty(const ASTContext &C, bool IsExtended)
Creates an empty clause with the place for N variables.
child_range used_children()
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Gets the location of '(' in clause for 'depobj' directive.
SourceLocation getArgumentLoc() const
Gets the location of argument in clause for 'depobj' directive.
bool isExtended() const
Checks if the clause is the extended clauses for 'depobj' directive.
friend class OMPClauseReader
child_range used_children()
child_range children()
SourceLocation getVarLoc() const
Returns the location of the interop variable.
OMPUseClause()
Build an empty clause.
const_child_range used_children() const
const_child_range children() const
OMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build 'use' clause with and interop variable expression InteropVar.
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the location of '('.
Expr * getInteropVar() const
Returns the interop variable.
This represents clause 'use_device_addr' in the 'pragma omp ...' directives.
const_child_range used_children() const
static bool classof(const OMPClause *T)
const_child_range children() const
static OMPUseDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'use_device_ptr' in the 'pragma omp ...' directives.
ArrayRef< const Expr * >::iterator private_copies_const_iterator
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
private_copies_const_range private_copies() const
const_child_range used_children() const
const_child_range children() const
llvm::iterator_range< inits_iterator > inits_range
MutableArrayRef< Expr * >::iterator inits_iterator
inits_const_range inits() const
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
ArrayRef< const Expr * >::iterator inits_const_iterator
static bool classof(const OMPClause *T)
MutableArrayRef< Expr * >::iterator private_copies_iterator
private_copies_range private_copies()
llvm::iterator_range< inits_const_iterator > inits_const_range
llvm::iterator_range< private_copies_iterator > private_copies_range
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range children() const
OMPUsesAllocatorsClause::Data getAllocatorData(unsigned I) const
Returns data for the specified allocator.
static OMPUsesAllocatorsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N allocators.
unsigned getNumberOfAllocators() const
Returns number of allocators associated with the clause.
const_child_range used_children() const
This represents clauses with the list of variables like 'private', 'firstprivate',...
varlist_const_range varlist() const
friend class OMPClauseReader
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
ArrayRef< const Expr * > getVarRefs() const
Fetches list of all variables in the clause.
OMPVarListClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
Build a clause with N variables.
MutableArrayRef< Expr * > getVarRefs()
Fetches list of variables associated with this clause.
varlist_range varlist()
varlist_const_iterator varlist_end() const
varlist_iterator varlist_end()
llvm::iterator_range< varlist_const_iterator > varlist_const_range
MutableArrayRef< Expr * >::iterator varlist_iterator
varlist_iterator varlist_begin()
ArrayRef< const Expr * >::iterator varlist_const_iterator
SourceLocation getLParenLoc() const
Returns the location of '('.
unsigned varlist_size() const
varlist_const_iterator varlist_begin() const
llvm::iterator_range< varlist_iterator > varlist_range
void setVarRefs(ArrayRef< Expr * > VL)
Sets the list of variables for this clause.
const_child_range used_children() const
OMPWeakClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'weak' clause.
static bool classof(const OMPClause *T)
child_range used_children()
OMPWeakClause()
Build an empty clause.
const_child_range children() const
child_range children()
OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'write' clause.
const_child_range used_children() const
child_range used_children()
static bool classof(const OMPClause *T)
const_child_range children() const
OMPWriteClause()
Build an empty clause.
ArrayRef< const Attr * > getAttrs() const
Returned the attributes parsed from this clause.
OMPXAttributeClause()
Build an empty clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'ompx_attribute' clause.
OMPXBareClause()=default
Build an empty clause.
OMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'ompx_bare' clause.
OMPXDynCGroupMemClause(Expr *Size, Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'ompx_dyn_cgroup_mem' clause.
Expr * getSize()
Return the size expression.
Expr * getSize() const
Return the size expression.
OMPXDynCGroupMemClause()
Build an empty clause.
A (possibly-)qualified type.
Definition TypeBase.h:937
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
Stmt - This represents one statement.
Definition Stmt.h:85
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
Definition Stmt.h:1569
llvm::iterator_range< child_iterator > child_range
Definition Stmt.h:1572
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
#define bool
Definition gpuintrin.h:32
Definition SPIR.cpp:35
The JSON file list parser is used to communicate input to InstallAPI.
OpenMPOriginalSharingModifier
OpenMP 6.0 original sharing modifiers.
bool checkFailClauseParameter(OpenMPClauseKind FailClauseParameter)
Checks if the parameter to the fail clause in "#pragma atomic compare fail" is restricted only to mem...
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
@ OMPC_DEFAULTMAP_MODIFIER_unknown
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
@ OMPC_ORDER_MODIFIER_unknown
std::add_pointer_t< std::add_const_t< T > > const_ptr
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
@ OMPC_AT_unknown
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
@ OMPC_REDUCTION_unknown
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition OpenMPKinds.h:39
@ OMPC_SCHEDULE_MODIFIER_unknown
Definition OpenMPKinds.h:40
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
@ OMPC_DIST_SCHEDULE_unknown
Expr * Cond
};
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
@ OMPC_DOACROSS_unknown
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
Definition OpenMPKinds.h:88
OpenMPDynGroupprivateClauseFallbackModifier
@ OMPC_DYN_GROUPPRIVATE_FALLBACK_unknown
@ Property
The type of a property.
Definition TypeBase.h:911
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
@ OMPC_BIND_unknown
const FunctionProtoType * T
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition OpenMPKinds.h:55
@ OMPC_DEPEND_unknown
Definition OpenMPKinds.h:59
OpenMPGrainsizeClauseModifier
@ OMPC_GRAINSIZE_unknown
OpenMPNumTasksClauseModifier
@ OMPC_NUMTASKS_unknown
@ Type
The name was classified as a type.
Definition Sema.h:562
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
@ OMPC_SEVERITY_unknown
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
OpenMPMotionModifierKind
OpenMP modifier kind for 'to' or 'from' clause.
Definition OpenMPKinds.h:92
@ OMPC_MOTION_MODIFIER_unknown
Definition OpenMPKinds.h:96
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
@ OMPC_DEFAULTMAP_unknown
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
@ OMPC_ALLOCATE_unknown
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition OpenMPKinds.h:63
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition OpenMPKinds.h:25
OpenMPDynGroupprivateClauseModifier
@ OMPC_DYN_GROUPPRIVATE_unknown
OpenMPNumThreadsClauseModifier
@ OMPC_NUMTHREADS_unknown
OpenMPAtomicDefaultMemOrderClauseKind
OpenMP attributes for 'atomic_default_mem_order' clause.
@ OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
U cast(CodeGen::Address addr)
Definition Address.h:327
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition OpenMPKinds.h:48
@ OMPC_DEVICE_unknown
Definition OpenMPKinds.h:51
OpenMPMapModifierKind
OpenMP modifier kind for 'map' clause.
Definition OpenMPKinds.h:79
@ OMPC_MAP_MODIFIER_unknown
Definition OpenMPKinds.h:80
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
Definition OpenMPKinds.h:28
@ Other
Other implicit parameter.
Definition Decl.h:1746
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
@ OMPC_ORDER_unknown
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition OpenMPKinds.h:31
@ OMPC_SCHEDULE_unknown
Definition OpenMPKinds.h:35
OpenMPThreadsetKind
OpenMP modifiers for 'threadset' clause.
@ OMPC_THREADSET_unknown
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition OpenMPKinds.h:71
@ OMPC_MAP_unknown
Definition OpenMPKinds.h:75
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
int const char * function
Definition c++config.h:31
#define true
Definition stdbool.h:25
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation OmpAllMemoryLoc
Location of 'omp_all_memory'.
SourceLocation ColonLoc
Colon location.
OpenMPDependClauseKind DepKind
Dependency type (one of in, out, inout).
SourceLocation DepLoc
Dependency type location.
This structure contains all sizes needed for by an OMPMappableExprListClause.
unsigned NumComponentLists
Number of component lists.
OMPMappableExprListSizeTy(unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
unsigned NumVars
Number of expressions listed.
unsigned NumUniqueDeclarations
Number of unique base declarations.
unsigned NumComponents
Total number of expression components.
const_child_range used_children() const
static bool classof(const OMPClause *T)
OMPNoChildClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'ClauseKind' clause.
child_range used_children()
OMPNoChildClause()
Build an empty clause.
const_child_range children() const
llvm::omp::TraitProperty Kind
StringRef RawString
The raw string as we parsed it.
llvm::omp::TraitSelector Kind
SmallVector< OMPTraitProperty, 1 > Properties
SmallVector< OMPTraitSelector, 2 > Selectors
llvm::omp::TraitSet Kind
Data for list of allocators.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
Expr * AllocatorTraits
Allocator traits.
This structure contains most locations needed for by an OMPVarListClause.
SourceLocation StartLoc
Starting location of the clause (the clause keyword).
SourceLocation LParenLoc
Location of '('.
SourceLocation EndLoc
Ending location of the clause.
OMPVarListLocTy(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Describes how types, statements, expressions, and declarations should be printed.
TargetOMPContext(ASTContext &ASTCtx, std::function< void(StringRef)> &&DiagUnknownTrait, const FunctionDecl *CurrentFunctionDecl, ArrayRef< llvm::omp::TraitProperty > ConstructTraits, int DeviceNum)
bool matchesISATrait(StringRef RawString) const override
See llvm::omp::OMPContext::matchesISATrait.
virtual ~TargetOMPContext()=default