Thanks to visit codestin.com
Credit goes to clang.llvm.org

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 'proc_bind' clause in the '#pragma omp ...'
1428/// directive.
1429///
1430/// \code
1431/// #pragma omp parallel proc_bind(master)
1432/// \endcode
1433/// In this example directive '#pragma omp parallel' has simple 'proc_bind'
1434/// clause with kind 'master'.
1436 friend class OMPClauseReader;
1437
1438 /// Location of '('.
1439 SourceLocation LParenLoc;
1440
1441 /// A kind of the 'proc_bind' clause.
1442 llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown;
1443
1444 /// Start location of the kind in source code.
1445 SourceLocation KindKwLoc;
1446
1447 /// Set kind of the clause.
1448 ///
1449 /// \param K Kind of clause.
1450 void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; }
1451
1452 /// Set clause kind location.
1453 ///
1454 /// \param KLoc Kind location.
1455 void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1456
1457public:
1458 /// Build 'proc_bind' clause with argument \a A ('master', 'close' or
1459 /// 'spread').
1460 ///
1461 /// \param A Argument of the clause ('master', 'close' or 'spread').
1462 /// \param ALoc Starting location of the argument.
1463 /// \param StartLoc Starting location of the clause.
1464 /// \param LParenLoc Location of '('.
1465 /// \param EndLoc Ending location of the clause.
1466 OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc,
1467 SourceLocation StartLoc, SourceLocation LParenLoc,
1468 SourceLocation EndLoc)
1469 : OMPClause(llvm::omp::OMPC_proc_bind, StartLoc, EndLoc),
1470 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1471
1472 /// Build an empty clause.
1474 : OMPClause(llvm::omp::OMPC_proc_bind, SourceLocation(),
1475 SourceLocation()) {}
1476
1477 /// Sets the location of '('.
1478 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1479
1480 /// Returns the location of '('.
1481 SourceLocation getLParenLoc() const { return LParenLoc; }
1482
1483 /// Returns kind of the clause.
1484 llvm::omp::ProcBindKind getProcBindKind() const { return Kind; }
1485
1486 /// Returns location of clause kind.
1487 SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
1488
1492
1496
1503
1504 static bool classof(const OMPClause *T) {
1505 return T->getClauseKind() == llvm::omp::OMPC_proc_bind;
1506 }
1507};
1508
1509/// This represents 'unified_address' clause in the '#pragma omp requires'
1510/// directive.
1511///
1512/// \code
1513/// #pragma omp requires unified_address
1514/// \endcode
1515/// In this example directive '#pragma omp requires' has 'unified_address'
1516/// clause.
1518 : public OMPNoChildClause<llvm::omp::OMPC_unified_address> {
1519public:
1520 friend class OMPClauseReader;
1521 /// Build 'unified_address' clause.
1522 ///
1523 /// \param StartLoc Starting location of the clause.
1524 /// \param EndLoc Ending location of the clause.
1526 : OMPNoChildClause(StartLoc, EndLoc) {}
1527
1528 /// Build an empty clause.
1530};
1531
1532/// This represents 'unified_shared_memory' clause in the '#pragma omp requires'
1533/// directive.
1534///
1535/// \code
1536/// #pragma omp requires unified_shared_memory
1537/// \endcode
1538/// In this example directive '#pragma omp requires' has 'unified_shared_memory'
1539/// clause.
1541public:
1542 friend class OMPClauseReader;
1543 /// Build 'unified_shared_memory' clause.
1544 ///
1545 /// \param StartLoc Starting location of the clause.
1546 /// \param EndLoc Ending location of the clause.
1548 : OMPClause(llvm::omp::OMPC_unified_shared_memory, StartLoc, EndLoc) {}
1549
1550 /// Build an empty clause.
1552 : OMPClause(llvm::omp::OMPC_unified_shared_memory, SourceLocation(),
1553 SourceLocation()) {}
1554
1558
1562
1569
1570 static bool classof(const OMPClause *T) {
1571 return T->getClauseKind() == llvm::omp::OMPC_unified_shared_memory;
1572 }
1573};
1574
1575/// This represents 'reverse_offload' clause in the '#pragma omp requires'
1576/// directive.
1577///
1578/// \code
1579/// #pragma omp requires reverse_offload
1580/// \endcode
1581/// In this example directive '#pragma omp requires' has 'reverse_offload'
1582/// clause.
1584public:
1585 friend class OMPClauseReader;
1586 /// Build 'reverse_offload' clause.
1587 ///
1588 /// \param StartLoc Starting location of the clause.
1589 /// \param EndLoc Ending location of the clause.
1591 : OMPClause(llvm::omp::OMPC_reverse_offload, StartLoc, EndLoc) {}
1592
1593 /// Build an empty clause.
1595 : OMPClause(llvm::omp::OMPC_reverse_offload, SourceLocation(),
1596 SourceLocation()) {}
1597
1601
1605
1612
1613 static bool classof(const OMPClause *T) {
1614 return T->getClauseKind() == llvm::omp::OMPC_reverse_offload;
1615 }
1616};
1617
1618/// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
1619/// directive.
1620///
1621/// \code
1622/// #pragma omp requires dynamic_allocators
1623/// \endcode
1624/// In this example directive '#pragma omp requires' has 'dynamic_allocators'
1625/// clause.
1627public:
1628 friend class OMPClauseReader;
1629 /// Build 'dynamic_allocators' clause.
1630 ///
1631 /// \param StartLoc Starting location of the clause.
1632 /// \param EndLoc Ending location of the clause.
1634 : OMPClause(llvm::omp::OMPC_dynamic_allocators, StartLoc, EndLoc) {}
1635
1636 /// Build an empty clause.
1638 : OMPClause(llvm::omp::OMPC_dynamic_allocators, SourceLocation(),
1639 SourceLocation()) {}
1640
1644
1648
1655
1656 static bool classof(const OMPClause *T) {
1657 return T->getClauseKind() == llvm::omp::OMPC_dynamic_allocators;
1658 }
1659};
1660
1661/// This represents 'atomic_default_mem_order' clause in the '#pragma omp
1662/// requires' directive.
1663///
1664/// \code
1665/// #pragma omp requires atomic_default_mem_order(seq_cst)
1666/// \endcode
1667/// In this example directive '#pragma omp requires' has simple
1668/// atomic_default_mem_order' clause with kind 'seq_cst'.
1670 friend class OMPClauseReader;
1671
1672 /// Location of '('
1673 SourceLocation LParenLoc;
1674
1675 /// A kind of the 'atomic_default_mem_order' clause.
1678
1679 /// Start location of the kind in source code.
1680 SourceLocation KindKwLoc;
1681
1682 /// Set kind of the clause.
1683 ///
1684 /// \param K Kind of clause.
1685 void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) {
1686 Kind = K;
1687 }
1688
1689 /// Set clause kind location.
1690 ///
1691 /// \param KLoc Kind location.
1692 void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) {
1693 KindKwLoc = KLoc;
1694 }
1695
1696public:
1697 /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst',
1698 /// 'acq_rel' or 'relaxed').
1699 ///
1700 /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed').
1701 /// \param ALoc Starting location of the argument.
1702 /// \param StartLoc Starting location of the clause.
1703 /// \param LParenLoc Location of '('.
1704 /// \param EndLoc Ending location of the clause.
1706 SourceLocation ALoc, SourceLocation StartLoc,
1707 SourceLocation LParenLoc,
1708 SourceLocation EndLoc)
1709 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, StartLoc, EndLoc),
1710 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1711
1712 /// Build an empty clause.
1714 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, SourceLocation(),
1715 SourceLocation()) {}
1716
1717 /// Sets the location of '('.
1718 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1719
1720 /// Returns the locaiton of '('.
1721 SourceLocation getLParenLoc() const { return LParenLoc; }
1722
1723 /// Returns kind of the clause.
1727
1728 /// Returns location of clause kind.
1730
1734
1738
1745
1746 static bool classof(const OMPClause *T) {
1747 return T->getClauseKind() == llvm::omp::OMPC_atomic_default_mem_order;
1748 }
1749};
1750
1751/// This represents 'self_maps' clause in the '#pragma omp requires'
1752/// directive.
1753///
1754/// \code
1755/// #pragma omp requires self_maps
1756/// \endcode
1757/// In this example directive '#pragma omp requires' has 'self_maps'
1758/// clause.
1759class OMPSelfMapsClause final : public OMPClause {
1760public:
1761 friend class OMPClauseReader;
1762 /// Build 'self_maps' clause.
1763 ///
1764 /// \param StartLoc Starting location of the clause.
1765 /// \param EndLoc Ending location of the clause.
1767 : OMPClause(llvm::omp::OMPC_self_maps, StartLoc, EndLoc) {}
1768
1769 /// Build an empty clause.
1771 : OMPClause(llvm::omp::OMPC_self_maps, SourceLocation(),
1772 SourceLocation()) {}
1773
1777
1781
1788
1789 static bool classof(const OMPClause *T) {
1790 return T->getClauseKind() == llvm::omp::OMPC_self_maps;
1791 }
1792};
1793
1794/// This represents 'at' clause in the '#pragma omp error' directive
1795///
1796/// \code
1797/// #pragma omp error at(compilation)
1798/// \endcode
1799/// In this example directive '#pragma omp error' has simple
1800/// 'at' clause with kind 'complilation'.
1801class OMPAtClause final : public OMPClause {
1802 friend class OMPClauseReader;
1803
1804 /// Location of '('
1805 SourceLocation LParenLoc;
1806
1807 /// A kind of the 'at' clause.
1809
1810 /// Start location of the kind in source code.
1811 SourceLocation KindKwLoc;
1812
1813 /// Set kind of the clause.
1814 ///
1815 /// \param K Kind of clause.
1816 void setAtKind(OpenMPAtClauseKind K) { Kind = K; }
1817
1818 /// Set clause kind location.
1819 ///
1820 /// \param KLoc Kind location.
1821 void setAtKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1822
1823 /// Sets the location of '('.
1824 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1825
1826public:
1827 /// Build 'at' clause with argument \a A ('compilation' or 'execution').
1828 ///
1829 /// \param A Argument of the clause ('compilation' or 'execution').
1830 /// \param ALoc Starting location of the argument.
1831 /// \param StartLoc Starting location of the clause.
1832 /// \param LParenLoc Location of '('.
1833 /// \param EndLoc Ending location of the clause.
1835 SourceLocation StartLoc, SourceLocation LParenLoc,
1836 SourceLocation EndLoc)
1837 : OMPClause(llvm::omp::OMPC_at, StartLoc, EndLoc), LParenLoc(LParenLoc),
1838 Kind(A), KindKwLoc(ALoc) {}
1839
1840 /// Build an empty clause.
1842 : OMPClause(llvm::omp::OMPC_at, SourceLocation(), SourceLocation()) {}
1843
1844 /// Returns the locaiton of '('.
1845 SourceLocation getLParenLoc() const { return LParenLoc; }
1846
1847 /// Returns kind of the clause.
1848 OpenMPAtClauseKind getAtKind() const { return Kind; }
1849
1850 /// Returns location of clause kind.
1851 SourceLocation getAtKindKwLoc() const { return KindKwLoc; }
1852
1856
1860
1867
1868 static bool classof(const OMPClause *T) {
1869 return T->getClauseKind() == llvm::omp::OMPC_at;
1870 }
1871};
1872
1873/// This represents the 'severity' clause in the '#pragma omp error' and the
1874/// '#pragma omp parallel' directives.
1875///
1876/// \code
1877/// #pragma omp error severity(fatal)
1878/// \endcode
1879/// In this example directive '#pragma omp error' has simple
1880/// 'severity' clause with kind 'fatal'.
1881class OMPSeverityClause final : public OMPClause {
1882 friend class OMPClauseReader;
1883
1884 /// Location of '('
1885 SourceLocation LParenLoc;
1886
1887 /// A kind of the 'severity' 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 setSeverityKind(OpenMPSeverityClauseKind K) { Kind = K; }
1897
1898 /// Set clause kind location.
1899 ///
1900 /// \param KLoc Kind location.
1901 void setSeverityKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1902
1903 /// Sets the location of '('.
1904 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1905
1906public:
1907 /// Build 'severity' clause with argument \a A ('fatal' or 'warning').
1908 ///
1909 /// \param A Argument of the clause ('fatal' or 'warning').
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_severity, StartLoc, EndLoc),
1918 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1919
1920 /// Build an empty clause.
1922 : OMPClause(llvm::omp::OMPC_severity, SourceLocation(),
1923 SourceLocation()) {}
1924
1925 /// Returns the locaiton of '('.
1926 SourceLocation getLParenLoc() const { return LParenLoc; }
1927
1928 /// Returns kind of the clause.
1930
1931 /// Returns location of clause kind.
1932 SourceLocation getSeverityKindKwLoc() const { return KindKwLoc; }
1933
1937
1941
1948
1949 static bool classof(const OMPClause *T) {
1950 return T->getClauseKind() == llvm::omp::OMPC_severity;
1951 }
1952};
1953
1954/// This represents the 'message' clause in the '#pragma omp error' and the
1955/// '#pragma omp parallel' directives.
1956///
1957/// \code
1958/// #pragma omp error message("GNU compiler required.")
1959/// \endcode
1960/// In this example directive '#pragma omp error' has simple
1961/// 'message' clause with user error message of "GNU compiler required.".
1963 : public OMPOneStmtClause<llvm::omp::OMPC_message, OMPClause>,
1964 public OMPClauseWithPreInit {
1965 friend class OMPClauseReader;
1966
1967 /// Set message string of the clause.
1968 void setMessageString(Expr *MS) { setStmt(MS); }
1969
1970public:
1971 /// Build 'message' clause with message string argument
1972 ///
1973 /// \param MS Argument of the clause (message string).
1974 /// \param HelperMS Helper statement for the construct.
1975 /// \param CaptureRegion Innermost OpenMP region where expressions in this
1976 /// clause must be captured.
1977 /// \param StartLoc Starting location of the clause.
1978 /// \param LParenLoc Location of '('.
1979 /// \param EndLoc Ending location of the clause.
1980 OMPMessageClause(Expr *MS, Stmt *HelperMS, OpenMPDirectiveKind CaptureRegion,
1981 SourceLocation StartLoc, SourceLocation LParenLoc,
1982 SourceLocation EndLoc)
1983 : OMPOneStmtClause(MS, StartLoc, LParenLoc, EndLoc),
1984 OMPClauseWithPreInit(this) {
1985 setPreInitStmt(HelperMS, CaptureRegion);
1986 }
1987
1988 /// Build an empty clause.
1990
1991 /// Returns message string of the clause.
1993
1994 /// Try to evaluate the message string at compile time.
1995 std::optional<std::string> tryEvaluateString(ASTContext &Ctx) const {
1996 if (Expr *MessageExpr = getMessageString())
1997 return MessageExpr->tryEvaluateString(Ctx);
1998 return std::nullopt;
1999 }
2000};
2001
2002/// This represents 'schedule' clause in the '#pragma omp ...' directive.
2003///
2004/// \code
2005/// #pragma omp for schedule(static, 3)
2006/// \endcode
2007/// In this example directive '#pragma omp for' has 'schedule' clause with
2008/// arguments 'static' and '3'.
2010 friend class OMPClauseReader;
2011
2012 /// Location of '('.
2013 SourceLocation LParenLoc;
2014
2015 /// A kind of the 'schedule' clause.
2017
2018 /// Modifiers for 'schedule' clause.
2019 enum {FIRST, SECOND, NUM_MODIFIERS};
2020 OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
2021
2022 /// Locations of modifiers.
2023 SourceLocation ModifiersLoc[NUM_MODIFIERS];
2024
2025 /// Start location of the schedule ind in source code.
2026 SourceLocation KindLoc;
2027
2028 /// Location of ',' (if any).
2029 SourceLocation CommaLoc;
2030
2031 /// Chunk size.
2032 Expr *ChunkSize = nullptr;
2033
2034 /// Set schedule kind.
2035 ///
2036 /// \param K Schedule kind.
2037 void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
2038
2039 /// Set the first schedule modifier.
2040 ///
2041 /// \param M Schedule modifier.
2042 void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
2043 Modifiers[FIRST] = M;
2044 }
2045
2046 /// Set the second schedule modifier.
2047 ///
2048 /// \param M Schedule modifier.
2049 void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
2050 Modifiers[SECOND] = M;
2051 }
2052
2053 /// Set location of the first schedule modifier.
2054 void setFirstScheduleModifierLoc(SourceLocation Loc) {
2055 ModifiersLoc[FIRST] = Loc;
2056 }
2057
2058 /// Set location of the second schedule modifier.
2059 void setSecondScheduleModifierLoc(SourceLocation Loc) {
2060 ModifiersLoc[SECOND] = Loc;
2061 }
2062
2063 /// Set schedule modifier location.
2064 ///
2065 /// \param M Schedule modifier location.
2066 void setScheduleModifer(OpenMPScheduleClauseModifier M) {
2067 if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
2068 Modifiers[FIRST] = M;
2069 else {
2070 assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
2071 Modifiers[SECOND] = M;
2072 }
2073 }
2074
2075 /// Sets the location of '('.
2076 ///
2077 /// \param Loc Location of '('.
2078 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2079
2080 /// Set schedule kind start location.
2081 ///
2082 /// \param KLoc Schedule kind location.
2083 void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
2084
2085 /// Set location of ','.
2086 ///
2087 /// \param Loc Location of ','.
2088 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
2089
2090 /// Set chunk size.
2091 ///
2092 /// \param E Chunk size.
2093 void setChunkSize(Expr *E) { ChunkSize = E; }
2094
2095public:
2096 /// Build 'schedule' clause with schedule kind \a Kind and chunk size
2097 /// expression \a ChunkSize.
2098 ///
2099 /// \param StartLoc Starting location of the clause.
2100 /// \param LParenLoc Location of '('.
2101 /// \param KLoc Starting location of the argument.
2102 /// \param CommaLoc Location of ','.
2103 /// \param EndLoc Ending location of the clause.
2104 /// \param Kind Schedule kind.
2105 /// \param ChunkSize Chunk size.
2106 /// \param HelperChunkSize Helper chunk size for combined directives.
2107 /// \param M1 The first modifier applied to 'schedule' clause.
2108 /// \param M1Loc Location of the first modifier
2109 /// \param M2 The second modifier applied to 'schedule' clause.
2110 /// \param M2Loc Location of the second modifier
2112 SourceLocation KLoc, SourceLocation CommaLoc,
2114 Expr *ChunkSize, Stmt *HelperChunkSize,
2117 : OMPClause(llvm::omp::OMPC_schedule, StartLoc, EndLoc),
2118 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
2119 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
2120 setPreInitStmt(HelperChunkSize);
2121 Modifiers[FIRST] = M1;
2122 Modifiers[SECOND] = M2;
2123 ModifiersLoc[FIRST] = M1Loc;
2124 ModifiersLoc[SECOND] = M2Loc;
2125 }
2126
2127 /// Build an empty clause.
2129 : OMPClause(llvm::omp::OMPC_schedule, SourceLocation(), SourceLocation()),
2130 OMPClauseWithPreInit(this) {
2131 Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
2132 Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
2133 }
2134
2135 /// Get kind of the clause.
2137
2138 /// Get the first modifier of the clause.
2140 return Modifiers[FIRST];
2141 }
2142
2143 /// Get the second modifier of the clause.
2145 return Modifiers[SECOND];
2146 }
2147
2148 /// Get location of '('.
2149 SourceLocation getLParenLoc() { return LParenLoc; }
2150
2151 /// Get kind location.
2153
2154 /// Get the first modifier location.
2156 return ModifiersLoc[FIRST];
2157 }
2158
2159 /// Get the second modifier location.
2161 return ModifiersLoc[SECOND];
2162 }
2163
2164 /// Get location of ','.
2165 SourceLocation getCommaLoc() { return CommaLoc; }
2166
2167 /// Get chunk size.
2168 Expr *getChunkSize() { return ChunkSize; }
2169
2170 /// Get chunk size.
2171 const Expr *getChunkSize() const { return ChunkSize; }
2172
2174 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
2175 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
2176 }
2177
2179 auto Children = const_cast<OMPScheduleClause *>(this)->children();
2180 return const_child_range(Children.begin(), Children.end());
2181 }
2182
2189
2190 static bool classof(const OMPClause *T) {
2191 return T->getClauseKind() == llvm::omp::OMPC_schedule;
2192 }
2193};
2194
2195/// This represents 'ordered' clause in the '#pragma omp ...' directive.
2196///
2197/// \code
2198/// #pragma omp for ordered (2)
2199/// \endcode
2200/// In this example directive '#pragma omp for' has 'ordered' clause with
2201/// parameter 2.
2202class OMPOrderedClause final
2203 : public OMPClause,
2204 private llvm::TrailingObjects<OMPOrderedClause, Expr *> {
2205 friend class OMPClauseReader;
2206 friend TrailingObjects;
2207
2208 /// Location of '('.
2209 SourceLocation LParenLoc;
2210
2211 /// Number of for-loops.
2212 Stmt *NumForLoops = nullptr;
2213
2214 /// Real number of loops.
2215 unsigned NumberOfLoops = 0;
2216
2217 /// Build 'ordered' clause.
2218 ///
2219 /// \param Num Expression, possibly associated with this clause.
2220 /// \param NumLoops Number of loops, associated with this clause.
2221 /// \param StartLoc Starting location of the clause.
2222 /// \param LParenLoc Location of '('.
2223 /// \param EndLoc Ending location of the clause.
2224 OMPOrderedClause(Expr *Num, unsigned NumLoops, SourceLocation StartLoc,
2225 SourceLocation LParenLoc, SourceLocation EndLoc)
2226 : OMPClause(llvm::omp::OMPC_ordered, StartLoc, EndLoc),
2227 LParenLoc(LParenLoc), NumForLoops(Num), NumberOfLoops(NumLoops) {}
2228
2229 /// Build an empty clause.
2230 explicit OMPOrderedClause(unsigned NumLoops)
2231 : OMPClause(llvm::omp::OMPC_ordered, SourceLocation(), SourceLocation()),
2232 NumberOfLoops(NumLoops) {}
2233
2234 /// Set the number of associated for-loops.
2235 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
2236
2237public:
2238 /// Build 'ordered' clause.
2239 ///
2240 /// \param Num Expression, possibly associated with this clause.
2241 /// \param NumLoops Number of loops, associated with this clause.
2242 /// \param StartLoc Starting location of the clause.
2243 /// \param LParenLoc Location of '('.
2244 /// \param EndLoc Ending location of the clause.
2245 static OMPOrderedClause *Create(const ASTContext &C, Expr *Num,
2246 unsigned NumLoops, SourceLocation StartLoc,
2247 SourceLocation LParenLoc,
2248 SourceLocation EndLoc);
2249
2250 /// Build an empty clause.
2251 static OMPOrderedClause* CreateEmpty(const ASTContext &C, unsigned NumLoops);
2252
2253 /// Sets the location of '('.
2254 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2255
2256 /// Returns the location of '('.
2257 SourceLocation getLParenLoc() const { return LParenLoc; }
2258
2259 /// Return the number of associated for-loops.
2260 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
2261
2262 /// Set number of iterations for the specified loop.
2263 void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations);
2264 /// Get number of iterations for all the loops.
2266
2267 /// Set loop counter for the specified loop.
2268 void setLoopCounter(unsigned NumLoop, Expr *Counter);
2269 /// Get loops counter for the specified loop.
2270 Expr *getLoopCounter(unsigned NumLoop);
2271 const Expr *getLoopCounter(unsigned NumLoop) const;
2272
2273 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
2274
2276 return const_child_range(&NumForLoops, &NumForLoops + 1);
2277 }
2278
2285
2286 static bool classof(const OMPClause *T) {
2287 return T->getClauseKind() == llvm::omp::OMPC_ordered;
2288 }
2289};
2290
2291/// This represents 'nowait' clause in the '#pragma omp ...' directive.
2292///
2293/// \code
2294/// #pragma omp for nowait
2295/// \endcode
2296/// In this example directive '#pragma omp for' has 'nowait' clause.
2297class OMPNowaitClause final : public OMPNoChildClause<llvm::omp::OMPC_nowait> {
2298public:
2299 /// Build 'nowait' clause.
2300 ///
2301 /// \param StartLoc Starting location of the clause.
2302 /// \param EndLoc Ending location of the clause.
2304 SourceLocation EndLoc = SourceLocation())
2305 : OMPNoChildClause(StartLoc, EndLoc) {}
2306};
2307
2308/// This represents 'untied' clause in the '#pragma omp ...' directive.
2309///
2310/// \code
2311/// #pragma omp task untied
2312/// \endcode
2313/// In this example directive '#pragma omp task' has 'untied' clause.
2315public:
2316 /// Build 'untied' clause.
2317 ///
2318 /// \param StartLoc Starting location of the clause.
2319 /// \param EndLoc Ending location of the clause.
2321 : OMPClause(llvm::omp::OMPC_untied, StartLoc, EndLoc) {}
2322
2323 /// Build an empty clause.
2325 : OMPClause(llvm::omp::OMPC_untied, SourceLocation(), SourceLocation()) {}
2326
2330
2334
2341
2342 static bool classof(const OMPClause *T) {
2343 return T->getClauseKind() == llvm::omp::OMPC_untied;
2344 }
2345};
2346
2347/// This represents 'mergeable' clause in the '#pragma omp ...'
2348/// directive.
2349///
2350/// \code
2351/// #pragma omp task mergeable
2352/// \endcode
2353/// In this example directive '#pragma omp task' has 'mergeable' clause.
2355public:
2356 /// Build 'mergeable' clause.
2357 ///
2358 /// \param StartLoc Starting location of the clause.
2359 /// \param EndLoc Ending location of the clause.
2361 : OMPClause(llvm::omp::OMPC_mergeable, StartLoc, EndLoc) {}
2362
2363 /// Build an empty clause.
2365 : OMPClause(llvm::omp::OMPC_mergeable, SourceLocation(),
2366 SourceLocation()) {}
2367
2371
2375
2382
2383 static bool classof(const OMPClause *T) {
2384 return T->getClauseKind() == llvm::omp::OMPC_mergeable;
2385 }
2386};
2387
2388/// This represents the 'absent' clause in the '#pragma omp assume'
2389/// directive.
2390///
2391/// \code
2392/// #pragma omp assume absent(<directive-name list>)
2393/// \endcode
2394/// In this example directive '#pragma omp assume' has an 'absent' clause.
2395class OMPAbsentClause final
2396 : public OMPDirectiveListClause<OMPAbsentClause>,
2397 private llvm::TrailingObjects<OMPAbsentClause, OpenMPDirectiveKind> {
2398 friend OMPDirectiveListClause;
2399 friend TrailingObjects;
2400
2401 /// Build 'absent' clause.
2402 ///
2403 /// \param StartLoc Starting location of the clause.
2404 /// \param LParenLoc Location of '('.
2405 /// \param EndLoc Ending location of the clause.
2406 /// \param NumKinds Number of directive kinds listed in the clause.
2407 OMPAbsentClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2408 SourceLocation EndLoc, unsigned NumKinds)
2409 : OMPDirectiveListClause<OMPAbsentClause>(
2410 llvm::omp::OMPC_absent, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2411
2412 /// Build an empty clause.
2413 OMPAbsentClause(unsigned NumKinds)
2414 : OMPDirectiveListClause<OMPAbsentClause>(
2415 llvm::omp::OMPC_absent, SourceLocation(), SourceLocation(),
2417
2418public:
2419 static OMPAbsentClause *Create(const ASTContext &C,
2422 SourceLocation RLoc);
2423
2424 static OMPAbsentClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2425
2426 static bool classof(const OMPClause *C) {
2427 return C->getClauseKind() == llvm::omp::OMPC_absent;
2428 }
2429};
2430
2431/// This represents the 'contains' clause in the '#pragma omp assume'
2432/// directive.
2433///
2434/// \code
2435/// #pragma omp assume contains(<directive-name list>)
2436/// \endcode
2437/// In this example directive '#pragma omp assume' has a 'contains' clause.
2438class OMPContainsClause final
2439 : public OMPDirectiveListClause<OMPContainsClause>,
2440 private llvm::TrailingObjects<OMPContainsClause, OpenMPDirectiveKind> {
2441 friend OMPDirectiveListClause;
2442 friend TrailingObjects;
2443
2444 /// Build 'contains' clause.
2445 ///
2446 /// \param StartLoc Starting location of the clause.
2447 /// \param LParenLoc Location of '('.
2448 /// \param EndLoc Ending location of the clause.
2449 /// \param NumKinds Number of directive kinds listed in the clause.
2450 OMPContainsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2451 SourceLocation EndLoc, unsigned NumKinds)
2452 : OMPDirectiveListClause<OMPContainsClause>(
2453 llvm::omp::OMPC_contains, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2454
2455 /// Build an empty clause.
2456 OMPContainsClause(unsigned NumKinds)
2457 : OMPDirectiveListClause<OMPContainsClause>(
2458 llvm::omp::OMPC_contains, SourceLocation(), SourceLocation(),
2460
2461public:
2462 static OMPContainsClause *Create(const ASTContext &C,
2465 SourceLocation RLoc);
2466
2467 static OMPContainsClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2468
2469 static bool classof(const OMPClause *C) {
2470 return C->getClauseKind() == llvm::omp::OMPC_contains;
2471 }
2472};
2473
2474/// This represents the 'holds' clause in the '#pragma omp assume'
2475/// directive.
2476///
2477/// \code
2478/// #pragma omp assume holds(<expr>)
2479/// \endcode
2480/// In this example directive '#pragma omp assume' has a 'holds' clause.
2482 : public OMPOneStmtClause<llvm::omp::OMPC_holds, OMPClause> {
2483 friend class OMPClauseReader;
2484
2485public:
2486 /// Build 'holds' clause.
2487 ///
2488 /// \param StartLoc Starting location of the clause.
2489 /// \param EndLoc Ending location of the clause.
2491 SourceLocation EndLoc)
2492 : OMPOneStmtClause(E, StartLoc, LParenLoc, EndLoc) {}
2493
2494 /// Build an empty clause.
2496
2497 Expr *getExpr() const { return getStmtAs<Expr>(); }
2498 void setExpr(Expr *E) { setStmt(E); }
2499};
2500
2501/// This represents the 'no_openmp' clause in the '#pragma omp assume'
2502/// directive.
2503///
2504/// \code
2505/// #pragma omp assume no_openmp
2506/// \endcode
2507/// In this example directive '#pragma omp assume' has a 'no_openmp' clause.
2509 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp> {
2510public:
2511 /// Build 'no_openmp' clause.
2512 ///
2513 /// \param StartLoc Starting location of the clause.
2514 /// \param EndLoc Ending location of the clause.
2516 : OMPNoChildClause(StartLoc, EndLoc) {}
2517
2518 /// Build an empty clause.
2520};
2521
2522/// This represents the 'no_openmp_routines' clause in the '#pragma omp assume'
2523/// directive.
2524///
2525/// \code
2526/// #pragma omp assume no_openmp_routines
2527/// \endcode
2528/// In this example directive '#pragma omp assume' has a 'no_openmp_routines'
2529/// clause.
2531 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp_routines> {
2532public:
2533 /// Build 'no_openmp_routines' clause.
2534 ///
2535 /// \param StartLoc Starting location of the clause.
2536 /// \param EndLoc Ending location of the clause.
2538 : OMPNoChildClause(StartLoc, EndLoc) {}
2539
2540 /// Build an empty clause.
2542};
2543
2544/// This represents the 'no_openmp_constructs' clause in the
2545//// '#pragma omp assume' directive.
2546///
2547/// \code
2548/// #pragma omp assume no_openmp_constructs
2549/// \endcode
2550/// In this example directive '#pragma omp assume' has a 'no_openmp_constructs'
2551/// clause.
2553 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp_constructs> {
2554public:
2555 /// Build 'no_openmp_constructs' clause.
2556 ///
2557 /// \param StartLoc Starting location of the clause.
2558 /// \param EndLoc Ending location of the clause.
2560 : OMPNoChildClause(StartLoc, EndLoc) {}
2561
2562 /// Build an empty clause.
2564};
2565
2566/// This represents the 'no_parallelism' clause in the '#pragma omp assume'
2567/// directive.
2568///
2569/// \code
2570/// #pragma omp assume no_parallelism
2571/// \endcode
2572/// In this example directive '#pragma omp assume' has a 'no_parallelism'
2573/// clause.
2575 : public OMPNoChildClause<llvm::omp::OMPC_no_parallelism> {
2576public:
2577 /// Build 'no_parallelism' clause.
2578 ///
2579 /// \param StartLoc Starting location of the clause.
2580 /// \param EndLoc Ending location of the clause.
2582 : OMPNoChildClause(StartLoc, EndLoc) {}
2583
2584 /// Build an empty clause.
2586};
2587
2588/// This represents 'read' clause in the '#pragma omp atomic' directive.
2589///
2590/// \code
2591/// #pragma omp atomic read
2592/// \endcode
2593/// In this example directive '#pragma omp atomic' has 'read' clause.
2594class OMPReadClause : public OMPClause {
2595public:
2596 /// Build 'read' clause.
2597 ///
2598 /// \param StartLoc Starting location of the clause.
2599 /// \param EndLoc Ending location of the clause.
2601 : OMPClause(llvm::omp::OMPC_read, StartLoc, EndLoc) {}
2602
2603 /// Build an empty clause.
2605 : OMPClause(llvm::omp::OMPC_read, SourceLocation(), SourceLocation()) {}
2606
2610
2614
2621
2622 static bool classof(const OMPClause *T) {
2623 return T->getClauseKind() == llvm::omp::OMPC_read;
2624 }
2625};
2626
2627/// This represents 'write' clause in the '#pragma omp atomic' directive.
2628///
2629/// \code
2630/// #pragma omp atomic write
2631/// \endcode
2632/// In this example directive '#pragma omp atomic' has 'write' clause.
2634public:
2635 /// Build 'write' clause.
2636 ///
2637 /// \param StartLoc Starting location of the clause.
2638 /// \param EndLoc Ending location of the clause.
2640 : OMPClause(llvm::omp::OMPC_write, StartLoc, EndLoc) {}
2641
2642 /// Build an empty clause.
2644 : OMPClause(llvm::omp::OMPC_write, SourceLocation(), SourceLocation()) {}
2645
2649
2653
2660
2661 static bool classof(const OMPClause *T) {
2662 return T->getClauseKind() == llvm::omp::OMPC_write;
2663 }
2664};
2665
2666/// This represents 'update' clause in the '#pragma omp atomic'
2667/// directive.
2668///
2669/// \code
2670/// #pragma omp atomic update
2671/// \endcode
2672/// In this example directive '#pragma omp atomic' has 'update' clause.
2673/// Also, this class represents 'update' clause in '#pragma omp depobj'
2674/// directive.
2675///
2676/// \code
2677/// #pragma omp depobj(a) update(in)
2678/// \endcode
2679/// In this example directive '#pragma omp depobj' has 'update' clause with 'in'
2680/// dependence kind.
2681class OMPUpdateClause final
2682 : public OMPClause,
2683 private llvm::TrailingObjects<OMPUpdateClause, SourceLocation,
2684 OpenMPDependClauseKind> {
2685 friend class OMPClauseReader;
2686 friend TrailingObjects;
2687
2688 /// true if extended version of the clause for 'depobj' directive.
2689 bool IsExtended = false;
2690
2691 /// Define the sizes of each trailing object array except the last one. This
2692 /// is required for TrailingObjects to work properly.
2693 size_t numTrailingObjects(OverloadToken<SourceLocation>) const {
2694 // 2 locations: for '(' and argument location.
2695 return IsExtended ? 2 : 0;
2696 }
2697
2698 /// Sets the location of '(' in clause for 'depobj' directive.
2699 void setLParenLoc(SourceLocation Loc) {
2700 assert(IsExtended && "Expected extended clause.");
2701 *getTrailingObjects<SourceLocation>() = Loc;
2702 }
2703
2704 /// Sets the location of '(' in clause for 'depobj' directive.
2705 void setArgumentLoc(SourceLocation Loc) {
2706 assert(IsExtended && "Expected extended clause.");
2707 *std::next(getTrailingObjects<SourceLocation>(), 1) = Loc;
2708 }
2709
2710 /// Sets the dependence kind for the clause for 'depobj' directive.
2711 void setDependencyKind(OpenMPDependClauseKind DK) {
2712 assert(IsExtended && "Expected extended clause.");
2713 *getTrailingObjects<OpenMPDependClauseKind>() = DK;
2714 }
2715
2716 /// Build 'update' clause.
2717 ///
2718 /// \param StartLoc Starting location of the clause.
2719 /// \param EndLoc Ending location of the clause.
2720 OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc,
2721 bool IsExtended)
2722 : OMPClause(llvm::omp::OMPC_update, StartLoc, EndLoc),
2723 IsExtended(IsExtended) {}
2724
2725 /// Build an empty clause.
2726 OMPUpdateClause(bool IsExtended)
2727 : OMPClause(llvm::omp::OMPC_update, SourceLocation(), SourceLocation()),
2728 IsExtended(IsExtended) {}
2729
2730public:
2731 /// Creates clause for 'atomic' directive.
2732 ///
2733 /// \param C AST context.
2734 /// \param StartLoc Starting location of the clause.
2735 /// \param EndLoc Ending location of the clause.
2736 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2737 SourceLocation EndLoc);
2738
2739 /// Creates clause for 'depobj' directive.
2740 ///
2741 /// \param C AST context.
2742 /// \param StartLoc Starting location of the clause.
2743 /// \param LParenLoc Location of '('.
2744 /// \param ArgumentLoc Location of the argument.
2745 /// \param DK Dependence kind.
2746 /// \param EndLoc Ending location of the clause.
2747 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2748 SourceLocation LParenLoc,
2749 SourceLocation ArgumentLoc,
2751 SourceLocation EndLoc);
2752
2753 /// Creates an empty clause with the place for \a N variables.
2754 ///
2755 /// \param C AST context.
2756 /// \param IsExtended true if extended clause for 'depobj' directive must be
2757 /// created.
2758 static OMPUpdateClause *CreateEmpty(const ASTContext &C, bool IsExtended);
2759
2760 /// Checks if the clause is the extended clauses for 'depobj' directive.
2761 bool isExtended() const { return IsExtended; }
2762
2766
2770
2777
2778 /// Gets the location of '(' in clause for 'depobj' directive.
2780 assert(IsExtended && "Expected extended clause.");
2781 return *getTrailingObjects<SourceLocation>();
2782 }
2783
2784 /// Gets the location of argument in clause for 'depobj' directive.
2786 assert(IsExtended && "Expected extended clause.");
2787 return *std::next(getTrailingObjects<SourceLocation>(), 1);
2788 }
2789
2790 /// Gets the dependence kind in clause for 'depobj' directive.
2792 assert(IsExtended && "Expected extended clause.");
2793 return *getTrailingObjects<OpenMPDependClauseKind>();
2794 }
2795
2796 static bool classof(const OMPClause *T) {
2797 return T->getClauseKind() == llvm::omp::OMPC_update;
2798 }
2799};
2800
2801/// This represents 'capture' clause in the '#pragma omp atomic'
2802/// directive.
2803///
2804/// \code
2805/// #pragma omp atomic capture
2806/// \endcode
2807/// In this example directive '#pragma omp atomic' has 'capture' clause.
2809public:
2810 /// Build 'capture' clause.
2811 ///
2812 /// \param StartLoc Starting location of the clause.
2813 /// \param EndLoc Ending location of the clause.
2815 : OMPClause(llvm::omp::OMPC_capture, StartLoc, EndLoc) {}
2816
2817 /// Build an empty clause.
2819 : OMPClause(llvm::omp::OMPC_capture, SourceLocation(), SourceLocation()) {
2820 }
2821
2825
2829
2836
2837 static bool classof(const OMPClause *T) {
2838 return T->getClauseKind() == llvm::omp::OMPC_capture;
2839 }
2840};
2841
2842/// This represents 'compare' clause in the '#pragma omp atomic'
2843/// directive.
2844///
2845/// \code
2846/// #pragma omp atomic compare
2847/// \endcode
2848/// In this example directive '#pragma omp atomic' has 'compare' clause.
2849class OMPCompareClause final : public OMPClause {
2850public:
2851 /// Build 'compare' clause.
2852 ///
2853 /// \param StartLoc Starting location of the clause.
2854 /// \param EndLoc Ending location of the clause.
2856 : OMPClause(llvm::omp::OMPC_compare, StartLoc, EndLoc) {}
2857
2858 /// Build an empty clause.
2860 : OMPClause(llvm::omp::OMPC_compare, SourceLocation(), SourceLocation()) {
2861 }
2862
2866
2870
2877
2878 static bool classof(const OMPClause *T) {
2879 return T->getClauseKind() == llvm::omp::OMPC_compare;
2880 }
2881};
2882
2883/// This represents 'seq_cst' clause in the '#pragma omp atomic|flush'
2884/// directives.
2885///
2886/// \code
2887/// #pragma omp atomic seq_cst
2888/// \endcode
2889/// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
2891public:
2892 /// Build 'seq_cst' clause.
2893 ///
2894 /// \param StartLoc Starting location of the clause.
2895 /// \param EndLoc Ending location of the clause.
2897 : OMPClause(llvm::omp::OMPC_seq_cst, StartLoc, EndLoc) {}
2898
2899 /// Build an empty clause.
2901 : OMPClause(llvm::omp::OMPC_seq_cst, SourceLocation(), SourceLocation()) {
2902 }
2903
2907
2911
2918
2919 static bool classof(const OMPClause *T) {
2920 return T->getClauseKind() == llvm::omp::OMPC_seq_cst;
2921 }
2922};
2923
2924/// This represents 'acq_rel' clause in the '#pragma omp atomic|flush'
2925/// directives.
2926///
2927/// \code
2928/// #pragma omp flush acq_rel
2929/// \endcode
2930/// In this example directive '#pragma omp flush' has 'acq_rel' clause.
2931class OMPAcqRelClause final : public OMPClause {
2932public:
2933 /// Build 'ack_rel' clause.
2934 ///
2935 /// \param StartLoc Starting location of the clause.
2936 /// \param EndLoc Ending location of the clause.
2938 : OMPClause(llvm::omp::OMPC_acq_rel, StartLoc, EndLoc) {}
2939
2940 /// Build an empty clause.
2942 : OMPClause(llvm::omp::OMPC_acq_rel, SourceLocation(), SourceLocation()) {
2943 }
2944
2948
2952
2959
2960 static bool classof(const OMPClause *T) {
2961 return T->getClauseKind() == llvm::omp::OMPC_acq_rel;
2962 }
2963};
2964
2965/// This represents 'acquire' clause in the '#pragma omp atomic|flush'
2966/// directives.
2967///
2968/// \code
2969/// #pragma omp flush acquire
2970/// \endcode
2971/// In this example directive '#pragma omp flush' has 'acquire' clause.
2972class OMPAcquireClause final : public OMPClause {
2973public:
2974 /// Build 'acquire' clause.
2975 ///
2976 /// \param StartLoc Starting location of the clause.
2977 /// \param EndLoc Ending location of the clause.
2979 : OMPClause(llvm::omp::OMPC_acquire, StartLoc, EndLoc) {}
2980
2981 /// Build an empty clause.
2983 : OMPClause(llvm::omp::OMPC_acquire, SourceLocation(), SourceLocation()) {
2984 }
2985
2989
2993
3000
3001 static bool classof(const OMPClause *T) {
3002 return T->getClauseKind() == llvm::omp::OMPC_acquire;
3003 }
3004};
3005
3006/// This represents 'release' clause in the '#pragma omp atomic|flush'
3007/// directives.
3008///
3009/// \code
3010/// #pragma omp flush release
3011/// \endcode
3012/// In this example directive '#pragma omp flush' has 'release' clause.
3013class OMPReleaseClause final : public OMPClause {
3014public:
3015 /// Build 'release' clause.
3016 ///
3017 /// \param StartLoc Starting location of the clause.
3018 /// \param EndLoc Ending location of the clause.
3020 : OMPClause(llvm::omp::OMPC_release, StartLoc, EndLoc) {}
3021
3022 /// Build an empty clause.
3024 : OMPClause(llvm::omp::OMPC_release, SourceLocation(), SourceLocation()) {
3025 }
3026
3030
3034
3041
3042 static bool classof(const OMPClause *T) {
3043 return T->getClauseKind() == llvm::omp::OMPC_release;
3044 }
3045};
3046
3047/// This represents 'relaxed' clause in the '#pragma omp atomic'
3048/// directives.
3049///
3050/// \code
3051/// #pragma omp atomic relaxed
3052/// \endcode
3053/// In this example directive '#pragma omp atomic' has 'relaxed' clause.
3054class OMPRelaxedClause final : public OMPClause {
3055public:
3056 /// Build 'relaxed' clause.
3057 ///
3058 /// \param StartLoc Starting location of the clause.
3059 /// \param EndLoc Ending location of the clause.
3061 : OMPClause(llvm::omp::OMPC_relaxed, StartLoc, EndLoc) {}
3062
3063 /// Build an empty clause.
3065 : OMPClause(llvm::omp::OMPC_relaxed, SourceLocation(), SourceLocation()) {
3066 }
3067
3071
3075
3082
3083 static bool classof(const OMPClause *T) {
3084 return T->getClauseKind() == llvm::omp::OMPC_relaxed;
3085 }
3086};
3087
3088/// This represents 'weak' clause in the '#pragma omp atomic'
3089/// directives.
3090///
3091/// \code
3092/// #pragma omp atomic compare weak
3093/// \endcode
3094/// In this example directive '#pragma omp atomic' has 'weak' clause.
3095class OMPWeakClause final : public OMPClause {
3096public:
3097 /// Build 'weak' clause.
3098 ///
3099 /// \param StartLoc Starting location of the clause.
3100 /// \param EndLoc Ending location of the clause.
3102 : OMPClause(llvm::omp::OMPC_weak, StartLoc, EndLoc) {}
3103
3104 /// Build an empty clause.
3106 : OMPClause(llvm::omp::OMPC_weak, SourceLocation(), SourceLocation()) {}
3107
3111
3115
3122
3123 static bool classof(const OMPClause *T) {
3124 return T->getClauseKind() == llvm::omp::OMPC_weak;
3125 }
3126};
3127
3128/// This represents 'fail' clause in the '#pragma omp atomic'
3129/// directive.
3130///
3131/// \code
3132/// #pragma omp atomic compare fail
3133/// \endcode
3134/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
3135class OMPFailClause final : public OMPClause {
3136
3137 // FailParameter is a memory-order-clause. Storing the ClauseKind is
3138 // sufficient for our purpose.
3139 OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
3140 SourceLocation FailParameterLoc;
3141 SourceLocation LParenLoc;
3142
3143 friend class OMPClauseReader;
3144
3145 /// Sets the location of '(' in fail clause.
3146 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3147
3148 /// Sets the location of memoryOrder clause argument in fail clause.
3149 void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
3150
3151 /// Sets the mem_order clause for 'atomic compare fail' directive.
3152 void setFailParameter(OpenMPClauseKind FailParameter) {
3153 this->FailParameter = FailParameter;
3154 assert(checkFailClauseParameter(FailParameter) &&
3155 "Invalid fail clause parameter");
3156 }
3157
3158public:
3159 /// Build 'fail' clause.
3160 ///
3161 /// \param StartLoc Starting location of the clause.
3162 /// \param EndLoc Ending location of the clause.
3164 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
3165
3166 OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation FailParameterLoc,
3167 SourceLocation StartLoc, SourceLocation LParenLoc,
3168 SourceLocation EndLoc)
3169 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
3170 FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
3171
3172 setFailParameter(FailParameter);
3173 }
3174
3175 /// Build an empty clause.
3177 : OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
3178
3182
3186
3193
3194 static bool classof(const OMPClause *T) {
3195 return T->getClauseKind() == llvm::omp::OMPC_fail;
3196 }
3197
3198 /// Gets the location of '(' (for the parameter) in fail clause.
3200 return LParenLoc;
3201 }
3202
3203 /// Gets the location of Fail Parameter (type memory-order-clause) in
3204 /// fail clause.
3205 SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
3206
3207 /// Gets the parameter (type memory-order-clause) in Fail clause.
3208 OpenMPClauseKind getFailParameter() const { return FailParameter; }
3209};
3210
3211/// This represents clause 'private' in the '#pragma omp ...' directives.
3212///
3213/// \code
3214/// #pragma omp parallel private(a,b)
3215/// \endcode
3216/// In this example directive '#pragma omp parallel' has clause 'private'
3217/// with the variables 'a' and 'b'.
3218class OMPPrivateClause final
3219 : public OMPVarListClause<OMPPrivateClause>,
3220 private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
3221 friend class OMPClauseReader;
3222 friend OMPVarListClause;
3223 friend TrailingObjects;
3224
3225 /// Build clause with number of variables \a N.
3226 ///
3227 /// \param StartLoc Starting location of the clause.
3228 /// \param LParenLoc Location of '('.
3229 /// \param EndLoc Ending location of the clause.
3230 /// \param N Number of the variables in the clause.
3231 OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3232 SourceLocation EndLoc, unsigned N)
3233 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private, StartLoc,
3234 LParenLoc, EndLoc, N) {}
3235
3236 /// Build an empty clause.
3237 ///
3238 /// \param N Number of variables.
3239 explicit OMPPrivateClause(unsigned N)
3240 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private,
3242 SourceLocation(), N) {}
3243
3244 /// Sets the list of references to private copies with initializers for
3245 /// new private variables.
3246 /// \param VL List of references.
3247 void setPrivateCopies(ArrayRef<Expr *> VL);
3248
3249 /// Gets the list of references to private copies with initializers for
3250 /// new private variables.
3251 MutableArrayRef<Expr *> getPrivateCopies() {
3252 return {varlist_end(), varlist_size()};
3253 }
3254 ArrayRef<const Expr *> getPrivateCopies() const {
3255 return {varlist_end(), varlist_size()};
3256 }
3257
3258public:
3259 /// Creates clause with a list of variables \a VL.
3260 ///
3261 /// \param C AST context.
3262 /// \param StartLoc Starting location of the clause.
3263 /// \param LParenLoc Location of '('.
3264 /// \param EndLoc Ending location of the clause.
3265 /// \param VL List of references to the variables.
3266 /// \param PrivateVL List of references to private copies with initializers.
3267 static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
3268 SourceLocation LParenLoc,
3269 SourceLocation EndLoc, ArrayRef<Expr *> VL,
3270 ArrayRef<Expr *> PrivateVL);
3271
3272 /// Creates an empty clause with the place for \a N variables.
3273 ///
3274 /// \param C AST context.
3275 /// \param N The number of variables.
3276 static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3277
3280 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
3282 llvm::iterator_range<private_copies_const_iterator>;
3283
3285 return private_copies_range(getPrivateCopies().begin(),
3286 getPrivateCopies().end());
3287 }
3288
3290 return private_copies_const_range(getPrivateCopies().begin(),
3291 getPrivateCopies().end());
3292 }
3293
3295 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3296 reinterpret_cast<Stmt **>(varlist_end()));
3297 }
3298
3300 auto Children = const_cast<OMPPrivateClause *>(this)->children();
3301 return const_child_range(Children.begin(), Children.end());
3302 }
3303
3310
3311 static bool classof(const OMPClause *T) {
3312 return T->getClauseKind() == llvm::omp::OMPC_private;
3313 }
3314};
3315
3316/// This represents clause 'firstprivate' in the '#pragma omp ...'
3317/// directives.
3318///
3319/// \code
3320/// #pragma omp parallel firstprivate(a,b)
3321/// \endcode
3322/// In this example directive '#pragma omp parallel' has clause 'firstprivate'
3323/// with the variables 'a' and 'b'.
3324class OMPFirstprivateClause final
3325 : public OMPVarListClause<OMPFirstprivateClause>,
3326 public OMPClauseWithPreInit,
3327 private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
3328 friend class OMPClauseReader;
3329 friend OMPVarListClause;
3330 friend TrailingObjects;
3331
3332 /// Build clause with number of variables \a N.
3333 ///
3334 /// \param StartLoc Starting location of the clause.
3335 /// \param LParenLoc Location of '('.
3336 /// \param EndLoc Ending location of the clause.
3337 /// \param N Number of the variables in the clause.
3338 OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3339 SourceLocation EndLoc, unsigned N)
3340 : OMPVarListClause<OMPFirstprivateClause>(llvm::omp::OMPC_firstprivate,
3341 StartLoc, LParenLoc, EndLoc, N),
3342 OMPClauseWithPreInit(this) {}
3343
3344 /// Build an empty clause.
3345 ///
3346 /// \param N Number of variables.
3347 explicit OMPFirstprivateClause(unsigned N)
3349 llvm::omp::OMPC_firstprivate, SourceLocation(), SourceLocation(),
3350 SourceLocation(), N),
3351 OMPClauseWithPreInit(this) {}
3352
3353 /// Sets the list of references to private copies with initializers for
3354 /// new private variables.
3355 /// \param VL List of references.
3356 void setPrivateCopies(ArrayRef<Expr *> VL);
3357
3358 /// Gets the list of references to private copies with initializers for
3359 /// new private variables.
3360 MutableArrayRef<Expr *> getPrivateCopies() {
3361 return {varlist_end(), varlist_size()};
3362 }
3363 ArrayRef<const Expr *> getPrivateCopies() const {
3364 return {varlist_end(), varlist_size()};
3365 }
3366
3367 /// Sets the list of references to initializer variables for new
3368 /// private variables.
3369 /// \param VL List of references.
3370 void setInits(ArrayRef<Expr *> VL);
3371
3372 /// Gets the list of references to initializer variables for new
3373 /// private variables.
3374 MutableArrayRef<Expr *> getInits() {
3375 return {getPrivateCopies().end(), varlist_size()};
3376 }
3377 ArrayRef<const Expr *> getInits() const {
3378 return {getPrivateCopies().end(), varlist_size()};
3379 }
3380
3381public:
3382 /// Creates clause with a list of variables \a VL.
3383 ///
3384 /// \param C AST context.
3385 /// \param StartLoc Starting location of the clause.
3386 /// \param LParenLoc Location of '('.
3387 /// \param EndLoc Ending location of the clause.
3388 /// \param VL List of references to the original variables.
3389 /// \param PrivateVL List of references to private copies with initializers.
3390 /// \param InitVL List of references to auto generated variables used for
3391 /// initialization of a single array element. Used if firstprivate variable is
3392 /// of array type.
3393 /// \param PreInit Statement that must be executed before entering the OpenMP
3394 /// region with this clause.
3395 static OMPFirstprivateClause *
3396 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3397 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
3398 ArrayRef<Expr *> InitVL, Stmt *PreInit);
3399
3400 /// Creates an empty clause with the place for \a N variables.
3401 ///
3402 /// \param C AST context.
3403 /// \param N The number of variables.
3404 static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3405
3408 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
3410 llvm::iterator_range<private_copies_const_iterator>;
3411
3413 return private_copies_range(getPrivateCopies().begin(),
3414 getPrivateCopies().end());
3415 }
3417 return private_copies_const_range(getPrivateCopies().begin(),
3418 getPrivateCopies().end());
3419 }
3420
3423 using inits_range = llvm::iterator_range<inits_iterator>;
3424 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
3425
3427 return inits_range(getInits().begin(), getInits().end());
3428 }
3430 return inits_const_range(getInits().begin(), getInits().end());
3431 }
3432
3434 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3435 reinterpret_cast<Stmt **>(varlist_end()));
3436 }
3437
3439 auto Children = const_cast<OMPFirstprivateClause *>(this)->children();
3440 return const_child_range(Children.begin(), Children.end());
3441 }
3442
3444 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3445 reinterpret_cast<Stmt **>(varlist_end()));
3446 }
3448 auto Children = const_cast<OMPFirstprivateClause *>(this)->used_children();
3449 return const_child_range(Children.begin(), Children.end());
3450 }
3451
3452 static bool classof(const OMPClause *T) {
3453 return T->getClauseKind() == llvm::omp::OMPC_firstprivate;
3454 }
3455};
3456
3457/// This represents clause 'lastprivate' in the '#pragma omp ...'
3458/// directives.
3459///
3460/// \code
3461/// #pragma omp simd lastprivate(a,b)
3462/// \endcode
3463/// In this example directive '#pragma omp simd' has clause 'lastprivate'
3464/// with the variables 'a' and 'b'.
3465class OMPLastprivateClause final
3466 : public OMPVarListClause<OMPLastprivateClause>,
3468 private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
3469 // There are 4 additional tail-allocated arrays at the end of the class:
3470 // 1. Contains list of pseudo variables with the default initialization for
3471 // each non-firstprivate variables. Used in codegen for initialization of
3472 // lastprivate copies.
3473 // 2. List of helper expressions for proper generation of assignment operation
3474 // required for lastprivate clause. This list represents private variables
3475 // (for arrays, single array element).
3476 // 3. List of helper expressions for proper generation of assignment operation
3477 // required for lastprivate clause. This list represents original variables
3478 // (for arrays, single array element).
3479 // 4. List of helper expressions that represents assignment operation:
3480 // \code
3481 // DstExprs = SrcExprs;
3482 // \endcode
3483 // Required for proper codegen of final assignment performed by the
3484 // lastprivate clause.
3485 friend class OMPClauseReader;
3486 friend OMPVarListClause;
3487 friend TrailingObjects;
3488
3489 /// Optional lastprivate kind, e.g. 'conditional', if specified by user.
3491 /// Optional location of the lasptrivate kind, if specified by user.
3492 SourceLocation LPKindLoc;
3493 /// Optional colon location, if specified by user.
3494 SourceLocation ColonLoc;
3495
3496 /// Build clause with number of variables \a N.
3497 ///
3498 /// \param StartLoc Starting location of the clause.
3499 /// \param LParenLoc Location of '('.
3500 /// \param EndLoc Ending location of the clause.
3501 /// \param N Number of the variables in the clause.
3502 OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3504 SourceLocation LPKindLoc, SourceLocation ColonLoc,
3505 unsigned N)
3506 : OMPVarListClause<OMPLastprivateClause>(llvm::omp::OMPC_lastprivate,
3507 StartLoc, LParenLoc, EndLoc, N),
3508 OMPClauseWithPostUpdate(this), LPKind(LPKind), LPKindLoc(LPKindLoc),
3509 ColonLoc(ColonLoc) {}
3510
3511 /// Build an empty clause.
3512 ///
3513 /// \param N Number of variables.
3514 explicit OMPLastprivateClause(unsigned N)
3516 llvm::omp::OMPC_lastprivate, SourceLocation(), SourceLocation(),
3517 SourceLocation(), N),
3519
3520 /// Get the list of helper expressions for initialization of private
3521 /// copies for lastprivate variables.
3522 MutableArrayRef<Expr *> getPrivateCopies() {
3523 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3524 }
3525 ArrayRef<const Expr *> getPrivateCopies() const {
3526 return {varlist_end(), varlist_size()};
3527 }
3528
3529 /// Set list of helper expressions, required for proper codegen of the
3530 /// clause. These expressions represent private variables (for arrays, single
3531 /// array element) in the final assignment statement performed by the
3532 /// lastprivate clause.
3533 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
3534
3535 /// Get the list of helper source expressions.
3536 MutableArrayRef<Expr *> getSourceExprs() {
3537 return {getPrivateCopies().end(), varlist_size()};
3538 }
3539 ArrayRef<const Expr *> getSourceExprs() const {
3540 return {getPrivateCopies().end(), varlist_size()};
3541 }
3542
3543 /// Set list of helper expressions, required for proper codegen of the
3544 /// clause. These expressions represent original variables (for arrays, single
3545 /// array element) in the final assignment statement performed by the
3546 /// lastprivate clause.
3547 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
3548
3549 /// Get the list of helper destination expressions.
3550 MutableArrayRef<Expr *> getDestinationExprs() {
3551 return {getSourceExprs().end(), varlist_size()};
3552 }
3553 ArrayRef<const Expr *> getDestinationExprs() const {
3554 return {getSourceExprs().end(), varlist_size()};
3555 }
3556
3557 /// Set list of helper assignment expressions, required for proper
3558 /// codegen of the clause. These expressions are assignment expressions that
3559 /// assign private copy of the variable to original variable.
3560 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
3561
3562 /// Get the list of helper assignment expressions.
3563 MutableArrayRef<Expr *> getAssignmentOps() {
3564 return {getDestinationExprs().end(), varlist_size()};
3565 }
3566 ArrayRef<const Expr *> getAssignmentOps() const {
3567 return {getDestinationExprs().end(), varlist_size()};
3568 }
3569
3570 /// Sets lastprivate kind.
3571 void setKind(OpenMPLastprivateModifier Kind) { LPKind = Kind; }
3572 /// Sets location of the lastprivate kind.
3573 void setKindLoc(SourceLocation Loc) { LPKindLoc = Loc; }
3574 /// Sets colon symbol location.
3575 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3576
3577public:
3578 /// Creates clause with a list of variables \a VL.
3579 ///
3580 /// \param C AST context.
3581 /// \param StartLoc Starting location of the clause.
3582 /// \param LParenLoc Location of '('.
3583 /// \param EndLoc Ending location of the clause.
3584 /// \param VL List of references to the variables.
3585 /// \param SrcExprs List of helper expressions for proper generation of
3586 /// assignment operation required for lastprivate clause. This list represents
3587 /// private variables (for arrays, single array element).
3588 /// \param DstExprs List of helper expressions for proper generation of
3589 /// assignment operation required for lastprivate clause. This list represents
3590 /// original variables (for arrays, single array element).
3591 /// \param AssignmentOps List of helper expressions that represents assignment
3592 /// operation:
3593 /// \code
3594 /// DstExprs = SrcExprs;
3595 /// \endcode
3596 /// Required for proper codegen of final assignment performed by the
3597 /// lastprivate clause.
3598 /// \param LPKind Lastprivate kind, e.g. 'conditional'.
3599 /// \param LPKindLoc Location of the lastprivate kind.
3600 /// \param ColonLoc Location of the ':' symbol if lastprivate kind is used.
3601 /// \param PreInit Statement that must be executed before entering the OpenMP
3602 /// region with this clause.
3603 /// \param PostUpdate Expression that must be executed after exit from the
3604 /// OpenMP region with this clause.
3605 static OMPLastprivateClause *
3606 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3607 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
3608 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
3609 OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
3610 SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate);
3611
3612 /// Creates an empty clause with the place for \a N variables.
3613 ///
3614 /// \param C AST context.
3615 /// \param N The number of variables.
3616 static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3617
3618 /// Lastprivate kind.
3619 OpenMPLastprivateModifier getKind() const { return LPKind; }
3620 /// Returns the location of the lastprivate kind.
3621 SourceLocation getKindLoc() const { return LPKindLoc; }
3622 /// Returns the location of the ':' symbol, if any.
3623 SourceLocation getColonLoc() const { return ColonLoc; }
3624
3627 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3629 llvm::iterator_range<helper_expr_const_iterator>;
3630
3631 /// Set list of helper expressions, required for generation of private
3632 /// copies of original lastprivate variables.
3633 void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
3634
3636 return helper_expr_const_range(getPrivateCopies().begin(),
3637 getPrivateCopies().end());
3638 }
3639
3641 return helper_expr_range(getPrivateCopies().begin(),
3642 getPrivateCopies().end());
3643 }
3644
3646 return helper_expr_const_range(getSourceExprs().begin(),
3647 getSourceExprs().end());
3648 }
3649
3651 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
3652 }
3653
3655 return helper_expr_const_range(getDestinationExprs().begin(),
3656 getDestinationExprs().end());
3657 }
3658
3660 return helper_expr_range(getDestinationExprs().begin(),
3661 getDestinationExprs().end());
3662 }
3663
3665 return helper_expr_const_range(getAssignmentOps().begin(),
3666 getAssignmentOps().end());
3667 }
3668
3670 return helper_expr_range(getAssignmentOps().begin(),
3671 getAssignmentOps().end());
3672 }
3673
3675 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3676 reinterpret_cast<Stmt **>(varlist_end()));
3677 }
3678
3680 auto Children = const_cast<OMPLastprivateClause *>(this)->children();
3681 return const_child_range(Children.begin(), Children.end());
3682 }
3683
3690
3691 static bool classof(const OMPClause *T) {
3692 return T->getClauseKind() == llvm::omp::OMPC_lastprivate;
3693 }
3694};
3695
3696/// This represents clause 'shared' in the '#pragma omp ...' directives.
3697///
3698/// \code
3699/// #pragma omp parallel shared(a,b)
3700/// \endcode
3701/// In this example directive '#pragma omp parallel' has clause 'shared'
3702/// with the variables 'a' and 'b'.
3703class OMPSharedClause final
3704 : public OMPVarListClause<OMPSharedClause>,
3705 private llvm::TrailingObjects<OMPSharedClause, Expr *> {
3706 friend OMPVarListClause;
3707 friend TrailingObjects;
3708
3709 /// Build clause with number of variables \a N.
3710 ///
3711 /// \param StartLoc Starting location of the clause.
3712 /// \param LParenLoc Location of '('.
3713 /// \param EndLoc Ending location of the clause.
3714 /// \param N Number of the variables in the clause.
3715 OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3716 SourceLocation EndLoc, unsigned N)
3717 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared, StartLoc,
3718 LParenLoc, EndLoc, N) {}
3719
3720 /// Build an empty clause.
3721 ///
3722 /// \param N Number of variables.
3723 explicit OMPSharedClause(unsigned N)
3724 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared,
3726 SourceLocation(), N) {}
3727
3728public:
3729 /// Creates clause with a list of variables \a VL.
3730 ///
3731 /// \param C AST context.
3732 /// \param StartLoc Starting location of the clause.
3733 /// \param LParenLoc Location of '('.
3734 /// \param EndLoc Ending location of the clause.
3735 /// \param VL List of references to the variables.
3736 static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
3737 SourceLocation LParenLoc,
3738 SourceLocation EndLoc, ArrayRef<Expr *> VL);
3739
3740 /// Creates an empty clause with \a N variables.
3741 ///
3742 /// \param C AST context.
3743 /// \param N The number of variables.
3744 static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
3745
3747 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3748 reinterpret_cast<Stmt **>(varlist_end()));
3749 }
3750
3752 auto Children = const_cast<OMPSharedClause *>(this)->children();
3753 return const_child_range(Children.begin(), Children.end());
3754 }
3755
3762
3763 static bool classof(const OMPClause *T) {
3764 return T->getClauseKind() == llvm::omp::OMPC_shared;
3765 }
3766};
3767
3768/// This represents clause 'reduction' in the '#pragma omp ...'
3769/// directives.
3770///
3771/// \code
3772/// #pragma omp parallel reduction(+:a,b)
3773/// \endcode
3774/// In this example directive '#pragma omp parallel' has clause 'reduction'
3775/// with operator '+' and the variables 'a' and 'b'.
3776class OMPReductionClause final
3777 : public OMPVarListClause<OMPReductionClause>,
3779 private llvm::TrailingObjects<OMPReductionClause, Expr *, bool> {
3780 friend class OMPClauseReader;
3781 friend OMPVarListClause;
3782 friend TrailingObjects;
3783
3784 /// Reduction modifier.
3786
3787 /// Original Sharing modifier.
3788 OpenMPOriginalSharingModifier OriginalSharingModifier =
3789 OMPC_ORIGINAL_SHARING_default;
3790
3791 /// Reduction modifier location.
3792 SourceLocation ModifierLoc;
3793
3794 /// Location of ':'.
3795 SourceLocation ColonLoc;
3796
3797 /// Nested name specifier for C++.
3798 NestedNameSpecifierLoc QualifierLoc;
3799
3800 /// Name of custom operator.
3801 DeclarationNameInfo NameInfo;
3802
3803 /// Build clause with number of variables \a N.
3804 ///
3805 /// \param StartLoc Starting location of the clause.
3806 /// \param LParenLoc Location of '('.
3807 /// \param ModifierLoc Modifier location.
3808 /// \param ColonLoc Location of ':'.
3809 /// \param EndLoc Ending location of the clause.
3810 /// \param N Number of the variables in the clause.
3811 /// \param QualifierLoc The nested-name qualifier with location information
3812 /// \param NameInfo The full name info for reduction identifier.
3813 OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3814 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3815 SourceLocation EndLoc,
3817 OpenMPOriginalSharingModifier OriginalSharingModifier,
3818 unsigned N, NestedNameSpecifierLoc QualifierLoc,
3819 const DeclarationNameInfo &NameInfo)
3820 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3821 StartLoc, LParenLoc, EndLoc, N),
3822 OMPClauseWithPostUpdate(this), Modifier(Modifier),
3823 OriginalSharingModifier(OriginalSharingModifier),
3824 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
3825 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3826
3827 /// Build an empty clause.
3828 ///
3829 /// \param N Number of variables.
3830 explicit OMPReductionClause(unsigned N)
3831 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3833 SourceLocation(), N),
3835
3836 /// Sets reduction modifier.
3837 void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; }
3838
3839 /// Sets Original Sharing modifier.
3840 void setOriginalSharingModifier(OpenMPOriginalSharingModifier M) {
3841 OriginalSharingModifier = M;
3842 }
3843
3844 /// Sets location of the modifier.
3845 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
3846
3847 /// Sets location of ':' symbol in clause.
3848 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3849
3850 /// Sets the name info for specified reduction identifier.
3851 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3852
3853 /// Sets the nested name specifier.
3854 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3855
3856 /// Set list of helper expressions, required for proper codegen of the
3857 /// clause. These expressions represent private copy of the reduction
3858 /// variable.
3859 void setPrivates(ArrayRef<Expr *> Privates);
3860
3861 /// Get the list of helper privates.
3862 MutableArrayRef<Expr *> getPrivates() {
3863 return {varlist_end(), varlist_size()};
3864 }
3865 ArrayRef<const Expr *> getPrivates() const {
3866 return {varlist_end(), varlist_size()};
3867 }
3868
3869 /// Set list of helper expressions, required for proper codegen of the
3870 /// clause. These expressions represent LHS expression in the final
3871 /// reduction expression performed by the reduction clause.
3872 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3873
3874 /// Get the list of helper LHS expressions.
3875 MutableArrayRef<Expr *> getLHSExprs() {
3876 return {getPrivates().end(), varlist_size()};
3877 }
3878 ArrayRef<const Expr *> getLHSExprs() const {
3879 return {getPrivates().end(), varlist_size()};
3880 }
3881
3882 /// Set list of helper expressions, required for proper codegen of the
3883 /// clause. These expressions represent RHS expression in the final
3884 /// reduction expression performed by the reduction clause.
3885 /// Also, variables in these expressions are used for proper initialization of
3886 /// reduction copies.
3887 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3888
3889 /// Set the list private reduction flags
3890 void setPrivateVariableReductionFlags(ArrayRef<bool> Flags) {
3891 assert(Flags.size() == varlist_size() &&
3892 "Number of private flags does not match vars");
3893 llvm::copy(Flags, getTrailingObjects<bool>());
3894 }
3895
3896 /// Get the list of help private variable reduction flags
3897 MutableArrayRef<bool> getPrivateVariableReductionFlags() {
3898 return getTrailingObjects<bool>(varlist_size());
3899 }
3900 ArrayRef<bool> getPrivateVariableReductionFlags() const {
3901 return getTrailingObjects<bool>(varlist_size());
3902 }
3903
3904 /// Returns the number of Expr* objects in trailing storage
3905 size_t numTrailingObjects(OverloadToken<Expr *>) const {
3906 return varlist_size() * (Modifier == OMPC_REDUCTION_inscan ? 8 : 5);
3907 }
3908
3909 /// Returns the number of bool flags in trailing storage
3910 size_t numTrailingObjects(OverloadToken<bool>) const {
3911 return varlist_size();
3912 }
3913
3914 /// Get the list of helper destination expressions.
3915 MutableArrayRef<Expr *> getRHSExprs() {
3916 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3917 }
3918 ArrayRef<const Expr *> getRHSExprs() const {
3919 return {getLHSExprs().end(), varlist_size()};
3920 }
3921
3922 /// Set list of helper reduction expressions, required for proper
3923 /// codegen of the clause. These expressions are binary expressions or
3924 /// operator/custom reduction call that calculates new value from source
3925 /// helper expressions to destination helper expressions.
3926 void setReductionOps(ArrayRef<Expr *> ReductionOps);
3927
3928 /// Get the list of helper reduction expressions.
3929 MutableArrayRef<Expr *> getReductionOps() {
3930 return {getRHSExprs().end(), varlist_size()};
3931 }
3932 ArrayRef<const Expr *> getReductionOps() const {
3933 return {getRHSExprs().end(), varlist_size()};
3934 }
3935
3936 /// Set list of helper copy operations for inscan reductions.
3937 /// The form is: Temps[i] = LHS[i];
3938 void setInscanCopyOps(ArrayRef<Expr *> Ops);
3939
3940 /// Get the list of helper inscan copy operations.
3941 MutableArrayRef<Expr *> getInscanCopyOps() {
3942 return {getReductionOps().end(), varlist_size()};
3943 }
3944 ArrayRef<const Expr *> getInscanCopyOps() const {
3945 return {getReductionOps().end(), varlist_size()};
3946 }
3947
3948 /// Set list of helper temp vars for inscan copy array operations.
3949 void setInscanCopyArrayTemps(ArrayRef<Expr *> CopyArrayTemps);
3950
3951 /// Get the list of helper inscan copy temps.
3952 MutableArrayRef<Expr *> getInscanCopyArrayTemps() {
3953 return {getInscanCopyOps().end(), varlist_size()};
3954 }
3955 ArrayRef<const Expr *> getInscanCopyArrayTemps() const {
3956 return {getInscanCopyOps().end(), varlist_size()};
3957 }
3958
3959 /// Set list of helper temp elements vars for inscan copy array operations.
3960 void setInscanCopyArrayElems(ArrayRef<Expr *> CopyArrayElems);
3961
3962 /// Get the list of helper inscan copy temps.
3963 MutableArrayRef<Expr *> getInscanCopyArrayElems() {
3964 return {getInscanCopyArrayTemps().end(), varlist_size()};
3965 }
3966 ArrayRef<const Expr *> getInscanCopyArrayElems() const {
3967 return {getInscanCopyArrayTemps().end(), varlist_size()};
3968 }
3969
3970public:
3971 /// Creates clause with a list of variables \a VL.
3972 ///
3973 /// \param StartLoc Starting location of the clause.
3974 /// \param LParenLoc Location of '('.
3975 /// \param ModifierLoc Modifier location.
3976 /// \param ColonLoc Location of ':'.
3977 /// \param EndLoc Ending location of the clause.
3978 /// \param VL The variables in the clause.
3979 /// \param QualifierLoc The nested-name qualifier with location information
3980 /// \param NameInfo The full name info for reduction identifier.
3981 /// \param Privates List of helper expressions for proper generation of
3982 /// private copies.
3983 /// \param LHSExprs List of helper expressions for proper generation of
3984 /// assignment operation required for copyprivate clause. This list represents
3985 /// LHSs of the reduction expressions.
3986 /// \param RHSExprs List of helper expressions for proper generation of
3987 /// assignment operation required for copyprivate clause. This list represents
3988 /// RHSs of the reduction expressions.
3989 /// Also, variables in these expressions are used for proper initialization of
3990 /// reduction copies.
3991 /// \param ReductionOps List of helper expressions that represents reduction
3992 /// expressions:
3993 /// \code
3994 /// LHSExprs binop RHSExprs;
3995 /// operator binop(LHSExpr, RHSExpr);
3996 /// <CutomReduction>(LHSExpr, RHSExpr);
3997 /// \endcode
3998 /// Required for proper codegen of final reduction operation performed by the
3999 /// reduction clause.
4000 /// \param CopyOps List of copy operations for inscan reductions:
4001 /// \code
4002 /// TempExprs = LHSExprs;
4003 /// \endcode
4004 /// \param CopyArrayTemps Temp arrays for prefix sums.
4005 /// \param CopyArrayElems Temp arrays for prefix sums.
4006 /// \param PreInit Statement that must be executed before entering the OpenMP
4007 /// region with this clause.
4008 /// \param PostUpdate Expression that must be executed after exit from the
4009 /// OpenMP region with this clause.
4010 /// \param IsPrivateVarReduction array for private variable reduction flags
4011 static OMPReductionClause *
4012 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4013 SourceLocation ModifierLoc, SourceLocation ColonLoc,
4014 SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier,
4015 ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc,
4016 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4017 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4018 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps,
4019 ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems,
4020 Stmt *PreInit, Expr *PostUpdate, ArrayRef<bool> IsPrivateVarReduction,
4021 OpenMPOriginalSharingModifier OriginalSharingModifier);
4022
4023 /// Creates an empty clause with the place for \a N variables.
4024 ///
4025 /// \param C AST context.
4026 /// \param N The number of variables.
4027 /// \param Modifier Reduction modifier.
4028 static OMPReductionClause *
4029 CreateEmpty(const ASTContext &C, unsigned N,
4031
4032 /// Returns modifier.
4033 OpenMPReductionClauseModifier getModifier() const { return Modifier; }
4034
4035 /// Returns Original Sharing Modifier.
4037 return OriginalSharingModifier;
4038 }
4039
4040 /// Returns modifier location.
4041 SourceLocation getModifierLoc() const { return ModifierLoc; }
4042
4043 /// Gets location of ':' symbol in clause.
4044 SourceLocation getColonLoc() const { return ColonLoc; }
4045
4046 /// Gets the name info for specified reduction identifier.
4047 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4048
4049 /// Gets the nested name specifier.
4050 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4051
4054 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4056 llvm::iterator_range<helper_expr_const_iterator>;
4059 using helper_flag_range = llvm::iterator_range<helper_flag_iterator>;
4061 llvm::iterator_range<helper_flag_const_iterator>;
4062
4064 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
4065 }
4066
4068 return helper_expr_range(getPrivates().begin(), getPrivates().end());
4069 }
4070
4072 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
4073 }
4074
4076 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
4077 }
4078
4080 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
4081 }
4082
4084 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
4085 }
4086
4088 return helper_flag_const_range(getPrivateVariableReductionFlags().begin(),
4089 getPrivateVariableReductionFlags().end());
4090 }
4091
4093 return helper_flag_range(getPrivateVariableReductionFlags().begin(),
4094 getPrivateVariableReductionFlags().end());
4095 }
4096
4098 return helper_expr_const_range(getReductionOps().begin(),
4099 getReductionOps().end());
4100 }
4101
4103 return helper_expr_range(getReductionOps().begin(),
4104 getReductionOps().end());
4105 }
4106
4108 return helper_expr_const_range(getInscanCopyOps().begin(),
4109 getInscanCopyOps().end());
4110 }
4111
4113 return helper_expr_range(getInscanCopyOps().begin(),
4114 getInscanCopyOps().end());
4115 }
4116
4118 return helper_expr_const_range(getInscanCopyArrayTemps().begin(),
4119 getInscanCopyArrayTemps().end());
4120 }
4121
4123 return helper_expr_range(getInscanCopyArrayTemps().begin(),
4124 getInscanCopyArrayTemps().end());
4125 }
4126
4128 return helper_expr_const_range(getInscanCopyArrayElems().begin(),
4129 getInscanCopyArrayElems().end());
4130 }
4131
4133 return helper_expr_range(getInscanCopyArrayElems().begin(),
4134 getInscanCopyArrayElems().end());
4135 }
4136
4138 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4139 reinterpret_cast<Stmt **>(varlist_end()));
4140 }
4141
4143 auto Children = const_cast<OMPReductionClause *>(this)->children();
4144 return const_child_range(Children.begin(), Children.end());
4145 }
4146
4148 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4149 reinterpret_cast<Stmt **>(varlist_end()));
4150 }
4152 auto Children = const_cast<OMPReductionClause *>(this)->used_children();
4153 return const_child_range(Children.begin(), Children.end());
4154 }
4155
4156 static bool classof(const OMPClause *T) {
4157 return T->getClauseKind() == llvm::omp::OMPC_reduction;
4158 }
4159};
4160
4161/// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
4162/// directives.
4163///
4164/// \code
4165/// #pragma omp taskgroup task_reduction(+:a,b)
4166/// \endcode
4167/// In this example directive '#pragma omp taskgroup' has clause
4168/// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
4169class OMPTaskReductionClause final
4170 : public OMPVarListClause<OMPTaskReductionClause>,
4172 private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> {
4173 friend class OMPClauseReader;
4174 friend OMPVarListClause;
4175 friend TrailingObjects;
4176
4177 /// Location of ':'.
4178 SourceLocation ColonLoc;
4179
4180 /// Nested name specifier for C++.
4181 NestedNameSpecifierLoc QualifierLoc;
4182
4183 /// Name of custom operator.
4184 DeclarationNameInfo NameInfo;
4185
4186 /// Build clause with number of variables \a N.
4187 ///
4188 /// \param StartLoc Starting location of the clause.
4189 /// \param LParenLoc Location of '('.
4190 /// \param EndLoc Ending location of the clause.
4191 /// \param ColonLoc Location of ':'.
4192 /// \param N Number of the variables in the clause.
4193 /// \param QualifierLoc The nested-name qualifier with location information
4194 /// \param NameInfo The full name info for reduction identifier.
4195 OMPTaskReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4196 SourceLocation ColonLoc, SourceLocation EndLoc,
4197 unsigned N, NestedNameSpecifierLoc QualifierLoc,
4198 const DeclarationNameInfo &NameInfo)
4199 : OMPVarListClause<OMPTaskReductionClause>(
4200 llvm::omp::OMPC_task_reduction, StartLoc, LParenLoc, EndLoc, N),
4201 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
4202 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
4203
4204 /// Build an empty clause.
4205 ///
4206 /// \param N Number of variables.
4207 explicit OMPTaskReductionClause(unsigned N)
4209 llvm::omp::OMPC_task_reduction, SourceLocation(), SourceLocation(),
4210 SourceLocation(), N),
4212
4213 /// Sets location of ':' symbol in clause.
4214 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
4215
4216 /// Sets the name info for specified reduction identifier.
4217 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
4218
4219 /// Sets the nested name specifier.
4220 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
4221
4222 /// Set list of helper expressions, required for proper codegen of the clause.
4223 /// These expressions represent private copy of the reduction variable.
4224 void setPrivates(ArrayRef<Expr *> Privates);
4225
4226 /// Get the list of helper privates.
4227 MutableArrayRef<Expr *> getPrivates() {
4228 return {varlist_end(), varlist_size()};
4229 }
4230 ArrayRef<const Expr *> getPrivates() const {
4231 return {varlist_end(), varlist_size()};
4232 }
4233
4234 /// Set list of helper expressions, required for proper codegen of the clause.
4235 /// These expressions represent LHS expression in the final reduction
4236 /// expression performed by the reduction clause.
4237 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
4238
4239 /// Get the list of helper LHS expressions.
4240 MutableArrayRef<Expr *> getLHSExprs() {
4241 return {getPrivates().end(), varlist_size()};
4242 }
4243 ArrayRef<const Expr *> getLHSExprs() const {
4244 return {getPrivates().end(), varlist_size()};
4245 }
4246
4247 /// Set list of helper expressions, required for proper codegen of the clause.
4248 /// These expressions represent RHS expression in the final reduction
4249 /// expression performed by the reduction clause. Also, variables in these
4250 /// expressions are used for proper initialization of reduction copies.
4251 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
4252
4253 /// Get the list of helper destination expressions.
4254 MutableArrayRef<Expr *> getRHSExprs() {
4255 return {getLHSExprs().end(), varlist_size()};
4256 }
4257 ArrayRef<const Expr *> getRHSExprs() const {
4258 return {getLHSExprs().end(), varlist_size()};
4259 }
4260
4261 /// Set list of helper reduction expressions, required for proper
4262 /// codegen of the clause. These expressions are binary expressions or
4263 /// operator/custom reduction call that calculates new value from source
4264 /// helper expressions to destination helper expressions.
4265 void setReductionOps(ArrayRef<Expr *> ReductionOps);
4266
4267 /// Get the list of helper reduction expressions.
4268 MutableArrayRef<Expr *> getReductionOps() {
4269 return {getRHSExprs().end(), varlist_size()};
4270 }
4271 ArrayRef<const Expr *> getReductionOps() const {
4272 return {getRHSExprs().end(), varlist_size()};
4273 }
4274
4275public:
4276 /// Creates clause with a list of variables \a VL.
4277 ///
4278 /// \param StartLoc Starting location of the clause.
4279 /// \param LParenLoc Location of '('.
4280 /// \param ColonLoc Location of ':'.
4281 /// \param EndLoc Ending location of the clause.
4282 /// \param VL The variables in the clause.
4283 /// \param QualifierLoc The nested-name qualifier with location information
4284 /// \param NameInfo The full name info for reduction identifier.
4285 /// \param Privates List of helper expressions for proper generation of
4286 /// private copies.
4287 /// \param LHSExprs List of helper expressions for proper generation of
4288 /// assignment operation required for copyprivate clause. This list represents
4289 /// LHSs of the reduction expressions.
4290 /// \param RHSExprs List of helper expressions for proper generation of
4291 /// assignment operation required for copyprivate clause. This list represents
4292 /// RHSs of the reduction expressions.
4293 /// Also, variables in these expressions are used for proper initialization of
4294 /// reduction copies.
4295 /// \param ReductionOps List of helper expressions that represents reduction
4296 /// expressions:
4297 /// \code
4298 /// LHSExprs binop RHSExprs;
4299 /// operator binop(LHSExpr, RHSExpr);
4300 /// <CutomReduction>(LHSExpr, RHSExpr);
4301 /// \endcode
4302 /// Required for proper codegen of final reduction operation performed by the
4303 /// reduction clause.
4304 /// \param PreInit Statement that must be executed before entering the OpenMP
4305 /// region with this clause.
4306 /// \param PostUpdate Expression that must be executed after exit from the
4307 /// OpenMP region with this clause.
4308 static OMPTaskReductionClause *
4309 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4310 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
4311 NestedNameSpecifierLoc QualifierLoc,
4312 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4313 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4314 ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
4315
4316 /// Creates an empty clause with the place for \a N variables.
4317 ///
4318 /// \param C AST context.
4319 /// \param N The number of variables.
4320 static OMPTaskReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
4321
4322 /// Gets location of ':' symbol in clause.
4323 SourceLocation getColonLoc() const { return ColonLoc; }
4324
4325 /// Gets the name info for specified reduction identifier.
4326 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4327
4328 /// Gets the nested name specifier.
4329 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4330
4333 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4335 llvm::iterator_range<helper_expr_const_iterator>;
4336
4338 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
4339 }
4340
4342 return helper_expr_range(getPrivates().begin(), getPrivates().end());
4343 }
4344
4346 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
4347 }
4348
4350 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
4351 }
4352
4354 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
4355 }
4356
4358 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
4359 }
4360
4362 return helper_expr_const_range(getReductionOps().begin(),
4363 getReductionOps().end());
4364 }
4365
4367 return helper_expr_range(getReductionOps().begin(),
4368 getReductionOps().end());
4369 }
4370
4372 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4373 reinterpret_cast<Stmt **>(varlist_end()));
4374 }
4375
4377 auto Children = const_cast<OMPTaskReductionClause *>(this)->children();
4378 return const_child_range(Children.begin(), Children.end());
4379 }
4380
4387
4388 static bool classof(const OMPClause *T) {
4389 return T->getClauseKind() == llvm::omp::OMPC_task_reduction;
4390 }
4391};
4392
4393/// This represents clause 'in_reduction' in the '#pragma omp task' directives.
4394///
4395/// \code
4396/// #pragma omp task in_reduction(+:a,b)
4397/// \endcode
4398/// In this example directive '#pragma omp task' has clause 'in_reduction' with
4399/// operator '+' and the variables 'a' and 'b'.
4400class OMPInReductionClause final
4401 : public OMPVarListClause<OMPInReductionClause>,
4403 private llvm::TrailingObjects<OMPInReductionClause, Expr *> {
4404 friend class OMPClauseReader;
4405 friend OMPVarListClause;
4406 friend TrailingObjects;
4407
4408 /// Location of ':'.
4409 SourceLocation ColonLoc;
4410
4411 /// Nested name specifier for C++.
4412 NestedNameSpecifierLoc QualifierLoc;
4413
4414 /// Name of custom operator.
4415 DeclarationNameInfo NameInfo;
4416
4417 /// Build clause with number of variables \a N.
4418 ///
4419 /// \param StartLoc Starting location of the clause.
4420 /// \param LParenLoc Location of '('.
4421 /// \param EndLoc Ending location of the clause.
4422 /// \param ColonLoc Location of ':'.
4423 /// \param N Number of the variables in the clause.
4424 /// \param QualifierLoc The nested-name qualifier with location information
4425 /// \param NameInfo The full name info for reduction identifier.
4426 OMPInReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4427 SourceLocation ColonLoc, SourceLocation EndLoc,
4428 unsigned N, NestedNameSpecifierLoc QualifierLoc,
4429 const DeclarationNameInfo &NameInfo)
4430 : OMPVarListClause<OMPInReductionClause>(llvm::omp::OMPC_in_reduction,
4431 StartLoc, LParenLoc, EndLoc, N),
4432 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
4433 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
4434
4435 /// Build an empty clause.
4436 ///
4437 /// \param N Number of variables.
4438 explicit OMPInReductionClause(unsigned N)
4440 llvm::omp::OMPC_in_reduction, SourceLocation(), SourceLocation(),
4441 SourceLocation(), N),
4443
4444 /// Sets location of ':' symbol in clause.
4445 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
4446
4447 /// Sets the name info for specified reduction identifier.
4448 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
4449
4450 /// Sets the nested name specifier.
4451 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
4452
4453 /// Set list of helper expressions, required for proper codegen of the clause.
4454 /// These expressions represent private copy of the reduction variable.
4455 void setPrivates(ArrayRef<Expr *> Privates);
4456
4457 /// Get the list of helper privates.
4458 MutableArrayRef<Expr *> getPrivates() {
4459 return {varlist_end(), varlist_size()};
4460 }
4461 ArrayRef<const Expr *> getPrivates() const {
4462 return {varlist_end(), varlist_size()};
4463 }
4464
4465 /// Set list of helper expressions, required for proper codegen of the clause.
4466 /// These expressions represent LHS expression in the final reduction
4467 /// expression performed by the reduction clause.
4468 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
4469
4470 /// Get the list of helper LHS expressions.
4471 MutableArrayRef<Expr *> getLHSExprs() {
4472 return {getPrivates().end(), varlist_size()};
4473 }
4474 ArrayRef<const Expr *> getLHSExprs() const {
4475 return {getPrivates().end(), varlist_size()};
4476 }
4477
4478 /// Set list of helper expressions, required for proper codegen of the clause.
4479 /// These expressions represent RHS expression in the final reduction
4480 /// expression performed by the reduction clause. Also, variables in these
4481 /// expressions are used for proper initialization of reduction copies.
4482 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
4483
4484 /// Get the list of helper destination expressions.
4485 MutableArrayRef<Expr *> getRHSExprs() {
4486 return {getLHSExprs().end(), varlist_size()};
4487 }
4488 ArrayRef<const Expr *> getRHSExprs() const {
4489 return {getLHSExprs().end(), varlist_size()};
4490 }
4491
4492 /// Set list of helper reduction expressions, required for proper
4493 /// codegen of the clause. These expressions are binary expressions or
4494 /// operator/custom reduction call that calculates new value from source
4495 /// helper expressions to destination helper expressions.
4496 void setReductionOps(ArrayRef<Expr *> ReductionOps);
4497
4498 /// Get the list of helper reduction expressions.
4499 MutableArrayRef<Expr *> getReductionOps() {
4500 return {getRHSExprs().end(), varlist_size()};
4501 }
4502 ArrayRef<const Expr *> getReductionOps() const {
4503 return {getRHSExprs().end(), varlist_size()};
4504 }
4505
4506 /// Set list of helper reduction taskgroup descriptors.
4507 void setTaskgroupDescriptors(ArrayRef<Expr *> ReductionOps);
4508
4509 /// Get the list of helper reduction taskgroup descriptors.
4510 MutableArrayRef<Expr *> getTaskgroupDescriptors() {
4511 return {getReductionOps().end(), varlist_size()};
4512 }
4513 ArrayRef<const Expr *> getTaskgroupDescriptors() const {
4514 return {getReductionOps().end(), varlist_size()};
4515 }
4516
4517public:
4518 /// Creates clause with a list of variables \a VL.
4519 ///
4520 /// \param StartLoc Starting location of the clause.
4521 /// \param LParenLoc Location of '('.
4522 /// \param ColonLoc Location of ':'.
4523 /// \param EndLoc Ending location of the clause.
4524 /// \param VL The variables in the clause.
4525 /// \param QualifierLoc The nested-name qualifier with location information
4526 /// \param NameInfo The full name info for reduction identifier.
4527 /// \param Privates List of helper expressions for proper generation of
4528 /// private copies.
4529 /// \param LHSExprs List of helper expressions for proper generation of
4530 /// assignment operation required for copyprivate clause. This list represents
4531 /// LHSs of the reduction expressions.
4532 /// \param RHSExprs List of helper expressions for proper generation of
4533 /// assignment operation required for copyprivate clause. This list represents
4534 /// RHSs of the reduction expressions.
4535 /// Also, variables in these expressions are used for proper initialization of
4536 /// reduction copies.
4537 /// \param ReductionOps List of helper expressions that represents reduction
4538 /// expressions:
4539 /// \code
4540 /// LHSExprs binop RHSExprs;
4541 /// operator binop(LHSExpr, RHSExpr);
4542 /// <CutomReduction>(LHSExpr, RHSExpr);
4543 /// \endcode
4544 /// Required for proper codegen of final reduction operation performed by the
4545 /// reduction clause.
4546 /// \param TaskgroupDescriptors List of helper taskgroup descriptors for
4547 /// corresponding items in parent taskgroup task_reduction clause.
4548 /// \param PreInit Statement that must be executed before entering the OpenMP
4549 /// region with this clause.
4550 /// \param PostUpdate Expression that must be executed after exit from the
4551 /// OpenMP region with this clause.
4552 static OMPInReductionClause *
4553 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4554 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
4555 NestedNameSpecifierLoc QualifierLoc,
4556 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4557 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4558 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> TaskgroupDescriptors,
4559 Stmt *PreInit, Expr *PostUpdate);
4560
4561 /// Creates an empty clause with the place for \a N variables.
4562 ///
4563 /// \param C AST context.
4564 /// \param N The number of variables.
4565 static OMPInReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
4566
4567 /// Gets location of ':' symbol in clause.
4568 SourceLocation getColonLoc() const { return ColonLoc; }
4569
4570 /// Gets the name info for specified reduction identifier.
4571 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4572
4573 /// Gets the nested name specifier.
4574 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4575
4578 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4580 llvm::iterator_range<helper_expr_const_iterator>;
4581
4583 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
4584 }
4585
4587 return helper_expr_range(getPrivates().begin(), getPrivates().end());
4588 }
4589
4591 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
4592 }
4593
4595 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
4596 }
4597
4599 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
4600 }
4601
4603 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
4604 }
4605
4607 return helper_expr_const_range(getReductionOps().begin(),
4608 getReductionOps().end());
4609 }
4610
4612 return helper_expr_range(getReductionOps().begin(),
4613 getReductionOps().end());
4614 }
4615
4617 return helper_expr_const_range(getTaskgroupDescriptors().begin(),
4618 getTaskgroupDescriptors().end());
4619 }
4620
4622 return helper_expr_range(getTaskgroupDescriptors().begin(),
4623 getTaskgroupDescriptors().end());
4624 }
4625
4627 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4628 reinterpret_cast<Stmt **>(varlist_end()));
4629 }
4630
4632 auto Children = const_cast<OMPInReductionClause *>(this)->children();
4633 return const_child_range(Children.begin(), Children.end());
4634 }
4635
4642
4643 static bool classof(const OMPClause *T) {
4644 return T->getClauseKind() == llvm::omp::OMPC_in_reduction;
4645 }
4646};
4647
4648/// This represents clause 'linear' in the '#pragma omp ...'
4649/// directives.
4650///
4651/// \code
4652/// #pragma omp simd linear(a,b : 2)
4653/// \endcode
4654/// In this example directive '#pragma omp simd' has clause 'linear'
4655/// with variables 'a', 'b' and linear step '2'.
4656class OMPLinearClause final
4657 : public OMPVarListClause<OMPLinearClause>,
4659 private llvm::TrailingObjects<OMPLinearClause, Expr *> {
4660 friend class OMPClauseReader;
4661 friend OMPVarListClause;
4662 friend TrailingObjects;
4663
4664 /// Modifier of 'linear' clause.
4665 OpenMPLinearClauseKind Modifier = OMPC_LINEAR_val;
4666
4667 /// Location of linear modifier if any.
4668 SourceLocation ModifierLoc;
4669
4670 /// Location of ':'.
4671 SourceLocation ColonLoc;
4672
4673 /// Location of 'step' modifier.
4674 SourceLocation StepModifierLoc;
4675
4676 /// Sets the linear step for clause.
4677 void setStep(Expr *Step) { *(getFinals().end()) = Step; }
4678
4679 /// Sets the expression to calculate linear step for clause.
4680 void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
4681
4682 /// Build 'linear' clause with given number of variables \a NumVars.
4683 ///
4684 /// \param StartLoc Starting location of the clause.
4685 /// \param LParenLoc Location of '('.
4686 /// \param ColonLoc Location of ':'.
4687 /// \param StepModifierLoc Location of 'step' modifier.
4688 /// \param EndLoc Ending location of the clause.
4689 /// \param NumVars Number of variables.
4690 OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4691 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4692 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4693 SourceLocation EndLoc, unsigned NumVars)
4694 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear, StartLoc,
4695 LParenLoc, EndLoc, NumVars),
4696 OMPClauseWithPostUpdate(this), Modifier(Modifier),
4697 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
4698 StepModifierLoc(StepModifierLoc) {}
4699
4700 /// Build an empty clause.
4701 ///
4702 /// \param NumVars Number of variables.
4703 explicit OMPLinearClause(unsigned NumVars)
4704 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear,
4705 SourceLocation(), SourceLocation(),
4706 SourceLocation(), NumVars),
4708
4709 /// Gets the list of initial values for linear variables.
4710 ///
4711 /// There are NumVars expressions with initial values allocated after the
4712 /// varlist, they are followed by NumVars update expressions (used to update
4713 /// the linear variable's value on current iteration) and they are followed by
4714 /// NumVars final expressions (used to calculate the linear variable's
4715 /// value after the loop body). After these lists, there are 2 helper
4716 /// expressions - linear step and a helper to calculate it before the
4717 /// loop body (used when the linear step is not constant):
4718 ///
4719 /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
4720 /// Finals[]; Step; CalcStep; }
4721 MutableArrayRef<Expr *> getPrivates() {
4722 return {varlist_end(), varlist_size()};
4723 }
4724 ArrayRef<const Expr *> getPrivates() const {
4725 return {varlist_end(), varlist_size()};
4726 }
4727
4728 MutableArrayRef<Expr *> getInits() {
4729 return {getPrivates().end(), varlist_size()};
4730 }
4731 ArrayRef<const Expr *> getInits() const {
4732 return {getPrivates().end(), varlist_size()};
4733 }
4734
4735 /// Sets the list of update expressions for linear variables.
4736 MutableArrayRef<Expr *> getUpdates() {
4737 return {getInits().end(), varlist_size()};
4738 }
4739 ArrayRef<const Expr *> getUpdates() const {
4740 return {getInits().end(), varlist_size()};
4741 }
4742
4743 /// Sets the list of final update expressions for linear variables.
4744 MutableArrayRef<Expr *> getFinals() {
4745 return {getUpdates().end(), varlist_size()};
4746 }
4747 ArrayRef<const Expr *> getFinals() const {
4748 return {getUpdates().end(), varlist_size()};
4749 }
4750
4751 /// Gets the list of used expressions for linear variables.
4752 MutableArrayRef<Expr *> getUsedExprs() {
4753 return {getFinals().end() + 2, varlist_size() + 1};
4754 }
4755 ArrayRef<const Expr *> getUsedExprs() const {
4756 return {getFinals().end() + 2, varlist_size() + 1};
4757 }
4758
4759 /// Sets the list of the copies of original linear variables.
4760 /// \param PL List of expressions.
4761 void setPrivates(ArrayRef<Expr *> PL);
4762
4763 /// Sets the list of the initial values for linear variables.
4764 /// \param IL List of expressions.
4765 void setInits(ArrayRef<Expr *> IL);
4766
4767public:
4768 /// Creates clause with a list of variables \a VL and a linear step
4769 /// \a Step.
4770 ///
4771 /// \param C AST Context.
4772 /// \param StartLoc Starting location of the clause.
4773 /// \param LParenLoc Location of '('.
4774 /// \param Modifier Modifier of 'linear' clause.
4775 /// \param ModifierLoc Modifier location.
4776 /// \param ColonLoc Location of ':'.
4777 /// \param StepModifierLoc Location of 'step' modifier.
4778 /// \param EndLoc Ending location of the clause.
4779 /// \param VL List of references to the variables.
4780 /// \param PL List of private copies of original variables.
4781 /// \param IL List of initial values for the variables.
4782 /// \param Step Linear step.
4783 /// \param CalcStep Calculation of the linear step.
4784 /// \param PreInit Statement that must be executed before entering the OpenMP
4785 /// region with this clause.
4786 /// \param PostUpdate Expression that must be executed after exit from the
4787 /// OpenMP region with this clause.
4788 static OMPLinearClause *
4789 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4790 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4791 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4792 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PL,
4793 ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit,
4794 Expr *PostUpdate);
4795
4796 /// Creates an empty clause with the place for \a NumVars variables.
4797 ///
4798 /// \param C AST context.
4799 /// \param NumVars Number of variables.
4800 static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4801
4802 /// Set modifier.
4803 void setModifier(OpenMPLinearClauseKind Kind) { Modifier = Kind; }
4804
4805 /// Return modifier.
4806 OpenMPLinearClauseKind getModifier() const { return Modifier; }
4807
4808 /// Set modifier location.
4809 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
4810
4811 /// Return modifier location.
4812 SourceLocation getModifierLoc() const { return ModifierLoc; }
4813
4814 /// Sets the location of ':'.
4815 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4816
4817 /// Sets the location of 'step' modifier.
4818 void setStepModifierLoc(SourceLocation Loc) { StepModifierLoc = Loc; }
4819
4820 /// Returns the location of ':'.
4821 SourceLocation getColonLoc() const { return ColonLoc; }
4822
4823 /// Returns the location of 'step' modifier.
4824 SourceLocation getStepModifierLoc() const { return StepModifierLoc; }
4825
4826 /// Returns linear step.
4827 Expr *getStep() { return *(getFinals().end()); }
4828
4829 /// Returns linear step.
4830 const Expr *getStep() const { return *(getFinals().end()); }
4831
4832 /// Returns expression to calculate linear step.
4833 Expr *getCalcStep() { return *(getFinals().end() + 1); }
4834
4835 /// Returns expression to calculate linear step.
4836 const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
4837
4838 /// Sets the list of update expressions for linear variables.
4839 /// \param UL List of expressions.
4841
4842 /// Sets the list of final update expressions for linear variables.
4843 /// \param FL List of expressions.
4844 void setFinals(ArrayRef<Expr *> FL);
4845
4846 /// Sets the list of used expressions for the linear clause.
4848
4851 using privates_range = llvm::iterator_range<privates_iterator>;
4852 using privates_const_range = llvm::iterator_range<privates_const_iterator>;
4853
4855 return privates_range(getPrivates().begin(), getPrivates().end());
4856 }
4857
4859 return privates_const_range(getPrivates().begin(), getPrivates().end());
4860 }
4861
4864 using inits_range = llvm::iterator_range<inits_iterator>;
4865 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
4866
4868 return inits_range(getInits().begin(), getInits().end());
4869 }
4870
4872 return inits_const_range(getInits().begin(), getInits().end());
4873 }
4874
4877 using updates_range = llvm::iterator_range<updates_iterator>;
4878 using updates_const_range = llvm::iterator_range<updates_const_iterator>;
4879
4881 return updates_range(getUpdates().begin(), getUpdates().end());
4882 }
4883
4885 return updates_const_range(getUpdates().begin(), getUpdates().end());
4886 }
4887
4890 using finals_range = llvm::iterator_range<finals_iterator>;
4891 using finals_const_range = llvm::iterator_range<finals_const_iterator>;
4892
4894 return finals_range(getFinals().begin(), getFinals().end());
4895 }
4896
4898 return finals_const_range(getFinals().begin(), getFinals().end());
4899 }
4900
4904 llvm::iterator_range<used_expressions_iterator>;
4906 llvm::iterator_range<used_expressions_const_iterator>;
4907
4909 return finals_range(getUsedExprs().begin(), getUsedExprs().end());
4910 }
4911
4913 return finals_const_range(getUsedExprs().begin(), getUsedExprs().end());
4914 }
4915
4917 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4918 reinterpret_cast<Stmt **>(varlist_end()));
4919 }
4920
4922 auto Children = const_cast<OMPLinearClause *>(this)->children();
4923 return const_child_range(Children.begin(), Children.end());
4924 }
4925
4927
4929 auto Children = const_cast<OMPLinearClause *>(this)->used_children();
4930 return const_child_range(Children.begin(), Children.end());
4931 }
4932
4933 static bool classof(const OMPClause *T) {
4934 return T->getClauseKind() == llvm::omp::OMPC_linear;
4935 }
4936};
4937
4938/// This represents clause 'aligned' in the '#pragma omp ...'
4939/// directives.
4940///
4941/// \code
4942/// #pragma omp simd aligned(a,b : 8)
4943/// \endcode
4944/// In this example directive '#pragma omp simd' has clause 'aligned'
4945/// with variables 'a', 'b' and alignment '8'.
4946class OMPAlignedClause final
4947 : public OMPVarListClause<OMPAlignedClause>,
4948 private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
4949 friend class OMPClauseReader;
4950 friend OMPVarListClause;
4951 friend TrailingObjects;
4952
4953 /// Location of ':'.
4954 SourceLocation ColonLoc;
4955
4956 /// Sets the alignment for clause.
4957 void setAlignment(Expr *A) { *varlist_end() = A; }
4958
4959 /// Build 'aligned' clause with given number of variables \a NumVars.
4960 ///
4961 /// \param StartLoc Starting location of the clause.
4962 /// \param LParenLoc Location of '('.
4963 /// \param ColonLoc Location of ':'.
4964 /// \param EndLoc Ending location of the clause.
4965 /// \param NumVars Number of variables.
4967 SourceLocation ColonLoc, SourceLocation EndLoc,
4968 unsigned NumVars)
4969 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned, StartLoc,
4970 LParenLoc, EndLoc, NumVars),
4971 ColonLoc(ColonLoc) {}
4972
4973 /// Build an empty clause.
4974 ///
4975 /// \param NumVars Number of variables.
4976 explicit OMPAlignedClause(unsigned NumVars)
4977 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned,
4978 SourceLocation(), SourceLocation(),
4979 SourceLocation(), NumVars) {}
4980
4981public:
4982 /// Creates clause with a list of variables \a VL and alignment \a A.
4983 ///
4984 /// \param C AST Context.
4985 /// \param StartLoc Starting location of the clause.
4986 /// \param LParenLoc Location of '('.
4987 /// \param ColonLoc Location of ':'.
4988 /// \param EndLoc Ending location of the clause.
4989 /// \param VL List of references to the variables.
4990 /// \param A Alignment.
4991 static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
4992 SourceLocation LParenLoc,
4993 SourceLocation ColonLoc,
4994 SourceLocation EndLoc, ArrayRef<Expr *> VL,
4995 Expr *A);
4996
4997 /// Creates an empty clause with the place for \a NumVars variables.
4998 ///
4999 /// \param C AST context.
5000 /// \param NumVars Number of variables.
5001 static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
5002
5003 /// Sets the location of ':'.
5004 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
5005
5006 /// Returns the location of ':'.
5007 SourceLocation getColonLoc() const { return ColonLoc; }
5008
5009 /// Returns alignment.
5011
5012 /// Returns alignment.
5013 const Expr *getAlignment() const { return *varlist_end(); }
5014
5016 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5017 reinterpret_cast<Stmt **>(varlist_end()));
5018 }
5019
5021 auto Children = const_cast<OMPAlignedClause *>(this)->children();
5022 return const_child_range(Children.begin(), Children.end());
5023 }
5024
5031
5032 static bool classof(const OMPClause *T) {
5033 return T->getClauseKind() == llvm::omp::OMPC_aligned;
5034 }
5035};
5036
5037/// This represents clause 'copyin' in the '#pragma omp ...' directives.
5038///
5039/// \code
5040/// #pragma omp parallel copyin(a,b)
5041/// \endcode
5042/// In this example directive '#pragma omp parallel' has clause 'copyin'
5043/// with the variables 'a' and 'b'.
5044class OMPCopyinClause final
5045 : public OMPVarListClause<OMPCopyinClause>,
5046 private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
5047 // Class has 3 additional tail allocated arrays:
5048 // 1. List of helper expressions for proper generation of assignment operation
5049 // required for copyin clause. This list represents sources.
5050 // 2. List of helper expressions for proper generation of assignment operation
5051 // required for copyin clause. This list represents destinations.
5052 // 3. List of helper expressions that represents assignment operation:
5053 // \code
5054 // DstExprs = SrcExprs;
5055 // \endcode
5056 // Required for proper codegen of propagation of master's thread values of
5057 // threadprivate variables to local instances of that variables in other
5058 // implicit threads.
5059
5060 friend class OMPClauseReader;
5061 friend OMPVarListClause;
5062 friend TrailingObjects;
5063
5064 /// Build clause with number of variables \a N.
5065 ///
5066 /// \param StartLoc Starting location of the clause.
5067 /// \param LParenLoc Location of '('.
5068 /// \param EndLoc Ending location of the clause.
5069 /// \param N Number of the variables in the clause.
5070 OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5071 SourceLocation EndLoc, unsigned N)
5072 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin, StartLoc,
5073 LParenLoc, EndLoc, N) {}
5074
5075 /// Build an empty clause.
5076 ///
5077 /// \param N Number of variables.
5078 explicit OMPCopyinClause(unsigned N)
5079 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin,
5081 SourceLocation(), N) {}
5082
5083 /// Set list of helper expressions, required for proper codegen of the
5084 /// clause. These expressions represent source expression in the final
5085 /// assignment statement performed by the copyin clause.
5086 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
5087
5088 /// Get the list of helper source expressions.
5089 MutableArrayRef<Expr *> getSourceExprs() {
5090 return {varlist_end(), varlist_size()};
5091 }
5092 ArrayRef<const Expr *> getSourceExprs() const {
5093 return {varlist_end(), varlist_size()};
5094 }
5095
5096 /// Set list of helper expressions, required for proper codegen of the
5097 /// clause. These expressions represent destination expression in the final
5098 /// assignment statement performed by the copyin clause.
5099 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
5100
5101 /// Get the list of helper destination expressions.
5102 MutableArrayRef<Expr *> getDestinationExprs() {
5103 return {getSourceExprs().end(), varlist_size()};
5104 }
5105 ArrayRef<const Expr *> getDestinationExprs() const {
5106 return {getSourceExprs().end(), varlist_size()};
5107 }
5108
5109 /// Set list of helper assignment expressions, required for proper
5110 /// codegen of the clause. These expressions are assignment expressions that
5111 /// assign source helper expressions to destination helper expressions
5112 /// correspondingly.
5113 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
5114
5115 /// Get the list of helper assignment expressions.
5116 MutableArrayRef<Expr *> getAssignmentOps() {
5117 return {getDestinationExprs().end(), varlist_size()};
5118 }
5119 ArrayRef<const Expr *> getAssignmentOps() const {
5120 return {getDestinationExprs().end(), varlist_size()};
5121 }
5122
5123public:
5124 /// Creates clause with a list of variables \a VL.
5125 ///
5126 /// \param C AST context.
5127 /// \param StartLoc Starting location of the clause.
5128 /// \param LParenLoc Location of '('.
5129 /// \param EndLoc Ending location of the clause.
5130 /// \param VL List of references to the variables.
5131 /// \param SrcExprs List of helper expressions for proper generation of
5132 /// assignment operation required for copyin clause. This list represents
5133 /// sources.
5134 /// \param DstExprs List of helper expressions for proper generation of
5135 /// assignment operation required for copyin clause. This list represents
5136 /// destinations.
5137 /// \param AssignmentOps List of helper expressions that represents assignment
5138 /// operation:
5139 /// \code
5140 /// DstExprs = SrcExprs;
5141 /// \endcode
5142 /// Required for proper codegen of propagation of master's thread values of
5143 /// threadprivate variables to local instances of that variables in other
5144 /// implicit threads.
5145 static OMPCopyinClause *
5146 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
5147 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
5148 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
5149
5150 /// Creates an empty clause with \a N variables.
5151 ///
5152 /// \param C AST context.
5153 /// \param N The number of variables.
5154 static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
5155
5158 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
5160 llvm::iterator_range<helper_expr_const_iterator>;
5161
5163 return helper_expr_const_range(getSourceExprs().begin(),
5164 getSourceExprs().end());
5165 }
5166
5168 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
5169 }
5170
5172 return helper_expr_const_range(getDestinationExprs().begin(),
5173 getDestinationExprs().end());
5174 }
5175
5177 return helper_expr_range(getDestinationExprs().begin(),
5178 getDestinationExprs().end());
5179 }
5180
5182 return helper_expr_const_range(getAssignmentOps().begin(),
5183 getAssignmentOps().end());
5184 }
5185
5187 return helper_expr_range(getAssignmentOps().begin(),
5188 getAssignmentOps().end());
5189 }
5190
5192 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5193 reinterpret_cast<Stmt **>(varlist_end()));
5194 }
5195
5197 auto Children = const_cast<OMPCopyinClause *>(this)->children();
5198 return const_child_range(Children.begin(), Children.end());
5199 }
5200
5207
5208 static bool classof(const OMPClause *T) {
5209 return T->getClauseKind() == llvm::omp::OMPC_copyin;
5210 }
5211};
5212
5213/// This represents clause 'copyprivate' in the '#pragma omp ...'
5214/// directives.
5215///
5216/// \code
5217/// #pragma omp single copyprivate(a,b)
5218/// \endcode
5219/// In this example directive '#pragma omp single' has clause 'copyprivate'
5220/// with the variables 'a' and 'b'.
5221class OMPCopyprivateClause final
5222 : public OMPVarListClause<OMPCopyprivateClause>,
5223 private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
5224 friend class OMPClauseReader;
5225 friend OMPVarListClause;
5226 friend TrailingObjects;
5227
5228 /// Build clause with number of variables \a N.
5229 ///
5230 /// \param StartLoc Starting location of the clause.
5231 /// \param LParenLoc Location of '('.
5232 /// \param EndLoc Ending location of the clause.
5233 /// \param N Number of the variables in the clause.
5234 OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5235 SourceLocation EndLoc, unsigned N)
5236 : OMPVarListClause<OMPCopyprivateClause>(llvm::omp::OMPC_copyprivate,
5237 StartLoc, LParenLoc, EndLoc, N) {
5238 }
5239
5240 /// Build an empty clause.
5241 ///
5242 /// \param N Number of variables.
5243 explicit OMPCopyprivateClause(unsigned N)
5245 llvm::omp::OMPC_copyprivate, SourceLocation(), SourceLocation(),
5246 SourceLocation(), N) {}
5247
5248 /// Set list of helper expressions, required for proper codegen of the
5249 /// clause. These expressions represent source expression in the final
5250 /// assignment statement performed by the copyprivate clause.
5251 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
5252
5253 /// Get the list of helper source expressions.
5254 MutableArrayRef<Expr *> getSourceExprs() {
5255 return {varlist_end(), varlist_size()};
5256 }
5257 ArrayRef<const Expr *> getSourceExprs() const {
5258 return {varlist_end(), varlist_size()};
5259 }
5260
5261 /// Set list of helper expressions, required for proper codegen of the
5262 /// clause. These expressions represent destination expression in the final
5263 /// assignment statement performed by the copyprivate clause.
5264 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
5265
5266 /// Get the list of helper destination expressions.
5267 MutableArrayRef<Expr *> getDestinationExprs() {
5268 return {getSourceExprs().end(), varlist_size()};
5269 }
5270 ArrayRef<const Expr *> getDestinationExprs() const {
5271 return {getSourceExprs().end(), varlist_size()};
5272 }
5273
5274 /// Set list of helper assignment expressions, required for proper
5275 /// codegen of the clause. These expressions are assignment expressions that
5276 /// assign source helper expressions to destination helper expressions
5277 /// correspondingly.
5278 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
5279
5280 /// Get the list of helper assignment expressions.
5281 MutableArrayRef<Expr *> getAssignmentOps() {
5282 return {getDestinationExprs().end(), varlist_size()};
5283 }
5284 ArrayRef<const Expr *> getAssignmentOps() const {
5285 return {getDestinationExprs().end(), varlist_size()};
5286 }
5287
5288public:
5289 /// Creates clause with a list of variables \a VL.
5290 ///
5291 /// \param C AST context.
5292 /// \param StartLoc Starting location of the clause.
5293 /// \param LParenLoc Location of '('.
5294 /// \param EndLoc Ending location of the clause.
5295 /// \param VL List of references to the variables.
5296 /// \param SrcExprs List of helper expressions for proper generation of
5297 /// assignment operation required for copyprivate clause. This list represents
5298 /// sources.
5299 /// \param DstExprs List of helper expressions for proper generation of
5300 /// assignment operation required for copyprivate clause. This list represents
5301 /// destinations.
5302 /// \param AssignmentOps List of helper expressions that represents assignment
5303 /// operation:
5304 /// \code
5305 /// DstExprs = SrcExprs;
5306 /// \endcode
5307 /// Required for proper codegen of final assignment performed by the
5308 /// copyprivate clause.
5309 static OMPCopyprivateClause *
5310 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
5311 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
5312 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
5313
5314 /// Creates an empty clause with \a N variables.
5315 ///
5316 /// \param C AST context.
5317 /// \param N The number of variables.
5318 static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
5319
5322 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
5324 llvm::iterator_range<helper_expr_const_iterator>;
5325
5327 return helper_expr_const_range(getSourceExprs().begin(),
5328 getSourceExprs().end());
5329 }
5330
5332 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
5333 }
5334
5336 return helper_expr_const_range(getDestinationExprs().begin(),
5337 getDestinationExprs().end());
5338 }
5339
5341 return helper_expr_range(getDestinationExprs().begin(),
5342 getDestinationExprs().end());
5343 }
5344
5346 return helper_expr_const_range(getAssignmentOps().begin(),
5347 getAssignmentOps().end());
5348 }
5349
5351 return helper_expr_range(getAssignmentOps().begin(),
5352 getAssignmentOps().end());
5353 }
5354
5356 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5357 reinterpret_cast<Stmt **>(varlist_end()));
5358 }
5359
5361 auto Children = const_cast<OMPCopyprivateClause *>(this)->children();
5362 return const_child_range(Children.begin(), Children.end());
5363 }
5364
5371
5372 static bool classof(const OMPClause *T) {
5373 return T->getClauseKind() == llvm::omp::OMPC_copyprivate;
5374 }
5375};
5376
5377/// This represents implicit clause 'flush' for the '#pragma omp flush'
5378/// directive.
5379/// This clause does not exist by itself, it can be only as a part of 'omp
5380/// flush' directive. This clause is introduced to keep the original structure
5381/// of \a OMPExecutableDirective class and its derivatives and to use the
5382/// existing infrastructure of clauses with the list of variables.
5383///
5384/// \code
5385/// #pragma omp flush(a,b)
5386/// \endcode
5387/// In this example directive '#pragma omp flush' has implicit clause 'flush'
5388/// with the variables 'a' and 'b'.
5389class OMPFlushClause final
5390 : public OMPVarListClause<OMPFlushClause>,
5391 private llvm::TrailingObjects<OMPFlushClause, Expr *> {
5392 friend OMPVarListClause;
5393 friend TrailingObjects;
5394
5395 /// Build clause with number of variables \a N.
5396 ///
5397 /// \param StartLoc Starting location of the clause.
5398 /// \param LParenLoc Location of '('.
5399 /// \param EndLoc Ending location of the clause.
5400 /// \param N Number of the variables in the clause.
5401 OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5402 SourceLocation EndLoc, unsigned N)
5403 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush, StartLoc,
5404 LParenLoc, EndLoc, N) {}
5405
5406 /// Build an empty clause.
5407 ///
5408 /// \param N Number of variables.
5409 explicit OMPFlushClause(unsigned N)
5410 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush,
5412 SourceLocation(), N) {}
5413
5414public:
5415 /// Creates clause with a list of variables \a VL.
5416 ///
5417 /// \param C AST context.
5418 /// \param StartLoc Starting location of the clause.
5419 /// \param LParenLoc Location of '('.
5420 /// \param EndLoc Ending location of the clause.
5421 /// \param VL List of references to the variables.
5422 static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
5423 SourceLocation LParenLoc, SourceLocation EndLoc,
5424 ArrayRef<Expr *> VL);
5425
5426 /// Creates an empty clause with \a N variables.
5427 ///
5428 /// \param C AST context.
5429 /// \param N The number of variables.
5430 static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
5431
5433 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5434 reinterpret_cast<Stmt **>(varlist_end()));
5435 }
5436
5438 auto Children = const_cast<OMPFlushClause *>(this)->children();
5439 return const_child_range(Children.begin(), Children.end());
5440 }
5441
5448
5449 static bool classof(const OMPClause *T) {
5450 return T->getClauseKind() == llvm::omp::OMPC_flush;
5451 }
5452};
5453
5454/// This represents implicit clause 'depobj' for the '#pragma omp depobj'
5455/// directive.
5456/// This clause does not exist by itself, it can be only as a part of 'omp
5457/// depobj' directive. This clause is introduced to keep the original structure
5458/// of \a OMPExecutableDirective class and its derivatives and to use the
5459/// existing infrastructure of clauses with the list of variables.
5460///
5461/// \code
5462/// #pragma omp depobj(a) destroy
5463/// \endcode
5464/// In this example directive '#pragma omp depobj' has implicit clause 'depobj'
5465/// with the depobj 'a'.
5466class OMPDepobjClause final : public OMPClause {
5467 friend class OMPClauseReader;
5468
5469 /// Location of '('.
5470 SourceLocation LParenLoc;
5471
5472 /// Chunk size.
5473 Expr *Depobj = nullptr;
5474
5475 /// Build clause with number of variables \a N.
5476 ///
5477 /// \param StartLoc Starting location of the clause.
5478 /// \param LParenLoc Location of '('.
5479 /// \param EndLoc Ending location of the clause.
5480 OMPDepobjClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5481 SourceLocation EndLoc)
5482 : OMPClause(llvm::omp::OMPC_depobj, StartLoc, EndLoc),
5483 LParenLoc(LParenLoc) {}
5484
5485 /// Build an empty clause.
5486 ///
5487 explicit OMPDepobjClause()
5488 : OMPClause(llvm::omp::OMPC_depobj, SourceLocation(), SourceLocation()) {}
5489
5490 void setDepobj(Expr *E) { Depobj = E; }
5491
5492 /// Sets the location of '('.
5493 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5494
5495public:
5496 /// Creates clause.
5497 ///
5498 /// \param C AST context.
5499 /// \param StartLoc Starting location of the clause.
5500 /// \param LParenLoc Location of '('.
5501 /// \param EndLoc Ending location of the clause.
5502 /// \param Depobj depobj expression associated with the 'depobj' directive.
5503 static OMPDepobjClause *Create(const ASTContext &C, SourceLocation StartLoc,
5504 SourceLocation LParenLoc,
5505 SourceLocation EndLoc, Expr *Depobj);
5506
5507 /// Creates an empty clause.
5508 ///
5509 /// \param C AST context.
5510 static OMPDepobjClause *CreateEmpty(const ASTContext &C);
5511
5512 /// Returns depobj expression associated with the clause.
5513 Expr *getDepobj() { return Depobj; }
5514 const Expr *getDepobj() const { return Depobj; }
5515
5516 /// Returns the location of '('.
5517 SourceLocation getLParenLoc() const { return LParenLoc; }
5518
5520 return child_range(reinterpret_cast<Stmt **>(&Depobj),
5521 reinterpret_cast<Stmt **>(&Depobj) + 1);
5522 }
5523
5525 auto Children = const_cast<OMPDepobjClause *>(this)->children();
5526 return const_child_range(Children.begin(), Children.end());
5527 }
5528
5535
5536 static bool classof(const OMPClause *T) {
5537 return T->getClauseKind() == llvm::omp::OMPC_depobj;
5538 }
5539};
5540
5541/// This represents implicit clause 'depend' for the '#pragma omp task'
5542/// directive.
5543///
5544/// \code
5545/// #pragma omp task depend(in:a,b)
5546/// \endcode
5547/// In this example directive '#pragma omp task' with clause 'depend' with the
5548/// variables 'a' and 'b' with dependency 'in'.
5549class OMPDependClause final
5550 : public OMPVarListClause<OMPDependClause>,
5551 private llvm::TrailingObjects<OMPDependClause, Expr *> {
5552 friend class OMPClauseReader;
5553 friend OMPVarListClause;
5554 friend TrailingObjects;
5555
5556public:
5557 struct DependDataTy final {
5558 /// Dependency type (one of in, out, inout).
5560
5561 /// Dependency type location.
5563
5564 /// Colon location.
5566
5567 /// Location of 'omp_all_memory'.
5569 };
5570
5571private:
5572 /// Dependency type and source locations.
5573 DependDataTy Data;
5574
5575 /// Number of loops, associated with the depend clause.
5576 unsigned NumLoops = 0;
5577
5578 /// Build clause with number of variables \a N.
5579 ///
5580 /// \param StartLoc Starting location of the clause.
5581 /// \param LParenLoc Location of '('.
5582 /// \param EndLoc Ending location of the clause.
5583 /// \param N Number of the variables in the clause.
5584 /// \param NumLoops Number of loops that is associated with this depend
5585 /// clause.
5586 OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5587 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
5588 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend, StartLoc,
5589 LParenLoc, EndLoc, N),
5590 NumLoops(NumLoops) {}
5591
5592 /// Build an empty clause.
5593 ///
5594 /// \param N Number of variables.
5595 /// \param NumLoops Number of loops that is associated with this depend
5596 /// clause.
5597 explicit OMPDependClause(unsigned N, unsigned NumLoops)
5598 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend,
5600 SourceLocation(), N),
5601 NumLoops(NumLoops) {}
5602
5603 /// Set dependency kind.
5604 void setDependencyKind(OpenMPDependClauseKind K) { Data.DepKind = K; }
5605
5606 /// Set dependency kind and its location.
5607 void setDependencyLoc(SourceLocation Loc) { Data.DepLoc = Loc; }
5608
5609 /// Set colon location.
5610 void setColonLoc(SourceLocation Loc) { Data.ColonLoc = Loc; }
5611
5612 /// Set the 'omp_all_memory' location.
5613 void setOmpAllMemoryLoc(SourceLocation Loc) { Data.OmpAllMemoryLoc = Loc; }
5614
5615 /// Sets optional dependency modifier.
5616 void setModifier(Expr *DepModifier);
5617
5618public:
5619 /// Creates clause with a list of variables \a VL.
5620 ///
5621 /// \param C AST context.
5622 /// \param StartLoc Starting location of the clause.
5623 /// \param LParenLoc Location of '('.
5624 /// \param EndLoc Ending location of the clause.
5625 /// \param Data Dependency type and source locations.
5626 /// \param VL List of references to the variables.
5627 /// \param NumLoops Number of loops that is associated with this depend
5628 /// clause.
5629 static OMPDependClause *Create(const ASTContext &C, SourceLocation StartLoc,
5630 SourceLocation LParenLoc,
5631 SourceLocation EndLoc, DependDataTy Data,
5632 Expr *DepModifier, ArrayRef<Expr *> VL,
5633 unsigned NumLoops);
5634
5635 /// Creates an empty clause with \a N variables.
5636 ///
5637 /// \param C AST context.
5638 /// \param N The number of variables.
5639 /// \param NumLoops Number of loops that is associated with this depend
5640 /// clause.
5641 static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N,
5642 unsigned NumLoops);
5643
5644 /// Get dependency type.
5645 OpenMPDependClauseKind getDependencyKind() const { return Data.DepKind; }
5646
5647 /// Get dependency type location.
5648 SourceLocation getDependencyLoc() const { return Data.DepLoc; }
5649
5650 /// Get colon location.
5651 SourceLocation getColonLoc() const { return Data.ColonLoc; }
5652
5653 /// Get 'omp_all_memory' location.
5654 SourceLocation getOmpAllMemoryLoc() const { return Data.OmpAllMemoryLoc; }
5655
5656 /// Return optional depend modifier.
5657 Expr *getModifier();
5658 const Expr *getModifier() const {
5659 return const_cast<OMPDependClause *>(this)->getModifier();
5660 }
5661
5662 /// Get number of loops associated with the clause.
5663 unsigned getNumLoops() const { return NumLoops; }
5664
5665 /// Set the loop data for the depend clauses with 'sink|source' kind of
5666 /// dependency.
5667 void setLoopData(unsigned NumLoop, Expr *Cnt);
5668
5669 /// Get the loop data.
5670 Expr *getLoopData(unsigned NumLoop);
5671 const Expr *getLoopData(unsigned NumLoop) const;
5672
5674 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5675 reinterpret_cast<Stmt **>(varlist_end()));
5676 }
5677
5679 auto Children = const_cast<OMPDependClause *>(this)->children();
5680 return const_child_range(Children.begin(), Children.end());
5681 }
5682
5689
5690 static bool classof(const OMPClause *T) {
5691 return T->getClauseKind() == llvm::omp::OMPC_depend;
5692 }
5693};
5694
5695/// This represents 'device' clause in the '#pragma omp ...'
5696/// directive.
5697///
5698/// \code
5699/// #pragma omp target device(a)
5700/// \endcode
5701/// In this example directive '#pragma omp target' has clause 'device'
5702/// with single expression 'a'.
5704 friend class OMPClauseReader;
5705
5706 /// Location of '('.
5707 SourceLocation LParenLoc;
5708
5709 /// Device clause modifier.
5711
5712 /// Location of the modifier.
5713 SourceLocation ModifierLoc;
5714
5715 /// Device number.
5716 Stmt *Device = nullptr;
5717
5718 /// Set the device number.
5719 ///
5720 /// \param E Device number.
5721 void setDevice(Expr *E) { Device = E; }
5722
5723 /// Sets modifier.
5724 void setModifier(OpenMPDeviceClauseModifier M) { Modifier = M; }
5725
5726 /// Setst modifier location.
5727 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
5728
5729public:
5730 /// Build 'device' clause.
5731 ///
5732 /// \param Modifier Clause modifier.
5733 /// \param E Expression associated with this clause.
5734 /// \param CaptureRegion Innermost OpenMP region where expressions in this
5735 /// clause must be captured.
5736 /// \param StartLoc Starting location of the clause.
5737 /// \param ModifierLoc Modifier location.
5738 /// \param LParenLoc Location of '('.
5739 /// \param EndLoc Ending location of the clause.
5741 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
5742 SourceLocation LParenLoc, SourceLocation ModifierLoc,
5743 SourceLocation EndLoc)
5744 : OMPClause(llvm::omp::OMPC_device, StartLoc, EndLoc),
5745 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
5746 ModifierLoc(ModifierLoc), Device(E) {
5747 setPreInitStmt(HelperE, CaptureRegion);
5748 }
5749
5750 /// Build an empty clause.
5752 : OMPClause(llvm::omp::OMPC_device, SourceLocation(), SourceLocation()),
5753 OMPClauseWithPreInit(this) {}
5754
5755 /// Sets the location of '('.
5756 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5757
5758 /// Returns the location of '('.
5759 SourceLocation getLParenLoc() const { return LParenLoc; }
5760
5761 /// Return device number.
5762 Expr *getDevice() { return cast<Expr>(Device); }
5763
5764 /// Return device number.
5765 Expr *getDevice() const { return cast<Expr>(Device); }
5766
5767 /// Gets modifier.
5768 OpenMPDeviceClauseModifier getModifier() const { return Modifier; }
5769
5770 /// Gets modifier location.
5771 SourceLocation getModifierLoc() const { return ModifierLoc; }
5772
5773 child_range children() { return child_range(&Device, &Device + 1); }
5774
5776 return const_child_range(&Device, &Device + 1);
5777 }
5778
5785
5786 static bool classof(const OMPClause *T) {
5787 return T->getClauseKind() == llvm::omp::OMPC_device;
5788 }
5789};
5790
5791/// This represents 'threads' clause in the '#pragma omp ...' directive.
5792///
5793/// \code
5794/// #pragma omp ordered threads
5795/// \endcode
5796/// In this example directive '#pragma omp ordered' has simple 'threads' clause.
5798 : public OMPNoChildClause<llvm::omp::OMPC_threads> {
5799public:
5800 /// Build 'threads' clause.
5801 ///
5802 /// \param StartLoc Starting location of the clause.
5803 /// \param EndLoc Ending location of the clause.
5805 : OMPNoChildClause(StartLoc, EndLoc) {}
5806
5807 /// Build an empty clause.
5809};
5810
5811/// This represents 'simd' clause in the '#pragma omp ...' directive.
5812///
5813/// \code
5814/// #pragma omp ordered simd
5815/// \endcode
5816/// In this example directive '#pragma omp ordered' has simple 'simd' clause.
5817class OMPSIMDClause : public OMPClause {
5818public:
5819 /// Build 'simd' clause.
5820 ///
5821 /// \param StartLoc Starting location of the clause.
5822 /// \param EndLoc Ending location of the clause.
5824 : OMPClause(llvm::omp::OMPC_simd, StartLoc, EndLoc) {}
5825
5826 /// Build an empty clause.
5828 : OMPClause(llvm::omp::OMPC_simd, SourceLocation(), SourceLocation()) {}
5829
5833
5837
5844
5845 static bool classof(const OMPClause *T) {
5846 return T->getClauseKind() == llvm::omp::OMPC_simd;
5847 }
5848};
5849
5850/// Struct that defines common infrastructure to handle mappable
5851/// expressions used in OpenMP clauses.
5853public:
5854 /// Class that represents a component of a mappable expression. E.g.
5855 /// for an expression S.a, the first component is a declaration reference
5856 /// expression associated with 'S' and the second is a member expression
5857 /// associated with the field declaration 'a'. If the expression is an array
5858 /// subscript it may not have any associated declaration. In that case the
5859 /// associated declaration is set to nullptr.
5861 /// Pair of Expression and Non-contiguous pair associated with the
5862 /// component.
5863 llvm::PointerIntPair<Expr *, 1, bool> AssociatedExpressionNonContiguousPr;
5864
5865 /// Declaration associated with the declaration. If the component does
5866 /// not have a declaration (e.g. array subscripts or section), this is set
5867 /// to nullptr.
5868 ValueDecl *AssociatedDeclaration = nullptr;
5869
5870 public:
5871 explicit MappableComponent() = default;
5872 explicit MappableComponent(Expr *AssociatedExpression,
5873 ValueDecl *AssociatedDeclaration,
5874 bool IsNonContiguous)
5875 : AssociatedExpressionNonContiguousPr(AssociatedExpression,
5876 IsNonContiguous),
5877 AssociatedDeclaration(
5878 AssociatedDeclaration
5879 ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
5880 : nullptr) {}
5881
5883 return AssociatedExpressionNonContiguousPr.getPointer();
5884 }
5885
5886 bool isNonContiguous() const {
5887 return AssociatedExpressionNonContiguousPr.getInt();
5888 }
5889
5891 return AssociatedDeclaration;
5892 }
5893
5895 return AssociatedExpressionNonContiguousPr ==
5896 Other.AssociatedExpressionNonContiguousPr &&
5897 AssociatedDeclaration == Other.AssociatedDeclaration;
5898 }
5899 };
5900
5901 // List of components of an expression. This first one is the whole
5902 // expression and the last one is the base expression.
5905
5906 // List of all component lists associated to the same base declaration.
5907 // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
5908 // their component list but the same base declaration 'S'.
5911
5912 // Hash function to allow usage as DenseMap keys.
5913 friend llvm::hash_code hash_value(const MappableComponent &MC) {
5914 return llvm::hash_combine(MC.getAssociatedExpression(),
5916 MC.isNonContiguous());
5917 }
5918
5919public:
5920 /// Get the type of an element of a ComponentList Expr \p Exp.
5921 ///
5922 /// For something like the following:
5923 /// ```c
5924 /// int *p, **p;
5925 /// ```
5926 /// The types for the following Exprs would be:
5927 /// Expr | Type
5928 /// ---------|-----------
5929 /// p | int *
5930 /// *p | int
5931 /// p[0] | int
5932 /// p[0:1] | int
5933 /// pp | int **
5934 /// pp[0] | int *
5935 /// pp[0:1] | int *
5936 /// Note: this assumes that if \p Exp is an array-section, it is contiguous.
5937 static QualType getComponentExprElementType(const Expr *Exp);
5938
5939 /// Find the attach pointer expression from a list of mappable expression
5940 /// components.
5941 ///
5942 /// This function traverses the component list to find the first
5943 /// expression that has a pointer type, which represents the attach
5944 /// base pointer expr for the current component-list.
5945 ///
5946 /// For example, given the following:
5947 ///
5948 /// ```c
5949 /// struct S {
5950 /// int a;
5951 /// int b[10];
5952 /// int c[10][10];
5953 /// int *p;
5954 /// int **pp;
5955 /// }
5956 /// S s, *ps, **pps, *(pas[10]), ***ppps;
5957 /// int i;
5958 /// ```
5959 ///
5960 /// The base-pointers for the following map operands would be:
5961 /// map list-item | attach base-pointer | attach base-pointer
5962 /// | for directives except | target_update (if
5963 /// | target_update | different)
5964 /// ----------------|-----------------------|---------------------
5965 /// s | N/A |
5966 /// s.a | N/A |
5967 /// s.p | N/A |
5968 /// ps | N/A |
5969 /// ps->p | ps |
5970 /// ps[1] | ps |
5971 /// *(ps + 1) | ps |
5972 /// (ps + 1)[1] | ps |
5973 /// ps[1:10] | ps |
5974 /// ps->b[10] | ps |
5975 /// ps->p[10] | ps->p |
5976 /// ps->c[1][2] | ps |
5977 /// ps->c[1:2][2] | (error diagnostic) | N/A, TODO: ps
5978 /// ps->c[1:1][2] | ps | N/A, TODO: ps
5979 /// pps[1][2] | pps[1] |
5980 /// pps[1:1][2] | pps[1:1] | N/A, TODO: pps[1:1]
5981 /// pps[1:i][2] | pps[1:i] | N/A, TODO: pps[1:i]
5982 /// pps[1:2][2] | (error diagnostic) | N/A
5983 /// pps[1]->p | pps[1] |
5984 /// pps[1]->p[10] | pps[1] |
5985 /// pas[1] | N/A |
5986 /// pas[1][2] | pas[1] |
5987 /// ppps[1][2] | ppps[1] |
5988 /// ppps[1][2][3] | ppps[1][2] |
5989 /// ppps[1][2:1][3] | ppps[1][2:1] | N/A, TODO: ppps[1][2:1]
5990 /// ppps[1][2:2][3] | (error diagnostic) | N/A
5991 /// Returns a pair of the attach pointer expression and its depth in the
5992 /// component list.
5993 /// TODO: This may need to be updated to handle ref_ptr/ptee cases for byref
5994 /// map operands.
5995 /// TODO: Handle cases for target-update, where the list-item is a
5996 /// non-contiguous array-section that still has a base-pointer.
5997 static std::pair<const Expr *, std::optional<size_t>>
5999 OpenMPDirectiveKind CurDirKind);
6000
6001protected:
6002 // Return the total number of elements in a list of component lists.
6003 static unsigned
6005
6006 // Return the total number of elements in a list of declarations. All
6007 // declarations are expected to be canonical.
6008 static unsigned
6010};
6011
6012/// This structure contains all sizes needed for by an
6013/// OMPMappableExprListClause.
6015 /// Number of expressions listed.
6016 unsigned NumVars;
6017 /// Number of unique base declarations.
6019 /// Number of component lists.
6021 /// Total number of expression components.
6028};
6029
6030/// This represents clauses with a list of expressions that are mappable.
6031/// Examples of these clauses are 'map' in
6032/// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
6033/// in '#pragma omp target update...' directives.
6034template <class T>
6037 friend class OMPClauseReader;
6038
6039 /// Number of unique declarations in this clause.
6040 unsigned NumUniqueDeclarations;
6041
6042 /// Number of component lists in this clause.
6043 unsigned NumComponentLists;
6044
6045 /// Total number of components in this clause.
6046 unsigned NumComponents;
6047
6048 /// Whether this clause is possible to have user-defined mappers associated.
6049 /// It should be true for map, to, and from clauses, and false for
6050 /// use_device_ptr and is_device_ptr.
6051 const bool SupportsMapper;
6052
6053 /// C++ nested name specifier for the associated user-defined mapper.
6054 NestedNameSpecifierLoc MapperQualifierLoc;
6055
6056 /// The associated user-defined mapper identifier information.
6057 DeclarationNameInfo MapperIdInfo;
6058
6059protected:
6060 /// Build a clause for \a NumUniqueDeclarations declarations, \a
6061 /// NumComponentLists total component lists, and \a NumComponents total
6062 /// components.
6063 ///
6064 /// \param K Kind of the clause.
6065 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6066 /// StartLoc: starting location of the clause (the clause keyword); 2)
6067 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6068 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6069 /// NumVars: number of expressions listed in this clause; 2)
6070 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6071 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6072 /// NumComponents: total number of expression components in the clause.
6073 /// \param SupportsMapper Indicates whether this clause is possible to have
6074 /// user-defined mappers associated.
6075 /// \param MapperQualifierLocPtr C++ nested name specifier for the associated
6076 /// user-defined mapper.
6077 /// \param MapperIdInfoPtr The identifier of associated user-defined mapper.
6079 OpenMPClauseKind K, const OMPVarListLocTy &Locs,
6080 const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false,
6081 NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr,
6082 DeclarationNameInfo *MapperIdInfoPtr = nullptr)
6083 : OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc,
6084 Sizes.NumVars),
6085 NumUniqueDeclarations(Sizes.NumUniqueDeclarations),
6086 NumComponentLists(Sizes.NumComponentLists),
6087 NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) {
6088 if (MapperQualifierLocPtr)
6089 MapperQualifierLoc = *MapperQualifierLocPtr;
6090 if (MapperIdInfoPtr)
6091 MapperIdInfo = *MapperIdInfoPtr;
6092 }
6093
6094 /// Get the unique declarations that are in the trailing objects of the
6095 /// class.
6097 return static_cast<T *>(this)
6098 ->template getTrailingObjectsNonStrict<ValueDecl *>(
6099 NumUniqueDeclarations);
6100 }
6101
6102 /// Get the unique declarations that are in the trailing objects of the
6103 /// class.
6105 return static_cast<const T *>(this)
6106 ->template getTrailingObjectsNonStrict<ValueDecl *>(
6107 NumUniqueDeclarations);
6108 }
6109
6110 /// Set the unique declarations that are in the trailing objects of the
6111 /// class.
6113 assert(UDs.size() == NumUniqueDeclarations &&
6114 "Unexpected amount of unique declarations.");
6115 llvm::copy(UDs, getUniqueDeclsRef().begin());
6116 }
6117
6118 /// Get the number of lists per declaration that are in the trailing
6119 /// objects of the class.
6121 return static_cast<T *>(this)
6122 ->template getTrailingObjectsNonStrict<unsigned>(NumUniqueDeclarations);
6123 }
6124
6125 /// Get the number of lists per declaration that are in the trailing
6126 /// objects of the class.
6128 return static_cast<const T *>(this)
6129 ->template getTrailingObjectsNonStrict<unsigned>(NumUniqueDeclarations);
6130 }
6131
6132 /// Set the number of lists per declaration that are in the trailing
6133 /// objects of the class.
6135 assert(DNLs.size() == NumUniqueDeclarations &&
6136 "Unexpected amount of list numbers.");
6137 llvm::copy(DNLs, getDeclNumListsRef().begin());
6138 }
6139
6140 /// Get the cumulative component lists sizes that are in the trailing
6141 /// objects of the class. They are appended after the number of lists.
6144 static_cast<T *>(this)
6145 ->template getTrailingObjectsNonStrict<unsigned>() +
6146 NumUniqueDeclarations,
6147 NumComponentLists);
6148 }
6149
6150 /// Get the cumulative component lists sizes that are in the trailing
6151 /// objects of the class. They are appended after the number of lists.
6153 return ArrayRef<unsigned>(
6154 static_cast<const T *>(this)
6155 ->template getTrailingObjectsNonStrict<unsigned>() +
6156 NumUniqueDeclarations,
6157 NumComponentLists);
6158 }
6159
6160 /// Set the cumulative component lists sizes that are in the trailing
6161 /// objects of the class.
6163 assert(CLSs.size() == NumComponentLists &&
6164 "Unexpected amount of component lists.");
6165 llvm::copy(CLSs, getComponentListSizesRef().begin());
6166 }
6167
6168 /// Get the components that are in the trailing objects of the class.
6170 return static_cast<T *>(this)
6171 ->template getTrailingObjectsNonStrict<MappableComponent>(
6172 NumComponents);
6173 }
6174
6175 /// Get the components that are in the trailing objects of the class.
6177 return static_cast<const T *>(this)
6178 ->template getTrailingObjectsNonStrict<MappableComponent>(
6179 NumComponents);
6180 }
6181
6182 /// Set the components that are in the trailing objects of the class.
6183 /// This requires the list sizes so that it can also fill the original
6184 /// expressions, which are the first component of each list.
6186 ArrayRef<unsigned> CLSs) {
6187 assert(Components.size() == NumComponents &&
6188 "Unexpected amount of component lists.");
6189 assert(CLSs.size() == NumComponentLists &&
6190 "Unexpected amount of list sizes.");
6191 llvm::copy(Components, getComponentsRef().begin());
6192 }
6193
6194 /// Fill the clause information from the list of declarations and
6195 /// associated component lists.
6197 MappableExprComponentListsRef ComponentLists) {
6198 // Perform some checks to make sure the data sizes are consistent with the
6199 // information available when the clause was created.
6200 assert(getUniqueDeclarationsTotalNumber(Declarations) ==
6201 NumUniqueDeclarations &&
6202 "Unexpected number of mappable expression info entries!");
6203 assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
6204 "Unexpected total number of components!");
6205 assert(Declarations.size() == ComponentLists.size() &&
6206 "Declaration and component lists size is not consistent!");
6207 assert(Declarations.size() == NumComponentLists &&
6208 "Unexpected declaration and component lists size!");
6209
6210 // Organize the components by declaration and retrieve the original
6211 // expression. Original expressions are always the first component of the
6212 // mappable component list.
6213 llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
6214 ComponentListMap;
6215 {
6216 auto CI = ComponentLists.begin();
6217 for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
6218 ++DI, ++CI) {
6219 assert(!CI->empty() && "Invalid component list!");
6220 ComponentListMap[*DI].push_back(*CI);
6221 }
6222 }
6223
6224 // Iterators of the target storage.
6225 auto UniqueDeclarations = getUniqueDeclsRef();
6226 auto UDI = UniqueDeclarations.begin();
6227
6228 auto DeclNumLists = getDeclNumListsRef();
6229 auto DNLI = DeclNumLists.begin();
6230
6231 auto ComponentListSizes = getComponentListSizesRef();
6232 auto CLSI = ComponentListSizes.begin();
6233
6234 auto Components = getComponentsRef();
6235 auto CI = Components.begin();
6236
6237 // Variable to compute the accumulation of the number of components.
6238 unsigned PrevSize = 0u;
6239
6240 // Scan all the declarations and associated component lists.
6241 for (auto &M : ComponentListMap) {
6242 // The declaration.
6243 auto *D = M.first;
6244 // The component lists.
6245 auto CL = M.second;
6246
6247 // Initialize the entry.
6248 *UDI = D;
6249 ++UDI;
6250
6251 *DNLI = CL.size();
6252 ++DNLI;
6253
6254 // Obtain the cumulative sizes and concatenate all the components in the
6255 // reserved storage.
6256 for (auto C : CL) {
6257 // Accumulate with the previous size.
6258 PrevSize += C.size();
6259
6260 // Save the size.
6261 *CLSI = PrevSize;
6262 ++CLSI;
6263
6264 // Append components after the current components iterator.
6265 CI = llvm::copy(C, CI);
6266 }
6267 }
6268 }
6269
6270 /// Set the nested name specifier of associated user-defined mapper.
6272 MapperQualifierLoc = NNSL;
6273 }
6274
6275 /// Set the name of associated user-defined mapper.
6277 MapperIdInfo = MapperId;
6278 }
6279
6280 /// Get the user-defined mapper references that are in the trailing objects of
6281 /// the class.
6283 assert(SupportsMapper &&
6284 "Must be a clause that is possible to have user-defined mappers");
6286 static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
6289 }
6290
6291 /// Get the user-defined mappers references that are in the trailing objects
6292 /// of the class.
6294 assert(SupportsMapper &&
6295 "Must be a clause that is possible to have user-defined mappers");
6296 return ArrayRef<Expr *>(
6297 static_cast<const T *>(this)->template getTrailingObjects<Expr *>() +
6300 }
6301
6302 /// Set the user-defined mappers that are in the trailing objects of the
6303 /// class.
6305 assert(DMDs.size() == OMPVarListClause<T>::varlist_size() &&
6306 "Unexpected number of user-defined mappers.");
6307 assert(SupportsMapper &&
6308 "Must be a clause that is possible to have user-defined mappers");
6309 llvm::copy(DMDs, getUDMapperRefs().begin());
6310 }
6311
6312public:
6313 /// Return the number of unique base declarations in this clause.
6314 unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
6315
6316 /// Return the number of lists derived from the clause expressions.
6317 unsigned getTotalComponentListNum() const { return NumComponentLists; }
6318
6319 /// Return the total number of components in all lists derived from the
6320 /// clause.
6321 unsigned getTotalComponentsNum() const { return NumComponents; }
6322
6323 /// Gets the nested name specifier for associated user-defined mapper.
6325 return MapperQualifierLoc;
6326 }
6327
6328 /// Gets the name info for associated user-defined mapper.
6329 const DeclarationNameInfo &getMapperIdInfo() const { return MapperIdInfo; }
6330
6331 /// Iterator that browse the components by lists. It also allows
6332 /// browsing components of a single declaration.
6334 : public llvm::iterator_adaptor_base<
6335 const_component_lists_iterator,
6336 MappableExprComponentListRef::const_iterator,
6337 std::forward_iterator_tag, MappableComponent, ptrdiff_t,
6338 MappableComponent, MappableComponent> {
6339 // The declaration the iterator currently refers to.
6341
6342 // The list number associated with the current declaration.
6343 ArrayRef<unsigned>::iterator NumListsCur;
6344
6345 // Whether this clause is possible to have user-defined mappers associated.
6346 const bool SupportsMapper;
6347
6348 // The user-defined mapper associated with the current declaration.
6350
6351 // Remaining lists for the current declaration.
6352 unsigned RemainingLists = 0;
6353
6354 // The cumulative size of the previous list, or zero if there is no previous
6355 // list.
6356 unsigned PrevListSize = 0;
6357
6358 // The cumulative sizes of the current list - it will delimit the remaining
6359 // range of interest.
6362
6363 // Iterator to the end of the components storage.
6364 MappableExprComponentListRef::const_iterator End;
6365
6366 public:
6367 /// Construct an iterator that scans all lists.
6369 ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
6370 ArrayRef<unsigned> CumulativeListSizes,
6371 MappableExprComponentListRef Components, bool SupportsMapper,
6372 ArrayRef<Expr *> Mappers)
6373 : const_component_lists_iterator::iterator_adaptor_base(
6374 Components.begin()),
6375 DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
6376 SupportsMapper(SupportsMapper),
6377 ListSizeCur(CumulativeListSizes.begin()),
6378 ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
6379 assert(UniqueDecls.size() == DeclsListNum.size() &&
6380 "Inconsistent number of declarations and list sizes!");
6381 if (!DeclsListNum.empty())
6382 RemainingLists = *NumListsCur;
6383 if (SupportsMapper)
6384 MapperCur = Mappers.begin();
6385 }
6386
6387 /// Construct an iterator that scan lists for a given declaration \a
6388 /// Declaration.
6390 const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
6391 ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
6392 MappableExprComponentListRef Components, bool SupportsMapper,
6393 ArrayRef<Expr *> Mappers)
6394 : const_component_lists_iterator(UniqueDecls, DeclsListNum,
6395 CumulativeListSizes, Components,
6396 SupportsMapper, Mappers) {
6397 // Look for the desired declaration. While we are looking for it, we
6398 // update the state so that we know the component where a given list
6399 // starts.
6400 for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
6401 if (*DeclCur == Declaration)
6402 break;
6403
6404 assert(*NumListsCur > 0 && "No lists associated with declaration??");
6405
6406 // Skip the lists associated with the current declaration, but save the
6407 // last list size that was skipped.
6408 std::advance(ListSizeCur, *NumListsCur - 1);
6409 PrevListSize = *ListSizeCur;
6410 ++ListSizeCur;
6411
6412 if (SupportsMapper)
6413 ++MapperCur;
6414 }
6415
6416 // If we didn't find any declaration, advance the iterator to after the
6417 // last component and set remaining lists to zero.
6418 if (ListSizeCur == CumulativeListSizes.end()) {
6419 this->I = End;
6420 RemainingLists = 0u;
6421 return;
6422 }
6423
6424 // Set the remaining lists with the total number of lists of the current
6425 // declaration.
6426 RemainingLists = *NumListsCur;
6427
6428 // Adjust the list size end iterator to the end of the relevant range.
6429 ListSizeEnd = ListSizeCur;
6430 std::advance(ListSizeEnd, RemainingLists);
6431
6432 // Given that the list sizes are cumulative, the index of the component
6433 // that start the list is the size of the previous list.
6434 std::advance(this->I, PrevListSize);
6435 }
6436
6437 // Return the array with the current list. The sizes are cumulative, so the
6438 // array size is the difference between the current size and previous one.
6439 std::tuple<const ValueDecl *, MappableExprComponentListRef,
6440 const ValueDecl *>
6441 operator*() const {
6442 assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
6443 const ValueDecl *Mapper = nullptr;
6444 if (SupportsMapper && *MapperCur)
6445 Mapper = cast<ValueDecl>(cast<DeclRefExpr>(*MapperCur)->getDecl());
6446 return std::make_tuple(
6447 *DeclCur,
6448 MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize),
6449 Mapper);
6450 }
6451 std::tuple<const ValueDecl *, MappableExprComponentListRef,
6452 const ValueDecl *>
6453 operator->() const {
6454 return **this;
6455 }
6456
6457 // Skip the components of the current list.
6459 assert(ListSizeCur != ListSizeEnd && RemainingLists &&
6460 "Invalid iterator!");
6461
6462 // If we don't have more lists just skip all the components. Otherwise,
6463 // advance the iterator by the number of components in the current list.
6464 if (std::next(ListSizeCur) == ListSizeEnd) {
6465 this->I = End;
6466 RemainingLists = 0;
6467 } else {
6468 std::advance(this->I, *ListSizeCur - PrevListSize);
6469 PrevListSize = *ListSizeCur;
6470
6471 // We are done with a declaration, move to the next one.
6472 if (!(--RemainingLists)) {
6473 ++DeclCur;
6474 ++NumListsCur;
6475 RemainingLists = *NumListsCur;
6476 assert(RemainingLists && "No lists in the following declaration??");
6477 }
6478 }
6479
6480 ++ListSizeCur;
6481 if (SupportsMapper)
6482 ++MapperCur;
6483 return *this;
6484 }
6485 };
6486
6488 llvm::iterator_range<const_component_lists_iterator>;
6489
6490 /// Iterators for all component lists.
6507
6508 /// Iterators for component lists associated with the provided
6509 /// declaration.
6510 const_component_lists_iterator
6514 getComponentListSizesRef(), getComponentsRef(), SupportsMapper,
6515 SupportsMapper ? getUDMapperRefs() : ArrayRef<Expr *>());
6516 }
6523
6524 /// Iterators to access all the declarations, number of lists, list sizes, and
6525 /// components.
6527 using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>;
6528
6530 auto A = getUniqueDeclsRef();
6531 return const_all_decls_range(A.begin(), A.end());
6532 }
6533
6536 llvm::iterator_range<const_all_num_lists_iterator>;
6537
6539 auto A = getDeclNumListsRef();
6540 return const_all_num_lists_range(A.begin(), A.end());
6541 }
6542
6545 llvm::iterator_range<const_all_lists_sizes_iterator>;
6546
6548 auto A = getComponentListSizesRef();
6549 return const_all_lists_sizes_range(A.begin(), A.end());
6550 }
6551
6554 llvm::iterator_range<const_all_components_iterator>;
6555
6557 auto A = getComponentsRef();
6558 return const_all_components_range(A.begin(), A.end());
6559 }
6560
6563 using mapperlist_range = llvm::iterator_range<mapperlist_iterator>;
6565 llvm::iterator_range<mapperlist_const_iterator>;
6566
6570 return getUDMapperRefs().begin();
6571 }
6573 return getUDMapperRefs().end();
6574 }
6581};
6582
6583/// This represents clause 'map' in the '#pragma omp ...'
6584/// directives.
6585///
6586/// \code
6587/// #pragma omp target map(a,b)
6588/// \endcode
6589/// In this example directive '#pragma omp target' has clause 'map'
6590/// with the variables 'a' and 'b'.
6591class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
6592 private llvm::TrailingObjects<
6593 OMPMapClause, Expr *, ValueDecl *, unsigned,
6594 OMPClauseMappableExprCommon::MappableComponent> {
6595 friend class OMPClauseReader;
6596 friend OMPMappableExprListClause;
6597 friend OMPVarListClause;
6598 friend TrailingObjects;
6599
6600 /// Define the sizes of each trailing object array except the last one. This
6601 /// is required for TrailingObjects to work properly.
6602 size_t numTrailingObjects(OverloadToken<Expr *>) const {
6603 // There are varlist_size() of expressions, and varlist_size() of
6604 // user-defined mappers.
6605 return 2 * varlist_size() + 1;
6606 }
6607 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
6608 return getUniqueDeclarationsNum();
6609 }
6610 size_t numTrailingObjects(OverloadToken<unsigned>) const {
6612 }
6613
6614private:
6615 /// Map-type-modifiers for the 'map' clause.
6621
6622 /// Location of map-type-modifiers for the 'map' clause.
6623 SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers];
6624
6625 /// Map type for the 'map' clause.
6627
6628 /// Is this an implicit map type or not.
6629 bool MapTypeIsImplicit = false;
6630
6631 /// Location of the map type.
6632 SourceLocation MapLoc;
6633
6634 /// Colon location.
6635 SourceLocation ColonLoc;
6636
6637 /// Build a clause for \a NumVars listed expressions, \a
6638 /// NumUniqueDeclarations declarations, \a NumComponentLists total component
6639 /// lists, and \a NumComponents total expression components.
6640 ///
6641 /// \param MapModifiers Map-type-modifiers.
6642 /// \param MapModifiersLoc Locations of map-type-modifiers.
6643 /// \param MapperQualifierLoc C++ nested name specifier for the associated
6644 /// user-defined mapper.
6645 /// \param MapperIdInfo The identifier of associated user-defined mapper.
6646 /// \param MapType Map type.
6647 /// \param MapTypeIsImplicit Map type is inferred implicitly.
6648 /// \param MapLoc Location of the map type.
6649 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6650 /// StartLoc: starting location of the clause (the clause keyword); 2)
6651 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6652 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6653 /// NumVars: number of expressions listed in this clause; 2)
6654 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6655 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6656 /// NumComponents: total number of expression components in the clause.
6657 explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers,
6658 ArrayRef<SourceLocation> MapModifiersLoc,
6659 NestedNameSpecifierLoc MapperQualifierLoc,
6660 DeclarationNameInfo MapperIdInfo,
6661 OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
6662 SourceLocation MapLoc, const OMPVarListLocTy &Locs,
6663 const OMPMappableExprListSizeTy &Sizes)
6664 : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes,
6665 /*SupportsMapper=*/true, &MapperQualifierLoc,
6666 &MapperIdInfo),
6667 MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {
6668 assert(std::size(MapTypeModifiers) == MapModifiers.size() &&
6669 "Unexpected number of map type modifiers.");
6670 llvm::copy(MapModifiers, std::begin(MapTypeModifiers));
6671
6672 assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() &&
6673 "Unexpected number of map type modifier locations.");
6674 llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc));
6675 }
6676
6677 /// Build an empty clause.
6678 ///
6679 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6680 /// NumVars: number of expressions listed in this clause; 2)
6681 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6682 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6683 /// NumComponents: total number of expression components in the clause.
6684 explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes)
6685 : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes,
6686 /*SupportsMapper=*/true) {}
6687
6688 /// Set map-type-modifier for the clause.
6689 ///
6690 /// \param I index for map-type-modifier.
6691 /// \param T map-type-modifier for the clause.
6692 void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) {
6693 assert(I < NumberOfOMPMapClauseModifiers &&
6694 "Unexpected index to store map type modifier, exceeds array size.");
6695 MapTypeModifiers[I] = T;
6696 }
6697
6698 /// Set location for the map-type-modifier.
6699 ///
6700 /// \param I index for map-type-modifier location.
6701 /// \param TLoc map-type-modifier location.
6702 void setMapTypeModifierLoc(unsigned I, SourceLocation TLoc) {
6703 assert(I < NumberOfOMPMapClauseModifiers &&
6704 "Index to store map type modifier location exceeds array size.");
6705 MapTypeModifiersLoc[I] = TLoc;
6706 }
6707
6708 /// Set type for the clause.
6709 ///
6710 /// \param T Type for the clause.
6711 void setMapType(OpenMPMapClauseKind T) { MapType = T; }
6712
6713 /// Set type location.
6714 ///
6715 /// \param TLoc Type location.
6716 void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
6717
6718 /// Set colon location.
6719 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
6720
6721 /// Set iterator modifier.
6722 void setIteratorModifier(Expr *IteratorModifier) {
6723 getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier;
6724 }
6725
6726public:
6727 /// Creates clause with a list of variables \a VL.
6728 ///
6729 /// \param C AST context.
6730 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6731 /// StartLoc: starting location of the clause (the clause keyword); 2)
6732 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6733 /// \param Vars The original expression used in the clause.
6734 /// \param Declarations Declarations used in the clause.
6735 /// \param ComponentLists Component lists used in the clause.
6736 /// \param UDMapperRefs References to user-defined mappers associated with
6737 /// expressions used in the clause.
6738 /// \param IteratorModifier Iterator modifier.
6739 /// \param MapModifiers Map-type-modifiers.
6740 /// \param MapModifiersLoc Location of map-type-modifiers.
6741 /// \param UDMQualifierLoc C++ nested name specifier for the associated
6742 /// user-defined mapper.
6743 /// \param MapperId The identifier of associated user-defined mapper.
6744 /// \param Type Map type.
6745 /// \param TypeIsImplicit Map type is inferred implicitly.
6746 /// \param TypeLoc Location of the map type.
6747 static OMPMapClause *
6748 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
6749 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
6750 MappableExprComponentListsRef ComponentLists,
6751 ArrayRef<Expr *> UDMapperRefs, Expr *IteratorModifier,
6752 ArrayRef<OpenMPMapModifierKind> MapModifiers,
6753 ArrayRef<SourceLocation> MapModifiersLoc,
6754 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
6755 OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc);
6756
6757 /// Creates an empty clause with the place for \a NumVars original
6758 /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
6759 /// lists, and \a NumComponents expression components.
6760 ///
6761 /// \param C AST context.
6762 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6763 /// NumVars: number of expressions listed in this clause; 2)
6764 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6765 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6766 /// NumComponents: total number of expression components in the clause.
6767 static OMPMapClause *CreateEmpty(const ASTContext &C,
6768 const OMPMappableExprListSizeTy &Sizes);
6769
6770 /// Fetches Expr * of iterator modifier.
6772 return getTrailingObjects<Expr *>()[2 * varlist_size()];
6773 }
6774
6775 /// Fetches mapping kind for the clause.
6776 OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
6777
6778 /// Is this an implicit map type?
6779 /// We have to capture 'IsMapTypeImplicit' from the parser for more
6780 /// informative error messages. It helps distinguish map(r) from
6781 /// map(tofrom: r), which is important to print more helpful error
6782 /// messages for some target directives.
6783 bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
6784
6785 /// Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
6786 ///
6787 /// \param Cnt index for map-type-modifier.
6788 OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY {
6789 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6790 "Requested modifier exceeds the total number of modifiers.");
6791 return MapTypeModifiers[Cnt];
6792 }
6793
6794 /// Fetches the map-type-modifier location at 'Cnt' index of array of
6795 /// modifiers' locations.
6796 ///
6797 /// \param Cnt index for map-type-modifier location.
6798 SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY {
6799 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6800 "Requested modifier location exceeds total number of modifiers.");
6801 return MapTypeModifiersLoc[Cnt];
6802 }
6803
6804 /// Fetches ArrayRef of map-type-modifiers.
6806 return MapTypeModifiers;
6807 }
6808
6809 /// Fetches ArrayRef of location of map-type-modifiers.
6811 return MapTypeModifiersLoc;
6812 }
6813
6814 /// Fetches location of clause mapping kind.
6815 SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
6816
6817 /// Get colon location.
6818 SourceLocation getColonLoc() const { return ColonLoc; }
6819
6821 return child_range(
6822 reinterpret_cast<Stmt **>(varlist_begin()),
6823 reinterpret_cast<Stmt **>(varlist_end()));
6824 }
6825
6827 auto Children = const_cast<OMPMapClause *>(this)->children();
6828 return const_child_range(Children.begin(), Children.end());
6829 }
6830
6832 if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom)
6833 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6834 reinterpret_cast<Stmt **>(varlist_end()));
6836 }
6838 auto Children = const_cast<OMPMapClause *>(this)->used_children();
6839 return const_child_range(Children.begin(), Children.end());
6840 }
6841
6842
6843 static bool classof(const OMPClause *T) {
6844 return T->getClauseKind() == llvm::omp::OMPC_map;
6845 }
6846};
6847
6848/// This represents 'num_teams' clause in the '#pragma omp ...'
6849/// directive.
6850///
6851/// \code
6852/// #pragma omp teams num_teams(n)
6853/// \endcode
6854/// In this example directive '#pragma omp teams' has clause 'num_teams'
6855/// with single expression 'n'.
6856///
6857/// When 'ompx_bare' clause exists on a 'target' directive, 'num_teams' clause
6858/// can accept up to three expressions.
6859///
6860/// \code
6861/// #pragma omp target teams ompx_bare num_teams(x, y, z)
6862/// \endcode
6863class OMPNumTeamsClause final
6864 : public OMPVarListClause<OMPNumTeamsClause>,
6865 public OMPClauseWithPreInit,
6866 private llvm::TrailingObjects<OMPNumTeamsClause, Expr *> {
6867 friend OMPVarListClause;
6868 friend TrailingObjects;
6869
6870 /// Location of '('.
6871 SourceLocation LParenLoc;
6872
6873 OMPNumTeamsClause(const ASTContext &C, SourceLocation StartLoc,
6874 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
6875 : OMPVarListClause(llvm::omp::OMPC_num_teams, StartLoc, LParenLoc, EndLoc,
6876 N),
6877 OMPClauseWithPreInit(this) {}
6878
6879 /// Build an empty clause.
6880 OMPNumTeamsClause(unsigned N)
6881 : OMPVarListClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6883 OMPClauseWithPreInit(this) {}
6884
6885public:
6886 /// Creates clause with a list of variables \a VL.
6887 ///
6888 /// \param C AST context.
6889 /// \param StartLoc Starting location of the clause.
6890 /// \param LParenLoc Location of '('.
6891 /// \param EndLoc Ending location of the clause.
6892 /// \param VL List of references to the variables.
6893 /// \param PreInit
6894 static OMPNumTeamsClause *
6895 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6896 SourceLocation StartLoc, SourceLocation LParenLoc,
6897 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6898
6899 /// Creates an empty clause with \a N variables.
6900 ///
6901 /// \param C AST context.
6902 /// \param N The number of variables.
6903 static OMPNumTeamsClause *CreateEmpty(const ASTContext &C, unsigned N);
6904
6905 /// Sets the location of '('.
6906 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6907
6908 /// Returns the location of '('.
6909 SourceLocation getLParenLoc() const { return LParenLoc; }
6910
6911 /// Return NumTeams expressions.
6913
6914 /// Return NumTeams expressions.
6916 return const_cast<OMPNumTeamsClause *>(this)->getNumTeams();
6917 }
6918
6920 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6921 reinterpret_cast<Stmt **>(varlist_end()));
6922 }
6923
6925 auto Children = const_cast<OMPNumTeamsClause *>(this)->children();
6926 return const_child_range(Children.begin(), Children.end());
6927 }
6928
6935
6936 static bool classof(const OMPClause *T) {
6937 return T->getClauseKind() == llvm::omp::OMPC_num_teams;
6938 }
6939};
6940
6941/// This represents 'thread_limit' clause in the '#pragma omp ...'
6942/// directive.
6943///
6944/// \code
6945/// #pragma omp teams thread_limit(n)
6946/// \endcode
6947/// In this example directive '#pragma omp teams' has clause 'thread_limit'
6948/// with single expression 'n'.
6949///
6950/// When 'ompx_bare' clause exists on a 'target' directive, 'thread_limit'
6951/// clause can accept up to three expressions.
6952///
6953/// \code
6954/// #pragma omp target teams ompx_bare thread_limit(x, y, z)
6955/// \endcode
6956class OMPThreadLimitClause final
6957 : public OMPVarListClause<OMPThreadLimitClause>,
6958 public OMPClauseWithPreInit,
6959 private llvm::TrailingObjects<OMPThreadLimitClause, Expr *> {
6960 friend OMPVarListClause;
6961 friend TrailingObjects;
6962
6963 /// Location of '('.
6964 SourceLocation LParenLoc;
6965
6966 OMPThreadLimitClause(const ASTContext &C, SourceLocation StartLoc,
6967 SourceLocation LParenLoc, SourceLocation EndLoc,
6968 unsigned N)
6969 : OMPVarListClause(llvm::omp::OMPC_thread_limit, StartLoc, LParenLoc,
6970 EndLoc, N),
6971 OMPClauseWithPreInit(this) {}
6972
6973 /// Build an empty clause.
6974 OMPThreadLimitClause(unsigned N)
6975 : OMPVarListClause(llvm::omp::OMPC_thread_limit, SourceLocation(),
6977 OMPClauseWithPreInit(this) {}
6978
6979public:
6980 /// Creates clause with a list of variables \a VL.
6981 ///
6982 /// \param C AST context.
6983 /// \param StartLoc Starting location of the clause.
6984 /// \param LParenLoc Location of '('.
6985 /// \param EndLoc Ending location of the clause.
6986 /// \param VL List of references to the variables.
6987 /// \param PreInit
6988 static OMPThreadLimitClause *
6989 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6990 SourceLocation StartLoc, SourceLocation LParenLoc,
6991 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6992
6993 /// Creates an empty clause with \a N variables.
6994 ///
6995 /// \param C AST context.
6996 /// \param N The number of variables.
6997 static OMPThreadLimitClause *CreateEmpty(const ASTContext &C, unsigned N);
6998
6999 /// Sets the location of '('.
7000 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7001
7002 /// Returns the location of '('.
7003 SourceLocation getLParenLoc() const { return LParenLoc; }
7004
7005 /// Return ThreadLimit expressions.
7007
7008 /// Return ThreadLimit expressions.
7010 return const_cast<OMPThreadLimitClause *>(this)->getThreadLimit();
7011 }
7012
7014 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7015 reinterpret_cast<Stmt **>(varlist_end()));
7016 }
7017
7019 auto Children = const_cast<OMPThreadLimitClause *>(this)->children();
7020 return const_child_range(Children.begin(), Children.end());
7021 }
7022
7029
7030 static bool classof(const OMPClause *T) {
7031 return T->getClauseKind() == llvm::omp::OMPC_thread_limit;
7032 }
7033};
7034
7035/// This represents 'priority' clause in the '#pragma omp ...'
7036/// directive.
7037///
7038/// \code
7039/// #pragma omp task priority(n)
7040/// \endcode
7041/// In this example directive '#pragma omp teams' has clause 'priority' with
7042/// single expression 'n'.
7044 friend class OMPClauseReader;
7045
7046 /// Location of '('.
7047 SourceLocation LParenLoc;
7048
7049 /// Priority number.
7050 Stmt *Priority = nullptr;
7051
7052 /// Set the Priority number.
7053 ///
7054 /// \param E Priority number.
7055 void setPriority(Expr *E) { Priority = E; }
7056
7057public:
7058 /// Build 'priority' clause.
7059 ///
7060 /// \param Priority Expression associated with this clause.
7061 /// \param HelperPriority Helper priority for the construct.
7062 /// \param CaptureRegion Innermost OpenMP region where expressions in this
7063 /// clause must be captured.
7064 /// \param StartLoc Starting location of the clause.
7065 /// \param LParenLoc Location of '('.
7066 /// \param EndLoc Ending location of the clause.
7067 OMPPriorityClause(Expr *Priority, Stmt *HelperPriority,
7068 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
7069 SourceLocation LParenLoc, SourceLocation EndLoc)
7070 : OMPClause(llvm::omp::OMPC_priority, StartLoc, EndLoc),
7071 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Priority(Priority) {
7072 setPreInitStmt(HelperPriority, CaptureRegion);
7073 }
7074
7075 /// Build an empty clause.
7077 : OMPClause(llvm::omp::OMPC_priority, SourceLocation(), SourceLocation()),
7078 OMPClauseWithPreInit(this) {}
7079
7080 /// Sets the location of '('.
7081 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7082
7083 /// Returns the location of '('.
7084 SourceLocation getLParenLoc() const { return LParenLoc; }
7085
7086 /// Return Priority number.
7087 Expr *getPriority() { return cast<Expr>(Priority); }
7088
7089 /// Return Priority number.
7090 Expr *getPriority() const { return cast<Expr>(Priority); }
7091
7092 child_range children() { return child_range(&Priority, &Priority + 1); }
7093
7095 return const_child_range(&Priority, &Priority + 1);
7096 }
7097
7100 auto Children = const_cast<OMPPriorityClause *>(this)->used_children();
7101 return const_child_range(Children.begin(), Children.end());
7102 }
7103
7104 static bool classof(const OMPClause *T) {
7105 return T->getClauseKind() == llvm::omp::OMPC_priority;
7106 }
7107};
7108
7109/// This represents 'grainsize' clause in the '#pragma omp ...'
7110/// directive.
7111///
7112/// \code
7113/// #pragma omp taskloop grainsize(4)
7114/// \endcode
7115/// In this example directive '#pragma omp taskloop' has clause 'grainsize'
7116/// with single expression '4'.
7118 friend class OMPClauseReader;
7119
7120 /// Location of '('.
7121 SourceLocation LParenLoc;
7122
7123 /// Modifiers for 'grainsize' clause.
7125
7126 /// Location of the modifier.
7127 SourceLocation ModifierLoc;
7128
7129 /// Safe iteration space distance.
7130 Stmt *Grainsize = nullptr;
7131
7132 /// Set safelen.
7133 void setGrainsize(Expr *Size) { Grainsize = Size; }
7134
7135 /// Sets modifier.
7136 void setModifier(OpenMPGrainsizeClauseModifier M) { Modifier = M; }
7137
7138 /// Sets modifier location.
7139 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
7140
7141public:
7142 /// Build 'grainsize' clause.
7143 ///
7144 /// \param Modifier Clause modifier.
7145 /// \param Size Expression associated with this clause.
7146 /// \param HelperSize Helper grainsize for the construct.
7147 /// \param CaptureRegion Innermost OpenMP region where expressions in this
7148 /// clause must be captured.
7149 /// \param StartLoc Starting location of the clause.
7150 /// \param ModifierLoc Modifier location.
7151 /// \param LParenLoc Location of '('.
7152 /// \param EndLoc Ending location of the clause.
7154 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
7155 SourceLocation StartLoc, SourceLocation LParenLoc,
7156 SourceLocation ModifierLoc, SourceLocation EndLoc)
7157 : OMPClause(llvm::omp::OMPC_grainsize, StartLoc, EndLoc),
7158 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
7159 ModifierLoc(ModifierLoc), Grainsize(Size) {
7160 setPreInitStmt(HelperSize, CaptureRegion);
7161 }
7162
7163 /// Build an empty clause.
7165 : OMPClause(llvm::omp::OMPC_grainsize, SourceLocation(),
7166 SourceLocation()),
7167 OMPClauseWithPreInit(this) {}
7168
7169 /// Sets the location of '('.
7170 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7171
7172 /// Returns the location of '('.
7173 SourceLocation getLParenLoc() const { return LParenLoc; }
7174
7175 /// Return safe iteration space distance.
7176 Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
7177
7178 /// Gets modifier.
7179 OpenMPGrainsizeClauseModifier getModifier() const { return Modifier; }
7180
7181 /// Gets modifier location.
7182 SourceLocation getModifierLoc() const { return ModifierLoc; }
7183
7184 child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
7185
7187 return const_child_range(&Grainsize, &Grainsize + 1);
7188 }
7189
7192 auto Children = const_cast<OMPGrainsizeClause *>(this)->used_children();
7193 return const_child_range(Children.begin(), Children.end());
7194 }
7195
7196 static bool classof(const OMPClause *T) {
7197 return T->getClauseKind() == llvm::omp::OMPC_grainsize;
7198 }
7199};
7200
7201/// This represents 'nogroup' clause in the '#pragma omp ...' directive.
7202///
7203/// \code
7204/// #pragma omp taskloop nogroup
7205/// \endcode
7206/// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
7208public:
7209 /// Build 'nogroup' clause.
7210 ///
7211 /// \param StartLoc Starting location of the clause.
7212 /// \param EndLoc Ending location of the clause.
7214 : OMPClause(llvm::omp::OMPC_nogroup, StartLoc, EndLoc) {}
7215
7216 /// Build an empty clause.
7218 : OMPClause(llvm::omp::OMPC_nogroup, SourceLocation(), SourceLocation()) {
7219 }
7220
7224
7228
7235
7236 static bool classof(const OMPClause *T) {
7237 return T->getClauseKind() == llvm::omp::OMPC_nogroup;
7238 }
7239};
7240
7241/// This represents 'num_tasks' clause in the '#pragma omp ...'
7242/// directive.
7243///
7244/// \code
7245/// #pragma omp taskloop num_tasks(4)
7246/// \endcode
7247/// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
7248/// with single expression '4'.
7250 friend class OMPClauseReader;
7251
7252 /// Location of '('.
7253 SourceLocation LParenLoc;
7254
7255 /// Modifiers for 'num_tasks' clause.
7257
7258 /// Location of the modifier.
7259 SourceLocation ModifierLoc;
7260
7261 /// Safe iteration space distance.
7262 Stmt *NumTasks = nullptr;
7263
7264 /// Set safelen.
7265 void setNumTasks(Expr *Size) { NumTasks = Size; }
7266
7267 /// Sets modifier.
7268 void setModifier(OpenMPNumTasksClauseModifier M) { Modifier = M; }
7269
7270 /// Sets modifier location.
7271 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
7272
7273public:
7274 /// Build 'num_tasks' clause.
7275 ///
7276 /// \param Modifier Clause modifier.
7277 /// \param Size Expression associated with this clause.
7278 /// \param HelperSize Helper grainsize for the construct.
7279 /// \param CaptureRegion Innermost OpenMP region where expressions in this
7280 /// clause must be captured.
7281 /// \param StartLoc Starting location of the clause.
7282 /// \param EndLoc Ending location of the clause.
7283 /// \param ModifierLoc Modifier location.
7284 /// \param LParenLoc Location of '('.
7286 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
7287 SourceLocation StartLoc, SourceLocation LParenLoc,
7288 SourceLocation ModifierLoc, SourceLocation EndLoc)
7289 : OMPClause(llvm::omp::OMPC_num_tasks, StartLoc, EndLoc),
7290 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
7291 ModifierLoc(ModifierLoc), NumTasks(Size) {
7292 setPreInitStmt(HelperSize, CaptureRegion);
7293 }
7294
7295 /// Build an empty clause.
7297 : OMPClause(llvm::omp::OMPC_num_tasks, SourceLocation(),
7298 SourceLocation()),
7299 OMPClauseWithPreInit(this) {}
7300
7301 /// Sets the location of '('.
7302 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7303
7304 /// Returns the location of '('.
7305 SourceLocation getLParenLoc() const { return LParenLoc; }
7306
7307 /// Return safe iteration space distance.
7308 Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
7309
7310 /// Gets modifier.
7311 OpenMPNumTasksClauseModifier getModifier() const { return Modifier; }
7312
7313 /// Gets modifier location.
7314 SourceLocation getModifierLoc() const { return ModifierLoc; }
7315
7316 child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
7317
7319 return const_child_range(&NumTasks, &NumTasks + 1);
7320 }
7321
7324 auto Children = const_cast<OMPNumTasksClause *>(this)->used_children();
7325 return const_child_range(Children.begin(), Children.end());
7326 }
7327
7328 static bool classof(const OMPClause *T) {
7329 return T->getClauseKind() == llvm::omp::OMPC_num_tasks;
7330 }
7331};
7332
7333/// This represents 'hint' clause in the '#pragma omp ...' directive.
7334///
7335/// \code
7336/// #pragma omp critical (name) hint(6)
7337/// \endcode
7338/// In this example directive '#pragma omp critical' has name 'name' and clause
7339/// 'hint' with argument '6'.
7340class OMPHintClause : public OMPClause {
7341 friend class OMPClauseReader;
7342
7343 /// Location of '('.
7344 SourceLocation LParenLoc;
7345
7346 /// Hint expression of the 'hint' clause.
7347 Stmt *Hint = nullptr;
7348
7349 /// Set hint expression.
7350 void setHint(Expr *H) { Hint = H; }
7351
7352public:
7353 /// Build 'hint' clause with expression \a Hint.
7354 ///
7355 /// \param Hint Hint expression.
7356 /// \param StartLoc Starting location of the clause.
7357 /// \param LParenLoc Location of '('.
7358 /// \param EndLoc Ending location of the clause.
7360 SourceLocation EndLoc)
7361 : OMPClause(llvm::omp::OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
7362 Hint(Hint) {}
7363
7364 /// Build an empty clause.
7366 : OMPClause(llvm::omp::OMPC_hint, SourceLocation(), SourceLocation()) {}
7367
7368 /// Sets the location of '('.
7369 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7370
7371 /// Returns the location of '('.
7372 SourceLocation getLParenLoc() const { return LParenLoc; }
7373
7374 /// Returns number of threads.
7375 Expr *getHint() const { return cast_or_null<Expr>(Hint); }
7376
7377 child_range children() { return child_range(&Hint, &Hint + 1); }
7378
7380 return const_child_range(&Hint, &Hint + 1);
7381 }
7382
7389
7390 static bool classof(const OMPClause *T) {
7391 return T->getClauseKind() == llvm::omp::OMPC_hint;
7392 }
7393};
7394
7395/// This represents 'dist_schedule' clause in the '#pragma omp ...'
7396/// directive.
7397///
7398/// \code
7399/// #pragma omp distribute dist_schedule(static, 3)
7400/// \endcode
7401/// In this example directive '#pragma omp distribute' has 'dist_schedule'
7402/// clause with arguments 'static' and '3'.
7404 friend class OMPClauseReader;
7405
7406 /// Location of '('.
7407 SourceLocation LParenLoc;
7408
7409 /// A kind of the 'schedule' clause.
7411
7412 /// Start location of the schedule kind in source code.
7413 SourceLocation KindLoc;
7414
7415 /// Location of ',' (if any).
7416 SourceLocation CommaLoc;
7417
7418 /// Chunk size.
7419 Expr *ChunkSize = nullptr;
7420
7421 /// Set schedule kind.
7422 ///
7423 /// \param K Schedule kind.
7424 void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
7425
7426 /// Sets the location of '('.
7427 ///
7428 /// \param Loc Location of '('.
7429 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7430
7431 /// Set schedule kind start location.
7432 ///
7433 /// \param KLoc Schedule kind location.
7434 void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
7435
7436 /// Set location of ','.
7437 ///
7438 /// \param Loc Location of ','.
7439 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
7440
7441 /// Set chunk size.
7442 ///
7443 /// \param E Chunk size.
7444 void setChunkSize(Expr *E) { ChunkSize = E; }
7445
7446public:
7447 /// Build 'dist_schedule' clause with schedule kind \a Kind and chunk
7448 /// size expression \a ChunkSize.
7449 ///
7450 /// \param StartLoc Starting location of the clause.
7451 /// \param LParenLoc Location of '('.
7452 /// \param KLoc Starting location of the argument.
7453 /// \param CommaLoc Location of ','.
7454 /// \param EndLoc Ending location of the clause.
7455 /// \param Kind DistSchedule kind.
7456 /// \param ChunkSize Chunk size.
7457 /// \param HelperChunkSize Helper chunk size for combined directives.
7459 SourceLocation KLoc, SourceLocation CommaLoc,
7460 SourceLocation EndLoc,
7461 OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
7462 Stmt *HelperChunkSize)
7463 : OMPClause(llvm::omp::OMPC_dist_schedule, StartLoc, EndLoc),
7464 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
7465 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
7466 setPreInitStmt(HelperChunkSize);
7467 }
7468
7469 /// Build an empty clause.
7471 : OMPClause(llvm::omp::OMPC_dist_schedule, SourceLocation(),
7472 SourceLocation()),
7473 OMPClauseWithPreInit(this) {}
7474
7475 /// Get kind of the clause.
7477
7478 /// Get location of '('.
7479 SourceLocation getLParenLoc() { return LParenLoc; }
7480
7481 /// Get kind location.
7483
7484 /// Get location of ','.
7485 SourceLocation getCommaLoc() { return CommaLoc; }
7486
7487 /// Get chunk size.
7488 Expr *getChunkSize() { return ChunkSize; }
7489
7490 /// Get chunk size.
7491 const Expr *getChunkSize() const { return ChunkSize; }
7492
7494 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
7495 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
7496 }
7497
7499 auto Children = const_cast<OMPDistScheduleClause *>(this)->children();
7500 return const_child_range(Children.begin(), Children.end());
7501 }
7502
7509
7510 static bool classof(const OMPClause *T) {
7511 return T->getClauseKind() == llvm::omp::OMPC_dist_schedule;
7512 }
7513};
7514
7515/// This represents 'defaultmap' clause in the '#pragma omp ...' directive.
7516///
7517/// \code
7518/// #pragma omp target defaultmap(tofrom: scalar)
7519/// \endcode
7520/// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
7521/// 'scalar' with modifier 'tofrom'.
7523 friend class OMPClauseReader;
7524
7525 /// Location of '('.
7526 SourceLocation LParenLoc;
7527
7528 /// Modifiers for 'defaultmap' clause.
7530
7531 /// Locations of modifiers.
7532 SourceLocation ModifierLoc;
7533
7534 /// A kind of the 'defaultmap' clause.
7536
7537 /// Start location of the defaultmap kind in source code.
7538 SourceLocation KindLoc;
7539
7540 /// Set defaultmap kind.
7541 ///
7542 /// \param K Defaultmap kind.
7543 void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
7544
7545 /// Set the defaultmap modifier.
7546 ///
7547 /// \param M Defaultmap modifier.
7548 void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
7549 Modifier = M;
7550 }
7551
7552 /// Set location of the defaultmap modifier.
7553 void setDefaultmapModifierLoc(SourceLocation Loc) {
7554 ModifierLoc = Loc;
7555 }
7556
7557 /// Sets the location of '('.
7558 ///
7559 /// \param Loc Location of '('.
7560 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7561
7562 /// Set defaultmap kind start location.
7563 ///
7564 /// \param KLoc Defaultmap kind location.
7565 void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
7566
7567public:
7568 /// Build 'defaultmap' clause with defaultmap kind \a Kind
7569 ///
7570 /// \param StartLoc Starting location of the clause.
7571 /// \param LParenLoc Location of '('.
7572 /// \param KLoc Starting location of the argument.
7573 /// \param EndLoc Ending location of the clause.
7574 /// \param Kind Defaultmap kind.
7575 /// \param M The modifier applied to 'defaultmap' clause.
7576 /// \param MLoc Location of the modifier
7578 SourceLocation MLoc, SourceLocation KLoc,
7581 : OMPClause(llvm::omp::OMPC_defaultmap, StartLoc, EndLoc),
7582 LParenLoc(LParenLoc), Modifier(M), ModifierLoc(MLoc), Kind(Kind),
7583 KindLoc(KLoc) {}
7584
7585 /// Build an empty clause.
7587 : OMPClause(llvm::omp::OMPC_defaultmap, SourceLocation(),
7588 SourceLocation()) {}
7589
7590 /// Get kind of the clause.
7592
7593 /// Get the modifier of the clause.
7595 return Modifier;
7596 }
7597
7598 /// Get location of '('.
7599 SourceLocation getLParenLoc() { return LParenLoc; }
7600
7601 /// Get kind location.
7603
7604 /// Get the modifier location.
7606 return ModifierLoc;
7607 }
7608
7612
7616
7623
7624 static bool classof(const OMPClause *T) {
7625 return T->getClauseKind() == llvm::omp::OMPC_defaultmap;
7626 }
7627};
7628
7629/// This represents clause 'to' in the '#pragma omp ...'
7630/// directives.
7631///
7632/// \code
7633/// #pragma omp target update to(a,b)
7634/// \endcode
7635/// In this example directive '#pragma omp target update' has clause 'to'
7636/// with the variables 'a' and 'b'.
7637class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
7638 private llvm::TrailingObjects<
7639 OMPToClause, Expr *, ValueDecl *, unsigned,
7640 OMPClauseMappableExprCommon::MappableComponent> {
7641 friend class OMPClauseReader;
7642 friend OMPMappableExprListClause;
7643 friend OMPVarListClause;
7644 friend TrailingObjects;
7645
7646 /// Motion-modifiers for the 'to' clause.
7649
7650 /// Location of motion-modifiers for the 'to' clause.
7651 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7652
7653 /// Colon location.
7654 SourceLocation ColonLoc;
7655
7656 /// Build clause with number of variables \a NumVars.
7657 ///
7658 /// \param TheMotionModifiers Motion-modifiers.
7659 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7660 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7661 /// user-defined mapper.
7662 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7663 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7664 /// StartLoc: starting location of the clause (the clause keyword); 2)
7665 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7666 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7667 /// NumVars: number of expressions listed in this clause; 2)
7668 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7669 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7670 /// NumComponents: total number of expression components in the clause.
7671 explicit OMPToClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7672 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7673 NestedNameSpecifierLoc MapperQualifierLoc,
7674 DeclarationNameInfo MapperIdInfo,
7675 const OMPVarListLocTy &Locs,
7676 const OMPMappableExprListSizeTy &Sizes)
7677 : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
7678 /*SupportsMapper=*/true, &MapperQualifierLoc,
7679 &MapperIdInfo) {
7680 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7681 "Unexpected number of motion modifiers.");
7682 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7683
7684 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7685 "Unexpected number of motion modifier locations.");
7686 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7687 }
7688
7689 /// Build an empty clause.
7690 ///
7691 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7692 /// NumVars: number of expressions listed in this clause; 2)
7693 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7694 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7695 /// NumComponents: total number of expression components in the clause.
7696 explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes)
7697 : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
7698 /*SupportsMapper=*/true) {}
7699
7700 /// Set motion-modifier for the clause.
7701 ///
7702 /// \param I index for motion-modifier.
7703 /// \param T motion-modifier for the clause.
7704 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7705 assert(I < NumberOfOMPMotionModifiers &&
7706 "Unexpected index to store motion modifier, exceeds array size.");
7707 MotionModifiers[I] = T;
7708 }
7709
7710 /// Set location for the motion-modifier.
7711 ///
7712 /// \param I index for motion-modifier location.
7713 /// \param TLoc motion-modifier location.
7714 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7715 assert(I < NumberOfOMPMotionModifiers &&
7716 "Index to store motion modifier location exceeds array size.");
7717 MotionModifiersLoc[I] = TLoc;
7718 }
7719
7720 /// Set colon location.
7721 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7722
7723 /// Define the sizes of each trailing object array except the last one. This
7724 /// is required for TrailingObjects to work properly.
7725 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7726 // There are varlist_size() of expressions, and varlist_size() of
7727 // user-defined mappers.
7728 return 2 * varlist_size();
7729 }
7730 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7731 return getUniqueDeclarationsNum();
7732 }
7733 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7735 }
7736
7737public:
7738 /// Creates clause with a list of variables \a Vars.
7739 ///
7740 /// \param C AST context.
7741 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7742 /// StartLoc: starting location of the clause (the clause keyword); 2)
7743 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7744 /// \param Vars The original expression used in the clause.
7745 /// \param Declarations Declarations used in the clause.
7746 /// \param ComponentLists Component lists used in the clause.
7747 /// \param MotionModifiers Motion-modifiers.
7748 /// \param MotionModifiersLoc Location of motion-modifiers.
7749 /// \param UDMapperRefs References to user-defined mappers associated with
7750 /// expressions used in the clause.
7751 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7752 /// user-defined mapper.
7753 /// \param MapperId The identifier of associated user-defined mapper.
7754 static OMPToClause *Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7755 ArrayRef<Expr *> Vars,
7756 ArrayRef<ValueDecl *> Declarations,
7757 MappableExprComponentListsRef ComponentLists,
7758 ArrayRef<Expr *> UDMapperRefs,
7759 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7760 ArrayRef<SourceLocation> MotionModifiersLoc,
7761 NestedNameSpecifierLoc UDMQualifierLoc,
7762 DeclarationNameInfo MapperId);
7763
7764 /// Creates an empty clause with the place for \a NumVars variables.
7765 ///
7766 /// \param C AST context.
7767 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7768 /// NumVars: number of expressions listed in this clause; 2)
7769 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7770 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7771 /// NumComponents: total number of expression components in the clause.
7772 static OMPToClause *CreateEmpty(const ASTContext &C,
7773 const OMPMappableExprListSizeTy &Sizes);
7774
7775 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7776 ///
7777 /// \param Cnt index for motion-modifier.
7778 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7779 assert(Cnt < NumberOfOMPMotionModifiers &&
7780 "Requested modifier exceeds the total number of modifiers.");
7781 return MotionModifiers[Cnt];
7782 }
7783
7784 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7785 /// locations.
7786 ///
7787 /// \param Cnt index for motion-modifier location.
7788 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7789 assert(Cnt < NumberOfOMPMotionModifiers &&
7790 "Requested modifier location exceeds total number of modifiers.");
7791 return MotionModifiersLoc[Cnt];
7792 }
7793
7794 /// Fetches ArrayRef of motion-modifiers.
7796 return MotionModifiers;
7797 }
7798
7799 /// Fetches ArrayRef of location of motion-modifiers.
7801 return MotionModifiersLoc;
7802 }
7803
7804 /// Get colon location.
7805 SourceLocation getColonLoc() const { return ColonLoc; }
7806
7808 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7809 reinterpret_cast<Stmt **>(varlist_end()));
7810 }
7811
7813 auto Children = const_cast<OMPToClause *>(this)->children();
7814 return const_child_range(Children.begin(), Children.end());
7815 }
7816
7823
7824 static bool classof(const OMPClause *T) {
7825 return T->getClauseKind() == llvm::omp::OMPC_to;
7826 }
7827};
7828
7829/// This represents clause 'from' in the '#pragma omp ...'
7830/// directives.
7831///
7832/// \code
7833/// #pragma omp target update from(a,b)
7834/// \endcode
7835/// In this example directive '#pragma omp target update' has clause 'from'
7836/// with the variables 'a' and 'b'.
7837class OMPFromClause final
7838 : public OMPMappableExprListClause<OMPFromClause>,
7839 private llvm::TrailingObjects<
7840 OMPFromClause, Expr *, ValueDecl *, unsigned,
7841 OMPClauseMappableExprCommon::MappableComponent> {
7842 friend class OMPClauseReader;
7843 friend OMPMappableExprListClause;
7844 friend OMPVarListClause;
7845 friend TrailingObjects;
7846
7847 /// Motion-modifiers for the 'from' clause.
7850
7851 /// Location of motion-modifiers for the 'from' clause.
7852 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7853
7854 /// Colon location.
7855 SourceLocation ColonLoc;
7856
7857 /// Build clause with number of variables \a NumVars.
7858 ///
7859 /// \param TheMotionModifiers Motion-modifiers.
7860 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7861 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7862 /// user-defined mapper.
7863 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7864 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7865 /// StartLoc: starting location of the clause (the clause keyword); 2)
7866 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7867 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7868 /// NumVars: number of expressions listed in this clause; 2)
7869 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7870 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7871 /// NumComponents: total number of expression components in the clause.
7872 explicit OMPFromClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7873 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7874 NestedNameSpecifierLoc MapperQualifierLoc,
7875 DeclarationNameInfo MapperIdInfo,
7876 const OMPVarListLocTy &Locs,
7877 const OMPMappableExprListSizeTy &Sizes)
7878 : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes,
7879 /*SupportsMapper=*/true, &MapperQualifierLoc,
7880 &MapperIdInfo) {
7881 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7882 "Unexpected number of motion modifiers.");
7883 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7884
7885 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7886 "Unexpected number of motion modifier locations.");
7887 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7888 }
7889
7890 /// Build an empty clause.
7891 ///
7892 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7893 /// NumVars: number of expressions listed in this clause; 2)
7894 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7895 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7896 /// NumComponents: total number of expression components in the clause.
7897 explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes)
7898 : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(),
7899 Sizes, /*SupportsMapper=*/true) {}
7900
7901 /// Set motion-modifier for the clause.
7902 ///
7903 /// \param I index for motion-modifier.
7904 /// \param T motion-modifier for the clause.
7905 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7906 assert(I < NumberOfOMPMotionModifiers &&
7907 "Unexpected index to store motion modifier, exceeds array size.");
7908 MotionModifiers[I] = T;
7909 }
7910
7911 /// Set location for the motion-modifier.
7912 ///
7913 /// \param I index for motion-modifier location.
7914 /// \param TLoc motion-modifier location.
7915 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7916 assert(I < NumberOfOMPMotionModifiers &&
7917 "Index to store motion modifier location exceeds array size.");
7918 MotionModifiersLoc[I] = TLoc;
7919 }
7920
7921 /// Set colon location.
7922 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7923
7924 /// Define the sizes of each trailing object array except the last one. This
7925 /// is required for TrailingObjects to work properly.
7926 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7927 // There are varlist_size() of expressions, and varlist_size() of
7928 // user-defined mappers.
7929 return 2 * varlist_size();
7930 }
7931 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7932 return getUniqueDeclarationsNum();
7933 }
7934 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7936 }
7937
7938public:
7939 /// Creates clause with a list of variables \a Vars.
7940 ///
7941 /// \param C AST context.
7942 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7943 /// StartLoc: starting location of the clause (the clause keyword); 2)
7944 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7945 /// \param Vars The original expression used in the clause.
7946 /// \param Declarations Declarations used in the clause.
7947 /// \param ComponentLists Component lists used in the clause.
7948 /// \param MotionModifiers Motion-modifiers.
7949 /// \param MotionModifiersLoc Location of motion-modifiers.
7950 /// \param UDMapperRefs References to user-defined mappers associated with
7951 /// expressions used in the clause.
7952 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7953 /// user-defined mapper.
7954 /// \param MapperId The identifier of associated user-defined mapper.
7955 static OMPFromClause *
7956 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7957 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7958 MappableExprComponentListsRef ComponentLists,
7959 ArrayRef<Expr *> UDMapperRefs,
7960 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7961 ArrayRef<SourceLocation> MotionModifiersLoc,
7962 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId);
7963
7964 /// Creates an empty clause with the place for \a NumVars variables.
7965 ///
7966 /// \param C AST context.
7967 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7968 /// NumVars: number of expressions listed in this clause; 2)
7969 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7970 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7971 /// NumComponents: total number of expression components in the clause.
7972 static OMPFromClause *CreateEmpty(const ASTContext &C,
7973 const OMPMappableExprListSizeTy &Sizes);
7974
7975 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7976 ///
7977 /// \param Cnt index for motion-modifier.
7978 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7979 assert(Cnt < NumberOfOMPMotionModifiers &&
7980 "Requested modifier exceeds the total number of modifiers.");
7981 return MotionModifiers[Cnt];
7982 }
7983
7984 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7985 /// locations.
7986 ///
7987 /// \param Cnt index for motion-modifier location.
7988 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7989 assert(Cnt < NumberOfOMPMotionModifiers &&
7990 "Requested modifier location exceeds total number of modifiers.");
7991 return MotionModifiersLoc[Cnt];
7992 }
7993
7994 /// Fetches ArrayRef of motion-modifiers.
7996 return MotionModifiers;
7997 }
7998
7999 /// Fetches ArrayRef of location of motion-modifiers.
8001 return MotionModifiersLoc;
8002 }
8003
8004 /// Get colon location.
8005 SourceLocation getColonLoc() const { return ColonLoc; }
8006
8008 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8009 reinterpret_cast<Stmt **>(varlist_end()));
8010 }
8011
8013 auto Children = const_cast<OMPFromClause *>(this)->children();
8014 return const_child_range(Children.begin(), Children.end());
8015 }
8016
8023
8024 static bool classof(const OMPClause *T) {
8025 return T->getClauseKind() == llvm::omp::OMPC_from;
8026 }
8027};
8028
8029/// This represents clause 'use_device_ptr' in the '#pragma omp ...'
8030/// directives.
8031///
8032/// \code
8033/// #pragma omp target data use_device_ptr(a,b)
8034/// \endcode
8035/// In this example directive '#pragma omp target data' has clause
8036/// 'use_device_ptr' with the variables 'a' and 'b'.
8037class OMPUseDevicePtrClause final
8038 : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
8039 private llvm::TrailingObjects<
8040 OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
8041 OMPClauseMappableExprCommon::MappableComponent> {
8042 friend class OMPClauseReader;
8043 friend OMPMappableExprListClause;
8044 friend OMPVarListClause;
8045 friend TrailingObjects;
8046
8047 /// Build clause with number of variables \a NumVars.
8048 ///
8049 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8050 /// StartLoc: starting location of the clause (the clause keyword); 2)
8051 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8052 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8053 /// NumVars: number of expressions listed in this clause; 2)
8054 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8055 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8056 /// NumComponents: total number of expression components in the clause.
8057 explicit OMPUseDevicePtrClause(const OMPVarListLocTy &Locs,
8058 const OMPMappableExprListSizeTy &Sizes)
8059 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr, Locs, Sizes) {
8060 }
8061
8062 /// Build an empty clause.
8063 ///
8064 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8065 /// NumVars: number of expressions listed in this clause; 2)
8066 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8067 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8068 /// NumComponents: total number of expression components in the clause.
8070 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr,
8071 OMPVarListLocTy(), Sizes) {}
8072
8073 /// Define the sizes of each trailing object array except the last one. This
8074 /// is required for TrailingObjects to work properly.
8075 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8076 return 3 * varlist_size();
8077 }
8078 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8079 return getUniqueDeclarationsNum();
8080 }
8081 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8083 }
8084
8085 /// Sets the list of references to private copies with initializers for new
8086 /// private variables.
8087 /// \param VL List of references.
8088 void setPrivateCopies(ArrayRef<Expr *> VL);
8089
8090 /// Gets the list of references to private copies with initializers for new
8091 /// private variables.
8092 MutableArrayRef<Expr *> getPrivateCopies() {
8093 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
8094 }
8095 ArrayRef<const Expr *> getPrivateCopies() const {
8096 return {varlist_end(), varlist_size()};
8097 }
8098
8099 /// Sets the list of references to initializer variables for new private
8100 /// variables.
8101 /// \param VL List of references.
8102 void setInits(ArrayRef<Expr *> VL);
8103
8104 /// Gets the list of references to initializer variables for new private
8105 /// variables.
8106 MutableArrayRef<Expr *> getInits() {
8107 return {getPrivateCopies().end(), varlist_size()};
8108 }
8109 ArrayRef<const Expr *> getInits() const {
8110 return {getPrivateCopies().end(), varlist_size()};
8111 }
8112
8113public:
8114 /// Creates clause with a list of variables \a Vars.
8115 ///
8116 /// \param C AST context.
8117 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8118 /// StartLoc: starting location of the clause (the clause keyword); 2)
8119 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8120 /// \param Vars The original expression used in the clause.
8121 /// \param PrivateVars Expressions referring to private copies.
8122 /// \param Inits Expressions referring to private copy initializers.
8123 /// \param Declarations Declarations used in the clause.
8124 /// \param ComponentLists Component lists used in the clause.
8125 static OMPUseDevicePtrClause *
8126 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8127 ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
8128 ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
8129 MappableExprComponentListsRef ComponentLists);
8130
8131 /// Creates an empty clause with the place for \a NumVars variables.
8132 ///
8133 /// \param C AST context.
8134 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8135 /// NumVars: number of expressions listed in this clause; 2)
8136 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8137 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8138 /// NumComponents: total number of expression components in the clause.
8139 static OMPUseDevicePtrClause *
8140 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8141
8144 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
8146 llvm::iterator_range<private_copies_const_iterator>;
8147
8149 return private_copies_range(getPrivateCopies().begin(),
8150 getPrivateCopies().end());
8151 }
8152
8154 return private_copies_const_range(getPrivateCopies().begin(),
8155 getPrivateCopies().end());
8156 }
8157
8160 using inits_range = llvm::iterator_range<inits_iterator>;
8161 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
8162
8164 return inits_range(getInits().begin(), getInits().end());
8165 }
8166
8168 return inits_const_range(getInits().begin(), getInits().end());
8169 }
8170
8172 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8173 reinterpret_cast<Stmt **>(varlist_end()));
8174 }
8175
8177 auto Children = const_cast<OMPUseDevicePtrClause *>(this)->children();
8178 return const_child_range(Children.begin(), Children.end());
8179 }
8180
8187
8188 static bool classof(const OMPClause *T) {
8189 return T->getClauseKind() == llvm::omp::OMPC_use_device_ptr;
8190 }
8191};
8192
8193/// This represents clause 'use_device_addr' in the '#pragma omp ...'
8194/// directives.
8195///
8196/// \code
8197/// #pragma omp target data use_device_addr(a,b)
8198/// \endcode
8199/// In this example directive '#pragma omp target data' has clause
8200/// 'use_device_addr' with the variables 'a' and 'b'.
8201class OMPUseDeviceAddrClause final
8202 : public OMPMappableExprListClause<OMPUseDeviceAddrClause>,
8203 private llvm::TrailingObjects<
8204 OMPUseDeviceAddrClause, Expr *, ValueDecl *, unsigned,
8205 OMPClauseMappableExprCommon::MappableComponent> {
8206 friend class OMPClauseReader;
8207 friend OMPMappableExprListClause;
8208 friend OMPVarListClause;
8209 friend TrailingObjects;
8210
8211 /// Build clause with number of variables \a NumVars.
8212 ///
8213 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8214 /// StartLoc: starting location of the clause (the clause keyword); 2)
8215 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8216 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8217 /// NumVars: number of expressions listed in this clause; 2)
8218 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8219 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8220 /// NumComponents: total number of expression components in the clause.
8221 explicit OMPUseDeviceAddrClause(const OMPVarListLocTy &Locs,
8222 const OMPMappableExprListSizeTy &Sizes)
8223 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr, Locs,
8224 Sizes) {}
8225
8226 /// Build an empty clause.
8227 ///
8228 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8229 /// NumVars: number of expressions listed in this clause; 2)
8230 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8231 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8232 /// NumComponents: total number of expression components in the clause.
8234 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr,
8235 OMPVarListLocTy(), Sizes) {}
8236
8237 /// Define the sizes of each trailing object array except the last one. This
8238 /// is required for TrailingObjects to work properly.
8239 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8240 return varlist_size();
8241 }
8242 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8243 return getUniqueDeclarationsNum();
8244 }
8245 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8247 }
8248
8249public:
8250 /// Creates clause with a list of variables \a Vars.
8251 ///
8252 /// \param C AST context.
8253 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8254 /// StartLoc: starting location of the clause (the clause keyword); 2)
8255 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8256 /// \param Vars The original expression used in the clause.
8257 /// \param Declarations Declarations used in the clause.
8258 /// \param ComponentLists Component lists used in the clause.
8259 static OMPUseDeviceAddrClause *
8260 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8261 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8262 MappableExprComponentListsRef ComponentLists);
8263
8264 /// Creates an empty clause with the place for \a NumVars variables.
8265 ///
8266 /// \param C AST context.
8267 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8268 /// NumVars: number of expressions listed in this clause; 2)
8269 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8270 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8271 /// NumComponents: total number of expression components in the clause.
8272 static OMPUseDeviceAddrClause *
8273 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8274
8276 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8277 reinterpret_cast<Stmt **>(varlist_end()));
8278 }
8279
8281 auto Children = const_cast<OMPUseDeviceAddrClause *>(this)->children();
8282 return const_child_range(Children.begin(), Children.end());
8283 }
8284
8291
8292 static bool classof(const OMPClause *T) {
8293 return T->getClauseKind() == llvm::omp::OMPC_use_device_addr;
8294 }
8295};
8296
8297/// This represents clause 'is_device_ptr' in the '#pragma omp ...'
8298/// directives.
8299///
8300/// \code
8301/// #pragma omp target is_device_ptr(a,b)
8302/// \endcode
8303/// In this example directive '#pragma omp target' has clause
8304/// 'is_device_ptr' with the variables 'a' and 'b'.
8305class OMPIsDevicePtrClause final
8306 : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
8307 private llvm::TrailingObjects<
8308 OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
8309 OMPClauseMappableExprCommon::MappableComponent> {
8310 friend class OMPClauseReader;
8311 friend OMPMappableExprListClause;
8312 friend OMPVarListClause;
8313 friend TrailingObjects;
8314
8315 /// Build clause with number of variables \a NumVars.
8316 ///
8317 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8318 /// StartLoc: starting location of the clause (the clause keyword); 2)
8319 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8320 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8321 /// NumVars: number of expressions listed in this clause; 2)
8322 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8323 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8324 /// NumComponents: total number of expression components in the clause.
8325 explicit OMPIsDevicePtrClause(const OMPVarListLocTy &Locs,
8326 const OMPMappableExprListSizeTy &Sizes)
8327 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr, Locs, Sizes) {}
8328
8329 /// Build an empty clause.
8330 ///
8331 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8332 /// NumVars: number of expressions listed in this clause; 2)
8333 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8334 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8335 /// NumComponents: total number of expression components in the clause.
8336 explicit OMPIsDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
8337 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr,
8338 OMPVarListLocTy(), Sizes) {}
8339
8340 /// Define the sizes of each trailing object array except the last one. This
8341 /// is required for TrailingObjects to work properly.
8342 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8343 return varlist_size();
8344 }
8345 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8346 return getUniqueDeclarationsNum();
8347 }
8348 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8350 }
8351
8352public:
8353 /// Creates clause with a list of variables \a Vars.
8354 ///
8355 /// \param C AST context.
8356 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8357 /// StartLoc: starting location of the clause (the clause keyword); 2)
8358 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8359 /// \param Vars The original expression used in the clause.
8360 /// \param Declarations Declarations used in the clause.
8361 /// \param ComponentLists Component lists used in the clause.
8362 static OMPIsDevicePtrClause *
8363 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8364 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8365 MappableExprComponentListsRef ComponentLists);
8366
8367 /// Creates an empty clause with the place for \a NumVars variables.
8368 ///
8369 /// \param C AST context.
8370 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8371 /// NumVars: number of expressions listed in this clause; 2)
8372 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8373 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8374 /// NumComponents: total number of expression components in the clause.
8375 static OMPIsDevicePtrClause *
8376 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8377
8379 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8380 reinterpret_cast<Stmt **>(varlist_end()));
8381 }
8382
8384 auto Children = const_cast<OMPIsDevicePtrClause *>(this)->children();
8385 return const_child_range(Children.begin(), Children.end());
8386 }
8387
8394
8395 static bool classof(const OMPClause *T) {
8396 return T->getClauseKind() == llvm::omp::OMPC_is_device_ptr;
8397 }
8398};
8399
8400/// This represents clause 'has_device_ptr' in the '#pragma omp ...'
8401/// directives.
8402///
8403/// \code
8404/// #pragma omp target has_device_addr(a,b)
8405/// \endcode
8406/// In this example directive '#pragma omp target' has clause
8407/// 'has_device_ptr' with the variables 'a' and 'b'.
8408class OMPHasDeviceAddrClause final
8409 : public OMPMappableExprListClause<OMPHasDeviceAddrClause>,
8410 private llvm::TrailingObjects<
8411 OMPHasDeviceAddrClause, Expr *, ValueDecl *, unsigned,
8412 OMPClauseMappableExprCommon::MappableComponent> {
8413 friend class OMPClauseReader;
8414 friend OMPMappableExprListClause;
8415 friend OMPVarListClause;
8416 friend TrailingObjects;
8417
8418 /// Build clause with number of variables \a NumVars.
8419 ///
8420 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8421 /// StartLoc: starting location of the clause (the clause keyword); 2)
8422 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8423 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8424 /// NumVars: number of expressions listed in this clause; 2)
8425 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8426 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8427 /// NumComponents: total number of expression components in the clause.
8428 explicit OMPHasDeviceAddrClause(const OMPVarListLocTy &Locs,
8429 const OMPMappableExprListSizeTy &Sizes)
8430 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, Locs,
8431 Sizes) {}
8432
8433 /// Build an empty clause.
8434 ///
8435 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8436 /// NumVars: number of expressions listed in this clause; 2)
8437 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8438 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8439 /// NumComponents: total number of expression components in the clause.
8441 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr,
8442 OMPVarListLocTy(), Sizes) {}
8443
8444 /// Define the sizes of each trailing object array except the last one. This
8445 /// is required for TrailingObjects to work properly.
8446 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8447 return varlist_size();
8448 }
8449 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8450 return getUniqueDeclarationsNum();
8451 }
8452 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8454 }
8455
8456public:
8457 /// Creates clause with a list of variables \a Vars.
8458 ///
8459 /// \param C AST context.
8460 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8461 /// StartLoc: starting location of the clause (the clause keyword); 2)
8462 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8463 /// \param Vars The original expression used in the clause.
8464 /// \param Declarations Declarations used in the clause.
8465 /// \param ComponentLists Component lists used in the clause.
8466 static OMPHasDeviceAddrClause *
8467 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8468 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8469 MappableExprComponentListsRef ComponentLists);
8470
8471 /// Creates an empty clause with the place for \a NumVars variables.
8472 ///
8473 /// \param C AST context.
8474 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8475 /// NumVars: number of expressions listed in this clause; 2)
8476 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8477 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8478 /// NumComponents: total number of expression components in the clause.
8479 static OMPHasDeviceAddrClause *
8480 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8481
8483 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8484 reinterpret_cast<Stmt **>(varlist_end()));
8485 }
8486
8488 auto Children = const_cast<OMPHasDeviceAddrClause *>(this)->children();
8489 return const_child_range(Children.begin(), Children.end());
8490 }
8491
8498
8499 static bool classof(const OMPClause *T) {
8500 return T->getClauseKind() == llvm::omp::OMPC_has_device_addr;
8501 }
8502};
8503
8504/// This represents clause 'nontemporal' in the '#pragma omp ...' directives.
8505///
8506/// \code
8507/// #pragma omp simd nontemporal(a)
8508/// \endcode
8509/// In this example directive '#pragma omp simd' has clause 'nontemporal' for
8510/// the variable 'a'.
8511class OMPNontemporalClause final
8512 : public OMPVarListClause<OMPNontemporalClause>,
8513 private llvm::TrailingObjects<OMPNontemporalClause, Expr *> {
8514 friend class OMPClauseReader;
8515 friend OMPVarListClause;
8516 friend TrailingObjects;
8517
8518 /// Build clause with number of variables \a N.
8519 ///
8520 /// \param StartLoc Starting location of the clause.
8521 /// \param LParenLoc Location of '('.
8522 /// \param EndLoc Ending location of the clause.
8523 /// \param N Number of the variables in the clause.
8524 OMPNontemporalClause(SourceLocation StartLoc, SourceLocation LParenLoc,
8525 SourceLocation EndLoc, unsigned N)
8526 : OMPVarListClause<OMPNontemporalClause>(llvm::omp::OMPC_nontemporal,
8527 StartLoc, LParenLoc, EndLoc, N) {
8528 }
8529
8530 /// Build an empty clause.
8531 ///
8532 /// \param N Number of variables.
8533 explicit OMPNontemporalClause(unsigned N)
8535 llvm::omp::OMPC_nontemporal, SourceLocation(), SourceLocation(),
8536 SourceLocation(), N) {}
8537
8538 /// Get the list of privatied copies if the member expression was captured by
8539 /// one of the privatization clauses.
8540 MutableArrayRef<Expr *> getPrivateRefs() {
8541 return {varlist_end(), varlist_size()};
8542 }
8543 ArrayRef<const Expr *> getPrivateRefs() const {
8544 return {varlist_end(), varlist_size()};
8545 }
8546
8547public:
8548 /// Creates clause with a list of variables \a VL.
8549 ///
8550 /// \param C AST context.
8551 /// \param StartLoc Starting location of the clause.
8552 /// \param LParenLoc Location of '('.
8553 /// \param EndLoc Ending location of the clause.
8554 /// \param VL List of references to the variables.
8555 static OMPNontemporalClause *
8556 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
8557 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8558
8559 /// Creates an empty clause with the place for \a N variables.
8560 ///
8561 /// \param C AST context.
8562 /// \param N The number of variables.
8563 static OMPNontemporalClause *CreateEmpty(const ASTContext &C, unsigned N);
8564
8565 /// Sets the list of references to private copies created in private clauses.
8566 /// \param VL List of references.
8567 void setPrivateRefs(ArrayRef<Expr *> VL);
8568
8570 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8571 reinterpret_cast<Stmt **>(varlist_end()));
8572 }
8573
8575 auto Children = const_cast<OMPNontemporalClause *>(this)->children();
8576 return const_child_range(Children.begin(), Children.end());
8577 }
8578
8580 return child_range(reinterpret_cast<Stmt **>(getPrivateRefs().begin()),
8581 reinterpret_cast<Stmt **>(getPrivateRefs().end()));
8582 }
8583
8585 auto Children = const_cast<OMPNontemporalClause *>(this)->private_refs();
8586 return const_child_range(Children.begin(), Children.end());
8587 }
8588
8595
8596 static bool classof(const OMPClause *T) {
8597 return T->getClauseKind() == llvm::omp::OMPC_nontemporal;
8598 }
8599};
8600
8601/// This represents 'order' clause in the '#pragma omp ...' directive.
8602///
8603/// \code
8604/// #pragma omp simd order(concurrent)
8605/// \endcode
8606/// In this example directive '#pragma omp parallel' has simple 'order'
8607/// clause with kind 'concurrent'.
8608class OMPOrderClause final : public OMPClause {
8609 friend class OMPClauseReader;
8610
8611 /// Location of '('.
8612 SourceLocation LParenLoc;
8613
8614 /// A kind of the 'order' clause.
8616
8617 /// Start location of the kind in source code.
8618 SourceLocation KindKwLoc;
8619
8620 /// A modifier for order clause
8622
8623 /// Start location of the modifier in source code.
8624 SourceLocation ModifierKwLoc;
8625
8626 /// Set kind of the clause.
8627 ///
8628 /// \param K Argument of clause.
8629 void setKind(OpenMPOrderClauseKind K) { Kind = K; }
8630
8631 /// Set argument location.
8632 ///
8633 /// \param KLoc Argument location.
8634 void setKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
8635
8636 /// Set modifier of the clause.
8637 ///
8638 /// \param M Argument of clause.
8639 void setModifier(OpenMPOrderClauseModifier M) { Modifier = M; }
8640
8641 /// Set modifier location.
8642 ///
8643 /// \param MLoc Modifier keyword location.
8644 void setModifierKwLoc(SourceLocation MLoc) { ModifierKwLoc = MLoc; }
8645
8646public:
8647 /// Build 'order' clause with argument \p A ('concurrent').
8648 ///
8649 /// \param A Argument of the clause ('concurrent').
8650 /// \param ALoc Starting location of the argument.
8651 /// \param StartLoc Starting location of the clause.
8652 /// \param LParenLoc Location of '('.
8653 /// \param EndLoc Ending location of the clause.
8654 /// \param Modifier The modifier applied to 'order' clause.
8655 /// \param MLoc Location of the modifier
8657 SourceLocation StartLoc, SourceLocation LParenLoc,
8659 SourceLocation MLoc)
8660 : OMPClause(llvm::omp::OMPC_order, StartLoc, EndLoc),
8661 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), Modifier(Modifier),
8662 ModifierKwLoc(MLoc) {}
8663
8664 /// Build an empty clause.
8666 : OMPClause(llvm::omp::OMPC_order, SourceLocation(), SourceLocation()) {}
8667
8668 /// Sets the location of '('.
8669 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8670
8671 /// Returns the location of '('.
8672 SourceLocation getLParenLoc() const { return LParenLoc; }
8673
8674 /// Returns kind of the clause.
8675 OpenMPOrderClauseKind getKind() const { return Kind; }
8676
8677 /// Returns location of clause kind.
8678 SourceLocation getKindKwLoc() const { return KindKwLoc; }
8679
8680 /// Returns Modifier of the clause.
8681 OpenMPOrderClauseModifier getModifier() const { return Modifier; }
8682
8683 /// Returns location of clause modifier.
8684 SourceLocation getModifierKwLoc() const { return ModifierKwLoc; }
8685
8689
8693
8700
8701 static bool classof(const OMPClause *T) {
8702 return T->getClauseKind() == llvm::omp::OMPC_order;
8703 }
8704};
8705
8706/// This represents the 'init' clause in '#pragma omp ...' directives.
8707///
8708/// \code
8709/// #pragma omp interop init(target:obj)
8710/// \endcode
8711class OMPInitClause final
8712 : public OMPVarListClause<OMPInitClause>,
8713 private llvm::TrailingObjects<OMPInitClause, Expr *> {
8714 friend class OMPClauseReader;
8715 friend OMPVarListClause;
8716 friend TrailingObjects;
8717
8718 /// Location of interop variable.
8719 SourceLocation VarLoc;
8720
8721 bool IsTarget = false;
8722 bool IsTargetSync = false;
8723
8724 void setInteropVar(Expr *E) { varlist_begin()[0] = E; }
8725
8726 void setIsTarget(bool V) { IsTarget = V; }
8727
8728 void setIsTargetSync(bool V) { IsTargetSync = V; }
8729
8730 /// Sets the location of the interop variable.
8731 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8732
8733 /// Build 'init' clause.
8734 ///
8735 /// \param IsTarget Uses the 'target' interop-type.
8736 /// \param IsTargetSync Uses the 'targetsync' interop-type.
8737 /// \param StartLoc Starting location of the clause.
8738 /// \param LParenLoc Location of '('.
8739 /// \param VarLoc Location of the interop variable.
8740 /// \param EndLoc Ending location of the clause.
8741 /// \param N Number of expressions.
8742 OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc,
8743 SourceLocation LParenLoc, SourceLocation VarLoc,
8744 SourceLocation EndLoc, unsigned N)
8745 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc,
8746 LParenLoc, EndLoc, N),
8747 VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {}
8748
8749 /// Build an empty clause.
8750 OMPInitClause(unsigned N)
8751 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(),
8752 SourceLocation(), SourceLocation(), N) {
8753 }
8754
8755public:
8756 /// Creates a fully specified clause.
8757 ///
8758 /// \param C AST context.
8759 /// \param InteropVar The interop variable.
8760 /// \param InteropInfo The interop-type and prefer_type list.
8761 /// \param StartLoc Starting location of the clause.
8762 /// \param LParenLoc Location of '('.
8763 /// \param VarLoc Location of the interop variable.
8764 /// \param EndLoc Ending location of the clause.
8765 static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar,
8766 OMPInteropInfo &InteropInfo,
8767 SourceLocation StartLoc,
8768 SourceLocation LParenLoc, SourceLocation VarLoc,
8769 SourceLocation EndLoc);
8770
8771 /// Creates an empty clause with \a N expressions.
8772 ///
8773 /// \param C AST context.
8774 /// \param N Number of expression items.
8775 static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N);
8776
8777 /// Returns the location of the interop variable.
8778 SourceLocation getVarLoc() const { return VarLoc; }
8779
8780 /// Returns the interop variable.
8782 const Expr *getInteropVar() const { return varlist_begin()[0]; }
8783
8784 /// Returns true is interop-type 'target' is used.
8785 bool getIsTarget() const { return IsTarget; }
8786
8787 /// Returns true is interop-type 'targetsync' is used.
8788 bool getIsTargetSync() const { return IsTargetSync; }
8789
8791 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8792 reinterpret_cast<Stmt **>(varlist_end()));
8793 }
8794
8796 auto Children = const_cast<OMPInitClause *>(this)->children();
8797 return const_child_range(Children.begin(), Children.end());
8798 }
8799
8806
8809 using prefs_range = llvm::iterator_range<prefs_iterator>;
8810 using const_prefs_range = llvm::iterator_range<const_prefs_iterator>;
8811
8813 return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())),
8814 reinterpret_cast<Expr **>(varlist_end()));
8815 }
8816
8818 auto Prefs = const_cast<OMPInitClause *>(this)->prefs();
8819 return const_prefs_range(Prefs.begin(), Prefs.end());
8820 }
8821
8822 static bool classof(const OMPClause *T) {
8823 return T->getClauseKind() == llvm::omp::OMPC_init;
8824 }
8825};
8826
8827/// This represents the 'use' clause in '#pragma omp ...' directives.
8828///
8829/// \code
8830/// #pragma omp interop use(obj)
8831/// \endcode
8832class OMPUseClause final : public OMPClause {
8833 friend class OMPClauseReader;
8834
8835 /// Location of '('.
8836 SourceLocation LParenLoc;
8837
8838 /// Location of interop variable.
8839 SourceLocation VarLoc;
8840
8841 /// The interop variable.
8842 Stmt *InteropVar = nullptr;
8843
8844 /// Set the interop variable.
8845 void setInteropVar(Expr *E) { InteropVar = E; }
8846
8847 /// Sets the location of '('.
8848 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8849
8850 /// Sets the location of the interop variable.
8851 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8852
8853public:
8854 /// Build 'use' clause with and interop variable expression \a InteropVar.
8855 ///
8856 /// \param InteropVar The interop variable.
8857 /// \param StartLoc Starting location of the clause.
8858 /// \param LParenLoc Location of '('.
8859 /// \param VarLoc Location of the interop variable.
8860 /// \param EndLoc Ending location of the clause.
8861 OMPUseClause(Expr *InteropVar, SourceLocation StartLoc,
8862 SourceLocation LParenLoc, SourceLocation VarLoc,
8863 SourceLocation EndLoc)
8864 : OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc),
8865 VarLoc(VarLoc), InteropVar(InteropVar) {}
8866
8867 /// Build an empty clause.
8869 : OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {}
8870
8871 /// Returns the location of '('.
8872 SourceLocation getLParenLoc() const { return LParenLoc; }
8873
8874 /// Returns the location of the interop variable.
8875 SourceLocation getVarLoc() const { return VarLoc; }
8876
8877 /// Returns the interop variable.
8878 Expr *getInteropVar() const { return cast<Expr>(InteropVar); }
8879
8880 child_range children() { return child_range(&InteropVar, &InteropVar + 1); }
8881
8883 return const_child_range(&InteropVar, &InteropVar + 1);
8884 }
8885
8892
8893 static bool classof(const OMPClause *T) {
8894 return T->getClauseKind() == llvm::omp::OMPC_use;
8895 }
8896};
8897
8898/// This represents 'destroy' clause in the '#pragma omp depobj'
8899/// directive or the '#pragma omp interop' directive..
8900///
8901/// \code
8902/// #pragma omp depobj(a) destroy
8903/// #pragma omp interop destroy(obj)
8904/// \endcode
8905/// In these examples directive '#pragma omp depobj' and '#pragma omp interop'
8906/// have a 'destroy' clause. The 'interop' directive includes an object.
8907class OMPDestroyClause final : public OMPClause {
8908 friend class OMPClauseReader;
8909
8910 /// Location of '('.
8911 SourceLocation LParenLoc;
8912
8913 /// Location of interop variable.
8914 SourceLocation VarLoc;
8915
8916 /// The interop variable.
8917 Stmt *InteropVar = nullptr;
8918
8919 /// Set the interop variable.
8920 void setInteropVar(Expr *E) { InteropVar = E; }
8921
8922 /// Sets the location of '('.
8923 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8924
8925 /// Sets the location of the interop variable.
8926 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8927
8928public:
8929 /// Build 'destroy' clause with an interop variable expression \a InteropVar.
8930 ///
8931 /// \param InteropVar The interop variable.
8932 /// \param StartLoc Starting location of the clause.
8933 /// \param LParenLoc Location of '('.
8934 /// \param VarLoc Location of the interop variable.
8935 /// \param EndLoc Ending location of the clause.
8936 OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc,
8937 SourceLocation LParenLoc, SourceLocation VarLoc,
8938 SourceLocation EndLoc)
8939 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc),
8940 LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {}
8941
8942 /// Build 'destroy' clause.
8943 ///
8944 /// \param StartLoc Starting location of the clause.
8945 /// \param EndLoc Ending location of the clause.
8947 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc) {}
8948
8949 /// Build an empty clause.
8951 : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) {
8952 }
8953
8954 /// Returns the location of '('.
8955 SourceLocation getLParenLoc() const { return LParenLoc; }
8956
8957 /// Returns the location of the interop variable.
8958 SourceLocation getVarLoc() const { return VarLoc; }
8959
8960 /// Returns the interop variable.
8961 Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); }
8962
8964 if (InteropVar)
8965 return child_range(&InteropVar, &InteropVar + 1);
8967 }
8968
8970 if (InteropVar)
8971 return const_child_range(&InteropVar, &InteropVar + 1);
8973 }
8974
8981
8982 static bool classof(const OMPClause *T) {
8983 return T->getClauseKind() == llvm::omp::OMPC_destroy;
8984 }
8985};
8986
8987/// This represents 'novariants' clause in the '#pragma omp ...' directive.
8988///
8989/// \code
8990/// #pragma omp dispatch novariants(a > 5)
8991/// \endcode
8992/// In this example directive '#pragma omp dispatch' has simple 'novariants'
8993/// clause with condition 'a > 5'.
8995 : public OMPOneStmtClause<llvm::omp::OMPC_novariants, OMPClause>,
8996 public OMPClauseWithPreInit {
8997 friend class OMPClauseReader;
8998
8999 /// Set condition.
9000 void setCondition(Expr *Cond) { setStmt(Cond); }
9001
9002public:
9003 /// Build 'novariants' clause with condition \a Cond.
9004 ///
9005 /// \param Cond Condition of the clause.
9006 /// \param HelperCond Helper condition for the construct.
9007 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9008 /// clause must be captured.
9009 /// \param StartLoc Starting location of the clause.
9010 /// \param LParenLoc Location of '('.
9011 /// \param EndLoc Ending location of the clause.
9013 OpenMPDirectiveKind CaptureRegion,
9014 SourceLocation StartLoc, SourceLocation LParenLoc,
9015 SourceLocation EndLoc)
9016 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
9017 OMPClauseWithPreInit(this) {
9018 setPreInitStmt(HelperCond, CaptureRegion);
9019 }
9020
9021 /// Build an empty clause.
9023
9024 /// Returns condition.
9025 Expr *getCondition() const { return getStmtAs<Expr>(); }
9026
9029 auto Children = const_cast<OMPNovariantsClause *>(this)->used_children();
9030 return const_child_range(Children.begin(), Children.end());
9031 }
9032};
9033
9034/// This represents 'nocontext' clause in the '#pragma omp ...' directive.
9035///
9036/// \code
9037/// #pragma omp dispatch nocontext(a > 5)
9038/// \endcode
9039/// In this example directive '#pragma omp dispatch' has simple 'nocontext'
9040/// clause with condition 'a > 5'.
9042 : public OMPOneStmtClause<llvm::omp::OMPC_nocontext, OMPClause>,
9043 public OMPClauseWithPreInit {
9044 friend class OMPClauseReader;
9045
9046 /// Set condition.
9047 void setCondition(Expr *Cond) { setStmt(Cond); }
9048
9049public:
9050 /// Build 'nocontext' clause with condition \a Cond.
9051 ///
9052 /// \param Cond Condition of the clause.
9053 /// \param HelperCond Helper condition for the construct.
9054 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9055 /// clause must be captured.
9056 /// \param StartLoc Starting location of the clause.
9057 /// \param LParenLoc Location of '('.
9058 /// \param EndLoc Ending location of the clause.
9060 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
9061 SourceLocation LParenLoc, SourceLocation EndLoc)
9062 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
9063 OMPClauseWithPreInit(this) {
9064 setPreInitStmt(HelperCond, CaptureRegion);
9065 }
9066
9067 /// Build an empty clause.
9069
9070 /// Returns condition.
9071 Expr *getCondition() const { return getStmtAs<Expr>(); }
9072
9075 auto Children = const_cast<OMPNocontextClause *>(this)->used_children();
9076 return const_child_range(Children.begin(), Children.end());
9077 }
9078};
9079
9080/// This represents 'detach' clause in the '#pragma omp task' directive.
9081///
9082/// \code
9083/// #pragma omp task detach(evt)
9084/// \endcode
9085/// In this example directive '#pragma omp detach' has simple 'detach' clause
9086/// with the variable 'evt'.
9088 : public OMPOneStmtClause<llvm::omp::OMPC_detach, OMPClause> {
9089 friend class OMPClauseReader;
9090
9091 /// Set condition.
9092 void setEventHandler(Expr *E) { setStmt(E); }
9093
9094public:
9095 /// Build 'detach' clause with event-handler \a Evt.
9096 ///
9097 /// \param Evt Event handler expression.
9098 /// \param StartLoc Starting location of the clause.
9099 /// \param LParenLoc Location of '('.
9100 /// \param EndLoc Ending location of the clause.
9102 SourceLocation EndLoc)
9103 : OMPOneStmtClause(Evt, StartLoc, LParenLoc, EndLoc) {}
9104
9105 /// Build an empty clause.
9107
9108 /// Returns event-handler expression.
9109 Expr *getEventHandler() const { return getStmtAs<Expr>(); }
9110};
9111
9112/// This represents clause 'inclusive' in the '#pragma omp scan' directive.
9113///
9114/// \code
9115/// #pragma omp scan inclusive(a,b)
9116/// \endcode
9117/// In this example directive '#pragma omp scan' has clause 'inclusive'
9118/// with the variables 'a' and 'b'.
9119class OMPInclusiveClause final
9120 : public OMPVarListClause<OMPInclusiveClause>,
9121 private llvm::TrailingObjects<OMPInclusiveClause, Expr *> {
9122 friend class OMPClauseReader;
9123 friend OMPVarListClause;
9124 friend TrailingObjects;
9125
9126 /// Build clause with number of variables \a N.
9127 ///
9128 /// \param StartLoc Starting location of the clause.
9129 /// \param LParenLoc Location of '('.
9130 /// \param EndLoc Ending location of the clause.
9131 /// \param N Number of the variables in the clause.
9132 OMPInclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9133 SourceLocation EndLoc, unsigned N)
9134 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
9135 StartLoc, LParenLoc, EndLoc, N) {}
9136
9137 /// Build an empty clause.
9138 ///
9139 /// \param N Number of variables.
9140 explicit OMPInclusiveClause(unsigned N)
9141 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
9143 SourceLocation(), N) {}
9144
9145public:
9146 /// Creates clause with a list of variables \a VL.
9147 ///
9148 /// \param C AST context.
9149 /// \param StartLoc Starting location of the clause.
9150 /// \param LParenLoc Location of '('.
9151 /// \param EndLoc Ending location of the clause.
9152 /// \param VL List of references to the original variables.
9153 static OMPInclusiveClause *Create(const ASTContext &C,
9154 SourceLocation StartLoc,
9155 SourceLocation LParenLoc,
9156 SourceLocation EndLoc, ArrayRef<Expr *> VL);
9157
9158 /// Creates an empty clause with the place for \a N variables.
9159 ///
9160 /// \param C AST context.
9161 /// \param N The number of variables.
9162 static OMPInclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
9163
9165 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9166 reinterpret_cast<Stmt **>(varlist_end()));
9167 }
9168
9170 auto Children = const_cast<OMPInclusiveClause *>(this)->children();
9171 return const_child_range(Children.begin(), Children.end());
9172 }
9173
9180
9181 static bool classof(const OMPClause *T) {
9182 return T->getClauseKind() == llvm::omp::OMPC_inclusive;
9183 }
9184};
9185
9186/// This represents clause 'exclusive' in the '#pragma omp scan' directive.
9187///
9188/// \code
9189/// #pragma omp scan exclusive(a,b)
9190/// \endcode
9191/// In this example directive '#pragma omp scan' has clause 'exclusive'
9192/// with the variables 'a' and 'b'.
9193class OMPExclusiveClause final
9194 : public OMPVarListClause<OMPExclusiveClause>,
9195 private llvm::TrailingObjects<OMPExclusiveClause, Expr *> {
9196 friend class OMPClauseReader;
9197 friend OMPVarListClause;
9198 friend TrailingObjects;
9199
9200 /// Build clause with number of variables \a N.
9201 ///
9202 /// \param StartLoc Starting location of the clause.
9203 /// \param LParenLoc Location of '('.
9204 /// \param EndLoc Ending location of the clause.
9205 /// \param N Number of the variables in the clause.
9206 OMPExclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9207 SourceLocation EndLoc, unsigned N)
9208 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
9209 StartLoc, LParenLoc, EndLoc, N) {}
9210
9211 /// Build an empty clause.
9212 ///
9213 /// \param N Number of variables.
9214 explicit OMPExclusiveClause(unsigned N)
9215 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
9217 SourceLocation(), N) {}
9218
9219public:
9220 /// Creates clause with a list of variables \a VL.
9221 ///
9222 /// \param C AST context.
9223 /// \param StartLoc Starting location of the clause.
9224 /// \param LParenLoc Location of '('.
9225 /// \param EndLoc Ending location of the clause.
9226 /// \param VL List of references to the original variables.
9227 static OMPExclusiveClause *Create(const ASTContext &C,
9228 SourceLocation StartLoc,
9229 SourceLocation LParenLoc,
9230 SourceLocation EndLoc, ArrayRef<Expr *> VL);
9231
9232 /// Creates an empty clause with the place for \a N variables.
9233 ///
9234 /// \param C AST context.
9235 /// \param N The number of variables.
9236 static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
9237
9239 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9240 reinterpret_cast<Stmt **>(varlist_end()));
9241 }
9242
9244 auto Children = const_cast<OMPExclusiveClause *>(this)->children();
9245 return const_child_range(Children.begin(), Children.end());
9246 }
9247
9254
9255 static bool classof(const OMPClause *T) {
9256 return T->getClauseKind() == llvm::omp::OMPC_exclusive;
9257 }
9258};
9259
9260/// This represents clause 'uses_allocators' in the '#pragma omp target'-based
9261/// directives.
9262///
9263/// \code
9264/// #pragma omp target uses_allocators(default_allocator, my_allocator(traits))
9265/// \endcode
9266/// In this example directive '#pragma omp target' has clause 'uses_allocators'
9267/// with the allocators 'default_allocator' and user-defined 'my_allocator'.
9268class OMPUsesAllocatorsClause final
9269 : public OMPClause,
9270 private llvm::TrailingObjects<OMPUsesAllocatorsClause, Expr *,
9271 SourceLocation> {
9272public:
9273 /// Data for list of allocators.
9274 struct Data {
9275 /// Allocator.
9276 Expr *Allocator = nullptr;
9277 /// Allocator traits.
9279 /// Locations of '(' and ')' symbols.
9281 };
9282
9283private:
9284 friend class OMPClauseReader;
9285 friend TrailingObjects;
9286
9287 enum class ExprOffsets {
9288 Allocator,
9289 AllocatorTraits,
9290 Total,
9291 };
9292
9293 enum class ParenLocsOffsets {
9294 LParen,
9295 RParen,
9296 Total,
9297 };
9298
9299 /// Location of '('.
9300 SourceLocation LParenLoc;
9301 /// Total number of allocators in the clause.
9302 unsigned NumOfAllocators = 0;
9303
9304 /// Build clause.
9305 ///
9306 /// \param StartLoc Starting location of the clause.
9307 /// \param LParenLoc Location of '('.
9308 /// \param EndLoc Ending location of the clause.
9309 /// \param N Number of allocators associated with the clause.
9310 OMPUsesAllocatorsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9311 SourceLocation EndLoc, unsigned N)
9312 : OMPClause(llvm::omp::OMPC_uses_allocators, StartLoc, EndLoc),
9313 LParenLoc(LParenLoc), NumOfAllocators(N) {}
9314
9315 /// Build an empty clause.
9316 /// \param N Number of allocators associated with the clause.
9317 ///
9318 explicit OMPUsesAllocatorsClause(unsigned N)
9319 : OMPClause(llvm::omp::OMPC_uses_allocators, SourceLocation(),
9320 SourceLocation()),
9321 NumOfAllocators(N) {}
9322
9323 unsigned numTrailingObjects(OverloadToken<Expr *>) const {
9324 return NumOfAllocators * static_cast<int>(ExprOffsets::Total);
9325 }
9326
9327 /// Sets the location of '('.
9328 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9329
9330 /// Sets the allocators data for the clause.
9331 void setAllocatorsData(ArrayRef<OMPUsesAllocatorsClause::Data> Data);
9332
9333public:
9334 /// Creates clause with a list of allocators \p Data.
9335 ///
9336 /// \param C AST context.
9337 /// \param StartLoc Starting location of the clause.
9338 /// \param LParenLoc Location of '('.
9339 /// \param EndLoc Ending location of the clause.
9340 /// \param Data List of allocators.
9341 static OMPUsesAllocatorsClause *
9342 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
9343 SourceLocation EndLoc, ArrayRef<OMPUsesAllocatorsClause::Data> Data);
9344
9345 /// Creates an empty clause with the place for \p N allocators.
9346 ///
9347 /// \param C AST context.
9348 /// \param N The number of allocators.
9349 static OMPUsesAllocatorsClause *CreateEmpty(const ASTContext &C, unsigned N);
9350
9351 /// Returns the location of '('.
9352 SourceLocation getLParenLoc() const { return LParenLoc; }
9353
9354 /// Returns number of allocators associated with the clause.
9355 unsigned getNumberOfAllocators() const { return NumOfAllocators; }
9356
9357 /// Returns data for the specified allocator.
9359
9360 // Iterators
9362 Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
9363 return child_range(Begin, Begin + NumOfAllocators *
9364 static_cast<int>(ExprOffsets::Total));
9365 }
9367 Stmt *const *Begin =
9368 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
9369 return const_child_range(
9370 Begin, Begin + NumOfAllocators * static_cast<int>(ExprOffsets::Total));
9371 }
9372
9379
9380 static bool classof(const OMPClause *T) {
9381 return T->getClauseKind() == llvm::omp::OMPC_uses_allocators;
9382 }
9383};
9384
9385/// This represents clause 'affinity' in the '#pragma omp task'-based
9386/// directives.
9387///
9388/// \code
9389/// #pragma omp task affinity(iterator(i = 0:n) : ([3][n])a, b[:n], c[i])
9390/// \endcode
9391/// In this example directive '#pragma omp task' has clause 'affinity' with the
9392/// affinity modifer 'iterator(i = 0:n)' and locator items '([3][n])a', 'b[:n]'
9393/// and 'c[i]'.
9394class OMPAffinityClause final
9395 : public OMPVarListClause<OMPAffinityClause>,
9396 private llvm::TrailingObjects<OMPAffinityClause, Expr *> {
9397 friend class OMPClauseReader;
9398 friend OMPVarListClause;
9399 friend TrailingObjects;
9400
9401 /// Location of ':' symbol.
9402 SourceLocation ColonLoc;
9403
9404 /// Build clause.
9405 ///
9406 /// \param StartLoc Starting location of the clause.
9407 /// \param LParenLoc Location of '('.
9408 /// \param ColonLoc Location of ':'.
9409 /// \param EndLoc Ending location of the clause.
9410 /// \param N Number of locators associated with the clause.
9411 OMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9412 SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N)
9413 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, StartLoc,
9414 LParenLoc, EndLoc, N) {}
9415
9416 /// Build an empty clause.
9417 /// \param N Number of locators associated with the clause.
9418 ///
9419 explicit OMPAffinityClause(unsigned N)
9420 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity,
9422 SourceLocation(), N) {}
9423
9424 /// Sets the affinity modifier for the clause, if any.
9425 void setModifier(Expr *E) { getTrailingObjects()[varlist_size()] = E; }
9426
9427 /// Sets the location of ':' symbol.
9428 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
9429
9430public:
9431 /// Creates clause with a modifier a list of locator items.
9432 ///
9433 /// \param C AST context.
9434 /// \param StartLoc Starting location of the clause.
9435 /// \param LParenLoc Location of '('.
9436 /// \param ColonLoc Location of ':'.
9437 /// \param EndLoc Ending location of the clause.
9438 /// \param Locators List of locator items.
9439 static OMPAffinityClause *Create(const ASTContext &C, SourceLocation StartLoc,
9440 SourceLocation LParenLoc,
9441 SourceLocation ColonLoc,
9442 SourceLocation EndLoc, Expr *Modifier,
9443 ArrayRef<Expr *> Locators);
9444
9445 /// Creates an empty clause with the place for \p N locator items.
9446 ///
9447 /// \param C AST context.
9448 /// \param N The number of locator items.
9449 static OMPAffinityClause *CreateEmpty(const ASTContext &C, unsigned N);
9450
9451 /// Gets affinity modifier.
9452 Expr *getModifier() { return getTrailingObjects()[varlist_size()]; }
9453 Expr *getModifier() const { return getTrailingObjects()[varlist_size()]; }
9454
9455 /// Gets the location of ':' symbol.
9456 SourceLocation getColonLoc() const { return ColonLoc; }
9457
9458 // Iterators
9460 int Offset = getModifier() ? 1 : 0;
9461 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9462 reinterpret_cast<Stmt **>(varlist_end() + Offset));
9463 }
9464
9466 auto Children = const_cast<OMPAffinityClause *>(this)->children();
9467 return const_child_range(Children.begin(), Children.end());
9468 }
9469
9476
9477 static bool classof(const OMPClause *T) {
9478 return T->getClauseKind() == llvm::omp::OMPC_affinity;
9479 }
9480};
9481
9482/// This represents 'filter' clause in the '#pragma omp ...' directive.
9483///
9484/// \code
9485/// #pragma omp masked filter(tid)
9486/// \endcode
9487/// In this example directive '#pragma omp masked' has 'filter' clause with
9488/// thread id.
9490 : public OMPOneStmtClause<llvm::omp::OMPC_filter, OMPClause>,
9491 public OMPClauseWithPreInit {
9492 friend class OMPClauseReader;
9493
9494 /// Sets the thread identifier.
9495 void setThreadID(Expr *TID) { setStmt(TID); }
9496
9497public:
9498 /// Build 'filter' clause with thread-id \a ThreadID.
9499 ///
9500 /// \param ThreadID Thread identifier.
9501 /// \param HelperE Helper expression associated with this clause.
9502 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9503 /// clause must be captured.
9504 /// \param StartLoc Starting location of the clause.
9505 /// \param LParenLoc Location of '('.
9506 /// \param EndLoc Ending location of the clause.
9507 OMPFilterClause(Expr *ThreadID, Stmt *HelperE,
9508 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
9509 SourceLocation LParenLoc, SourceLocation EndLoc)
9510 : OMPOneStmtClause(ThreadID, StartLoc, LParenLoc, EndLoc),
9511 OMPClauseWithPreInit(this) {
9512 setPreInitStmt(HelperE, CaptureRegion);
9513 }
9514
9515 /// Build an empty clause.
9517
9518 /// Return thread identifier.
9519 Expr *getThreadID() const { return getStmtAs<Expr>(); }
9520
9521 /// Return thread identifier.
9523};
9524
9525/// This represents 'bind' clause in the '#pragma omp ...' directives.
9526///
9527/// \code
9528/// #pragma omp loop bind(parallel)
9529/// \endcode
9530class OMPBindClause final : public OMPNoChildClause<llvm::omp::OMPC_bind> {
9531 friend class OMPClauseReader;
9532
9533 /// Location of '('.
9534 SourceLocation LParenLoc;
9535
9536 /// The binding kind of 'bind' clause.
9538
9539 /// Start location of the kind in source code.
9540 SourceLocation KindLoc;
9541
9542 /// Sets the location of '('.
9543 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9544
9545 /// Set the binding kind.
9546 void setBindKind(OpenMPBindClauseKind K) { Kind = K; }
9547
9548 /// Set the binding kind location.
9549 void setBindKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
9550
9551 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9552 ///
9553 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9554 /// \param KLoc Starting location of the binding kind.
9555 /// \param StartLoc Starting location of the clause.
9556 /// \param LParenLoc Location of '('.
9557 /// \param EndLoc Ending location of the clause.
9558 OMPBindClause(OpenMPBindClauseKind K, SourceLocation KLoc,
9559 SourceLocation StartLoc, SourceLocation LParenLoc,
9560 SourceLocation EndLoc)
9561 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Kind(K),
9562 KindLoc(KLoc) {}
9563
9564 /// Build an empty clause.
9565 OMPBindClause() : OMPNoChildClause() {}
9566
9567public:
9568 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9569 ///
9570 /// \param C AST context
9571 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9572 /// \param KLoc Starting location of the binding kind.
9573 /// \param StartLoc Starting location of the clause.
9574 /// \param LParenLoc Location of '('.
9575 /// \param EndLoc Ending location of the clause.
9576 static OMPBindClause *Create(const ASTContext &C, OpenMPBindClauseKind K,
9577 SourceLocation KLoc, SourceLocation StartLoc,
9578 SourceLocation LParenLoc, SourceLocation EndLoc);
9579
9580 /// Build an empty 'bind' clause.
9581 ///
9582 /// \param C AST context
9583 static OMPBindClause *CreateEmpty(const ASTContext &C);
9584
9585 /// Returns the location of '('.
9586 SourceLocation getLParenLoc() const { return LParenLoc; }
9587
9588 /// Returns kind of the clause.
9589 OpenMPBindClauseKind getBindKind() const { return Kind; }
9590
9591 /// Returns location of clause kind.
9592 SourceLocation getBindKindLoc() const { return KindLoc; }
9593};
9594
9595/// This class implements a simple visitor for OMPClause
9596/// subclasses.
9597template<class ImplClass, template <typename> class Ptr, typename RetTy>
9599public:
9600#define PTR(CLASS) Ptr<CLASS>
9601#define DISPATCH(CLASS) \
9602 return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S))
9603
9604#define GEN_CLANG_CLAUSE_CLASS
9605#define CLAUSE_CLASS(Enum, Str, Class) \
9606 RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
9607#include "llvm/Frontend/OpenMP/OMP.inc"
9608
9609 RetTy Visit(PTR(OMPClause) S) {
9610 // Top switch clause: visit each OMPClause.
9611 switch (S->getClauseKind()) {
9612#define GEN_CLANG_CLAUSE_CLASS
9613#define CLAUSE_CLASS(Enum, Str, Class) \
9614 case llvm::omp::Clause::Enum: \
9615 return Visit##Class(static_cast<PTR(Class)>(S));
9616#define CLAUSE_NO_CLASS(Enum, Str) \
9617 case llvm::omp::Clause::Enum: \
9618 break;
9619#include "llvm/Frontend/OpenMP/OMP.inc"
9620 }
9621 }
9622 // Base case, ignore it. :)
9623 RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); }
9624#undef PTR
9625#undef DISPATCH
9626};
9627
9628template <typename T> using const_ptr = std::add_pointer_t<std::add_const_t<T>>;
9629
9630template <class ImplClass, typename RetTy = void>
9632 : public OMPClauseVisitorBase<ImplClass, std::add_pointer_t, RetTy> {};
9633template<class ImplClass, typename RetTy = void>
9635 public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {};
9636
9637class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
9638 raw_ostream &OS;
9639 const PrintingPolicy &Policy;
9640 unsigned Version;
9641
9642 /// Process clauses with list of variables.
9643 template <typename T> void VisitOMPClauseList(T *Node, char StartSym);
9644 /// Process motion clauses.
9645 template <typename T> void VisitOMPMotionClause(T *Node);
9646
9647public:
9648 OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy,
9649 unsigned OpenMPVersion)
9650 : OS(OS), Policy(Policy), Version(OpenMPVersion) {}
9651
9652#define GEN_CLANG_CLAUSE_CLASS
9653#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
9654#include "llvm/Frontend/OpenMP/OMP.inc"
9655};
9656
9658 llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
9659
9660 /// The raw string as we parsed it. This is needed for the `isa` trait set
9661 /// (which accepts anything) and (later) extensions.
9662 StringRef RawString;
9663};
9664
9667 llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
9669};
9670
9672 llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
9674};
9675
9676/// Helper data structure representing the traits in a match clause of an
9677/// `declare variant` or `metadirective`. The outer level is an ordered
9678/// collection of selector sets, each with an associated kind and an ordered
9679/// collection of selectors. A selector has a kind, an optional score/condition,
9680/// and an ordered collection of properties.
9681class OMPTraitInfo {
9682 /// Private constructor accesible only by ASTContext.
9683 OMPTraitInfo() {}
9684 friend class ASTContext;
9685
9686public:
9687 /// Reconstruct a (partial) OMPTraitInfo object from a mangled name.
9688 OMPTraitInfo(StringRef MangledName);
9689
9690 /// The outermost level of selector sets.
9692
9694 llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) {
9695 return llvm::any_of(Sets, [&](OMPTraitSet &Set) {
9696 return llvm::any_of(
9697 Set.Selectors, [&](OMPTraitSelector &Selector) {
9698 return Cond(Selector.ScoreOrCondition,
9699 /* IsScore */ Selector.Kind !=
9700 llvm::omp::TraitSelector::user_condition);
9701 });
9702 });
9703 }
9704
9705 /// Create a variant match info object from this trait info object. While the
9706 /// former is a flat representation the actual main difference is that the
9707 /// latter uses clang::Expr to store the score/condition while the former is
9708 /// independent of clang. Thus, expressions and conditions are evaluated in
9709 /// this method.
9710 void getAsVariantMatchInfo(ASTContext &ASTCtx,
9711 llvm::omp::VariantMatchInfo &VMI) const;
9712
9713 /// Return a string representation identifying this context selector.
9714 std::string getMangledName() const;
9715
9716 /// Check the extension trait \p TP is active.
9717 bool isExtensionActive(llvm::omp::TraitProperty TP) {
9718 for (const OMPTraitSet &Set : Sets) {
9719 if (Set.Kind != llvm::omp::TraitSet::implementation)
9720 continue;
9721 for (const OMPTraitSelector &Selector : Set.Selectors) {
9722 if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
9723 continue;
9724 for (const OMPTraitProperty &Property : Selector.Properties) {
9725 if (Property.Kind == TP)
9726 return true;
9727 }
9728 }
9729 }
9730 return false;
9731 }
9732
9733 /// Print a human readable representation into \p OS.
9734 void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
9735};
9736llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
9737llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
9738
9739/// Clang specific specialization of the OMPContext to lookup target features.
9742 std::function<void(StringRef)> &&DiagUnknownTrait,
9743 const FunctionDecl *CurrentFunctionDecl,
9744 ArrayRef<llvm::omp::TraitProperty> ConstructTraits,
9745 int DeviceNum);
9746
9747 virtual ~TargetOMPContext() = default;
9748
9749 /// See llvm::omp::OMPContext::matchesISATrait
9750 bool matchesISATrait(StringRef RawString) const override;
9751
9752private:
9753 std::function<bool(StringRef)> FeatureValidityCheck;
9754 std::function<void(StringRef)> DiagUnknownTrait;
9755 llvm::StringMap<bool> FeatureMap;
9756};
9757
9758/// Contains data for OpenMP directives: clauses, children
9759/// expressions/statements (helpers for codegen) and associated statement, if
9760/// any.
9761class OMPChildren final
9762 : private llvm::TrailingObjects<OMPChildren, OMPClause *, Stmt *> {
9763 friend TrailingObjects;
9764 friend class OMPClauseReader;
9766 template <typename T> friend class OMPDeclarativeDirective;
9767
9768 /// Numbers of clauses.
9769 unsigned NumClauses = 0;
9770 /// Number of child expressions/stmts.
9771 unsigned NumChildren = 0;
9772 /// true if the directive has associated statement.
9773 bool HasAssociatedStmt = false;
9774
9775 /// Define the sizes of each trailing object array except the last one. This
9776 /// is required for TrailingObjects to work properly.
9777 size_t numTrailingObjects(OverloadToken<OMPClause *>) const {
9778 return NumClauses;
9779 }
9780
9781 OMPChildren() = delete;
9782
9783 OMPChildren(unsigned NumClauses, unsigned NumChildren, bool HasAssociatedStmt)
9784 : NumClauses(NumClauses), NumChildren(NumChildren),
9785 HasAssociatedStmt(HasAssociatedStmt) {}
9786
9787 static size_t size(unsigned NumClauses, bool HasAssociatedStmt,
9788 unsigned NumChildren);
9789
9790 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses);
9791 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses, Stmt *S,
9792 unsigned NumChildren = 0);
9793 static OMPChildren *CreateEmpty(void *Mem, unsigned NumClauses,
9794 bool HasAssociatedStmt = false,
9795 unsigned NumChildren = 0);
9796
9797public:
9798 unsigned getNumClauses() const { return NumClauses; }
9799 unsigned getNumChildren() const { return NumChildren; }
9800 bool hasAssociatedStmt() const { return HasAssociatedStmt; }
9801
9802 /// Set associated statement.
9804 getTrailingObjects<Stmt *>()[NumChildren] = S;
9805 }
9806
9808
9809 /// Sets the list of variables for this clause.
9810 ///
9811 /// \param Clauses The list of clauses for the directive.
9812 ///
9813 void setClauses(ArrayRef<OMPClause *> Clauses);
9814
9815 /// Returns statement associated with the directive.
9816 const Stmt *getAssociatedStmt() const {
9817 return const_cast<OMPChildren *>(this)->getAssociatedStmt();
9818 }
9820 assert(HasAssociatedStmt &&
9821 "Expected directive with the associated statement.");
9822 return getTrailingObjects<Stmt *>()[NumChildren];
9823 }
9824
9825 /// Get the clauses storage.
9827 return getTrailingObjects<OMPClause *>(NumClauses);
9828 }
9830 return const_cast<OMPChildren *>(this)->getClauses();
9831 }
9832
9833 /// Returns the captured statement associated with the
9834 /// component region within the (combined) directive.
9835 ///
9836 /// \param RegionKind Component region kind.
9837 const CapturedStmt *
9839 ArrayRef<OpenMPDirectiveKind> CaptureRegions) const {
9840 assert(llvm::is_contained(CaptureRegions, RegionKind) &&
9841 "RegionKind not found in OpenMP CaptureRegions.");
9843 for (auto ThisCaptureRegion : CaptureRegions) {
9844 if (ThisCaptureRegion == RegionKind)
9845 return CS;
9846 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9847 }
9848 llvm_unreachable("Incorrect RegionKind specified for directive.");
9849 }
9850
9851 /// Get innermost captured statement for the construct.
9852 CapturedStmt *
9854 assert(hasAssociatedStmt() && "Must have associated captured statement.");
9855 assert(!CaptureRegions.empty() &&
9856 "At least one captured statement must be provided.");
9858 for (unsigned Level = CaptureRegions.size(); Level > 1; --Level)
9859 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9860 return CS;
9861 }
9862
9863 const CapturedStmt *
9865 return const_cast<OMPChildren *>(this)->getInnermostCapturedStmt(
9866 CaptureRegions);
9867 }
9868
9871 return const_cast<OMPChildren *>(this)->getChildren();
9872 }
9873
9875 assert(HasAssociatedStmt &&
9876 "Expected directive with the associated statement.");
9877 if (auto *CS = dyn_cast<CapturedStmt>(getAssociatedStmt())) {
9878 Stmt *S = nullptr;
9879 do {
9880 S = CS->getCapturedStmt();
9881 CS = dyn_cast<CapturedStmt>(S);
9882 } while (CS);
9883 return S;
9884 }
9885 return getAssociatedStmt();
9886 }
9887 const Stmt *getRawStmt() const {
9888 return const_cast<OMPChildren *>(this)->getRawStmt();
9889 }
9890
9892 if (!HasAssociatedStmt)
9894 return Stmt::child_range(&getTrailingObjects<Stmt *>()[NumChildren],
9895 &getTrailingObjects<Stmt *>()[NumChildren + 1]);
9896 }
9897};
9898
9899/// This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...'
9900/// directive.
9901///
9902/// \code
9903/// #pragma omp target [...] ompx_dyn_cgroup_mem(N)
9904/// \endcode
9906 : public OMPOneStmtClause<llvm::omp::OMPC_ompx_dyn_cgroup_mem, OMPClause>,
9907 public OMPClauseWithPreInit {
9908 friend class OMPClauseReader;
9909
9910 /// Set size.
9911 void setSize(Expr *E) { setStmt(E); }
9912
9913public:
9914 /// Build 'ompx_dyn_cgroup_mem' clause.
9915 ///
9916 /// \param Size Size expression.
9917 /// \param HelperSize Helper Size expression
9918 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9919 /// \param StartLoc Starting location of the clause.
9920 /// \param LParenLoc Location of '('.
9921 /// \param EndLoc Ending location of the clause.
9923 OpenMPDirectiveKind CaptureRegion,
9924 SourceLocation StartLoc, SourceLocation LParenLoc,
9925 SourceLocation EndLoc)
9926 : OMPOneStmtClause(Size, StartLoc, LParenLoc, EndLoc),
9927 OMPClauseWithPreInit(this) {
9928 setPreInitStmt(HelperSize, CaptureRegion);
9929 }
9930
9931 /// Build an empty clause.
9933
9934 /// Return the size expression.
9936
9937 /// Return the size expression.
9938 Expr *getSize() const { return getStmtAs<Expr>(); }
9939};
9940
9941/// This represents the 'doacross' clause for the '#pragma omp ordered'
9942/// directive.
9943///
9944/// \code
9945/// #pragma omp ordered doacross(sink: i-1, j-1)
9946/// \endcode
9947/// In this example directive '#pragma omp ordered' with clause 'doacross' with
9948/// a dependence-type 'sink' and loop-iteration vector expressions i-1 and j-1.
9949class OMPDoacrossClause final
9950 : public OMPVarListClause<OMPDoacrossClause>,
9951 private llvm::TrailingObjects<OMPDoacrossClause, Expr *> {
9952 friend class OMPClauseReader;
9953 friend OMPVarListClause;
9954 friend TrailingObjects;
9955
9956 /// Dependence type (sink or source).
9958
9959 /// Dependence type location.
9960 SourceLocation DepLoc;
9961
9962 /// Colon location.
9963 SourceLocation ColonLoc;
9964
9965 /// Number of loops, associated with the doacross clause.
9966 unsigned NumLoops = 0;
9967
9968 /// Build clause with number of expressions \a N.
9969 ///
9970 /// \param StartLoc Starting location of the clause.
9971 /// \param LParenLoc Location of '('.
9972 /// \param EndLoc Ending location of the clause.
9973 /// \param N Number of expressions in the clause.
9974 /// \param NumLoops Number of loops associated with the clause.
9975 OMPDoacrossClause(SourceLocation StartLoc, SourceLocation LParenLoc,
9976 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
9977 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross, StartLoc,
9978 LParenLoc, EndLoc, N),
9979 NumLoops(NumLoops) {}
9980
9981 /// Build an empty clause.
9982 ///
9983 /// \param N Number of expressions in the clause.
9984 /// \param NumLoops Number of loops associated with the clause.
9985 explicit OMPDoacrossClause(unsigned N, unsigned NumLoops)
9986 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross,
9988 SourceLocation(), N),
9989 NumLoops(NumLoops) {}
9990
9991 /// Set dependence type.
9992 void setDependenceType(OpenMPDoacrossClauseModifier M) { DepType = M; }
9993
9994 /// Set dependence type location.
9995 void setDependenceLoc(SourceLocation Loc) { DepLoc = Loc; }
9996
9997 /// Set colon location.
9998 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
9999
10000public:
10001 /// Creates clause with a list of expressions \a VL.
10002 ///
10003 /// \param C AST context.
10004 /// \param StartLoc Starting location of the clause.
10005 /// \param LParenLoc Location of '('.
10006 /// \param EndLoc Ending location of the clause.
10007 /// \param DepType The dependence type.
10008 /// \param DepLoc Location of the dependence type.
10009 /// \param ColonLoc Location of ':'.
10010 /// \param VL List of references to the expressions.
10011 /// \param NumLoops Number of loops that associated with the clause.
10012 static OMPDoacrossClause *
10013 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
10014 SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType,
10015 SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
10016 unsigned NumLoops);
10017
10018 /// Creates an empty clause with \a N expressions.
10019 ///
10020 /// \param C AST context.
10021 /// \param N The number of expressions.
10022 /// \param NumLoops Number of loops that is associated with this clause.
10023 static OMPDoacrossClause *CreateEmpty(const ASTContext &C, unsigned N,
10024 unsigned NumLoops);
10025
10026 /// Get dependence type.
10028
10029 /// Get dependence type location.
10030 SourceLocation getDependenceLoc() const { return DepLoc; }
10031
10032 /// Get colon location.
10033 SourceLocation getColonLoc() const { return ColonLoc; }
10034
10035 /// Get number of loops associated with the clause.
10036 unsigned getNumLoops() const { return NumLoops; }
10037
10038 /// Set the loop data.
10039 void setLoopData(unsigned NumLoop, Expr *Cnt);
10040
10041 /// Get the loop data.
10042 Expr *getLoopData(unsigned NumLoop);
10043 const Expr *getLoopData(unsigned NumLoop) const;
10044
10046 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
10047 reinterpret_cast<Stmt **>(varlist_end()));
10048 }
10049
10051 auto Children = const_cast<OMPDoacrossClause *>(this)->children();
10052 return const_child_range(Children.begin(), Children.end());
10053 }
10054
10061
10062 static bool classof(const OMPClause *T) {
10063 return T->getClauseKind() == llvm::omp::OMPC_doacross;
10064 }
10065};
10066
10067/// This represents 'ompx_attribute' clause in a directive that might generate
10068/// an outlined function. An example is given below.
10069///
10070/// \code
10071/// #pragma omp target [...] ompx_attribute(flatten)
10072/// \endcode
10074 : public OMPNoChildClause<llvm::omp::OMPC_ompx_attribute> {
10075 friend class OMPClauseReader;
10076
10077 /// Location of '('.
10078 SourceLocation LParenLoc;
10079
10080 /// The parsed attributes (clause arguments)
10082
10083public:
10084 /// Build 'ompx_attribute' clause.
10085 ///
10086 /// \param Attrs The parsed attributes (clause arguments)
10087 /// \param StartLoc Starting location of the clause.
10088 /// \param LParenLoc Location of '('.
10089 /// \param EndLoc Ending location of the clause.
10091 SourceLocation LParenLoc, SourceLocation EndLoc)
10092 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Attrs(Attrs) {
10093 }
10094
10095 /// Build an empty clause.
10097
10098 /// Sets the location of '('.
10099 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
10100
10101 /// Returns the location of '('.
10102 SourceLocation getLParenLoc() const { return LParenLoc; }
10103
10104 /// Returned the attributes parsed from this clause.
10105 ArrayRef<const Attr *> getAttrs() const { return Attrs; }
10106
10107private:
10108 /// Replace the attributes with \p NewAttrs.
10109 void setAttrs(ArrayRef<Attr *> NewAttrs) {
10110 Attrs.clear();
10111 Attrs.append(NewAttrs.begin(), NewAttrs.end());
10112 }
10113};
10114
10115/// This represents 'ompx_bare' clause in the '#pragma omp target teams ...'
10116/// directive.
10117///
10118/// \code
10119/// #pragma omp target teams ompx_bare
10120/// \endcode
10121/// In this example directive '#pragma omp target teams' has a 'ompx_bare'
10122/// clause.
10123class OMPXBareClause : public OMPNoChildClause<llvm::omp::OMPC_ompx_bare> {
10124public:
10125 /// Build 'ompx_bare' clause.
10126 ///
10127 /// \param StartLoc Starting location of the clause.
10128 /// \param EndLoc Ending location of the clause.
10130 : OMPNoChildClause(StartLoc, EndLoc) {}
10131
10132 /// Build an empty clause.
10133 OMPXBareClause() = default;
10134};
10135
10136} // namespace clang
10137
10138#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:1999
A C++ nested-name-specifier augmented with source location information.
static OMPAbsentClause * CreateEmpty(const ASTContext &C, unsigned NumKinds)
static bool classof(const OMPClause *C)
static bool classof(const OMPClause *T)
OMPAcqRelClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'ack_rel' clause.
const_child_range used_children() const
child_range used_children()
const_child_range children() const
OMPAcqRelClause()
Build an empty clause.
static bool classof(const OMPClause *T)
const_child_range children() const
OMPAcquireClause()
Build an empty clause.
child_range used_children()
const_child_range used_children() const
OMPAcquireClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'acquire' clause.
This represents clause 'affinity' in the 'pragma omp task'-based directives.
Expr * getModifier()
Gets affinity modifier.
const_child_range children() const
static OMPAffinityClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N locator items.
SourceLocation getColonLoc() const
Gets the location of ':' symbol.
const_child_range used_children() const
static bool classof(const OMPClause *T)
This represents the 'align' clause in the 'pragma omp allocate' directive.
friend class OMPClauseReader
Expr * getAlignment() const
Returns alignment.
This represents clause 'aligned' in the 'pragma omp ...' directives.
Expr * getAlignment()
Returns alignment.
const Expr * getAlignment() const
Returns alignment.
void setColonLoc(SourceLocation Loc)
Sets the location of ':'.
const_child_range used_children() const
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
const_child_range children() const
SourceLocation getColonLoc() const
Returns the location of ':'.
static bool classof(const OMPClause *T)
child_range used_children()
This represents clause 'allocate' in the 'pragma omp ...' directives.
const_child_range children() const
SourceLocation getAllocatorModifierLoc() const
Return the location of the modifier.
const_child_range used_children() const
OpenMPAllocateClauseModifier getAllocatorModifier() const
Return 'allocate' modifier.
OpenMPAllocateClauseModifier getSecondAllocateModifier() const
Get the second modifier of the clause.
SourceLocation getColonLoc() const
Returns the location of the ':' delimiter.
Expr * getAlignment() const
Returns the alignment expression or nullptr, if no alignment specified.
OpenMPAllocateClauseModifier getFirstAllocateModifier() const
Get the first modifier of the clause.
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
SourceLocation getSecondAllocateModifierLoc() const
Get location of second modifier of the clause.
child_range used_children()
SourceLocation getFirstAllocateModifierLoc() const
Get location of first modifier of the clause.
static OMPAllocateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static bool classof(const OMPClause *T)
OMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'allocator' clause with the given allocator.
OMPAllocatorClause()
Build an empty clause.
Expr * getAllocator() const
Returns allocator.
friend class OMPClauseReader
OMPAtClause(OpenMPAtClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'at' clause with argument A ('compilation' or 'execution').
SourceLocation getAtKindKwLoc() const
Returns location of clause kind.
child_range children()
static bool classof(const OMPClause *T)
OpenMPAtClauseKind getAtKind() const
Returns kind of the clause.
const_child_range used_children() const
child_range used_children()
SourceLocation getLParenLoc() const
Returns the locaiton of '('.
OMPAtClause()
Build an empty clause.
const_child_range children() const
const_child_range used_children() const
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the locaiton of '('.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const
Returns kind of the clause.
OMPAtomicDefaultMemOrderClause(OpenMPAtomicDefaultMemOrderClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'atomic_default_mem_order' clause with argument A ('seq_cst', 'acq_rel' or 'relaxed').
const_child_range children() const
OMPAtomicDefaultMemOrderClause()
Build an empty clause.
SourceLocation getAtomicDefaultMemOrderKindKwLoc() const
Returns location of clause kind.
OpenMPBindClauseKind getBindKind() const
Returns kind of the clause.
friend class OMPClauseReader
SourceLocation getLParenLoc() const
Returns the location of '('.
SourceLocation getBindKindLoc() const
Returns location of clause kind.
static OMPBindClause * CreateEmpty(const ASTContext &C)
Build an empty 'bind' clause.
OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'capture' clause.
const_child_range used_children() const
child_range used_children()
const_child_range children() const
static bool classof(const OMPClause *T)
OMPCaptureClause()
Build an empty clause.
Contains data for OpenMP directives: clauses, children expressions/statements (helpers for codegen) a...
unsigned getNumClauses() const
const CapturedStmt * getCapturedStmt(OpenMPDirectiveKind RegionKind, ArrayRef< OpenMPDirectiveKind > CaptureRegions) const
Returns the captured statement associated with the component region within the (combined) directive.
friend class OMPClauseReader
bool hasAssociatedStmt() const
Stmt::child_range getAssociatedStmtAsRange()
void setClauses(ArrayRef< OMPClause * > Clauses)
Sets the list of variables for this clause.
friend class OMPDeclarativeDirective
unsigned getNumChildren() const
const Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
void setChildren(ArrayRef< Stmt * > Children)
ArrayRef< Stmt * > getChildren() const
MutableArrayRef< OMPClause * > getClauses()
Get the clauses storage.
friend class OMPExecutableDirective
MutableArrayRef< Stmt * > getChildren()
const Stmt * getRawStmt() const
void setAssociatedStmt(Stmt *S)
Set associated statement.
CapturedStmt * getInnermostCapturedStmt(ArrayRef< OpenMPDirectiveKind > CaptureRegions)
Get innermost captured statement for the construct.
ArrayRef< OMPClause * > getClauses() const
const CapturedStmt * getInnermostCapturedStmt(ArrayRef< OpenMPDirectiveKind > CaptureRegions) const
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.
OMPNowaitClause(SourceLocation StartLoc=SourceLocation(), SourceLocation EndLoc=SourceLocation())
Build 'nowait' clause.
const_child_range children() const
Expr * getNumTasks() const
Return safe iteration space distance.
SourceLocation getModifierLoc() const
Gets modifier location.
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *Size, Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build 'num_tasks' clause.
static bool classof(const OMPClause *T)
const_child_range used_children() const
OMPNumTasksClause()
Build an empty clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OpenMPNumTasksClauseModifier getModifier() const
Gets modifier.
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range children() const
const_child_range used_children() const
static bool classof(const OMPClause *T)
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
ArrayRef< Expr * > getNumTeams() const
Return NumTeams expressions.
static OMPNumTeamsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
ArrayRef< Expr * > getNumTeams()
Return NumTeams expressions.
OpenMPNumThreadsClauseModifier getModifier() const
Gets modifier.
SourceLocation getModifierLoc() const
Gets modifier location.
OMPNumThreadsClause()
Build an empty clause.
OMPNumThreadsClause(OpenMPNumThreadsClauseModifier Modifier, Expr *NumThreads, Stmt *HelperNumThreads, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build 'num_threads' clause with condition NumThreads.
Expr * getNumThreads() const
Returns number of threads.
const_child_range used_children() const
child_range used_children()
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OMPOneStmtClause(Stmt *S, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static bool classof(const OMPClause *T)
ConstStmtIterator const_child_iterator
const_child_range children() const
StmtIterator child_iterator
llvm::iterator_range< child_iterator > child_range
SourceLocation getLParenLoc() const
Returns the location of '('.
llvm::iterator_range< const_child_iterator > const_child_range
T * getStmtAs() const
Return the associated statement, potentially casted to T.
OMPOrderClause(OpenMPOrderClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPOrderClauseModifier Modifier, SourceLocation MLoc)
Build 'order' clause with argument A ('concurrent').
friend class OMPClauseReader
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range children() const
const_child_range used_children() const
SourceLocation getKindKwLoc() const
Returns location of clause kind.
static bool classof(const OMPClause *T)
SourceLocation getModifierKwLoc() const
Returns location of clause modifier.
OpenMPOrderClauseKind getKind() const
Returns kind of the clause.
child_range used_children()
OMPOrderClause()
Build an empty clause.
OpenMPOrderClauseModifier getModifier() const
Returns Modifier of the clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
This represents 'ordered' clause in the 'pragma omp ...' directive.
const_child_range children() const
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
static bool classof(const OMPClause *T)
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Expr * getNumForLoops() const
Return the number of associated for-loops.
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range used_children() const
ArrayRef< Expr * > getLoopNumIterations() const
Get number of iterations for all the loops.
child_range used_children()
static OMPOrderedClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty clause.
Expr * getLoopCounter(unsigned NumLoop)
Get loops counter for the specified loop.
child_range used_children()
static OMPPartialClause * CreateEmpty(const ASTContext &C)
Build an empty 'partial' AST node for deserialization.
const_child_range used_children() const
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range children() const
static bool classof(const OMPClause *T)
Expr * getFactor() const
Returns the argument of the clause or nullptr if not set.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
static bool classof(const OMPClause *T)
ArrayRef< Expr * > getArgsRefs() const
unsigned getNumLoops() const
Returns the number of list items.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
SourceLocation getLParenLoc() const
Returns the location of '('.
MutableArrayRef< Expr * > getArgsRefs()
Returns the permutation index expressions.
static OMPPermutationClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty 'permutation' AST node for deserialization.
const_child_range used_children() const
const_child_range children() const
OMPPriorityClause(Expr *Priority, Stmt *HelperPriority, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'priority' clause.
Expr * getPriority() const
Return Priority number.
const_child_range used_children() const
static bool classof(const OMPClause *T)
const_child_range children() const
OMPPriorityClause()
Build an empty clause.
SourceLocation getLParenLoc() const
Returns the location of '('.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Expr * getPriority()
Return Priority number.
This represents clause 'private' in the 'pragma omp ...' directives.
const_child_range children() const
private_copies_range private_copies()
static bool classof(const OMPClause *T)
const_child_range used_children() const
child_range used_children()
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
llvm::iterator_range< private_copies_iterator > private_copies_range
ArrayRef< const Expr * >::iterator private_copies_const_iterator
private_copies_const_range private_copies() const
MutableArrayRef< Expr * >::iterator private_copies_iterator
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
const_child_range used_children() const
SourceLocation getProcBindKindKwLoc() const
Returns location of clause kind.
const_child_range children() const
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPProcBindClause()
Build an empty clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'proc_bind' clause with argument A ('master', 'close' or 'spread').
llvm::omp::ProcBindKind getProcBindKind() const
Returns kind of the clause.
static bool classof(const OMPClause *T)
child_range children()
static bool classof(const OMPClause *T)
child_range used_children()
const_child_range children() const
const_child_range used_children() const
OMPReadClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'read' clause.
OMPReadClause()
Build an empty clause.
This represents clause 'reduction' in the 'pragma omp ...' directives.
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
OpenMPOriginalSharingModifier getOriginalSharingModifier() const
Returns Original Sharing Modifier.
MutableArrayRef< Expr * >::iterator helper_expr_iterator
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
helper_expr_const_range rhs_exprs() const
llvm::iterator_range< helper_expr_iterator > helper_expr_range
helper_expr_const_range lhs_exprs() const
helper_expr_range copy_array_temps()
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N, OpenMPReductionClauseModifier Modifier)
Creates an empty clause with the place for N variables.
helper_expr_range rhs_exprs()
helper_expr_range copy_array_elems()
helper_expr_range lhs_exprs()
helper_expr_const_range copy_array_temps() const
const_child_range used_children() const
helper_expr_const_range reduction_ops() const
helper_expr_range privates()
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
ArrayRef< bool >::iterator helper_flag_const_iterator
helper_expr_const_range privates() const
MutableArrayRef< bool >::iterator helper_flag_iterator
llvm::iterator_range< helper_flag_const_iterator > helper_flag_const_range
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
static bool classof(const OMPClause *T)
helper_expr_const_range copy_array_elems() const
helper_expr_const_range copy_ops() const
helper_flag_const_range private_var_reduction_flags() const
OpenMPReductionClauseModifier getModifier() const
Returns modifier.
SourceLocation getModifierLoc() const
Returns modifier location.
helper_expr_range copy_ops()
const_child_range children() const
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
llvm::iterator_range< helper_flag_iterator > helper_flag_range
helper_expr_range reduction_ops()
helper_flag_range private_var_reduction_flags()
static bool classof(const OMPClause *T)
const_child_range used_children() const
child_range used_children()
OMPRelaxedClause()
Build an empty clause.
const_child_range children() const
OMPRelaxedClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'relaxed' clause.
const_child_range children() const
child_range used_children()
OMPReleaseClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'release' clause.
OMPReleaseClause()
Build an empty clause.
static bool classof(const OMPClause *T)
const_child_range used_children() const
const_child_range children() const
const_child_range used_children() const
OMPReverseOffloadClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'reverse_offload' clause.
static bool classof(const OMPClause *T)
OMPReverseOffloadClause()
Build an empty clause.
OMPSIMDClause()
Build an empty clause.
const_child_range children() const
const_child_range used_children() const
child_range used_children()
child_range children()
static bool classof(const OMPClause *T)
OMPSIMDClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'simd' clause.
friend class OMPClauseReader
OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'safelen' clause.
Expr * getSafelen() const
Return safe iteration space distance.
OMPSafelenClause()
Build an empty clause.
static bool classof(const OMPClause *T)
SourceLocation getFirstScheduleModifierLoc() const
Get the first modifier location.
OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KLoc, SourceLocation CommaLoc, SourceLocation EndLoc, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, Stmt *HelperChunkSize, OpenMPScheduleClauseModifier M1, SourceLocation M1Loc, OpenMPScheduleClauseModifier M2, SourceLocation M2Loc)
Build 'schedule' clause with schedule kind Kind and chunk size expression ChunkSize.
SourceLocation getScheduleKindLoc()
Get kind location.
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
SourceLocation getLParenLoc()
Get location of '('.
const Expr * getChunkSize() const
Get chunk size.
OMPScheduleClause()
Build an empty clause.
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
SourceLocation getCommaLoc()
Get location of ','.
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
SourceLocation getSecondScheduleModifierLoc() const
Get the second modifier location.
const_child_range children() const
const_child_range used_children() const
Expr * getChunkSize()
Get chunk size.
static bool classof(const OMPClause *T)
OMPSelfMapsClause()
Build an empty clause.
OMPSelfMapsClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'self_maps' clause.
const_child_range used_children() const
const_child_range children() const
OMPSeqCstClause()
Build an empty clause.
const_child_range used_children() const
OMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'seq_cst' clause.
child_range used_children()
const_child_range children() const
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the locaiton of '('.
const_child_range children() const
static bool classof(const OMPClause *T)
OMPSeverityClause()
Build an empty clause.
OMPSeverityClause(OpenMPSeverityClauseKind A, SourceLocation ALoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'severity' clause with argument A ('fatal' or 'warning').
OpenMPSeverityClauseKind getSeverityKind() const
Returns kind of the clause.
const_child_range used_children() const
SourceLocation getSeverityKindKwLoc() const
Returns location of clause kind.
child_range used_children()
const_child_range used_children() const
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
const_child_range children() const
static bool classof(const OMPClause *T)
friend class OMPClauseReader
OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'simdlen' clause.
Expr * getSimdlen() const
Return safe iteration space distance.
OMPSimdlenClause()
Build an empty clause.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
SourceLocation getLParenLoc() const
Returns the location of '('.
friend class OMPClauseReader
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
static bool classof(const OMPClause *T)
const_child_range used_children() const
void setSizesRefs(ArrayRef< Expr * > VL)
Sets the tile size expressions.
unsigned getNumSizes() const
Returns the number of list items.
child_range used_children()
MutableArrayRef< Expr * > getSizesRefs()
Returns the tile size expressions.
ArrayRef< Expr * > getSizesRefs() const
const_child_range children() const
static OMPSizesClause * CreateEmpty(const ASTContext &C, unsigned NumSizes)
Build an empty 'sizes' AST node for deserialization.
This represents clause 'task_reduction' in the 'pragma omp taskgroup' directives.
helper_expr_const_range rhs_exprs() const
llvm::iterator_range< helper_expr_iterator > helper_expr_range
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
helper_expr_const_range lhs_exprs() const
const_child_range used_children() const
helper_expr_const_range reduction_ops() const
helper_expr_range privates()
const_child_range children() const
SourceLocation getColonLoc() const
Gets location of ':' symbol in clause.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
ArrayRef< const Expr * >::iterator helper_expr_const_iterator
MutableArrayRef< Expr * >::iterator helper_expr_iterator
llvm::iterator_range< helper_expr_const_iterator > helper_expr_const_range
helper_expr_range rhs_exprs()
helper_expr_range lhs_exprs()
helper_expr_range reduction_ops()
helper_expr_const_range privates() const
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static bool classof(const OMPClause *T)
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
ArrayRef< Expr * > getThreadLimit()
Return ThreadLimit expressions.
const_child_range children() const
ArrayRef< Expr * > getThreadLimit() const
Return ThreadLimit expressions.
SourceLocation getLParenLoc() const
Returns the location of '('.
static OMPThreadLimitClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
const_child_range used_children() const
static bool classof(const OMPClause *T)
OMPThreadsClause()
Build an empty clause.
OMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'threads' clause.
This represents clause 'to' in the 'pragma omp ...' directives.
friend class OMPClauseReader
static OMPToClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
const_child_range used_children() const
SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY
Fetches the motion-modifier location at 'Cnt' index of array of modifiers' locations.
ArrayRef< OpenMPMotionModifierKind > getMotionModifiers() const LLVM_READONLY
Fetches ArrayRef of motion-modifiers.
child_range children()
ArrayRef< SourceLocation > getMotionModifiersLoc() const LLVM_READONLY
Fetches ArrayRef of location of motion-modifiers.
const_child_range children() const
SourceLocation getColonLoc() const
Get colon location.
static bool classof(const OMPClause *T)
child_range used_children()
OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY
Fetches the motion-modifier at 'Cnt' index of array of modifiers.
bool isExtensionActive(llvm::omp::TraitProperty TP)
Check the extension trait TP is active.
bool anyScoreOrCondition(llvm::function_ref< bool(Expr *&, bool)> Cond)
std::string getMangledName() const
Return a string representation identifying this context selector.
friend class ASTContext
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Print a human readable representation into OS.
void getAsVariantMatchInfo(ASTContext &ASTCtx, llvm::omp::VariantMatchInfo &VMI) const
Create a variant match info object from this trait info object.
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
OMPUnifiedAddressClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'unified_address' clause.
OMPUnifiedAddressClause()
Build an empty clause.
OMPUnifiedSharedMemoryClause()
Build an empty clause.
static bool classof(const OMPClause *T)
const_child_range children() const
OMPUnifiedSharedMemoryClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'unified_shared_memory' clause.
const_child_range used_children() const
child_range used_children()
OMPUntiedClause()
Build an empty clause.
OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'untied' clause.
static bool classof(const OMPClause *T)
const_child_range used_children() const
const_child_range children() const
friend class OMPClauseReader
const_child_range used_children() const
const_child_range children() const
OpenMPDependClauseKind getDependencyKind() const
Gets the dependence kind in clause for 'depobj' directive.
static OMPUpdateClause * CreateEmpty(const ASTContext &C, bool IsExtended)
Creates an empty clause with the place for N variables.
child_range used_children()
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Gets the location of '(' in clause for 'depobj' directive.
SourceLocation getArgumentLoc() const
Gets the location of argument in clause for 'depobj' directive.
bool isExtended() const
Checks if the clause is the extended clauses for 'depobj' directive.
friend class OMPClauseReader
child_range used_children()
child_range children()
SourceLocation getVarLoc() const
Returns the location of the interop variable.
OMPUseClause()
Build an empty clause.
const_child_range used_children() const
const_child_range children() const
OMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build 'use' clause with and interop variable expression InteropVar.
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the location of '('.
Expr * getInteropVar() const
Returns the interop variable.
This represents clause 'use_device_addr' in the 'pragma omp ...' directives.
const_child_range used_children() const
static bool classof(const OMPClause *T)
const_child_range children() const
static OMPUseDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'use_device_ptr' in the 'pragma omp ...' directives.
ArrayRef< const Expr * >::iterator private_copies_const_iterator
llvm::iterator_range< private_copies_const_iterator > private_copies_const_range
private_copies_const_range private_copies() const
const_child_range used_children() const
const_child_range children() const
llvm::iterator_range< inits_iterator > inits_range
MutableArrayRef< Expr * >::iterator inits_iterator
inits_const_range inits() const
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
ArrayRef< const Expr * >::iterator inits_const_iterator
static bool classof(const OMPClause *T)
MutableArrayRef< Expr * >::iterator private_copies_iterator
private_copies_range private_copies()
llvm::iterator_range< inits_const_iterator > inits_const_range
llvm::iterator_range< private_copies_iterator > private_copies_range
static bool classof(const OMPClause *T)
SourceLocation getLParenLoc() const
Returns the location of '('.
const_child_range children() const
OMPUsesAllocatorsClause::Data getAllocatorData(unsigned I) const
Returns data for the specified allocator.
static OMPUsesAllocatorsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N allocators.
unsigned getNumberOfAllocators() const
Returns number of allocators associated with the clause.
const_child_range used_children() const
This represents clauses with the list of variables like 'private', 'firstprivate',...
varlist_const_range varlist() const
friend class OMPClauseReader
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
ArrayRef< const Expr * > getVarRefs() const
Fetches list of all variables in the clause.
OMPVarListClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
Build a clause with N variables.
MutableArrayRef< Expr * > getVarRefs()
Fetches list of variables associated with this clause.
varlist_range varlist()
varlist_const_iterator varlist_end() const
varlist_iterator varlist_end()
llvm::iterator_range< varlist_const_iterator > varlist_const_range
MutableArrayRef< Expr * >::iterator varlist_iterator
varlist_iterator varlist_begin()
ArrayRef< const Expr * >::iterator varlist_const_iterator
SourceLocation getLParenLoc() const
Returns the location of '('.
unsigned varlist_size() const
varlist_const_iterator varlist_begin() const
llvm::iterator_range< varlist_iterator > varlist_range
void setVarRefs(ArrayRef< Expr * > VL)
Sets the list of variables for this clause.
const_child_range used_children() const
OMPWeakClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'weak' clause.
static bool classof(const OMPClause *T)
child_range used_children()
OMPWeakClause()
Build an empty clause.
const_child_range children() const
child_range children()
OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'write' clause.
const_child_range used_children() const
child_range used_children()
static bool classof(const OMPClause *T)
const_child_range children() const
OMPWriteClause()
Build an empty clause.
ArrayRef< const Attr * > getAttrs() const
Returned the attributes parsed from this clause.
OMPXAttributeClause()
Build an empty clause.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'ompx_attribute' clause.
OMPXBareClause()=default
Build an empty clause.
OMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'ompx_bare' clause.
OMPXDynCGroupMemClause(Expr *Size, Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'ompx_dyn_cgroup_mem' clause.
Expr * getSize()
Return the size expression.
Expr * getSize() const
Return the size expression.
OMPXDynCGroupMemClause()
Build an empty clause.
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:711
#define bool
Definition gpuintrin.h:32
Definition SPIR.cpp:35
The JSON file list parser is used to communicate input to InstallAPI.
OpenMPOriginalSharingModifier
OpenMP 6.0 original sharing modifiers.
bool checkFailClauseParameter(OpenMPClauseKind FailClauseParameter)
Checks if the parameter to the fail clause in "#pragma atomic compare fail" is restricted only to mem...
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
@ OMPC_DEFAULTMAP_MODIFIER_unknown
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
@ OMPC_ORDER_MODIFIER_unknown
std::add_pointer_t< std::add_const_t< T > > const_ptr
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
@ OMPC_AT_unknown
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
@ OMPC_REDUCTION_unknown
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition OpenMPKinds.h:39
@ OMPC_SCHEDULE_MODIFIER_unknown
Definition OpenMPKinds.h:40
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
@ OMPC_DIST_SCHEDULE_unknown
Expr * Cond
};
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
@ OMPC_DOACROSS_unknown
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
Definition OpenMPKinds.h:88
@ Property
The type of a property.
Definition TypeBase.h:911
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
@ OMPC_BIND_unknown
const FunctionProtoType * T
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition OpenMPKinds.h:55
@ OMPC_DEPEND_unknown
Definition OpenMPKinds.h:59
OpenMPGrainsizeClauseModifier
@ OMPC_GRAINSIZE_unknown
OpenMPNumTasksClauseModifier
@ OMPC_NUMTASKS_unknown
@ Type
The name was classified as a type.
Definition Sema.h:561
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
@ OMPC_SEVERITY_unknown
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
OpenMPMotionModifierKind
OpenMP modifier kind for 'to' or 'from' clause.
Definition OpenMPKinds.h:92
@ OMPC_MOTION_MODIFIER_unknown
Definition OpenMPKinds.h:96
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
@ OMPC_DEFAULTMAP_unknown
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
@ OMPC_ALLOCATE_unknown
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition OpenMPKinds.h:63
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition OpenMPKinds.h:25
OpenMPNumThreadsClauseModifier
@ OMPC_NUMTHREADS_unknown
OpenMPAtomicDefaultMemOrderClauseKind
OpenMP attributes for 'atomic_default_mem_order' clause.
@ OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
U cast(CodeGen::Address addr)
Definition Address.h:327
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition OpenMPKinds.h:48
@ OMPC_DEVICE_unknown
Definition OpenMPKinds.h:51
OpenMPMapModifierKind
OpenMP modifier kind for 'map' clause.
Definition OpenMPKinds.h:79
@ OMPC_MAP_MODIFIER_unknown
Definition OpenMPKinds.h:80
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
Definition OpenMPKinds.h:28
@ Other
Other implicit parameter.
Definition Decl.h:1745
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
@ OMPC_ORDER_unknown
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition OpenMPKinds.h:31
@ OMPC_SCHEDULE_unknown
Definition OpenMPKinds.h:35
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition OpenMPKinds.h:71
@ OMPC_MAP_unknown
Definition OpenMPKinds.h:75
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
int const char * function
Definition c++config.h:31
#define true
Definition stdbool.h:25
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation OmpAllMemoryLoc
Location of 'omp_all_memory'.
SourceLocation ColonLoc
Colon location.
OpenMPDependClauseKind DepKind
Dependency type (one of in, out, inout).
SourceLocation DepLoc
Dependency type location.
This structure contains all sizes needed for by an OMPMappableExprListClause.
unsigned NumComponentLists
Number of component lists.
OMPMappableExprListSizeTy(unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
unsigned NumVars
Number of expressions listed.
unsigned NumUniqueDeclarations
Number of unique base declarations.
unsigned NumComponents
Total number of expression components.
const_child_range used_children() const
static bool classof(const OMPClause *T)
OMPNoChildClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build 'ClauseKind' clause.
child_range used_children()
OMPNoChildClause()
Build an empty clause.
const_child_range children() const
llvm::omp::TraitProperty Kind
StringRef RawString
The raw string as we parsed it.
llvm::omp::TraitSelector Kind
SmallVector< OMPTraitProperty, 1 > Properties
SmallVector< OMPTraitSelector, 2 > Selectors
llvm::omp::TraitSet Kind
Data for list of allocators.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
Expr * AllocatorTraits
Allocator traits.
This structure contains most locations needed for by an OMPVarListClause.
SourceLocation StartLoc
Starting location of the clause (the clause keyword).
SourceLocation LParenLoc
Location of '('.
SourceLocation EndLoc
Ending location of the clause.
OMPVarListLocTy(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Describes how types, statements, expressions, and declarations should be printed.
TargetOMPContext(ASTContext &ASTCtx, std::function< void(StringRef)> &&DiagUnknownTrait, const FunctionDecl *CurrentFunctionDecl, ArrayRef< llvm::omp::TraitProperty > ConstructTraits, int DeviceNum)
bool matchesISATrait(StringRef RawString) const override
See llvm::omp::OMPContext::matchesISATrait.
virtual ~TargetOMPContext()=default