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 auto Children = const_cast<OMPClause *>(this)->children();
95 return const_child_range(Children.begin(), Children.end());
96 }
97
98 /// Get the iterator range for the expressions used in the clauses. Used
99 /// expressions include only the children that must be evaluated at the
100 /// runtime before entering the construct.
103 auto Children = const_cast<OMPClause *>(this)->children();
104 return const_child_range(Children.begin(), Children.end());
105 }
106
107 static bool classof(const OMPClause *) { return true; }
108};
109
110template <OpenMPClauseKind ClauseKind>
112 /// Build '\p ClauseKind' clause.
113 ///
114 /// \param StartLoc Starting location of the clause.
115 /// \param EndLoc Ending location of the clause.
117 : OMPClause(ClauseKind, StartLoc, EndLoc) {}
118
119 /// Build an empty clause.
122
126
130
137
138 static bool classof(const OMPClause *T) {
139 return T->getClauseKind() == ClauseKind;
140 }
141};
142
143template <OpenMPClauseKind ClauseKind, class Base>
144class OMPOneStmtClause : public Base {
145
146 /// Location of '('.
147 SourceLocation LParenLoc;
148
149 /// Sub-expression.
150 Stmt *S = nullptr;
151
152protected:
153 void setStmt(Stmt *S) { this->S = S; }
154
155public:
157 SourceLocation EndLoc)
158 : Base(ClauseKind, StartLoc, EndLoc), LParenLoc(LParenLoc), S(S) {}
159
161
162 /// Return the associated statement, potentially casted to \p T.
163 template <typename T> T *getStmtAs() const { return cast_or_null<T>(S); }
164
165 /// Sets the location of '('.
166 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
167
168 /// Returns the location of '('.
169 SourceLocation getLParenLoc() const { return LParenLoc; }
170
173 using child_range = llvm::iterator_range<child_iterator>;
174 using const_child_range = llvm::iterator_range<const_child_iterator>;
175
176 child_range children() { return child_range(&S, &S + 1); }
177
178 const_child_range children() const { return const_child_range(&S, &S + 1); }
179
180 // TODO: Consider making the getAddrOfExprAsWritten version the default.
187
188 static bool classof(const OMPClause *T) {
189 return T->getClauseKind() == ClauseKind;
190 }
191};
192
193/// Class that handles pre-initialization statement for some clauses, like
194/// 'schedule', 'firstprivate' etc.
196 friend class OMPClauseReader;
197
198 /// Pre-initialization statement for the clause.
199 Stmt *PreInit = nullptr;
200
201 /// Region that captures the associated stmt.
202 OpenMPDirectiveKind CaptureRegion = llvm::omp::OMPD_unknown;
203
204protected:
206 assert(get(This) && "get is not tuned for pre-init.");
207 }
208
209 /// Set pre-initialization statement for the clause.
210 void
212 OpenMPDirectiveKind ThisRegion = llvm::omp::OMPD_unknown) {
213 PreInit = S;
214 CaptureRegion = ThisRegion;
215 }
216
217public:
218 /// Get pre-initialization statement for the clause.
219 const Stmt *getPreInitStmt() const { return PreInit; }
220
221 /// Get pre-initialization statement for the clause.
222 Stmt *getPreInitStmt() { return PreInit; }
223
224 /// Get capture region for the stmt in the clause.
225 OpenMPDirectiveKind getCaptureRegion() const { return CaptureRegion; }
226
228 static const OMPClauseWithPreInit *get(const OMPClause *C);
229};
230
231/// Class that handles post-update expression for some clauses, like
232/// 'lastprivate', 'reduction' etc.
234 friend class OMPClauseReader;
235
236 /// Post-update expression for the clause.
237 Expr *PostUpdate = nullptr;
238
239protected:
241 assert(get(This) && "get is not tuned for post-update.");
242 }
243
244 /// Set pre-initialization statement for the clause.
245 void setPostUpdateExpr(Expr *S) { PostUpdate = S; }
246
247public:
248 /// Get post-update expression for the clause.
249 const Expr *getPostUpdateExpr() const { return PostUpdate; }
250
251 /// Get post-update expression for the clause.
252 Expr *getPostUpdateExpr() { return PostUpdate; }
253
255 static const OMPClauseWithPostUpdate *get(const OMPClause *C);
256};
257
258/// This structure contains most locations needed for by an OMPVarListClause.
260 /// Starting location of the clause (the clause keyword).
262 /// Location of '('.
264 /// Ending location of the clause.
266 OMPVarListLocTy() = default;
270};
271
272/// This represents clauses with the list of variables like 'private',
273/// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
274/// '#pragma omp ...' directives.
275template <class T> class OMPVarListClause : public OMPClause {
276 friend class OMPClauseReader;
277
278 /// Location of '('.
279 SourceLocation LParenLoc;
280
281 /// Number of variables in the list.
282 unsigned NumVars;
283
284protected:
285 /// Build a clause with \a N variables
286 ///
287 /// \param K Kind of the clause.
288 /// \param StartLoc Starting location of the clause (the clause keyword).
289 /// \param LParenLoc Location of '('.
290 /// \param EndLoc Ending location of the clause.
291 /// \param N Number of the variables in the clause.
293 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
294 : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {}
295
296 /// Fetches list of variables associated with this clause.
298 return static_cast<T *>(this)->template getTrailingObjectsNonStrict<Expr *>(
299 NumVars);
300 }
301
302 /// Sets the list of variables for this clause.
304 assert(VL.size() == NumVars &&
305 "Number of variables is not the same as the preallocated buffer");
306 llvm::copy(VL, getVarRefs().begin());
307 }
308
309public:
312 using varlist_range = llvm::iterator_range<varlist_iterator>;
313 using varlist_const_range = llvm::iterator_range<varlist_const_iterator>;
314
315 unsigned varlist_size() const { return NumVars; }
316 bool varlist_empty() const { return NumVars == 0; }
317
324
327 varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
329
330 /// Sets the location of '('.
331 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
332
333 /// Returns the location of '('.
334 SourceLocation getLParenLoc() const { return LParenLoc; }
335
336 /// Fetches list of all variables in the clause.
338 return static_cast<const T *>(this)
339 ->template getTrailingObjectsNonStrict<Expr *>(NumVars);
340 }
341};
342
343/// Class that represents a list of directive kinds (parallel, target, etc.)
344/// as used in \c absent, \c contains clauses.
345template <class T> class OMPDirectiveListClause : public OMPClause {
346 /// Location of '('.
347 SourceLocation LParenLoc;
348
349protected:
350 /// Number of directive kinds listed in the clause
351 unsigned NumKinds;
352
353public:
354 /// Build a clause with \a NumKinds directive kinds.
355 ///
356 /// \param K The clause kind.
357 /// \param StartLoc Starting location of the clause (the clause keyword).
358 /// \param LParenLoc Location of '('.
359 /// \param EndLoc Ending location of the clause.
360 /// \param NumKinds Number of directive kinds listed in the clause.
362 SourceLocation LParenLoc, SourceLocation EndLoc,
363 unsigned NumKinds)
364 : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc),
366
370
374
381
383 return static_cast<T *>(this)
384 ->template getTrailingObjectsNonStrict<OpenMPDirectiveKind>(NumKinds);
385 }
386
388 assert(
389 DK.size() == NumKinds &&
390 "Number of directive kinds is not the same as the preallocated buffer");
391 llvm::copy(DK, getDirectiveKinds().begin());
392 }
393
394 SourceLocation getLParenLoc() { return LParenLoc; }
395
396 void setLParenLoc(SourceLocation S) { LParenLoc = S; }
397};
398
399/// This represents 'allocator' clause in the '#pragma omp ...'
400/// directive.
401///
402/// \code
403/// #pragma omp allocate(a) allocator(omp_default_mem_alloc)
404/// \endcode
405/// In this example directive '#pragma omp allocate' has simple 'allocator'
406/// clause with the allocator 'omp_default_mem_alloc'.
408 : public OMPOneStmtClause<llvm::omp::OMPC_allocator, OMPClause> {
409 friend class OMPClauseReader;
410
411 /// Set allocator.
412 void setAllocator(Expr *A) { setStmt(A); }
413
414public:
415 /// Build 'allocator' clause with the given allocator.
416 ///
417 /// \param A Allocator.
418 /// \param StartLoc Starting location of the clause.
419 /// \param LParenLoc Location of '('.
420 /// \param EndLoc Ending location of the clause.
422 SourceLocation EndLoc)
423 : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
424
425 /// Build an empty clause.
427
428 /// Returns allocator.
429 Expr *getAllocator() const { return getStmtAs<Expr>(); }
430};
431
432/// This represents the 'align' clause in the '#pragma omp allocate'
433/// directive.
434///
435/// \code
436/// #pragma omp allocate(a) allocator(omp_default_mem_alloc) align(8)
437/// \endcode
438/// In this example directive '#pragma omp allocate' has simple 'allocator'
439/// clause with the allocator 'omp_default_mem_alloc' and align clause with
440/// value of 8.
441class OMPAlignClause final
442 : public OMPOneStmtClause<llvm::omp::OMPC_align, OMPClause> {
443 friend class OMPClauseReader;
444
445 /// Set alignment value.
446 void setAlignment(Expr *A) { setStmt(A); }
447
448 /// Build 'align' clause with the given alignment
449 ///
450 /// \param A Alignment value.
451 /// \param StartLoc Starting location of the clause.
452 /// \param LParenLoc Location of '('.
453 /// \param EndLoc Ending location of the clause.
454 OMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc,
455 SourceLocation EndLoc)
456 : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
457
458 /// Build an empty clause.
459 OMPAlignClause() : OMPOneStmtClause() {}
460
461public:
462 /// Build 'align' clause with the given alignment
463 ///
464 /// \param A Alignment value.
465 /// \param StartLoc Starting location of the clause.
466 /// \param LParenLoc Location of '('.
467 /// \param EndLoc Ending location of the clause.
468 static OMPAlignClause *Create(const ASTContext &C, Expr *A,
469 SourceLocation StartLoc,
470 SourceLocation LParenLoc,
471 SourceLocation EndLoc);
472
473 /// Returns alignment
474 Expr *getAlignment() const { return getStmtAs<Expr>(); }
475};
476
477/// This represents clause 'allocate' in the '#pragma omp ...' directives.
478///
479/// \code
480/// #pragma omp parallel private(a) allocate(omp_default_mem_alloc :a)
481/// \endcode
482/// In this example directive '#pragma omp parallel' has clause 'private'
483/// and clause 'allocate' for the variable 'a', which specifies an explicit
484/// memory allocator.
485class OMPAllocateClause final
486 : public OMPVarListClause<OMPAllocateClause>,
487 private llvm::TrailingObjects<OMPAllocateClause, Expr *> {
488 friend class OMPClauseReader;
489 friend OMPVarListClause;
490 friend TrailingObjects;
491
492 /// Allocator specified in the clause, or 'nullptr' if the default one is
493 /// used.
494 Expr *Allocator = nullptr;
495 /// Alignment specified in the clause, or 'nullptr' if the default one is
496 /// used.
497 Expr *Alignment = nullptr;
498 /// Position of the ':' delimiter in the clause;
499 SourceLocation ColonLoc;
500 /// Modifier of 'allocate' clause.
502 /// Location of allocator modifier if any.
503 SourceLocation AllocatorModifierLoc;
504
505 // ----------------------------------------------------------------------------
506
507 /// Modifiers for 'allocate' clause.
508 enum { FIRST, SECOND, NUM_MODIFIERS };
509 OpenMPAllocateClauseModifier Modifiers[NUM_MODIFIERS];
510
511 /// Locations of modifiers.
512 SourceLocation ModifiersLoc[NUM_MODIFIERS];
513
514 /// Set the first allocate modifier.
515 ///
516 /// \param M Allocate modifier.
517 void setFirstAllocateModifier(OpenMPAllocateClauseModifier M) {
518 Modifiers[FIRST] = M;
519 }
520
521 /// Set the second allocate modifier.
522 ///
523 /// \param M Allocate modifier.
524 void setSecondAllocateModifier(OpenMPAllocateClauseModifier M) {
525 Modifiers[SECOND] = M;
526 }
527
528 /// Set location of the first allocate modifier.
529 void setFirstAllocateModifierLoc(SourceLocation Loc) {
530 ModifiersLoc[FIRST] = Loc;
531 }
532
533 /// Set location of the second allocate modifier.
534 void setSecondAllocateModifierLoc(SourceLocation Loc) {
535 ModifiersLoc[SECOND] = Loc;
536 }
537
538 // ----------------------------------------------------------------------------
539
540 /// Build clause with number of variables \a N.
541 ///
542 /// \param StartLoc Starting location of the clause.
543 /// \param LParenLoc Location of '('.
544 /// \param Allocator Allocator expression.
545 /// \param ColonLoc Location of ':' delimiter.
546 /// \param EndLoc Ending location of the clause.
547 /// \param N Number of the variables in the clause.
548 OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
549 Expr *Allocator, Expr *Alignment, SourceLocation ColonLoc,
551 SourceLocation Modifier1Loc,
553 SourceLocation Modifier2Loc, SourceLocation EndLoc,
554 unsigned N)
555 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate, StartLoc,
556 LParenLoc, EndLoc, N),
557 Allocator(Allocator), Alignment(Alignment), ColonLoc(ColonLoc) {
558 Modifiers[FIRST] = Modifier1;
559 Modifiers[SECOND] = Modifier2;
560 ModifiersLoc[FIRST] = Modifier1Loc;
561 ModifiersLoc[SECOND] = Modifier2Loc;
562 }
563
564 /// Build an empty clause.
565 ///
566 /// \param N Number of variables.
567 explicit OMPAllocateClause(unsigned N)
568 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate,
569 SourceLocation(), SourceLocation(),
570 SourceLocation(), N) {
571 Modifiers[FIRST] = OMPC_ALLOCATE_unknown;
572 Modifiers[SECOND] = OMPC_ALLOCATE_unknown;
573 }
574
575 /// Sets location of ':' symbol in clause.
576 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
577
578 void setAllocator(Expr *A) { Allocator = A; }
579 void setAllocatorModifier(OpenMPAllocateClauseModifier AM) {
580 AllocatorModifier = AM;
581 }
582 void setAlignment(Expr *A) { Alignment = A; }
583
584public:
585 /// Creates clause with a list of variables \a VL.
586 ///
587 /// \param C AST context.
588 /// \param StartLoc Starting location of the clause.
589 /// \param LParenLoc Location of '('.
590 /// \param Allocator Allocator expression.
591 /// \param ColonLoc Location of ':' delimiter.
592 /// \param AllocatorModifier Allocator modifier.
593 /// \param SourceLocation Allocator modifier location.
594 /// \param EndLoc Ending location of the clause.
595 /// \param VL List of references to the variables.
596 static OMPAllocateClause *
597 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
598 Expr *Allocator, Expr *Alignment, SourceLocation ColonLoc,
599 OpenMPAllocateClauseModifier Modifier1, SourceLocation Modifier1Loc,
600 OpenMPAllocateClauseModifier Modifier2, SourceLocation Modifier2Loc,
601 SourceLocation EndLoc, ArrayRef<Expr *> VL);
602
603 /// Returns the allocator expression or nullptr, if no allocator is specified.
604 Expr *getAllocator() const { return Allocator; }
605
606 /// Returns the alignment expression or nullptr, if no alignment specified.
607 Expr *getAlignment() const { return Alignment; }
608
609 /// Return 'allocate' modifier.
611 return AllocatorModifier;
612 }
613
614 /// Get the first modifier of the clause.
616 return Modifiers[FIRST];
617 }
618
619 /// Get location of first modifier of the clause.
621 return ModifiersLoc[FIRST];
622 }
623
624 /// Get the second modifier of the clause.
626 return Modifiers[SECOND];
627 }
628
629 /// Get location of second modifier of the clause.
631 return ModifiersLoc[SECOND];
632 }
633
634 /// Returns the location of the ':' delimiter.
635 SourceLocation getColonLoc() const { return ColonLoc; }
636 /// Return the location of the modifier.
638 return AllocatorModifierLoc;
639 }
640
641 /// Creates an empty clause with the place for \a N variables.
642 ///
643 /// \param C AST context.
644 /// \param N The number of variables.
645 static OMPAllocateClause *CreateEmpty(const ASTContext &C, unsigned N);
646
648 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
649 reinterpret_cast<Stmt **>(varlist_end()));
650 }
651
653 auto Children = const_cast<OMPAllocateClause *>(this)->children();
654 return const_child_range(Children.begin(), Children.end());
655 }
656
663
664 static bool classof(const OMPClause *T) {
665 return T->getClauseKind() == llvm::omp::OMPC_allocate;
666 }
667};
668
669/// This represents 'if' clause in the '#pragma omp ...' directive.
670///
671/// \code
672/// #pragma omp parallel if(parallel:a > 5)
673/// \endcode
674/// In this example directive '#pragma omp parallel' has simple 'if' clause with
675/// condition 'a > 5' and directive name modifier 'parallel'.
677 friend class OMPClauseReader;
678
679 /// Location of '('.
680 SourceLocation LParenLoc;
681
682 /// Condition of the 'if' clause.
683 Stmt *Condition = nullptr;
684
685 /// Location of ':' (if any).
686 SourceLocation ColonLoc;
687
688 /// Directive name modifier for the clause.
689 OpenMPDirectiveKind NameModifier = llvm::omp::OMPD_unknown;
690
691 /// Name modifier location.
692 SourceLocation NameModifierLoc;
693
694 /// Set condition.
695 void setCondition(Expr *Cond) { Condition = Cond; }
696
697 /// Set directive name modifier for the clause.
698 void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
699
700 /// Set location of directive name modifier for the clause.
701 void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
702
703 /// Set location of ':'.
704 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
705
706public:
707 /// Build 'if' clause with condition \a Cond.
708 ///
709 /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
710 /// \param Cond Condition of the clause.
711 /// \param HelperCond Helper condition for the clause.
712 /// \param CaptureRegion Innermost OpenMP region where expressions in this
713 /// clause must be captured.
714 /// \param StartLoc Starting location of the clause.
715 /// \param LParenLoc Location of '('.
716 /// \param NameModifierLoc Location of directive name modifier.
717 /// \param ColonLoc [OpenMP 4.1] Location of ':'.
718 /// \param EndLoc Ending location of the clause.
719 OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond,
720 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
721 SourceLocation LParenLoc, SourceLocation NameModifierLoc,
722 SourceLocation ColonLoc, SourceLocation EndLoc)
723 : OMPClause(llvm::omp::OMPC_if, StartLoc, EndLoc),
724 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond),
725 ColonLoc(ColonLoc), NameModifier(NameModifier),
726 NameModifierLoc(NameModifierLoc) {
727 setPreInitStmt(HelperCond, CaptureRegion);
728 }
729
730 /// Build an empty clause.
734
735 /// Sets the location of '('.
736 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
737
738 /// Returns the location of '('.
739 SourceLocation getLParenLoc() const { return LParenLoc; }
740
741 /// Return the location of ':'.
742 SourceLocation getColonLoc() const { return ColonLoc; }
743
744 /// Returns condition.
745 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
746
747 /// Return directive name modifier associated with the clause.
748 OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
749
750 /// Return the location of directive name modifier.
751 SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
752
753 child_range children() { return child_range(&Condition, &Condition + 1); }
754
756 return const_child_range(&Condition, &Condition + 1);
757 }
758
761 auto Children = const_cast<OMPIfClause *>(this)->used_children();
762 return const_child_range(Children.begin(), Children.end());
763 }
764
765 static bool classof(const OMPClause *T) {
766 return T->getClauseKind() == llvm::omp::OMPC_if;
767 }
768};
769
770/// This represents 'final' clause in the '#pragma omp ...' directive.
771///
772/// \code
773/// #pragma omp task final(a > 5)
774/// \endcode
775/// In this example directive '#pragma omp task' has simple 'final'
776/// clause with condition 'a > 5'.
777class OMPFinalClause final
778 : public OMPOneStmtClause<llvm::omp::OMPC_final, OMPClause>,
779 public OMPClauseWithPreInit {
780 friend class OMPClauseReader;
781
782 /// Set condition.
783 void setCondition(Expr *Cond) { setStmt(Cond); }
784
785public:
786 /// Build 'final' clause with condition \a Cond.
787 ///
788 /// \param Cond Condition of the clause.
789 /// \param HelperCond Helper condition for the construct.
790 /// \param CaptureRegion Innermost OpenMP region where expressions in this
791 /// clause must be captured.
792 /// \param StartLoc Starting location of the clause.
793 /// \param LParenLoc Location of '('.
794 /// \param EndLoc Ending location of the clause.
796 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
797 SourceLocation LParenLoc, SourceLocation EndLoc)
798 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
800 setPreInitStmt(HelperCond, CaptureRegion);
801 }
802
803 /// Build an empty clause.
805
806 /// Returns condition.
807 Expr *getCondition() const { return getStmtAs<Expr>(); }
808
811 auto Children = const_cast<OMPFinalClause *>(this)->used_children();
812 return const_child_range(Children.begin(), Children.end());
813 }
814};
815/// This represents 'num_threads' clause in the '#pragma omp ...'
816/// directive.
817///
818/// \code
819/// #pragma omp parallel num_threads(6)
820/// \endcode
821/// In this example directive '#pragma omp parallel' has simple 'num_threads'
822/// clause with number of threads '6'.
824 : public OMPOneStmtClause<llvm::omp::OMPC_num_threads, OMPClause>,
825 public OMPClauseWithPreInit {
826 friend class OMPClauseReader;
827
828 /// Modifiers for 'num_threads' clause.
830
831 /// Location of the modifier.
832 SourceLocation ModifierLoc;
833
834 /// Sets modifier.
835 void setModifier(OpenMPNumThreadsClauseModifier M) { Modifier = M; }
836
837 /// Sets modifier location.
838 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
839
840 /// Set condition.
841 void setNumThreads(Expr *NThreads) { setStmt(NThreads); }
842
843public:
844 /// Build 'num_threads' clause with condition \a NumThreads.
845 ///
846 /// \param Modifier Clause modifier.
847 /// \param NumThreads Number of threads for the construct.
848 /// \param HelperNumThreads Helper Number of threads for the construct.
849 /// \param CaptureRegion Innermost OpenMP region where expressions in this
850 /// clause must be captured.
851 /// \param StartLoc Starting location of the clause.
852 /// \param LParenLoc Location of '('.
853 /// \param ModifierLoc Modifier location.
854 /// \param EndLoc Ending location of the clause.
856 Stmt *HelperNumThreads, OpenMPDirectiveKind CaptureRegion,
857 SourceLocation StartLoc, SourceLocation LParenLoc,
858 SourceLocation ModifierLoc, SourceLocation EndLoc)
859 : OMPOneStmtClause(NumThreads, StartLoc, LParenLoc, EndLoc),
860 OMPClauseWithPreInit(this), Modifier(Modifier),
861 ModifierLoc(ModifierLoc) {
862 setPreInitStmt(HelperNumThreads, CaptureRegion);
863 }
864
865 /// Build an empty clause.
867
868 /// Gets modifier.
869 OpenMPNumThreadsClauseModifier getModifier() const { return Modifier; }
870
871 /// Gets modifier location.
872 SourceLocation getModifierLoc() const { return ModifierLoc; }
873
874 /// Returns number of threads.
875 Expr *getNumThreads() const { return getStmtAs<Expr>(); }
876};
877
878/// This represents 'safelen' clause in the '#pragma omp ...'
879/// directive.
880///
881/// \code
882/// #pragma omp simd safelen(4)
883/// \endcode
884/// In this example directive '#pragma omp simd' has clause 'safelen'
885/// with single expression '4'.
886/// If the safelen clause is used then no two iterations executed
887/// concurrently with SIMD instructions can have a greater distance
888/// in the logical iteration space than its value. The parameter of
889/// the safelen clause must be a constant positive integer expression.
891 : public OMPOneStmtClause<llvm::omp::OMPC_safelen, OMPClause> {
892 friend class OMPClauseReader;
893
894 /// Set safelen.
895 void setSafelen(Expr *Len) { setStmt(Len); }
896
897public:
898 /// Build 'safelen' clause.
899 ///
900 /// \param Len Expression associated with this clause.
901 /// \param StartLoc Starting location of the clause.
902 /// \param EndLoc Ending location of the clause.
904 SourceLocation EndLoc)
905 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
906
907 /// Build an empty clause.
909
910 /// Return safe iteration space distance.
911 Expr *getSafelen() const { return getStmtAs<Expr>(); }
912};
913
914/// This represents 'simdlen' clause in the '#pragma omp ...'
915/// directive.
916///
917/// \code
918/// #pragma omp simd simdlen(4)
919/// \endcode
920/// In this example directive '#pragma omp simd' has clause 'simdlen'
921/// with single expression '4'.
922/// If the 'simdlen' clause is used then it specifies the preferred number of
923/// iterations to be executed concurrently. The parameter of the 'simdlen'
924/// clause must be a constant positive integer expression.
926 : public OMPOneStmtClause<llvm::omp::OMPC_simdlen, OMPClause> {
927 friend class OMPClauseReader;
928
929 /// Set simdlen.
930 void setSimdlen(Expr *Len) { setStmt(Len); }
931
932public:
933 /// Build 'simdlen' clause.
934 ///
935 /// \param Len Expression associated with this clause.
936 /// \param StartLoc Starting location of the clause.
937 /// \param EndLoc Ending location of the clause.
939 SourceLocation EndLoc)
940 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
941
942 /// Build an empty clause.
944
945 /// Return safe iteration space distance.
946 Expr *getSimdlen() const { return getStmtAs<Expr>(); }
947};
948
949/// This represents the 'sizes' clause in the '#pragma omp tile' directive.
950///
951/// \code
952/// #pragma omp tile sizes(5,5)
953/// for (int i = 0; i < 64; ++i)
954/// for (int j = 0; j < 64; ++j)
955/// \endcode
956class OMPSizesClause final
957 : public OMPClause,
958 private llvm::TrailingObjects<OMPSizesClause, Expr *> {
959 friend class OMPClauseReader;
960 friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
961
962 /// Location of '('.
963 SourceLocation LParenLoc;
964
965 /// Number of tile sizes in the clause.
966 unsigned NumSizes;
967
968 /// Build an empty clause.
969 explicit OMPSizesClause(int NumSizes)
970 : OMPClause(llvm::omp::OMPC_sizes, SourceLocation(), SourceLocation()),
971 NumSizes(NumSizes) {}
972
973public:
974 /// Build a 'sizes' AST node.
975 ///
976 /// \param C Context of the AST.
977 /// \param StartLoc Location of the 'sizes' identifier.
978 /// \param LParenLoc Location of '('.
979 /// \param EndLoc Location of ')'.
980 /// \param Sizes Content of the clause.
981 static OMPSizesClause *Create(const ASTContext &C, SourceLocation StartLoc,
982 SourceLocation LParenLoc, SourceLocation EndLoc,
983 ArrayRef<Expr *> Sizes);
984
985 /// Build an empty 'sizes' AST node for deserialization.
986 ///
987 /// \param C Context of the AST.
988 /// \param NumSizes Number of items in the clause.
989 static OMPSizesClause *CreateEmpty(const ASTContext &C, unsigned NumSizes);
990
991 /// Sets the location of '('.
992 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
993
994 /// Returns the location of '('.
995 SourceLocation getLParenLoc() const { return LParenLoc; }
996
997 /// Returns the number of list items.
998 unsigned getNumSizes() const { return NumSizes; }
999
1000 /// Returns the tile size expressions.
1002 return getTrailingObjects(NumSizes);
1003 }
1004 ArrayRef<Expr *> getSizesRefs() const { return getTrailingObjects(NumSizes); }
1005
1006 /// Sets the tile size expressions.
1008 assert(VL.size() == NumSizes);
1009 llvm::copy(VL, getSizesRefs().begin());
1010 }
1011
1014 return child_range(reinterpret_cast<Stmt **>(Sizes.begin()),
1015 reinterpret_cast<Stmt **>(Sizes.end()));
1016 }
1019 return const_child_range(reinterpret_cast<Stmt *const *>(Sizes.begin()),
1020 reinterpret_cast<Stmt *const *>(Sizes.end()));
1021 }
1022
1029
1030 static bool classof(const OMPClause *T) {
1031 return T->getClauseKind() == llvm::omp::OMPC_sizes;
1032 }
1033};
1034
1035/// This class represents the 'permutation' clause in the
1036/// '#pragma omp interchange' directive.
1037///
1038/// \code{.c}
1039/// #pragma omp interchange permutation(2,1)
1040/// for (int i = 0; i < 64; ++i)
1041/// for (int j = 0; j < 64; ++j)
1042/// \endcode
1043class OMPPermutationClause final
1044 : public OMPClause,
1045 private llvm::TrailingObjects<OMPSizesClause, Expr *> {
1046 friend class OMPClauseReader;
1047 friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
1048
1049 /// Location of '('.
1050 SourceLocation LParenLoc;
1051
1052 /// Number of arguments in the clause, and hence also the number of loops to
1053 /// be permuted.
1054 unsigned NumLoops;
1055
1056 /// Sets the permutation index expressions.
1057 void setArgRefs(ArrayRef<Expr *> VL) {
1058 assert(VL.size() == NumLoops && "Expecting one expression per loop");
1059 llvm::copy(VL, getTrailingObjects());
1060 }
1061
1062 /// Build an empty clause.
1063 explicit OMPPermutationClause(int NumLoops)
1064 : OMPClause(llvm::omp::OMPC_permutation, SourceLocation(),
1065 SourceLocation()),
1066 NumLoops(NumLoops) {}
1067
1068public:
1069 /// Build a 'permutation' clause AST node.
1070 ///
1071 /// \param C Context of the AST.
1072 /// \param StartLoc Location of the 'permutation' identifier.
1073 /// \param LParenLoc Location of '('.
1074 /// \param EndLoc Location of ')'.
1075 /// \param Args Content of the clause.
1076 static OMPPermutationClause *
1077 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1078 SourceLocation EndLoc, ArrayRef<Expr *> Args);
1079
1080 /// Build an empty 'permutation' AST node for deserialization.
1081 ///
1082 /// \param C Context of the AST.
1083 /// \param NumLoops Number of arguments in the clause.
1084 static OMPPermutationClause *CreateEmpty(const ASTContext &C,
1085 unsigned NumLoops);
1086
1087 /// Sets the location of '('.
1088 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1089
1090 /// Returns the location of '('.
1091 SourceLocation getLParenLoc() const { return LParenLoc; }
1092
1093 /// Returns the number of list items.
1094 unsigned getNumLoops() const { return NumLoops; }
1095
1096 /// Returns the permutation index expressions.
1097 ///@{
1098 MutableArrayRef<Expr *> getArgsRefs() { return getTrailingObjects(NumLoops); }
1099 ArrayRef<Expr *> getArgsRefs() const { return getTrailingObjects(NumLoops); }
1100 ///@}
1101
1104 return child_range(reinterpret_cast<Stmt **>(Args.begin()),
1105 reinterpret_cast<Stmt **>(Args.end()));
1106 }
1109 return const_child_range(reinterpret_cast<Stmt *const *>(Args.begin()),
1110 reinterpret_cast<Stmt *const *>(Args.end()));
1111 }
1112
1119
1120 static bool classof(const OMPClause *T) {
1121 return T->getClauseKind() == llvm::omp::OMPC_permutation;
1122 }
1123};
1124
1125/// Representation of the 'full' clause of the '#pragma omp unroll' directive.
1126///
1127/// \code
1128/// #pragma omp unroll full
1129/// for (int i = 0; i < 64; ++i)
1130/// \endcode
1131class OMPFullClause final : public OMPNoChildClause<llvm::omp::OMPC_full> {
1132 friend class OMPClauseReader;
1133
1134 /// Build an empty clause.
1135 explicit OMPFullClause() : OMPNoChildClause() {}
1136
1137public:
1138 /// Build an AST node for a 'full' clause.
1139 ///
1140 /// \param C Context of the AST.
1141 /// \param StartLoc Starting location of the clause.
1142 /// \param EndLoc Ending location of the clause.
1143 static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc,
1144 SourceLocation EndLoc);
1145
1146 /// Build an empty 'full' AST node for deserialization.
1147 ///
1148 /// \param C Context of the AST.
1149 static OMPFullClause *CreateEmpty(const ASTContext &C);
1150};
1151
1152/// Representation of the 'partial' clause of the '#pragma omp unroll'
1153/// directive.
1154///
1155/// \code
1156/// #pragma omp unroll partial(4)
1157/// for (int i = start; i < end; ++i)
1158/// \endcode
1159class OMPPartialClause final : public OMPClause {
1160 friend class OMPClauseReader;
1161
1162 /// Location of '('.
1163 SourceLocation LParenLoc;
1164
1165 /// Optional argument to the clause (unroll factor).
1166 Stmt *Factor;
1167
1168 /// Build an empty clause.
1169 explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {}
1170
1171 /// Set the unroll factor.
1172 void setFactor(Expr *E) { Factor = E; }
1173
1174 /// Sets the location of '('.
1175 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1176
1177public:
1178 /// Build an AST node for a 'partial' clause.
1179 ///
1180 /// \param C Context of the AST.
1181 /// \param StartLoc Location of the 'partial' identifier.
1182 /// \param LParenLoc Location of '('.
1183 /// \param EndLoc Location of ')'.
1184 /// \param Factor Clause argument.
1185 static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc,
1186 SourceLocation LParenLoc,
1187 SourceLocation EndLoc, Expr *Factor);
1188
1189 /// Build an empty 'partial' AST node for deserialization.
1190 ///
1191 /// \param C Context of the AST.
1192 static OMPPartialClause *CreateEmpty(const ASTContext &C);
1193
1194 /// Returns the location of '('.
1195 SourceLocation getLParenLoc() const { return LParenLoc; }
1196
1197 /// Returns the argument of the clause or nullptr if not set.
1198 Expr *getFactor() const { return cast_or_null<Expr>(Factor); }
1199
1200 child_range children() { return child_range(&Factor, &Factor + 1); }
1202 return const_child_range(&Factor, &Factor + 1);
1203 }
1204
1211
1212 static bool classof(const OMPClause *T) {
1213 return T->getClauseKind() == llvm::omp::OMPC_partial;
1214 }
1215};
1216
1217/// This represents 'collapse' clause in the '#pragma omp ...'
1218/// directive.
1219///
1220/// \code
1221/// #pragma omp simd collapse(3)
1222/// \endcode
1223/// In this example directive '#pragma omp simd' has clause 'collapse'
1224/// with single expression '3'.
1225/// The parameter must be a constant positive integer expression, it specifies
1226/// the number of nested loops that should be collapsed into a single iteration
1227/// space.
1229 : public OMPOneStmtClause<llvm::omp::OMPC_collapse, OMPClause> {
1230 friend class OMPClauseReader;
1231
1232 /// Set the number of associated for-loops.
1233 void setNumForLoops(Expr *Num) { setStmt(Num); }
1234
1235public:
1236 /// Build 'collapse' clause.
1237 ///
1238 /// \param Num Expression associated with this clause.
1239 /// \param StartLoc Starting location of the clause.
1240 /// \param LParenLoc Location of '('.
1241 /// \param EndLoc Ending location of the clause.
1243 SourceLocation LParenLoc, SourceLocation EndLoc)
1244 : OMPOneStmtClause(Num, StartLoc, LParenLoc, EndLoc) {}
1245
1246 /// Build an empty clause.
1248
1249 /// Return the number of associated for-loops.
1250 Expr *getNumForLoops() const { return getStmtAs<Expr>(); }
1251};
1252
1253/// This represents 'default' clause in the '#pragma omp ...' directive.
1254///
1255/// \code
1256/// #pragma omp parallel default(shared)
1257/// \endcode
1258/// In this example directive '#pragma omp parallel' has simple 'default'
1259/// clause with kind 'shared'.
1261 friend class OMPClauseReader;
1262
1263 /// Location of '('.
1264 SourceLocation LParenLoc;
1265
1266 /// A kind of the 'default' clause.
1267 llvm::omp::DefaultKind Kind = llvm::omp::OMP_DEFAULT_unknown;
1268
1269 /// Start location of the kind in source code.
1270 SourceLocation KindKwLoc;
1271
1272 /// Variable-Category to indicate where Kind is applied
1273 OpenMPDefaultClauseVariableCategory VC = OMPC_DEFAULT_VC_all;
1274
1275 /// Start location of Variable-Category
1276 SourceLocation VCLoc;
1277
1278 /// Set kind of the clauses.
1279 ///
1280 /// \param K Argument of clause.
1281 void setDefaultKind(llvm::omp::DefaultKind K) { Kind = K; }
1282
1283 /// Set argument location.
1284 ///
1285 /// \param KLoc Argument location.
1286 void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1287
1288 /// Set Variable Category used with the Kind Clause (Default Modifier)
1289 void setDefaultVariableCategory(OpenMPDefaultClauseVariableCategory VC) {
1290 this->VC = VC;
1291 }
1292
1293 void setDefaultVariableCategoryLocation(SourceLocation VCLoc) {
1294 this->VCLoc = VCLoc;
1295 }
1296
1297public:
1298 /// Build 'default' clause with argument \a A ('none' or 'shared').
1299 ///
1300 /// \param A Argument of the clause ('none' or 'shared').
1301 /// \param ALoc Starting location of the argument.
1302 /// \param StartLoc Starting location of the clause.
1303 /// \param LParenLoc Location of '('.
1304 /// \param EndLoc Ending location of the clause.
1305 OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc,
1307 SourceLocation StartLoc, SourceLocation LParenLoc,
1308 SourceLocation EndLoc)
1309 : OMPClause(llvm::omp::OMPC_default, StartLoc, EndLoc),
1310 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), VC(VC), VCLoc(VCLoc) {}
1311
1312 /// Build an empty clause.
1314 : OMPClause(llvm::omp::OMPC_default, SourceLocation(), SourceLocation()) {
1315 }
1316
1317 /// Sets the location of '('.
1318 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1319
1320 /// Returns the location of '('.
1321 SourceLocation getLParenLoc() const { return LParenLoc; }
1322
1323 /// Returns kind of the clause.
1324 llvm::omp::DefaultKind getDefaultKind() const { return Kind; }
1325
1326 /// Returns location of clause kind.
1327 SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
1328
1330
1331 SourceLocation getDefaultVCLoc() const { return VCLoc; }
1332
1336
1340
1347
1348 static bool classof(const OMPClause *T) {
1349 return T->getClauseKind() == llvm::omp::OMPC_default;
1350 }
1351};
1352
1353/// This represents 'proc_bind' clause in the '#pragma omp ...'
1354/// directive.
1355///
1356/// \code
1357/// #pragma omp parallel proc_bind(master)
1358/// \endcode
1359/// In this example directive '#pragma omp parallel' has simple 'proc_bind'
1360/// clause with kind 'master'.
1362 friend class OMPClauseReader;
1363
1364 /// Location of '('.
1365 SourceLocation LParenLoc;
1366
1367 /// A kind of the 'proc_bind' clause.
1368 llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown;
1369
1370 /// Start location of the kind in source code.
1371 SourceLocation KindKwLoc;
1372
1373 /// Set kind of the clause.
1374 ///
1375 /// \param K Kind of clause.
1376 void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; }
1377
1378 /// Set clause kind location.
1379 ///
1380 /// \param KLoc Kind location.
1381 void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1382
1383public:
1384 /// Build 'proc_bind' clause with argument \a A ('master', 'close' or
1385 /// 'spread').
1386 ///
1387 /// \param A Argument of the clause ('master', 'close' or 'spread').
1388 /// \param ALoc Starting location of the argument.
1389 /// \param StartLoc Starting location of the clause.
1390 /// \param LParenLoc Location of '('.
1391 /// \param EndLoc Ending location of the clause.
1392 OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc,
1393 SourceLocation StartLoc, SourceLocation LParenLoc,
1394 SourceLocation EndLoc)
1395 : OMPClause(llvm::omp::OMPC_proc_bind, StartLoc, EndLoc),
1396 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1397
1398 /// Build an empty clause.
1400 : OMPClause(llvm::omp::OMPC_proc_bind, SourceLocation(),
1401 SourceLocation()) {}
1402
1403 /// Sets the location of '('.
1404 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1405
1406 /// Returns the location of '('.
1407 SourceLocation getLParenLoc() const { return LParenLoc; }
1408
1409 /// Returns kind of the clause.
1410 llvm::omp::ProcBindKind getProcBindKind() const { return Kind; }
1411
1412 /// Returns location of clause kind.
1413 SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
1414
1418
1422
1429
1430 static bool classof(const OMPClause *T) {
1431 return T->getClauseKind() == llvm::omp::OMPC_proc_bind;
1432 }
1433};
1434
1435/// This represents 'unified_address' clause in the '#pragma omp requires'
1436/// directive.
1437///
1438/// \code
1439/// #pragma omp requires unified_address
1440/// \endcode
1441/// In this example directive '#pragma omp requires' has 'unified_address'
1442/// clause.
1444 : public OMPNoChildClause<llvm::omp::OMPC_unified_address> {
1445public:
1446 friend class OMPClauseReader;
1447 /// Build 'unified_address' clause.
1448 ///
1449 /// \param StartLoc Starting location of the clause.
1450 /// \param EndLoc Ending location of the clause.
1452 : OMPNoChildClause(StartLoc, EndLoc) {}
1453
1454 /// Build an empty clause.
1456};
1457
1458/// This represents 'unified_shared_memory' clause in the '#pragma omp requires'
1459/// directive.
1460///
1461/// \code
1462/// #pragma omp requires unified_shared_memory
1463/// \endcode
1464/// In this example directive '#pragma omp requires' has 'unified_shared_memory'
1465/// clause.
1467public:
1468 friend class OMPClauseReader;
1469 /// Build 'unified_shared_memory' clause.
1470 ///
1471 /// \param StartLoc Starting location of the clause.
1472 /// \param EndLoc Ending location of the clause.
1474 : OMPClause(llvm::omp::OMPC_unified_shared_memory, StartLoc, EndLoc) {}
1475
1476 /// Build an empty clause.
1478 : OMPClause(llvm::omp::OMPC_unified_shared_memory, SourceLocation(),
1479 SourceLocation()) {}
1480
1484
1488
1495
1496 static bool classof(const OMPClause *T) {
1497 return T->getClauseKind() == llvm::omp::OMPC_unified_shared_memory;
1498 }
1499};
1500
1501/// This represents 'reverse_offload' clause in the '#pragma omp requires'
1502/// directive.
1503///
1504/// \code
1505/// #pragma omp requires reverse_offload
1506/// \endcode
1507/// In this example directive '#pragma omp requires' has 'reverse_offload'
1508/// clause.
1510public:
1511 friend class OMPClauseReader;
1512 /// Build 'reverse_offload' clause.
1513 ///
1514 /// \param StartLoc Starting location of the clause.
1515 /// \param EndLoc Ending location of the clause.
1517 : OMPClause(llvm::omp::OMPC_reverse_offload, StartLoc, EndLoc) {}
1518
1519 /// Build an empty clause.
1521 : OMPClause(llvm::omp::OMPC_reverse_offload, SourceLocation(),
1522 SourceLocation()) {}
1523
1527
1531
1538
1539 static bool classof(const OMPClause *T) {
1540 return T->getClauseKind() == llvm::omp::OMPC_reverse_offload;
1541 }
1542};
1543
1544/// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
1545/// directive.
1546///
1547/// \code
1548/// #pragma omp requires dynamic_allocators
1549/// \endcode
1550/// In this example directive '#pragma omp requires' has 'dynamic_allocators'
1551/// clause.
1553public:
1554 friend class OMPClauseReader;
1555 /// Build 'dynamic_allocators' clause.
1556 ///
1557 /// \param StartLoc Starting location of the clause.
1558 /// \param EndLoc Ending location of the clause.
1560 : OMPClause(llvm::omp::OMPC_dynamic_allocators, StartLoc, EndLoc) {}
1561
1562 /// Build an empty clause.
1564 : OMPClause(llvm::omp::OMPC_dynamic_allocators, SourceLocation(),
1565 SourceLocation()) {}
1566
1570
1574
1581
1582 static bool classof(const OMPClause *T) {
1583 return T->getClauseKind() == llvm::omp::OMPC_dynamic_allocators;
1584 }
1585};
1586
1587/// This represents 'atomic_default_mem_order' clause in the '#pragma omp
1588/// requires' directive.
1589///
1590/// \code
1591/// #pragma omp requires atomic_default_mem_order(seq_cst)
1592/// \endcode
1593/// In this example directive '#pragma omp requires' has simple
1594/// atomic_default_mem_order' clause with kind 'seq_cst'.
1596 friend class OMPClauseReader;
1597
1598 /// Location of '('
1599 SourceLocation LParenLoc;
1600
1601 /// A kind of the 'atomic_default_mem_order' clause.
1604
1605 /// Start location of the kind in source code.
1606 SourceLocation KindKwLoc;
1607
1608 /// Set kind of the clause.
1609 ///
1610 /// \param K Kind of clause.
1611 void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) {
1612 Kind = K;
1613 }
1614
1615 /// Set clause kind location.
1616 ///
1617 /// \param KLoc Kind location.
1618 void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) {
1619 KindKwLoc = KLoc;
1620 }
1621
1622public:
1623 /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst',
1624 /// 'acq_rel' or 'relaxed').
1625 ///
1626 /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed').
1627 /// \param ALoc Starting location of the argument.
1628 /// \param StartLoc Starting location of the clause.
1629 /// \param LParenLoc Location of '('.
1630 /// \param EndLoc Ending location of the clause.
1632 SourceLocation ALoc, SourceLocation StartLoc,
1633 SourceLocation LParenLoc,
1634 SourceLocation EndLoc)
1635 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, StartLoc, EndLoc),
1636 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1637
1638 /// Build an empty clause.
1640 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, SourceLocation(),
1641 SourceLocation()) {}
1642
1643 /// Sets the location of '('.
1644 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1645
1646 /// Returns the locaiton of '('.
1647 SourceLocation getLParenLoc() const { return LParenLoc; }
1648
1649 /// Returns kind of the clause.
1653
1654 /// Returns location of clause kind.
1656
1660
1664
1671
1672 static bool classof(const OMPClause *T) {
1673 return T->getClauseKind() == llvm::omp::OMPC_atomic_default_mem_order;
1674 }
1675};
1676
1677/// This represents 'self_maps' clause in the '#pragma omp requires'
1678/// directive.
1679///
1680/// \code
1681/// #pragma omp requires self_maps
1682/// \endcode
1683/// In this example directive '#pragma omp requires' has 'self_maps'
1684/// clause.
1685class OMPSelfMapsClause final : public OMPClause {
1686public:
1687 friend class OMPClauseReader;
1688 /// Build 'self_maps' clause.
1689 ///
1690 /// \param StartLoc Starting location of the clause.
1691 /// \param EndLoc Ending location of the clause.
1693 : OMPClause(llvm::omp::OMPC_self_maps, StartLoc, EndLoc) {}
1694
1695 /// Build an empty clause.
1697 : OMPClause(llvm::omp::OMPC_self_maps, SourceLocation(),
1698 SourceLocation()) {}
1699
1703
1707
1714
1715 static bool classof(const OMPClause *T) {
1716 return T->getClauseKind() == llvm::omp::OMPC_self_maps;
1717 }
1718};
1719
1720/// This represents 'at' clause in the '#pragma omp error' directive
1721///
1722/// \code
1723/// #pragma omp error at(compilation)
1724/// \endcode
1725/// In this example directive '#pragma omp error' has simple
1726/// 'at' clause with kind 'complilation'.
1727class OMPAtClause final : public OMPClause {
1728 friend class OMPClauseReader;
1729
1730 /// Location of '('
1731 SourceLocation LParenLoc;
1732
1733 /// A kind of the 'at' clause.
1735
1736 /// Start location of the kind in source code.
1737 SourceLocation KindKwLoc;
1738
1739 /// Set kind of the clause.
1740 ///
1741 /// \param K Kind of clause.
1742 void setAtKind(OpenMPAtClauseKind K) { Kind = K; }
1743
1744 /// Set clause kind location.
1745 ///
1746 /// \param KLoc Kind location.
1747 void setAtKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1748
1749 /// Sets the location of '('.
1750 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1751
1752public:
1753 /// Build 'at' clause with argument \a A ('compilation' or 'execution').
1754 ///
1755 /// \param A Argument of the clause ('compilation' or 'execution').
1756 /// \param ALoc Starting location of the argument.
1757 /// \param StartLoc Starting location of the clause.
1758 /// \param LParenLoc Location of '('.
1759 /// \param EndLoc Ending location of the clause.
1761 SourceLocation StartLoc, SourceLocation LParenLoc,
1762 SourceLocation EndLoc)
1763 : OMPClause(llvm::omp::OMPC_at, StartLoc, EndLoc), LParenLoc(LParenLoc),
1764 Kind(A), KindKwLoc(ALoc) {}
1765
1766 /// Build an empty clause.
1768 : OMPClause(llvm::omp::OMPC_at, SourceLocation(), SourceLocation()) {}
1769
1770 /// Returns the locaiton of '('.
1771 SourceLocation getLParenLoc() const { return LParenLoc; }
1772
1773 /// Returns kind of the clause.
1774 OpenMPAtClauseKind getAtKind() const { return Kind; }
1775
1776 /// Returns location of clause kind.
1777 SourceLocation getAtKindKwLoc() const { return KindKwLoc; }
1778
1782
1786
1793
1794 static bool classof(const OMPClause *T) {
1795 return T->getClauseKind() == llvm::omp::OMPC_at;
1796 }
1797};
1798
1799/// This represents the 'severity' clause in the '#pragma omp error' and the
1800/// '#pragma omp parallel' directives.
1801///
1802/// \code
1803/// #pragma omp error severity(fatal)
1804/// \endcode
1805/// In this example directive '#pragma omp error' has simple
1806/// 'severity' clause with kind 'fatal'.
1807class OMPSeverityClause final : public OMPClause {
1808 friend class OMPClauseReader;
1809
1810 /// Location of '('
1811 SourceLocation LParenLoc;
1812
1813 /// A kind of the 'severity' clause.
1815
1816 /// Start location of the kind in source code.
1817 SourceLocation KindKwLoc;
1818
1819 /// Set kind of the clause.
1820 ///
1821 /// \param K Kind of clause.
1822 void setSeverityKind(OpenMPSeverityClauseKind K) { Kind = K; }
1823
1824 /// Set clause kind location.
1825 ///
1826 /// \param KLoc Kind location.
1827 void setSeverityKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1828
1829 /// Sets the location of '('.
1830 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1831
1832public:
1833 /// Build 'severity' clause with argument \a A ('fatal' or 'warning').
1834 ///
1835 /// \param A Argument of the clause ('fatal' or 'warning').
1836 /// \param ALoc Starting location of the argument.
1837 /// \param StartLoc Starting location of the clause.
1838 /// \param LParenLoc Location of '('.
1839 /// \param EndLoc Ending location of the clause.
1841 SourceLocation StartLoc, SourceLocation LParenLoc,
1842 SourceLocation EndLoc)
1843 : OMPClause(llvm::omp::OMPC_severity, StartLoc, EndLoc),
1844 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1845
1846 /// Build an empty clause.
1848 : OMPClause(llvm::omp::OMPC_severity, SourceLocation(),
1849 SourceLocation()) {}
1850
1851 /// Returns the locaiton of '('.
1852 SourceLocation getLParenLoc() const { return LParenLoc; }
1853
1854 /// Returns kind of the clause.
1856
1857 /// Returns location of clause kind.
1858 SourceLocation getSeverityKindKwLoc() const { return KindKwLoc; }
1859
1863
1867
1874
1875 static bool classof(const OMPClause *T) {
1876 return T->getClauseKind() == llvm::omp::OMPC_severity;
1877 }
1878};
1879
1880/// This represents the 'message' clause in the '#pragma omp error' and the
1881/// '#pragma omp parallel' directives.
1882///
1883/// \code
1884/// #pragma omp error message("GNU compiler required.")
1885/// \endcode
1886/// In this example directive '#pragma omp error' has simple
1887/// 'message' clause with user error message of "GNU compiler required.".
1889 : public OMPOneStmtClause<llvm::omp::OMPC_message, OMPClause>,
1890 public OMPClauseWithPreInit {
1891 friend class OMPClauseReader;
1892
1893 /// Set message string of the clause.
1894 void setMessageString(Expr *MS) { setStmt(MS); }
1895
1896public:
1897 /// Build 'message' clause with message string argument
1898 ///
1899 /// \param MS Argument of the clause (message string).
1900 /// \param HelperMS Helper statement for the construct.
1901 /// \param CaptureRegion Innermost OpenMP region where expressions in this
1902 /// clause must be captured.
1903 /// \param StartLoc Starting location of the clause.
1904 /// \param LParenLoc Location of '('.
1905 /// \param EndLoc Ending location of the clause.
1906 OMPMessageClause(Expr *MS, Stmt *HelperMS, OpenMPDirectiveKind CaptureRegion,
1907 SourceLocation StartLoc, SourceLocation LParenLoc,
1908 SourceLocation EndLoc)
1909 : OMPOneStmtClause(MS, StartLoc, LParenLoc, EndLoc),
1910 OMPClauseWithPreInit(this) {
1911 setPreInitStmt(HelperMS, CaptureRegion);
1912 }
1913
1914 /// Build an empty clause.
1916
1917 /// Returns message string of the clause.
1919
1920 /// Try to evaluate the message string at compile time.
1921 std::optional<std::string> tryEvaluateString(ASTContext &Ctx) const {
1922 if (Expr *MessageExpr = getMessageString())
1923 return MessageExpr->tryEvaluateString(Ctx);
1924 return std::nullopt;
1925 }
1926};
1927
1928/// This represents 'schedule' clause in the '#pragma omp ...' directive.
1929///
1930/// \code
1931/// #pragma omp for schedule(static, 3)
1932/// \endcode
1933/// In this example directive '#pragma omp for' has 'schedule' clause with
1934/// arguments 'static' and '3'.
1936 friend class OMPClauseReader;
1937
1938 /// Location of '('.
1939 SourceLocation LParenLoc;
1940
1941 /// A kind of the 'schedule' clause.
1943
1944 /// Modifiers for 'schedule' clause.
1945 enum {FIRST, SECOND, NUM_MODIFIERS};
1946 OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
1947
1948 /// Locations of modifiers.
1949 SourceLocation ModifiersLoc[NUM_MODIFIERS];
1950
1951 /// Start location of the schedule ind in source code.
1952 SourceLocation KindLoc;
1953
1954 /// Location of ',' (if any).
1955 SourceLocation CommaLoc;
1956
1957 /// Chunk size.
1958 Expr *ChunkSize = nullptr;
1959
1960 /// Set schedule kind.
1961 ///
1962 /// \param K Schedule kind.
1963 void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
1964
1965 /// Set the first schedule modifier.
1966 ///
1967 /// \param M Schedule modifier.
1968 void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
1969 Modifiers[FIRST] = M;
1970 }
1971
1972 /// Set the second schedule modifier.
1973 ///
1974 /// \param M Schedule modifier.
1975 void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
1976 Modifiers[SECOND] = M;
1977 }
1978
1979 /// Set location of the first schedule modifier.
1980 void setFirstScheduleModifierLoc(SourceLocation Loc) {
1981 ModifiersLoc[FIRST] = Loc;
1982 }
1983
1984 /// Set location of the second schedule modifier.
1985 void setSecondScheduleModifierLoc(SourceLocation Loc) {
1986 ModifiersLoc[SECOND] = Loc;
1987 }
1988
1989 /// Set schedule modifier location.
1990 ///
1991 /// \param M Schedule modifier location.
1992 void setScheduleModifer(OpenMPScheduleClauseModifier M) {
1993 if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
1994 Modifiers[FIRST] = M;
1995 else {
1996 assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
1997 Modifiers[SECOND] = M;
1998 }
1999 }
2000
2001 /// Sets the location of '('.
2002 ///
2003 /// \param Loc Location of '('.
2004 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2005
2006 /// Set schedule kind start location.
2007 ///
2008 /// \param KLoc Schedule kind location.
2009 void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
2010
2011 /// Set location of ','.
2012 ///
2013 /// \param Loc Location of ','.
2014 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
2015
2016 /// Set chunk size.
2017 ///
2018 /// \param E Chunk size.
2019 void setChunkSize(Expr *E) { ChunkSize = E; }
2020
2021public:
2022 /// Build 'schedule' clause with schedule kind \a Kind and chunk size
2023 /// expression \a ChunkSize.
2024 ///
2025 /// \param StartLoc Starting location of the clause.
2026 /// \param LParenLoc Location of '('.
2027 /// \param KLoc Starting location of the argument.
2028 /// \param CommaLoc Location of ','.
2029 /// \param EndLoc Ending location of the clause.
2030 /// \param Kind Schedule kind.
2031 /// \param ChunkSize Chunk size.
2032 /// \param HelperChunkSize Helper chunk size for combined directives.
2033 /// \param M1 The first modifier applied to 'schedule' clause.
2034 /// \param M1Loc Location of the first modifier
2035 /// \param M2 The second modifier applied to 'schedule' clause.
2036 /// \param M2Loc Location of the second modifier
2038 SourceLocation KLoc, SourceLocation CommaLoc,
2040 Expr *ChunkSize, Stmt *HelperChunkSize,
2043 : OMPClause(llvm::omp::OMPC_schedule, StartLoc, EndLoc),
2044 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
2045 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
2046 setPreInitStmt(HelperChunkSize);
2047 Modifiers[FIRST] = M1;
2048 Modifiers[SECOND] = M2;
2049 ModifiersLoc[FIRST] = M1Loc;
2050 ModifiersLoc[SECOND] = M2Loc;
2051 }
2052
2053 /// Build an empty clause.
2055 : OMPClause(llvm::omp::OMPC_schedule, SourceLocation(), SourceLocation()),
2056 OMPClauseWithPreInit(this) {
2057 Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
2058 Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
2059 }
2060
2061 /// Get kind of the clause.
2063
2064 /// Get the first modifier of the clause.
2066 return Modifiers[FIRST];
2067 }
2068
2069 /// Get the second modifier of the clause.
2071 return Modifiers[SECOND];
2072 }
2073
2074 /// Get location of '('.
2075 SourceLocation getLParenLoc() { return LParenLoc; }
2076
2077 /// Get kind location.
2079
2080 /// Get the first modifier location.
2082 return ModifiersLoc[FIRST];
2083 }
2084
2085 /// Get the second modifier location.
2087 return ModifiersLoc[SECOND];
2088 }
2089
2090 /// Get location of ','.
2091 SourceLocation getCommaLoc() { return CommaLoc; }
2092
2093 /// Get chunk size.
2094 Expr *getChunkSize() { return ChunkSize; }
2095
2096 /// Get chunk size.
2097 const Expr *getChunkSize() const { return ChunkSize; }
2098
2100 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
2101 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
2102 }
2103
2105 auto Children = const_cast<OMPScheduleClause *>(this)->children();
2106 return const_child_range(Children.begin(), Children.end());
2107 }
2108
2115
2116 static bool classof(const OMPClause *T) {
2117 return T->getClauseKind() == llvm::omp::OMPC_schedule;
2118 }
2119};
2120
2121/// This represents 'ordered' clause in the '#pragma omp ...' directive.
2122///
2123/// \code
2124/// #pragma omp for ordered (2)
2125/// \endcode
2126/// In this example directive '#pragma omp for' has 'ordered' clause with
2127/// parameter 2.
2128class OMPOrderedClause final
2129 : public OMPClause,
2130 private llvm::TrailingObjects<OMPOrderedClause, Expr *> {
2131 friend class OMPClauseReader;
2132 friend TrailingObjects;
2133
2134 /// Location of '('.
2135 SourceLocation LParenLoc;
2136
2137 /// Number of for-loops.
2138 Stmt *NumForLoops = nullptr;
2139
2140 /// Real number of loops.
2141 unsigned NumberOfLoops = 0;
2142
2143 /// Build 'ordered' clause.
2144 ///
2145 /// \param Num Expression, possibly associated with this clause.
2146 /// \param NumLoops Number of loops, associated with this clause.
2147 /// \param StartLoc Starting location of the clause.
2148 /// \param LParenLoc Location of '('.
2149 /// \param EndLoc Ending location of the clause.
2150 OMPOrderedClause(Expr *Num, unsigned NumLoops, SourceLocation StartLoc,
2151 SourceLocation LParenLoc, SourceLocation EndLoc)
2152 : OMPClause(llvm::omp::OMPC_ordered, StartLoc, EndLoc),
2153 LParenLoc(LParenLoc), NumForLoops(Num), NumberOfLoops(NumLoops) {}
2154
2155 /// Build an empty clause.
2156 explicit OMPOrderedClause(unsigned NumLoops)
2157 : OMPClause(llvm::omp::OMPC_ordered, SourceLocation(), SourceLocation()),
2158 NumberOfLoops(NumLoops) {}
2159
2160 /// Set the number of associated for-loops.
2161 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
2162
2163public:
2164 /// Build 'ordered' clause.
2165 ///
2166 /// \param Num Expression, possibly associated with this clause.
2167 /// \param NumLoops Number of loops, associated with this clause.
2168 /// \param StartLoc Starting location of the clause.
2169 /// \param LParenLoc Location of '('.
2170 /// \param EndLoc Ending location of the clause.
2171 static OMPOrderedClause *Create(const ASTContext &C, Expr *Num,
2172 unsigned NumLoops, SourceLocation StartLoc,
2173 SourceLocation LParenLoc,
2174 SourceLocation EndLoc);
2175
2176 /// Build an empty clause.
2177 static OMPOrderedClause* CreateEmpty(const ASTContext &C, unsigned NumLoops);
2178
2179 /// Sets the location of '('.
2180 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2181
2182 /// Returns the location of '('.
2183 SourceLocation getLParenLoc() const { return LParenLoc; }
2184
2185 /// Return the number of associated for-loops.
2186 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
2187
2188 /// Set number of iterations for the specified loop.
2189 void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations);
2190 /// Get number of iterations for all the loops.
2192
2193 /// Set loop counter for the specified loop.
2194 void setLoopCounter(unsigned NumLoop, Expr *Counter);
2195 /// Get loops counter for the specified loop.
2196 Expr *getLoopCounter(unsigned NumLoop);
2197 const Expr *getLoopCounter(unsigned NumLoop) const;
2198
2199 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
2200
2202 return const_child_range(&NumForLoops, &NumForLoops + 1);
2203 }
2204
2211
2212 static bool classof(const OMPClause *T) {
2213 return T->getClauseKind() == llvm::omp::OMPC_ordered;
2214 }
2215};
2216
2217/// This represents 'nowait' clause in the '#pragma omp ...' directive.
2218///
2219/// \code
2220/// #pragma omp for nowait
2221/// \endcode
2222/// In this example directive '#pragma omp for' has 'nowait' clause.
2223class OMPNowaitClause final : public OMPNoChildClause<llvm::omp::OMPC_nowait> {
2224public:
2225 /// Build 'nowait' clause.
2226 ///
2227 /// \param StartLoc Starting location of the clause.
2228 /// \param EndLoc Ending location of the clause.
2230 SourceLocation EndLoc = SourceLocation())
2231 : OMPNoChildClause(StartLoc, EndLoc) {}
2232};
2233
2234/// This represents 'untied' clause in the '#pragma omp ...' directive.
2235///
2236/// \code
2237/// #pragma omp task untied
2238/// \endcode
2239/// In this example directive '#pragma omp task' has 'untied' clause.
2241public:
2242 /// Build 'untied' clause.
2243 ///
2244 /// \param StartLoc Starting location of the clause.
2245 /// \param EndLoc Ending location of the clause.
2247 : OMPClause(llvm::omp::OMPC_untied, StartLoc, EndLoc) {}
2248
2249 /// Build an empty clause.
2251 : OMPClause(llvm::omp::OMPC_untied, SourceLocation(), SourceLocation()) {}
2252
2256
2260
2267
2268 static bool classof(const OMPClause *T) {
2269 return T->getClauseKind() == llvm::omp::OMPC_untied;
2270 }
2271};
2272
2273/// This represents 'mergeable' clause in the '#pragma omp ...'
2274/// directive.
2275///
2276/// \code
2277/// #pragma omp task mergeable
2278/// \endcode
2279/// In this example directive '#pragma omp task' has 'mergeable' clause.
2281public:
2282 /// Build 'mergeable' clause.
2283 ///
2284 /// \param StartLoc Starting location of the clause.
2285 /// \param EndLoc Ending location of the clause.
2287 : OMPClause(llvm::omp::OMPC_mergeable, StartLoc, EndLoc) {}
2288
2289 /// Build an empty clause.
2291 : OMPClause(llvm::omp::OMPC_mergeable, SourceLocation(),
2292 SourceLocation()) {}
2293
2297
2301
2308
2309 static bool classof(const OMPClause *T) {
2310 return T->getClauseKind() == llvm::omp::OMPC_mergeable;
2311 }
2312};
2313
2314/// This represents the 'absent' clause in the '#pragma omp assume'
2315/// directive.
2316///
2317/// \code
2318/// #pragma omp assume absent(<directive-name list>)
2319/// \endcode
2320/// In this example directive '#pragma omp assume' has an 'absent' clause.
2321class OMPAbsentClause final
2322 : public OMPDirectiveListClause<OMPAbsentClause>,
2323 private llvm::TrailingObjects<OMPAbsentClause, OpenMPDirectiveKind> {
2324 friend OMPDirectiveListClause;
2325 friend TrailingObjects;
2326
2327 /// Build 'absent' clause.
2328 ///
2329 /// \param StartLoc Starting location of the clause.
2330 /// \param LParenLoc Location of '('.
2331 /// \param EndLoc Ending location of the clause.
2332 /// \param NumKinds Number of directive kinds listed in the clause.
2333 OMPAbsentClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2334 SourceLocation EndLoc, unsigned NumKinds)
2335 : OMPDirectiveListClause<OMPAbsentClause>(
2336 llvm::omp::OMPC_absent, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2337
2338 /// Build an empty clause.
2339 OMPAbsentClause(unsigned NumKinds)
2340 : OMPDirectiveListClause<OMPAbsentClause>(
2341 llvm::omp::OMPC_absent, SourceLocation(), SourceLocation(),
2343
2344public:
2345 static OMPAbsentClause *Create(const ASTContext &C,
2348 SourceLocation RLoc);
2349
2350 static OMPAbsentClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2351
2352 static bool classof(const OMPClause *C) {
2353 return C->getClauseKind() == llvm::omp::OMPC_absent;
2354 }
2355};
2356
2357/// This represents the 'contains' clause in the '#pragma omp assume'
2358/// directive.
2359///
2360/// \code
2361/// #pragma omp assume contains(<directive-name list>)
2362/// \endcode
2363/// In this example directive '#pragma omp assume' has a 'contains' clause.
2364class OMPContainsClause final
2365 : public OMPDirectiveListClause<OMPContainsClause>,
2366 private llvm::TrailingObjects<OMPContainsClause, OpenMPDirectiveKind> {
2367 friend OMPDirectiveListClause;
2368 friend TrailingObjects;
2369
2370 /// Build 'contains' clause.
2371 ///
2372 /// \param StartLoc Starting location of the clause.
2373 /// \param LParenLoc Location of '('.
2374 /// \param EndLoc Ending location of the clause.
2375 /// \param NumKinds Number of directive kinds listed in the clause.
2376 OMPContainsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2377 SourceLocation EndLoc, unsigned NumKinds)
2378 : OMPDirectiveListClause<OMPContainsClause>(
2379 llvm::omp::OMPC_contains, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2380
2381 /// Build an empty clause.
2382 OMPContainsClause(unsigned NumKinds)
2383 : OMPDirectiveListClause<OMPContainsClause>(
2384 llvm::omp::OMPC_contains, SourceLocation(), SourceLocation(),
2386
2387public:
2388 static OMPContainsClause *Create(const ASTContext &C,
2391 SourceLocation RLoc);
2392
2393 static OMPContainsClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2394
2395 static bool classof(const OMPClause *C) {
2396 return C->getClauseKind() == llvm::omp::OMPC_contains;
2397 }
2398};
2399
2400/// This represents the 'holds' clause in the '#pragma omp assume'
2401/// directive.
2402///
2403/// \code
2404/// #pragma omp assume holds(<expr>)
2405/// \endcode
2406/// In this example directive '#pragma omp assume' has a 'holds' clause.
2408 : public OMPOneStmtClause<llvm::omp::OMPC_holds, OMPClause> {
2409 friend class OMPClauseReader;
2410
2411public:
2412 /// Build 'holds' clause.
2413 ///
2414 /// \param StartLoc Starting location of the clause.
2415 /// \param EndLoc Ending location of the clause.
2417 SourceLocation EndLoc)
2418 : OMPOneStmtClause(E, StartLoc, LParenLoc, EndLoc) {}
2419
2420 /// Build an empty clause.
2422
2423 Expr *getExpr() const { return getStmtAs<Expr>(); }
2424 void setExpr(Expr *E) { setStmt(E); }
2425};
2426
2427/// This represents the 'no_openmp' clause in the '#pragma omp assume'
2428/// directive.
2429///
2430/// \code
2431/// #pragma omp assume no_openmp
2432/// \endcode
2433/// In this example directive '#pragma omp assume' has a 'no_openmp' clause.
2435 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp> {
2436public:
2437 /// Build 'no_openmp' clause.
2438 ///
2439 /// \param StartLoc Starting location of the clause.
2440 /// \param EndLoc Ending location of the clause.
2442 : OMPNoChildClause(StartLoc, EndLoc) {}
2443
2444 /// Build an empty clause.
2446};
2447
2448/// This represents the 'no_openmp_routines' clause in the '#pragma omp assume'
2449/// directive.
2450///
2451/// \code
2452/// #pragma omp assume no_openmp_routines
2453/// \endcode
2454/// In this example directive '#pragma omp assume' has a 'no_openmp_routines'
2455/// clause.
2457 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp_routines> {
2458public:
2459 /// Build 'no_openmp_routines' clause.
2460 ///
2461 /// \param StartLoc Starting location of the clause.
2462 /// \param EndLoc Ending location of the clause.
2464 : OMPNoChildClause(StartLoc, EndLoc) {}
2465
2466 /// Build an empty clause.
2468};
2469
2470/// This represents the 'no_openmp_constructs' clause in the
2471//// '#pragma omp assume' directive.
2472///
2473/// \code
2474/// #pragma omp assume no_openmp_constructs
2475/// \endcode
2476/// In this example directive '#pragma omp assume' has a 'no_openmp_constructs'
2477/// clause.
2479 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp_constructs> {
2480public:
2481 /// Build 'no_openmp_constructs' clause.
2482 ///
2483 /// \param StartLoc Starting location of the clause.
2484 /// \param EndLoc Ending location of the clause.
2486 : OMPNoChildClause(StartLoc, EndLoc) {}
2487
2488 /// Build an empty clause.
2490};
2491
2492/// This represents the 'no_parallelism' clause in the '#pragma omp assume'
2493/// directive.
2494///
2495/// \code
2496/// #pragma omp assume no_parallelism
2497/// \endcode
2498/// In this example directive '#pragma omp assume' has a 'no_parallelism'
2499/// clause.
2501 : public OMPNoChildClause<llvm::omp::OMPC_no_parallelism> {
2502public:
2503 /// Build 'no_parallelism' clause.
2504 ///
2505 /// \param StartLoc Starting location of the clause.
2506 /// \param EndLoc Ending location of the clause.
2508 : OMPNoChildClause(StartLoc, EndLoc) {}
2509
2510 /// Build an empty clause.
2512};
2513
2514/// This represents 'read' clause in the '#pragma omp atomic' directive.
2515///
2516/// \code
2517/// #pragma omp atomic read
2518/// \endcode
2519/// In this example directive '#pragma omp atomic' has 'read' clause.
2520class OMPReadClause : public OMPClause {
2521public:
2522 /// Build 'read' clause.
2523 ///
2524 /// \param StartLoc Starting location of the clause.
2525 /// \param EndLoc Ending location of the clause.
2527 : OMPClause(llvm::omp::OMPC_read, StartLoc, EndLoc) {}
2528
2529 /// Build an empty clause.
2531 : OMPClause(llvm::omp::OMPC_read, SourceLocation(), SourceLocation()) {}
2532
2536
2540
2547
2548 static bool classof(const OMPClause *T) {
2549 return T->getClauseKind() == llvm::omp::OMPC_read;
2550 }
2551};
2552
2553/// This represents 'write' clause in the '#pragma omp atomic' directive.
2554///
2555/// \code
2556/// #pragma omp atomic write
2557/// \endcode
2558/// In this example directive '#pragma omp atomic' has 'write' clause.
2560public:
2561 /// Build 'write' clause.
2562 ///
2563 /// \param StartLoc Starting location of the clause.
2564 /// \param EndLoc Ending location of the clause.
2566 : OMPClause(llvm::omp::OMPC_write, StartLoc, EndLoc) {}
2567
2568 /// Build an empty clause.
2570 : OMPClause(llvm::omp::OMPC_write, SourceLocation(), SourceLocation()) {}
2571
2575
2579
2586
2587 static bool classof(const OMPClause *T) {
2588 return T->getClauseKind() == llvm::omp::OMPC_write;
2589 }
2590};
2591
2592/// This represents 'update' clause in the '#pragma omp atomic'
2593/// directive.
2594///
2595/// \code
2596/// #pragma omp atomic update
2597/// \endcode
2598/// In this example directive '#pragma omp atomic' has 'update' clause.
2599/// Also, this class represents 'update' clause in '#pragma omp depobj'
2600/// directive.
2601///
2602/// \code
2603/// #pragma omp depobj(a) update(in)
2604/// \endcode
2605/// In this example directive '#pragma omp depobj' has 'update' clause with 'in'
2606/// dependence kind.
2607class OMPUpdateClause final
2608 : public OMPClause,
2609 private llvm::TrailingObjects<OMPUpdateClause, SourceLocation,
2610 OpenMPDependClauseKind> {
2611 friend class OMPClauseReader;
2612 friend TrailingObjects;
2613
2614 /// true if extended version of the clause for 'depobj' directive.
2615 bool IsExtended = false;
2616
2617 /// Define the sizes of each trailing object array except the last one. This
2618 /// is required for TrailingObjects to work properly.
2619 size_t numTrailingObjects(OverloadToken<SourceLocation>) const {
2620 // 2 locations: for '(' and argument location.
2621 return IsExtended ? 2 : 0;
2622 }
2623
2624 /// Sets the location of '(' in clause for 'depobj' directive.
2625 void setLParenLoc(SourceLocation Loc) {
2626 assert(IsExtended && "Expected extended clause.");
2627 *getTrailingObjects<SourceLocation>() = Loc;
2628 }
2629
2630 /// Sets the location of '(' in clause for 'depobj' directive.
2631 void setArgumentLoc(SourceLocation Loc) {
2632 assert(IsExtended && "Expected extended clause.");
2633 *std::next(getTrailingObjects<SourceLocation>(), 1) = Loc;
2634 }
2635
2636 /// Sets the dependence kind for the clause for 'depobj' directive.
2637 void setDependencyKind(OpenMPDependClauseKind DK) {
2638 assert(IsExtended && "Expected extended clause.");
2639 *getTrailingObjects<OpenMPDependClauseKind>() = DK;
2640 }
2641
2642 /// Build 'update' clause.
2643 ///
2644 /// \param StartLoc Starting location of the clause.
2645 /// \param EndLoc Ending location of the clause.
2646 OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc,
2647 bool IsExtended)
2648 : OMPClause(llvm::omp::OMPC_update, StartLoc, EndLoc),
2649 IsExtended(IsExtended) {}
2650
2651 /// Build an empty clause.
2652 OMPUpdateClause(bool IsExtended)
2653 : OMPClause(llvm::omp::OMPC_update, SourceLocation(), SourceLocation()),
2654 IsExtended(IsExtended) {}
2655
2656public:
2657 /// Creates clause for 'atomic' directive.
2658 ///
2659 /// \param C AST context.
2660 /// \param StartLoc Starting location of the clause.
2661 /// \param EndLoc Ending location of the clause.
2662 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2663 SourceLocation EndLoc);
2664
2665 /// Creates clause for 'depobj' directive.
2666 ///
2667 /// \param C AST context.
2668 /// \param StartLoc Starting location of the clause.
2669 /// \param LParenLoc Location of '('.
2670 /// \param ArgumentLoc Location of the argument.
2671 /// \param DK Dependence kind.
2672 /// \param EndLoc Ending location of the clause.
2673 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2674 SourceLocation LParenLoc,
2675 SourceLocation ArgumentLoc,
2677 SourceLocation EndLoc);
2678
2679 /// Creates an empty clause with the place for \a N variables.
2680 ///
2681 /// \param C AST context.
2682 /// \param IsExtended true if extended clause for 'depobj' directive must be
2683 /// created.
2684 static OMPUpdateClause *CreateEmpty(const ASTContext &C, bool IsExtended);
2685
2686 /// Checks if the clause is the extended clauses for 'depobj' directive.
2687 bool isExtended() const { return IsExtended; }
2688
2692
2696
2703
2704 /// Gets the location of '(' in clause for 'depobj' directive.
2706 assert(IsExtended && "Expected extended clause.");
2707 return *getTrailingObjects<SourceLocation>();
2708 }
2709
2710 /// Gets the location of argument in clause for 'depobj' directive.
2712 assert(IsExtended && "Expected extended clause.");
2713 return *std::next(getTrailingObjects<SourceLocation>(), 1);
2714 }
2715
2716 /// Gets the dependence kind in clause for 'depobj' directive.
2718 assert(IsExtended && "Expected extended clause.");
2719 return *getTrailingObjects<OpenMPDependClauseKind>();
2720 }
2721
2722 static bool classof(const OMPClause *T) {
2723 return T->getClauseKind() == llvm::omp::OMPC_update;
2724 }
2725};
2726
2727/// This represents 'capture' clause in the '#pragma omp atomic'
2728/// directive.
2729///
2730/// \code
2731/// #pragma omp atomic capture
2732/// \endcode
2733/// In this example directive '#pragma omp atomic' has 'capture' clause.
2735public:
2736 /// Build 'capture' clause.
2737 ///
2738 /// \param StartLoc Starting location of the clause.
2739 /// \param EndLoc Ending location of the clause.
2741 : OMPClause(llvm::omp::OMPC_capture, StartLoc, EndLoc) {}
2742
2743 /// Build an empty clause.
2745 : OMPClause(llvm::omp::OMPC_capture, SourceLocation(), SourceLocation()) {
2746 }
2747
2751
2755
2762
2763 static bool classof(const OMPClause *T) {
2764 return T->getClauseKind() == llvm::omp::OMPC_capture;
2765 }
2766};
2767
2768/// This represents 'compare' clause in the '#pragma omp atomic'
2769/// directive.
2770///
2771/// \code
2772/// #pragma omp atomic compare
2773/// \endcode
2774/// In this example directive '#pragma omp atomic' has 'compare' clause.
2775class OMPCompareClause final : public OMPClause {
2776public:
2777 /// Build 'compare' clause.
2778 ///
2779 /// \param StartLoc Starting location of the clause.
2780 /// \param EndLoc Ending location of the clause.
2782 : OMPClause(llvm::omp::OMPC_compare, StartLoc, EndLoc) {}
2783
2784 /// Build an empty clause.
2786 : OMPClause(llvm::omp::OMPC_compare, SourceLocation(), SourceLocation()) {
2787 }
2788
2792
2796
2803
2804 static bool classof(const OMPClause *T) {
2805 return T->getClauseKind() == llvm::omp::OMPC_compare;
2806 }
2807};
2808
2809/// This represents 'seq_cst' clause in the '#pragma omp atomic|flush'
2810/// directives.
2811///
2812/// \code
2813/// #pragma omp atomic seq_cst
2814/// \endcode
2815/// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
2817public:
2818 /// Build 'seq_cst' clause.
2819 ///
2820 /// \param StartLoc Starting location of the clause.
2821 /// \param EndLoc Ending location of the clause.
2823 : OMPClause(llvm::omp::OMPC_seq_cst, StartLoc, EndLoc) {}
2824
2825 /// Build an empty clause.
2827 : OMPClause(llvm::omp::OMPC_seq_cst, SourceLocation(), SourceLocation()) {
2828 }
2829
2833
2837
2844
2845 static bool classof(const OMPClause *T) {
2846 return T->getClauseKind() == llvm::omp::OMPC_seq_cst;
2847 }
2848};
2849
2850/// This represents 'acq_rel' clause in the '#pragma omp atomic|flush'
2851/// directives.
2852///
2853/// \code
2854/// #pragma omp flush acq_rel
2855/// \endcode
2856/// In this example directive '#pragma omp flush' has 'acq_rel' clause.
2857class OMPAcqRelClause final : public OMPClause {
2858public:
2859 /// Build 'ack_rel' clause.
2860 ///
2861 /// \param StartLoc Starting location of the clause.
2862 /// \param EndLoc Ending location of the clause.
2864 : OMPClause(llvm::omp::OMPC_acq_rel, StartLoc, EndLoc) {}
2865
2866 /// Build an empty clause.
2868 : OMPClause(llvm::omp::OMPC_acq_rel, SourceLocation(), SourceLocation()) {
2869 }
2870
2874
2878
2885
2886 static bool classof(const OMPClause *T) {
2887 return T->getClauseKind() == llvm::omp::OMPC_acq_rel;
2888 }
2889};
2890
2891/// This represents 'acquire' clause in the '#pragma omp atomic|flush'
2892/// directives.
2893///
2894/// \code
2895/// #pragma omp flush acquire
2896/// \endcode
2897/// In this example directive '#pragma omp flush' has 'acquire' clause.
2898class OMPAcquireClause final : public OMPClause {
2899public:
2900 /// Build 'acquire' clause.
2901 ///
2902 /// \param StartLoc Starting location of the clause.
2903 /// \param EndLoc Ending location of the clause.
2905 : OMPClause(llvm::omp::OMPC_acquire, StartLoc, EndLoc) {}
2906
2907 /// Build an empty clause.
2909 : OMPClause(llvm::omp::OMPC_acquire, SourceLocation(), SourceLocation()) {
2910 }
2911
2915
2919
2926
2927 static bool classof(const OMPClause *T) {
2928 return T->getClauseKind() == llvm::omp::OMPC_acquire;
2929 }
2930};
2931
2932/// This represents 'release' clause in the '#pragma omp atomic|flush'
2933/// directives.
2934///
2935/// \code
2936/// #pragma omp flush release
2937/// \endcode
2938/// In this example directive '#pragma omp flush' has 'release' clause.
2939class OMPReleaseClause final : public OMPClause {
2940public:
2941 /// Build 'release' clause.
2942 ///
2943 /// \param StartLoc Starting location of the clause.
2944 /// \param EndLoc Ending location of the clause.
2946 : OMPClause(llvm::omp::OMPC_release, StartLoc, EndLoc) {}
2947
2948 /// Build an empty clause.
2950 : OMPClause(llvm::omp::OMPC_release, SourceLocation(), SourceLocation()) {
2951 }
2952
2956
2960
2967
2968 static bool classof(const OMPClause *T) {
2969 return T->getClauseKind() == llvm::omp::OMPC_release;
2970 }
2971};
2972
2973/// This represents 'relaxed' clause in the '#pragma omp atomic'
2974/// directives.
2975///
2976/// \code
2977/// #pragma omp atomic relaxed
2978/// \endcode
2979/// In this example directive '#pragma omp atomic' has 'relaxed' clause.
2980class OMPRelaxedClause final : public OMPClause {
2981public:
2982 /// Build 'relaxed' clause.
2983 ///
2984 /// \param StartLoc Starting location of the clause.
2985 /// \param EndLoc Ending location of the clause.
2987 : OMPClause(llvm::omp::OMPC_relaxed, StartLoc, EndLoc) {}
2988
2989 /// Build an empty clause.
2991 : OMPClause(llvm::omp::OMPC_relaxed, SourceLocation(), SourceLocation()) {
2992 }
2993
2997
3001
3008
3009 static bool classof(const OMPClause *T) {
3010 return T->getClauseKind() == llvm::omp::OMPC_relaxed;
3011 }
3012};
3013
3014/// This represents 'weak' clause in the '#pragma omp atomic'
3015/// directives.
3016///
3017/// \code
3018/// #pragma omp atomic compare weak
3019/// \endcode
3020/// In this example directive '#pragma omp atomic' has 'weak' clause.
3021class OMPWeakClause final : public OMPClause {
3022public:
3023 /// Build 'weak' clause.
3024 ///
3025 /// \param StartLoc Starting location of the clause.
3026 /// \param EndLoc Ending location of the clause.
3028 : OMPClause(llvm::omp::OMPC_weak, StartLoc, EndLoc) {}
3029
3030 /// Build an empty clause.
3032 : OMPClause(llvm::omp::OMPC_weak, SourceLocation(), SourceLocation()) {}
3033
3037
3041
3048
3049 static bool classof(const OMPClause *T) {
3050 return T->getClauseKind() == llvm::omp::OMPC_weak;
3051 }
3052};
3053
3054/// This represents 'fail' clause in the '#pragma omp atomic'
3055/// directive.
3056///
3057/// \code
3058/// #pragma omp atomic compare fail
3059/// \endcode
3060/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
3061class OMPFailClause final : public OMPClause {
3062
3063 // FailParameter is a memory-order-clause. Storing the ClauseKind is
3064 // sufficient for our purpose.
3065 OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
3066 SourceLocation FailParameterLoc;
3067 SourceLocation LParenLoc;
3068
3069 friend class OMPClauseReader;
3070
3071 /// Sets the location of '(' in fail clause.
3072 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3073
3074 /// Sets the location of memoryOrder clause argument in fail clause.
3075 void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
3076
3077 /// Sets the mem_order clause for 'atomic compare fail' directive.
3078 void setFailParameter(OpenMPClauseKind FailParameter) {
3079 this->FailParameter = FailParameter;
3080 assert(checkFailClauseParameter(FailParameter) &&
3081 "Invalid fail clause parameter");
3082 }
3083
3084public:
3085 /// Build 'fail' clause.
3086 ///
3087 /// \param StartLoc Starting location of the clause.
3088 /// \param EndLoc Ending location of the clause.
3090 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
3091
3092 OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation FailParameterLoc,
3093 SourceLocation StartLoc, SourceLocation LParenLoc,
3094 SourceLocation EndLoc)
3095 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
3096 FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
3097
3098 setFailParameter(FailParameter);
3099 }
3100
3101 /// Build an empty clause.
3103 : OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
3104
3108
3112
3119
3120 static bool classof(const OMPClause *T) {
3121 return T->getClauseKind() == llvm::omp::OMPC_fail;
3122 }
3123
3124 /// Gets the location of '(' (for the parameter) in fail clause.
3126 return LParenLoc;
3127 }
3128
3129 /// Gets the location of Fail Parameter (type memory-order-clause) in
3130 /// fail clause.
3131 SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
3132
3133 /// Gets the parameter (type memory-order-clause) in Fail clause.
3134 OpenMPClauseKind getFailParameter() const { return FailParameter; }
3135};
3136
3137/// This represents clause 'private' in the '#pragma omp ...' directives.
3138///
3139/// \code
3140/// #pragma omp parallel private(a,b)
3141/// \endcode
3142/// In this example directive '#pragma omp parallel' has clause 'private'
3143/// with the variables 'a' and 'b'.
3144class OMPPrivateClause final
3145 : public OMPVarListClause<OMPPrivateClause>,
3146 private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
3147 friend class OMPClauseReader;
3148 friend OMPVarListClause;
3149 friend TrailingObjects;
3150
3151 /// Build clause with number of variables \a N.
3152 ///
3153 /// \param StartLoc Starting location of the clause.
3154 /// \param LParenLoc Location of '('.
3155 /// \param EndLoc Ending location of the clause.
3156 /// \param N Number of the variables in the clause.
3157 OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3158 SourceLocation EndLoc, unsigned N)
3159 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private, StartLoc,
3160 LParenLoc, EndLoc, N) {}
3161
3162 /// Build an empty clause.
3163 ///
3164 /// \param N Number of variables.
3165 explicit OMPPrivateClause(unsigned N)
3166 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private,
3168 SourceLocation(), N) {}
3169
3170 /// Sets the list of references to private copies with initializers for
3171 /// new private variables.
3172 /// \param VL List of references.
3173 void setPrivateCopies(ArrayRef<Expr *> VL);
3174
3175 /// Gets the list of references to private copies with initializers for
3176 /// new private variables.
3177 MutableArrayRef<Expr *> getPrivateCopies() {
3178 return {varlist_end(), varlist_size()};
3179 }
3180 ArrayRef<const Expr *> getPrivateCopies() const {
3181 return {varlist_end(), varlist_size()};
3182 }
3183
3184public:
3185 /// Creates clause with a list of variables \a VL.
3186 ///
3187 /// \param C AST context.
3188 /// \param StartLoc Starting location of the clause.
3189 /// \param LParenLoc Location of '('.
3190 /// \param EndLoc Ending location of the clause.
3191 /// \param VL List of references to the variables.
3192 /// \param PrivateVL List of references to private copies with initializers.
3193 static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
3194 SourceLocation LParenLoc,
3195 SourceLocation EndLoc, ArrayRef<Expr *> VL,
3196 ArrayRef<Expr *> PrivateVL);
3197
3198 /// Creates an empty clause with the place for \a N variables.
3199 ///
3200 /// \param C AST context.
3201 /// \param N The number of variables.
3202 static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3203
3206 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
3208 llvm::iterator_range<private_copies_const_iterator>;
3209
3211 return private_copies_range(getPrivateCopies().begin(),
3212 getPrivateCopies().end());
3213 }
3214
3216 return private_copies_const_range(getPrivateCopies().begin(),
3217 getPrivateCopies().end());
3218 }
3219
3221 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3222 reinterpret_cast<Stmt **>(varlist_end()));
3223 }
3224
3226 auto Children = const_cast<OMPPrivateClause *>(this)->children();
3227 return const_child_range(Children.begin(), Children.end());
3228 }
3229
3236
3237 static bool classof(const OMPClause *T) {
3238 return T->getClauseKind() == llvm::omp::OMPC_private;
3239 }
3240};
3241
3242/// This represents clause 'firstprivate' in the '#pragma omp ...'
3243/// directives.
3244///
3245/// \code
3246/// #pragma omp parallel firstprivate(a,b)
3247/// \endcode
3248/// In this example directive '#pragma omp parallel' has clause 'firstprivate'
3249/// with the variables 'a' and 'b'.
3250class OMPFirstprivateClause final
3251 : public OMPVarListClause<OMPFirstprivateClause>,
3252 public OMPClauseWithPreInit,
3253 private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
3254 friend class OMPClauseReader;
3255 friend OMPVarListClause;
3256 friend TrailingObjects;
3257
3258 /// Build clause with number of variables \a N.
3259 ///
3260 /// \param StartLoc Starting location of the clause.
3261 /// \param LParenLoc Location of '('.
3262 /// \param EndLoc Ending location of the clause.
3263 /// \param N Number of the variables in the clause.
3264 OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3265 SourceLocation EndLoc, unsigned N)
3266 : OMPVarListClause<OMPFirstprivateClause>(llvm::omp::OMPC_firstprivate,
3267 StartLoc, LParenLoc, EndLoc, N),
3268 OMPClauseWithPreInit(this) {}
3269
3270 /// Build an empty clause.
3271 ///
3272 /// \param N Number of variables.
3273 explicit OMPFirstprivateClause(unsigned N)
3275 llvm::omp::OMPC_firstprivate, SourceLocation(), SourceLocation(),
3276 SourceLocation(), N),
3277 OMPClauseWithPreInit(this) {}
3278
3279 /// Sets the list of references to private copies with initializers for
3280 /// new private variables.
3281 /// \param VL List of references.
3282 void setPrivateCopies(ArrayRef<Expr *> VL);
3283
3284 /// Gets the list of references to private copies with initializers for
3285 /// new private variables.
3286 MutableArrayRef<Expr *> getPrivateCopies() {
3287 return {varlist_end(), varlist_size()};
3288 }
3289 ArrayRef<const Expr *> getPrivateCopies() const {
3290 return {varlist_end(), varlist_size()};
3291 }
3292
3293 /// Sets the list of references to initializer variables for new
3294 /// private variables.
3295 /// \param VL List of references.
3296 void setInits(ArrayRef<Expr *> VL);
3297
3298 /// Gets the list of references to initializer variables for new
3299 /// private variables.
3300 MutableArrayRef<Expr *> getInits() {
3301 return {getPrivateCopies().end(), varlist_size()};
3302 }
3303 ArrayRef<const Expr *> getInits() const {
3304 return {getPrivateCopies().end(), varlist_size()};
3305 }
3306
3307public:
3308 /// Creates clause with a list of variables \a VL.
3309 ///
3310 /// \param C AST context.
3311 /// \param StartLoc Starting location of the clause.
3312 /// \param LParenLoc Location of '('.
3313 /// \param EndLoc Ending location of the clause.
3314 /// \param VL List of references to the original variables.
3315 /// \param PrivateVL List of references to private copies with initializers.
3316 /// \param InitVL List of references to auto generated variables used for
3317 /// initialization of a single array element. Used if firstprivate variable is
3318 /// of array type.
3319 /// \param PreInit Statement that must be executed before entering the OpenMP
3320 /// region with this clause.
3321 static OMPFirstprivateClause *
3322 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3323 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
3324 ArrayRef<Expr *> InitVL, Stmt *PreInit);
3325
3326 /// Creates an empty clause with the place for \a N variables.
3327 ///
3328 /// \param C AST context.
3329 /// \param N The number of variables.
3330 static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3331
3334 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
3336 llvm::iterator_range<private_copies_const_iterator>;
3337
3339 return private_copies_range(getPrivateCopies().begin(),
3340 getPrivateCopies().end());
3341 }
3343 return private_copies_const_range(getPrivateCopies().begin(),
3344 getPrivateCopies().end());
3345 }
3346
3349 using inits_range = llvm::iterator_range<inits_iterator>;
3350 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
3351
3353 return inits_range(getInits().begin(), getInits().end());
3354 }
3356 return inits_const_range(getInits().begin(), getInits().end());
3357 }
3358
3360 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3361 reinterpret_cast<Stmt **>(varlist_end()));
3362 }
3363
3365 auto Children = const_cast<OMPFirstprivateClause *>(this)->children();
3366 return const_child_range(Children.begin(), Children.end());
3367 }
3368
3370 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3371 reinterpret_cast<Stmt **>(varlist_end()));
3372 }
3374 auto Children = const_cast<OMPFirstprivateClause *>(this)->used_children();
3375 return const_child_range(Children.begin(), Children.end());
3376 }
3377
3378 static bool classof(const OMPClause *T) {
3379 return T->getClauseKind() == llvm::omp::OMPC_firstprivate;
3380 }
3381};
3382
3383/// This represents clause 'lastprivate' in the '#pragma omp ...'
3384/// directives.
3385///
3386/// \code
3387/// #pragma omp simd lastprivate(a,b)
3388/// \endcode
3389/// In this example directive '#pragma omp simd' has clause 'lastprivate'
3390/// with the variables 'a' and 'b'.
3391class OMPLastprivateClause final
3392 : public OMPVarListClause<OMPLastprivateClause>,
3394 private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
3395 // There are 4 additional tail-allocated arrays at the end of the class:
3396 // 1. Contains list of pseudo variables with the default initialization for
3397 // each non-firstprivate variables. Used in codegen for initialization of
3398 // lastprivate copies.
3399 // 2. List of helper expressions for proper generation of assignment operation
3400 // required for lastprivate clause. This list represents private variables
3401 // (for arrays, single array element).
3402 // 3. List of helper expressions for proper generation of assignment operation
3403 // required for lastprivate clause. This list represents original variables
3404 // (for arrays, single array element).
3405 // 4. List of helper expressions that represents assignment operation:
3406 // \code
3407 // DstExprs = SrcExprs;
3408 // \endcode
3409 // Required for proper codegen of final assignment performed by the
3410 // lastprivate clause.
3411 friend class OMPClauseReader;
3412 friend OMPVarListClause;
3413 friend TrailingObjects;
3414
3415 /// Optional lastprivate kind, e.g. 'conditional', if specified by user.
3417 /// Optional location of the lasptrivate kind, if specified by user.
3418 SourceLocation LPKindLoc;
3419 /// Optional colon location, if specified by user.
3420 SourceLocation ColonLoc;
3421
3422 /// Build clause with number of variables \a N.
3423 ///
3424 /// \param StartLoc Starting location of the clause.
3425 /// \param LParenLoc Location of '('.
3426 /// \param EndLoc Ending location of the clause.
3427 /// \param N Number of the variables in the clause.
3428 OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3430 SourceLocation LPKindLoc, SourceLocation ColonLoc,
3431 unsigned N)
3432 : OMPVarListClause<OMPLastprivateClause>(llvm::omp::OMPC_lastprivate,
3433 StartLoc, LParenLoc, EndLoc, N),
3434 OMPClauseWithPostUpdate(this), LPKind(LPKind), LPKindLoc(LPKindLoc),
3435 ColonLoc(ColonLoc) {}
3436
3437 /// Build an empty clause.
3438 ///
3439 /// \param N Number of variables.
3440 explicit OMPLastprivateClause(unsigned N)
3442 llvm::omp::OMPC_lastprivate, SourceLocation(), SourceLocation(),
3443 SourceLocation(), N),
3445
3446 /// Get the list of helper expressions for initialization of private
3447 /// copies for lastprivate variables.
3448 MutableArrayRef<Expr *> getPrivateCopies() {
3449 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3450 }
3451 ArrayRef<const Expr *> getPrivateCopies() const {
3452 return {varlist_end(), varlist_size()};
3453 }
3454
3455 /// Set list of helper expressions, required for proper codegen of the
3456 /// clause. These expressions represent private variables (for arrays, single
3457 /// array element) in the final assignment statement performed by the
3458 /// lastprivate clause.
3459 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
3460
3461 /// Get the list of helper source expressions.
3462 MutableArrayRef<Expr *> getSourceExprs() {
3463 return {getPrivateCopies().end(), varlist_size()};
3464 }
3465 ArrayRef<const Expr *> getSourceExprs() const {
3466 return {getPrivateCopies().end(), varlist_size()};
3467 }
3468
3469 /// Set list of helper expressions, required for proper codegen of the
3470 /// clause. These expressions represent original variables (for arrays, single
3471 /// array element) in the final assignment statement performed by the
3472 /// lastprivate clause.
3473 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
3474
3475 /// Get the list of helper destination expressions.
3476 MutableArrayRef<Expr *> getDestinationExprs() {
3477 return {getSourceExprs().end(), varlist_size()};
3478 }
3479 ArrayRef<const Expr *> getDestinationExprs() const {
3480 return {getSourceExprs().end(), varlist_size()};
3481 }
3482
3483 /// Set list of helper assignment expressions, required for proper
3484 /// codegen of the clause. These expressions are assignment expressions that
3485 /// assign private copy of the variable to original variable.
3486 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
3487
3488 /// Get the list of helper assignment expressions.
3489 MutableArrayRef<Expr *> getAssignmentOps() {
3490 return {getDestinationExprs().end(), varlist_size()};
3491 }
3492 ArrayRef<const Expr *> getAssignmentOps() const {
3493 return {getDestinationExprs().end(), varlist_size()};
3494 }
3495
3496 /// Sets lastprivate kind.
3497 void setKind(OpenMPLastprivateModifier Kind) { LPKind = Kind; }
3498 /// Sets location of the lastprivate kind.
3499 void setKindLoc(SourceLocation Loc) { LPKindLoc = Loc; }
3500 /// Sets colon symbol location.
3501 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3502
3503public:
3504 /// Creates clause with a list of variables \a VL.
3505 ///
3506 /// \param C AST context.
3507 /// \param StartLoc Starting location of the clause.
3508 /// \param LParenLoc Location of '('.
3509 /// \param EndLoc Ending location of the clause.
3510 /// \param VL List of references to the variables.
3511 /// \param SrcExprs List of helper expressions for proper generation of
3512 /// assignment operation required for lastprivate clause. This list represents
3513 /// private variables (for arrays, single array element).
3514 /// \param DstExprs List of helper expressions for proper generation of
3515 /// assignment operation required for lastprivate clause. This list represents
3516 /// original variables (for arrays, single array element).
3517 /// \param AssignmentOps List of helper expressions that represents assignment
3518 /// operation:
3519 /// \code
3520 /// DstExprs = SrcExprs;
3521 /// \endcode
3522 /// Required for proper codegen of final assignment performed by the
3523 /// lastprivate clause.
3524 /// \param LPKind Lastprivate kind, e.g. 'conditional'.
3525 /// \param LPKindLoc Location of the lastprivate kind.
3526 /// \param ColonLoc Location of the ':' symbol if lastprivate kind is used.
3527 /// \param PreInit Statement that must be executed before entering the OpenMP
3528 /// region with this clause.
3529 /// \param PostUpdate Expression that must be executed after exit from the
3530 /// OpenMP region with this clause.
3531 static OMPLastprivateClause *
3532 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3533 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
3534 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
3535 OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
3536 SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate);
3537
3538 /// Creates an empty clause with the place for \a N variables.
3539 ///
3540 /// \param C AST context.
3541 /// \param N The number of variables.
3542 static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3543
3544 /// Lastprivate kind.
3545 OpenMPLastprivateModifier getKind() const { return LPKind; }
3546 /// Returns the location of the lastprivate kind.
3547 SourceLocation getKindLoc() const { return LPKindLoc; }
3548 /// Returns the location of the ':' symbol, if any.
3549 SourceLocation getColonLoc() const { return ColonLoc; }
3550
3553 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3555 llvm::iterator_range<helper_expr_const_iterator>;
3556
3557 /// Set list of helper expressions, required for generation of private
3558 /// copies of original lastprivate variables.
3559 void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
3560
3562 return helper_expr_const_range(getPrivateCopies().begin(),
3563 getPrivateCopies().end());
3564 }
3565
3567 return helper_expr_range(getPrivateCopies().begin(),
3568 getPrivateCopies().end());
3569 }
3570
3572 return helper_expr_const_range(getSourceExprs().begin(),
3573 getSourceExprs().end());
3574 }
3575
3577 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
3578 }
3579
3581 return helper_expr_const_range(getDestinationExprs().begin(),
3582 getDestinationExprs().end());
3583 }
3584
3586 return helper_expr_range(getDestinationExprs().begin(),
3587 getDestinationExprs().end());
3588 }
3589
3591 return helper_expr_const_range(getAssignmentOps().begin(),
3592 getAssignmentOps().end());
3593 }
3594
3596 return helper_expr_range(getAssignmentOps().begin(),
3597 getAssignmentOps().end());
3598 }
3599
3601 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3602 reinterpret_cast<Stmt **>(varlist_end()));
3603 }
3604
3606 auto Children = const_cast<OMPLastprivateClause *>(this)->children();
3607 return const_child_range(Children.begin(), Children.end());
3608 }
3609
3616
3617 static bool classof(const OMPClause *T) {
3618 return T->getClauseKind() == llvm::omp::OMPC_lastprivate;
3619 }
3620};
3621
3622/// This represents clause 'shared' in the '#pragma omp ...' directives.
3623///
3624/// \code
3625/// #pragma omp parallel shared(a,b)
3626/// \endcode
3627/// In this example directive '#pragma omp parallel' has clause 'shared'
3628/// with the variables 'a' and 'b'.
3629class OMPSharedClause final
3630 : public OMPVarListClause<OMPSharedClause>,
3631 private llvm::TrailingObjects<OMPSharedClause, Expr *> {
3632 friend OMPVarListClause;
3633 friend TrailingObjects;
3634
3635 /// Build clause with number of variables \a N.
3636 ///
3637 /// \param StartLoc Starting location of the clause.
3638 /// \param LParenLoc Location of '('.
3639 /// \param EndLoc Ending location of the clause.
3640 /// \param N Number of the variables in the clause.
3641 OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3642 SourceLocation EndLoc, unsigned N)
3643 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared, StartLoc,
3644 LParenLoc, EndLoc, N) {}
3645
3646 /// Build an empty clause.
3647 ///
3648 /// \param N Number of variables.
3649 explicit OMPSharedClause(unsigned N)
3650 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared,
3652 SourceLocation(), N) {}
3653
3654public:
3655 /// Creates clause with a list of variables \a VL.
3656 ///
3657 /// \param C AST context.
3658 /// \param StartLoc Starting location of the clause.
3659 /// \param LParenLoc Location of '('.
3660 /// \param EndLoc Ending location of the clause.
3661 /// \param VL List of references to the variables.
3662 static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
3663 SourceLocation LParenLoc,
3664 SourceLocation EndLoc, ArrayRef<Expr *> VL);
3665
3666 /// Creates an empty clause with \a N variables.
3667 ///
3668 /// \param C AST context.
3669 /// \param N The number of variables.
3670 static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
3671
3673 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3674 reinterpret_cast<Stmt **>(varlist_end()));
3675 }
3676
3678 auto Children = const_cast<OMPSharedClause *>(this)->children();
3679 return const_child_range(Children.begin(), Children.end());
3680 }
3681
3688
3689 static bool classof(const OMPClause *T) {
3690 return T->getClauseKind() == llvm::omp::OMPC_shared;
3691 }
3692};
3693
3694/// This represents clause 'reduction' in the '#pragma omp ...'
3695/// directives.
3696///
3697/// \code
3698/// #pragma omp parallel reduction(+:a,b)
3699/// \endcode
3700/// In this example directive '#pragma omp parallel' has clause 'reduction'
3701/// with operator '+' and the variables 'a' and 'b'.
3702class OMPReductionClause final
3703 : public OMPVarListClause<OMPReductionClause>,
3705 private llvm::TrailingObjects<OMPReductionClause, Expr *, bool> {
3706 friend class OMPClauseReader;
3707 friend OMPVarListClause;
3708 friend TrailingObjects;
3709
3710 /// Reduction modifier.
3712
3713 /// Original Sharing modifier.
3714 OpenMPOriginalSharingModifier OriginalSharingModifier =
3715 OMPC_ORIGINAL_SHARING_default;
3716
3717 /// Reduction modifier location.
3718 SourceLocation ModifierLoc;
3719
3720 /// Location of ':'.
3721 SourceLocation ColonLoc;
3722
3723 /// Nested name specifier for C++.
3724 NestedNameSpecifierLoc QualifierLoc;
3725
3726 /// Name of custom operator.
3727 DeclarationNameInfo NameInfo;
3728
3729 /// Build clause with number of variables \a N.
3730 ///
3731 /// \param StartLoc Starting location of the clause.
3732 /// \param LParenLoc Location of '('.
3733 /// \param ModifierLoc Modifier location.
3734 /// \param ColonLoc Location of ':'.
3735 /// \param EndLoc Ending location of the clause.
3736 /// \param N Number of the variables in the clause.
3737 /// \param QualifierLoc The nested-name qualifier with location information
3738 /// \param NameInfo The full name info for reduction identifier.
3739 OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3740 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3741 SourceLocation EndLoc,
3743 OpenMPOriginalSharingModifier OriginalSharingModifier,
3744 unsigned N, NestedNameSpecifierLoc QualifierLoc,
3745 const DeclarationNameInfo &NameInfo)
3746 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3747 StartLoc, LParenLoc, EndLoc, N),
3748 OMPClauseWithPostUpdate(this), Modifier(Modifier),
3749 OriginalSharingModifier(OriginalSharingModifier),
3750 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
3751 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3752
3753 /// Build an empty clause.
3754 ///
3755 /// \param N Number of variables.
3756 explicit OMPReductionClause(unsigned N)
3757 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3759 SourceLocation(), N),
3761
3762 /// Sets reduction modifier.
3763 void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; }
3764
3765 /// Sets Original Sharing modifier.
3766 void setOriginalSharingModifier(OpenMPOriginalSharingModifier M) {
3767 OriginalSharingModifier = M;
3768 }
3769
3770 /// Sets location of the modifier.
3771 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
3772
3773 /// Sets location of ':' symbol in clause.
3774 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3775
3776 /// Sets the name info for specified reduction identifier.
3777 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3778
3779 /// Sets the nested name specifier.
3780 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3781
3782 /// Set list of helper expressions, required for proper codegen of the
3783 /// clause. These expressions represent private copy of the reduction
3784 /// variable.
3785 void setPrivates(ArrayRef<Expr *> Privates);
3786
3787 /// Get the list of helper privates.
3788 MutableArrayRef<Expr *> getPrivates() {
3789 return {varlist_end(), varlist_size()};
3790 }
3791 ArrayRef<const Expr *> getPrivates() const {
3792 return {varlist_end(), varlist_size()};
3793 }
3794
3795 /// Set list of helper expressions, required for proper codegen of the
3796 /// clause. These expressions represent LHS expression in the final
3797 /// reduction expression performed by the reduction clause.
3798 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3799
3800 /// Get the list of helper LHS expressions.
3801 MutableArrayRef<Expr *> getLHSExprs() {
3802 return {getPrivates().end(), varlist_size()};
3803 }
3804 ArrayRef<const Expr *> getLHSExprs() const {
3805 return {getPrivates().end(), varlist_size()};
3806 }
3807
3808 /// Set list of helper expressions, required for proper codegen of the
3809 /// clause. These expressions represent RHS expression in the final
3810 /// reduction expression performed by the reduction clause.
3811 /// Also, variables in these expressions are used for proper initialization of
3812 /// reduction copies.
3813 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3814
3815 /// Set the list private reduction flags
3816 void setPrivateVariableReductionFlags(ArrayRef<bool> Flags) {
3817 assert(Flags.size() == varlist_size() &&
3818 "Number of private flags does not match vars");
3819 llvm::copy(Flags, getTrailingObjects<bool>());
3820 }
3821
3822 /// Get the list of help private variable reduction flags
3823 MutableArrayRef<bool> getPrivateVariableReductionFlags() {
3824 return getTrailingObjects<bool>(varlist_size());
3825 }
3826 ArrayRef<bool> getPrivateVariableReductionFlags() const {
3827 return getTrailingObjects<bool>(varlist_size());
3828 }
3829
3830 /// Returns the number of Expr* objects in trailing storage
3831 size_t numTrailingObjects(OverloadToken<Expr *>) const {
3832 return varlist_size() * (Modifier == OMPC_REDUCTION_inscan ? 8 : 5);
3833 }
3834
3835 /// Returns the number of bool flags in trailing storage
3836 size_t numTrailingObjects(OverloadToken<bool>) const {
3837 return varlist_size();
3838 }
3839
3840 /// Get the list of helper destination expressions.
3841 MutableArrayRef<Expr *> getRHSExprs() {
3842 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3843 }
3844 ArrayRef<const Expr *> getRHSExprs() const {
3845 return {getLHSExprs().end(), varlist_size()};
3846 }
3847
3848 /// Set list of helper reduction expressions, required for proper
3849 /// codegen of the clause. These expressions are binary expressions or
3850 /// operator/custom reduction call that calculates new value from source
3851 /// helper expressions to destination helper expressions.
3852 void setReductionOps(ArrayRef<Expr *> ReductionOps);
3853
3854 /// Get the list of helper reduction expressions.
3855 MutableArrayRef<Expr *> getReductionOps() {
3856 return {getRHSExprs().end(), varlist_size()};
3857 }
3858 ArrayRef<const Expr *> getReductionOps() const {
3859 return {getRHSExprs().end(), varlist_size()};
3860 }
3861
3862 /// Set list of helper copy operations for inscan reductions.
3863 /// The form is: Temps[i] = LHS[i];
3864 void setInscanCopyOps(ArrayRef<Expr *> Ops);
3865
3866 /// Get the list of helper inscan copy operations.
3867 MutableArrayRef<Expr *> getInscanCopyOps() {
3868 return {getReductionOps().end(), varlist_size()};
3869 }
3870 ArrayRef<const Expr *> getInscanCopyOps() const {
3871 return {getReductionOps().end(), varlist_size()};
3872 }
3873
3874 /// Set list of helper temp vars for inscan copy array operations.
3875 void setInscanCopyArrayTemps(ArrayRef<Expr *> CopyArrayTemps);
3876
3877 /// Get the list of helper inscan copy temps.
3878 MutableArrayRef<Expr *> getInscanCopyArrayTemps() {
3879 return {getInscanCopyOps().end(), varlist_size()};
3880 }
3881 ArrayRef<const Expr *> getInscanCopyArrayTemps() const {
3882 return {getInscanCopyOps().end(), varlist_size()};
3883 }
3884
3885 /// Set list of helper temp elements vars for inscan copy array operations.
3886 void setInscanCopyArrayElems(ArrayRef<Expr *> CopyArrayElems);
3887
3888 /// Get the list of helper inscan copy temps.
3889 MutableArrayRef<Expr *> getInscanCopyArrayElems() {
3890 return {getInscanCopyArrayTemps().end(), varlist_size()};
3891 }
3892 ArrayRef<const Expr *> getInscanCopyArrayElems() const {
3893 return {getInscanCopyArrayTemps().end(), varlist_size()};
3894 }
3895
3896public:
3897 /// Creates clause with a list of variables \a VL.
3898 ///
3899 /// \param StartLoc Starting location of the clause.
3900 /// \param LParenLoc Location of '('.
3901 /// \param ModifierLoc Modifier location.
3902 /// \param ColonLoc Location of ':'.
3903 /// \param EndLoc Ending location of the clause.
3904 /// \param VL The variables in the clause.
3905 /// \param QualifierLoc The nested-name qualifier with location information
3906 /// \param NameInfo The full name info for reduction identifier.
3907 /// \param Privates List of helper expressions for proper generation of
3908 /// private copies.
3909 /// \param LHSExprs List of helper expressions for proper generation of
3910 /// assignment operation required for copyprivate clause. This list represents
3911 /// LHSs of the reduction expressions.
3912 /// \param RHSExprs List of helper expressions for proper generation of
3913 /// assignment operation required for copyprivate clause. This list represents
3914 /// RHSs of the reduction expressions.
3915 /// Also, variables in these expressions are used for proper initialization of
3916 /// reduction copies.
3917 /// \param ReductionOps List of helper expressions that represents reduction
3918 /// expressions:
3919 /// \code
3920 /// LHSExprs binop RHSExprs;
3921 /// operator binop(LHSExpr, RHSExpr);
3922 /// <CutomReduction>(LHSExpr, RHSExpr);
3923 /// \endcode
3924 /// Required for proper codegen of final reduction operation performed by the
3925 /// reduction clause.
3926 /// \param CopyOps List of copy operations for inscan reductions:
3927 /// \code
3928 /// TempExprs = LHSExprs;
3929 /// \endcode
3930 /// \param CopyArrayTemps Temp arrays for prefix sums.
3931 /// \param CopyArrayElems Temp arrays for prefix sums.
3932 /// \param PreInit Statement that must be executed before entering the OpenMP
3933 /// region with this clause.
3934 /// \param PostUpdate Expression that must be executed after exit from the
3935 /// OpenMP region with this clause.
3936 /// \param IsPrivateVarReduction array for private variable reduction flags
3937 static OMPReductionClause *
3938 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3939 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3940 SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier,
3941 ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc,
3942 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
3943 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
3944 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps,
3945 ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems,
3946 Stmt *PreInit, Expr *PostUpdate, ArrayRef<bool> IsPrivateVarReduction,
3947 OpenMPOriginalSharingModifier OriginalSharingModifier);
3948
3949 /// Creates an empty clause with the place for \a N variables.
3950 ///
3951 /// \param C AST context.
3952 /// \param N The number of variables.
3953 /// \param Modifier Reduction modifier.
3954 static OMPReductionClause *
3955 CreateEmpty(const ASTContext &C, unsigned N,
3957
3958 /// Returns modifier.
3959 OpenMPReductionClauseModifier getModifier() const { return Modifier; }
3960
3961 /// Returns Original Sharing Modifier.
3963 return OriginalSharingModifier;
3964 }
3965
3966 /// Returns modifier location.
3967 SourceLocation getModifierLoc() const { return ModifierLoc; }
3968
3969 /// Gets location of ':' symbol in clause.
3970 SourceLocation getColonLoc() const { return ColonLoc; }
3971
3972 /// Gets the name info for specified reduction identifier.
3973 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3974
3975 /// Gets the nested name specifier.
3976 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3977
3980 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3982 llvm::iterator_range<helper_expr_const_iterator>;
3985 using helper_flag_range = llvm::iterator_range<helper_flag_iterator>;
3987 llvm::iterator_range<helper_flag_const_iterator>;
3988
3990 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
3991 }
3992
3994 return helper_expr_range(getPrivates().begin(), getPrivates().end());
3995 }
3996
3998 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
3999 }
4000
4002 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
4003 }
4004
4006 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
4007 }
4008
4010 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
4011 }
4012
4014 return helper_flag_const_range(getPrivateVariableReductionFlags().begin(),
4015 getPrivateVariableReductionFlags().end());
4016 }
4017
4019 return helper_flag_range(getPrivateVariableReductionFlags().begin(),
4020 getPrivateVariableReductionFlags().end());
4021 }
4022
4024 return helper_expr_const_range(getReductionOps().begin(),
4025 getReductionOps().end());
4026 }
4027
4029 return helper_expr_range(getReductionOps().begin(),
4030 getReductionOps().end());
4031 }
4032
4034 return helper_expr_const_range(getInscanCopyOps().begin(),
4035 getInscanCopyOps().end());
4036 }
4037
4039 return helper_expr_range(getInscanCopyOps().begin(),
4040 getInscanCopyOps().end());
4041 }
4042
4044 return helper_expr_const_range(getInscanCopyArrayTemps().begin(),
4045 getInscanCopyArrayTemps().end());
4046 }
4047
4049 return helper_expr_range(getInscanCopyArrayTemps().begin(),
4050 getInscanCopyArrayTemps().end());
4051 }
4052
4054 return helper_expr_const_range(getInscanCopyArrayElems().begin(),
4055 getInscanCopyArrayElems().end());
4056 }
4057
4059 return helper_expr_range(getInscanCopyArrayElems().begin(),
4060 getInscanCopyArrayElems().end());
4061 }
4062
4064 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4065 reinterpret_cast<Stmt **>(varlist_end()));
4066 }
4067
4069 auto Children = const_cast<OMPReductionClause *>(this)->children();
4070 return const_child_range(Children.begin(), Children.end());
4071 }
4072
4074 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4075 reinterpret_cast<Stmt **>(varlist_end()));
4076 }
4078 auto Children = const_cast<OMPReductionClause *>(this)->used_children();
4079 return const_child_range(Children.begin(), Children.end());
4080 }
4081
4082 static bool classof(const OMPClause *T) {
4083 return T->getClauseKind() == llvm::omp::OMPC_reduction;
4084 }
4085};
4086
4087/// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
4088/// directives.
4089///
4090/// \code
4091/// #pragma omp taskgroup task_reduction(+:a,b)
4092/// \endcode
4093/// In this example directive '#pragma omp taskgroup' has clause
4094/// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
4095class OMPTaskReductionClause final
4096 : public OMPVarListClause<OMPTaskReductionClause>,
4098 private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> {
4099 friend class OMPClauseReader;
4100 friend OMPVarListClause;
4101 friend TrailingObjects;
4102
4103 /// Location of ':'.
4104 SourceLocation ColonLoc;
4105
4106 /// Nested name specifier for C++.
4107 NestedNameSpecifierLoc QualifierLoc;
4108
4109 /// Name of custom operator.
4110 DeclarationNameInfo NameInfo;
4111
4112 /// Build clause with number of variables \a N.
4113 ///
4114 /// \param StartLoc Starting location of the clause.
4115 /// \param LParenLoc Location of '('.
4116 /// \param EndLoc Ending location of the clause.
4117 /// \param ColonLoc Location of ':'.
4118 /// \param N Number of the variables in the clause.
4119 /// \param QualifierLoc The nested-name qualifier with location information
4120 /// \param NameInfo The full name info for reduction identifier.
4121 OMPTaskReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4122 SourceLocation ColonLoc, SourceLocation EndLoc,
4123 unsigned N, NestedNameSpecifierLoc QualifierLoc,
4124 const DeclarationNameInfo &NameInfo)
4125 : OMPVarListClause<OMPTaskReductionClause>(
4126 llvm::omp::OMPC_task_reduction, StartLoc, LParenLoc, EndLoc, N),
4127 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
4128 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
4129
4130 /// Build an empty clause.
4131 ///
4132 /// \param N Number of variables.
4133 explicit OMPTaskReductionClause(unsigned N)
4135 llvm::omp::OMPC_task_reduction, SourceLocation(), SourceLocation(),
4136 SourceLocation(), N),
4138
4139 /// Sets location of ':' symbol in clause.
4140 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
4141
4142 /// Sets the name info for specified reduction identifier.
4143 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
4144
4145 /// Sets the nested name specifier.
4146 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
4147
4148 /// Set list of helper expressions, required for proper codegen of the clause.
4149 /// These expressions represent private copy of the reduction variable.
4150 void setPrivates(ArrayRef<Expr *> Privates);
4151
4152 /// Get the list of helper privates.
4153 MutableArrayRef<Expr *> getPrivates() {
4154 return {varlist_end(), varlist_size()};
4155 }
4156 ArrayRef<const Expr *> getPrivates() const {
4157 return {varlist_end(), varlist_size()};
4158 }
4159
4160 /// Set list of helper expressions, required for proper codegen of the clause.
4161 /// These expressions represent LHS expression in the final reduction
4162 /// expression performed by the reduction clause.
4163 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
4164
4165 /// Get the list of helper LHS expressions.
4166 MutableArrayRef<Expr *> getLHSExprs() {
4167 return {getPrivates().end(), varlist_size()};
4168 }
4169 ArrayRef<const Expr *> getLHSExprs() const {
4170 return {getPrivates().end(), varlist_size()};
4171 }
4172
4173 /// Set list of helper expressions, required for proper codegen of the clause.
4174 /// These expressions represent RHS expression in the final reduction
4175 /// expression performed by the reduction clause. Also, variables in these
4176 /// expressions are used for proper initialization of reduction copies.
4177 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
4178
4179 /// Get the list of helper destination expressions.
4180 MutableArrayRef<Expr *> getRHSExprs() {
4181 return {getLHSExprs().end(), varlist_size()};
4182 }
4183 ArrayRef<const Expr *> getRHSExprs() const {
4184 return {getLHSExprs().end(), varlist_size()};
4185 }
4186
4187 /// Set list of helper reduction expressions, required for proper
4188 /// codegen of the clause. These expressions are binary expressions or
4189 /// operator/custom reduction call that calculates new value from source
4190 /// helper expressions to destination helper expressions.
4191 void setReductionOps(ArrayRef<Expr *> ReductionOps);
4192
4193 /// Get the list of helper reduction expressions.
4194 MutableArrayRef<Expr *> getReductionOps() {
4195 return {getRHSExprs().end(), varlist_size()};
4196 }
4197 ArrayRef<const Expr *> getReductionOps() const {
4198 return {getRHSExprs().end(), varlist_size()};
4199 }
4200
4201public:
4202 /// Creates clause with a list of variables \a VL.
4203 ///
4204 /// \param StartLoc Starting location of the clause.
4205 /// \param LParenLoc Location of '('.
4206 /// \param ColonLoc Location of ':'.
4207 /// \param EndLoc Ending location of the clause.
4208 /// \param VL The variables in the clause.
4209 /// \param QualifierLoc The nested-name qualifier with location information
4210 /// \param NameInfo The full name info for reduction identifier.
4211 /// \param Privates List of helper expressions for proper generation of
4212 /// private copies.
4213 /// \param LHSExprs List of helper expressions for proper generation of
4214 /// assignment operation required for copyprivate clause. This list represents
4215 /// LHSs of the reduction expressions.
4216 /// \param RHSExprs List of helper expressions for proper generation of
4217 /// assignment operation required for copyprivate clause. This list represents
4218 /// RHSs of the reduction expressions.
4219 /// Also, variables in these expressions are used for proper initialization of
4220 /// reduction copies.
4221 /// \param ReductionOps List of helper expressions that represents reduction
4222 /// expressions:
4223 /// \code
4224 /// LHSExprs binop RHSExprs;
4225 /// operator binop(LHSExpr, RHSExpr);
4226 /// <CutomReduction>(LHSExpr, RHSExpr);
4227 /// \endcode
4228 /// Required for proper codegen of final reduction operation performed by the
4229 /// reduction clause.
4230 /// \param PreInit Statement that must be executed before entering the OpenMP
4231 /// region with this clause.
4232 /// \param PostUpdate Expression that must be executed after exit from the
4233 /// OpenMP region with this clause.
4234 static OMPTaskReductionClause *
4235 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4236 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
4237 NestedNameSpecifierLoc QualifierLoc,
4238 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4239 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4240 ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
4241
4242 /// Creates an empty clause with the place for \a N variables.
4243 ///
4244 /// \param C AST context.
4245 /// \param N The number of variables.
4246 static OMPTaskReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
4247
4248 /// Gets location of ':' symbol in clause.
4249 SourceLocation getColonLoc() const { return ColonLoc; }
4250
4251 /// Gets the name info for specified reduction identifier.
4252 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4253
4254 /// Gets the nested name specifier.
4255 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4256
4259 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4261 llvm::iterator_range<helper_expr_const_iterator>;
4262
4264 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
4265 }
4266
4268 return helper_expr_range(getPrivates().begin(), getPrivates().end());
4269 }
4270
4272 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
4273 }
4274
4276 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
4277 }
4278
4280 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
4281 }
4282
4284 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
4285 }
4286
4288 return helper_expr_const_range(getReductionOps().begin(),
4289 getReductionOps().end());
4290 }
4291
4293 return helper_expr_range(getReductionOps().begin(),
4294 getReductionOps().end());
4295 }
4296
4298 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4299 reinterpret_cast<Stmt **>(varlist_end()));
4300 }
4301
4303 auto Children = const_cast<OMPTaskReductionClause *>(this)->children();
4304 return const_child_range(Children.begin(), Children.end());
4305 }
4306
4313
4314 static bool classof(const OMPClause *T) {
4315 return T->getClauseKind() == llvm::omp::OMPC_task_reduction;
4316 }
4317};
4318
4319/// This represents clause 'in_reduction' in the '#pragma omp task' directives.
4320///
4321/// \code
4322/// #pragma omp task in_reduction(+:a,b)
4323/// \endcode
4324/// In this example directive '#pragma omp task' has clause 'in_reduction' with
4325/// operator '+' and the variables 'a' and 'b'.
4326class OMPInReductionClause final
4327 : public OMPVarListClause<OMPInReductionClause>,
4329 private llvm::TrailingObjects<OMPInReductionClause, Expr *> {
4330 friend class OMPClauseReader;
4331 friend OMPVarListClause;
4332 friend TrailingObjects;
4333
4334 /// Location of ':'.
4335 SourceLocation ColonLoc;
4336
4337 /// Nested name specifier for C++.
4338 NestedNameSpecifierLoc QualifierLoc;
4339
4340 /// Name of custom operator.
4341 DeclarationNameInfo NameInfo;
4342
4343 /// Build clause with number of variables \a N.
4344 ///
4345 /// \param StartLoc Starting location of the clause.
4346 /// \param LParenLoc Location of '('.
4347 /// \param EndLoc Ending location of the clause.
4348 /// \param ColonLoc Location of ':'.
4349 /// \param N Number of the variables in the clause.
4350 /// \param QualifierLoc The nested-name qualifier with location information
4351 /// \param NameInfo The full name info for reduction identifier.
4352 OMPInReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4353 SourceLocation ColonLoc, SourceLocation EndLoc,
4354 unsigned N, NestedNameSpecifierLoc QualifierLoc,
4355 const DeclarationNameInfo &NameInfo)
4356 : OMPVarListClause<OMPInReductionClause>(llvm::omp::OMPC_in_reduction,
4357 StartLoc, LParenLoc, EndLoc, N),
4358 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
4359 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
4360
4361 /// Build an empty clause.
4362 ///
4363 /// \param N Number of variables.
4364 explicit OMPInReductionClause(unsigned N)
4366 llvm::omp::OMPC_in_reduction, SourceLocation(), SourceLocation(),
4367 SourceLocation(), N),
4369
4370 /// Sets location of ':' symbol in clause.
4371 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
4372
4373 /// Sets the name info for specified reduction identifier.
4374 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
4375
4376 /// Sets the nested name specifier.
4377 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
4378
4379 /// Set list of helper expressions, required for proper codegen of the clause.
4380 /// These expressions represent private copy of the reduction variable.
4381 void setPrivates(ArrayRef<Expr *> Privates);
4382
4383 /// Get the list of helper privates.
4384 MutableArrayRef<Expr *> getPrivates() {
4385 return {varlist_end(), varlist_size()};
4386 }
4387 ArrayRef<const Expr *> getPrivates() const {
4388 return {varlist_end(), varlist_size()};
4389 }
4390
4391 /// Set list of helper expressions, required for proper codegen of the clause.
4392 /// These expressions represent LHS expression in the final reduction
4393 /// expression performed by the reduction clause.
4394 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
4395
4396 /// Get the list of helper LHS expressions.
4397 MutableArrayRef<Expr *> getLHSExprs() {
4398 return {getPrivates().end(), varlist_size()};
4399 }
4400 ArrayRef<const Expr *> getLHSExprs() const {
4401 return {getPrivates().end(), varlist_size()};
4402 }
4403
4404 /// Set list of helper expressions, required for proper codegen of the clause.
4405 /// These expressions represent RHS expression in the final reduction
4406 /// expression performed by the reduction clause. Also, variables in these
4407 /// expressions are used for proper initialization of reduction copies.
4408 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
4409
4410 /// Get the list of helper destination expressions.
4411 MutableArrayRef<Expr *> getRHSExprs() {
4412 return {getLHSExprs().end(), varlist_size()};
4413 }
4414 ArrayRef<const Expr *> getRHSExprs() const {
4415 return {getLHSExprs().end(), varlist_size()};
4416 }
4417
4418 /// Set list of helper reduction expressions, required for proper
4419 /// codegen of the clause. These expressions are binary expressions or
4420 /// operator/custom reduction call that calculates new value from source
4421 /// helper expressions to destination helper expressions.
4422 void setReductionOps(ArrayRef<Expr *> ReductionOps);
4423
4424 /// Get the list of helper reduction expressions.
4425 MutableArrayRef<Expr *> getReductionOps() {
4426 return {getRHSExprs().end(), varlist_size()};
4427 }
4428 ArrayRef<const Expr *> getReductionOps() const {
4429 return {getRHSExprs().end(), varlist_size()};
4430 }
4431
4432 /// Set list of helper reduction taskgroup descriptors.
4433 void setTaskgroupDescriptors(ArrayRef<Expr *> ReductionOps);
4434
4435 /// Get the list of helper reduction taskgroup descriptors.
4436 MutableArrayRef<Expr *> getTaskgroupDescriptors() {
4437 return {getReductionOps().end(), varlist_size()};
4438 }
4439 ArrayRef<const Expr *> getTaskgroupDescriptors() const {
4440 return {getReductionOps().end(), varlist_size()};
4441 }
4442
4443public:
4444 /// Creates clause with a list of variables \a VL.
4445 ///
4446 /// \param StartLoc Starting location of the clause.
4447 /// \param LParenLoc Location of '('.
4448 /// \param ColonLoc Location of ':'.
4449 /// \param EndLoc Ending location of the clause.
4450 /// \param VL The variables in the clause.
4451 /// \param QualifierLoc The nested-name qualifier with location information
4452 /// \param NameInfo The full name info for reduction identifier.
4453 /// \param Privates List of helper expressions for proper generation of
4454 /// private copies.
4455 /// \param LHSExprs List of helper expressions for proper generation of
4456 /// assignment operation required for copyprivate clause. This list represents
4457 /// LHSs of the reduction expressions.
4458 /// \param RHSExprs List of helper expressions for proper generation of
4459 /// assignment operation required for copyprivate clause. This list represents
4460 /// RHSs of the reduction expressions.
4461 /// Also, variables in these expressions are used for proper initialization of
4462 /// reduction copies.
4463 /// \param ReductionOps List of helper expressions that represents reduction
4464 /// expressions:
4465 /// \code
4466 /// LHSExprs binop RHSExprs;
4467 /// operator binop(LHSExpr, RHSExpr);
4468 /// <CutomReduction>(LHSExpr, RHSExpr);
4469 /// \endcode
4470 /// Required for proper codegen of final reduction operation performed by the
4471 /// reduction clause.
4472 /// \param TaskgroupDescriptors List of helper taskgroup descriptors for
4473 /// corresponding items in parent taskgroup task_reduction clause.
4474 /// \param PreInit Statement that must be executed before entering the OpenMP
4475 /// region with this clause.
4476 /// \param PostUpdate Expression that must be executed after exit from the
4477 /// OpenMP region with this clause.
4478 static OMPInReductionClause *
4479 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4480 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
4481 NestedNameSpecifierLoc QualifierLoc,
4482 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4483 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4484 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> TaskgroupDescriptors,
4485 Stmt *PreInit, Expr *PostUpdate);
4486
4487 /// Creates an empty clause with the place for \a N variables.
4488 ///
4489 /// \param C AST context.
4490 /// \param N The number of variables.
4491 static OMPInReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
4492
4493 /// Gets location of ':' symbol in clause.
4494 SourceLocation getColonLoc() const { return ColonLoc; }
4495
4496 /// Gets the name info for specified reduction identifier.
4497 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4498
4499 /// Gets the nested name specifier.
4500 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4501
4504 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4506 llvm::iterator_range<helper_expr_const_iterator>;
4507
4509 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
4510 }
4511
4513 return helper_expr_range(getPrivates().begin(), getPrivates().end());
4514 }
4515
4517 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
4518 }
4519
4521 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
4522 }
4523
4525 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
4526 }
4527
4529 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
4530 }
4531
4533 return helper_expr_const_range(getReductionOps().begin(),
4534 getReductionOps().end());
4535 }
4536
4538 return helper_expr_range(getReductionOps().begin(),
4539 getReductionOps().end());
4540 }
4541
4543 return helper_expr_const_range(getTaskgroupDescriptors().begin(),
4544 getTaskgroupDescriptors().end());
4545 }
4546
4548 return helper_expr_range(getTaskgroupDescriptors().begin(),
4549 getTaskgroupDescriptors().end());
4550 }
4551
4553 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4554 reinterpret_cast<Stmt **>(varlist_end()));
4555 }
4556
4558 auto Children = const_cast<OMPInReductionClause *>(this)->children();
4559 return const_child_range(Children.begin(), Children.end());
4560 }
4561
4568
4569 static bool classof(const OMPClause *T) {
4570 return T->getClauseKind() == llvm::omp::OMPC_in_reduction;
4571 }
4572};
4573
4574/// This represents clause 'linear' in the '#pragma omp ...'
4575/// directives.
4576///
4577/// \code
4578/// #pragma omp simd linear(a,b : 2)
4579/// \endcode
4580/// In this example directive '#pragma omp simd' has clause 'linear'
4581/// with variables 'a', 'b' and linear step '2'.
4582class OMPLinearClause final
4583 : public OMPVarListClause<OMPLinearClause>,
4585 private llvm::TrailingObjects<OMPLinearClause, Expr *> {
4586 friend class OMPClauseReader;
4587 friend OMPVarListClause;
4588 friend TrailingObjects;
4589
4590 /// Modifier of 'linear' clause.
4591 OpenMPLinearClauseKind Modifier = OMPC_LINEAR_val;
4592
4593 /// Location of linear modifier if any.
4594 SourceLocation ModifierLoc;
4595
4596 /// Location of ':'.
4597 SourceLocation ColonLoc;
4598
4599 /// Location of 'step' modifier.
4600 SourceLocation StepModifierLoc;
4601
4602 /// Sets the linear step for clause.
4603 void setStep(Expr *Step) { *(getFinals().end()) = Step; }
4604
4605 /// Sets the expression to calculate linear step for clause.
4606 void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
4607
4608 /// Build 'linear' clause with given number of variables \a NumVars.
4609 ///
4610 /// \param StartLoc Starting location of the clause.
4611 /// \param LParenLoc Location of '('.
4612 /// \param ColonLoc Location of ':'.
4613 /// \param StepModifierLoc Location of 'step' modifier.
4614 /// \param EndLoc Ending location of the clause.
4615 /// \param NumVars Number of variables.
4616 OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4617 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4618 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4619 SourceLocation EndLoc, unsigned NumVars)
4620 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear, StartLoc,
4621 LParenLoc, EndLoc, NumVars),
4622 OMPClauseWithPostUpdate(this), Modifier(Modifier),
4623 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
4624 StepModifierLoc(StepModifierLoc) {}
4625
4626 /// Build an empty clause.
4627 ///
4628 /// \param NumVars Number of variables.
4629 explicit OMPLinearClause(unsigned NumVars)
4630 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear,
4631 SourceLocation(), SourceLocation(),
4632 SourceLocation(), NumVars),
4634
4635 /// Gets the list of initial values for linear variables.
4636 ///
4637 /// There are NumVars expressions with initial values allocated after the
4638 /// varlist, they are followed by NumVars update expressions (used to update
4639 /// the linear variable's value on current iteration) and they are followed by
4640 /// NumVars final expressions (used to calculate the linear variable's
4641 /// value after the loop body). After these lists, there are 2 helper
4642 /// expressions - linear step and a helper to calculate it before the
4643 /// loop body (used when the linear step is not constant):
4644 ///
4645 /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
4646 /// Finals[]; Step; CalcStep; }
4647 MutableArrayRef<Expr *> getPrivates() {
4648 return {varlist_end(), varlist_size()};
4649 }
4650 ArrayRef<const Expr *> getPrivates() const {
4651 return {varlist_end(), varlist_size()};
4652 }
4653
4654 MutableArrayRef<Expr *> getInits() {
4655 return {getPrivates().end(), varlist_size()};
4656 }
4657 ArrayRef<const Expr *> getInits() const {
4658 return {getPrivates().end(), varlist_size()};
4659 }
4660
4661 /// Sets the list of update expressions for linear variables.
4662 MutableArrayRef<Expr *> getUpdates() {
4663 return {getInits().end(), varlist_size()};
4664 }
4665 ArrayRef<const Expr *> getUpdates() const {
4666 return {getInits().end(), varlist_size()};
4667 }
4668
4669 /// Sets the list of final update expressions for linear variables.
4670 MutableArrayRef<Expr *> getFinals() {
4671 return {getUpdates().end(), varlist_size()};
4672 }
4673 ArrayRef<const Expr *> getFinals() const {
4674 return {getUpdates().end(), varlist_size()};
4675 }
4676
4677 /// Gets the list of used expressions for linear variables.
4678 MutableArrayRef<Expr *> getUsedExprs() {
4679 return {getFinals().end() + 2, varlist_size() + 1};
4680 }
4681 ArrayRef<const Expr *> getUsedExprs() const {
4682 return {getFinals().end() + 2, varlist_size() + 1};
4683 }
4684
4685 /// Sets the list of the copies of original linear variables.
4686 /// \param PL List of expressions.
4687 void setPrivates(ArrayRef<Expr *> PL);
4688
4689 /// Sets the list of the initial values for linear variables.
4690 /// \param IL List of expressions.
4691 void setInits(ArrayRef<Expr *> IL);
4692
4693public:
4694 /// Creates clause with a list of variables \a VL and a linear step
4695 /// \a Step.
4696 ///
4697 /// \param C AST Context.
4698 /// \param StartLoc Starting location of the clause.
4699 /// \param LParenLoc Location of '('.
4700 /// \param Modifier Modifier of 'linear' clause.
4701 /// \param ModifierLoc Modifier location.
4702 /// \param ColonLoc Location of ':'.
4703 /// \param StepModifierLoc Location of 'step' modifier.
4704 /// \param EndLoc Ending location of the clause.
4705 /// \param VL List of references to the variables.
4706 /// \param PL List of private copies of original variables.
4707 /// \param IL List of initial values for the variables.
4708 /// \param Step Linear step.
4709 /// \param CalcStep Calculation of the linear step.
4710 /// \param PreInit Statement that must be executed before entering the OpenMP
4711 /// region with this clause.
4712 /// \param PostUpdate Expression that must be executed after exit from the
4713 /// OpenMP region with this clause.
4714 static OMPLinearClause *
4715 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4716 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4717 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4718 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PL,
4719 ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit,
4720 Expr *PostUpdate);
4721
4722 /// Creates an empty clause with the place for \a NumVars variables.
4723 ///
4724 /// \param C AST context.
4725 /// \param NumVars Number of variables.
4726 static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4727
4728 /// Set modifier.
4729 void setModifier(OpenMPLinearClauseKind Kind) { Modifier = Kind; }
4730
4731 /// Return modifier.
4732 OpenMPLinearClauseKind getModifier() const { return Modifier; }
4733
4734 /// Set modifier location.
4735 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
4736
4737 /// Return modifier location.
4738 SourceLocation getModifierLoc() const { return ModifierLoc; }
4739
4740 /// Sets the location of ':'.
4741 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4742
4743 /// Sets the location of 'step' modifier.
4744 void setStepModifierLoc(SourceLocation Loc) { StepModifierLoc = Loc; }
4745
4746 /// Returns the location of ':'.
4747 SourceLocation getColonLoc() const { return ColonLoc; }
4748
4749 /// Returns the location of 'step' modifier.
4750 SourceLocation getStepModifierLoc() const { return StepModifierLoc; }
4751
4752 /// Returns linear step.
4753 Expr *getStep() { return *(getFinals().end()); }
4754
4755 /// Returns linear step.
4756 const Expr *getStep() const { return *(getFinals().end()); }
4757
4758 /// Returns expression to calculate linear step.
4759 Expr *getCalcStep() { return *(getFinals().end() + 1); }
4760
4761 /// Returns expression to calculate linear step.
4762 const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
4763
4764 /// Sets the list of update expressions for linear variables.
4765 /// \param UL List of expressions.
4767
4768 /// Sets the list of final update expressions for linear variables.
4769 /// \param FL List of expressions.
4770 void setFinals(ArrayRef<Expr *> FL);
4771
4772 /// Sets the list of used expressions for the linear clause.
4774
4777 using privates_range = llvm::iterator_range<privates_iterator>;
4778 using privates_const_range = llvm::iterator_range<privates_const_iterator>;
4779
4781 return privates_range(getPrivates().begin(), getPrivates().end());
4782 }
4783
4785 return privates_const_range(getPrivates().begin(), getPrivates().end());
4786 }
4787
4790 using inits_range = llvm::iterator_range<inits_iterator>;
4791 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
4792
4794 return inits_range(getInits().begin(), getInits().end());
4795 }
4796
4798 return inits_const_range(getInits().begin(), getInits().end());
4799 }
4800
4803 using updates_range = llvm::iterator_range<updates_iterator>;
4804 using updates_const_range = llvm::iterator_range<updates_const_iterator>;
4805
4807 return updates_range(getUpdates().begin(), getUpdates().end());
4808 }
4809
4811 return updates_const_range(getUpdates().begin(), getUpdates().end());
4812 }
4813
4816 using finals_range = llvm::iterator_range<finals_iterator>;
4817 using finals_const_range = llvm::iterator_range<finals_const_iterator>;
4818
4820 return finals_range(getFinals().begin(), getFinals().end());
4821 }
4822
4824 return finals_const_range(getFinals().begin(), getFinals().end());
4825 }
4826
4830 llvm::iterator_range<used_expressions_iterator>;
4832 llvm::iterator_range<used_expressions_const_iterator>;
4833
4835 return finals_range(getUsedExprs().begin(), getUsedExprs().end());
4836 }
4837
4839 return finals_const_range(getUsedExprs().begin(), getUsedExprs().end());
4840 }
4841
4843 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4844 reinterpret_cast<Stmt **>(varlist_end()));
4845 }
4846
4848 auto Children = const_cast<OMPLinearClause *>(this)->children();
4849 return const_child_range(Children.begin(), Children.end());
4850 }
4851
4853
4855 auto Children = const_cast<OMPLinearClause *>(this)->used_children();
4856 return const_child_range(Children.begin(), Children.end());
4857 }
4858
4859 static bool classof(const OMPClause *T) {
4860 return T->getClauseKind() == llvm::omp::OMPC_linear;
4861 }
4862};
4863
4864/// This represents clause 'aligned' in the '#pragma omp ...'
4865/// directives.
4866///
4867/// \code
4868/// #pragma omp simd aligned(a,b : 8)
4869/// \endcode
4870/// In this example directive '#pragma omp simd' has clause 'aligned'
4871/// with variables 'a', 'b' and alignment '8'.
4872class OMPAlignedClause final
4873 : public OMPVarListClause<OMPAlignedClause>,
4874 private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
4875 friend class OMPClauseReader;
4876 friend OMPVarListClause;
4877 friend TrailingObjects;
4878
4879 /// Location of ':'.
4880 SourceLocation ColonLoc;
4881
4882 /// Sets the alignment for clause.
4883 void setAlignment(Expr *A) { *varlist_end() = A; }
4884
4885 /// Build 'aligned' clause with given number of variables \a NumVars.
4886 ///
4887 /// \param StartLoc Starting location of the clause.
4888 /// \param LParenLoc Location of '('.
4889 /// \param ColonLoc Location of ':'.
4890 /// \param EndLoc Ending location of the clause.
4891 /// \param NumVars Number of variables.
4893 SourceLocation ColonLoc, SourceLocation EndLoc,
4894 unsigned NumVars)
4895 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned, StartLoc,
4896 LParenLoc, EndLoc, NumVars),
4897 ColonLoc(ColonLoc) {}
4898
4899 /// Build an empty clause.
4900 ///
4901 /// \param NumVars Number of variables.
4902 explicit OMPAlignedClause(unsigned NumVars)
4903 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned,
4904 SourceLocation(), SourceLocation(),
4905 SourceLocation(), NumVars) {}
4906
4907public:
4908 /// Creates clause with a list of variables \a VL and alignment \a A.
4909 ///
4910 /// \param C AST Context.
4911 /// \param StartLoc Starting location of the clause.
4912 /// \param LParenLoc Location of '('.
4913 /// \param ColonLoc Location of ':'.
4914 /// \param EndLoc Ending location of the clause.
4915 /// \param VL List of references to the variables.
4916 /// \param A Alignment.
4917 static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
4918 SourceLocation LParenLoc,
4919 SourceLocation ColonLoc,
4920 SourceLocation EndLoc, ArrayRef<Expr *> VL,
4921 Expr *A);
4922
4923 /// Creates an empty clause with the place for \a NumVars variables.
4924 ///
4925 /// \param C AST context.
4926 /// \param NumVars Number of variables.
4927 static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4928
4929 /// Sets the location of ':'.
4930 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4931
4932 /// Returns the location of ':'.
4933 SourceLocation getColonLoc() const { return ColonLoc; }
4934
4935 /// Returns alignment.
4937
4938 /// Returns alignment.
4939 const Expr *getAlignment() const { return *varlist_end(); }
4940
4942 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4943 reinterpret_cast<Stmt **>(varlist_end()));
4944 }
4945
4947 auto Children = const_cast<OMPAlignedClause *>(this)->children();
4948 return const_child_range(Children.begin(), Children.end());
4949 }
4950
4957
4958 static bool classof(const OMPClause *T) {
4959 return T->getClauseKind() == llvm::omp::OMPC_aligned;
4960 }
4961};
4962
4963/// This represents clause 'copyin' in the '#pragma omp ...' directives.
4964///
4965/// \code
4966/// #pragma omp parallel copyin(a,b)
4967/// \endcode
4968/// In this example directive '#pragma omp parallel' has clause 'copyin'
4969/// with the variables 'a' and 'b'.
4970class OMPCopyinClause final
4971 : public OMPVarListClause<OMPCopyinClause>,
4972 private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
4973 // Class has 3 additional tail allocated arrays:
4974 // 1. List of helper expressions for proper generation of assignment operation
4975 // required for copyin clause. This list represents sources.
4976 // 2. List of helper expressions for proper generation of assignment operation
4977 // required for copyin clause. This list represents destinations.
4978 // 3. List of helper expressions that represents assignment operation:
4979 // \code
4980 // DstExprs = SrcExprs;
4981 // \endcode
4982 // Required for proper codegen of propagation of master's thread values of
4983 // threadprivate variables to local instances of that variables in other
4984 // implicit threads.
4985
4986 friend class OMPClauseReader;
4987 friend OMPVarListClause;
4988 friend TrailingObjects;
4989
4990 /// Build clause with number of variables \a N.
4991 ///
4992 /// \param StartLoc Starting location of the clause.
4993 /// \param LParenLoc Location of '('.
4994 /// \param EndLoc Ending location of the clause.
4995 /// \param N Number of the variables in the clause.
4996 OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4997 SourceLocation EndLoc, unsigned N)
4998 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin, StartLoc,
4999 LParenLoc, EndLoc, N) {}
5000
5001 /// Build an empty clause.
5002 ///
5003 /// \param N Number of variables.
5004 explicit OMPCopyinClause(unsigned N)
5005 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin,
5007 SourceLocation(), N) {}
5008
5009 /// Set list of helper expressions, required for proper codegen of the
5010 /// clause. These expressions represent source expression in the final
5011 /// assignment statement performed by the copyin clause.
5012 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
5013
5014 /// Get the list of helper source expressions.
5015 MutableArrayRef<Expr *> getSourceExprs() {
5016 return {varlist_end(), varlist_size()};
5017 }
5018 ArrayRef<const Expr *> getSourceExprs() const {
5019 return {varlist_end(), varlist_size()};
5020 }
5021
5022 /// Set list of helper expressions, required for proper codegen of the
5023 /// clause. These expressions represent destination expression in the final
5024 /// assignment statement performed by the copyin clause.
5025 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
5026
5027 /// Get the list of helper destination expressions.
5028 MutableArrayRef<Expr *> getDestinationExprs() {
5029 return {getSourceExprs().end(), varlist_size()};
5030 }
5031 ArrayRef<const Expr *> getDestinationExprs() const {
5032 return {getSourceExprs().end(), varlist_size()};
5033 }
5034
5035 /// Set list of helper assignment expressions, required for proper
5036 /// codegen of the clause. These expressions are assignment expressions that
5037 /// assign source helper expressions to destination helper expressions
5038 /// correspondingly.
5039 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
5040
5041 /// Get the list of helper assignment expressions.
5042 MutableArrayRef<Expr *> getAssignmentOps() {
5043 return {getDestinationExprs().end(), varlist_size()};
5044 }
5045 ArrayRef<const Expr *> getAssignmentOps() const {
5046 return {getDestinationExprs().end(), varlist_size()};
5047 }
5048
5049public:
5050 /// Creates clause with a list of variables \a VL.
5051 ///
5052 /// \param C AST context.
5053 /// \param StartLoc Starting location of the clause.
5054 /// \param LParenLoc Location of '('.
5055 /// \param EndLoc Ending location of the clause.
5056 /// \param VL List of references to the variables.
5057 /// \param SrcExprs List of helper expressions for proper generation of
5058 /// assignment operation required for copyin clause. This list represents
5059 /// sources.
5060 /// \param DstExprs List of helper expressions for proper generation of
5061 /// assignment operation required for copyin clause. This list represents
5062 /// destinations.
5063 /// \param AssignmentOps List of helper expressions that represents assignment
5064 /// operation:
5065 /// \code
5066 /// DstExprs = SrcExprs;
5067 /// \endcode
5068 /// Required for proper codegen of propagation of master's thread values of
5069 /// threadprivate variables to local instances of that variables in other
5070 /// implicit threads.
5071 static OMPCopyinClause *
5072 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
5073 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
5074 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
5075
5076 /// Creates an empty clause with \a N variables.
5077 ///
5078 /// \param C AST context.
5079 /// \param N The number of variables.
5080 static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
5081
5084 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
5086 llvm::iterator_range<helper_expr_const_iterator>;
5087
5089 return helper_expr_const_range(getSourceExprs().begin(),
5090 getSourceExprs().end());
5091 }
5092
5094 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
5095 }
5096
5098 return helper_expr_const_range(getDestinationExprs().begin(),
5099 getDestinationExprs().end());
5100 }
5101
5103 return helper_expr_range(getDestinationExprs().begin(),
5104 getDestinationExprs().end());
5105 }
5106
5108 return helper_expr_const_range(getAssignmentOps().begin(),
5109 getAssignmentOps().end());
5110 }
5111
5113 return helper_expr_range(getAssignmentOps().begin(),
5114 getAssignmentOps().end());
5115 }
5116
5118 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5119 reinterpret_cast<Stmt **>(varlist_end()));
5120 }
5121
5123 auto Children = const_cast<OMPCopyinClause *>(this)->children();
5124 return const_child_range(Children.begin(), Children.end());
5125 }
5126
5133
5134 static bool classof(const OMPClause *T) {
5135 return T->getClauseKind() == llvm::omp::OMPC_copyin;
5136 }
5137};
5138
5139/// This represents clause 'copyprivate' in the '#pragma omp ...'
5140/// directives.
5141///
5142/// \code
5143/// #pragma omp single copyprivate(a,b)
5144/// \endcode
5145/// In this example directive '#pragma omp single' has clause 'copyprivate'
5146/// with the variables 'a' and 'b'.
5147class OMPCopyprivateClause final
5148 : public OMPVarListClause<OMPCopyprivateClause>,
5149 private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
5150 friend class OMPClauseReader;
5151 friend OMPVarListClause;
5152 friend TrailingObjects;
5153
5154 /// Build clause with number of variables \a N.
5155 ///
5156 /// \param StartLoc Starting location of the clause.
5157 /// \param LParenLoc Location of '('.
5158 /// \param EndLoc Ending location of the clause.
5159 /// \param N Number of the variables in the clause.
5160 OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5161 SourceLocation EndLoc, unsigned N)
5162 : OMPVarListClause<OMPCopyprivateClause>(llvm::omp::OMPC_copyprivate,
5163 StartLoc, LParenLoc, EndLoc, N) {
5164 }
5165
5166 /// Build an empty clause.
5167 ///
5168 /// \param N Number of variables.
5169 explicit OMPCopyprivateClause(unsigned N)
5171 llvm::omp::OMPC_copyprivate, SourceLocation(), SourceLocation(),
5172 SourceLocation(), N) {}
5173
5174 /// Set list of helper expressions, required for proper codegen of the
5175 /// clause. These expressions represent source expression in the final
5176 /// assignment statement performed by the copyprivate clause.
5177 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
5178
5179 /// Get the list of helper source expressions.
5180 MutableArrayRef<Expr *> getSourceExprs() {
5181 return {varlist_end(), varlist_size()};
5182 }
5183 ArrayRef<const Expr *> getSourceExprs() const {
5184 return {varlist_end(), varlist_size()};
5185 }
5186
5187 /// Set list of helper expressions, required for proper codegen of the
5188 /// clause. These expressions represent destination expression in the final
5189 /// assignment statement performed by the copyprivate clause.
5190 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
5191
5192 /// Get the list of helper destination expressions.
5193 MutableArrayRef<Expr *> getDestinationExprs() {
5194 return {getSourceExprs().end(), varlist_size()};
5195 }
5196 ArrayRef<const Expr *> getDestinationExprs() const {
5197 return {getSourceExprs().end(), varlist_size()};
5198 }
5199
5200 /// Set list of helper assignment expressions, required for proper
5201 /// codegen of the clause. These expressions are assignment expressions that
5202 /// assign source helper expressions to destination helper expressions
5203 /// correspondingly.
5204 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
5205
5206 /// Get the list of helper assignment expressions.
5207 MutableArrayRef<Expr *> getAssignmentOps() {
5208 return {getDestinationExprs().end(), varlist_size()};
5209 }
5210 ArrayRef<const Expr *> getAssignmentOps() const {
5211 return {getDestinationExprs().end(), varlist_size()};
5212 }
5213
5214public:
5215 /// Creates clause with a list of variables \a VL.
5216 ///
5217 /// \param C AST context.
5218 /// \param StartLoc Starting location of the clause.
5219 /// \param LParenLoc Location of '('.
5220 /// \param EndLoc Ending location of the clause.
5221 /// \param VL List of references to the variables.
5222 /// \param SrcExprs List of helper expressions for proper generation of
5223 /// assignment operation required for copyprivate clause. This list represents
5224 /// sources.
5225 /// \param DstExprs List of helper expressions for proper generation of
5226 /// assignment operation required for copyprivate clause. This list represents
5227 /// destinations.
5228 /// \param AssignmentOps List of helper expressions that represents assignment
5229 /// operation:
5230 /// \code
5231 /// DstExprs = SrcExprs;
5232 /// \endcode
5233 /// Required for proper codegen of final assignment performed by the
5234 /// copyprivate clause.
5235 static OMPCopyprivateClause *
5236 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
5237 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
5238 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
5239
5240 /// Creates an empty clause with \a N variables.
5241 ///
5242 /// \param C AST context.
5243 /// \param N The number of variables.
5244 static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
5245
5248 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
5250 llvm::iterator_range<helper_expr_const_iterator>;
5251
5253 return helper_expr_const_range(getSourceExprs().begin(),
5254 getSourceExprs().end());
5255 }
5256
5258 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
5259 }
5260
5262 return helper_expr_const_range(getDestinationExprs().begin(),
5263 getDestinationExprs().end());
5264 }
5265
5267 return helper_expr_range(getDestinationExprs().begin(),
5268 getDestinationExprs().end());
5269 }
5270
5272 return helper_expr_const_range(getAssignmentOps().begin(),
5273 getAssignmentOps().end());
5274 }
5275
5277 return helper_expr_range(getAssignmentOps().begin(),
5278 getAssignmentOps().end());
5279 }
5280
5282 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5283 reinterpret_cast<Stmt **>(varlist_end()));
5284 }
5285
5287 auto Children = const_cast<OMPCopyprivateClause *>(this)->children();
5288 return const_child_range(Children.begin(), Children.end());
5289 }
5290
5297
5298 static bool classof(const OMPClause *T) {
5299 return T->getClauseKind() == llvm::omp::OMPC_copyprivate;
5300 }
5301};
5302
5303/// This represents implicit clause 'flush' for the '#pragma omp flush'
5304/// directive.
5305/// This clause does not exist by itself, it can be only as a part of 'omp
5306/// flush' directive. This clause is introduced to keep the original structure
5307/// of \a OMPExecutableDirective class and its derivatives and to use the
5308/// existing infrastructure of clauses with the list of variables.
5309///
5310/// \code
5311/// #pragma omp flush(a,b)
5312/// \endcode
5313/// In this example directive '#pragma omp flush' has implicit clause 'flush'
5314/// with the variables 'a' and 'b'.
5315class OMPFlushClause final
5316 : public OMPVarListClause<OMPFlushClause>,
5317 private llvm::TrailingObjects<OMPFlushClause, Expr *> {
5318 friend OMPVarListClause;
5319 friend TrailingObjects;
5320
5321 /// Build clause with number of variables \a N.
5322 ///
5323 /// \param StartLoc Starting location of the clause.
5324 /// \param LParenLoc Location of '('.
5325 /// \param EndLoc Ending location of the clause.
5326 /// \param N Number of the variables in the clause.
5327 OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5328 SourceLocation EndLoc, unsigned N)
5329 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush, StartLoc,
5330 LParenLoc, EndLoc, N) {}
5331
5332 /// Build an empty clause.
5333 ///
5334 /// \param N Number of variables.
5335 explicit OMPFlushClause(unsigned N)
5336 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush,
5338 SourceLocation(), N) {}
5339
5340public:
5341 /// Creates clause with a list of variables \a VL.
5342 ///
5343 /// \param C AST context.
5344 /// \param StartLoc Starting location of the clause.
5345 /// \param LParenLoc Location of '('.
5346 /// \param EndLoc Ending location of the clause.
5347 /// \param VL List of references to the variables.
5348 static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
5349 SourceLocation LParenLoc, SourceLocation EndLoc,
5350 ArrayRef<Expr *> VL);
5351
5352 /// Creates an empty clause with \a N variables.
5353 ///
5354 /// \param C AST context.
5355 /// \param N The number of variables.
5356 static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
5357
5359 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5360 reinterpret_cast<Stmt **>(varlist_end()));
5361 }
5362
5364 auto Children = const_cast<OMPFlushClause *>(this)->children();
5365 return const_child_range(Children.begin(), Children.end());
5366 }
5367
5374
5375 static bool classof(const OMPClause *T) {
5376 return T->getClauseKind() == llvm::omp::OMPC_flush;
5377 }
5378};
5379
5380/// This represents implicit clause 'depobj' for the '#pragma omp depobj'
5381/// directive.
5382/// This clause does not exist by itself, it can be only as a part of 'omp
5383/// depobj' directive. This clause is introduced to keep the original structure
5384/// of \a OMPExecutableDirective class and its derivatives and to use the
5385/// existing infrastructure of clauses with the list of variables.
5386///
5387/// \code
5388/// #pragma omp depobj(a) destroy
5389/// \endcode
5390/// In this example directive '#pragma omp depobj' has implicit clause 'depobj'
5391/// with the depobj 'a'.
5392class OMPDepobjClause final : public OMPClause {
5393 friend class OMPClauseReader;
5394
5395 /// Location of '('.
5396 SourceLocation LParenLoc;
5397
5398 /// Chunk size.
5399 Expr *Depobj = nullptr;
5400
5401 /// Build clause with number of variables \a N.
5402 ///
5403 /// \param StartLoc Starting location of the clause.
5404 /// \param LParenLoc Location of '('.
5405 /// \param EndLoc Ending location of the clause.
5406 OMPDepobjClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5407 SourceLocation EndLoc)
5408 : OMPClause(llvm::omp::OMPC_depobj, StartLoc, EndLoc),
5409 LParenLoc(LParenLoc) {}
5410
5411 /// Build an empty clause.
5412 ///
5413 explicit OMPDepobjClause()
5414 : OMPClause(llvm::omp::OMPC_depobj, SourceLocation(), SourceLocation()) {}
5415
5416 void setDepobj(Expr *E) { Depobj = E; }
5417
5418 /// Sets the location of '('.
5419 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5420
5421public:
5422 /// Creates clause.
5423 ///
5424 /// \param C AST context.
5425 /// \param StartLoc Starting location of the clause.
5426 /// \param LParenLoc Location of '('.
5427 /// \param EndLoc Ending location of the clause.
5428 /// \param Depobj depobj expression associated with the 'depobj' directive.
5429 static OMPDepobjClause *Create(const ASTContext &C, SourceLocation StartLoc,
5430 SourceLocation LParenLoc,
5431 SourceLocation EndLoc, Expr *Depobj);
5432
5433 /// Creates an empty clause.
5434 ///
5435 /// \param C AST context.
5436 static OMPDepobjClause *CreateEmpty(const ASTContext &C);
5437
5438 /// Returns depobj expression associated with the clause.
5439 Expr *getDepobj() { return Depobj; }
5440 const Expr *getDepobj() const { return Depobj; }
5441
5442 /// Returns the location of '('.
5443 SourceLocation getLParenLoc() const { return LParenLoc; }
5444
5446 return child_range(reinterpret_cast<Stmt **>(&Depobj),
5447 reinterpret_cast<Stmt **>(&Depobj) + 1);
5448 }
5449
5451 auto Children = const_cast<OMPDepobjClause *>(this)->children();
5452 return const_child_range(Children.begin(), Children.end());
5453 }
5454
5461
5462 static bool classof(const OMPClause *T) {
5463 return T->getClauseKind() == llvm::omp::OMPC_depobj;
5464 }
5465};
5466
5467/// This represents implicit clause 'depend' for the '#pragma omp task'
5468/// directive.
5469///
5470/// \code
5471/// #pragma omp task depend(in:a,b)
5472/// \endcode
5473/// In this example directive '#pragma omp task' with clause 'depend' with the
5474/// variables 'a' and 'b' with dependency 'in'.
5475class OMPDependClause final
5476 : public OMPVarListClause<OMPDependClause>,
5477 private llvm::TrailingObjects<OMPDependClause, Expr *> {
5478 friend class OMPClauseReader;
5479 friend OMPVarListClause;
5480 friend TrailingObjects;
5481
5482public:
5483 struct DependDataTy final {
5484 /// Dependency type (one of in, out, inout).
5486
5487 /// Dependency type location.
5489
5490 /// Colon location.
5492
5493 /// Location of 'omp_all_memory'.
5495 };
5496
5497private:
5498 /// Dependency type and source locations.
5499 DependDataTy Data;
5500
5501 /// Number of loops, associated with the depend clause.
5502 unsigned NumLoops = 0;
5503
5504 /// Build clause with number of variables \a N.
5505 ///
5506 /// \param StartLoc Starting location of the clause.
5507 /// \param LParenLoc Location of '('.
5508 /// \param EndLoc Ending location of the clause.
5509 /// \param N Number of the variables in the clause.
5510 /// \param NumLoops Number of loops that is associated with this depend
5511 /// clause.
5512 OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5513 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
5514 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend, StartLoc,
5515 LParenLoc, EndLoc, N),
5516 NumLoops(NumLoops) {}
5517
5518 /// Build an empty clause.
5519 ///
5520 /// \param N Number of variables.
5521 /// \param NumLoops Number of loops that is associated with this depend
5522 /// clause.
5523 explicit OMPDependClause(unsigned N, unsigned NumLoops)
5524 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend,
5526 SourceLocation(), N),
5527 NumLoops(NumLoops) {}
5528
5529 /// Set dependency kind.
5530 void setDependencyKind(OpenMPDependClauseKind K) { Data.DepKind = K; }
5531
5532 /// Set dependency kind and its location.
5533 void setDependencyLoc(SourceLocation Loc) { Data.DepLoc = Loc; }
5534
5535 /// Set colon location.
5536 void setColonLoc(SourceLocation Loc) { Data.ColonLoc = Loc; }
5537
5538 /// Set the 'omp_all_memory' location.
5539 void setOmpAllMemoryLoc(SourceLocation Loc) { Data.OmpAllMemoryLoc = Loc; }
5540
5541 /// Sets optional dependency modifier.
5542 void setModifier(Expr *DepModifier);
5543
5544public:
5545 /// Creates clause with a list of variables \a VL.
5546 ///
5547 /// \param C AST context.
5548 /// \param StartLoc Starting location of the clause.
5549 /// \param LParenLoc Location of '('.
5550 /// \param EndLoc Ending location of the clause.
5551 /// \param Data Dependency type and source locations.
5552 /// \param VL List of references to the variables.
5553 /// \param NumLoops Number of loops that is associated with this depend
5554 /// clause.
5555 static OMPDependClause *Create(const ASTContext &C, SourceLocation StartLoc,
5556 SourceLocation LParenLoc,
5557 SourceLocation EndLoc, DependDataTy Data,
5558 Expr *DepModifier, ArrayRef<Expr *> VL,
5559 unsigned NumLoops);
5560
5561 /// Creates an empty clause with \a N variables.
5562 ///
5563 /// \param C AST context.
5564 /// \param N The number of variables.
5565 /// \param NumLoops Number of loops that is associated with this depend
5566 /// clause.
5567 static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N,
5568 unsigned NumLoops);
5569
5570 /// Get dependency type.
5571 OpenMPDependClauseKind getDependencyKind() const { return Data.DepKind; }
5572
5573 /// Get dependency type location.
5574 SourceLocation getDependencyLoc() const { return Data.DepLoc; }
5575
5576 /// Get colon location.
5577 SourceLocation getColonLoc() const { return Data.ColonLoc; }
5578
5579 /// Get 'omp_all_memory' location.
5580 SourceLocation getOmpAllMemoryLoc() const { return Data.OmpAllMemoryLoc; }
5581
5582 /// Return optional depend modifier.
5583 Expr *getModifier();
5584 const Expr *getModifier() const {
5585 return const_cast<OMPDependClause *>(this)->getModifier();
5586 }
5587
5588 /// Get number of loops associated with the clause.
5589 unsigned getNumLoops() const { return NumLoops; }
5590
5591 /// Set the loop data for the depend clauses with 'sink|source' kind of
5592 /// dependency.
5593 void setLoopData(unsigned NumLoop, Expr *Cnt);
5594
5595 /// Get the loop data.
5596 Expr *getLoopData(unsigned NumLoop);
5597 const Expr *getLoopData(unsigned NumLoop) const;
5598
5600 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5601 reinterpret_cast<Stmt **>(varlist_end()));
5602 }
5603
5605 auto Children = const_cast<OMPDependClause *>(this)->children();
5606 return const_child_range(Children.begin(), Children.end());
5607 }
5608
5615
5616 static bool classof(const OMPClause *T) {
5617 return T->getClauseKind() == llvm::omp::OMPC_depend;
5618 }
5619};
5620
5621/// This represents 'device' clause in the '#pragma omp ...'
5622/// directive.
5623///
5624/// \code
5625/// #pragma omp target device(a)
5626/// \endcode
5627/// In this example directive '#pragma omp target' has clause 'device'
5628/// with single expression 'a'.
5630 friend class OMPClauseReader;
5631
5632 /// Location of '('.
5633 SourceLocation LParenLoc;
5634
5635 /// Device clause modifier.
5637
5638 /// Location of the modifier.
5639 SourceLocation ModifierLoc;
5640
5641 /// Device number.
5642 Stmt *Device = nullptr;
5643
5644 /// Set the device number.
5645 ///
5646 /// \param E Device number.
5647 void setDevice(Expr *E) { Device = E; }
5648
5649 /// Sets modifier.
5650 void setModifier(OpenMPDeviceClauseModifier M) { Modifier = M; }
5651
5652 /// Setst modifier location.
5653 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
5654
5655public:
5656 /// Build 'device' clause.
5657 ///
5658 /// \param Modifier Clause modifier.
5659 /// \param E Expression associated with this clause.
5660 /// \param CaptureRegion Innermost OpenMP region where expressions in this
5661 /// clause must be captured.
5662 /// \param StartLoc Starting location of the clause.
5663 /// \param ModifierLoc Modifier location.
5664 /// \param LParenLoc Location of '('.
5665 /// \param EndLoc Ending location of the clause.
5667 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
5668 SourceLocation LParenLoc, SourceLocation ModifierLoc,
5669 SourceLocation EndLoc)
5670 : OMPClause(llvm::omp::OMPC_device, StartLoc, EndLoc),
5671 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
5672 ModifierLoc(ModifierLoc), Device(E) {
5673 setPreInitStmt(HelperE, CaptureRegion);
5674 }
5675
5676 /// Build an empty clause.
5678 : OMPClause(llvm::omp::OMPC_device, SourceLocation(), SourceLocation()),
5679 OMPClauseWithPreInit(this) {}
5680
5681 /// Sets the location of '('.
5682 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5683
5684 /// Returns the location of '('.
5685 SourceLocation getLParenLoc() const { return LParenLoc; }
5686
5687 /// Return device number.
5688 Expr *getDevice() { return cast<Expr>(Device); }
5689
5690 /// Return device number.
5691 Expr *getDevice() const { return cast<Expr>(Device); }
5692
5693 /// Gets modifier.
5694 OpenMPDeviceClauseModifier getModifier() const { return Modifier; }
5695
5696 /// Gets modifier location.
5697 SourceLocation getModifierLoc() const { return ModifierLoc; }
5698
5699 child_range children() { return child_range(&Device, &Device + 1); }
5700
5702 return const_child_range(&Device, &Device + 1);
5703 }
5704
5711
5712 static bool classof(const OMPClause *T) {
5713 return T->getClauseKind() == llvm::omp::OMPC_device;
5714 }
5715};
5716
5717/// This represents 'threads' clause in the '#pragma omp ...' directive.
5718///
5719/// \code
5720/// #pragma omp ordered threads
5721/// \endcode
5722/// In this example directive '#pragma omp ordered' has simple 'threads' clause.
5724 : public OMPNoChildClause<llvm::omp::OMPC_threads> {
5725public:
5726 /// Build 'threads' clause.
5727 ///
5728 /// \param StartLoc Starting location of the clause.
5729 /// \param EndLoc Ending location of the clause.
5731 : OMPNoChildClause(StartLoc, EndLoc) {}
5732
5733 /// Build an empty clause.
5735};
5736
5737/// This represents 'simd' clause in the '#pragma omp ...' directive.
5738///
5739/// \code
5740/// #pragma omp ordered simd
5741/// \endcode
5742/// In this example directive '#pragma omp ordered' has simple 'simd' clause.
5743class OMPSIMDClause : public OMPClause {
5744public:
5745 /// Build 'simd' clause.
5746 ///
5747 /// \param StartLoc Starting location of the clause.
5748 /// \param EndLoc Ending location of the clause.
5750 : OMPClause(llvm::omp::OMPC_simd, StartLoc, EndLoc) {}
5751
5752 /// Build an empty clause.
5754 : OMPClause(llvm::omp::OMPC_simd, SourceLocation(), SourceLocation()) {}
5755
5759
5763
5770
5771 static bool classof(const OMPClause *T) {
5772 return T->getClauseKind() == llvm::omp::OMPC_simd;
5773 }
5774};
5775
5776/// Struct that defines common infrastructure to handle mappable
5777/// expressions used in OpenMP clauses.
5779public:
5780 /// Class that represents a component of a mappable expression. E.g.
5781 /// for an expression S.a, the first component is a declaration reference
5782 /// expression associated with 'S' and the second is a member expression
5783 /// associated with the field declaration 'a'. If the expression is an array
5784 /// subscript it may not have any associated declaration. In that case the
5785 /// associated declaration is set to nullptr.
5787 /// Pair of Expression and Non-contiguous pair associated with the
5788 /// component.
5789 llvm::PointerIntPair<Expr *, 1, bool> AssociatedExpressionNonContiguousPr;
5790
5791 /// Declaration associated with the declaration. If the component does
5792 /// not have a declaration (e.g. array subscripts or section), this is set
5793 /// to nullptr.
5794 ValueDecl *AssociatedDeclaration = nullptr;
5795
5796 public:
5797 explicit MappableComponent() = default;
5798 explicit MappableComponent(Expr *AssociatedExpression,
5799 ValueDecl *AssociatedDeclaration,
5800 bool IsNonContiguous)
5801 : AssociatedExpressionNonContiguousPr(AssociatedExpression,
5802 IsNonContiguous),
5803 AssociatedDeclaration(
5804 AssociatedDeclaration
5805 ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
5806 : nullptr) {}
5807
5809 return AssociatedExpressionNonContiguousPr.getPointer();
5810 }
5811
5812 bool isNonContiguous() const {
5813 return AssociatedExpressionNonContiguousPr.getInt();
5814 }
5815
5817 return AssociatedDeclaration;
5818 }
5819 };
5820
5821 // List of components of an expression. This first one is the whole
5822 // expression and the last one is the base expression.
5825
5826 // List of all component lists associated to the same base declaration.
5827 // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
5828 // their component list but the same base declaration 'S'.
5831
5832protected:
5833 // Return the total number of elements in a list of component lists.
5834 static unsigned
5836
5837 // Return the total number of elements in a list of declarations. All
5838 // declarations are expected to be canonical.
5839 static unsigned
5841};
5842
5843/// This structure contains all sizes needed for by an
5844/// OMPMappableExprListClause.
5846 /// Number of expressions listed.
5847 unsigned NumVars;
5848 /// Number of unique base declarations.
5850 /// Number of component lists.
5852 /// Total number of expression components.
5859};
5860
5861/// This represents clauses with a list of expressions that are mappable.
5862/// Examples of these clauses are 'map' in
5863/// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
5864/// in '#pragma omp target update...' directives.
5865template <class T>
5868 friend class OMPClauseReader;
5869
5870 /// Number of unique declarations in this clause.
5871 unsigned NumUniqueDeclarations;
5872
5873 /// Number of component lists in this clause.
5874 unsigned NumComponentLists;
5875
5876 /// Total number of components in this clause.
5877 unsigned NumComponents;
5878
5879 /// Whether this clause is possible to have user-defined mappers associated.
5880 /// It should be true for map, to, and from clauses, and false for
5881 /// use_device_ptr and is_device_ptr.
5882 const bool SupportsMapper;
5883
5884 /// C++ nested name specifier for the associated user-defined mapper.
5885 NestedNameSpecifierLoc MapperQualifierLoc;
5886
5887 /// The associated user-defined mapper identifier information.
5888 DeclarationNameInfo MapperIdInfo;
5889
5890protected:
5891 /// Build a clause for \a NumUniqueDeclarations declarations, \a
5892 /// NumComponentLists total component lists, and \a NumComponents total
5893 /// components.
5894 ///
5895 /// \param K Kind of the clause.
5896 /// \param Locs Locations needed to build a mappable clause. It includes 1)
5897 /// StartLoc: starting location of the clause (the clause keyword); 2)
5898 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5899 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5900 /// NumVars: number of expressions listed in this clause; 2)
5901 /// NumUniqueDeclarations: number of unique base declarations in this clause;
5902 /// 3) NumComponentLists: number of component lists in this clause; and 4)
5903 /// NumComponents: total number of expression components in the clause.
5904 /// \param SupportsMapper Indicates whether this clause is possible to have
5905 /// user-defined mappers associated.
5906 /// \param MapperQualifierLocPtr C++ nested name specifier for the associated
5907 /// user-defined mapper.
5908 /// \param MapperIdInfoPtr The identifier of associated user-defined mapper.
5910 OpenMPClauseKind K, const OMPVarListLocTy &Locs,
5911 const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false,
5912 NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr,
5913 DeclarationNameInfo *MapperIdInfoPtr = nullptr)
5914 : OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc,
5915 Sizes.NumVars),
5916 NumUniqueDeclarations(Sizes.NumUniqueDeclarations),
5917 NumComponentLists(Sizes.NumComponentLists),
5918 NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) {
5919 if (MapperQualifierLocPtr)
5920 MapperQualifierLoc = *MapperQualifierLocPtr;
5921 if (MapperIdInfoPtr)
5922 MapperIdInfo = *MapperIdInfoPtr;
5923 }
5924
5925 /// Get the unique declarations that are in the trailing objects of the
5926 /// class.
5928 return static_cast<T *>(this)
5929 ->template getTrailingObjectsNonStrict<ValueDecl *>(
5930 NumUniqueDeclarations);
5931 }
5932
5933 /// Get the unique declarations that are in the trailing objects of the
5934 /// class.
5936 return static_cast<const T *>(this)
5937 ->template getTrailingObjectsNonStrict<ValueDecl *>(
5938 NumUniqueDeclarations);
5939 }
5940
5941 /// Set the unique declarations that are in the trailing objects of the
5942 /// class.
5944 assert(UDs.size() == NumUniqueDeclarations &&
5945 "Unexpected amount of unique declarations.");
5946 llvm::copy(UDs, getUniqueDeclsRef().begin());
5947 }
5948
5949 /// Get the number of lists per declaration that are in the trailing
5950 /// objects of the class.
5952 return static_cast<T *>(this)
5953 ->template getTrailingObjectsNonStrict<unsigned>(NumUniqueDeclarations);
5954 }
5955
5956 /// Get the number of lists per declaration that are in the trailing
5957 /// objects of the class.
5959 return static_cast<const T *>(this)
5960 ->template getTrailingObjectsNonStrict<unsigned>(NumUniqueDeclarations);
5961 }
5962
5963 /// Set the number of lists per declaration that are in the trailing
5964 /// objects of the class.
5966 assert(DNLs.size() == NumUniqueDeclarations &&
5967 "Unexpected amount of list numbers.");
5968 llvm::copy(DNLs, getDeclNumListsRef().begin());
5969 }
5970
5971 /// Get the cumulative component lists sizes that are in the trailing
5972 /// objects of the class. They are appended after the number of lists.
5975 static_cast<T *>(this)
5976 ->template getTrailingObjectsNonStrict<unsigned>() +
5977 NumUniqueDeclarations,
5978 NumComponentLists);
5979 }
5980
5981 /// Get the cumulative component lists sizes that are in the trailing
5982 /// objects of the class. They are appended after the number of lists.
5984 return ArrayRef<unsigned>(
5985 static_cast<const T *>(this)
5986 ->template getTrailingObjectsNonStrict<unsigned>() +
5987 NumUniqueDeclarations,
5988 NumComponentLists);
5989 }
5990
5991 /// Set the cumulative component lists sizes that are in the trailing
5992 /// objects of the class.
5994 assert(CLSs.size() == NumComponentLists &&
5995 "Unexpected amount of component lists.");
5996 llvm::copy(CLSs, getComponentListSizesRef().begin());
5997 }
5998
5999 /// Get the components that are in the trailing objects of the class.
6001 return static_cast<T *>(this)
6002 ->template getTrailingObjectsNonStrict<MappableComponent>(
6003 NumComponents);
6004 }
6005
6006 /// Get the components that are in the trailing objects of the class.
6008 return static_cast<const T *>(this)
6009 ->template getTrailingObjectsNonStrict<MappableComponent>(
6010 NumComponents);
6011 }
6012
6013 /// Set the components that are in the trailing objects of the class.
6014 /// This requires the list sizes so that it can also fill the original
6015 /// expressions, which are the first component of each list.
6017 ArrayRef<unsigned> CLSs) {
6018 assert(Components.size() == NumComponents &&
6019 "Unexpected amount of component lists.");
6020 assert(CLSs.size() == NumComponentLists &&
6021 "Unexpected amount of list sizes.");
6022 llvm::copy(Components, getComponentsRef().begin());
6023 }
6024
6025 /// Fill the clause information from the list of declarations and
6026 /// associated component lists.
6028 MappableExprComponentListsRef ComponentLists) {
6029 // Perform some checks to make sure the data sizes are consistent with the
6030 // information available when the clause was created.
6031 assert(getUniqueDeclarationsTotalNumber(Declarations) ==
6032 NumUniqueDeclarations &&
6033 "Unexpected number of mappable expression info entries!");
6034 assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
6035 "Unexpected total number of components!");
6036 assert(Declarations.size() == ComponentLists.size() &&
6037 "Declaration and component lists size is not consistent!");
6038 assert(Declarations.size() == NumComponentLists &&
6039 "Unexpected declaration and component lists size!");
6040
6041 // Organize the components by declaration and retrieve the original
6042 // expression. Original expressions are always the first component of the
6043 // mappable component list.
6044 llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
6045 ComponentListMap;
6046 {
6047 auto CI = ComponentLists.begin();
6048 for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
6049 ++DI, ++CI) {
6050 assert(!CI->empty() && "Invalid component list!");
6051 ComponentListMap[*DI].push_back(*CI);
6052 }
6053 }
6054
6055 // Iterators of the target storage.
6056 auto UniqueDeclarations = getUniqueDeclsRef();
6057 auto UDI = UniqueDeclarations.begin();
6058
6059 auto DeclNumLists = getDeclNumListsRef();
6060 auto DNLI = DeclNumLists.begin();
6061
6062 auto ComponentListSizes = getComponentListSizesRef();
6063 auto CLSI = ComponentListSizes.begin();
6064
6065 auto Components = getComponentsRef();
6066 auto CI = Components.begin();
6067
6068 // Variable to compute the accumulation of the number of components.
6069 unsigned PrevSize = 0u;
6070
6071 // Scan all the declarations and associated component lists.
6072 for (auto &M : ComponentListMap) {
6073 // The declaration.
6074 auto *D = M.first;
6075 // The component lists.
6076 auto CL = M.second;
6077
6078 // Initialize the entry.
6079 *UDI = D;
6080 ++UDI;
6081
6082 *DNLI = CL.size();
6083 ++DNLI;
6084
6085 // Obtain the cumulative sizes and concatenate all the components in the
6086 // reserved storage.
6087 for (auto C : CL) {
6088 // Accumulate with the previous size.
6089 PrevSize += C.size();
6090
6091 // Save the size.
6092 *CLSI = PrevSize;
6093 ++CLSI;
6094
6095 // Append components after the current components iterator.
6096 CI = llvm::copy(C, CI);
6097 }
6098 }
6099 }
6100
6101 /// Set the nested name specifier of associated user-defined mapper.
6103 MapperQualifierLoc = NNSL;
6104 }
6105
6106 /// Set the name of associated user-defined mapper.
6108 MapperIdInfo = MapperId;
6109 }
6110
6111 /// Get the user-defined mapper references that are in the trailing objects of
6112 /// the class.
6114 assert(SupportsMapper &&
6115 "Must be a clause that is possible to have user-defined mappers");
6117 static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
6120 }
6121
6122 /// Get the user-defined mappers references that are in the trailing objects
6123 /// of the class.
6125 assert(SupportsMapper &&
6126 "Must be a clause that is possible to have user-defined mappers");
6127 return ArrayRef<Expr *>(
6128 static_cast<const T *>(this)->template getTrailingObjects<Expr *>() +
6131 }
6132
6133 /// Set the user-defined mappers that are in the trailing objects of the
6134 /// class.
6136 assert(DMDs.size() == OMPVarListClause<T>::varlist_size() &&
6137 "Unexpected number of user-defined mappers.");
6138 assert(SupportsMapper &&
6139 "Must be a clause that is possible to have user-defined mappers");
6140 llvm::copy(DMDs, getUDMapperRefs().begin());
6141 }
6142
6143public:
6144 /// Return the number of unique base declarations in this clause.
6145 unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
6146
6147 /// Return the number of lists derived from the clause expressions.
6148 unsigned getTotalComponentListNum() const { return NumComponentLists; }
6149
6150 /// Return the total number of components in all lists derived from the
6151 /// clause.
6152 unsigned getTotalComponentsNum() const { return NumComponents; }
6153
6154 /// Gets the nested name specifier for associated user-defined mapper.
6156 return MapperQualifierLoc;
6157 }
6158
6159 /// Gets the name info for associated user-defined mapper.
6160 const DeclarationNameInfo &getMapperIdInfo() const { return MapperIdInfo; }
6161
6162 /// Iterator that browse the components by lists. It also allows
6163 /// browsing components of a single declaration.
6165 : public llvm::iterator_adaptor_base<
6166 const_component_lists_iterator,
6167 MappableExprComponentListRef::const_iterator,
6168 std::forward_iterator_tag, MappableComponent, ptrdiff_t,
6169 MappableComponent, MappableComponent> {
6170 // The declaration the iterator currently refers to.
6172
6173 // The list number associated with the current declaration.
6174 ArrayRef<unsigned>::iterator NumListsCur;
6175
6176 // Whether this clause is possible to have user-defined mappers associated.
6177 const bool SupportsMapper;
6178
6179 // The user-defined mapper associated with the current declaration.
6181
6182 // Remaining lists for the current declaration.
6183 unsigned RemainingLists = 0;
6184
6185 // The cumulative size of the previous list, or zero if there is no previous
6186 // list.
6187 unsigned PrevListSize = 0;
6188
6189 // The cumulative sizes of the current list - it will delimit the remaining
6190 // range of interest.
6193
6194 // Iterator to the end of the components storage.
6195 MappableExprComponentListRef::const_iterator End;
6196
6197 public:
6198 /// Construct an iterator that scans all lists.
6200 ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
6201 ArrayRef<unsigned> CumulativeListSizes,
6202 MappableExprComponentListRef Components, bool SupportsMapper,
6203 ArrayRef<Expr *> Mappers)
6204 : const_component_lists_iterator::iterator_adaptor_base(
6205 Components.begin()),
6206 DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
6207 SupportsMapper(SupportsMapper),
6208 ListSizeCur(CumulativeListSizes.begin()),
6209 ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
6210 assert(UniqueDecls.size() == DeclsListNum.size() &&
6211 "Inconsistent number of declarations and list sizes!");
6212 if (!DeclsListNum.empty())
6213 RemainingLists = *NumListsCur;
6214 if (SupportsMapper)
6215 MapperCur = Mappers.begin();
6216 }
6217
6218 /// Construct an iterator that scan lists for a given declaration \a
6219 /// Declaration.
6221 const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
6222 ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
6223 MappableExprComponentListRef Components, bool SupportsMapper,
6224 ArrayRef<Expr *> Mappers)
6225 : const_component_lists_iterator(UniqueDecls, DeclsListNum,
6226 CumulativeListSizes, Components,
6227 SupportsMapper, Mappers) {
6228 // Look for the desired declaration. While we are looking for it, we
6229 // update the state so that we know the component where a given list
6230 // starts.
6231 for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
6232 if (*DeclCur == Declaration)
6233 break;
6234
6235 assert(*NumListsCur > 0 && "No lists associated with declaration??");
6236
6237 // Skip the lists associated with the current declaration, but save the
6238 // last list size that was skipped.
6239 std::advance(ListSizeCur, *NumListsCur - 1);
6240 PrevListSize = *ListSizeCur;
6241 ++ListSizeCur;
6242
6243 if (SupportsMapper)
6244 ++MapperCur;
6245 }
6246
6247 // If we didn't find any declaration, advance the iterator to after the
6248 // last component and set remaining lists to zero.
6249 if (ListSizeCur == CumulativeListSizes.end()) {
6250 this->I = End;
6251 RemainingLists = 0u;
6252 return;
6253 }
6254
6255 // Set the remaining lists with the total number of lists of the current
6256 // declaration.
6257 RemainingLists = *NumListsCur;
6258
6259 // Adjust the list size end iterator to the end of the relevant range.
6260 ListSizeEnd = ListSizeCur;
6261 std::advance(ListSizeEnd, RemainingLists);
6262
6263 // Given that the list sizes are cumulative, the index of the component
6264 // that start the list is the size of the previous list.
6265 std::advance(this->I, PrevListSize);
6266 }
6267
6268 // Return the array with the current list. The sizes are cumulative, so the
6269 // array size is the difference between the current size and previous one.
6270 std::tuple<const ValueDecl *, MappableExprComponentListRef,
6271 const ValueDecl *>
6272 operator*() const {
6273 assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
6274 const ValueDecl *Mapper = nullptr;
6275 if (SupportsMapper && *MapperCur)
6276 Mapper = cast<ValueDecl>(cast<DeclRefExpr>(*MapperCur)->getDecl());
6277 return std::make_tuple(
6278 *DeclCur,
6279 MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize),
6280 Mapper);
6281 }
6282 std::tuple<const ValueDecl *, MappableExprComponentListRef,
6283 const ValueDecl *>
6284 operator->() const {
6285 return **this;
6286 }
6287
6288 // Skip the components of the current list.
6290 assert(ListSizeCur != ListSizeEnd && RemainingLists &&
6291 "Invalid iterator!");
6292
6293 // If we don't have more lists just skip all the components. Otherwise,
6294 // advance the iterator by the number of components in the current list.
6295 if (std::next(ListSizeCur) == ListSizeEnd) {
6296 this->I = End;
6297 RemainingLists = 0;
6298 } else {
6299 std::advance(this->I, *ListSizeCur - PrevListSize);
6300 PrevListSize = *ListSizeCur;
6301
6302 // We are done with a declaration, move to the next one.
6303 if (!(--RemainingLists)) {
6304 ++DeclCur;
6305 ++NumListsCur;
6306 RemainingLists = *NumListsCur;
6307 assert(RemainingLists && "No lists in the following declaration??");
6308 }
6309 }
6310
6311 ++ListSizeCur;
6312 if (SupportsMapper)
6313 ++MapperCur;
6314 return *this;
6315 }
6316 };
6317
6319 llvm::iterator_range<const_component_lists_iterator>;
6320
6321 /// Iterators for all component lists.
6338
6339 /// Iterators for component lists associated with the provided
6340 /// declaration.
6341 const_component_lists_iterator
6345 getComponentListSizesRef(), getComponentsRef(), SupportsMapper,
6346 SupportsMapper ? getUDMapperRefs() : ArrayRef<Expr *>());
6347 }
6354
6355 /// Iterators to access all the declarations, number of lists, list sizes, and
6356 /// components.
6358 using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>;
6359
6361 auto A = getUniqueDeclsRef();
6362 return const_all_decls_range(A.begin(), A.end());
6363 }
6364
6367 llvm::iterator_range<const_all_num_lists_iterator>;
6368
6370 auto A = getDeclNumListsRef();
6371 return const_all_num_lists_range(A.begin(), A.end());
6372 }
6373
6376 llvm::iterator_range<const_all_lists_sizes_iterator>;
6377
6379 auto A = getComponentListSizesRef();
6380 return const_all_lists_sizes_range(A.begin(), A.end());
6381 }
6382
6385 llvm::iterator_range<const_all_components_iterator>;
6386
6388 auto A = getComponentsRef();
6389 return const_all_components_range(A.begin(), A.end());
6390 }
6391
6394 using mapperlist_range = llvm::iterator_range<mapperlist_iterator>;
6396 llvm::iterator_range<mapperlist_const_iterator>;
6397
6401 return getUDMapperRefs().begin();
6402 }
6404 return getUDMapperRefs().end();
6405 }
6412};
6413
6414/// This represents clause 'map' in the '#pragma omp ...'
6415/// directives.
6416///
6417/// \code
6418/// #pragma omp target map(a,b)
6419/// \endcode
6420/// In this example directive '#pragma omp target' has clause 'map'
6421/// with the variables 'a' and 'b'.
6422class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
6423 private llvm::TrailingObjects<
6424 OMPMapClause, Expr *, ValueDecl *, unsigned,
6425 OMPClauseMappableExprCommon::MappableComponent> {
6426 friend class OMPClauseReader;
6427 friend OMPMappableExprListClause;
6428 friend OMPVarListClause;
6429 friend TrailingObjects;
6430
6431 /// Define the sizes of each trailing object array except the last one. This
6432 /// is required for TrailingObjects to work properly.
6433 size_t numTrailingObjects(OverloadToken<Expr *>) const {
6434 // There are varlist_size() of expressions, and varlist_size() of
6435 // user-defined mappers.
6436 return 2 * varlist_size() + 1;
6437 }
6438 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
6439 return getUniqueDeclarationsNum();
6440 }
6441 size_t numTrailingObjects(OverloadToken<unsigned>) const {
6443 }
6444
6445private:
6446 /// Map-type-modifiers for the 'map' clause.
6452
6453 /// Location of map-type-modifiers for the 'map' clause.
6454 SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers];
6455
6456 /// Map type for the 'map' clause.
6458
6459 /// Is this an implicit map type or not.
6460 bool MapTypeIsImplicit = false;
6461
6462 /// Location of the map type.
6463 SourceLocation MapLoc;
6464
6465 /// Colon location.
6466 SourceLocation ColonLoc;
6467
6468 /// Build a clause for \a NumVars listed expressions, \a
6469 /// NumUniqueDeclarations declarations, \a NumComponentLists total component
6470 /// lists, and \a NumComponents total expression components.
6471 ///
6472 /// \param MapModifiers Map-type-modifiers.
6473 /// \param MapModifiersLoc Locations of map-type-modifiers.
6474 /// \param MapperQualifierLoc C++ nested name specifier for the associated
6475 /// user-defined mapper.
6476 /// \param MapperIdInfo The identifier of associated user-defined mapper.
6477 /// \param MapType Map type.
6478 /// \param MapTypeIsImplicit Map type is inferred implicitly.
6479 /// \param MapLoc Location of the map type.
6480 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6481 /// StartLoc: starting location of the clause (the clause keyword); 2)
6482 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6483 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6484 /// NumVars: number of expressions listed in this clause; 2)
6485 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6486 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6487 /// NumComponents: total number of expression components in the clause.
6488 explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers,
6489 ArrayRef<SourceLocation> MapModifiersLoc,
6490 NestedNameSpecifierLoc MapperQualifierLoc,
6491 DeclarationNameInfo MapperIdInfo,
6492 OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
6493 SourceLocation MapLoc, const OMPVarListLocTy &Locs,
6494 const OMPMappableExprListSizeTy &Sizes)
6495 : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes,
6496 /*SupportsMapper=*/true, &MapperQualifierLoc,
6497 &MapperIdInfo),
6498 MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {
6499 assert(std::size(MapTypeModifiers) == MapModifiers.size() &&
6500 "Unexpected number of map type modifiers.");
6501 llvm::copy(MapModifiers, std::begin(MapTypeModifiers));
6502
6503 assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() &&
6504 "Unexpected number of map type modifier locations.");
6505 llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc));
6506 }
6507
6508 /// Build an empty clause.
6509 ///
6510 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6511 /// NumVars: number of expressions listed in this clause; 2)
6512 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6513 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6514 /// NumComponents: total number of expression components in the clause.
6515 explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes)
6516 : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes,
6517 /*SupportsMapper=*/true) {}
6518
6519 /// Set map-type-modifier for the clause.
6520 ///
6521 /// \param I index for map-type-modifier.
6522 /// \param T map-type-modifier for the clause.
6523 void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) {
6524 assert(I < NumberOfOMPMapClauseModifiers &&
6525 "Unexpected index to store map type modifier, exceeds array size.");
6526 MapTypeModifiers[I] = T;
6527 }
6528
6529 /// Set location for the map-type-modifier.
6530 ///
6531 /// \param I index for map-type-modifier location.
6532 /// \param TLoc map-type-modifier location.
6533 void setMapTypeModifierLoc(unsigned I, SourceLocation TLoc) {
6534 assert(I < NumberOfOMPMapClauseModifiers &&
6535 "Index to store map type modifier location exceeds array size.");
6536 MapTypeModifiersLoc[I] = TLoc;
6537 }
6538
6539 /// Set type for the clause.
6540 ///
6541 /// \param T Type for the clause.
6542 void setMapType(OpenMPMapClauseKind T) { MapType = T; }
6543
6544 /// Set type location.
6545 ///
6546 /// \param TLoc Type location.
6547 void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
6548
6549 /// Set colon location.
6550 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
6551
6552 /// Set iterator modifier.
6553 void setIteratorModifier(Expr *IteratorModifier) {
6554 getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier;
6555 }
6556
6557public:
6558 /// Creates clause with a list of variables \a VL.
6559 ///
6560 /// \param C AST context.
6561 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6562 /// StartLoc: starting location of the clause (the clause keyword); 2)
6563 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6564 /// \param Vars The original expression used in the clause.
6565 /// \param Declarations Declarations used in the clause.
6566 /// \param ComponentLists Component lists used in the clause.
6567 /// \param UDMapperRefs References to user-defined mappers associated with
6568 /// expressions used in the clause.
6569 /// \param IteratorModifier Iterator modifier.
6570 /// \param MapModifiers Map-type-modifiers.
6571 /// \param MapModifiersLoc Location of map-type-modifiers.
6572 /// \param UDMQualifierLoc C++ nested name specifier for the associated
6573 /// user-defined mapper.
6574 /// \param MapperId The identifier of associated user-defined mapper.
6575 /// \param Type Map type.
6576 /// \param TypeIsImplicit Map type is inferred implicitly.
6577 /// \param TypeLoc Location of the map type.
6578 static OMPMapClause *
6579 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
6580 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
6581 MappableExprComponentListsRef ComponentLists,
6582 ArrayRef<Expr *> UDMapperRefs, Expr *IteratorModifier,
6583 ArrayRef<OpenMPMapModifierKind> MapModifiers,
6584 ArrayRef<SourceLocation> MapModifiersLoc,
6585 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
6586 OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc);
6587
6588 /// Creates an empty clause with the place for \a NumVars original
6589 /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
6590 /// lists, and \a NumComponents expression components.
6591 ///
6592 /// \param C AST context.
6593 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6594 /// NumVars: number of expressions listed in this clause; 2)
6595 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6596 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6597 /// NumComponents: total number of expression components in the clause.
6598 static OMPMapClause *CreateEmpty(const ASTContext &C,
6599 const OMPMappableExprListSizeTy &Sizes);
6600
6601 /// Fetches Expr * of iterator modifier.
6603 return getTrailingObjects<Expr *>()[2 * varlist_size()];
6604 }
6605
6606 /// Fetches mapping kind for the clause.
6607 OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
6608
6609 /// Is this an implicit map type?
6610 /// We have to capture 'IsMapTypeImplicit' from the parser for more
6611 /// informative error messages. It helps distinguish map(r) from
6612 /// map(tofrom: r), which is important to print more helpful error
6613 /// messages for some target directives.
6614 bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
6615
6616 /// Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
6617 ///
6618 /// \param Cnt index for map-type-modifier.
6619 OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY {
6620 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6621 "Requested modifier exceeds the total number of modifiers.");
6622 return MapTypeModifiers[Cnt];
6623 }
6624
6625 /// Fetches the map-type-modifier location at 'Cnt' index of array of
6626 /// modifiers' locations.
6627 ///
6628 /// \param Cnt index for map-type-modifier location.
6629 SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY {
6630 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6631 "Requested modifier location exceeds total number of modifiers.");
6632 return MapTypeModifiersLoc[Cnt];
6633 }
6634
6635 /// Fetches ArrayRef of map-type-modifiers.
6637 return MapTypeModifiers;
6638 }
6639
6640 /// Fetches ArrayRef of location of map-type-modifiers.
6642 return MapTypeModifiersLoc;
6643 }
6644
6645 /// Fetches location of clause mapping kind.
6646 SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
6647
6648 /// Get colon location.
6649 SourceLocation getColonLoc() const { return ColonLoc; }
6650
6652 return child_range(
6653 reinterpret_cast<Stmt **>(varlist_begin()),
6654 reinterpret_cast<Stmt **>(varlist_end()));
6655 }
6656
6658 auto Children = const_cast<OMPMapClause *>(this)->children();
6659 return const_child_range(Children.begin(), Children.end());
6660 }
6661
6663 if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom)
6664 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6665 reinterpret_cast<Stmt **>(varlist_end()));
6667 }
6669 auto Children = const_cast<OMPMapClause *>(this)->used_children();
6670 return const_child_range(Children.begin(), Children.end());
6671 }
6672
6673
6674 static bool classof(const OMPClause *T) {
6675 return T->getClauseKind() == llvm::omp::OMPC_map;
6676 }
6677};
6678
6679/// This represents 'num_teams' clause in the '#pragma omp ...'
6680/// directive.
6681///
6682/// \code
6683/// #pragma omp teams num_teams(n)
6684/// \endcode
6685/// In this example directive '#pragma omp teams' has clause 'num_teams'
6686/// with single expression 'n'.
6687///
6688/// When 'ompx_bare' clause exists on a 'target' directive, 'num_teams' clause
6689/// can accept up to three expressions.
6690///
6691/// \code
6692/// #pragma omp target teams ompx_bare num_teams(x, y, z)
6693/// \endcode
6694class OMPNumTeamsClause final
6695 : public OMPVarListClause<OMPNumTeamsClause>,
6696 public OMPClauseWithPreInit,
6697 private llvm::TrailingObjects<OMPNumTeamsClause, Expr *> {
6698 friend OMPVarListClause;
6699 friend TrailingObjects;
6700
6701 /// Location of '('.
6702 SourceLocation LParenLoc;
6703
6704 OMPNumTeamsClause(const ASTContext &C, SourceLocation StartLoc,
6705 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
6706 : OMPVarListClause(llvm::omp::OMPC_num_teams, StartLoc, LParenLoc, EndLoc,
6707 N),
6708 OMPClauseWithPreInit(this) {}
6709
6710 /// Build an empty clause.
6711 OMPNumTeamsClause(unsigned N)
6712 : OMPVarListClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6714 OMPClauseWithPreInit(this) {}
6715
6716public:
6717 /// Creates clause with a list of variables \a VL.
6718 ///
6719 /// \param C AST context.
6720 /// \param StartLoc Starting location of the clause.
6721 /// \param LParenLoc Location of '('.
6722 /// \param EndLoc Ending location of the clause.
6723 /// \param VL List of references to the variables.
6724 /// \param PreInit
6725 static OMPNumTeamsClause *
6726 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6727 SourceLocation StartLoc, SourceLocation LParenLoc,
6728 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6729
6730 /// Creates an empty clause with \a N variables.
6731 ///
6732 /// \param C AST context.
6733 /// \param N The number of variables.
6734 static OMPNumTeamsClause *CreateEmpty(const ASTContext &C, unsigned N);
6735
6736 /// Sets the location of '('.
6737 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6738
6739 /// Returns the location of '('.
6740 SourceLocation getLParenLoc() const { return LParenLoc; }
6741
6742 /// Return NumTeams expressions.
6744
6745 /// Return NumTeams expressions.
6747 return const_cast<OMPNumTeamsClause *>(this)->getNumTeams();
6748 }
6749
6751 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6752 reinterpret_cast<Stmt **>(varlist_end()));
6753 }
6754
6756 auto Children = const_cast<OMPNumTeamsClause *>(this)->children();
6757 return const_child_range(Children.begin(), Children.end());
6758 }
6759
6766
6767 static bool classof(const OMPClause *T) {
6768 return T->getClauseKind() == llvm::omp::OMPC_num_teams;
6769 }
6770};
6771
6772/// This represents 'thread_limit' clause in the '#pragma omp ...'
6773/// directive.
6774///
6775/// \code
6776/// #pragma omp teams thread_limit(n)
6777/// \endcode
6778/// In this example directive '#pragma omp teams' has clause 'thread_limit'
6779/// with single expression 'n'.
6780///
6781/// When 'ompx_bare' clause exists on a 'target' directive, 'thread_limit'
6782/// clause can accept up to three expressions.
6783///
6784/// \code
6785/// #pragma omp target teams ompx_bare thread_limit(x, y, z)
6786/// \endcode
6787class OMPThreadLimitClause final
6788 : public OMPVarListClause<OMPThreadLimitClause>,
6789 public OMPClauseWithPreInit,
6790 private llvm::TrailingObjects<OMPThreadLimitClause, Expr *> {
6791 friend OMPVarListClause;
6792 friend TrailingObjects;
6793
6794 /// Location of '('.
6795 SourceLocation LParenLoc;
6796
6797 OMPThreadLimitClause(const ASTContext &C, SourceLocation StartLoc,
6798 SourceLocation LParenLoc, SourceLocation EndLoc,
6799 unsigned N)
6800 : OMPVarListClause(llvm::omp::OMPC_thread_limit, StartLoc, LParenLoc,
6801 EndLoc, N),
6802 OMPClauseWithPreInit(this) {}
6803
6804 /// Build an empty clause.
6805 OMPThreadLimitClause(unsigned N)
6806 : OMPVarListClause(llvm::omp::OMPC_thread_limit, SourceLocation(),
6808 OMPClauseWithPreInit(this) {}
6809
6810public:
6811 /// Creates clause with a list of variables \a VL.
6812 ///
6813 /// \param C AST context.
6814 /// \param StartLoc Starting location of the clause.
6815 /// \param LParenLoc Location of '('.
6816 /// \param EndLoc Ending location of the clause.
6817 /// \param VL List of references to the variables.
6818 /// \param PreInit
6819 static OMPThreadLimitClause *
6820 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6821 SourceLocation StartLoc, SourceLocation LParenLoc,
6822 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6823
6824 /// Creates an empty clause with \a N variables.
6825 ///
6826 /// \param C AST context.
6827 /// \param N The number of variables.
6828 static OMPThreadLimitClause *CreateEmpty(const ASTContext &C, unsigned N);
6829
6830 /// Sets the location of '('.
6831 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6832
6833 /// Returns the location of '('.
6834 SourceLocation getLParenLoc() const { return LParenLoc; }
6835
6836 /// Return ThreadLimit expressions.
6838
6839 /// Return ThreadLimit expressions.
6841 return const_cast<OMPThreadLimitClause *>(this)->getThreadLimit();
6842 }
6843
6845 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6846 reinterpret_cast<Stmt **>(varlist_end()));
6847 }
6848
6850 auto Children = const_cast<OMPThreadLimitClause *>(this)->children();
6851 return const_child_range(Children.begin(), Children.end());
6852 }
6853
6860
6861 static bool classof(const OMPClause *T) {
6862 return T->getClauseKind() == llvm::omp::OMPC_thread_limit;
6863 }
6864};
6865
6866/// This represents 'priority' clause in the '#pragma omp ...'
6867/// directive.
6868///
6869/// \code
6870/// #pragma omp task priority(n)
6871/// \endcode
6872/// In this example directive '#pragma omp teams' has clause 'priority' with
6873/// single expression 'n'.
6875 friend class OMPClauseReader;
6876
6877 /// Location of '('.
6878 SourceLocation LParenLoc;
6879
6880 /// Priority number.
6881 Stmt *Priority = nullptr;
6882
6883 /// Set the Priority number.
6884 ///
6885 /// \param E Priority number.
6886 void setPriority(Expr *E) { Priority = E; }
6887
6888public:
6889 /// Build 'priority' clause.
6890 ///
6891 /// \param Priority Expression associated with this clause.
6892 /// \param HelperPriority Helper priority for the construct.
6893 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6894 /// clause must be captured.
6895 /// \param StartLoc Starting location of the clause.
6896 /// \param LParenLoc Location of '('.
6897 /// \param EndLoc Ending location of the clause.
6898 OMPPriorityClause(Expr *Priority, Stmt *HelperPriority,
6899 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
6900 SourceLocation LParenLoc, SourceLocation EndLoc)
6901 : OMPClause(llvm::omp::OMPC_priority, StartLoc, EndLoc),
6902 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Priority(Priority) {
6903 setPreInitStmt(HelperPriority, CaptureRegion);
6904 }
6905
6906 /// Build an empty clause.
6908 : OMPClause(llvm::omp::OMPC_priority, SourceLocation(), SourceLocation()),
6909 OMPClauseWithPreInit(this) {}
6910
6911 /// Sets the location of '('.
6912 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6913
6914 /// Returns the location of '('.
6915 SourceLocation getLParenLoc() const { return LParenLoc; }
6916
6917 /// Return Priority number.
6918 Expr *getPriority() { return cast<Expr>(Priority); }
6919
6920 /// Return Priority number.
6921 Expr *getPriority() const { return cast<Expr>(Priority); }
6922
6923 child_range children() { return child_range(&Priority, &Priority + 1); }
6924
6926 return const_child_range(&Priority, &Priority + 1);
6927 }
6928
6931 auto Children = const_cast<OMPPriorityClause *>(this)->used_children();
6932 return const_child_range(Children.begin(), Children.end());
6933 }
6934
6935 static bool classof(const OMPClause *T) {
6936 return T->getClauseKind() == llvm::omp::OMPC_priority;
6937 }
6938};
6939
6940/// This represents 'grainsize' clause in the '#pragma omp ...'
6941/// directive.
6942///
6943/// \code
6944/// #pragma omp taskloop grainsize(4)
6945/// \endcode
6946/// In this example directive '#pragma omp taskloop' has clause 'grainsize'
6947/// with single expression '4'.
6949 friend class OMPClauseReader;
6950
6951 /// Location of '('.
6952 SourceLocation LParenLoc;
6953
6954 /// Modifiers for 'grainsize' clause.
6956
6957 /// Location of the modifier.
6958 SourceLocation ModifierLoc;
6959
6960 /// Safe iteration space distance.
6961 Stmt *Grainsize = nullptr;
6962
6963 /// Set safelen.
6964 void setGrainsize(Expr *Size) { Grainsize = Size; }
6965
6966 /// Sets modifier.
6967 void setModifier(OpenMPGrainsizeClauseModifier M) { Modifier = M; }
6968
6969 /// Sets modifier location.
6970 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
6971
6972public:
6973 /// Build 'grainsize' clause.
6974 ///
6975 /// \param Modifier Clause modifier.
6976 /// \param Size Expression associated with this clause.
6977 /// \param HelperSize Helper grainsize for the construct.
6978 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6979 /// clause must be captured.
6980 /// \param StartLoc Starting location of the clause.
6981 /// \param ModifierLoc Modifier location.
6982 /// \param LParenLoc Location of '('.
6983 /// \param EndLoc Ending location of the clause.
6985 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
6986 SourceLocation StartLoc, SourceLocation LParenLoc,
6987 SourceLocation ModifierLoc, SourceLocation EndLoc)
6988 : OMPClause(llvm::omp::OMPC_grainsize, StartLoc, EndLoc),
6989 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
6990 ModifierLoc(ModifierLoc), Grainsize(Size) {
6991 setPreInitStmt(HelperSize, CaptureRegion);
6992 }
6993
6994 /// Build an empty clause.
6996 : OMPClause(llvm::omp::OMPC_grainsize, SourceLocation(),
6997 SourceLocation()),
6998 OMPClauseWithPreInit(this) {}
6999
7000 /// Sets the location of '('.
7001 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7002
7003 /// Returns the location of '('.
7004 SourceLocation getLParenLoc() const { return LParenLoc; }
7005
7006 /// Return safe iteration space distance.
7007 Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
7008
7009 /// Gets modifier.
7010 OpenMPGrainsizeClauseModifier getModifier() const { return Modifier; }
7011
7012 /// Gets modifier location.
7013 SourceLocation getModifierLoc() const { return ModifierLoc; }
7014
7015 child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
7016
7018 return const_child_range(&Grainsize, &Grainsize + 1);
7019 }
7020
7023 auto Children = const_cast<OMPGrainsizeClause *>(this)->used_children();
7024 return const_child_range(Children.begin(), Children.end());
7025 }
7026
7027 static bool classof(const OMPClause *T) {
7028 return T->getClauseKind() == llvm::omp::OMPC_grainsize;
7029 }
7030};
7031
7032/// This represents 'nogroup' clause in the '#pragma omp ...' directive.
7033///
7034/// \code
7035/// #pragma omp taskloop nogroup
7036/// \endcode
7037/// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
7039public:
7040 /// Build 'nogroup' clause.
7041 ///
7042 /// \param StartLoc Starting location of the clause.
7043 /// \param EndLoc Ending location of the clause.
7045 : OMPClause(llvm::omp::OMPC_nogroup, StartLoc, EndLoc) {}
7046
7047 /// Build an empty clause.
7049 : OMPClause(llvm::omp::OMPC_nogroup, SourceLocation(), SourceLocation()) {
7050 }
7051
7055
7059
7066
7067 static bool classof(const OMPClause *T) {
7068 return T->getClauseKind() == llvm::omp::OMPC_nogroup;
7069 }
7070};
7071
7072/// This represents 'num_tasks' clause in the '#pragma omp ...'
7073/// directive.
7074///
7075/// \code
7076/// #pragma omp taskloop num_tasks(4)
7077/// \endcode
7078/// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
7079/// with single expression '4'.
7081 friend class OMPClauseReader;
7082
7083 /// Location of '('.
7084 SourceLocation LParenLoc;
7085
7086 /// Modifiers for 'num_tasks' clause.
7088
7089 /// Location of the modifier.
7090 SourceLocation ModifierLoc;
7091
7092 /// Safe iteration space distance.
7093 Stmt *NumTasks = nullptr;
7094
7095 /// Set safelen.
7096 void setNumTasks(Expr *Size) { NumTasks = Size; }
7097
7098 /// Sets modifier.
7099 void setModifier(OpenMPNumTasksClauseModifier M) { Modifier = M; }
7100
7101 /// Sets modifier location.
7102 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
7103
7104public:
7105 /// Build 'num_tasks' clause.
7106 ///
7107 /// \param Modifier Clause modifier.
7108 /// \param Size Expression associated with this clause.
7109 /// \param HelperSize Helper grainsize for the construct.
7110 /// \param CaptureRegion Innermost OpenMP region where expressions in this
7111 /// clause must be captured.
7112 /// \param StartLoc Starting location of the clause.
7113 /// \param EndLoc Ending location of the clause.
7114 /// \param ModifierLoc Modifier location.
7115 /// \param LParenLoc Location of '('.
7117 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
7118 SourceLocation StartLoc, SourceLocation LParenLoc,
7119 SourceLocation ModifierLoc, SourceLocation EndLoc)
7120 : OMPClause(llvm::omp::OMPC_num_tasks, StartLoc, EndLoc),
7121 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
7122 ModifierLoc(ModifierLoc), NumTasks(Size) {
7123 setPreInitStmt(HelperSize, CaptureRegion);
7124 }
7125
7126 /// Build an empty clause.
7128 : OMPClause(llvm::omp::OMPC_num_tasks, SourceLocation(),
7129 SourceLocation()),
7130 OMPClauseWithPreInit(this) {}
7131
7132 /// Sets the location of '('.
7133 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7134
7135 /// Returns the location of '('.
7136 SourceLocation getLParenLoc() const { return LParenLoc; }
7137
7138 /// Return safe iteration space distance.
7139 Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
7140
7141 /// Gets modifier.
7142 OpenMPNumTasksClauseModifier getModifier() const { return Modifier; }
7143
7144 /// Gets modifier location.
7145 SourceLocation getModifierLoc() const { return ModifierLoc; }
7146
7147 child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
7148
7150 return const_child_range(&NumTasks, &NumTasks + 1);
7151 }
7152
7155 auto Children = const_cast<OMPNumTasksClause *>(this)->used_children();
7156 return const_child_range(Children.begin(), Children.end());
7157 }
7158
7159 static bool classof(const OMPClause *T) {
7160 return T->getClauseKind() == llvm::omp::OMPC_num_tasks;
7161 }
7162};
7163
7164/// This represents 'hint' clause in the '#pragma omp ...' directive.
7165///
7166/// \code
7167/// #pragma omp critical (name) hint(6)
7168/// \endcode
7169/// In this example directive '#pragma omp critical' has name 'name' and clause
7170/// 'hint' with argument '6'.
7171class OMPHintClause : public OMPClause {
7172 friend class OMPClauseReader;
7173
7174 /// Location of '('.
7175 SourceLocation LParenLoc;
7176
7177 /// Hint expression of the 'hint' clause.
7178 Stmt *Hint = nullptr;
7179
7180 /// Set hint expression.
7181 void setHint(Expr *H) { Hint = H; }
7182
7183public:
7184 /// Build 'hint' clause with expression \a Hint.
7185 ///
7186 /// \param Hint Hint expression.
7187 /// \param StartLoc Starting location of the clause.
7188 /// \param LParenLoc Location of '('.
7189 /// \param EndLoc Ending location of the clause.
7191 SourceLocation EndLoc)
7192 : OMPClause(llvm::omp::OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
7193 Hint(Hint) {}
7194
7195 /// Build an empty clause.
7197 : OMPClause(llvm::omp::OMPC_hint, SourceLocation(), SourceLocation()) {}
7198
7199 /// Sets the location of '('.
7200 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7201
7202 /// Returns the location of '('.
7203 SourceLocation getLParenLoc() const { return LParenLoc; }
7204
7205 /// Returns number of threads.
7206 Expr *getHint() const { return cast_or_null<Expr>(Hint); }
7207
7208 child_range children() { return child_range(&Hint, &Hint + 1); }
7209
7211 return const_child_range(&Hint, &Hint + 1);
7212 }
7213
7220
7221 static bool classof(const OMPClause *T) {
7222 return T->getClauseKind() == llvm::omp::OMPC_hint;
7223 }
7224};
7225
7226/// This represents 'dist_schedule' clause in the '#pragma omp ...'
7227/// directive.
7228///
7229/// \code
7230/// #pragma omp distribute dist_schedule(static, 3)
7231/// \endcode
7232/// In this example directive '#pragma omp distribute' has 'dist_schedule'
7233/// clause with arguments 'static' and '3'.
7235 friend class OMPClauseReader;
7236
7237 /// Location of '('.
7238 SourceLocation LParenLoc;
7239
7240 /// A kind of the 'schedule' clause.
7242
7243 /// Start location of the schedule kind in source code.
7244 SourceLocation KindLoc;
7245
7246 /// Location of ',' (if any).
7247 SourceLocation CommaLoc;
7248
7249 /// Chunk size.
7250 Expr *ChunkSize = nullptr;
7251
7252 /// Set schedule kind.
7253 ///
7254 /// \param K Schedule kind.
7255 void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
7256
7257 /// Sets the location of '('.
7258 ///
7259 /// \param Loc Location of '('.
7260 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7261
7262 /// Set schedule kind start location.
7263 ///
7264 /// \param KLoc Schedule kind location.
7265 void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
7266
7267 /// Set location of ','.
7268 ///
7269 /// \param Loc Location of ','.
7270 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
7271
7272 /// Set chunk size.
7273 ///
7274 /// \param E Chunk size.
7275 void setChunkSize(Expr *E) { ChunkSize = E; }
7276
7277public:
7278 /// Build 'dist_schedule' clause with schedule kind \a Kind and chunk
7279 /// size expression \a ChunkSize.
7280 ///
7281 /// \param StartLoc Starting location of the clause.
7282 /// \param LParenLoc Location of '('.
7283 /// \param KLoc Starting location of the argument.
7284 /// \param CommaLoc Location of ','.
7285 /// \param EndLoc Ending location of the clause.
7286 /// \param Kind DistSchedule kind.
7287 /// \param ChunkSize Chunk size.
7288 /// \param HelperChunkSize Helper chunk size for combined directives.
7290 SourceLocation KLoc, SourceLocation CommaLoc,
7291 SourceLocation EndLoc,
7292 OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
7293 Stmt *HelperChunkSize)
7294 : OMPClause(llvm::omp::OMPC_dist_schedule, StartLoc, EndLoc),
7295 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
7296 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
7297 setPreInitStmt(HelperChunkSize);
7298 }
7299
7300 /// Build an empty clause.
7302 : OMPClause(llvm::omp::OMPC_dist_schedule, SourceLocation(),
7303 SourceLocation()),
7304 OMPClauseWithPreInit(this) {}
7305
7306 /// Get kind of the clause.
7308
7309 /// Get location of '('.
7310 SourceLocation getLParenLoc() { return LParenLoc; }
7311
7312 /// Get kind location.
7314
7315 /// Get location of ','.
7316 SourceLocation getCommaLoc() { return CommaLoc; }
7317
7318 /// Get chunk size.
7319 Expr *getChunkSize() { return ChunkSize; }
7320
7321 /// Get chunk size.
7322 const Expr *getChunkSize() const { return ChunkSize; }
7323
7325 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
7326 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
7327 }
7328
7330 auto Children = const_cast<OMPDistScheduleClause *>(this)->children();
7331 return const_child_range(Children.begin(), Children.end());
7332 }
7333
7340
7341 static bool classof(const OMPClause *T) {
7342 return T->getClauseKind() == llvm::omp::OMPC_dist_schedule;
7343 }
7344};
7345
7346/// This represents 'defaultmap' clause in the '#pragma omp ...' directive.
7347///
7348/// \code
7349/// #pragma omp target defaultmap(tofrom: scalar)
7350/// \endcode
7351/// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
7352/// 'scalar' with modifier 'tofrom'.
7354 friend class OMPClauseReader;
7355
7356 /// Location of '('.
7357 SourceLocation LParenLoc;
7358
7359 /// Modifiers for 'defaultmap' clause.
7361
7362 /// Locations of modifiers.
7363 SourceLocation ModifierLoc;
7364
7365 /// A kind of the 'defaultmap' clause.
7367
7368 /// Start location of the defaultmap kind in source code.
7369 SourceLocation KindLoc;
7370
7371 /// Set defaultmap kind.
7372 ///
7373 /// \param K Defaultmap kind.
7374 void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
7375
7376 /// Set the defaultmap modifier.
7377 ///
7378 /// \param M Defaultmap modifier.
7379 void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
7380 Modifier = M;
7381 }
7382
7383 /// Set location of the defaultmap modifier.
7384 void setDefaultmapModifierLoc(SourceLocation Loc) {
7385 ModifierLoc = Loc;
7386 }
7387
7388 /// Sets the location of '('.
7389 ///
7390 /// \param Loc Location of '('.
7391 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7392
7393 /// Set defaultmap kind start location.
7394 ///
7395 /// \param KLoc Defaultmap kind location.
7396 void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
7397
7398public:
7399 /// Build 'defaultmap' clause with defaultmap kind \a Kind
7400 ///
7401 /// \param StartLoc Starting location of the clause.
7402 /// \param LParenLoc Location of '('.
7403 /// \param KLoc Starting location of the argument.
7404 /// \param EndLoc Ending location of the clause.
7405 /// \param Kind Defaultmap kind.
7406 /// \param M The modifier applied to 'defaultmap' clause.
7407 /// \param MLoc Location of the modifier
7409 SourceLocation MLoc, SourceLocation KLoc,
7412 : OMPClause(llvm::omp::OMPC_defaultmap, StartLoc, EndLoc),
7413 LParenLoc(LParenLoc), Modifier(M), ModifierLoc(MLoc), Kind(Kind),
7414 KindLoc(KLoc) {}
7415
7416 /// Build an empty clause.
7418 : OMPClause(llvm::omp::OMPC_defaultmap, SourceLocation(),
7419 SourceLocation()) {}
7420
7421 /// Get kind of the clause.
7423
7424 /// Get the modifier of the clause.
7426 return Modifier;
7427 }
7428
7429 /// Get location of '('.
7430 SourceLocation getLParenLoc() { return LParenLoc; }
7431
7432 /// Get kind location.
7434
7435 /// Get the modifier location.
7437 return ModifierLoc;
7438 }
7439
7443
7447
7454
7455 static bool classof(const OMPClause *T) {
7456 return T->getClauseKind() == llvm::omp::OMPC_defaultmap;
7457 }
7458};
7459
7460/// This represents clause 'to' in the '#pragma omp ...'
7461/// directives.
7462///
7463/// \code
7464/// #pragma omp target update to(a,b)
7465/// \endcode
7466/// In this example directive '#pragma omp target update' has clause 'to'
7467/// with the variables 'a' and 'b'.
7468class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
7469 private llvm::TrailingObjects<
7470 OMPToClause, Expr *, ValueDecl *, unsigned,
7471 OMPClauseMappableExprCommon::MappableComponent> {
7472 friend class OMPClauseReader;
7473 friend OMPMappableExprListClause;
7474 friend OMPVarListClause;
7475 friend TrailingObjects;
7476
7477 /// Motion-modifiers for the 'to' clause.
7480
7481 /// Location of motion-modifiers for the 'to' clause.
7482 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7483
7484 /// Colon location.
7485 SourceLocation ColonLoc;
7486
7487 /// Build clause with number of variables \a NumVars.
7488 ///
7489 /// \param TheMotionModifiers Motion-modifiers.
7490 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7491 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7492 /// user-defined mapper.
7493 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7494 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7495 /// StartLoc: starting location of the clause (the clause keyword); 2)
7496 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7497 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7498 /// NumVars: number of expressions listed in this clause; 2)
7499 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7500 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7501 /// NumComponents: total number of expression components in the clause.
7502 explicit OMPToClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7503 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7504 NestedNameSpecifierLoc MapperQualifierLoc,
7505 DeclarationNameInfo MapperIdInfo,
7506 const OMPVarListLocTy &Locs,
7507 const OMPMappableExprListSizeTy &Sizes)
7508 : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
7509 /*SupportsMapper=*/true, &MapperQualifierLoc,
7510 &MapperIdInfo) {
7511 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7512 "Unexpected number of motion modifiers.");
7513 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7514
7515 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7516 "Unexpected number of motion modifier locations.");
7517 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7518 }
7519
7520 /// Build an empty clause.
7521 ///
7522 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7523 /// NumVars: number of expressions listed in this clause; 2)
7524 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7525 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7526 /// NumComponents: total number of expression components in the clause.
7527 explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes)
7528 : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
7529 /*SupportsMapper=*/true) {}
7530
7531 /// Set motion-modifier for the clause.
7532 ///
7533 /// \param I index for motion-modifier.
7534 /// \param T motion-modifier for the clause.
7535 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7536 assert(I < NumberOfOMPMotionModifiers &&
7537 "Unexpected index to store motion modifier, exceeds array size.");
7538 MotionModifiers[I] = T;
7539 }
7540
7541 /// Set location for the motion-modifier.
7542 ///
7543 /// \param I index for motion-modifier location.
7544 /// \param TLoc motion-modifier location.
7545 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7546 assert(I < NumberOfOMPMotionModifiers &&
7547 "Index to store motion modifier location exceeds array size.");
7548 MotionModifiersLoc[I] = TLoc;
7549 }
7550
7551 /// Set colon location.
7552 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7553
7554 /// Define the sizes of each trailing object array except the last one. This
7555 /// is required for TrailingObjects to work properly.
7556 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7557 // There are varlist_size() of expressions, and varlist_size() of
7558 // user-defined mappers.
7559 return 2 * varlist_size();
7560 }
7561 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7562 return getUniqueDeclarationsNum();
7563 }
7564 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7566 }
7567
7568public:
7569 /// Creates clause with a list of variables \a Vars.
7570 ///
7571 /// \param C AST context.
7572 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7573 /// StartLoc: starting location of the clause (the clause keyword); 2)
7574 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7575 /// \param Vars The original expression used in the clause.
7576 /// \param Declarations Declarations used in the clause.
7577 /// \param ComponentLists Component lists used in the clause.
7578 /// \param MotionModifiers Motion-modifiers.
7579 /// \param MotionModifiersLoc Location of motion-modifiers.
7580 /// \param UDMapperRefs References to user-defined mappers associated with
7581 /// expressions used in the clause.
7582 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7583 /// user-defined mapper.
7584 /// \param MapperId The identifier of associated user-defined mapper.
7585 static OMPToClause *Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7586 ArrayRef<Expr *> Vars,
7587 ArrayRef<ValueDecl *> Declarations,
7588 MappableExprComponentListsRef ComponentLists,
7589 ArrayRef<Expr *> UDMapperRefs,
7590 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7591 ArrayRef<SourceLocation> MotionModifiersLoc,
7592 NestedNameSpecifierLoc UDMQualifierLoc,
7593 DeclarationNameInfo MapperId);
7594
7595 /// Creates an empty clause with the place for \a NumVars variables.
7596 ///
7597 /// \param C AST context.
7598 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7599 /// NumVars: number of expressions listed in this clause; 2)
7600 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7601 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7602 /// NumComponents: total number of expression components in the clause.
7603 static OMPToClause *CreateEmpty(const ASTContext &C,
7604 const OMPMappableExprListSizeTy &Sizes);
7605
7606 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7607 ///
7608 /// \param Cnt index for motion-modifier.
7609 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7610 assert(Cnt < NumberOfOMPMotionModifiers &&
7611 "Requested modifier exceeds the total number of modifiers.");
7612 return MotionModifiers[Cnt];
7613 }
7614
7615 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7616 /// locations.
7617 ///
7618 /// \param Cnt index for motion-modifier location.
7619 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7620 assert(Cnt < NumberOfOMPMotionModifiers &&
7621 "Requested modifier location exceeds total number of modifiers.");
7622 return MotionModifiersLoc[Cnt];
7623 }
7624
7625 /// Fetches ArrayRef of motion-modifiers.
7627 return MotionModifiers;
7628 }
7629
7630 /// Fetches ArrayRef of location of motion-modifiers.
7632 return MotionModifiersLoc;
7633 }
7634
7635 /// Get colon location.
7636 SourceLocation getColonLoc() const { return ColonLoc; }
7637
7639 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7640 reinterpret_cast<Stmt **>(varlist_end()));
7641 }
7642
7644 auto Children = const_cast<OMPToClause *>(this)->children();
7645 return const_child_range(Children.begin(), Children.end());
7646 }
7647
7654
7655 static bool classof(const OMPClause *T) {
7656 return T->getClauseKind() == llvm::omp::OMPC_to;
7657 }
7658};
7659
7660/// This represents clause 'from' in the '#pragma omp ...'
7661/// directives.
7662///
7663/// \code
7664/// #pragma omp target update from(a,b)
7665/// \endcode
7666/// In this example directive '#pragma omp target update' has clause 'from'
7667/// with the variables 'a' and 'b'.
7668class OMPFromClause final
7669 : public OMPMappableExprListClause<OMPFromClause>,
7670 private llvm::TrailingObjects<
7671 OMPFromClause, Expr *, ValueDecl *, unsigned,
7672 OMPClauseMappableExprCommon::MappableComponent> {
7673 friend class OMPClauseReader;
7674 friend OMPMappableExprListClause;
7675 friend OMPVarListClause;
7676 friend TrailingObjects;
7677
7678 /// Motion-modifiers for the 'from' clause.
7681
7682 /// Location of motion-modifiers for the 'from' clause.
7683 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7684
7685 /// Colon location.
7686 SourceLocation ColonLoc;
7687
7688 /// Build clause with number of variables \a NumVars.
7689 ///
7690 /// \param TheMotionModifiers Motion-modifiers.
7691 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7692 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7693 /// user-defined mapper.
7694 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7695 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7696 /// StartLoc: starting location of the clause (the clause keyword); 2)
7697 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7698 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7699 /// NumVars: number of expressions listed in this clause; 2)
7700 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7701 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7702 /// NumComponents: total number of expression components in the clause.
7703 explicit OMPFromClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7704 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7705 NestedNameSpecifierLoc MapperQualifierLoc,
7706 DeclarationNameInfo MapperIdInfo,
7707 const OMPVarListLocTy &Locs,
7708 const OMPMappableExprListSizeTy &Sizes)
7709 : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes,
7710 /*SupportsMapper=*/true, &MapperQualifierLoc,
7711 &MapperIdInfo) {
7712 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7713 "Unexpected number of motion modifiers.");
7714 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7715
7716 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7717 "Unexpected number of motion modifier locations.");
7718 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7719 }
7720
7721 /// Build an empty clause.
7722 ///
7723 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7724 /// NumVars: number of expressions listed in this clause; 2)
7725 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7726 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7727 /// NumComponents: total number of expression components in the clause.
7728 explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes)
7729 : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(),
7730 Sizes, /*SupportsMapper=*/true) {}
7731
7732 /// Set motion-modifier for the clause.
7733 ///
7734 /// \param I index for motion-modifier.
7735 /// \param T motion-modifier for the clause.
7736 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7737 assert(I < NumberOfOMPMotionModifiers &&
7738 "Unexpected index to store motion modifier, exceeds array size.");
7739 MotionModifiers[I] = T;
7740 }
7741
7742 /// Set location for the motion-modifier.
7743 ///
7744 /// \param I index for motion-modifier location.
7745 /// \param TLoc motion-modifier location.
7746 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7747 assert(I < NumberOfOMPMotionModifiers &&
7748 "Index to store motion modifier location exceeds array size.");
7749 MotionModifiersLoc[I] = TLoc;
7750 }
7751
7752 /// Set colon location.
7753 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7754
7755 /// Define the sizes of each trailing object array except the last one. This
7756 /// is required for TrailingObjects to work properly.
7757 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7758 // There are varlist_size() of expressions, and varlist_size() of
7759 // user-defined mappers.
7760 return 2 * varlist_size();
7761 }
7762 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7763 return getUniqueDeclarationsNum();
7764 }
7765 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7767 }
7768
7769public:
7770 /// Creates clause with a list of variables \a Vars.
7771 ///
7772 /// \param C AST context.
7773 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7774 /// StartLoc: starting location of the clause (the clause keyword); 2)
7775 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7776 /// \param Vars The original expression used in the clause.
7777 /// \param Declarations Declarations used in the clause.
7778 /// \param ComponentLists Component lists used in the clause.
7779 /// \param MotionModifiers Motion-modifiers.
7780 /// \param MotionModifiersLoc Location of motion-modifiers.
7781 /// \param UDMapperRefs References to user-defined mappers associated with
7782 /// expressions used in the clause.
7783 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7784 /// user-defined mapper.
7785 /// \param MapperId The identifier of associated user-defined mapper.
7786 static OMPFromClause *
7787 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7788 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7789 MappableExprComponentListsRef ComponentLists,
7790 ArrayRef<Expr *> UDMapperRefs,
7791 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7792 ArrayRef<SourceLocation> MotionModifiersLoc,
7793 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId);
7794
7795 /// Creates an empty clause with the place for \a NumVars variables.
7796 ///
7797 /// \param C AST context.
7798 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7799 /// NumVars: number of expressions listed in this clause; 2)
7800 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7801 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7802 /// NumComponents: total number of expression components in the clause.
7803 static OMPFromClause *CreateEmpty(const ASTContext &C,
7804 const OMPMappableExprListSizeTy &Sizes);
7805
7806 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7807 ///
7808 /// \param Cnt index for motion-modifier.
7809 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7810 assert(Cnt < NumberOfOMPMotionModifiers &&
7811 "Requested modifier exceeds the total number of modifiers.");
7812 return MotionModifiers[Cnt];
7813 }
7814
7815 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7816 /// locations.
7817 ///
7818 /// \param Cnt index for motion-modifier location.
7819 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7820 assert(Cnt < NumberOfOMPMotionModifiers &&
7821 "Requested modifier location exceeds total number of modifiers.");
7822 return MotionModifiersLoc[Cnt];
7823 }
7824
7825 /// Fetches ArrayRef of motion-modifiers.
7827 return MotionModifiers;
7828 }
7829
7830 /// Fetches ArrayRef of location of motion-modifiers.
7832 return MotionModifiersLoc;
7833 }
7834
7835 /// Get colon location.
7836 SourceLocation getColonLoc() const { return ColonLoc; }
7837
7839 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7840 reinterpret_cast<Stmt **>(varlist_end()));
7841 }
7842
7844 auto Children = const_cast<OMPFromClause *>(this)->children();
7845 return const_child_range(Children.begin(), Children.end());
7846 }
7847
7854
7855 static bool classof(const OMPClause *T) {
7856 return T->getClauseKind() == llvm::omp::OMPC_from;
7857 }
7858};
7859
7860/// This represents clause 'use_device_ptr' in the '#pragma omp ...'
7861/// directives.
7862///
7863/// \code
7864/// #pragma omp target data use_device_ptr(a,b)
7865/// \endcode
7866/// In this example directive '#pragma omp target data' has clause
7867/// 'use_device_ptr' with the variables 'a' and 'b'.
7868class OMPUseDevicePtrClause final
7869 : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
7870 private llvm::TrailingObjects<
7871 OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
7872 OMPClauseMappableExprCommon::MappableComponent> {
7873 friend class OMPClauseReader;
7874 friend OMPMappableExprListClause;
7875 friend OMPVarListClause;
7876 friend TrailingObjects;
7877
7878 /// Build clause with number of variables \a NumVars.
7879 ///
7880 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7881 /// StartLoc: starting location of the clause (the clause keyword); 2)
7882 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7883 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7884 /// NumVars: number of expressions listed in this clause; 2)
7885 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7886 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7887 /// NumComponents: total number of expression components in the clause.
7888 explicit OMPUseDevicePtrClause(const OMPVarListLocTy &Locs,
7889 const OMPMappableExprListSizeTy &Sizes)
7890 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr, Locs, Sizes) {
7891 }
7892
7893 /// Build an empty clause.
7894 ///
7895 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7896 /// NumVars: number of expressions listed in this clause; 2)
7897 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7898 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7899 /// NumComponents: total number of expression components in the clause.
7901 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr,
7902 OMPVarListLocTy(), Sizes) {}
7903
7904 /// Define the sizes of each trailing object array except the last one. This
7905 /// is required for TrailingObjects to work properly.
7906 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7907 return 3 * varlist_size();
7908 }
7909 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7910 return getUniqueDeclarationsNum();
7911 }
7912 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7914 }
7915
7916 /// Sets the list of references to private copies with initializers for new
7917 /// private variables.
7918 /// \param VL List of references.
7919 void setPrivateCopies(ArrayRef<Expr *> VL);
7920
7921 /// Gets the list of references to private copies with initializers for new
7922 /// private variables.
7923 MutableArrayRef<Expr *> getPrivateCopies() {
7924 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
7925 }
7926 ArrayRef<const Expr *> getPrivateCopies() const {
7927 return {varlist_end(), varlist_size()};
7928 }
7929
7930 /// Sets the list of references to initializer variables for new private
7931 /// variables.
7932 /// \param VL List of references.
7933 void setInits(ArrayRef<Expr *> VL);
7934
7935 /// Gets the list of references to initializer variables for new private
7936 /// variables.
7937 MutableArrayRef<Expr *> getInits() {
7938 return {getPrivateCopies().end(), varlist_size()};
7939 }
7940 ArrayRef<const Expr *> getInits() const {
7941 return {getPrivateCopies().end(), varlist_size()};
7942 }
7943
7944public:
7945 /// Creates clause with a list of variables \a Vars.
7946 ///
7947 /// \param C AST context.
7948 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7949 /// StartLoc: starting location of the clause (the clause keyword); 2)
7950 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7951 /// \param Vars The original expression used in the clause.
7952 /// \param PrivateVars Expressions referring to private copies.
7953 /// \param Inits Expressions referring to private copy initializers.
7954 /// \param Declarations Declarations used in the clause.
7955 /// \param ComponentLists Component lists used in the clause.
7956 static OMPUseDevicePtrClause *
7957 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7958 ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
7959 ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
7960 MappableExprComponentListsRef ComponentLists);
7961
7962 /// Creates an empty clause with the place for \a NumVars variables.
7963 ///
7964 /// \param C AST context.
7965 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7966 /// NumVars: number of expressions listed in this clause; 2)
7967 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7968 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7969 /// NumComponents: total number of expression components in the clause.
7970 static OMPUseDevicePtrClause *
7971 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7972
7975 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
7977 llvm::iterator_range<private_copies_const_iterator>;
7978
7980 return private_copies_range(getPrivateCopies().begin(),
7981 getPrivateCopies().end());
7982 }
7983
7985 return private_copies_const_range(getPrivateCopies().begin(),
7986 getPrivateCopies().end());
7987 }
7988
7991 using inits_range = llvm::iterator_range<inits_iterator>;
7992 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
7993
7995 return inits_range(getInits().begin(), getInits().end());
7996 }
7997
7999 return inits_const_range(getInits().begin(), getInits().end());
8000 }
8001
8003 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8004 reinterpret_cast<Stmt **>(varlist_end()));
8005 }
8006
8008 auto Children = const_cast<OMPUseDevicePtrClause *>(this)->children();
8009 return const_child_range(Children.begin(), Children.end());
8010 }
8011
8018
8019 static bool classof(const OMPClause *T) {
8020 return T->getClauseKind() == llvm::omp::OMPC_use_device_ptr;
8021 }
8022};
8023
8024/// This represents clause 'use_device_addr' in the '#pragma omp ...'
8025/// directives.
8026///
8027/// \code
8028/// #pragma omp target data use_device_addr(a,b)
8029/// \endcode
8030/// In this example directive '#pragma omp target data' has clause
8031/// 'use_device_addr' with the variables 'a' and 'b'.
8032class OMPUseDeviceAddrClause final
8033 : public OMPMappableExprListClause<OMPUseDeviceAddrClause>,
8034 private llvm::TrailingObjects<
8035 OMPUseDeviceAddrClause, Expr *, ValueDecl *, unsigned,
8036 OMPClauseMappableExprCommon::MappableComponent> {
8037 friend class OMPClauseReader;
8038 friend OMPMappableExprListClause;
8039 friend OMPVarListClause;
8040 friend TrailingObjects;
8041
8042 /// Build clause with number of variables \a NumVars.
8043 ///
8044 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8045 /// StartLoc: starting location of the clause (the clause keyword); 2)
8046 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8047 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8048 /// NumVars: number of expressions listed in this clause; 2)
8049 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8050 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8051 /// NumComponents: total number of expression components in the clause.
8052 explicit OMPUseDeviceAddrClause(const OMPVarListLocTy &Locs,
8053 const OMPMappableExprListSizeTy &Sizes)
8054 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr, Locs,
8055 Sizes) {}
8056
8057 /// Build an empty clause.
8058 ///
8059 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8060 /// NumVars: number of expressions listed in this clause; 2)
8061 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8062 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8063 /// NumComponents: total number of expression components in the clause.
8065 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr,
8066 OMPVarListLocTy(), Sizes) {}
8067
8068 /// Define the sizes of each trailing object array except the last one. This
8069 /// is required for TrailingObjects to work properly.
8070 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8071 return varlist_size();
8072 }
8073 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8074 return getUniqueDeclarationsNum();
8075 }
8076 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8078 }
8079
8080public:
8081 /// Creates clause with a list of variables \a Vars.
8082 ///
8083 /// \param C AST context.
8084 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8085 /// StartLoc: starting location of the clause (the clause keyword); 2)
8086 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8087 /// \param Vars The original expression used in the clause.
8088 /// \param Declarations Declarations used in the clause.
8089 /// \param ComponentLists Component lists used in the clause.
8090 static OMPUseDeviceAddrClause *
8091 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8092 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8093 MappableExprComponentListsRef ComponentLists);
8094
8095 /// Creates an empty clause with the place for \a NumVars variables.
8096 ///
8097 /// \param C AST context.
8098 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8099 /// NumVars: number of expressions listed in this clause; 2)
8100 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8101 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8102 /// NumComponents: total number of expression components in the clause.
8103 static OMPUseDeviceAddrClause *
8104 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8105
8107 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8108 reinterpret_cast<Stmt **>(varlist_end()));
8109 }
8110
8112 auto Children = const_cast<OMPUseDeviceAddrClause *>(this)->children();
8113 return const_child_range(Children.begin(), Children.end());
8114 }
8115
8122
8123 static bool classof(const OMPClause *T) {
8124 return T->getClauseKind() == llvm::omp::OMPC_use_device_addr;
8125 }
8126};
8127
8128/// This represents clause 'is_device_ptr' in the '#pragma omp ...'
8129/// directives.
8130///
8131/// \code
8132/// #pragma omp target is_device_ptr(a,b)
8133/// \endcode
8134/// In this example directive '#pragma omp target' has clause
8135/// 'is_device_ptr' with the variables 'a' and 'b'.
8136class OMPIsDevicePtrClause final
8137 : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
8138 private llvm::TrailingObjects<
8139 OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
8140 OMPClauseMappableExprCommon::MappableComponent> {
8141 friend class OMPClauseReader;
8142 friend OMPMappableExprListClause;
8143 friend OMPVarListClause;
8144 friend TrailingObjects;
8145
8146 /// Build clause with number of variables \a NumVars.
8147 ///
8148 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8149 /// StartLoc: starting location of the clause (the clause keyword); 2)
8150 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8151 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8152 /// NumVars: number of expressions listed in this clause; 2)
8153 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8154 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8155 /// NumComponents: total number of expression components in the clause.
8156 explicit OMPIsDevicePtrClause(const OMPVarListLocTy &Locs,
8157 const OMPMappableExprListSizeTy &Sizes)
8158 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr, Locs, Sizes) {}
8159
8160 /// Build an empty clause.
8161 ///
8162 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8163 /// NumVars: number of expressions listed in this clause; 2)
8164 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8165 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8166 /// NumComponents: total number of expression components in the clause.
8167 explicit OMPIsDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
8168 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr,
8169 OMPVarListLocTy(), Sizes) {}
8170
8171 /// Define the sizes of each trailing object array except the last one. This
8172 /// is required for TrailingObjects to work properly.
8173 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8174 return varlist_size();
8175 }
8176 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8177 return getUniqueDeclarationsNum();
8178 }
8179 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8181 }
8182
8183public:
8184 /// Creates clause with a list of variables \a Vars.
8185 ///
8186 /// \param C AST context.
8187 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8188 /// StartLoc: starting location of the clause (the clause keyword); 2)
8189 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8190 /// \param Vars The original expression used in the clause.
8191 /// \param Declarations Declarations used in the clause.
8192 /// \param ComponentLists Component lists used in the clause.
8193 static OMPIsDevicePtrClause *
8194 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8195 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8196 MappableExprComponentListsRef ComponentLists);
8197
8198 /// Creates an empty clause with the place for \a NumVars variables.
8199 ///
8200 /// \param C AST context.
8201 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8202 /// NumVars: number of expressions listed in this clause; 2)
8203 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8204 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8205 /// NumComponents: total number of expression components in the clause.
8206 static OMPIsDevicePtrClause *
8207 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8208
8210 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8211 reinterpret_cast<Stmt **>(varlist_end()));
8212 }
8213
8215 auto Children = const_cast<OMPIsDevicePtrClause *>(this)->children();
8216 return const_child_range(Children.begin(), Children.end());
8217 }
8218
8225
8226 static bool classof(const OMPClause *T) {
8227 return T->getClauseKind() == llvm::omp::OMPC_is_device_ptr;
8228 }
8229};
8230
8231/// This represents clause 'has_device_ptr' in the '#pragma omp ...'
8232/// directives.
8233///
8234/// \code
8235/// #pragma omp target has_device_addr(a,b)
8236/// \endcode
8237/// In this example directive '#pragma omp target' has clause
8238/// 'has_device_ptr' with the variables 'a' and 'b'.
8239class OMPHasDeviceAddrClause final
8240 : public OMPMappableExprListClause<OMPHasDeviceAddrClause>,
8241 private llvm::TrailingObjects<
8242 OMPHasDeviceAddrClause, Expr *, ValueDecl *, unsigned,
8243 OMPClauseMappableExprCommon::MappableComponent> {
8244 friend class OMPClauseReader;
8245 friend OMPMappableExprListClause;
8246 friend OMPVarListClause;
8247 friend TrailingObjects;
8248
8249 /// Build clause with number of variables \a NumVars.
8250 ///
8251 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8252 /// StartLoc: starting location of the clause (the clause keyword); 2)
8253 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8254 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8255 /// NumVars: number of expressions listed in this clause; 2)
8256 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8257 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8258 /// NumComponents: total number of expression components in the clause.
8259 explicit OMPHasDeviceAddrClause(const OMPVarListLocTy &Locs,
8260 const OMPMappableExprListSizeTy &Sizes)
8261 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, Locs,
8262 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.
8272 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr,
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 OMPHasDeviceAddrClause *
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 OMPHasDeviceAddrClause *
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 auto Children = const_cast<OMPHasDeviceAddrClause *>(this)->children();
8320 return const_child_range(Children.begin(), Children.end());
8321 }
8322
8329
8330 static bool classof(const OMPClause *T) {
8331 return T->getClauseKind() == llvm::omp::OMPC_has_device_addr;
8332 }
8333};
8334
8335/// This represents clause 'nontemporal' in the '#pragma omp ...' directives.
8336///
8337/// \code
8338/// #pragma omp simd nontemporal(a)
8339/// \endcode
8340/// In this example directive '#pragma omp simd' has clause 'nontemporal' for
8341/// the variable 'a'.
8342class OMPNontemporalClause final
8343 : public OMPVarListClause<OMPNontemporalClause>,
8344 private llvm::TrailingObjects<OMPNontemporalClause, Expr *> {
8345 friend class OMPClauseReader;
8346 friend OMPVarListClause;
8347 friend TrailingObjects;
8348
8349 /// Build clause with number of variables \a N.
8350 ///
8351 /// \param StartLoc Starting location of the clause.
8352 /// \param LParenLoc Location of '('.
8353 /// \param EndLoc Ending location of the clause.
8354 /// \param N Number of the variables in the clause.
8355 OMPNontemporalClause(SourceLocation StartLoc, SourceLocation LParenLoc,
8356 SourceLocation EndLoc, unsigned N)
8357 : OMPVarListClause<OMPNontemporalClause>(llvm::omp::OMPC_nontemporal,
8358 StartLoc, LParenLoc, EndLoc, N) {
8359 }
8360
8361 /// Build an empty clause.
8362 ///
8363 /// \param N Number of variables.
8364 explicit OMPNontemporalClause(unsigned N)
8366 llvm::omp::OMPC_nontemporal, SourceLocation(), SourceLocation(),
8367 SourceLocation(), N) {}
8368
8369 /// Get the list of privatied copies if the member expression was captured by
8370 /// one of the privatization clauses.
8371 MutableArrayRef<Expr *> getPrivateRefs() {
8372 return {varlist_end(), varlist_size()};
8373 }
8374 ArrayRef<const Expr *> getPrivateRefs() const {
8375 return {varlist_end(), varlist_size()};
8376 }
8377
8378public:
8379 /// Creates clause with a list of variables \a VL.
8380 ///
8381 /// \param C AST context.
8382 /// \param StartLoc Starting location of the clause.
8383 /// \param LParenLoc Location of '('.
8384 /// \param EndLoc Ending location of the clause.
8385 /// \param VL List of references to the variables.
8386 static OMPNontemporalClause *
8387 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
8388 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8389
8390 /// Creates an empty clause with the place for \a N variables.
8391 ///
8392 /// \param C AST context.
8393 /// \param N The number of variables.
8394 static OMPNontemporalClause *CreateEmpty(const ASTContext &C, unsigned N);
8395
8396 /// Sets the list of references to private copies created in private clauses.
8397 /// \param VL List of references.
8398 void setPrivateRefs(ArrayRef<Expr *> VL);
8399
8401 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8402 reinterpret_cast<Stmt **>(varlist_end()));
8403 }
8404
8406 auto Children = const_cast<OMPNontemporalClause *>(this)->children();
8407 return const_child_range(Children.begin(), Children.end());
8408 }
8409
8411 return child_range(reinterpret_cast<Stmt **>(getPrivateRefs().begin()),
8412 reinterpret_cast<Stmt **>(getPrivateRefs().end()));
8413 }
8414
8416 auto Children = const_cast<OMPNontemporalClause *>(this)->private_refs();
8417 return const_child_range(Children.begin(), Children.end());
8418 }
8419
8426
8427 static bool classof(const OMPClause *T) {
8428 return T->getClauseKind() == llvm::omp::OMPC_nontemporal;
8429 }
8430};
8431
8432/// This represents 'order' clause in the '#pragma omp ...' directive.
8433///
8434/// \code
8435/// #pragma omp simd order(concurrent)
8436/// \endcode
8437/// In this example directive '#pragma omp parallel' has simple 'order'
8438/// clause with kind 'concurrent'.
8439class OMPOrderClause final : public OMPClause {
8440 friend class OMPClauseReader;
8441
8442 /// Location of '('.
8443 SourceLocation LParenLoc;
8444
8445 /// A kind of the 'order' clause.
8447
8448 /// Start location of the kind in source code.
8449 SourceLocation KindKwLoc;
8450
8451 /// A modifier for order clause
8453
8454 /// Start location of the modifier in source code.
8455 SourceLocation ModifierKwLoc;
8456
8457 /// Set kind of the clause.
8458 ///
8459 /// \param K Argument of clause.
8460 void setKind(OpenMPOrderClauseKind K) { Kind = K; }
8461
8462 /// Set argument location.
8463 ///
8464 /// \param KLoc Argument location.
8465 void setKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
8466
8467 /// Set modifier of the clause.
8468 ///
8469 /// \param M Argument of clause.
8470 void setModifier(OpenMPOrderClauseModifier M) { Modifier = M; }
8471
8472 /// Set modifier location.
8473 ///
8474 /// \param MLoc Modifier keyword location.
8475 void setModifierKwLoc(SourceLocation MLoc) { ModifierKwLoc = MLoc; }
8476
8477public:
8478 /// Build 'order' clause with argument \p A ('concurrent').
8479 ///
8480 /// \param A Argument of the clause ('concurrent').
8481 /// \param ALoc Starting location of the argument.
8482 /// \param StartLoc Starting location of the clause.
8483 /// \param LParenLoc Location of '('.
8484 /// \param EndLoc Ending location of the clause.
8485 /// \param Modifier The modifier applied to 'order' clause.
8486 /// \param MLoc Location of the modifier
8488 SourceLocation StartLoc, SourceLocation LParenLoc,
8490 SourceLocation MLoc)
8491 : OMPClause(llvm::omp::OMPC_order, StartLoc, EndLoc),
8492 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), Modifier(Modifier),
8493 ModifierKwLoc(MLoc) {}
8494
8495 /// Build an empty clause.
8497 : OMPClause(llvm::omp::OMPC_order, SourceLocation(), SourceLocation()) {}
8498
8499 /// Sets the location of '('.
8500 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8501
8502 /// Returns the location of '('.
8503 SourceLocation getLParenLoc() const { return LParenLoc; }
8504
8505 /// Returns kind of the clause.
8506 OpenMPOrderClauseKind getKind() const { return Kind; }
8507
8508 /// Returns location of clause kind.
8509 SourceLocation getKindKwLoc() const { return KindKwLoc; }
8510
8511 /// Returns Modifier of the clause.
8512 OpenMPOrderClauseModifier getModifier() const { return Modifier; }
8513
8514 /// Returns location of clause modifier.
8515 SourceLocation getModifierKwLoc() const { return ModifierKwLoc; }
8516
8520
8524
8531
8532 static bool classof(const OMPClause *T) {
8533 return T->getClauseKind() == llvm::omp::OMPC_order;
8534 }
8535};
8536
8537/// This represents the 'init' clause in '#pragma omp ...' directives.
8538///
8539/// \code
8540/// #pragma omp interop init(target:obj)
8541/// \endcode
8542class OMPInitClause final
8543 : public OMPVarListClause<OMPInitClause>,
8544 private llvm::TrailingObjects<OMPInitClause, Expr *> {
8545 friend class OMPClauseReader;
8546 friend OMPVarListClause;
8547 friend TrailingObjects;
8548
8549 /// Location of interop variable.
8550 SourceLocation VarLoc;
8551
8552 bool IsTarget = false;
8553 bool IsTargetSync = false;
8554
8555 void setInteropVar(Expr *E) { varlist_begin()[0] = E; }
8556
8557 void setIsTarget(bool V) { IsTarget = V; }
8558
8559 void setIsTargetSync(bool V) { IsTargetSync = V; }
8560
8561 /// Sets the location of the interop variable.
8562 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8563
8564 /// Build 'init' clause.
8565 ///
8566 /// \param IsTarget Uses the 'target' interop-type.
8567 /// \param IsTargetSync Uses the 'targetsync' interop-type.
8568 /// \param StartLoc Starting location of the clause.
8569 /// \param LParenLoc Location of '('.
8570 /// \param VarLoc Location of the interop variable.
8571 /// \param EndLoc Ending location of the clause.
8572 /// \param N Number of expressions.
8573 OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc,
8574 SourceLocation LParenLoc, SourceLocation VarLoc,
8575 SourceLocation EndLoc, unsigned N)
8576 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc,
8577 LParenLoc, EndLoc, N),
8578 VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {}
8579
8580 /// Build an empty clause.
8581 OMPInitClause(unsigned N)
8582 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(),
8583 SourceLocation(), SourceLocation(), N) {
8584 }
8585
8586public:
8587 /// Creates a fully specified clause.
8588 ///
8589 /// \param C AST context.
8590 /// \param InteropVar The interop variable.
8591 /// \param InteropInfo The interop-type and prefer_type list.
8592 /// \param StartLoc Starting location of the clause.
8593 /// \param LParenLoc Location of '('.
8594 /// \param VarLoc Location of the interop variable.
8595 /// \param EndLoc Ending location of the clause.
8596 static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar,
8597 OMPInteropInfo &InteropInfo,
8598 SourceLocation StartLoc,
8599 SourceLocation LParenLoc, SourceLocation VarLoc,
8600 SourceLocation EndLoc);
8601
8602 /// Creates an empty clause with \a N expressions.
8603 ///
8604 /// \param C AST context.
8605 /// \param N Number of expression items.
8606 static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N);
8607
8608 /// Returns the location of the interop variable.
8609 SourceLocation getVarLoc() const { return VarLoc; }
8610
8611 /// Returns the interop variable.
8613 const Expr *getInteropVar() const { return varlist_begin()[0]; }
8614
8615 /// Returns true is interop-type 'target' is used.
8616 bool getIsTarget() const { return IsTarget; }
8617
8618 /// Returns true is interop-type 'targetsync' is used.
8619 bool getIsTargetSync() const { return IsTargetSync; }
8620
8622 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8623 reinterpret_cast<Stmt **>(varlist_end()));
8624 }
8625
8627 auto Children = const_cast<OMPInitClause *>(this)->children();
8628 return const_child_range(Children.begin(), Children.end());
8629 }
8630
8637
8640 using prefs_range = llvm::iterator_range<prefs_iterator>;
8641 using const_prefs_range = llvm::iterator_range<const_prefs_iterator>;
8642
8644 return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())),
8645 reinterpret_cast<Expr **>(varlist_end()));
8646 }
8647
8649 auto Prefs = const_cast<OMPInitClause *>(this)->prefs();
8650 return const_prefs_range(Prefs.begin(), Prefs.end());
8651 }
8652
8653 static bool classof(const OMPClause *T) {
8654 return T->getClauseKind() == llvm::omp::OMPC_init;
8655 }
8656};
8657
8658/// This represents the 'use' clause in '#pragma omp ...' directives.
8659///
8660/// \code
8661/// #pragma omp interop use(obj)
8662/// \endcode
8663class OMPUseClause final : public OMPClause {
8664 friend class OMPClauseReader;
8665
8666 /// Location of '('.
8667 SourceLocation LParenLoc;
8668
8669 /// Location of interop variable.
8670 SourceLocation VarLoc;
8671
8672 /// The interop variable.
8673 Stmt *InteropVar = nullptr;
8674
8675 /// Set the interop variable.
8676 void setInteropVar(Expr *E) { InteropVar = E; }
8677
8678 /// Sets the location of '('.
8679 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8680
8681 /// Sets the location of the interop variable.
8682 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8683
8684public:
8685 /// Build 'use' clause with and interop variable expression \a InteropVar.
8686 ///
8687 /// \param InteropVar The interop variable.
8688 /// \param StartLoc Starting location of the clause.
8689 /// \param LParenLoc Location of '('.
8690 /// \param VarLoc Location of the interop variable.
8691 /// \param EndLoc Ending location of the clause.
8692 OMPUseClause(Expr *InteropVar, SourceLocation StartLoc,
8693 SourceLocation LParenLoc, SourceLocation VarLoc,
8694 SourceLocation EndLoc)
8695 : OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc),
8696 VarLoc(VarLoc), InteropVar(InteropVar) {}
8697
8698 /// Build an empty clause.
8700 : OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {}
8701
8702 /// Returns the location of '('.
8703 SourceLocation getLParenLoc() const { return LParenLoc; }
8704
8705 /// Returns the location of the interop variable.
8706 SourceLocation getVarLoc() const { return VarLoc; }
8707
8708 /// Returns the interop variable.
8709 Expr *getInteropVar() const { return cast<Expr>(InteropVar); }
8710
8711 child_range children() { return child_range(&InteropVar, &InteropVar + 1); }
8712
8714 return const_child_range(&InteropVar, &InteropVar + 1);
8715 }
8716
8723
8724 static bool classof(const OMPClause *T) {
8725 return T->getClauseKind() == llvm::omp::OMPC_use;
8726 }
8727};
8728
8729/// This represents 'destroy' clause in the '#pragma omp depobj'
8730/// directive or the '#pragma omp interop' directive..
8731///
8732/// \code
8733/// #pragma omp depobj(a) destroy
8734/// #pragma omp interop destroy(obj)
8735/// \endcode
8736/// In these examples directive '#pragma omp depobj' and '#pragma omp interop'
8737/// have a 'destroy' clause. The 'interop' directive includes an object.
8738class OMPDestroyClause final : public OMPClause {
8739 friend class OMPClauseReader;
8740
8741 /// Location of '('.
8742 SourceLocation LParenLoc;
8743
8744 /// Location of interop variable.
8745 SourceLocation VarLoc;
8746
8747 /// The interop variable.
8748 Stmt *InteropVar = nullptr;
8749
8750 /// Set the interop variable.
8751 void setInteropVar(Expr *E) { InteropVar = E; }
8752
8753 /// Sets the location of '('.
8754 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8755
8756 /// Sets the location of the interop variable.
8757 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8758
8759public:
8760 /// Build 'destroy' clause with an interop variable expression \a InteropVar.
8761 ///
8762 /// \param InteropVar The interop variable.
8763 /// \param StartLoc Starting location of the clause.
8764 /// \param LParenLoc Location of '('.
8765 /// \param VarLoc Location of the interop variable.
8766 /// \param EndLoc Ending location of the clause.
8767 OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc,
8768 SourceLocation LParenLoc, SourceLocation VarLoc,
8769 SourceLocation EndLoc)
8770 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc),
8771 LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {}
8772
8773 /// Build 'destroy' clause.
8774 ///
8775 /// \param StartLoc Starting location of the clause.
8776 /// \param EndLoc Ending location of the clause.
8778 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc) {}
8779
8780 /// Build an empty clause.
8782 : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) {
8783 }
8784
8785 /// Returns the location of '('.
8786 SourceLocation getLParenLoc() const { return LParenLoc; }
8787
8788 /// Returns the location of the interop variable.
8789 SourceLocation getVarLoc() const { return VarLoc; }
8790
8791 /// Returns the interop variable.
8792 Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); }
8793
8795 if (InteropVar)
8796 return child_range(&InteropVar, &InteropVar + 1);
8798 }
8799
8801 if (InteropVar)
8802 return const_child_range(&InteropVar, &InteropVar + 1);
8804 }
8805
8812
8813 static bool classof(const OMPClause *T) {
8814 return T->getClauseKind() == llvm::omp::OMPC_destroy;
8815 }
8816};
8817
8818/// This represents 'novariants' clause in the '#pragma omp ...' directive.
8819///
8820/// \code
8821/// #pragma omp dispatch novariants(a > 5)
8822/// \endcode
8823/// In this example directive '#pragma omp dispatch' has simple 'novariants'
8824/// clause with condition 'a > 5'.
8826 : public OMPOneStmtClause<llvm::omp::OMPC_novariants, OMPClause>,
8827 public OMPClauseWithPreInit {
8828 friend class OMPClauseReader;
8829
8830 /// Set condition.
8831 void setCondition(Expr *Cond) { setStmt(Cond); }
8832
8833public:
8834 /// Build 'novariants' clause with condition \a Cond.
8835 ///
8836 /// \param Cond Condition of the clause.
8837 /// \param HelperCond Helper condition for the construct.
8838 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8839 /// clause must be captured.
8840 /// \param StartLoc Starting location of the clause.
8841 /// \param LParenLoc Location of '('.
8842 /// \param EndLoc Ending location of the clause.
8844 OpenMPDirectiveKind CaptureRegion,
8845 SourceLocation StartLoc, SourceLocation LParenLoc,
8846 SourceLocation EndLoc)
8847 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8848 OMPClauseWithPreInit(this) {
8849 setPreInitStmt(HelperCond, CaptureRegion);
8850 }
8851
8852 /// Build an empty clause.
8854
8855 /// Returns condition.
8856 Expr *getCondition() const { return getStmtAs<Expr>(); }
8857
8860 auto Children = const_cast<OMPNovariantsClause *>(this)->used_children();
8861 return const_child_range(Children.begin(), Children.end());
8862 }
8863};
8864
8865/// This represents 'nocontext' clause in the '#pragma omp ...' directive.
8866///
8867/// \code
8868/// #pragma omp dispatch nocontext(a > 5)
8869/// \endcode
8870/// In this example directive '#pragma omp dispatch' has simple 'nocontext'
8871/// clause with condition 'a > 5'.
8873 : public OMPOneStmtClause<llvm::omp::OMPC_nocontext, OMPClause>,
8874 public OMPClauseWithPreInit {
8875 friend class OMPClauseReader;
8876
8877 /// Set condition.
8878 void setCondition(Expr *Cond) { setStmt(Cond); }
8879
8880public:
8881 /// Build 'nocontext' clause with condition \a Cond.
8882 ///
8883 /// \param Cond Condition of the clause.
8884 /// \param HelperCond Helper condition for the construct.
8885 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8886 /// clause must be captured.
8887 /// \param StartLoc Starting location of the clause.
8888 /// \param LParenLoc Location of '('.
8889 /// \param EndLoc Ending location of the clause.
8891 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
8892 SourceLocation LParenLoc, SourceLocation EndLoc)
8893 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8894 OMPClauseWithPreInit(this) {
8895 setPreInitStmt(HelperCond, CaptureRegion);
8896 }
8897
8898 /// Build an empty clause.
8900
8901 /// Returns condition.
8902 Expr *getCondition() const { return getStmtAs<Expr>(); }
8903
8906 auto Children = const_cast<OMPNocontextClause *>(this)->used_children();
8907 return const_child_range(Children.begin(), Children.end());
8908 }
8909};
8910
8911/// This represents 'detach' clause in the '#pragma omp task' directive.
8912///
8913/// \code
8914/// #pragma omp task detach(evt)
8915/// \endcode
8916/// In this example directive '#pragma omp detach' has simple 'detach' clause
8917/// with the variable 'evt'.
8919 : public OMPOneStmtClause<llvm::omp::OMPC_detach, OMPClause> {
8920 friend class OMPClauseReader;
8921
8922 /// Set condition.
8923 void setEventHandler(Expr *E) { setStmt(E); }
8924
8925public:
8926 /// Build 'detach' clause with event-handler \a Evt.
8927 ///
8928 /// \param Evt Event handler expression.
8929 /// \param StartLoc Starting location of the clause.
8930 /// \param LParenLoc Location of '('.
8931 /// \param EndLoc Ending location of the clause.
8933 SourceLocation EndLoc)
8934 : OMPOneStmtClause(Evt, StartLoc, LParenLoc, EndLoc) {}
8935
8936 /// Build an empty clause.
8938
8939 /// Returns event-handler expression.
8940 Expr *getEventHandler() const { return getStmtAs<Expr>(); }
8941};
8942
8943/// This represents clause 'inclusive' in the '#pragma omp scan' directive.
8944///
8945/// \code
8946/// #pragma omp scan inclusive(a,b)
8947/// \endcode
8948/// In this example directive '#pragma omp scan' has clause 'inclusive'
8949/// with the variables 'a' and 'b'.
8950class OMPInclusiveClause final
8951 : public OMPVarListClause<OMPInclusiveClause>,
8952 private llvm::TrailingObjects<OMPInclusiveClause, Expr *> {
8953 friend class OMPClauseReader;
8954 friend OMPVarListClause;
8955 friend TrailingObjects;
8956
8957 /// Build clause with number of variables \a N.
8958 ///
8959 /// \param StartLoc Starting location of the clause.
8960 /// \param LParenLoc Location of '('.
8961 /// \param EndLoc Ending location of the clause.
8962 /// \param N Number of the variables in the clause.
8963 OMPInclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
8964 SourceLocation EndLoc, unsigned N)
8965 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
8966 StartLoc, LParenLoc, EndLoc, N) {}
8967
8968 /// Build an empty clause.
8969 ///
8970 /// \param N Number of variables.
8971 explicit OMPInclusiveClause(unsigned N)
8972 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
8974 SourceLocation(), N) {}
8975
8976public:
8977 /// Creates clause with a list of variables \a VL.
8978 ///
8979 /// \param C AST context.
8980 /// \param StartLoc Starting location of the clause.
8981 /// \param LParenLoc Location of '('.
8982 /// \param EndLoc Ending location of the clause.
8983 /// \param VL List of references to the original variables.
8984 static OMPInclusiveClause *Create(const ASTContext &C,
8985 SourceLocation StartLoc,
8986 SourceLocation LParenLoc,
8987 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8988
8989 /// Creates an empty clause with the place for \a N variables.
8990 ///
8991 /// \param C AST context.
8992 /// \param N The number of variables.
8993 static OMPInclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
8994
8996 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8997 reinterpret_cast<Stmt **>(varlist_end()));
8998 }
8999
9001 auto Children = const_cast<OMPInclusiveClause *>(this)->children();
9002 return const_child_range(Children.begin(), Children.end());
9003 }
9004
9011
9012 static bool classof(const OMPClause *T) {
9013 return T->getClauseKind() == llvm::omp::OMPC_inclusive;
9014 }
9015};
9016
9017/// This represents clause 'exclusive' in the '#pragma omp scan' directive.
9018///
9019/// \code
9020/// #pragma omp scan exclusive(a,b)
9021/// \endcode
9022/// In this example directive '#pragma omp scan' has clause 'exclusive'
9023/// with the variables 'a' and 'b'.
9024class OMPExclusiveClause final
9025 : public OMPVarListClause<OMPExclusiveClause>,
9026 private llvm::TrailingObjects<OMPExclusiveClause, Expr *> {
9027 friend class OMPClauseReader;
9028 friend OMPVarListClause;
9029 friend TrailingObjects;
9030
9031 /// Build clause with number of variables \a N.
9032 ///
9033 /// \param StartLoc Starting location of the clause.
9034 /// \param LParenLoc Location of '('.
9035 /// \param EndLoc Ending location of the clause.
9036 /// \param N Number of the variables in the clause.
9037 OMPExclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9038 SourceLocation EndLoc, unsigned N)
9039 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
9040 StartLoc, LParenLoc, EndLoc, N) {}
9041
9042 /// Build an empty clause.
9043 ///
9044 /// \param N Number of variables.
9045 explicit OMPExclusiveClause(unsigned N)
9046 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
9048 SourceLocation(), N) {}
9049
9050public:
9051 /// Creates clause with a list of variables \a VL.
9052 ///
9053 /// \param C AST context.
9054 /// \param StartLoc Starting location of the clause.
9055 /// \param LParenLoc Location of '('.
9056 /// \param EndLoc Ending location of the clause.
9057 /// \param VL List of references to the original variables.
9058 static OMPExclusiveClause *Create(const ASTContext &C,
9059 SourceLocation StartLoc,
9060 SourceLocation LParenLoc,
9061 SourceLocation EndLoc, ArrayRef<Expr *> VL);
9062
9063 /// Creates an empty clause with the place for \a N variables.
9064 ///
9065 /// \param C AST context.
9066 /// \param N The number of variables.
9067 static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
9068
9070 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9071 reinterpret_cast<Stmt **>(varlist_end()));
9072 }
9073
9075 auto Children = const_cast<OMPExclusiveClause *>(this)->children();
9076 return const_child_range(Children.begin(), Children.end());
9077 }
9078
9085
9086 static bool classof(const OMPClause *T) {
9087 return T->getClauseKind() == llvm::omp::OMPC_exclusive;
9088 }
9089};
9090
9091/// This represents clause 'uses_allocators' in the '#pragma omp target'-based
9092/// directives.
9093///
9094/// \code
9095/// #pragma omp target uses_allocators(default_allocator, my_allocator(traits))
9096/// \endcode
9097/// In this example directive '#pragma omp target' has clause 'uses_allocators'
9098/// with the allocators 'default_allocator' and user-defined 'my_allocator'.
9099class OMPUsesAllocatorsClause final
9100 : public OMPClause,
9101 private llvm::TrailingObjects<OMPUsesAllocatorsClause, Expr *,
9102 SourceLocation> {
9103public:
9104 /// Data for list of allocators.
9105 struct Data {
9106 /// Allocator.
9107 Expr *Allocator = nullptr;
9108 /// Allocator traits.
9110 /// Locations of '(' and ')' symbols.
9112 };
9113
9114private:
9115 friend class OMPClauseReader;
9116 friend TrailingObjects;
9117
9118 enum class ExprOffsets {
9119 Allocator,
9120 AllocatorTraits,
9121 Total,
9122 };
9123
9124 enum class ParenLocsOffsets {
9125 LParen,
9126 RParen,
9127 Total,
9128 };
9129
9130 /// Location of '('.
9131 SourceLocation LParenLoc;
9132 /// Total number of allocators in the clause.
9133 unsigned NumOfAllocators = 0;
9134
9135 /// Build clause.
9136 ///
9137 /// \param StartLoc Starting location of the clause.
9138 /// \param LParenLoc Location of '('.
9139 /// \param EndLoc Ending location of the clause.
9140 /// \param N Number of allocators associated with the clause.
9141 OMPUsesAllocatorsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9142 SourceLocation EndLoc, unsigned N)
9143 : OMPClause(llvm::omp::OMPC_uses_allocators, StartLoc, EndLoc),
9144 LParenLoc(LParenLoc), NumOfAllocators(N) {}
9145
9146 /// Build an empty clause.
9147 /// \param N Number of allocators associated with the clause.
9148 ///
9149 explicit OMPUsesAllocatorsClause(unsigned N)
9150 : OMPClause(llvm::omp::OMPC_uses_allocators, SourceLocation(),
9151 SourceLocation()),
9152 NumOfAllocators(N) {}
9153
9154 unsigned numTrailingObjects(OverloadToken<Expr *>) const {
9155 return NumOfAllocators * static_cast<int>(ExprOffsets::Total);
9156 }
9157
9158 /// Sets the location of '('.
9159 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9160
9161 /// Sets the allocators data for the clause.
9162 void setAllocatorsData(ArrayRef<OMPUsesAllocatorsClause::Data> Data);
9163
9164public:
9165 /// Creates clause with a list of allocators \p Data.
9166 ///
9167 /// \param C AST context.
9168 /// \param StartLoc Starting location of the clause.
9169 /// \param LParenLoc Location of '('.
9170 /// \param EndLoc Ending location of the clause.
9171 /// \param Data List of allocators.
9172 static OMPUsesAllocatorsClause *
9173 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
9174 SourceLocation EndLoc, ArrayRef<OMPUsesAllocatorsClause::Data> Data);
9175
9176 /// Creates an empty clause with the place for \p N allocators.
9177 ///
9178 /// \param C AST context.
9179 /// \param N The number of allocators.
9180 static OMPUsesAllocatorsClause *CreateEmpty(const ASTContext &C, unsigned N);
9181
9182 /// Returns the location of '('.
9183 SourceLocation getLParenLoc() const { return LParenLoc; }
9184
9185 /// Returns number of allocators associated with the clause.
9186 unsigned getNumberOfAllocators() const { return NumOfAllocators; }
9187
9188 /// Returns data for the specified allocator.
9190
9191 // Iterators
9193 Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
9194 return child_range(Begin, Begin + NumOfAllocators *
9195 static_cast<int>(ExprOffsets::Total));
9196 }
9198 Stmt *const *Begin =
9199 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
9200 return const_child_range(
9201 Begin, Begin + NumOfAllocators * static_cast<int>(ExprOffsets::Total));
9202 }
9203
9210
9211 static bool classof(const OMPClause *T) {
9212 return T->getClauseKind() == llvm::omp::OMPC_uses_allocators;
9213 }
9214};
9215
9216/// This represents clause 'affinity' in the '#pragma omp task'-based
9217/// directives.
9218///
9219/// \code
9220/// #pragma omp task affinity(iterator(i = 0:n) : ([3][n])a, b[:n], c[i])
9221/// \endcode
9222/// In this example directive '#pragma omp task' has clause 'affinity' with the
9223/// affinity modifer 'iterator(i = 0:n)' and locator items '([3][n])a', 'b[:n]'
9224/// and 'c[i]'.
9225class OMPAffinityClause final
9226 : public OMPVarListClause<OMPAffinityClause>,
9227 private llvm::TrailingObjects<OMPAffinityClause, Expr *> {
9228 friend class OMPClauseReader;
9229 friend OMPVarListClause;
9230 friend TrailingObjects;
9231
9232 /// Location of ':' symbol.
9233 SourceLocation ColonLoc;
9234
9235 /// Build clause.
9236 ///
9237 /// \param StartLoc Starting location of the clause.
9238 /// \param LParenLoc Location of '('.
9239 /// \param ColonLoc Location of ':'.
9240 /// \param EndLoc Ending location of the clause.
9241 /// \param N Number of locators associated with the clause.
9242 OMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9243 SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N)
9244 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, StartLoc,
9245 LParenLoc, EndLoc, N) {}
9246
9247 /// Build an empty clause.
9248 /// \param N Number of locators associated with the clause.
9249 ///
9250 explicit OMPAffinityClause(unsigned N)
9251 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity,
9253 SourceLocation(), N) {}
9254
9255 /// Sets the affinity modifier for the clause, if any.
9256 void setModifier(Expr *E) { getTrailingObjects()[varlist_size()] = E; }
9257
9258 /// Sets the location of ':' symbol.
9259 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
9260
9261public:
9262 /// Creates clause with a modifier a list of locator items.
9263 ///
9264 /// \param C AST context.
9265 /// \param StartLoc Starting location of the clause.
9266 /// \param LParenLoc Location of '('.
9267 /// \param ColonLoc Location of ':'.
9268 /// \param EndLoc Ending location of the clause.
9269 /// \param Locators List of locator items.
9270 static OMPAffinityClause *Create(const ASTContext &C, SourceLocation StartLoc,
9271 SourceLocation LParenLoc,
9272 SourceLocation ColonLoc,
9273 SourceLocation EndLoc, Expr *Modifier,
9274 ArrayRef<Expr *> Locators);
9275
9276 /// Creates an empty clause with the place for \p N locator items.
9277 ///
9278 /// \param C AST context.
9279 /// \param N The number of locator items.
9280 static OMPAffinityClause *CreateEmpty(const ASTContext &C, unsigned N);
9281
9282 /// Gets affinity modifier.
9283 Expr *getModifier() { return getTrailingObjects()[varlist_size()]; }
9284 Expr *getModifier() const { return getTrailingObjects()[varlist_size()]; }
9285
9286 /// Gets the location of ':' symbol.
9287 SourceLocation getColonLoc() const { return ColonLoc; }
9288
9289 // Iterators
9291 int Offset = getModifier() ? 1 : 0;
9292 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9293 reinterpret_cast<Stmt **>(varlist_end() + Offset));
9294 }
9295
9297 auto Children = const_cast<OMPAffinityClause *>(this)->children();
9298 return const_child_range(Children.begin(), Children.end());
9299 }
9300
9307
9308 static bool classof(const OMPClause *T) {
9309 return T->getClauseKind() == llvm::omp::OMPC_affinity;
9310 }
9311};
9312
9313/// This represents 'filter' clause in the '#pragma omp ...' directive.
9314///
9315/// \code
9316/// #pragma omp masked filter(tid)
9317/// \endcode
9318/// In this example directive '#pragma omp masked' has 'filter' clause with
9319/// thread id.
9321 : public OMPOneStmtClause<llvm::omp::OMPC_filter, OMPClause>,
9322 public OMPClauseWithPreInit {
9323 friend class OMPClauseReader;
9324
9325 /// Sets the thread identifier.
9326 void setThreadID(Expr *TID) { setStmt(TID); }
9327
9328public:
9329 /// Build 'filter' clause with thread-id \a ThreadID.
9330 ///
9331 /// \param ThreadID Thread identifier.
9332 /// \param HelperE Helper expression associated with this clause.
9333 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9334 /// clause must be captured.
9335 /// \param StartLoc Starting location of the clause.
9336 /// \param LParenLoc Location of '('.
9337 /// \param EndLoc Ending location of the clause.
9338 OMPFilterClause(Expr *ThreadID, Stmt *HelperE,
9339 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
9340 SourceLocation LParenLoc, SourceLocation EndLoc)
9341 : OMPOneStmtClause(ThreadID, StartLoc, LParenLoc, EndLoc),
9342 OMPClauseWithPreInit(this) {
9343 setPreInitStmt(HelperE, CaptureRegion);
9344 }
9345
9346 /// Build an empty clause.
9348
9349 /// Return thread identifier.
9350 Expr *getThreadID() const { return getStmtAs<Expr>(); }
9351
9352 /// Return thread identifier.
9354};
9355
9356/// This represents 'bind' clause in the '#pragma omp ...' directives.
9357///
9358/// \code
9359/// #pragma omp loop bind(parallel)
9360/// \endcode
9361class OMPBindClause final : public OMPNoChildClause<llvm::omp::OMPC_bind> {
9362 friend class OMPClauseReader;
9363
9364 /// Location of '('.
9365 SourceLocation LParenLoc;
9366
9367 /// The binding kind of 'bind' clause.
9369
9370 /// Start location of the kind in source code.
9371 SourceLocation KindLoc;
9372
9373 /// Sets the location of '('.
9374 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9375
9376 /// Set the binding kind.
9377 void setBindKind(OpenMPBindClauseKind K) { Kind = K; }
9378
9379 /// Set the binding kind location.
9380 void setBindKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
9381
9382 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9383 ///
9384 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9385 /// \param KLoc Starting location of the binding kind.
9386 /// \param StartLoc Starting location of the clause.
9387 /// \param LParenLoc Location of '('.
9388 /// \param EndLoc Ending location of the clause.
9389 OMPBindClause(OpenMPBindClauseKind K, SourceLocation KLoc,
9390 SourceLocation StartLoc, SourceLocation LParenLoc,
9391 SourceLocation EndLoc)
9392 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Kind(K),
9393 KindLoc(KLoc) {}
9394
9395 /// Build an empty clause.
9396 OMPBindClause() : OMPNoChildClause() {}
9397
9398public:
9399 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9400 ///
9401 /// \param C AST context
9402 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9403 /// \param KLoc Starting location of the binding kind.
9404 /// \param StartLoc Starting location of the clause.
9405 /// \param LParenLoc Location of '('.
9406 /// \param EndLoc Ending location of the clause.
9407 static OMPBindClause *Create(const ASTContext &C, OpenMPBindClauseKind K,
9408 SourceLocation KLoc, SourceLocation StartLoc,
9409 SourceLocation LParenLoc, SourceLocation EndLoc);
9410
9411 /// Build an empty 'bind' clause.
9412 ///
9413 /// \param C AST context
9414 static OMPBindClause *CreateEmpty(const ASTContext &C);
9415
9416 /// Returns the location of '('.
9417 SourceLocation getLParenLoc() const { return LParenLoc; }
9418
9419 /// Returns kind of the clause.
9420 OpenMPBindClauseKind getBindKind() const { return Kind; }
9421
9422 /// Returns location of clause kind.
9423 SourceLocation getBindKindLoc() const { return KindLoc; }
9424};
9425
9426/// This class implements a simple visitor for OMPClause
9427/// subclasses.
9428template<class ImplClass, template <typename> class Ptr, typename RetTy>
9430public:
9431#define PTR(CLASS) Ptr<CLASS>
9432#define DISPATCH(CLASS) \
9433 return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S))
9434
9435#define GEN_CLANG_CLAUSE_CLASS
9436#define CLAUSE_CLASS(Enum, Str, Class) \
9437 RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
9438#include "llvm/Frontend/OpenMP/OMP.inc"
9439
9440 RetTy Visit(PTR(OMPClause) S) {
9441 // Top switch clause: visit each OMPClause.
9442 switch (S->getClauseKind()) {
9443#define GEN_CLANG_CLAUSE_CLASS
9444#define CLAUSE_CLASS(Enum, Str, Class) \
9445 case llvm::omp::Clause::Enum: \
9446 return Visit##Class(static_cast<PTR(Class)>(S));
9447#define CLAUSE_NO_CLASS(Enum, Str) \
9448 case llvm::omp::Clause::Enum: \
9449 break;
9450#include "llvm/Frontend/OpenMP/OMP.inc"
9451 }
9452 }
9453 // Base case, ignore it. :)
9454 RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); }
9455#undef PTR
9456#undef DISPATCH
9457};
9458
9459template <typename T> using const_ptr = std::add_pointer_t<std::add_const_t<T>>;
9460
9461template <class ImplClass, typename RetTy = void>
9463 : public OMPClauseVisitorBase<ImplClass, std::add_pointer_t, RetTy> {};
9464template<class ImplClass, typename RetTy = void>
9466 public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {};
9467
9468class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
9469 raw_ostream &OS;
9470 const PrintingPolicy &Policy;
9471 unsigned Version;
9472
9473 /// Process clauses with list of variables.
9474 template <typename T> void VisitOMPClauseList(T *Node, char StartSym);
9475 /// Process motion clauses.
9476 template <typename T> void VisitOMPMotionClause(T *Node);
9477
9478public:
9479 OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy,
9480 unsigned OpenMPVersion)
9481 : OS(OS), Policy(Policy), Version(OpenMPVersion) {}
9482
9483#define GEN_CLANG_CLAUSE_CLASS
9484#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
9485#include "llvm/Frontend/OpenMP/OMP.inc"
9486};
9487
9489 llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
9490
9491 /// The raw string as we parsed it. This is needed for the `isa` trait set
9492 /// (which accepts anything) and (later) extensions.
9493 StringRef RawString;
9494};
9495
9498 llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
9500};
9501
9503 llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
9505};
9506
9507/// Helper data structure representing the traits in a match clause of an
9508/// `declare variant` or `metadirective`. The outer level is an ordered
9509/// collection of selector sets, each with an associated kind and an ordered
9510/// collection of selectors. A selector has a kind, an optional score/condition,
9511/// and an ordered collection of properties.
9512class OMPTraitInfo {
9513 /// Private constructor accesible only by ASTContext.
9514 OMPTraitInfo() {}
9515 friend class ASTContext;
9516
9517public:
9518 /// Reconstruct a (partial) OMPTraitInfo object from a mangled name.
9519 OMPTraitInfo(StringRef MangledName);
9520
9521 /// The outermost level of selector sets.
9523
9525 llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) {
9526 return llvm::any_of(Sets, [&](OMPTraitSet &Set) {
9527 return llvm::any_of(
9528 Set.Selectors, [&](OMPTraitSelector &Selector) {
9529 return Cond(Selector.ScoreOrCondition,
9530 /* IsScore */ Selector.Kind !=
9531 llvm::omp::TraitSelector::user_condition);
9532 });
9533 });
9534 }
9535
9536 /// Create a variant match info object from this trait info object. While the
9537 /// former is a flat representation the actual main difference is that the
9538 /// latter uses clang::Expr to store the score/condition while the former is
9539 /// independent of clang. Thus, expressions and conditions are evaluated in
9540 /// this method.
9541 void getAsVariantMatchInfo(ASTContext &ASTCtx,
9542 llvm::omp::VariantMatchInfo &VMI) const;
9543
9544 /// Return a string representation identifying this context selector.
9545 std::string getMangledName() const;
9546
9547 /// Check the extension trait \p TP is active.
9548 bool isExtensionActive(llvm::omp::TraitProperty TP) {
9549 for (const OMPTraitSet &Set : Sets) {
9550 if (Set.Kind != llvm::omp::TraitSet::implementation)
9551 continue;
9552 for (const OMPTraitSelector &Selector : Set.Selectors) {
9553 if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
9554 continue;
9555 for (const OMPTraitProperty &Property : Selector.Properties) {
9556 if (Property.Kind == TP)
9557 return true;
9558 }
9559 }
9560 }
9561 return false;
9562 }
9563
9564 /// Print a human readable representation into \p OS.
9565 void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
9566};
9567llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
9568llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
9569
9570/// Clang specific specialization of the OMPContext to lookup target features.
9573 std::function<void(StringRef)> &&DiagUnknownTrait,
9574 const FunctionDecl *CurrentFunctionDecl,
9575 ArrayRef<llvm::omp::TraitProperty> ConstructTraits,
9576 int DeviceNum);
9577
9578 virtual ~TargetOMPContext() = default;
9579
9580 /// See llvm::omp::OMPContext::matchesISATrait
9581 bool matchesISATrait(StringRef RawString) const override;
9582
9583private:
9584 std::function<bool(StringRef)> FeatureValidityCheck;
9585 std::function<void(StringRef)> DiagUnknownTrait;
9586 llvm::StringMap<bool> FeatureMap;
9587};
9588
9589/// Contains data for OpenMP directives: clauses, children
9590/// expressions/statements (helpers for codegen) and associated statement, if
9591/// any.
9592class OMPChildren final
9593 : private llvm::TrailingObjects<OMPChildren, OMPClause *, Stmt *> {
9594 friend TrailingObjects;
9595 friend class OMPClauseReader;
9597 template <typename T> friend class OMPDeclarativeDirective;
9598
9599 /// Numbers of clauses.
9600 unsigned NumClauses = 0;
9601 /// Number of child expressions/stmts.
9602 unsigned NumChildren = 0;
9603 /// true if the directive has associated statement.
9604 bool HasAssociatedStmt = false;
9605
9606 /// Define the sizes of each trailing object array except the last one. This
9607 /// is required for TrailingObjects to work properly.
9608 size_t numTrailingObjects(OverloadToken<OMPClause *>) const {
9609 return NumClauses;
9610 }
9611
9612 OMPChildren() = delete;
9613
9614 OMPChildren(unsigned NumClauses, unsigned NumChildren, bool HasAssociatedStmt)
9615 : NumClauses(NumClauses), NumChildren(NumChildren),
9616 HasAssociatedStmt(HasAssociatedStmt) {}
9617
9618 static size_t size(unsigned NumClauses, bool HasAssociatedStmt,
9619 unsigned NumChildren);
9620
9621 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses);
9622 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses, Stmt *S,
9623 unsigned NumChildren = 0);
9624 static OMPChildren *CreateEmpty(void *Mem, unsigned NumClauses,
9625 bool HasAssociatedStmt = false,
9626 unsigned NumChildren = 0);
9627
9628public:
9629 unsigned getNumClauses() const { return NumClauses; }
9630 unsigned getNumChildren() const { return NumChildren; }
9631 bool hasAssociatedStmt() const { return HasAssociatedStmt; }
9632
9633 /// Set associated statement.
9635 getTrailingObjects<Stmt *>()[NumChildren] = S;
9636 }
9637
9639
9640 /// Sets the list of variables for this clause.
9641 ///
9642 /// \param Clauses The list of clauses for the directive.
9643 ///
9644 void setClauses(ArrayRef<OMPClause *> Clauses);
9645
9646 /// Returns statement associated with the directive.
9647 const Stmt *getAssociatedStmt() const {
9648 return const_cast<OMPChildren *>(this)->getAssociatedStmt();
9649 }
9651 assert(HasAssociatedStmt &&
9652 "Expected directive with the associated statement.");
9653 return getTrailingObjects<Stmt *>()[NumChildren];
9654 }
9655
9656 /// Get the clauses storage.
9658 return getTrailingObjects<OMPClause *>(NumClauses);
9659 }
9661 return const_cast<OMPChildren *>(this)->getClauses();
9662 }
9663
9664 /// Returns the captured statement associated with the
9665 /// component region within the (combined) directive.
9666 ///
9667 /// \param RegionKind Component region kind.
9668 const CapturedStmt *
9670 ArrayRef<OpenMPDirectiveKind> CaptureRegions) const {
9671 assert(llvm::is_contained(CaptureRegions, RegionKind) &&
9672 "RegionKind not found in OpenMP CaptureRegions.");
9674 for (auto ThisCaptureRegion : CaptureRegions) {
9675 if (ThisCaptureRegion == RegionKind)
9676 return CS;
9677 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9678 }
9679 llvm_unreachable("Incorrect RegionKind specified for directive.");
9680 }
9681
9682 /// Get innermost captured statement for the construct.
9683 CapturedStmt *
9685 assert(hasAssociatedStmt() && "Must have associated captured statement.");
9686 assert(!CaptureRegions.empty() &&
9687 "At least one captured statement must be provided.");
9689 for (unsigned Level = CaptureRegions.size(); Level > 1; --Level)
9690 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9691 return CS;
9692 }
9693
9694 const CapturedStmt *
9696 return const_cast<OMPChildren *>(this)->getInnermostCapturedStmt(
9697 CaptureRegions);
9698 }
9699
9702 return const_cast<OMPChildren *>(this)->getChildren();
9703 }
9704
9706 assert(HasAssociatedStmt &&
9707 "Expected directive with the associated statement.");
9708 if (auto *CS = dyn_cast<CapturedStmt>(getAssociatedStmt())) {
9709 Stmt *S = nullptr;
9710 do {
9711 S = CS->getCapturedStmt();
9712 CS = dyn_cast<CapturedStmt>(S);
9713 } while (CS);
9714 return S;
9715 }
9716 return getAssociatedStmt();
9717 }
9718 const Stmt *getRawStmt() const {
9719 return const_cast<OMPChildren *>(this)->getRawStmt();
9720 }
9721
9723 if (!HasAssociatedStmt)
9725 return Stmt::child_range(&getTrailingObjects<Stmt *>()[NumChildren],
9726 &getTrailingObjects<Stmt *>()[NumChildren + 1]);
9727 }
9728};
9729
9730/// This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...'
9731/// directive.
9732///
9733/// \code
9734/// #pragma omp target [...] ompx_dyn_cgroup_mem(N)
9735/// \endcode
9737 : public OMPOneStmtClause<llvm::omp::OMPC_ompx_dyn_cgroup_mem, OMPClause>,
9738 public OMPClauseWithPreInit {
9739 friend class OMPClauseReader;
9740
9741 /// Set size.
9742 void setSize(Expr *E) { setStmt(E); }
9743
9744public:
9745 /// Build 'ompx_dyn_cgroup_mem' clause.
9746 ///
9747 /// \param Size Size expression.
9748 /// \param HelperSize Helper Size expression
9749 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9750 /// \param StartLoc Starting location of the clause.
9751 /// \param LParenLoc Location of '('.
9752 /// \param EndLoc Ending location of the clause.
9754 OpenMPDirectiveKind CaptureRegion,
9755 SourceLocation StartLoc, SourceLocation LParenLoc,
9756 SourceLocation EndLoc)
9757 : OMPOneStmtClause(Size, StartLoc, LParenLoc, EndLoc),
9758 OMPClauseWithPreInit(this) {
9759 setPreInitStmt(HelperSize, CaptureRegion);
9760 }
9761
9762 /// Build an empty clause.
9764
9765 /// Return the size expression.
9767
9768 /// Return the size expression.
9769 Expr *getSize() const { return getStmtAs<Expr>(); }
9770};
9771
9772/// This represents the 'doacross' clause for the '#pragma omp ordered'
9773/// directive.
9774///
9775/// \code
9776/// #pragma omp ordered doacross(sink: i-1, j-1)
9777/// \endcode
9778/// In this example directive '#pragma omp ordered' with clause 'doacross' with
9779/// a dependence-type 'sink' and loop-iteration vector expressions i-1 and j-1.
9780class OMPDoacrossClause final
9781 : public OMPVarListClause<OMPDoacrossClause>,
9782 private llvm::TrailingObjects<OMPDoacrossClause, Expr *> {
9783 friend class OMPClauseReader;
9784 friend OMPVarListClause;
9785 friend TrailingObjects;
9786
9787 /// Dependence type (sink or source).
9789
9790 /// Dependence type location.
9791 SourceLocation DepLoc;
9792
9793 /// Colon location.
9794 SourceLocation ColonLoc;
9795
9796 /// Number of loops, associated with the doacross clause.
9797 unsigned NumLoops = 0;
9798
9799 /// Build clause with number of expressions \a N.
9800 ///
9801 /// \param StartLoc Starting location of the clause.
9802 /// \param LParenLoc Location of '('.
9803 /// \param EndLoc Ending location of the clause.
9804 /// \param N Number of expressions in the clause.
9805 /// \param NumLoops Number of loops associated with the clause.
9806 OMPDoacrossClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9807 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
9808 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross, StartLoc,
9809 LParenLoc, EndLoc, N),
9810 NumLoops(NumLoops) {}
9811
9812 /// Build an empty clause.
9813 ///
9814 /// \param N Number of expressions in the clause.
9815 /// \param NumLoops Number of loops associated with the clause.
9816 explicit OMPDoacrossClause(unsigned N, unsigned NumLoops)
9817 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross,
9819 SourceLocation(), N),
9820 NumLoops(NumLoops) {}
9821
9822 /// Set dependence type.
9823 void setDependenceType(OpenMPDoacrossClauseModifier M) { DepType = M; }
9824
9825 /// Set dependence type location.
9826 void setDependenceLoc(SourceLocation Loc) { DepLoc = Loc; }
9827
9828 /// Set colon location.
9829 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
9830
9831public:
9832 /// Creates clause with a list of expressions \a VL.
9833 ///
9834 /// \param C AST context.
9835 /// \param StartLoc Starting location of the clause.
9836 /// \param LParenLoc Location of '('.
9837 /// \param EndLoc Ending location of the clause.
9838 /// \param DepType The dependence type.
9839 /// \param DepLoc Location of the dependence type.
9840 /// \param ColonLoc Location of ':'.
9841 /// \param VL List of references to the expressions.
9842 /// \param NumLoops Number of loops that associated with the clause.
9843 static OMPDoacrossClause *
9844 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
9845 SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType,
9846 SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
9847 unsigned NumLoops);
9848
9849 /// Creates an empty clause with \a N expressions.
9850 ///
9851 /// \param C AST context.
9852 /// \param N The number of expressions.
9853 /// \param NumLoops Number of loops that is associated with this clause.
9854 static OMPDoacrossClause *CreateEmpty(const ASTContext &C, unsigned N,
9855 unsigned NumLoops);
9856
9857 /// Get dependence type.
9859
9860 /// Get dependence type location.
9861 SourceLocation getDependenceLoc() const { return DepLoc; }
9862
9863 /// Get colon location.
9864 SourceLocation getColonLoc() const { return ColonLoc; }
9865
9866 /// Get number of loops associated with the clause.
9867 unsigned getNumLoops() const { return NumLoops; }
9868
9869 /// Set the loop data.
9870 void setLoopData(unsigned NumLoop, Expr *Cnt);
9871
9872 /// Get the loop data.
9873 Expr *getLoopData(unsigned NumLoop);
9874 const Expr *getLoopData(unsigned NumLoop) const;
9875
9877 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9878 reinterpret_cast<Stmt **>(varlist_end()));
9879 }
9880
9882 auto Children = const_cast<OMPDoacrossClause *>(this)->children();
9883 return const_child_range(Children.begin(), Children.end());
9884 }
9885
9892
9893 static bool classof(const OMPClause *T) {
9894 return T->getClauseKind() == llvm::omp::OMPC_doacross;
9895 }
9896};
9897
9898/// This represents 'ompx_attribute' clause in a directive that might generate
9899/// an outlined function. An example is given below.
9900///
9901/// \code
9902/// #pragma omp target [...] ompx_attribute(flatten)
9903/// \endcode
9905 : public OMPNoChildClause<llvm::omp::OMPC_ompx_attribute> {
9906 friend class OMPClauseReader;
9907
9908 /// Location of '('.
9909 SourceLocation LParenLoc;
9910
9911 /// The parsed attributes (clause arguments)
9913
9914public:
9915 /// Build 'ompx_attribute' clause.
9916 ///
9917 /// \param Attrs The parsed attributes (clause arguments)
9918 /// \param StartLoc Starting location of the clause.
9919 /// \param LParenLoc Location of '('.
9920 /// \param EndLoc Ending location of the clause.
9922 SourceLocation LParenLoc, SourceLocation EndLoc)
9923 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Attrs(Attrs) {
9924 }
9925
9926 /// Build an empty clause.
9928
9929 /// Sets the location of '('.
9930 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9931
9932 /// Returns the location of '('.
9933 SourceLocation getLParenLoc() const { return LParenLoc; }
9934
9935 /// Returned the attributes parsed from this clause.
9936 ArrayRef<const Attr *> getAttrs() const { return Attrs; }
9937
9938private:
9939 /// Replace the attributes with \p NewAttrs.
9940 void setAttrs(ArrayRef<Attr *> NewAttrs) {
9941 Attrs.clear();
9942 Attrs.append(NewAttrs.begin(), NewAttrs.end());
9943 }
9944};
9945
9946/// This represents 'ompx_bare' clause in the '#pragma omp target teams ...'
9947/// directive.
9948///
9949/// \code
9950/// #pragma omp target teams ompx_bare
9951/// \endcode
9952/// In this example directive '#pragma omp target teams' has a 'ompx_bare'
9953/// clause.
9954class OMPXBareClause : public OMPNoChildClause<llvm::omp::OMPC_ompx_bare> {
9955public:
9956 /// Build 'ompx_bare' clause.
9957 ///
9958 /// \param StartLoc Starting location of the clause.
9959 /// \param EndLoc Ending location of the clause.
9961 : OMPNoChildClause(StartLoc, EndLoc) {}
9962
9963 /// Build an empty clause.
9964 OMPXBareClause() = default;
9965};
9966
9967} // namespace clang
9968
9969#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:188
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:188
This captures a statement into a function.
Definition Stmt.h:3886
This represents one expression.
Definition Expr.h:112
Represents a function declaration or definition.
Definition Decl.h:1999
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
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
SmallVector< MappableExprComponentList, 8 > MappableExprComponentLists
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.
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)
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
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.
OMPNowaitClause(SourceLocation StartLoc=SourceLocation(), SourceLocation EndLoc=SourceLocation())
Build 'nowait' clause.
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.
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.
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.
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:1558
llvm::iterator_range< child_iterator > child_range
Definition Stmt.h:1561
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:711
#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
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
Definition OpenMPKinds.h:88
@ 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
OpenMPNumThreadsClauseModifier
@ OMPC_NUMTHREADS_unknown
OpenMPAtomicDefaultMemOrderClauseKind
OpenMP attributes for 'atomic_default_mem_order' clause.
@ OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
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
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
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