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