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