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