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