clang 20.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.
299 static_cast<T *>(this)->template getTrailingObjects<Expr *>(), 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 std::copy(VL.begin(), VL.end(),
307 static_cast<T *>(this)->template getTrailingObjects<Expr *>());
308 }
309
310public:
313 using varlist_range = llvm::iterator_range<varlist_iterator>;
314 using varlist_const_range = llvm::iterator_range<varlist_const_iterator>;
315
316 unsigned varlist_size() const { return NumVars; }
317 bool varlist_empty() const { return NumVars == 0; }
318
321 }
324 }
325
328 varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
330
331 /// Sets the location of '('.
332 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
333
334 /// Returns the location of '('.
335 SourceLocation getLParenLoc() const { return LParenLoc; }
336
337 /// Fetches list of all variables in the clause.
339 return llvm::ArrayRef(
340 static_cast<const T *>(this)->template getTrailingObjects<Expr *>(),
341 NumVars);
342 }
343};
344
345/// Class that represents a list of directive kinds (parallel, target, etc.)
346/// as used in \c absent, \c contains clauses.
347template <class T> class OMPDirectiveListClause : public OMPClause {
348 /// Location of '('.
349 SourceLocation LParenLoc;
350
351protected:
352 /// Number of directive kinds listed in the clause
353 unsigned NumKinds;
354
355public:
356 /// Build a clause with \a NumKinds directive kinds.
357 ///
358 /// \param K The clause kind.
359 /// \param StartLoc Starting location of the clause (the clause keyword).
360 /// \param LParenLoc Location of '('.
361 /// \param EndLoc Ending location of the clause.
362 /// \param NumKinds Number of directive kinds listed in the clause.
364 SourceLocation LParenLoc, SourceLocation EndLoc,
365 unsigned NumKinds)
366 : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc),
368
371 }
372
375 }
376
379 }
382 }
383
386 static_cast<T *>(this)
387 ->template getTrailingObjects<OpenMPDirectiveKind>(),
388 NumKinds);
389 }
390
392 assert(
393 DK.size() == NumKinds &&
394 "Number of directive kinds is not the same as the preallocated buffer");
395 std::copy(DK.begin(), DK.end(),
396 static_cast<T *>(this)
397 ->template getTrailingObjects<OpenMPDirectiveKind>());
398 }
399
400 SourceLocation getLParenLoc() { return LParenLoc; }
401
402 void setLParenLoc(SourceLocation S) { LParenLoc = S; }
403};
404
405/// This represents 'allocator' clause in the '#pragma omp ...'
406/// directive.
407///
408/// \code
409/// #pragma omp allocate(a) allocator(omp_default_mem_alloc)
410/// \endcode
411/// In this example directive '#pragma omp allocate' has simple 'allocator'
412/// clause with the allocator 'omp_default_mem_alloc'.
414 : public OMPOneStmtClause<llvm::omp::OMPC_allocator, OMPClause> {
415 friend class OMPClauseReader;
416
417 /// Set allocator.
418 void setAllocator(Expr *A) { setStmt(A); }
419
420public:
421 /// Build 'allocator' clause with the given allocator.
422 ///
423 /// \param A Allocator.
424 /// \param StartLoc Starting location of the clause.
425 /// \param LParenLoc Location of '('.
426 /// \param EndLoc Ending location of the clause.
428 SourceLocation EndLoc)
429 : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
430
431 /// Build an empty clause.
433
434 /// Returns allocator.
435 Expr *getAllocator() const { return getStmtAs<Expr>(); }
436};
437
438/// This represents the 'align' clause in the '#pragma omp allocate'
439/// directive.
440///
441/// \code
442/// #pragma omp allocate(a) allocator(omp_default_mem_alloc) align(8)
443/// \endcode
444/// In this example directive '#pragma omp allocate' has simple 'allocator'
445/// clause with the allocator 'omp_default_mem_alloc' and align clause with
446/// value of 8.
447class OMPAlignClause final
448 : public OMPOneStmtClause<llvm::omp::OMPC_align, OMPClause> {
449 friend class OMPClauseReader;
450
451 /// Set alignment value.
452 void setAlignment(Expr *A) { setStmt(A); }
453
454 /// Build 'align' clause with the given alignment
455 ///
456 /// \param A Alignment value.
457 /// \param StartLoc Starting location of the clause.
458 /// \param LParenLoc Location of '('.
459 /// \param EndLoc Ending location of the clause.
460 OMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc,
461 SourceLocation EndLoc)
462 : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
463
464 /// Build an empty clause.
465 OMPAlignClause() : OMPOneStmtClause() {}
466
467public:
468 /// Build 'align' clause with the given alignment
469 ///
470 /// \param A Alignment value.
471 /// \param StartLoc Starting location of the clause.
472 /// \param LParenLoc Location of '('.
473 /// \param EndLoc Ending location of the clause.
474 static OMPAlignClause *Create(const ASTContext &C, Expr *A,
475 SourceLocation StartLoc,
476 SourceLocation LParenLoc,
477 SourceLocation EndLoc);
478
479 /// Returns alignment
480 Expr *getAlignment() const { return getStmtAs<Expr>(); }
481};
482
483/// This represents clause 'allocate' in the '#pragma omp ...' directives.
484///
485/// \code
486/// #pragma omp parallel private(a) allocate(omp_default_mem_alloc :a)
487/// \endcode
488/// In this example directive '#pragma omp parallel' has clause 'private'
489/// and clause 'allocate' for the variable 'a', which specifies an explicit
490/// memory allocator.
492 : public OMPVarListClause<OMPAllocateClause>,
493 private llvm::TrailingObjects<OMPAllocateClause, Expr *> {
494 friend class OMPClauseReader;
495 friend OMPVarListClause;
496 friend TrailingObjects;
497
498 /// Allocator specified in the clause, or 'nullptr' if the default one is
499 /// used.
500 Expr *Allocator = nullptr;
501 /// Position of the ':' delimiter in the clause;
502 SourceLocation ColonLoc;
503 /// Modifier of 'allocate' clause.
505 /// Location of allocator modifier if any.
506 SourceLocation AllocatorModifierLoc;
507
508 /// Build clause with number of variables \a N.
509 ///
510 /// \param StartLoc Starting location of the clause.
511 /// \param LParenLoc Location of '('.
512 /// \param Allocator Allocator expression.
513 /// \param ColonLoc Location of ':' delimiter.
514 /// \param EndLoc Ending location of the clause.
515 /// \param N Number of the variables in the clause.
517 Expr *Allocator, SourceLocation ColonLoc,
518 OpenMPAllocateClauseModifier AllocatorModifier,
519 SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
520 unsigned N)
521 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate, StartLoc,
522 LParenLoc, EndLoc, N),
523 Allocator(Allocator), ColonLoc(ColonLoc),
524 AllocatorModifier(AllocatorModifier),
525 AllocatorModifierLoc(AllocatorModifierLoc) {}
526
527 /// Build an empty clause.
528 ///
529 /// \param N Number of variables.
530 explicit OMPAllocateClause(unsigned N)
531 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate,
533 SourceLocation(), N) {}
534
535 /// Sets location of ':' symbol in clause.
536 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
537
538 void setAllocator(Expr *A) { Allocator = A; }
539 void setAllocatorModifier(OpenMPAllocateClauseModifier AM) {
540 AllocatorModifier = AM;
541 }
542
543public:
544 /// Creates clause with a list of variables \a VL.
545 ///
546 /// \param C AST context.
547 /// \param StartLoc Starting location of the clause.
548 /// \param LParenLoc Location of '('.
549 /// \param Allocator Allocator expression.
550 /// \param ColonLoc Location of ':' delimiter.
551 /// \param AllocatorModifier Allocator modifier.
552 /// \param SourceLocation Allocator modifier location.
553 /// \param EndLoc Ending location of the clause.
554 /// \param VL List of references to the variables.
555 static OMPAllocateClause *
556 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
557 Expr *Allocator, SourceLocation ColonLoc,
558 OpenMPAllocateClauseModifier AllocatorModifier,
559 SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
560 ArrayRef<Expr *> VL);
561
562 /// Returns the allocator expression or nullptr, if no allocator is specified.
563 Expr *getAllocator() const { return Allocator; }
564
565 /// Return 'allocate' modifier.
567 return AllocatorModifier;
568 }
569
570 /// Returns the location of the ':' delimiter.
571 SourceLocation getColonLoc() const { return ColonLoc; }
572 /// Return the location of the modifier.
574 return AllocatorModifierLoc;
575 }
576
577 /// Creates an empty clause with the place for \a N variables.
578 ///
579 /// \param C AST context.
580 /// \param N The number of variables.
581 static OMPAllocateClause *CreateEmpty(const ASTContext &C, unsigned N);
582
584 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
585 reinterpret_cast<Stmt **>(varlist_end()));
586 }
587
589 auto Children = const_cast<OMPAllocateClause *>(this)->children();
590 return const_child_range(Children.begin(), Children.end());
591 }
592
595 }
598 }
599
600 static bool classof(const OMPClause *T) {
601 return T->getClauseKind() == llvm::omp::OMPC_allocate;
602 }
603};
604
605/// This represents 'if' clause in the '#pragma omp ...' directive.
606///
607/// \code
608/// #pragma omp parallel if(parallel:a > 5)
609/// \endcode
610/// In this example directive '#pragma omp parallel' has simple 'if' clause with
611/// condition 'a > 5' and directive name modifier 'parallel'.
613 friend class OMPClauseReader;
614
615 /// Location of '('.
616 SourceLocation LParenLoc;
617
618 /// Condition of the 'if' clause.
619 Stmt *Condition = nullptr;
620
621 /// Location of ':' (if any).
622 SourceLocation ColonLoc;
623
624 /// Directive name modifier for the clause.
625 OpenMPDirectiveKind NameModifier = llvm::omp::OMPD_unknown;
626
627 /// Name modifier location.
628 SourceLocation NameModifierLoc;
629
630 /// Set condition.
631 void setCondition(Expr *Cond) { Condition = Cond; }
632
633 /// Set directive name modifier for the clause.
634 void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
635
636 /// Set location of directive name modifier for the clause.
637 void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
638
639 /// Set location of ':'.
640 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
641
642public:
643 /// Build 'if' clause with condition \a Cond.
644 ///
645 /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
646 /// \param Cond Condition of the clause.
647 /// \param HelperCond Helper condition for the clause.
648 /// \param CaptureRegion Innermost OpenMP region where expressions in this
649 /// clause must be captured.
650 /// \param StartLoc Starting location of the clause.
651 /// \param LParenLoc Location of '('.
652 /// \param NameModifierLoc Location of directive name modifier.
653 /// \param ColonLoc [OpenMP 4.1] Location of ':'.
654 /// \param EndLoc Ending location of the clause.
655 OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond,
656 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
657 SourceLocation LParenLoc, SourceLocation NameModifierLoc,
658 SourceLocation ColonLoc, SourceLocation EndLoc)
659 : OMPClause(llvm::omp::OMPC_if, StartLoc, EndLoc),
660 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond),
661 ColonLoc(ColonLoc), NameModifier(NameModifier),
662 NameModifierLoc(NameModifierLoc) {
663 setPreInitStmt(HelperCond, CaptureRegion);
664 }
665
666 /// Build an empty clause.
668 : OMPClause(llvm::omp::OMPC_if, SourceLocation(), SourceLocation()),
669 OMPClauseWithPreInit(this) {}
670
671 /// Sets the location of '('.
672 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
673
674 /// Returns the location of '('.
675 SourceLocation getLParenLoc() const { return LParenLoc; }
676
677 /// Return the location of ':'.
678 SourceLocation getColonLoc() const { return ColonLoc; }
679
680 /// Returns condition.
681 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
682
683 /// Return directive name modifier associated with the clause.
684 OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
685
686 /// Return the location of directive name modifier.
687 SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
688
690
693 }
694
697 auto Children = const_cast<OMPIfClause *>(this)->used_children();
698 return const_child_range(Children.begin(), Children.end());
699 }
700
701 static bool classof(const OMPClause *T) {
702 return T->getClauseKind() == llvm::omp::OMPC_if;
703 }
704};
705
706/// This represents 'final' clause in the '#pragma omp ...' directive.
707///
708/// \code
709/// #pragma omp task final(a > 5)
710/// \endcode
711/// In this example directive '#pragma omp task' has simple 'final'
712/// clause with condition 'a > 5'.
713class OMPFinalClause final
714 : public OMPOneStmtClause<llvm::omp::OMPC_final, OMPClause>,
715 public OMPClauseWithPreInit {
716 friend class OMPClauseReader;
717
718 /// Set condition.
719 void setCondition(Expr *Cond) { setStmt(Cond); }
720
721public:
722 /// Build 'final' clause with condition \a Cond.
723 ///
724 /// \param Cond Condition of the clause.
725 /// \param HelperCond Helper condition for the construct.
726 /// \param CaptureRegion Innermost OpenMP region where expressions in this
727 /// clause must be captured.
728 /// \param StartLoc Starting location of the clause.
729 /// \param LParenLoc Location of '('.
730 /// \param EndLoc Ending location of the clause.
731 OMPFinalClause(Expr *Cond, Stmt *HelperCond,
732 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
733 SourceLocation LParenLoc, SourceLocation EndLoc)
734 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
736 setPreInitStmt(HelperCond, CaptureRegion);
737 }
738
739 /// Build an empty clause.
741
742 /// Returns condition.
743 Expr *getCondition() const { return getStmtAs<Expr>(); }
744
747 auto Children = const_cast<OMPFinalClause *>(this)->used_children();
748 return const_child_range(Children.begin(), Children.end());
749 }
750};
751/// This represents 'num_threads' clause in the '#pragma omp ...'
752/// directive.
753///
754/// \code
755/// #pragma omp parallel num_threads(6)
756/// \endcode
757/// In this example directive '#pragma omp parallel' has simple 'num_threads'
758/// clause with number of threads '6'.
760 : public OMPOneStmtClause<llvm::omp::OMPC_num_threads, OMPClause>,
761 public OMPClauseWithPreInit {
762 friend class OMPClauseReader;
763
764 /// Set condition.
765 void setNumThreads(Expr *NThreads) { setStmt(NThreads); }
766
767public:
768 /// Build 'num_threads' clause with condition \a NumThreads.
769 ///
770 /// \param NumThreads Number of threads for the construct.
771 /// \param HelperNumThreads Helper Number of threads for the construct.
772 /// \param CaptureRegion Innermost OpenMP region where expressions in this
773 /// clause must be captured.
774 /// \param StartLoc Starting location of the clause.
775 /// \param LParenLoc Location of '('.
776 /// \param EndLoc Ending location of the clause.
777 OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads,
778 OpenMPDirectiveKind CaptureRegion,
779 SourceLocation StartLoc, SourceLocation LParenLoc,
780 SourceLocation EndLoc)
781 : OMPOneStmtClause(NumThreads, StartLoc, LParenLoc, EndLoc),
783 setPreInitStmt(HelperNumThreads, CaptureRegion);
784 }
785
786 /// Build an empty clause.
788
789 /// Returns number of threads.
790 Expr *getNumThreads() const { return getStmtAs<Expr>(); }
791};
792
793/// This represents 'safelen' clause in the '#pragma omp ...'
794/// directive.
795///
796/// \code
797/// #pragma omp simd safelen(4)
798/// \endcode
799/// In this example directive '#pragma omp simd' has clause 'safelen'
800/// with single expression '4'.
801/// If the safelen clause is used then no two iterations executed
802/// concurrently with SIMD instructions can have a greater distance
803/// in the logical iteration space than its value. The parameter of
804/// the safelen clause must be a constant positive integer expression.
806 : public OMPOneStmtClause<llvm::omp::OMPC_safelen, OMPClause> {
807 friend class OMPClauseReader;
808
809 /// Set safelen.
810 void setSafelen(Expr *Len) { setStmt(Len); }
811
812public:
813 /// Build 'safelen' clause.
814 ///
815 /// \param Len Expression associated with this clause.
816 /// \param StartLoc Starting location of the clause.
817 /// \param EndLoc Ending location of the clause.
819 SourceLocation EndLoc)
820 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
821
822 /// Build an empty clause.
824
825 /// Return safe iteration space distance.
826 Expr *getSafelen() const { return getStmtAs<Expr>(); }
827};
828
829/// This represents 'simdlen' clause in the '#pragma omp ...'
830/// directive.
831///
832/// \code
833/// #pragma omp simd simdlen(4)
834/// \endcode
835/// In this example directive '#pragma omp simd' has clause 'simdlen'
836/// with single expression '4'.
837/// If the 'simdlen' clause is used then it specifies the preferred number of
838/// iterations to be executed concurrently. The parameter of the 'simdlen'
839/// clause must be a constant positive integer expression.
841 : public OMPOneStmtClause<llvm::omp::OMPC_simdlen, OMPClause> {
842 friend class OMPClauseReader;
843
844 /// Set simdlen.
845 void setSimdlen(Expr *Len) { setStmt(Len); }
846
847public:
848 /// Build 'simdlen' clause.
849 ///
850 /// \param Len Expression associated with this clause.
851 /// \param StartLoc Starting location of the clause.
852 /// \param EndLoc Ending location of the clause.
854 SourceLocation EndLoc)
855 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
856
857 /// Build an empty clause.
859
860 /// Return safe iteration space distance.
861 Expr *getSimdlen() const { return getStmtAs<Expr>(); }
862};
863
864/// This represents the 'sizes' clause in the '#pragma omp tile' directive.
865///
866/// \code
867/// #pragma omp tile sizes(5,5)
868/// for (int i = 0; i < 64; ++i)
869/// for (int j = 0; j < 64; ++j)
870/// \endcode
871class OMPSizesClause final
872 : public OMPClause,
873 private llvm::TrailingObjects<OMPSizesClause, Expr *> {
874 friend class OMPClauseReader;
875 friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
876
877 /// Location of '('.
878 SourceLocation LParenLoc;
879
880 /// Number of tile sizes in the clause.
881 unsigned NumSizes;
882
883 /// Build an empty clause.
884 explicit OMPSizesClause(int NumSizes)
885 : OMPClause(llvm::omp::OMPC_sizes, SourceLocation(), SourceLocation()),
886 NumSizes(NumSizes) {}
887
888public:
889 /// Build a 'sizes' AST node.
890 ///
891 /// \param C Context of the AST.
892 /// \param StartLoc Location of the 'sizes' identifier.
893 /// \param LParenLoc Location of '('.
894 /// \param EndLoc Location of ')'.
895 /// \param Sizes Content of the clause.
896 static OMPSizesClause *Create(const ASTContext &C, SourceLocation StartLoc,
897 SourceLocation LParenLoc, SourceLocation EndLoc,
898 ArrayRef<Expr *> Sizes);
899
900 /// Build an empty 'sizes' AST node for deserialization.
901 ///
902 /// \param C Context of the AST.
903 /// \param NumSizes Number of items in the clause.
904 static OMPSizesClause *CreateEmpty(const ASTContext &C, unsigned NumSizes);
905
906 /// Sets the location of '('.
907 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
908
909 /// Returns the location of '('.
910 SourceLocation getLParenLoc() const { return LParenLoc; }
911
912 /// Returns the number of list items.
913 unsigned getNumSizes() const { return NumSizes; }
914
915 /// Returns the tile size expressions.
917 return MutableArrayRef<Expr *>(static_cast<OMPSizesClause *>(this)
918 ->template getTrailingObjects<Expr *>(),
919 NumSizes);
920 }
922 return ArrayRef<Expr *>(static_cast<const OMPSizesClause *>(this)
923 ->template getTrailingObjects<Expr *>(),
924 NumSizes);
925 }
926
927 /// Sets the tile size expressions.
929 assert(VL.size() == NumSizes);
930 std::copy(VL.begin(), VL.end(),
931 static_cast<OMPSizesClause *>(this)
932 ->template getTrailingObjects<Expr *>());
933 }
934
937 return child_range(reinterpret_cast<Stmt **>(Sizes.begin()),
938 reinterpret_cast<Stmt **>(Sizes.end()));
939 }
942 return const_child_range(reinterpret_cast<Stmt *const *>(Sizes.begin()),
943 reinterpret_cast<Stmt *const *>(Sizes.end()));
944 }
945
948 }
951 }
952
953 static bool classof(const OMPClause *T) {
954 return T->getClauseKind() == llvm::omp::OMPC_sizes;
955 }
956};
957
958/// This class represents the 'permutation' clause in the
959/// '#pragma omp interchange' directive.
960///
961/// \code{.c}
962/// #pragma omp interchange permutation(2,1)
963/// for (int i = 0; i < 64; ++i)
964/// for (int j = 0; j < 64; ++j)
965/// \endcode
967 : public OMPClause,
968 private llvm::TrailingObjects<OMPSizesClause, Expr *> {
969 friend class OMPClauseReader;
970 friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
971
972 /// Location of '('.
973 SourceLocation LParenLoc;
974
975 /// Number of arguments in the clause, and hence also the number of loops to
976 /// be permuted.
977 unsigned NumLoops;
978
979 /// Sets the permutation index expressions.
980 void setArgRefs(ArrayRef<Expr *> VL) {
981 assert(VL.size() == NumLoops && "Expecting one expression per loop");
982 llvm::copy(VL, static_cast<OMPPermutationClause *>(this)
983 ->template getTrailingObjects<Expr *>());
984 }
985
986 /// Build an empty clause.
987 explicit OMPPermutationClause(int NumLoops)
988 : OMPClause(llvm::omp::OMPC_permutation, SourceLocation(),
990 NumLoops(NumLoops) {}
991
992public:
993 /// Build a 'permutation' clause AST node.
994 ///
995 /// \param C Context of the AST.
996 /// \param StartLoc Location of the 'permutation' identifier.
997 /// \param LParenLoc Location of '('.
998 /// \param EndLoc Location of ')'.
999 /// \param Args Content of the clause.
1000 static OMPPermutationClause *
1001 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1002 SourceLocation EndLoc, ArrayRef<Expr *> Args);
1003
1004 /// Build an empty 'permutation' AST node for deserialization.
1005 ///
1006 /// \param C Context of the AST.
1007 /// \param NumLoops Number of arguments in the clause.
1008 static OMPPermutationClause *CreateEmpty(const ASTContext &C,
1009 unsigned NumLoops);
1010
1011 /// Sets the location of '('.
1012 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1013
1014 /// Returns the location of '('.
1015 SourceLocation getLParenLoc() const { return LParenLoc; }
1016
1017 /// Returns the number of list items.
1018 unsigned getNumLoops() const { return NumLoops; }
1019
1020 /// Returns the permutation index expressions.
1021 ///@{
1023 return MutableArrayRef<Expr *>(static_cast<OMPPermutationClause *>(this)
1024 ->template getTrailingObjects<Expr *>(),
1025 NumLoops);
1026 }
1028 return ArrayRef<Expr *>(static_cast<const OMPPermutationClause *>(this)
1029 ->template getTrailingObjects<Expr *>(),
1030 NumLoops);
1031 }
1032 ///@}
1033
1036 return child_range(reinterpret_cast<Stmt **>(Args.begin()),
1037 reinterpret_cast<Stmt **>(Args.end()));
1038 }
1041 return const_child_range(reinterpret_cast<Stmt *const *>(Args.begin()),
1042 reinterpret_cast<Stmt *const *>(Args.end()));
1043 }
1044
1047 }
1050 }
1051
1052 static bool classof(const OMPClause *T) {
1053 return T->getClauseKind() == llvm::omp::OMPC_permutation;
1054 }
1055};
1056
1057/// Representation of the 'full' clause of the '#pragma omp unroll' directive.
1058///
1059/// \code
1060/// #pragma omp unroll full
1061/// for (int i = 0; i < 64; ++i)
1062/// \endcode
1063class OMPFullClause final : public OMPNoChildClause<llvm::omp::OMPC_full> {
1064 friend class OMPClauseReader;
1065
1066 /// Build an empty clause.
1067 explicit OMPFullClause() : OMPNoChildClause() {}
1068
1069public:
1070 /// Build an AST node for a 'full' clause.
1071 ///
1072 /// \param C Context of the AST.
1073 /// \param StartLoc Starting location of the clause.
1074 /// \param EndLoc Ending location of the clause.
1075 static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc,
1076 SourceLocation EndLoc);
1077
1078 /// Build an empty 'full' AST node for deserialization.
1079 ///
1080 /// \param C Context of the AST.
1081 static OMPFullClause *CreateEmpty(const ASTContext &C);
1082};
1083
1084/// Representation of the 'partial' clause of the '#pragma omp unroll'
1085/// directive.
1086///
1087/// \code
1088/// #pragma omp unroll partial(4)
1089/// for (int i = start; i < end; ++i)
1090/// \endcode
1091class OMPPartialClause final : public OMPClause {
1092 friend class OMPClauseReader;
1093
1094 /// Location of '('.
1095 SourceLocation LParenLoc;
1096
1097 /// Optional argument to the clause (unroll factor).
1098 Stmt *Factor;
1099
1100 /// Build an empty clause.
1101 explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {}
1102
1103 /// Set the unroll factor.
1104 void setFactor(Expr *E) { Factor = E; }
1105
1106 /// Sets the location of '('.
1107 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1108
1109public:
1110 /// Build an AST node for a 'partial' clause.
1111 ///
1112 /// \param C Context of the AST.
1113 /// \param StartLoc Location of the 'partial' identifier.
1114 /// \param LParenLoc Location of '('.
1115 /// \param EndLoc Location of ')'.
1116 /// \param Factor Clause argument.
1117 static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc,
1118 SourceLocation LParenLoc,
1119 SourceLocation EndLoc, Expr *Factor);
1120
1121 /// Build an empty 'partial' AST node for deserialization.
1122 ///
1123 /// \param C Context of the AST.
1124 static OMPPartialClause *CreateEmpty(const ASTContext &C);
1125
1126 /// Returns the location of '('.
1127 SourceLocation getLParenLoc() const { return LParenLoc; }
1128
1129 /// Returns the argument of the clause or nullptr if not set.
1130 Expr *getFactor() const { return cast_or_null<Expr>(Factor); }
1131
1132 child_range children() { return child_range(&Factor, &Factor + 1); }
1134 return const_child_range(&Factor, &Factor + 1);
1135 }
1136
1139 }
1142 }
1143
1144 static bool classof(const OMPClause *T) {
1145 return T->getClauseKind() == llvm::omp::OMPC_partial;
1146 }
1147};
1148
1149/// This represents 'collapse' clause in the '#pragma omp ...'
1150/// directive.
1151///
1152/// \code
1153/// #pragma omp simd collapse(3)
1154/// \endcode
1155/// In this example directive '#pragma omp simd' has clause 'collapse'
1156/// with single expression '3'.
1157/// The parameter must be a constant positive integer expression, it specifies
1158/// the number of nested loops that should be collapsed into a single iteration
1159/// space.
1161 : public OMPOneStmtClause<llvm::omp::OMPC_collapse, OMPClause> {
1162 friend class OMPClauseReader;
1163
1164 /// Set the number of associated for-loops.
1165 void setNumForLoops(Expr *Num) { setStmt(Num); }
1166
1167public:
1168 /// Build 'collapse' clause.
1169 ///
1170 /// \param Num Expression associated with this clause.
1171 /// \param StartLoc Starting location of the clause.
1172 /// \param LParenLoc Location of '('.
1173 /// \param EndLoc Ending location of the clause.
1175 SourceLocation LParenLoc, SourceLocation EndLoc)
1176 : OMPOneStmtClause(Num, StartLoc, LParenLoc, EndLoc) {}
1177
1178 /// Build an empty clause.
1180
1181 /// Return the number of associated for-loops.
1182 Expr *getNumForLoops() const { return getStmtAs<Expr>(); }
1183};
1184
1185/// This represents 'default' clause in the '#pragma omp ...' directive.
1186///
1187/// \code
1188/// #pragma omp parallel default(shared)
1189/// \endcode
1190/// In this example directive '#pragma omp parallel' has simple 'default'
1191/// clause with kind 'shared'.
1193 friend class OMPClauseReader;
1194
1195 /// Location of '('.
1196 SourceLocation LParenLoc;
1197
1198 /// A kind of the 'default' clause.
1199 llvm::omp::DefaultKind Kind = llvm::omp::OMP_DEFAULT_unknown;
1200
1201 /// Start location of the kind in source code.
1202 SourceLocation KindKwLoc;
1203
1204 /// Set kind of the clauses.
1205 ///
1206 /// \param K Argument of clause.
1207 void setDefaultKind(llvm::omp::DefaultKind K) { Kind = K; }
1208
1209 /// Set argument location.
1210 ///
1211 /// \param KLoc Argument location.
1212 void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1213
1214public:
1215 /// Build 'default' clause with argument \a A ('none' or 'shared').
1216 ///
1217 /// \param A Argument of the clause ('none' or 'shared').
1218 /// \param ALoc Starting location of the argument.
1219 /// \param StartLoc Starting location of the clause.
1220 /// \param LParenLoc Location of '('.
1221 /// \param EndLoc Ending location of the clause.
1222 OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc,
1223 SourceLocation StartLoc, SourceLocation LParenLoc,
1224 SourceLocation EndLoc)
1225 : OMPClause(llvm::omp::OMPC_default, StartLoc, EndLoc),
1226 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1227
1228 /// Build an empty clause.
1230 : OMPClause(llvm::omp::OMPC_default, SourceLocation(), SourceLocation()) {
1231 }
1232
1233 /// Sets the location of '('.
1234 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1235
1236 /// Returns the location of '('.
1237 SourceLocation getLParenLoc() const { return LParenLoc; }
1238
1239 /// Returns kind of the clause.
1240 llvm::omp::DefaultKind getDefaultKind() const { return Kind; }
1241
1242 /// Returns location of clause kind.
1243 SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
1244
1247 }
1248
1251 }
1252
1255 }
1258 }
1259
1260 static bool classof(const OMPClause *T) {
1261 return T->getClauseKind() == llvm::omp::OMPC_default;
1262 }
1263};
1264
1265/// This represents 'proc_bind' clause in the '#pragma omp ...'
1266/// directive.
1267///
1268/// \code
1269/// #pragma omp parallel proc_bind(master)
1270/// \endcode
1271/// In this example directive '#pragma omp parallel' has simple 'proc_bind'
1272/// clause with kind 'master'.
1274 friend class OMPClauseReader;
1275
1276 /// Location of '('.
1277 SourceLocation LParenLoc;
1278
1279 /// A kind of the 'proc_bind' clause.
1280 llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown;
1281
1282 /// Start location of the kind in source code.
1283 SourceLocation KindKwLoc;
1284
1285 /// Set kind of the clause.
1286 ///
1287 /// \param K Kind of clause.
1288 void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; }
1289
1290 /// Set clause kind location.
1291 ///
1292 /// \param KLoc Kind location.
1293 void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1294
1295public:
1296 /// Build 'proc_bind' clause with argument \a A ('master', 'close' or
1297 /// 'spread').
1298 ///
1299 /// \param A Argument of the clause ('master', 'close' or 'spread').
1300 /// \param ALoc Starting location of the argument.
1301 /// \param StartLoc Starting location of the clause.
1302 /// \param LParenLoc Location of '('.
1303 /// \param EndLoc Ending location of the clause.
1304 OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc,
1305 SourceLocation StartLoc, SourceLocation LParenLoc,
1306 SourceLocation EndLoc)
1307 : OMPClause(llvm::omp::OMPC_proc_bind, StartLoc, EndLoc),
1308 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1309
1310 /// Build an empty clause.
1312 : OMPClause(llvm::omp::OMPC_proc_bind, SourceLocation(),
1313 SourceLocation()) {}
1314
1315 /// Sets the location of '('.
1316 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1317
1318 /// Returns the location of '('.
1319 SourceLocation getLParenLoc() const { return LParenLoc; }
1320
1321 /// Returns kind of the clause.
1322 llvm::omp::ProcBindKind getProcBindKind() const { return Kind; }
1323
1324 /// Returns location of clause kind.
1325 SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
1326
1329 }
1330
1333 }
1334
1337 }
1340 }
1341
1342 static bool classof(const OMPClause *T) {
1343 return T->getClauseKind() == llvm::omp::OMPC_proc_bind;
1344 }
1345};
1346
1347/// This represents 'unified_address' clause in the '#pragma omp requires'
1348/// directive.
1349///
1350/// \code
1351/// #pragma omp requires unified_address
1352/// \endcode
1353/// In this example directive '#pragma omp requires' has 'unified_address'
1354/// clause.
1356 : public OMPNoChildClause<llvm::omp::OMPC_unified_address> {
1357public:
1358 friend class OMPClauseReader;
1359 /// Build 'unified_address' clause.
1360 ///
1361 /// \param StartLoc Starting location of the clause.
1362 /// \param EndLoc Ending location of the clause.
1364 : OMPNoChildClause(StartLoc, EndLoc) {}
1365
1366 /// Build an empty clause.
1368};
1369
1370/// This represents 'unified_shared_memory' clause in the '#pragma omp requires'
1371/// directive.
1372///
1373/// \code
1374/// #pragma omp requires unified_shared_memory
1375/// \endcode
1376/// In this example directive '#pragma omp requires' has 'unified_shared_memory'
1377/// clause.
1379public:
1380 friend class OMPClauseReader;
1381 /// Build 'unified_shared_memory' clause.
1382 ///
1383 /// \param StartLoc Starting location of the clause.
1384 /// \param EndLoc Ending location of the clause.
1386 : OMPClause(llvm::omp::OMPC_unified_shared_memory, StartLoc, EndLoc) {}
1387
1388 /// Build an empty clause.
1390 : OMPClause(llvm::omp::OMPC_unified_shared_memory, SourceLocation(),
1391 SourceLocation()) {}
1392
1395 }
1396
1399 }
1400
1403 }
1406 }
1407
1408 static bool classof(const OMPClause *T) {
1409 return T->getClauseKind() == llvm::omp::OMPC_unified_shared_memory;
1410 }
1411};
1412
1413/// This represents 'reverse_offload' clause in the '#pragma omp requires'
1414/// directive.
1415///
1416/// \code
1417/// #pragma omp requires reverse_offload
1418/// \endcode
1419/// In this example directive '#pragma omp requires' has 'reverse_offload'
1420/// clause.
1422public:
1423 friend class OMPClauseReader;
1424 /// Build 'reverse_offload' clause.
1425 ///
1426 /// \param StartLoc Starting location of the clause.
1427 /// \param EndLoc Ending location of the clause.
1429 : OMPClause(llvm::omp::OMPC_reverse_offload, StartLoc, EndLoc) {}
1430
1431 /// Build an empty clause.
1433 : OMPClause(llvm::omp::OMPC_reverse_offload, SourceLocation(),
1434 SourceLocation()) {}
1435
1438 }
1439
1442 }
1443
1446 }
1449 }
1450
1451 static bool classof(const OMPClause *T) {
1452 return T->getClauseKind() == llvm::omp::OMPC_reverse_offload;
1453 }
1454};
1455
1456/// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
1457/// directive.
1458///
1459/// \code
1460/// #pragma omp requires dynamic_allocators
1461/// \endcode
1462/// In this example directive '#pragma omp requires' has 'dynamic_allocators'
1463/// clause.
1465public:
1466 friend class OMPClauseReader;
1467 /// Build 'dynamic_allocators' clause.
1468 ///
1469 /// \param StartLoc Starting location of the clause.
1470 /// \param EndLoc Ending location of the clause.
1472 : OMPClause(llvm::omp::OMPC_dynamic_allocators, StartLoc, EndLoc) {}
1473
1474 /// Build an empty clause.
1476 : OMPClause(llvm::omp::OMPC_dynamic_allocators, SourceLocation(),
1477 SourceLocation()) {}
1478
1481 }
1482
1485 }
1486
1489 }
1492 }
1493
1494 static bool classof(const OMPClause *T) {
1495 return T->getClauseKind() == llvm::omp::OMPC_dynamic_allocators;
1496 }
1497};
1498
1499/// This represents 'atomic_default_mem_order' clause in the '#pragma omp
1500/// requires' directive.
1501///
1502/// \code
1503/// #pragma omp requires atomic_default_mem_order(seq_cst)
1504/// \endcode
1505/// In this example directive '#pragma omp requires' has simple
1506/// atomic_default_mem_order' clause with kind 'seq_cst'.
1508 friend class OMPClauseReader;
1509
1510 /// Location of '('
1511 SourceLocation LParenLoc;
1512
1513 /// A kind of the 'atomic_default_mem_order' clause.
1516
1517 /// Start location of the kind in source code.
1518 SourceLocation KindKwLoc;
1519
1520 /// Set kind of the clause.
1521 ///
1522 /// \param K Kind of clause.
1523 void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) {
1524 Kind = K;
1525 }
1526
1527 /// Set clause kind location.
1528 ///
1529 /// \param KLoc Kind location.
1530 void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) {
1531 KindKwLoc = KLoc;
1532 }
1533
1534public:
1535 /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst',
1536 /// 'acq_rel' or 'relaxed').
1537 ///
1538 /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed').
1539 /// \param ALoc Starting location of the argument.
1540 /// \param StartLoc Starting location of the clause.
1541 /// \param LParenLoc Location of '('.
1542 /// \param EndLoc Ending location of the clause.
1544 SourceLocation ALoc, SourceLocation StartLoc,
1545 SourceLocation LParenLoc,
1546 SourceLocation EndLoc)
1547 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, StartLoc, EndLoc),
1548 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1549
1550 /// Build an empty clause.
1552 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, SourceLocation(),
1553 SourceLocation()) {}
1554
1555 /// Sets the location of '('.
1556 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1557
1558 /// Returns the locaiton of '('.
1559 SourceLocation getLParenLoc() const { return LParenLoc; }
1560
1561 /// Returns kind of the clause.
1563 return Kind;
1564 }
1565
1566 /// Returns location of clause kind.
1568
1571 }
1572
1575 }
1576
1579 }
1582 }
1583
1584 static bool classof(const OMPClause *T) {
1585 return T->getClauseKind() == llvm::omp::OMPC_atomic_default_mem_order;
1586 }
1587};
1588
1589/// This represents 'at' clause in the '#pragma omp error' directive
1590///
1591/// \code
1592/// #pragma omp error at(compilation)
1593/// \endcode
1594/// In this example directive '#pragma omp error' has simple
1595/// 'at' clause with kind 'complilation'.
1596class OMPAtClause final : public OMPClause {
1597 friend class OMPClauseReader;
1598
1599 /// Location of '('
1600 SourceLocation LParenLoc;
1601
1602 /// A kind of the 'at' clause.
1604
1605 /// Start location of the kind in source code.
1606 SourceLocation KindKwLoc;
1607
1608 /// Set kind of the clause.
1609 ///
1610 /// \param K Kind of clause.
1611 void setAtKind(OpenMPAtClauseKind K) { Kind = K; }
1612
1613 /// Set clause kind location.
1614 ///
1615 /// \param KLoc Kind location.
1616 void setAtKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1617
1618 /// Sets the location of '('.
1619 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1620
1621public:
1622 /// Build 'at' clause with argument \a A ('compilation' or 'execution').
1623 ///
1624 /// \param A Argument of the clause ('compilation' or 'execution').
1625 /// \param ALoc Starting location of the argument.
1626 /// \param StartLoc Starting location of the clause.
1627 /// \param LParenLoc Location of '('.
1628 /// \param EndLoc Ending location of the clause.
1630 SourceLocation StartLoc, SourceLocation LParenLoc,
1631 SourceLocation EndLoc)
1632 : OMPClause(llvm::omp::OMPC_at, StartLoc, EndLoc), LParenLoc(LParenLoc),
1633 Kind(A), KindKwLoc(ALoc) {}
1634
1635 /// Build an empty clause.
1637 : OMPClause(llvm::omp::OMPC_at, SourceLocation(), SourceLocation()) {}
1638
1639 /// Returns the locaiton of '('.
1640 SourceLocation getLParenLoc() const { return LParenLoc; }
1641
1642 /// Returns kind of the clause.
1644
1645 /// Returns location of clause kind.
1646 SourceLocation getAtKindKwLoc() const { return KindKwLoc; }
1647
1650 }
1651
1654 }
1655
1658 }
1661 }
1662
1663 static bool classof(const OMPClause *T) {
1664 return T->getClauseKind() == llvm::omp::OMPC_at;
1665 }
1666};
1667
1668/// This represents 'severity' clause in the '#pragma omp error' directive
1669///
1670/// \code
1671/// #pragma omp error severity(fatal)
1672/// \endcode
1673/// In this example directive '#pragma omp error' has simple
1674/// 'severity' clause with kind 'fatal'.
1675class OMPSeverityClause final : public OMPClause {
1676 friend class OMPClauseReader;
1677
1678 /// Location of '('
1679 SourceLocation LParenLoc;
1680
1681 /// A kind of the 'severity' clause.
1683
1684 /// Start location of the kind in source code.
1685 SourceLocation KindKwLoc;
1686
1687 /// Set kind of the clause.
1688 ///
1689 /// \param K Kind of clause.
1690 void setSeverityKind(OpenMPSeverityClauseKind K) { Kind = K; }
1691
1692 /// Set clause kind location.
1693 ///
1694 /// \param KLoc Kind location.
1695 void setSeverityKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1696
1697 /// Sets the location of '('.
1698 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1699
1700public:
1701 /// Build 'severity' clause with argument \a A ('fatal' or 'warning').
1702 ///
1703 /// \param A Argument of the clause ('fatal' or 'warning').
1704 /// \param ALoc Starting location of the argument.
1705 /// \param StartLoc Starting location of the clause.
1706 /// \param LParenLoc Location of '('.
1707 /// \param EndLoc Ending location of the clause.
1709 SourceLocation StartLoc, SourceLocation LParenLoc,
1710 SourceLocation EndLoc)
1711 : OMPClause(llvm::omp::OMPC_severity, StartLoc, EndLoc),
1712 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1713
1714 /// Build an empty clause.
1716 : OMPClause(llvm::omp::OMPC_severity, SourceLocation(),
1717 SourceLocation()) {}
1718
1719 /// Returns the locaiton of '('.
1720 SourceLocation getLParenLoc() const { return LParenLoc; }
1721
1722 /// Returns kind of the clause.
1724
1725 /// Returns location of clause kind.
1726 SourceLocation getSeverityKindKwLoc() const { return KindKwLoc; }
1727
1730 }
1731
1734 }
1735
1738 }
1741 }
1742
1743 static bool classof(const OMPClause *T) {
1744 return T->getClauseKind() == llvm::omp::OMPC_severity;
1745 }
1746};
1747
1748/// This represents 'message' clause in the '#pragma omp error' directive
1749///
1750/// \code
1751/// #pragma omp error message("GNU compiler required.")
1752/// \endcode
1753/// In this example directive '#pragma omp error' has simple
1754/// 'message' clause with user error message of "GNU compiler required.".
1755class OMPMessageClause final : public OMPClause {
1756 friend class OMPClauseReader;
1757
1758 /// Location of '('
1759 SourceLocation LParenLoc;
1760
1761 // Expression of the 'message' clause.
1762 Stmt *MessageString = nullptr;
1763
1764 /// Set message string of the clause.
1765 void setMessageString(Expr *MS) { MessageString = MS; }
1766
1767 /// Sets the location of '('.
1768 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1769
1770public:
1771 /// Build 'message' clause with message string argument
1772 ///
1773 /// \param MS Argument of the clause (message string).
1774 /// \param StartLoc Starting location of the clause.
1775 /// \param LParenLoc Location of '('.
1776 /// \param EndLoc Ending location of the clause.
1778 SourceLocation EndLoc)
1779 : OMPClause(llvm::omp::OMPC_message, StartLoc, EndLoc),
1780 LParenLoc(LParenLoc), MessageString(MS) {}
1781
1782 /// Build an empty clause.
1784 : OMPClause(llvm::omp::OMPC_message, SourceLocation(), SourceLocation()) {
1785 }
1786
1787 /// Returns the locaiton of '('.
1788 SourceLocation getLParenLoc() const { return LParenLoc; }
1789
1790 /// Returns message string of the clause.
1791 Expr *getMessageString() const { return cast_or_null<Expr>(MessageString); }
1792
1794 return child_range(&MessageString, &MessageString + 1);
1795 }
1796
1798 return const_child_range(&MessageString, &MessageString + 1);
1799 }
1800
1803 }
1804
1807 }
1808
1809 static bool classof(const OMPClause *T) {
1810 return T->getClauseKind() == llvm::omp::OMPC_message;
1811 }
1812};
1813
1814/// This represents 'schedule' clause in the '#pragma omp ...' directive.
1815///
1816/// \code
1817/// #pragma omp for schedule(static, 3)
1818/// \endcode
1819/// In this example directive '#pragma omp for' has 'schedule' clause with
1820/// arguments 'static' and '3'.
1822 friend class OMPClauseReader;
1823
1824 /// Location of '('.
1825 SourceLocation LParenLoc;
1826
1827 /// A kind of the 'schedule' clause.
1829
1830 /// Modifiers for 'schedule' clause.
1831 enum {FIRST, SECOND, NUM_MODIFIERS};
1832 OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
1833
1834 /// Locations of modifiers.
1835 SourceLocation ModifiersLoc[NUM_MODIFIERS];
1836
1837 /// Start location of the schedule ind in source code.
1838 SourceLocation KindLoc;
1839
1840 /// Location of ',' (if any).
1841 SourceLocation CommaLoc;
1842
1843 /// Chunk size.
1844 Expr *ChunkSize = nullptr;
1845
1846 /// Set schedule kind.
1847 ///
1848 /// \param K Schedule kind.
1849 void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
1850
1851 /// Set the first schedule modifier.
1852 ///
1853 /// \param M Schedule modifier.
1854 void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
1855 Modifiers[FIRST] = M;
1856 }
1857
1858 /// Set the second schedule modifier.
1859 ///
1860 /// \param M Schedule modifier.
1861 void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
1862 Modifiers[SECOND] = M;
1863 }
1864
1865 /// Set location of the first schedule modifier.
1866 void setFirstScheduleModifierLoc(SourceLocation Loc) {
1867 ModifiersLoc[FIRST] = Loc;
1868 }
1869
1870 /// Set location of the second schedule modifier.
1871 void setSecondScheduleModifierLoc(SourceLocation Loc) {
1872 ModifiersLoc[SECOND] = Loc;
1873 }
1874
1875 /// Set schedule modifier location.
1876 ///
1877 /// \param M Schedule modifier location.
1878 void setScheduleModifer(OpenMPScheduleClauseModifier M) {
1879 if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
1880 Modifiers[FIRST] = M;
1881 else {
1882 assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
1883 Modifiers[SECOND] = M;
1884 }
1885 }
1886
1887 /// Sets the location of '('.
1888 ///
1889 /// \param Loc Location of '('.
1890 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1891
1892 /// Set schedule kind start location.
1893 ///
1894 /// \param KLoc Schedule kind location.
1895 void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
1896
1897 /// Set location of ','.
1898 ///
1899 /// \param Loc Location of ','.
1900 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
1901
1902 /// Set chunk size.
1903 ///
1904 /// \param E Chunk size.
1905 void setChunkSize(Expr *E) { ChunkSize = E; }
1906
1907public:
1908 /// Build 'schedule' clause with schedule kind \a Kind and chunk size
1909 /// expression \a ChunkSize.
1910 ///
1911 /// \param StartLoc Starting location of the clause.
1912 /// \param LParenLoc Location of '('.
1913 /// \param KLoc Starting location of the argument.
1914 /// \param CommaLoc Location of ','.
1915 /// \param EndLoc Ending location of the clause.
1916 /// \param Kind Schedule kind.
1917 /// \param ChunkSize Chunk size.
1918 /// \param HelperChunkSize Helper chunk size for combined directives.
1919 /// \param M1 The first modifier applied to 'schedule' clause.
1920 /// \param M1Loc Location of the first modifier
1921 /// \param M2 The second modifier applied to 'schedule' clause.
1922 /// \param M2Loc Location of the second modifier
1924 SourceLocation KLoc, SourceLocation CommaLoc,
1926 Expr *ChunkSize, Stmt *HelperChunkSize,
1929 : OMPClause(llvm::omp::OMPC_schedule, StartLoc, EndLoc),
1930 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
1931 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
1932 setPreInitStmt(HelperChunkSize);
1933 Modifiers[FIRST] = M1;
1934 Modifiers[SECOND] = M2;
1935 ModifiersLoc[FIRST] = M1Loc;
1936 ModifiersLoc[SECOND] = M2Loc;
1937 }
1938
1939 /// Build an empty clause.
1941 : OMPClause(llvm::omp::OMPC_schedule, SourceLocation(), SourceLocation()),
1942 OMPClauseWithPreInit(this) {
1943 Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
1944 Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
1945 }
1946
1947 /// Get kind of the clause.
1949
1950 /// Get the first modifier of the clause.
1952 return Modifiers[FIRST];
1953 }
1954
1955 /// Get the second modifier of the clause.
1957 return Modifiers[SECOND];
1958 }
1959
1960 /// Get location of '('.
1961 SourceLocation getLParenLoc() { return LParenLoc; }
1962
1963 /// Get kind location.
1965
1966 /// Get the first modifier location.
1968 return ModifiersLoc[FIRST];
1969 }
1970
1971 /// Get the second modifier location.
1973 return ModifiersLoc[SECOND];
1974 }
1975
1976 /// Get location of ','.
1977 SourceLocation getCommaLoc() { return CommaLoc; }
1978
1979 /// Get chunk size.
1980 Expr *getChunkSize() { return ChunkSize; }
1981
1982 /// Get chunk size.
1983 const Expr *getChunkSize() const { return ChunkSize; }
1984
1986 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
1987 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
1988 }
1989
1991 auto Children = const_cast<OMPScheduleClause *>(this)->children();
1992 return const_child_range(Children.begin(), Children.end());
1993 }
1994
1997 }
2000 }
2001
2002 static bool classof(const OMPClause *T) {
2003 return T->getClauseKind() == llvm::omp::OMPC_schedule;
2004 }
2005};
2006
2007/// This represents 'ordered' clause in the '#pragma omp ...' directive.
2008///
2009/// \code
2010/// #pragma omp for ordered (2)
2011/// \endcode
2012/// In this example directive '#pragma omp for' has 'ordered' clause with
2013/// parameter 2.
2015 : public OMPClause,
2016 private llvm::TrailingObjects<OMPOrderedClause, Expr *> {
2017 friend class OMPClauseReader;
2018 friend TrailingObjects;
2019
2020 /// Location of '('.
2021 SourceLocation LParenLoc;
2022
2023 /// Number of for-loops.
2024 Stmt *NumForLoops = nullptr;
2025
2026 /// Real number of loops.
2027 unsigned NumberOfLoops = 0;
2028
2029 /// Build 'ordered' clause.
2030 ///
2031 /// \param Num Expression, possibly associated with this clause.
2032 /// \param NumLoops Number of loops, associated with this clause.
2033 /// \param StartLoc Starting location of the clause.
2034 /// \param LParenLoc Location of '('.
2035 /// \param EndLoc Ending location of the clause.
2036 OMPOrderedClause(Expr *Num, unsigned NumLoops, SourceLocation StartLoc,
2037 SourceLocation LParenLoc, SourceLocation EndLoc)
2038 : OMPClause(llvm::omp::OMPC_ordered, StartLoc, EndLoc),
2039 LParenLoc(LParenLoc), NumForLoops(Num), NumberOfLoops(NumLoops) {}
2040
2041 /// Build an empty clause.
2042 explicit OMPOrderedClause(unsigned NumLoops)
2043 : OMPClause(llvm::omp::OMPC_ordered, SourceLocation(), SourceLocation()),
2044 NumberOfLoops(NumLoops) {}
2045
2046 /// Set the number of associated for-loops.
2047 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
2048
2049public:
2050 /// Build 'ordered' clause.
2051 ///
2052 /// \param Num Expression, possibly associated with this clause.
2053 /// \param NumLoops Number of loops, associated with this clause.
2054 /// \param StartLoc Starting location of the clause.
2055 /// \param LParenLoc Location of '('.
2056 /// \param EndLoc Ending location of the clause.
2057 static OMPOrderedClause *Create(const ASTContext &C, Expr *Num,
2058 unsigned NumLoops, SourceLocation StartLoc,
2059 SourceLocation LParenLoc,
2060 SourceLocation EndLoc);
2061
2062 /// Build an empty clause.
2063 static OMPOrderedClause* CreateEmpty(const ASTContext &C, unsigned NumLoops);
2064
2065 /// Sets the location of '('.
2066 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2067
2068 /// Returns the location of '('.
2069 SourceLocation getLParenLoc() const { return LParenLoc; }
2070
2071 /// Return the number of associated for-loops.
2072 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
2073
2074 /// Set number of iterations for the specified loop.
2075 void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations);
2076 /// Get number of iterations for all the loops.
2078
2079 /// Set loop counter for the specified loop.
2080 void setLoopCounter(unsigned NumLoop, Expr *Counter);
2081 /// Get loops counter for the specified loop.
2082 Expr *getLoopCounter(unsigned NumLoop);
2083 const Expr *getLoopCounter(unsigned NumLoop) const;
2084
2085 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
2086
2088 return const_child_range(&NumForLoops, &NumForLoops + 1);
2089 }
2090
2093 }
2096 }
2097
2098 static bool classof(const OMPClause *T) {
2099 return T->getClauseKind() == llvm::omp::OMPC_ordered;
2100 }
2101};
2102
2103/// This represents 'nowait' clause in the '#pragma omp ...' directive.
2104///
2105/// \code
2106/// #pragma omp for nowait
2107/// \endcode
2108/// In this example directive '#pragma omp for' has 'nowait' clause.
2109class OMPNowaitClause final : public OMPNoChildClause<llvm::omp::OMPC_nowait> {
2110public:
2111 /// Build 'nowait' clause.
2112 ///
2113 /// \param StartLoc Starting location of the clause.
2114 /// \param EndLoc Ending location of the clause.
2116 SourceLocation EndLoc = SourceLocation())
2117 : OMPNoChildClause(StartLoc, EndLoc) {}
2118};
2119
2120/// This represents 'untied' clause in the '#pragma omp ...' directive.
2121///
2122/// \code
2123/// #pragma omp task untied
2124/// \endcode
2125/// In this example directive '#pragma omp task' has 'untied' clause.
2127public:
2128 /// Build 'untied' clause.
2129 ///
2130 /// \param StartLoc Starting location of the clause.
2131 /// \param EndLoc Ending location of the clause.
2133 : OMPClause(llvm::omp::OMPC_untied, StartLoc, EndLoc) {}
2134
2135 /// Build an empty clause.
2137 : OMPClause(llvm::omp::OMPC_untied, SourceLocation(), SourceLocation()) {}
2138
2141 }
2142
2145 }
2146
2149 }
2152 }
2153
2154 static bool classof(const OMPClause *T) {
2155 return T->getClauseKind() == llvm::omp::OMPC_untied;
2156 }
2157};
2158
2159/// This represents 'mergeable' clause in the '#pragma omp ...'
2160/// directive.
2161///
2162/// \code
2163/// #pragma omp task mergeable
2164/// \endcode
2165/// In this example directive '#pragma omp task' has 'mergeable' clause.
2167public:
2168 /// Build 'mergeable' clause.
2169 ///
2170 /// \param StartLoc Starting location of the clause.
2171 /// \param EndLoc Ending location of the clause.
2173 : OMPClause(llvm::omp::OMPC_mergeable, StartLoc, EndLoc) {}
2174
2175 /// Build an empty clause.
2177 : OMPClause(llvm::omp::OMPC_mergeable, SourceLocation(),
2178 SourceLocation()) {}
2179
2182 }
2183
2186 }
2187
2190 }
2193 }
2194
2195 static bool classof(const OMPClause *T) {
2196 return T->getClauseKind() == llvm::omp::OMPC_mergeable;
2197 }
2198};
2199
2200/// This represents the 'absent' clause in the '#pragma omp assume'
2201/// directive.
2202///
2203/// \code
2204/// #pragma omp assume absent(<directive-name list>)
2205/// \endcode
2206/// In this example directive '#pragma omp assume' has an 'absent' clause.
2208 : public OMPDirectiveListClause<OMPAbsentClause>,
2209 private llvm::TrailingObjects<OMPAbsentClause, OpenMPDirectiveKind> {
2211 friend TrailingObjects;
2212
2213 /// Build 'absent' clause.
2214 ///
2215 /// \param StartLoc Starting location of the clause.
2216 /// \param LParenLoc Location of '('.
2217 /// \param EndLoc Ending location of the clause.
2218 /// \param NumKinds Number of directive kinds listed in the clause.
2219 OMPAbsentClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2220 SourceLocation EndLoc, unsigned NumKinds)
2222 llvm::omp::OMPC_absent, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2223
2224 /// Build an empty clause.
2225 OMPAbsentClause(unsigned NumKinds)
2227 llvm::omp::OMPC_absent, SourceLocation(), SourceLocation(),
2229
2230public:
2231 static OMPAbsentClause *Create(const ASTContext &C,
2234 SourceLocation RLoc);
2235
2236 static OMPAbsentClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2237
2238 static bool classof(const OMPClause *C) {
2239 return C->getClauseKind() == llvm::omp::OMPC_absent;
2240 }
2241};
2242
2243/// This represents the 'contains' clause in the '#pragma omp assume'
2244/// directive.
2245///
2246/// \code
2247/// #pragma omp assume contains(<directive-name list>)
2248/// \endcode
2249/// In this example directive '#pragma omp assume' has a 'contains' clause.
2251 : public OMPDirectiveListClause<OMPContainsClause>,
2252 private llvm::TrailingObjects<OMPContainsClause, OpenMPDirectiveKind> {
2254 friend TrailingObjects;
2255
2256 /// Build 'contains' clause.
2257 ///
2258 /// \param StartLoc Starting location of the clause.
2259 /// \param LParenLoc Location of '('.
2260 /// \param EndLoc Ending location of the clause.
2261 /// \param NumKinds Number of directive kinds listed in the clause.
2263 SourceLocation EndLoc, unsigned NumKinds)
2265 llvm::omp::OMPC_contains, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2266
2267 /// Build an empty clause.
2268 OMPContainsClause(unsigned NumKinds)
2270 llvm::omp::OMPC_contains, SourceLocation(), SourceLocation(),
2272
2273public:
2274 static OMPContainsClause *Create(const ASTContext &C,
2277 SourceLocation RLoc);
2278
2279 static OMPContainsClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2280
2281 static bool classof(const OMPClause *C) {
2282 return C->getClauseKind() == llvm::omp::OMPC_contains;
2283 }
2284};
2285
2286/// This represents the 'holds' clause in the '#pragma omp assume'
2287/// directive.
2288///
2289/// \code
2290/// #pragma omp assume holds(<expr>)
2291/// \endcode
2292/// In this example directive '#pragma omp assume' has a 'holds' clause.
2294 : public OMPOneStmtClause<llvm::omp::OMPC_holds, OMPClause> {
2295 friend class OMPClauseReader;
2296
2297public:
2298 /// Build 'holds' clause.
2299 ///
2300 /// \param StartLoc Starting location of the clause.
2301 /// \param EndLoc Ending location of the clause.
2303 SourceLocation EndLoc)
2304 : OMPOneStmtClause(E, StartLoc, LParenLoc, EndLoc) {}
2305
2306 /// Build an empty clause.
2308
2309 Expr *getExpr() const { return getStmtAs<Expr>(); }
2310 void setExpr(Expr *E) { setStmt(E); }
2311};
2312
2313/// This represents the 'no_openmp' clause in the '#pragma omp assume'
2314/// directive.
2315///
2316/// \code
2317/// #pragma omp assume no_openmp
2318/// \endcode
2319/// In this example directive '#pragma omp assume' has a 'no_openmp' clause.
2321 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp> {
2322public:
2323 /// Build 'no_openmp' clause.
2324 ///
2325 /// \param StartLoc Starting location of the clause.
2326 /// \param EndLoc Ending location of the clause.
2328 : OMPNoChildClause(StartLoc, EndLoc) {}
2329
2330 /// Build an empty clause.
2332};
2333
2334/// This represents the 'no_openmp_routines' clause in the '#pragma omp assume'
2335/// directive.
2336///
2337/// \code
2338/// #pragma omp assume no_openmp_routines
2339/// \endcode
2340/// In this example directive '#pragma omp assume' has a 'no_openmp_routines'
2341/// clause.
2343 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp_routines> {
2344public:
2345 /// Build 'no_openmp_routines' clause.
2346 ///
2347 /// \param StartLoc Starting location of the clause.
2348 /// \param EndLoc Ending location of the clause.
2350 : OMPNoChildClause(StartLoc, EndLoc) {}
2351
2352 /// Build an empty clause.
2354};
2355
2356/// This represents the 'no_parallelism' clause in the '#pragma omp assume'
2357/// directive.
2358///
2359/// \code
2360/// #pragma omp assume no_parallelism
2361/// \endcode
2362/// In this example directive '#pragma omp assume' has a 'no_parallelism'
2363/// clause.
2365 : public OMPNoChildClause<llvm::omp::OMPC_no_parallelism> {
2366public:
2367 /// Build 'no_parallelism' clause.
2368 ///
2369 /// \param StartLoc Starting location of the clause.
2370 /// \param EndLoc Ending location of the clause.
2372 : OMPNoChildClause(StartLoc, EndLoc) {}
2373
2374 /// Build an empty clause.
2376};
2377
2378/// This represents 'read' clause in the '#pragma omp atomic' directive.
2379///
2380/// \code
2381/// #pragma omp atomic read
2382/// \endcode
2383/// In this example directive '#pragma omp atomic' has 'read' clause.
2384class OMPReadClause : public OMPClause {
2385public:
2386 /// Build 'read' clause.
2387 ///
2388 /// \param StartLoc Starting location of the clause.
2389 /// \param EndLoc Ending location of the clause.
2391 : OMPClause(llvm::omp::OMPC_read, StartLoc, EndLoc) {}
2392
2393 /// Build an empty clause.
2395 : OMPClause(llvm::omp::OMPC_read, SourceLocation(), SourceLocation()) {}
2396
2399 }
2400
2403 }
2404
2407 }
2410 }
2411
2412 static bool classof(const OMPClause *T) {
2413 return T->getClauseKind() == llvm::omp::OMPC_read;
2414 }
2415};
2416
2417/// This represents 'write' clause in the '#pragma omp atomic' directive.
2418///
2419/// \code
2420/// #pragma omp atomic write
2421/// \endcode
2422/// In this example directive '#pragma omp atomic' has 'write' clause.
2424public:
2425 /// Build 'write' clause.
2426 ///
2427 /// \param StartLoc Starting location of the clause.
2428 /// \param EndLoc Ending location of the clause.
2430 : OMPClause(llvm::omp::OMPC_write, StartLoc, EndLoc) {}
2431
2432 /// Build an empty clause.
2434 : OMPClause(llvm::omp::OMPC_write, SourceLocation(), SourceLocation()) {}
2435
2438 }
2439
2442 }
2443
2446 }
2449 }
2450
2451 static bool classof(const OMPClause *T) {
2452 return T->getClauseKind() == llvm::omp::OMPC_write;
2453 }
2454};
2455
2456/// This represents 'update' clause in the '#pragma omp atomic'
2457/// directive.
2458///
2459/// \code
2460/// #pragma omp atomic update
2461/// \endcode
2462/// In this example directive '#pragma omp atomic' has 'update' clause.
2463/// Also, this class represents 'update' clause in '#pragma omp depobj'
2464/// directive.
2465///
2466/// \code
2467/// #pragma omp depobj(a) update(in)
2468/// \endcode
2469/// In this example directive '#pragma omp depobj' has 'update' clause with 'in'
2470/// dependence kind.
2472 : public OMPClause,
2473 private llvm::TrailingObjects<OMPUpdateClause, SourceLocation,
2474 OpenMPDependClauseKind> {
2475 friend class OMPClauseReader;
2476 friend TrailingObjects;
2477
2478 /// true if extended version of the clause for 'depobj' directive.
2479 bool IsExtended = false;
2480
2481 /// Define the sizes of each trailing object array except the last one. This
2482 /// is required for TrailingObjects to work properly.
2483 size_t numTrailingObjects(OverloadToken<SourceLocation>) const {
2484 // 2 locations: for '(' and argument location.
2485 return IsExtended ? 2 : 0;
2486 }
2487
2488 /// Sets the location of '(' in clause for 'depobj' directive.
2489 void setLParenLoc(SourceLocation Loc) {
2490 assert(IsExtended && "Expected extended clause.");
2491 *getTrailingObjects<SourceLocation>() = Loc;
2492 }
2493
2494 /// Sets the location of '(' in clause for 'depobj' directive.
2495 void setArgumentLoc(SourceLocation Loc) {
2496 assert(IsExtended && "Expected extended clause.");
2497 *std::next(getTrailingObjects<SourceLocation>(), 1) = Loc;
2498 }
2499
2500 /// Sets the dependence kind for the clause for 'depobj' directive.
2501 void setDependencyKind(OpenMPDependClauseKind DK) {
2502 assert(IsExtended && "Expected extended clause.");
2503 *getTrailingObjects<OpenMPDependClauseKind>() = DK;
2504 }
2505
2506 /// Build 'update' clause.
2507 ///
2508 /// \param StartLoc Starting location of the clause.
2509 /// \param EndLoc Ending location of the clause.
2510 OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc,
2511 bool IsExtended)
2512 : OMPClause(llvm::omp::OMPC_update, StartLoc, EndLoc),
2513 IsExtended(IsExtended) {}
2514
2515 /// Build an empty clause.
2516 OMPUpdateClause(bool IsExtended)
2517 : OMPClause(llvm::omp::OMPC_update, SourceLocation(), SourceLocation()),
2518 IsExtended(IsExtended) {}
2519
2520public:
2521 /// Creates clause for 'atomic' directive.
2522 ///
2523 /// \param C AST context.
2524 /// \param StartLoc Starting location of the clause.
2525 /// \param EndLoc Ending location of the clause.
2526 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2527 SourceLocation EndLoc);
2528
2529 /// Creates clause for 'depobj' directive.
2530 ///
2531 /// \param C AST context.
2532 /// \param StartLoc Starting location of the clause.
2533 /// \param LParenLoc Location of '('.
2534 /// \param ArgumentLoc Location of the argument.
2535 /// \param DK Dependence kind.
2536 /// \param EndLoc Ending location of the clause.
2537 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2538 SourceLocation LParenLoc,
2539 SourceLocation ArgumentLoc,
2541 SourceLocation EndLoc);
2542
2543 /// Creates an empty clause with the place for \a N variables.
2544 ///
2545 /// \param C AST context.
2546 /// \param IsExtended true if extended clause for 'depobj' directive must be
2547 /// created.
2548 static OMPUpdateClause *CreateEmpty(const ASTContext &C, bool IsExtended);
2549
2550 /// Checks if the clause is the extended clauses for 'depobj' directive.
2551 bool isExtended() const { return IsExtended; }
2552
2555 }
2556
2559 }
2560
2563 }
2566 }
2567
2568 /// Gets the location of '(' in clause for 'depobj' directive.
2570 assert(IsExtended && "Expected extended clause.");
2571 return *getTrailingObjects<SourceLocation>();
2572 }
2573
2574 /// Gets the location of argument in clause for 'depobj' directive.
2576 assert(IsExtended && "Expected extended clause.");
2577 return *std::next(getTrailingObjects<SourceLocation>(), 1);
2578 }
2579
2580 /// Gets the dependence kind in clause for 'depobj' directive.
2582 assert(IsExtended && "Expected extended clause.");
2583 return *getTrailingObjects<OpenMPDependClauseKind>();
2584 }
2585
2586 static bool classof(const OMPClause *T) {
2587 return T->getClauseKind() == llvm::omp::OMPC_update;
2588 }
2589};
2590
2591/// This represents 'capture' clause in the '#pragma omp atomic'
2592/// directive.
2593///
2594/// \code
2595/// #pragma omp atomic capture
2596/// \endcode
2597/// In this example directive '#pragma omp atomic' has 'capture' clause.
2599public:
2600 /// Build 'capture' clause.
2601 ///
2602 /// \param StartLoc Starting location of the clause.
2603 /// \param EndLoc Ending location of the clause.
2605 : OMPClause(llvm::omp::OMPC_capture, StartLoc, EndLoc) {}
2606
2607 /// Build an empty clause.
2609 : OMPClause(llvm::omp::OMPC_capture, SourceLocation(), SourceLocation()) {
2610 }
2611
2614 }
2615
2618 }
2619
2622 }
2625 }
2626
2627 static bool classof(const OMPClause *T) {
2628 return T->getClauseKind() == llvm::omp::OMPC_capture;
2629 }
2630};
2631
2632/// This represents 'compare' clause in the '#pragma omp atomic'
2633/// directive.
2634///
2635/// \code
2636/// #pragma omp atomic compare
2637/// \endcode
2638/// In this example directive '#pragma omp atomic' has 'compare' clause.
2639class OMPCompareClause final : public OMPClause {
2640public:
2641 /// Build 'compare' clause.
2642 ///
2643 /// \param StartLoc Starting location of the clause.
2644 /// \param EndLoc Ending location of the clause.
2646 : OMPClause(llvm::omp::OMPC_compare, StartLoc, EndLoc) {}
2647
2648 /// Build an empty clause.
2650 : OMPClause(llvm::omp::OMPC_compare, SourceLocation(), SourceLocation()) {
2651 }
2652
2655 }
2656
2659 }
2660
2663 }
2666 }
2667
2668 static bool classof(const OMPClause *T) {
2669 return T->getClauseKind() == llvm::omp::OMPC_compare;
2670 }
2671};
2672
2673/// This represents 'seq_cst' clause in the '#pragma omp atomic|flush'
2674/// directives.
2675///
2676/// \code
2677/// #pragma omp atomic seq_cst
2678/// \endcode
2679/// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
2681public:
2682 /// Build 'seq_cst' clause.
2683 ///
2684 /// \param StartLoc Starting location of the clause.
2685 /// \param EndLoc Ending location of the clause.
2687 : OMPClause(llvm::omp::OMPC_seq_cst, StartLoc, EndLoc) {}
2688
2689 /// Build an empty clause.
2691 : OMPClause(llvm::omp::OMPC_seq_cst, SourceLocation(), SourceLocation()) {
2692 }
2693
2696 }
2697
2700 }
2701
2704 }
2707 }
2708
2709 static bool classof(const OMPClause *T) {
2710 return T->getClauseKind() == llvm::omp::OMPC_seq_cst;
2711 }
2712};
2713
2714/// This represents 'acq_rel' clause in the '#pragma omp atomic|flush'
2715/// directives.
2716///
2717/// \code
2718/// #pragma omp flush acq_rel
2719/// \endcode
2720/// In this example directive '#pragma omp flush' has 'acq_rel' clause.
2721class OMPAcqRelClause final : public OMPClause {
2722public:
2723 /// Build 'ack_rel' clause.
2724 ///
2725 /// \param StartLoc Starting location of the clause.
2726 /// \param EndLoc Ending location of the clause.
2728 : OMPClause(llvm::omp::OMPC_acq_rel, StartLoc, EndLoc) {}
2729
2730 /// Build an empty clause.
2732 : OMPClause(llvm::omp::OMPC_acq_rel, SourceLocation(), SourceLocation()) {
2733 }
2734
2737 }
2738
2741 }
2742
2745 }
2748 }
2749
2750 static bool classof(const OMPClause *T) {
2751 return T->getClauseKind() == llvm::omp::OMPC_acq_rel;
2752 }
2753};
2754
2755/// This represents 'acquire' clause in the '#pragma omp atomic|flush'
2756/// directives.
2757///
2758/// \code
2759/// #pragma omp flush acquire
2760/// \endcode
2761/// In this example directive '#pragma omp flush' has 'acquire' clause.
2762class OMPAcquireClause final : public OMPClause {
2763public:
2764 /// Build 'acquire' clause.
2765 ///
2766 /// \param StartLoc Starting location of the clause.
2767 /// \param EndLoc Ending location of the clause.
2769 : OMPClause(llvm::omp::OMPC_acquire, StartLoc, EndLoc) {}
2770
2771 /// Build an empty clause.
2773 : OMPClause(llvm::omp::OMPC_acquire, SourceLocation(), SourceLocation()) {
2774 }
2775
2778 }
2779
2782 }
2783
2786 }
2789 }
2790
2791 static bool classof(const OMPClause *T) {
2792 return T->getClauseKind() == llvm::omp::OMPC_acquire;
2793 }
2794};
2795
2796/// This represents 'release' clause in the '#pragma omp atomic|flush'
2797/// directives.
2798///
2799/// \code
2800/// #pragma omp flush release
2801/// \endcode
2802/// In this example directive '#pragma omp flush' has 'release' clause.
2803class OMPReleaseClause final : public OMPClause {
2804public:
2805 /// Build 'release' clause.
2806 ///
2807 /// \param StartLoc Starting location of the clause.
2808 /// \param EndLoc Ending location of the clause.
2810 : OMPClause(llvm::omp::OMPC_release, StartLoc, EndLoc) {}
2811
2812 /// Build an empty clause.
2814 : OMPClause(llvm::omp::OMPC_release, SourceLocation(), SourceLocation()) {
2815 }
2816
2819 }
2820
2823 }
2824
2827 }
2830 }
2831
2832 static bool classof(const OMPClause *T) {
2833 return T->getClauseKind() == llvm::omp::OMPC_release;
2834 }
2835};
2836
2837/// This represents 'relaxed' clause in the '#pragma omp atomic'
2838/// directives.
2839///
2840/// \code
2841/// #pragma omp atomic relaxed
2842/// \endcode
2843/// In this example directive '#pragma omp atomic' has 'relaxed' clause.
2844class OMPRelaxedClause final : public OMPClause {
2845public:
2846 /// Build 'relaxed' clause.
2847 ///
2848 /// \param StartLoc Starting location of the clause.
2849 /// \param EndLoc Ending location of the clause.
2851 : OMPClause(llvm::omp::OMPC_relaxed, StartLoc, EndLoc) {}
2852
2853 /// Build an empty clause.
2855 : OMPClause(llvm::omp::OMPC_relaxed, SourceLocation(), SourceLocation()) {
2856 }
2857
2860 }
2861
2864 }
2865
2868 }
2871 }
2872
2873 static bool classof(const OMPClause *T) {
2874 return T->getClauseKind() == llvm::omp::OMPC_relaxed;
2875 }
2876};
2877
2878/// This represents 'weak' clause in the '#pragma omp atomic'
2879/// directives.
2880///
2881/// \code
2882/// #pragma omp atomic compare weak
2883/// \endcode
2884/// In this example directive '#pragma omp atomic' has 'weak' clause.
2885class OMPWeakClause final : public OMPClause {
2886public:
2887 /// Build 'weak' clause.
2888 ///
2889 /// \param StartLoc Starting location of the clause.
2890 /// \param EndLoc Ending location of the clause.
2892 : OMPClause(llvm::omp::OMPC_weak, StartLoc, EndLoc) {}
2893
2894 /// Build an empty clause.
2896 : OMPClause(llvm::omp::OMPC_weak, SourceLocation(), SourceLocation()) {}
2897
2900 }
2901
2904 }
2905
2908 }
2911 }
2912
2913 static bool classof(const OMPClause *T) {
2914 return T->getClauseKind() == llvm::omp::OMPC_weak;
2915 }
2916};
2917
2918/// This represents 'fail' clause in the '#pragma omp atomic'
2919/// directive.
2920///
2921/// \code
2922/// #pragma omp atomic compare fail
2923/// \endcode
2924/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
2925class OMPFailClause final : public OMPClause {
2926
2927 // FailParameter is a memory-order-clause. Storing the ClauseKind is
2928 // sufficient for our purpose.
2929 OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
2930 SourceLocation FailParameterLoc;
2931 SourceLocation LParenLoc;
2932
2933 friend class OMPClauseReader;
2934
2935 /// Sets the location of '(' in fail clause.
2936 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2937
2938 /// Sets the location of memoryOrder clause argument in fail clause.
2939 void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
2940
2941 /// Sets the mem_order clause for 'atomic compare fail' directive.
2942 void setFailParameter(OpenMPClauseKind FailParameter) {
2943 this->FailParameter = FailParameter;
2944 assert(checkFailClauseParameter(FailParameter) &&
2945 "Invalid fail clause parameter");
2946 }
2947
2948public:
2949 /// Build 'fail' clause.
2950 ///
2951 /// \param StartLoc Starting location of the clause.
2952 /// \param EndLoc Ending location of the clause.
2954 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
2955
2956 OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation FailParameterLoc,
2957 SourceLocation StartLoc, SourceLocation LParenLoc,
2958 SourceLocation EndLoc)
2959 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
2960 FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
2961
2962 setFailParameter(FailParameter);
2963 }
2964
2965 /// Build an empty clause.
2967 : OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
2968
2971 }
2972
2975 }
2976
2979 }
2982 }
2983
2984 static bool classof(const OMPClause *T) {
2985 return T->getClauseKind() == llvm::omp::OMPC_fail;
2986 }
2987
2988 /// Gets the location of '(' (for the parameter) in fail clause.
2990 return LParenLoc;
2991 }
2992
2993 /// Gets the location of Fail Parameter (type memory-order-clause) in
2994 /// fail clause.
2995 SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
2996
2997 /// Gets the parameter (type memory-order-clause) in Fail clause.
2998 OpenMPClauseKind getFailParameter() const { return FailParameter; }
2999};
3000
3001/// This represents clause 'private' in the '#pragma omp ...' directives.
3002///
3003/// \code
3004/// #pragma omp parallel private(a,b)
3005/// \endcode
3006/// In this example directive '#pragma omp parallel' has clause 'private'
3007/// with the variables 'a' and 'b'.
3009 : public OMPVarListClause<OMPPrivateClause>,
3010 private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
3011 friend class OMPClauseReader;
3012 friend OMPVarListClause;
3013 friend TrailingObjects;
3014
3015 /// Build clause with number of variables \a N.
3016 ///
3017 /// \param StartLoc Starting location of the clause.
3018 /// \param LParenLoc Location of '('.
3019 /// \param EndLoc Ending location of the clause.
3020 /// \param N Number of the variables in the clause.
3022 SourceLocation EndLoc, unsigned N)
3023 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private, StartLoc,
3024 LParenLoc, EndLoc, N) {}
3025
3026 /// Build an empty clause.
3027 ///
3028 /// \param N Number of variables.
3029 explicit OMPPrivateClause(unsigned N)
3030 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private,
3032 SourceLocation(), N) {}
3033
3034 /// Sets the list of references to private copies with initializers for
3035 /// new private variables.
3036 /// \param VL List of references.
3037 void setPrivateCopies(ArrayRef<Expr *> VL);
3038
3039 /// Gets the list of references to private copies with initializers for
3040 /// new private variables.
3041 MutableArrayRef<Expr *> getPrivateCopies() {
3042 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3043 }
3044 ArrayRef<const Expr *> getPrivateCopies() const {
3046 }
3047
3048public:
3049 /// Creates clause with a list of variables \a VL.
3050 ///
3051 /// \param C AST context.
3052 /// \param StartLoc Starting location of the clause.
3053 /// \param LParenLoc Location of '('.
3054 /// \param EndLoc Ending location of the clause.
3055 /// \param VL List of references to the variables.
3056 /// \param PrivateVL List of references to private copies with initializers.
3057 static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
3058 SourceLocation LParenLoc,
3059 SourceLocation EndLoc, ArrayRef<Expr *> VL,
3060 ArrayRef<Expr *> PrivateVL);
3061
3062 /// Creates an empty clause with the place for \a N variables.
3063 ///
3064 /// \param C AST context.
3065 /// \param N The number of variables.
3066 static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3067
3070 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
3072 llvm::iterator_range<private_copies_const_iterator>;
3073
3075 return private_copies_range(getPrivateCopies().begin(),
3076 getPrivateCopies().end());
3077 }
3078
3080 return private_copies_const_range(getPrivateCopies().begin(),
3081 getPrivateCopies().end());
3082 }
3083
3085 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3086 reinterpret_cast<Stmt **>(varlist_end()));
3087 }
3088
3090 auto Children = const_cast<OMPPrivateClause *>(this)->children();
3091 return const_child_range(Children.begin(), Children.end());
3092 }
3093
3096 }
3099 }
3100
3101 static bool classof(const OMPClause *T) {
3102 return T->getClauseKind() == llvm::omp::OMPC_private;
3103 }
3104};
3105
3106/// This represents clause 'firstprivate' in the '#pragma omp ...'
3107/// directives.
3108///
3109/// \code
3110/// #pragma omp parallel firstprivate(a,b)
3111/// \endcode
3112/// In this example directive '#pragma omp parallel' has clause 'firstprivate'
3113/// with the variables 'a' and 'b'.
3115 : public OMPVarListClause<OMPFirstprivateClause>,
3116 public OMPClauseWithPreInit,
3117 private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
3118 friend class OMPClauseReader;
3119 friend OMPVarListClause;
3120 friend TrailingObjects;
3121
3122 /// Build clause with number of variables \a N.
3123 ///
3124 /// \param StartLoc Starting location of the clause.
3125 /// \param LParenLoc Location of '('.
3126 /// \param EndLoc Ending location of the clause.
3127 /// \param N Number of the variables in the clause.
3129 SourceLocation EndLoc, unsigned N)
3130 : OMPVarListClause<OMPFirstprivateClause>(llvm::omp::OMPC_firstprivate,
3131 StartLoc, LParenLoc, EndLoc, N),
3132 OMPClauseWithPreInit(this) {}
3133
3134 /// Build an empty clause.
3135 ///
3136 /// \param N Number of variables.
3137 explicit OMPFirstprivateClause(unsigned N)
3139 llvm::omp::OMPC_firstprivate, SourceLocation(), SourceLocation(),
3140 SourceLocation(), N),
3141 OMPClauseWithPreInit(this) {}
3142
3143 /// Sets the list of references to private copies with initializers for
3144 /// new private variables.
3145 /// \param VL List of references.
3146 void setPrivateCopies(ArrayRef<Expr *> VL);
3147
3148 /// Gets the list of references to private copies with initializers for
3149 /// new private variables.
3150 MutableArrayRef<Expr *> getPrivateCopies() {
3151 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3152 }
3153 ArrayRef<const Expr *> getPrivateCopies() const {
3155 }
3156
3157 /// Sets the list of references to initializer variables for new
3158 /// private variables.
3159 /// \param VL List of references.
3160 void setInits(ArrayRef<Expr *> VL);
3161
3162 /// Gets the list of references to initializer variables for new
3163 /// private variables.
3164 MutableArrayRef<Expr *> getInits() {
3165 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
3166 }
3167 ArrayRef<const Expr *> getInits() const {
3168 return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
3169 }
3170
3171public:
3172 /// Creates clause with a list of variables \a VL.
3173 ///
3174 /// \param C AST context.
3175 /// \param StartLoc Starting location of the clause.
3176 /// \param LParenLoc Location of '('.
3177 /// \param EndLoc Ending location of the clause.
3178 /// \param VL List of references to the original variables.
3179 /// \param PrivateVL List of references to private copies with initializers.
3180 /// \param InitVL List of references to auto generated variables used for
3181 /// initialization of a single array element. Used if firstprivate variable is
3182 /// of array type.
3183 /// \param PreInit Statement that must be executed before entering the OpenMP
3184 /// region with this clause.
3185 static OMPFirstprivateClause *
3186 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3187 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
3188 ArrayRef<Expr *> InitVL, Stmt *PreInit);
3189
3190 /// Creates an empty clause with the place for \a N variables.
3191 ///
3192 /// \param C AST context.
3193 /// \param N The number of variables.
3194 static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3195
3198 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
3200 llvm::iterator_range<private_copies_const_iterator>;
3201
3203 return private_copies_range(getPrivateCopies().begin(),
3204 getPrivateCopies().end());
3205 }
3207 return private_copies_const_range(getPrivateCopies().begin(),
3208 getPrivateCopies().end());
3209 }
3210
3213 using inits_range = llvm::iterator_range<inits_iterator>;
3214 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
3215
3217 return inits_range(getInits().begin(), getInits().end());
3218 }
3220 return inits_const_range(getInits().begin(), getInits().end());
3221 }
3222
3224 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3225 reinterpret_cast<Stmt **>(varlist_end()));
3226 }
3227
3229 auto Children = const_cast<OMPFirstprivateClause *>(this)->children();
3230 return const_child_range(Children.begin(), Children.end());
3231 }
3232
3234 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3235 reinterpret_cast<Stmt **>(varlist_end()));
3236 }
3238 auto Children = const_cast<OMPFirstprivateClause *>(this)->used_children();
3239 return const_child_range(Children.begin(), Children.end());
3240 }
3241
3242 static bool classof(const OMPClause *T) {
3243 return T->getClauseKind() == llvm::omp::OMPC_firstprivate;
3244 }
3245};
3246
3247/// This represents clause 'lastprivate' in the '#pragma omp ...'
3248/// directives.
3249///
3250/// \code
3251/// #pragma omp simd lastprivate(a,b)
3252/// \endcode
3253/// In this example directive '#pragma omp simd' has clause 'lastprivate'
3254/// with the variables 'a' and 'b'.
3256 : public OMPVarListClause<OMPLastprivateClause>,
3258 private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
3259 // There are 4 additional tail-allocated arrays at the end of the class:
3260 // 1. Contains list of pseudo variables with the default initialization for
3261 // each non-firstprivate variables. Used in codegen for initialization of
3262 // lastprivate copies.
3263 // 2. List of helper expressions for proper generation of assignment operation
3264 // required for lastprivate clause. This list represents private variables
3265 // (for arrays, single array element).
3266 // 3. List of helper expressions for proper generation of assignment operation
3267 // required for lastprivate clause. This list represents original variables
3268 // (for arrays, single array element).
3269 // 4. List of helper expressions that represents assignment operation:
3270 // \code
3271 // DstExprs = SrcExprs;
3272 // \endcode
3273 // Required for proper codegen of final assignment performed by the
3274 // lastprivate clause.
3275 friend class OMPClauseReader;
3276 friend OMPVarListClause;
3277 friend TrailingObjects;
3278
3279 /// Optional lastprivate kind, e.g. 'conditional', if specified by user.
3281 /// Optional location of the lasptrivate kind, if specified by user.
3282 SourceLocation LPKindLoc;
3283 /// Optional colon location, if specified by user.
3284 SourceLocation ColonLoc;
3285
3286 /// Build clause with number of variables \a N.
3287 ///
3288 /// \param StartLoc Starting location of the clause.
3289 /// \param LParenLoc Location of '('.
3290 /// \param EndLoc Ending location of the clause.
3291 /// \param N Number of the variables in the clause.
3294 SourceLocation LPKindLoc, SourceLocation ColonLoc,
3295 unsigned N)
3296 : OMPVarListClause<OMPLastprivateClause>(llvm::omp::OMPC_lastprivate,
3297 StartLoc, LParenLoc, EndLoc, N),
3298 OMPClauseWithPostUpdate(this), LPKind(LPKind), LPKindLoc(LPKindLoc),
3299 ColonLoc(ColonLoc) {}
3300
3301 /// Build an empty clause.
3302 ///
3303 /// \param N Number of variables.
3304 explicit OMPLastprivateClause(unsigned N)
3306 llvm::omp::OMPC_lastprivate, SourceLocation(), SourceLocation(),
3307 SourceLocation(), N),
3309
3310 /// Get the list of helper expressions for initialization of private
3311 /// copies for lastprivate variables.
3312 MutableArrayRef<Expr *> getPrivateCopies() {
3313 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3314 }
3315 ArrayRef<const Expr *> getPrivateCopies() const {
3317 }
3318
3319 /// Set list of helper expressions, required for proper codegen of the
3320 /// clause. These expressions represent private variables (for arrays, single
3321 /// array element) in the final assignment statement performed by the
3322 /// lastprivate clause.
3323 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
3324
3325 /// Get the list of helper source expressions.
3326 MutableArrayRef<Expr *> getSourceExprs() {
3327 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
3328 }
3329 ArrayRef<const Expr *> getSourceExprs() const {
3330 return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
3331 }
3332
3333 /// Set list of helper expressions, required for proper codegen of the
3334 /// clause. These expressions represent original variables (for arrays, single
3335 /// array element) in the final assignment statement performed by the
3336 /// lastprivate clause.
3337 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
3338
3339 /// Get the list of helper destination expressions.
3340 MutableArrayRef<Expr *> getDestinationExprs() {
3341 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
3342 }
3343 ArrayRef<const Expr *> getDestinationExprs() const {
3344 return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
3345 }
3346
3347 /// Set list of helper assignment expressions, required for proper
3348 /// codegen of the clause. These expressions are assignment expressions that
3349 /// assign private copy of the variable to original variable.
3350 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
3351
3352 /// Get the list of helper assignment expressions.
3353 MutableArrayRef<Expr *> getAssignmentOps() {
3354 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
3355 }
3356 ArrayRef<const Expr *> getAssignmentOps() const {
3357 return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
3358 }
3359
3360 /// Sets lastprivate kind.
3361 void setKind(OpenMPLastprivateModifier Kind) { LPKind = Kind; }
3362 /// Sets location of the lastprivate kind.
3363 void setKindLoc(SourceLocation Loc) { LPKindLoc = Loc; }
3364 /// Sets colon symbol location.
3365 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3366
3367public:
3368 /// Creates clause with a list of variables \a VL.
3369 ///
3370 /// \param C AST context.
3371 /// \param StartLoc Starting location of the clause.
3372 /// \param LParenLoc Location of '('.
3373 /// \param EndLoc Ending location of the clause.
3374 /// \param VL List of references to the variables.
3375 /// \param SrcExprs List of helper expressions for proper generation of
3376 /// assignment operation required for lastprivate clause. This list represents
3377 /// private variables (for arrays, single array element).
3378 /// \param DstExprs List of helper expressions for proper generation of
3379 /// assignment operation required for lastprivate clause. This list represents
3380 /// original variables (for arrays, single array element).
3381 /// \param AssignmentOps List of helper expressions that represents assignment
3382 /// operation:
3383 /// \code
3384 /// DstExprs = SrcExprs;
3385 /// \endcode
3386 /// Required for proper codegen of final assignment performed by the
3387 /// lastprivate clause.
3388 /// \param LPKind Lastprivate kind, e.g. 'conditional'.
3389 /// \param LPKindLoc Location of the lastprivate kind.
3390 /// \param ColonLoc Location of the ':' symbol if lastprivate kind is used.
3391 /// \param PreInit Statement that must be executed before entering the OpenMP
3392 /// region with this clause.
3393 /// \param PostUpdate Expression that must be executed after exit from the
3394 /// OpenMP region with this clause.
3395 static OMPLastprivateClause *
3396 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3397 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
3398 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
3399 OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
3400 SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate);
3401
3402 /// Creates an empty clause with the place for \a N variables.
3403 ///
3404 /// \param C AST context.
3405 /// \param N The number of variables.
3406 static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3407
3408 /// Lastprivate kind.
3409 OpenMPLastprivateModifier getKind() const { return LPKind; }
3410 /// Returns the location of the lastprivate kind.
3411 SourceLocation getKindLoc() const { return LPKindLoc; }
3412 /// Returns the location of the ':' symbol, if any.
3413 SourceLocation getColonLoc() const { return ColonLoc; }
3414
3417 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3419 llvm::iterator_range<helper_expr_const_iterator>;
3420
3421 /// Set list of helper expressions, required for generation of private
3422 /// copies of original lastprivate variables.
3423 void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
3424
3426 return helper_expr_const_range(getPrivateCopies().begin(),
3427 getPrivateCopies().end());
3428 }
3429
3431 return helper_expr_range(getPrivateCopies().begin(),
3432 getPrivateCopies().end());
3433 }
3434
3436 return helper_expr_const_range(getSourceExprs().begin(),
3437 getSourceExprs().end());
3438 }
3439
3441 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
3442 }
3443
3445 return helper_expr_const_range(getDestinationExprs().begin(),
3446 getDestinationExprs().end());
3447 }
3448
3450 return helper_expr_range(getDestinationExprs().begin(),
3451 getDestinationExprs().end());
3452 }
3453
3455 return helper_expr_const_range(getAssignmentOps().begin(),
3456 getAssignmentOps().end());
3457 }
3458
3460 return helper_expr_range(getAssignmentOps().begin(),
3461 getAssignmentOps().end());
3462 }
3463
3465 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3466 reinterpret_cast<Stmt **>(varlist_end()));
3467 }
3468
3470 auto Children = const_cast<OMPLastprivateClause *>(this)->children();
3471 return const_child_range(Children.begin(), Children.end());
3472 }
3473
3476 }
3479 }
3480
3481 static bool classof(const OMPClause *T) {
3482 return T->getClauseKind() == llvm::omp::OMPC_lastprivate;
3483 }
3484};
3485
3486/// This represents clause 'shared' in the '#pragma omp ...' directives.
3487///
3488/// \code
3489/// #pragma omp parallel shared(a,b)
3490/// \endcode
3491/// In this example directive '#pragma omp parallel' has clause 'shared'
3492/// with the variables 'a' and 'b'.
3494 : public OMPVarListClause<OMPSharedClause>,
3495 private llvm::TrailingObjects<OMPSharedClause, Expr *> {
3496 friend OMPVarListClause;
3497 friend TrailingObjects;
3498
3499 /// Build clause with number of variables \a N.
3500 ///
3501 /// \param StartLoc Starting location of the clause.
3502 /// \param LParenLoc Location of '('.
3503 /// \param EndLoc Ending location of the clause.
3504 /// \param N Number of the variables in the clause.
3505 OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3506 SourceLocation EndLoc, unsigned N)
3507 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared, StartLoc,
3508 LParenLoc, EndLoc, N) {}
3509
3510 /// Build an empty clause.
3511 ///
3512 /// \param N Number of variables.
3513 explicit OMPSharedClause(unsigned N)
3514 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared,
3516 SourceLocation(), N) {}
3517
3518public:
3519 /// Creates clause with a list of variables \a VL.
3520 ///
3521 /// \param C AST context.
3522 /// \param StartLoc Starting location of the clause.
3523 /// \param LParenLoc Location of '('.
3524 /// \param EndLoc Ending location of the clause.
3525 /// \param VL List of references to the variables.
3526 static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
3527 SourceLocation LParenLoc,
3528 SourceLocation EndLoc, ArrayRef<Expr *> VL);
3529
3530 /// Creates an empty clause with \a N variables.
3531 ///
3532 /// \param C AST context.
3533 /// \param N The number of variables.
3534 static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
3535
3537 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3538 reinterpret_cast<Stmt **>(varlist_end()));
3539 }
3540
3542 auto Children = const_cast<OMPSharedClause *>(this)->children();
3543 return const_child_range(Children.begin(), Children.end());
3544 }
3545
3548 }
3551 }
3552
3553 static bool classof(const OMPClause *T) {
3554 return T->getClauseKind() == llvm::omp::OMPC_shared;
3555 }
3556};
3557
3558/// This represents clause 'reduction' in the '#pragma omp ...'
3559/// directives.
3560///
3561/// \code
3562/// #pragma omp parallel reduction(+:a,b)
3563/// \endcode
3564/// In this example directive '#pragma omp parallel' has clause 'reduction'
3565/// with operator '+' and the variables 'a' and 'b'.
3567 : public OMPVarListClause<OMPReductionClause>,
3569 private llvm::TrailingObjects<OMPReductionClause, Expr *> {
3570 friend class OMPClauseReader;
3571 friend OMPVarListClause;
3572 friend TrailingObjects;
3573
3574 /// Reduction modifier.
3576
3577 /// Reduction modifier location.
3578 SourceLocation ModifierLoc;
3579
3580 /// Location of ':'.
3581 SourceLocation ColonLoc;
3582
3583 /// Nested name specifier for C++.
3584 NestedNameSpecifierLoc QualifierLoc;
3585
3586 /// Name of custom operator.
3587 DeclarationNameInfo NameInfo;
3588
3589 /// Build clause with number of variables \a N.
3590 ///
3591 /// \param StartLoc Starting location of the clause.
3592 /// \param LParenLoc Location of '('.
3593 /// \param ModifierLoc Modifier location.
3594 /// \param ColonLoc Location of ':'.
3595 /// \param EndLoc Ending location of the clause.
3596 /// \param N Number of the variables in the clause.
3597 /// \param QualifierLoc The nested-name qualifier with location information
3598 /// \param NameInfo The full name info for reduction identifier.
3600 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3601 SourceLocation EndLoc,
3602 OpenMPReductionClauseModifier Modifier, unsigned N,
3603 NestedNameSpecifierLoc QualifierLoc,
3604 const DeclarationNameInfo &NameInfo)
3605 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3606 StartLoc, LParenLoc, EndLoc, N),
3607 OMPClauseWithPostUpdate(this), Modifier(Modifier),
3608 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
3609 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3610
3611 /// Build an empty clause.
3612 ///
3613 /// \param N Number of variables.
3614 explicit OMPReductionClause(unsigned N)
3615 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3617 SourceLocation(), N),
3619
3620 /// Sets reduction modifier.
3621 void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; }
3622
3623 /// Sets location of the modifier.
3624 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
3625
3626 /// Sets location of ':' symbol in clause.
3627 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3628
3629 /// Sets the name info for specified reduction identifier.
3630 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3631
3632 /// Sets the nested name specifier.
3633 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3634
3635 /// Set list of helper expressions, required for proper codegen of the
3636 /// clause. These expressions represent private copy of the reduction
3637 /// variable.
3638 void setPrivates(ArrayRef<Expr *> Privates);
3639
3640 /// Get the list of helper privates.
3641 MutableArrayRef<Expr *> getPrivates() {
3642 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3643 }
3644 ArrayRef<const Expr *> getPrivates() const {
3646 }
3647
3648 /// Set list of helper expressions, required for proper codegen of the
3649 /// clause. These expressions represent LHS expression in the final
3650 /// reduction expression performed by the reduction clause.
3651 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3652
3653 /// Get the list of helper LHS expressions.
3654 MutableArrayRef<Expr *> getLHSExprs() {
3655 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
3656 }
3657 ArrayRef<const Expr *> getLHSExprs() const {
3658 return llvm::ArrayRef(getPrivates().end(), varlist_size());
3659 }
3660
3661 /// Set list of helper expressions, required for proper codegen of the
3662 /// clause. These expressions represent RHS expression in the final
3663 /// reduction expression performed by the reduction clause.
3664 /// Also, variables in these expressions are used for proper initialization of
3665 /// reduction copies.
3666 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3667
3668 /// Get the list of helper destination expressions.
3669 MutableArrayRef<Expr *> getRHSExprs() {
3670 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3671 }
3672 ArrayRef<const Expr *> getRHSExprs() const {
3673 return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
3674 }
3675
3676 /// Set list of helper reduction expressions, required for proper
3677 /// codegen of the clause. These expressions are binary expressions or
3678 /// operator/custom reduction call that calculates new value from source
3679 /// helper expressions to destination helper expressions.
3680 void setReductionOps(ArrayRef<Expr *> ReductionOps);
3681
3682 /// Get the list of helper reduction expressions.
3683 MutableArrayRef<Expr *> getReductionOps() {
3684 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
3685 }
3686 ArrayRef<const Expr *> getReductionOps() const {
3687 return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
3688 }
3689
3690 /// Set list of helper copy operations for inscan reductions.
3691 /// The form is: Temps[i] = LHS[i];
3692 void setInscanCopyOps(ArrayRef<Expr *> Ops);
3693
3694 /// Get the list of helper inscan copy operations.
3695 MutableArrayRef<Expr *> getInscanCopyOps() {
3696 return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size());
3697 }
3698 ArrayRef<const Expr *> getInscanCopyOps() const {
3699 return llvm::ArrayRef(getReductionOps().end(), varlist_size());
3700 }
3701
3702 /// Set list of helper temp vars for inscan copy array operations.
3703 void setInscanCopyArrayTemps(ArrayRef<Expr *> CopyArrayTemps);
3704
3705 /// Get the list of helper inscan copy temps.
3706 MutableArrayRef<Expr *> getInscanCopyArrayTemps() {
3707 return MutableArrayRef<Expr *>(getInscanCopyOps().end(), varlist_size());
3708 }
3709 ArrayRef<const Expr *> getInscanCopyArrayTemps() const {
3710 return llvm::ArrayRef(getInscanCopyOps().end(), varlist_size());
3711 }
3712
3713 /// Set list of helper temp elements vars for inscan copy array operations.
3714 void setInscanCopyArrayElems(ArrayRef<Expr *> CopyArrayElems);
3715
3716 /// Get the list of helper inscan copy temps.
3717 MutableArrayRef<Expr *> getInscanCopyArrayElems() {
3718 return MutableArrayRef<Expr *>(getInscanCopyArrayTemps().end(),
3719 varlist_size());
3720 }
3721 ArrayRef<const Expr *> getInscanCopyArrayElems() const {
3722 return llvm::ArrayRef(getInscanCopyArrayTemps().end(), varlist_size());
3723 }
3724
3725public:
3726 /// Creates clause with a list of variables \a VL.
3727 ///
3728 /// \param StartLoc Starting location of the clause.
3729 /// \param LParenLoc Location of '('.
3730 /// \param ModifierLoc Modifier location.
3731 /// \param ColonLoc Location of ':'.
3732 /// \param EndLoc Ending location of the clause.
3733 /// \param VL The variables in the clause.
3734 /// \param QualifierLoc The nested-name qualifier with location information
3735 /// \param NameInfo The full name info for reduction identifier.
3736 /// \param Privates List of helper expressions for proper generation of
3737 /// private copies.
3738 /// \param LHSExprs List of helper expressions for proper generation of
3739 /// assignment operation required for copyprivate clause. This list represents
3740 /// LHSs of the reduction expressions.
3741 /// \param RHSExprs List of helper expressions for proper generation of
3742 /// assignment operation required for copyprivate clause. This list represents
3743 /// RHSs of the reduction expressions.
3744 /// Also, variables in these expressions are used for proper initialization of
3745 /// reduction copies.
3746 /// \param ReductionOps List of helper expressions that represents reduction
3747 /// expressions:
3748 /// \code
3749 /// LHSExprs binop RHSExprs;
3750 /// operator binop(LHSExpr, RHSExpr);
3751 /// <CutomReduction>(LHSExpr, RHSExpr);
3752 /// \endcode
3753 /// Required for proper codegen of final reduction operation performed by the
3754 /// reduction clause.
3755 /// \param CopyOps List of copy operations for inscan reductions:
3756 /// \code
3757 /// TempExprs = LHSExprs;
3758 /// \endcode
3759 /// \param CopyArrayTemps Temp arrays for prefix sums.
3760 /// \param CopyArrayElems Temp arrays for prefix sums.
3761 /// \param PreInit Statement that must be executed before entering the OpenMP
3762 /// region with this clause.
3763 /// \param PostUpdate Expression that must be executed after exit from the
3764 /// OpenMP region with this clause.
3765 static OMPReductionClause *
3766 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3767 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3768 SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier,
3769 ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc,
3770 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
3771 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
3772 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps,
3773 ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems,
3774 Stmt *PreInit, Expr *PostUpdate);
3775
3776 /// Creates an empty clause with the place for \a N variables.
3777 ///
3778 /// \param C AST context.
3779 /// \param N The number of variables.
3780 /// \param Modifier Reduction modifier.
3781 static OMPReductionClause *
3782 CreateEmpty(const ASTContext &C, unsigned N,
3784
3785 /// Returns modifier.
3786 OpenMPReductionClauseModifier getModifier() const { return Modifier; }
3787
3788 /// Returns modifier location.
3789 SourceLocation getModifierLoc() const { return ModifierLoc; }
3790
3791 /// Gets location of ':' symbol in clause.
3792 SourceLocation getColonLoc() const { return ColonLoc; }
3793
3794 /// Gets the name info for specified reduction identifier.
3795 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3796
3797 /// Gets the nested name specifier.
3798 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3799
3802 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3804 llvm::iterator_range<helper_expr_const_iterator>;
3805
3807 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
3808 }
3809
3811 return helper_expr_range(getPrivates().begin(), getPrivates().end());
3812 }
3813
3815 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
3816 }
3817
3819 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
3820 }
3821
3823 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
3824 }
3825
3827 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
3828 }
3829
3831 return helper_expr_const_range(getReductionOps().begin(),
3832 getReductionOps().end());
3833 }
3834
3836 return helper_expr_range(getReductionOps().begin(),
3837 getReductionOps().end());
3838 }
3839
3841 return helper_expr_const_range(getInscanCopyOps().begin(),
3842 getInscanCopyOps().end());
3843 }
3844
3846 return helper_expr_range(getInscanCopyOps().begin(),
3847 getInscanCopyOps().end());
3848 }
3849
3851 return helper_expr_const_range(getInscanCopyArrayTemps().begin(),
3852 getInscanCopyArrayTemps().end());
3853 }
3854
3856 return helper_expr_range(getInscanCopyArrayTemps().begin(),
3857 getInscanCopyArrayTemps().end());
3858 }
3859
3861 return helper_expr_const_range(getInscanCopyArrayElems().begin(),
3862 getInscanCopyArrayElems().end());
3863 }
3864
3866 return helper_expr_range(getInscanCopyArrayElems().begin(),
3867 getInscanCopyArrayElems().end());
3868 }
3869
3871 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3872 reinterpret_cast<Stmt **>(varlist_end()));
3873 }
3874
3876 auto Children = const_cast<OMPReductionClause *>(this)->children();
3877 return const_child_range(Children.begin(), Children.end());
3878 }
3879
3881 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3882 reinterpret_cast<Stmt **>(varlist_end()));
3883 }
3885 auto Children = const_cast<OMPReductionClause *>(this)->used_children();
3886 return const_child_range(Children.begin(), Children.end());
3887 }
3888
3889 static bool classof(const OMPClause *T) {
3890 return T->getClauseKind() == llvm::omp::OMPC_reduction;
3891 }
3892};
3893
3894/// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
3895/// directives.
3896///
3897/// \code
3898/// #pragma omp taskgroup task_reduction(+:a,b)
3899/// \endcode
3900/// In this example directive '#pragma omp taskgroup' has clause
3901/// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
3903 : public OMPVarListClause<OMPTaskReductionClause>,
3905 private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> {
3906 friend class OMPClauseReader;
3907 friend OMPVarListClause;
3908 friend TrailingObjects;
3909
3910 /// Location of ':'.
3911 SourceLocation ColonLoc;
3912
3913 /// Nested name specifier for C++.
3914 NestedNameSpecifierLoc QualifierLoc;
3915
3916 /// Name of custom operator.
3917 DeclarationNameInfo NameInfo;
3918
3919 /// Build clause with number of variables \a N.
3920 ///
3921 /// \param StartLoc Starting location of the clause.
3922 /// \param LParenLoc Location of '('.
3923 /// \param EndLoc Ending location of the clause.
3924 /// \param ColonLoc Location of ':'.
3925 /// \param N Number of the variables in the clause.
3926 /// \param QualifierLoc The nested-name qualifier with location information
3927 /// \param NameInfo The full name info for reduction identifier.
3929 SourceLocation ColonLoc, SourceLocation EndLoc,
3930 unsigned N, NestedNameSpecifierLoc QualifierLoc,
3931 const DeclarationNameInfo &NameInfo)
3933 llvm::omp::OMPC_task_reduction, StartLoc, LParenLoc, EndLoc, N),
3934 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
3935 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3936
3937 /// Build an empty clause.
3938 ///
3939 /// \param N Number of variables.
3940 explicit OMPTaskReductionClause(unsigned N)
3942 llvm::omp::OMPC_task_reduction, SourceLocation(), SourceLocation(),
3943 SourceLocation(), N),
3945
3946 /// Sets location of ':' symbol in clause.
3947 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3948
3949 /// Sets the name info for specified reduction identifier.
3950 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3951
3952 /// Sets the nested name specifier.
3953 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3954
3955 /// Set list of helper expressions, required for proper codegen of the clause.
3956 /// These expressions represent private copy of the reduction variable.
3957 void setPrivates(ArrayRef<Expr *> Privates);
3958
3959 /// Get the list of helper privates.
3960 MutableArrayRef<Expr *> getPrivates() {
3961 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3962 }
3963 ArrayRef<const Expr *> getPrivates() const {
3965 }
3966
3967 /// Set list of helper expressions, required for proper codegen of the clause.
3968 /// These expressions represent LHS expression in the final reduction
3969 /// expression performed by the reduction clause.
3970 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3971
3972 /// Get the list of helper LHS expressions.
3973 MutableArrayRef<Expr *> getLHSExprs() {
3974 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
3975 }
3976 ArrayRef<const Expr *> getLHSExprs() const {
3977 return llvm::ArrayRef(getPrivates().end(), varlist_size());
3978 }
3979
3980 /// Set list of helper expressions, required for proper codegen of the clause.
3981 /// These expressions represent RHS expression in the final reduction
3982 /// expression performed by the reduction clause. Also, variables in these
3983 /// expressions are used for proper initialization of reduction copies.
3984 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3985
3986 /// Get the list of helper destination expressions.
3987 MutableArrayRef<Expr *> getRHSExprs() {
3988 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3989 }
3990 ArrayRef<const Expr *> getRHSExprs() const {
3991 return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
3992 }
3993
3994 /// Set list of helper reduction expressions, required for proper
3995 /// codegen of the clause. These expressions are binary expressions or
3996 /// operator/custom reduction call that calculates new value from source
3997 /// helper expressions to destination helper expressions.
3998 void setReductionOps(ArrayRef<Expr *> ReductionOps);
3999
4000 /// Get the list of helper reduction expressions.
4001 MutableArrayRef<Expr *> getReductionOps() {
4002 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
4003 }
4004 ArrayRef<const Expr *> getReductionOps() const {
4005 return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
4006 }
4007
4008public:
4009 /// Creates clause with a list of variables \a VL.
4010 ///
4011 /// \param StartLoc Starting location of the clause.
4012 /// \param LParenLoc Location of '('.
4013 /// \param ColonLoc Location of ':'.
4014 /// \param EndLoc Ending location of the clause.
4015 /// \param VL The variables in the clause.
4016 /// \param QualifierLoc The nested-name qualifier with location information
4017 /// \param NameInfo The full name info for reduction identifier.
4018 /// \param Privates List of helper expressions for proper generation of
4019 /// private copies.
4020 /// \param LHSExprs List of helper expressions for proper generation of
4021 /// assignment operation required for copyprivate clause. This list represents
4022 /// LHSs of the reduction expressions.
4023 /// \param RHSExprs List of helper expressions for proper generation of
4024 /// assignment operation required for copyprivate clause. This list represents
4025 /// RHSs of the reduction expressions.
4026 /// Also, variables in these expressions are used for proper initialization of
4027 /// reduction copies.
4028 /// \param ReductionOps List of helper expressions that represents reduction
4029 /// expressions:
4030 /// \code
4031 /// LHSExprs binop RHSExprs;
4032 /// operator binop(LHSExpr, RHSExpr);
4033 /// <CutomReduction>(LHSExpr, RHSExpr);
4034 /// \endcode
4035 /// Required for proper codegen of final reduction operation performed by the
4036 /// reduction clause.
4037 /// \param PreInit Statement that must be executed before entering the OpenMP
4038 /// region with this clause.
4039 /// \param PostUpdate Expression that must be executed after exit from the
4040 /// OpenMP region with this clause.
4041 static OMPTaskReductionClause *
4042 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4043 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
4044 NestedNameSpecifierLoc QualifierLoc,
4045 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4046 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4047 ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
4048
4049 /// Creates an empty clause with the place for \a N variables.
4050 ///
4051 /// \param C AST context.
4052 /// \param N The number of variables.
4053 static OMPTaskReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
4054
4055 /// Gets location of ':' symbol in clause.
4056 SourceLocation getColonLoc() const { return ColonLoc; }
4057
4058 /// Gets the name info for specified reduction identifier.
4059 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4060
4061 /// Gets the nested name specifier.
4062 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4063
4066 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4068 llvm::iterator_range<helper_expr_const_iterator>;
4069
4071 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
4072 }
4073
4075 return helper_expr_range(getPrivates().begin(), getPrivates().end());
4076 }
4077
4079 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
4080 }
4081
4083 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
4084 }
4085
4087 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
4088 }
4089
4091 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
4092 }
4093
4095 return helper_expr_const_range(getReductionOps().begin(),
4096 getReductionOps().end());
4097 }
4098
4100 return helper_expr_range(getReductionOps().begin(),
4101 getReductionOps().end());
4102 }
4103
4105 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4106 reinterpret_cast<Stmt **>(varlist_end()));
4107 }
4108
4110 auto Children = const_cast<OMPTaskReductionClause *>(this)->children();
4111 return const_child_range(Children.begin(), Children.end());
4112 }
4113
4116 }
4119 }
4120
4121 static bool classof(const OMPClause *T) {
4122 return T->getClauseKind() == llvm::omp::OMPC_task_reduction;
4123 }
4124};
4125
4126/// This represents clause 'in_reduction' in the '#pragma omp task' directives.
4127///
4128/// \code
4129/// #pragma omp task in_reduction(+:a,b)
4130/// \endcode
4131/// In this example directive '#pragma omp task' has clause 'in_reduction' with
4132/// operator '+' and the variables 'a' and 'b'.
4134 : public OMPVarListClause<OMPInReductionClause>,
4136 private llvm::TrailingObjects<OMPInReductionClause, Expr *> {
4137 friend class OMPClauseReader;
4138 friend OMPVarListClause;
4139 friend TrailingObjects;
4140
4141 /// Location of ':'.
4142 SourceLocation ColonLoc;
4143
4144 /// Nested name specifier for C++.
4145 NestedNameSpecifierLoc QualifierLoc;
4146
4147 /// Name of custom operator.
4148 DeclarationNameInfo NameInfo;
4149
4150 /// Build clause with number of variables \a N.
4151 ///
4152 /// \param StartLoc Starting location of the clause.
4153 /// \param LParenLoc Location of '('.
4154 /// \param EndLoc Ending location of the clause.
4155 /// \param ColonLoc Location of ':'.
4156 /// \param N Number of the variables in the clause.
4157 /// \param QualifierLoc The nested-name qualifier with location information
4158 /// \param NameInfo The full name info for reduction identifier.
4160 SourceLocation ColonLoc, SourceLocation EndLoc,
4161 unsigned N, NestedNameSpecifierLoc QualifierLoc,
4162 const DeclarationNameInfo &NameInfo)
4163 : OMPVarListClause<OMPInReductionClause>(llvm::omp::OMPC_in_reduction,
4164 StartLoc, LParenLoc, EndLoc, N),
4165 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
4166 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
4167
4168 /// Build an empty clause.
4169 ///
4170 /// \param N Number of variables.
4171 explicit OMPInReductionClause(unsigned N)
4173 llvm::omp::OMPC_in_reduction, SourceLocation(), SourceLocation(),
4174 SourceLocation(), N),
4176
4177 /// Sets location of ':' symbol in clause.
4178 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
4179
4180 /// Sets the name info for specified reduction identifier.
4181 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
4182
4183 /// Sets the nested name specifier.
4184 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
4185
4186 /// Set list of helper expressions, required for proper codegen of the clause.
4187 /// These expressions represent private copy of the reduction variable.
4188 void setPrivates(ArrayRef<Expr *> Privates);
4189
4190 /// Get the list of helper privates.
4191 MutableArrayRef<Expr *> getPrivates() {
4192 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4193 }
4194 ArrayRef<const Expr *> getPrivates() const {
4196 }
4197
4198 /// Set list of helper expressions, required for proper codegen of the clause.
4199 /// These expressions represent LHS expression in the final reduction
4200 /// expression performed by the reduction clause.
4201 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
4202
4203 /// Get the list of helper LHS expressions.
4204 MutableArrayRef<Expr *> getLHSExprs() {
4205 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
4206 }
4207 ArrayRef<const Expr *> getLHSExprs() const {
4208 return llvm::ArrayRef(getPrivates().end(), varlist_size());
4209 }
4210
4211 /// Set list of helper expressions, required for proper codegen of the clause.
4212 /// These expressions represent RHS expression in the final reduction
4213 /// expression performed by the reduction clause. Also, variables in these
4214 /// expressions are used for proper initialization of reduction copies.
4215 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
4216
4217 /// Get the list of helper destination expressions.
4218 MutableArrayRef<Expr *> getRHSExprs() {
4219 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
4220 }
4221 ArrayRef<const Expr *> getRHSExprs() const {
4222 return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
4223 }
4224
4225 /// Set list of helper reduction expressions, required for proper
4226 /// codegen of the clause. These expressions are binary expressions or
4227 /// operator/custom reduction call that calculates new value from source
4228 /// helper expressions to destination helper expressions.
4229 void setReductionOps(ArrayRef<Expr *> ReductionOps);
4230
4231 /// Get the list of helper reduction expressions.
4232 MutableArrayRef<Expr *> getReductionOps() {
4233 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
4234 }
4235 ArrayRef<const Expr *> getReductionOps() const {
4236 return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
4237 }
4238
4239 /// Set list of helper reduction taskgroup descriptors.
4240 void setTaskgroupDescriptors(ArrayRef<Expr *> ReductionOps);
4241
4242 /// Get the list of helper reduction taskgroup descriptors.
4243 MutableArrayRef<Expr *> getTaskgroupDescriptors() {
4244 return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size());
4245 }
4246 ArrayRef<const Expr *> getTaskgroupDescriptors() const {
4247 return llvm::ArrayRef(getReductionOps().end(), varlist_size());
4248 }
4249
4250public:
4251 /// Creates clause with a list of variables \a VL.
4252 ///
4253 /// \param StartLoc Starting location of the clause.
4254 /// \param LParenLoc Location of '('.
4255 /// \param ColonLoc Location of ':'.
4256 /// \param EndLoc Ending location of the clause.
4257 /// \param VL The variables in the clause.
4258 /// \param QualifierLoc The nested-name qualifier with location information
4259 /// \param NameInfo The full name info for reduction identifier.
4260 /// \param Privates List of helper expressions for proper generation of
4261 /// private copies.
4262 /// \param LHSExprs List of helper expressions for proper generation of
4263 /// assignment operation required for copyprivate clause. This list represents
4264 /// LHSs of the reduction expressions.
4265 /// \param RHSExprs List of helper expressions for proper generation of
4266 /// assignment operation required for copyprivate clause. This list represents
4267 /// RHSs of the reduction expressions.
4268 /// Also, variables in these expressions are used for proper initialization of
4269 /// reduction copies.
4270 /// \param ReductionOps List of helper expressions that represents reduction
4271 /// expressions:
4272 /// \code
4273 /// LHSExprs binop RHSExprs;
4274 /// operator binop(LHSExpr, RHSExpr);
4275 /// <CutomReduction>(LHSExpr, RHSExpr);
4276 /// \endcode
4277 /// Required for proper codegen of final reduction operation performed by the
4278 /// reduction clause.
4279 /// \param TaskgroupDescriptors List of helper taskgroup descriptors for
4280 /// corresponding items in parent taskgroup task_reduction clause.
4281 /// \param PreInit Statement that must be executed before entering the OpenMP
4282 /// region with this clause.
4283 /// \param PostUpdate Expression that must be executed after exit from the
4284 /// OpenMP region with this clause.
4285 static OMPInReductionClause *
4286 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4287 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
4288 NestedNameSpecifierLoc QualifierLoc,
4289 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4290 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4291 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> TaskgroupDescriptors,
4292 Stmt *PreInit, Expr *PostUpdate);
4293
4294 /// Creates an empty clause with the place for \a N variables.
4295 ///
4296 /// \param C AST context.
4297 /// \param N The number of variables.
4298 static OMPInReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
4299
4300 /// Gets location of ':' symbol in clause.
4301 SourceLocation getColonLoc() const { return ColonLoc; }
4302
4303 /// Gets the name info for specified reduction identifier.
4304 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4305
4306 /// Gets the nested name specifier.
4307 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4308
4311 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4313 llvm::iterator_range<helper_expr_const_iterator>;
4314
4316 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
4317 }
4318
4320 return helper_expr_range(getPrivates().begin(), getPrivates().end());
4321 }
4322
4324 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
4325 }
4326
4328 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
4329 }
4330
4332 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
4333 }
4334
4336 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
4337 }
4338
4340 return helper_expr_const_range(getReductionOps().begin(),
4341 getReductionOps().end());
4342 }
4343
4345 return helper_expr_range(getReductionOps().begin(),
4346 getReductionOps().end());
4347 }
4348
4350 return helper_expr_const_range(getTaskgroupDescriptors().begin(),
4351 getTaskgroupDescriptors().end());
4352 }
4353
4355 return helper_expr_range(getTaskgroupDescriptors().begin(),
4356 getTaskgroupDescriptors().end());
4357 }
4358
4360 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4361 reinterpret_cast<Stmt **>(varlist_end()));
4362 }
4363
4365 auto Children = const_cast<OMPInReductionClause *>(this)->children();
4366 return const_child_range(Children.begin(), Children.end());
4367 }
4368
4371 }
4374 }
4375
4376 static bool classof(const OMPClause *T) {
4377 return T->getClauseKind() == llvm::omp::OMPC_in_reduction;
4378 }
4379};
4380
4381/// This represents clause 'linear' in the '#pragma omp ...'
4382/// directives.
4383///
4384/// \code
4385/// #pragma omp simd linear(a,b : 2)
4386/// \endcode
4387/// In this example directive '#pragma omp simd' has clause 'linear'
4388/// with variables 'a', 'b' and linear step '2'.
4390 : public OMPVarListClause<OMPLinearClause>,
4392 private llvm::TrailingObjects<OMPLinearClause, Expr *> {
4393 friend class OMPClauseReader;
4394 friend OMPVarListClause;
4395 friend TrailingObjects;
4396
4397 /// Modifier of 'linear' clause.
4398 OpenMPLinearClauseKind Modifier = OMPC_LINEAR_val;
4399
4400 /// Location of linear modifier if any.
4401 SourceLocation ModifierLoc;
4402
4403 /// Location of ':'.
4404 SourceLocation ColonLoc;
4405
4406 /// Location of 'step' modifier.
4407 SourceLocation StepModifierLoc;
4408
4409 /// Sets the linear step for clause.
4410 void setStep(Expr *Step) { *(getFinals().end()) = Step; }
4411
4412 /// Sets the expression to calculate linear step for clause.
4413 void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
4414
4415 /// Build 'linear' clause with given number of variables \a NumVars.
4416 ///
4417 /// \param StartLoc Starting location of the clause.
4418 /// \param LParenLoc Location of '('.
4419 /// \param ColonLoc Location of ':'.
4420 /// \param StepModifierLoc Location of 'step' modifier.
4421 /// \param EndLoc Ending location of the clause.
4422 /// \param NumVars Number of variables.
4423 OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4424 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4425 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4426 SourceLocation EndLoc, unsigned NumVars)
4427 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear, StartLoc,
4428 LParenLoc, EndLoc, NumVars),
4429 OMPClauseWithPostUpdate(this), Modifier(Modifier),
4430 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
4431 StepModifierLoc(StepModifierLoc) {}
4432
4433 /// Build an empty clause.
4434 ///
4435 /// \param NumVars Number of variables.
4436 explicit OMPLinearClause(unsigned NumVars)
4437 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear,
4438 SourceLocation(), SourceLocation(),
4439 SourceLocation(), NumVars),
4441
4442 /// Gets the list of initial values for linear variables.
4443 ///
4444 /// There are NumVars expressions with initial values allocated after the
4445 /// varlist, they are followed by NumVars update expressions (used to update
4446 /// the linear variable's value on current iteration) and they are followed by
4447 /// NumVars final expressions (used to calculate the linear variable's
4448 /// value after the loop body). After these lists, there are 2 helper
4449 /// expressions - linear step and a helper to calculate it before the
4450 /// loop body (used when the linear step is not constant):
4451 ///
4452 /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
4453 /// Finals[]; Step; CalcStep; }
4454 MutableArrayRef<Expr *> getPrivates() {
4455 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4456 }
4457 ArrayRef<const Expr *> getPrivates() const {
4459 }
4460
4461 MutableArrayRef<Expr *> getInits() {
4462 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
4463 }
4464 ArrayRef<const Expr *> getInits() const {
4465 return llvm::ArrayRef(getPrivates().end(), varlist_size());
4466 }
4467
4468 /// Sets the list of update expressions for linear variables.
4469 MutableArrayRef<Expr *> getUpdates() {
4470 return MutableArrayRef<Expr *>(getInits().end(), varlist_size());
4471 }
4472 ArrayRef<const Expr *> getUpdates() const {
4473 return llvm::ArrayRef(getInits().end(), varlist_size());
4474 }
4475
4476 /// Sets the list of final update expressions for linear variables.
4477 MutableArrayRef<Expr *> getFinals() {
4478 return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size());
4479 }
4480 ArrayRef<const Expr *> getFinals() const {
4481 return llvm::ArrayRef(getUpdates().end(), varlist_size());
4482 }
4483
4484 /// Gets the list of used expressions for linear variables.
4485 MutableArrayRef<Expr *> getUsedExprs() {
4486 return MutableArrayRef<Expr *>(getFinals().end() + 2, varlist_size() + 1);
4487 }
4488 ArrayRef<const Expr *> getUsedExprs() const {
4489 return llvm::ArrayRef(getFinals().end() + 2, varlist_size() + 1);
4490 }
4491
4492 /// Sets the list of the copies of original linear variables.
4493 /// \param PL List of expressions.
4494 void setPrivates(ArrayRef<Expr *> PL);
4495
4496 /// Sets the list of the initial values for linear variables.
4497 /// \param IL List of expressions.
4498 void setInits(ArrayRef<Expr *> IL);
4499
4500public:
4501 /// Creates clause with a list of variables \a VL and a linear step
4502 /// \a Step.
4503 ///
4504 /// \param C AST Context.
4505 /// \param StartLoc Starting location of the clause.
4506 /// \param LParenLoc Location of '('.
4507 /// \param Modifier Modifier of 'linear' clause.
4508 /// \param ModifierLoc Modifier location.
4509 /// \param ColonLoc Location of ':'.
4510 /// \param StepModifierLoc Location of 'step' modifier.
4511 /// \param EndLoc Ending location of the clause.
4512 /// \param VL List of references to the variables.
4513 /// \param PL List of private copies of original variables.
4514 /// \param IL List of initial values for the variables.
4515 /// \param Step Linear step.
4516 /// \param CalcStep Calculation of the linear step.
4517 /// \param PreInit Statement that must be executed before entering the OpenMP
4518 /// region with this clause.
4519 /// \param PostUpdate Expression that must be executed after exit from the
4520 /// OpenMP region with this clause.
4521 static OMPLinearClause *
4522 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4523 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4524 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4525 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PL,
4526 ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit,
4527 Expr *PostUpdate);
4528
4529 /// Creates an empty clause with the place for \a NumVars variables.
4530 ///
4531 /// \param C AST context.
4532 /// \param NumVars Number of variables.
4533 static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4534
4535 /// Set modifier.
4537
4538 /// Return modifier.
4539 OpenMPLinearClauseKind getModifier() const { return Modifier; }
4540
4541 /// Set modifier location.
4542 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
4543
4544 /// Return modifier location.
4545 SourceLocation getModifierLoc() const { return ModifierLoc; }
4546
4547 /// Sets the location of ':'.
4548 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4549
4550 /// Sets the location of 'step' modifier.
4551 void setStepModifierLoc(SourceLocation Loc) { StepModifierLoc = Loc; }
4552
4553 /// Returns the location of ':'.
4554 SourceLocation getColonLoc() const { return ColonLoc; }
4555
4556 /// Returns the location of 'step' modifier.
4557 SourceLocation getStepModifierLoc() const { return StepModifierLoc; }
4558
4559 /// Returns linear step.
4560 Expr *getStep() { return *(getFinals().end()); }
4561
4562 /// Returns linear step.
4563 const Expr *getStep() const { return *(getFinals().end()); }
4564
4565 /// Returns expression to calculate linear step.
4566 Expr *getCalcStep() { return *(getFinals().end() + 1); }
4567
4568 /// Returns expression to calculate linear step.
4569 const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
4570
4571 /// Sets the list of update expressions for linear variables.
4572 /// \param UL List of expressions.
4574
4575 /// Sets the list of final update expressions for linear variables.
4576 /// \param FL List of expressions.
4577 void setFinals(ArrayRef<Expr *> FL);
4578
4579 /// Sets the list of used expressions for the linear clause.
4581
4584 using privates_range = llvm::iterator_range<privates_iterator>;
4585 using privates_const_range = llvm::iterator_range<privates_const_iterator>;
4586
4588 return privates_range(getPrivates().begin(), getPrivates().end());
4589 }
4590
4592 return privates_const_range(getPrivates().begin(), getPrivates().end());
4593 }
4594
4597 using inits_range = llvm::iterator_range<inits_iterator>;
4598 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
4599
4601 return inits_range(getInits().begin(), getInits().end());
4602 }
4603
4605 return inits_const_range(getInits().begin(), getInits().end());
4606 }
4607
4610 using updates_range = llvm::iterator_range<updates_iterator>;
4611 using updates_const_range = llvm::iterator_range<updates_const_iterator>;
4612
4614 return updates_range(getUpdates().begin(), getUpdates().end());
4615 }
4616
4618 return updates_const_range(getUpdates().begin(), getUpdates().end());
4619 }
4620
4623 using finals_range = llvm::iterator_range<finals_iterator>;
4624 using finals_const_range = llvm::iterator_range<finals_const_iterator>;
4625
4627 return finals_range(getFinals().begin(), getFinals().end());
4628 }
4629
4631 return finals_const_range(getFinals().begin(), getFinals().end());
4632 }
4633
4637 llvm::iterator_range<used_expressions_iterator>;
4639 llvm::iterator_range<used_expressions_const_iterator>;
4640
4642 return finals_range(getUsedExprs().begin(), getUsedExprs().end());
4643 }
4644
4646 return finals_const_range(getUsedExprs().begin(), getUsedExprs().end());
4647 }
4648
4650 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4651 reinterpret_cast<Stmt **>(varlist_end()));
4652 }
4653
4655 auto Children = const_cast<OMPLinearClause *>(this)->children();
4656 return const_child_range(Children.begin(), Children.end());
4657 }
4658
4660
4662 auto Children = const_cast<OMPLinearClause *>(this)->used_children();
4663 return const_child_range(Children.begin(), Children.end());
4664 }
4665
4666 static bool classof(const OMPClause *T) {
4667 return T->getClauseKind() == llvm::omp::OMPC_linear;
4668 }
4669};
4670
4671/// This represents clause 'aligned' in the '#pragma omp ...'
4672/// directives.
4673///
4674/// \code
4675/// #pragma omp simd aligned(a,b : 8)
4676/// \endcode
4677/// In this example directive '#pragma omp simd' has clause 'aligned'
4678/// with variables 'a', 'b' and alignment '8'.
4680 : public OMPVarListClause<OMPAlignedClause>,
4681 private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
4682 friend class OMPClauseReader;
4683 friend OMPVarListClause;
4684 friend TrailingObjects;
4685
4686 /// Location of ':'.
4687 SourceLocation ColonLoc;
4688
4689 /// Sets the alignment for clause.
4690 void setAlignment(Expr *A) { *varlist_end() = A; }
4691
4692 /// Build 'aligned' clause with given number of variables \a NumVars.
4693 ///
4694 /// \param StartLoc Starting location of the clause.
4695 /// \param LParenLoc Location of '('.
4696 /// \param ColonLoc Location of ':'.
4697 /// \param EndLoc Ending location of the clause.
4698 /// \param NumVars Number of variables.
4700 SourceLocation ColonLoc, SourceLocation EndLoc,
4701 unsigned NumVars)
4702 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned, StartLoc,
4703 LParenLoc, EndLoc, NumVars),
4704 ColonLoc(ColonLoc) {}
4705
4706 /// Build an empty clause.
4707 ///
4708 /// \param NumVars Number of variables.
4709 explicit OMPAlignedClause(unsigned NumVars)
4710 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned,
4711 SourceLocation(), SourceLocation(),
4712 SourceLocation(), NumVars) {}
4713
4714public:
4715 /// Creates clause with a list of variables \a VL and alignment \a A.
4716 ///
4717 /// \param C AST Context.
4718 /// \param StartLoc Starting location of the clause.
4719 /// \param LParenLoc Location of '('.
4720 /// \param ColonLoc Location of ':'.
4721 /// \param EndLoc Ending location of the clause.
4722 /// \param VL List of references to the variables.
4723 /// \param A Alignment.
4724 static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
4725 SourceLocation LParenLoc,
4726 SourceLocation ColonLoc,
4727 SourceLocation EndLoc, ArrayRef<Expr *> VL,
4728 Expr *A);
4729
4730 /// Creates an empty clause with the place for \a NumVars variables.
4731 ///
4732 /// \param C AST context.
4733 /// \param NumVars Number of variables.
4734 static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4735
4736 /// Sets the location of ':'.
4737 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4738
4739 /// Returns the location of ':'.
4740 SourceLocation getColonLoc() const { return ColonLoc; }
4741
4742 /// Returns alignment.
4744
4745 /// Returns alignment.
4746 const Expr *getAlignment() const { return *varlist_end(); }
4747
4749 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4750 reinterpret_cast<Stmt **>(varlist_end()));
4751 }
4752
4754 auto Children = const_cast<OMPAlignedClause *>(this)->children();
4755 return const_child_range(Children.begin(), Children.end());
4756 }
4757
4760 }
4763 }
4764
4765 static bool classof(const OMPClause *T) {
4766 return T->getClauseKind() == llvm::omp::OMPC_aligned;
4767 }
4768};
4769
4770/// This represents clause 'copyin' in the '#pragma omp ...' directives.
4771///
4772/// \code
4773/// #pragma omp parallel copyin(a,b)
4774/// \endcode
4775/// In this example directive '#pragma omp parallel' has clause 'copyin'
4776/// with the variables 'a' and 'b'.
4778 : public OMPVarListClause<OMPCopyinClause>,
4779 private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
4780 // Class has 3 additional tail allocated arrays:
4781 // 1. List of helper expressions for proper generation of assignment operation
4782 // required for copyin clause. This list represents sources.
4783 // 2. List of helper expressions for proper generation of assignment operation
4784 // required for copyin clause. This list represents destinations.
4785 // 3. List of helper expressions that represents assignment operation:
4786 // \code
4787 // DstExprs = SrcExprs;
4788 // \endcode
4789 // Required for proper codegen of propagation of master's thread values of
4790 // threadprivate variables to local instances of that variables in other
4791 // implicit threads.
4792
4793 friend class OMPClauseReader;
4794 friend OMPVarListClause;
4795 friend TrailingObjects;
4796
4797 /// Build clause with number of variables \a N.
4798 ///
4799 /// \param StartLoc Starting location of the clause.
4800 /// \param LParenLoc Location of '('.
4801 /// \param EndLoc Ending location of the clause.
4802 /// \param N Number of the variables in the clause.
4803 OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4804 SourceLocation EndLoc, unsigned N)
4805 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin, StartLoc,
4806 LParenLoc, EndLoc, N) {}
4807
4808 /// Build an empty clause.
4809 ///
4810 /// \param N Number of variables.
4811 explicit OMPCopyinClause(unsigned N)
4812 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin,
4814 SourceLocation(), N) {}
4815
4816 /// Set list of helper expressions, required for proper codegen of the
4817 /// clause. These expressions represent source expression in the final
4818 /// assignment statement performed by the copyin clause.
4819 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
4820
4821 /// Get the list of helper source expressions.
4822 MutableArrayRef<Expr *> getSourceExprs() {
4823 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4824 }
4825 ArrayRef<const Expr *> getSourceExprs() const {
4827 }
4828
4829 /// Set list of helper expressions, required for proper codegen of the
4830 /// clause. These expressions represent destination expression in the final
4831 /// assignment statement performed by the copyin clause.
4832 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
4833
4834 /// Get the list of helper destination expressions.
4835 MutableArrayRef<Expr *> getDestinationExprs() {
4836 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
4837 }
4838 ArrayRef<const Expr *> getDestinationExprs() const {
4839 return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
4840 }
4841
4842 /// Set list of helper assignment expressions, required for proper
4843 /// codegen of the clause. These expressions are assignment expressions that
4844 /// assign source helper expressions to destination helper expressions
4845 /// correspondingly.
4846 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
4847
4848 /// Get the list of helper assignment expressions.
4849 MutableArrayRef<Expr *> getAssignmentOps() {
4850 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
4851 }
4852 ArrayRef<const Expr *> getAssignmentOps() const {
4853 return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
4854 }
4855
4856public:
4857 /// Creates clause with a list of variables \a VL.
4858 ///
4859 /// \param C AST context.
4860 /// \param StartLoc Starting location of the clause.
4861 /// \param LParenLoc Location of '('.
4862 /// \param EndLoc Ending location of the clause.
4863 /// \param VL List of references to the variables.
4864 /// \param SrcExprs List of helper expressions for proper generation of
4865 /// assignment operation required for copyin clause. This list represents
4866 /// sources.
4867 /// \param DstExprs List of helper expressions for proper generation of
4868 /// assignment operation required for copyin clause. This list represents
4869 /// destinations.
4870 /// \param AssignmentOps List of helper expressions that represents assignment
4871 /// operation:
4872 /// \code
4873 /// DstExprs = SrcExprs;
4874 /// \endcode
4875 /// Required for proper codegen of propagation of master's thread values of
4876 /// threadprivate variables to local instances of that variables in other
4877 /// implicit threads.
4878 static OMPCopyinClause *
4879 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4880 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
4881 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
4882
4883 /// Creates an empty clause with \a N variables.
4884 ///
4885 /// \param C AST context.
4886 /// \param N The number of variables.
4887 static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
4888
4891 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4893 llvm::iterator_range<helper_expr_const_iterator>;
4894
4896 return helper_expr_const_range(getSourceExprs().begin(),
4897 getSourceExprs().end());
4898 }
4899
4901 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
4902 }
4903
4905 return helper_expr_const_range(getDestinationExprs().begin(),
4906 getDestinationExprs().end());
4907 }
4908
4910 return helper_expr_range(getDestinationExprs().begin(),
4911 getDestinationExprs().end());
4912 }
4913
4915 return helper_expr_const_range(getAssignmentOps().begin(),
4916 getAssignmentOps().end());
4917 }
4918
4920 return helper_expr_range(getAssignmentOps().begin(),
4921 getAssignmentOps().end());
4922 }
4923
4925 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4926 reinterpret_cast<Stmt **>(varlist_end()));
4927 }
4928
4930 auto Children = const_cast<OMPCopyinClause *>(this)->children();
4931 return const_child_range(Children.begin(), Children.end());
4932 }
4933
4936 }
4939 }
4940
4941 static bool classof(const OMPClause *T) {
4942 return T->getClauseKind() == llvm::omp::OMPC_copyin;
4943 }
4944};
4945
4946/// This represents clause 'copyprivate' in the '#pragma omp ...'
4947/// directives.
4948///
4949/// \code
4950/// #pragma omp single copyprivate(a,b)
4951/// \endcode
4952/// In this example directive '#pragma omp single' has clause 'copyprivate'
4953/// with the variables 'a' and 'b'.
4955 : public OMPVarListClause<OMPCopyprivateClause>,
4956 private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
4957 friend class OMPClauseReader;
4958 friend OMPVarListClause;
4959 friend TrailingObjects;
4960
4961 /// Build clause with number of variables \a N.
4962 ///
4963 /// \param StartLoc Starting location of the clause.
4964 /// \param LParenLoc Location of '('.
4965 /// \param EndLoc Ending location of the clause.
4966 /// \param N Number of the variables in the clause.
4968 SourceLocation EndLoc, unsigned N)
4969 : OMPVarListClause<OMPCopyprivateClause>(llvm::omp::OMPC_copyprivate,
4970 StartLoc, LParenLoc, EndLoc, N) {
4971 }
4972
4973 /// Build an empty clause.
4974 ///
4975 /// \param N Number of variables.
4976 explicit OMPCopyprivateClause(unsigned N)
4978 llvm::omp::OMPC_copyprivate, SourceLocation(), SourceLocation(),
4979 SourceLocation(), N) {}
4980
4981 /// Set list of helper expressions, required for proper codegen of the
4982 /// clause. These expressions represent source expression in the final
4983 /// assignment statement performed by the copyprivate clause.
4984 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
4985
4986 /// Get the list of helper source expressions.
4987 MutableArrayRef<Expr *> getSourceExprs() {
4988 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4989 }
4990 ArrayRef<const Expr *> getSourceExprs() const {
4992 }
4993
4994 /// Set list of helper expressions, required for proper codegen of the
4995 /// clause. These expressions represent destination expression in the final
4996 /// assignment statement performed by the copyprivate clause.
4997 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
4998
4999 /// Get the list of helper destination expressions.
5000 MutableArrayRef<Expr *> getDestinationExprs() {
5001 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
5002 }
5003 ArrayRef<const Expr *> getDestinationExprs() const {
5004 return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
5005 }
5006
5007 /// Set list of helper assignment expressions, required for proper
5008 /// codegen of the clause. These expressions are assignment expressions that
5009 /// assign source helper expressions to destination helper expressions
5010 /// correspondingly.
5011 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
5012
5013 /// Get the list of helper assignment expressions.
5014 MutableArrayRef<Expr *> getAssignmentOps() {
5015 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
5016 }
5017 ArrayRef<const Expr *> getAssignmentOps() const {
5018 return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
5019 }
5020
5021public:
5022 /// Creates clause with a list of variables \a VL.
5023 ///
5024 /// \param C AST context.
5025 /// \param StartLoc Starting location of the clause.
5026 /// \param LParenLoc Location of '('.
5027 /// \param EndLoc Ending location of the clause.
5028 /// \param VL List of references to the variables.
5029 /// \param SrcExprs List of helper expressions for proper generation of
5030 /// assignment operation required for copyprivate clause. This list represents
5031 /// sources.
5032 /// \param DstExprs List of helper expressions for proper generation of
5033 /// assignment operation required for copyprivate clause. This list represents
5034 /// destinations.
5035 /// \param AssignmentOps List of helper expressions that represents assignment
5036 /// operation:
5037 /// \code
5038 /// DstExprs = SrcExprs;
5039 /// \endcode
5040 /// Required for proper codegen of final assignment performed by the
5041 /// copyprivate clause.
5042 static OMPCopyprivateClause *
5043 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
5044 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
5045 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
5046
5047 /// Creates an empty clause with \a N variables.
5048 ///
5049 /// \param C AST context.
5050 /// \param N The number of variables.
5051 static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
5052
5055 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
5057 llvm::iterator_range<helper_expr_const_iterator>;
5058
5060 return helper_expr_const_range(getSourceExprs().begin(),
5061 getSourceExprs().end());
5062 }
5063
5065 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
5066 }
5067
5069 return helper_expr_const_range(getDestinationExprs().begin(),
5070 getDestinationExprs().end());
5071 }
5072
5074 return helper_expr_range(getDestinationExprs().begin(),
5075 getDestinationExprs().end());
5076 }
5077
5079 return helper_expr_const_range(getAssignmentOps().begin(),
5080 getAssignmentOps().end());
5081 }
5082
5084 return helper_expr_range(getAssignmentOps().begin(),
5085 getAssignmentOps().end());
5086 }
5087
5089 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5090 reinterpret_cast<Stmt **>(varlist_end()));
5091 }
5092
5094 auto Children = const_cast<OMPCopyprivateClause *>(this)->children();
5095 return const_child_range(Children.begin(), Children.end());
5096 }
5097
5100 }
5103 }
5104
5105 static bool classof(const OMPClause *T) {
5106 return T->getClauseKind() == llvm::omp::OMPC_copyprivate;
5107 }
5108};
5109
5110/// This represents implicit clause 'flush' for the '#pragma omp flush'
5111/// directive.
5112/// This clause does not exist by itself, it can be only as a part of 'omp
5113/// flush' directive. This clause is introduced to keep the original structure
5114/// of \a OMPExecutableDirective class and its derivatives and to use the
5115/// existing infrastructure of clauses with the list of variables.
5116///
5117/// \code
5118/// #pragma omp flush(a,b)
5119/// \endcode
5120/// In this example directive '#pragma omp flush' has implicit clause 'flush'
5121/// with the variables 'a' and 'b'.
5123 : public OMPVarListClause<OMPFlushClause>,
5124 private llvm::TrailingObjects<OMPFlushClause, Expr *> {
5125 friend OMPVarListClause;
5126 friend TrailingObjects;
5127
5128 /// Build clause with number of variables \a N.
5129 ///
5130 /// \param StartLoc Starting location of the clause.
5131 /// \param LParenLoc Location of '('.
5132 /// \param EndLoc Ending location of the clause.
5133 /// \param N Number of the variables in the clause.
5134 OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5135 SourceLocation EndLoc, unsigned N)
5136 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush, StartLoc,
5137 LParenLoc, EndLoc, N) {}
5138
5139 /// Build an empty clause.
5140 ///
5141 /// \param N Number of variables.
5142 explicit OMPFlushClause(unsigned N)
5143 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush,
5145 SourceLocation(), N) {}
5146
5147public:
5148 /// Creates clause with a list of variables \a VL.
5149 ///
5150 /// \param C AST context.
5151 /// \param StartLoc Starting location of the clause.
5152 /// \param LParenLoc Location of '('.
5153 /// \param EndLoc Ending location of the clause.
5154 /// \param VL List of references to the variables.
5155 static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
5156 SourceLocation LParenLoc, SourceLocation EndLoc,
5157 ArrayRef<Expr *> VL);
5158
5159 /// Creates an empty clause with \a N variables.
5160 ///
5161 /// \param C AST context.
5162 /// \param N The number of variables.
5163 static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
5164
5166 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5167 reinterpret_cast<Stmt **>(varlist_end()));
5168 }
5169
5171 auto Children = const_cast<OMPFlushClause *>(this)->children();
5172 return const_child_range(Children.begin(), Children.end());
5173 }
5174
5177 }
5180 }
5181
5182 static bool classof(const OMPClause *T) {
5183 return T->getClauseKind() == llvm::omp::OMPC_flush;
5184 }
5185};
5186
5187/// This represents implicit clause 'depobj' for the '#pragma omp depobj'
5188/// directive.
5189/// This clause does not exist by itself, it can be only as a part of 'omp
5190/// depobj' directive. This clause is introduced to keep the original structure
5191/// of \a OMPExecutableDirective class and its derivatives and to use the
5192/// existing infrastructure of clauses with the list of variables.
5193///
5194/// \code
5195/// #pragma omp depobj(a) destroy
5196/// \endcode
5197/// In this example directive '#pragma omp depobj' has implicit clause 'depobj'
5198/// with the depobj 'a'.
5199class OMPDepobjClause final : public OMPClause {
5200 friend class OMPClauseReader;
5201
5202 /// Location of '('.
5203 SourceLocation LParenLoc;
5204
5205 /// Chunk size.
5206 Expr *Depobj = nullptr;
5207
5208 /// Build clause with number of variables \a N.
5209 ///
5210 /// \param StartLoc Starting location of the clause.
5211 /// \param LParenLoc Location of '('.
5212 /// \param EndLoc Ending location of the clause.
5213 OMPDepobjClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5214 SourceLocation EndLoc)
5215 : OMPClause(llvm::omp::OMPC_depobj, StartLoc, EndLoc),
5216 LParenLoc(LParenLoc) {}
5217
5218 /// Build an empty clause.
5219 ///
5220 explicit OMPDepobjClause()
5221 : OMPClause(llvm::omp::OMPC_depobj, SourceLocation(), SourceLocation()) {}
5222
5223 void setDepobj(Expr *E) { Depobj = E; }
5224
5225 /// Sets the location of '('.
5226 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5227
5228public:
5229 /// Creates clause.
5230 ///
5231 /// \param C AST context.
5232 /// \param StartLoc Starting location of the clause.
5233 /// \param LParenLoc Location of '('.
5234 /// \param EndLoc Ending location of the clause.
5235 /// \param Depobj depobj expression associated with the 'depobj' directive.
5236 static OMPDepobjClause *Create(const ASTContext &C, SourceLocation StartLoc,
5237 SourceLocation LParenLoc,
5238 SourceLocation EndLoc, Expr *Depobj);
5239
5240 /// Creates an empty clause.
5241 ///
5242 /// \param C AST context.
5243 static OMPDepobjClause *CreateEmpty(const ASTContext &C);
5244
5245 /// Returns depobj expression associated with the clause.
5246 Expr *getDepobj() { return Depobj; }
5247 const Expr *getDepobj() const { return Depobj; }
5248
5249 /// Returns the location of '('.
5250 SourceLocation getLParenLoc() const { return LParenLoc; }
5251
5253 return child_range(reinterpret_cast<Stmt **>(&Depobj),
5254 reinterpret_cast<Stmt **>(&Depobj) + 1);
5255 }
5256
5258 auto Children = const_cast<OMPDepobjClause *>(this)->children();
5259 return const_child_range(Children.begin(), Children.end());
5260 }
5261
5264 }
5267 }
5268
5269 static bool classof(const OMPClause *T) {
5270 return T->getClauseKind() == llvm::omp::OMPC_depobj;
5271 }
5272};
5273
5274/// This represents implicit clause 'depend' for the '#pragma omp task'
5275/// directive.
5276///
5277/// \code
5278/// #pragma omp task depend(in:a,b)
5279/// \endcode
5280/// In this example directive '#pragma omp task' with clause 'depend' with the
5281/// variables 'a' and 'b' with dependency 'in'.
5283 : public OMPVarListClause<OMPDependClause>,
5284 private llvm::TrailingObjects<OMPDependClause, Expr *> {
5285 friend class OMPClauseReader;
5286 friend OMPVarListClause;
5287 friend TrailingObjects;
5288
5289public:
5290 struct DependDataTy final {
5291 /// Dependency type (one of in, out, inout).
5293
5294 /// Dependency type location.
5296
5297 /// Colon location.
5299
5300 /// Location of 'omp_all_memory'.
5302 };
5303
5304private:
5305 /// Dependency type and source locations.
5306 DependDataTy Data;
5307
5308 /// Number of loops, associated with the depend clause.
5309 unsigned NumLoops = 0;
5310
5311 /// Build clause with number of variables \a N.
5312 ///
5313 /// \param StartLoc Starting location of the clause.
5314 /// \param LParenLoc Location of '('.
5315 /// \param EndLoc Ending location of the clause.
5316 /// \param N Number of the variables in the clause.
5317 /// \param NumLoops Number of loops that is associated with this depend
5318 /// clause.
5319 OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5320 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
5321 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend, StartLoc,
5322 LParenLoc, EndLoc, N),
5323 NumLoops(NumLoops) {}
5324
5325 /// Build an empty clause.
5326 ///
5327 /// \param N Number of variables.
5328 /// \param NumLoops Number of loops that is associated with this depend
5329 /// clause.
5330 explicit OMPDependClause(unsigned N, unsigned NumLoops)
5331 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend,
5333 SourceLocation(), N),
5334 NumLoops(NumLoops) {}
5335
5336 /// Set dependency kind.
5337 void setDependencyKind(OpenMPDependClauseKind K) { Data.DepKind = K; }
5338
5339 /// Set dependency kind and its location.
5340 void setDependencyLoc(SourceLocation Loc) { Data.DepLoc = Loc; }
5341
5342 /// Set colon location.
5343 void setColonLoc(SourceLocation Loc) { Data.ColonLoc = Loc; }
5344
5345 /// Set the 'omp_all_memory' location.
5346 void setOmpAllMemoryLoc(SourceLocation Loc) { Data.OmpAllMemoryLoc = Loc; }
5347
5348 /// Sets optional dependency modifier.
5349 void setModifier(Expr *DepModifier);
5350
5351public:
5352 /// Creates clause with a list of variables \a VL.
5353 ///
5354 /// \param C AST context.
5355 /// \param StartLoc Starting location of the clause.
5356 /// \param LParenLoc Location of '('.
5357 /// \param EndLoc Ending location of the clause.
5358 /// \param Data Dependency type and source locations.
5359 /// \param VL List of references to the variables.
5360 /// \param NumLoops Number of loops that is associated with this depend
5361 /// clause.
5362 static OMPDependClause *Create(const ASTContext &C, SourceLocation StartLoc,
5363 SourceLocation LParenLoc,
5364 SourceLocation EndLoc, DependDataTy Data,
5365 Expr *DepModifier, ArrayRef<Expr *> VL,
5366 unsigned NumLoops);
5367
5368 /// Creates an empty clause with \a N variables.
5369 ///
5370 /// \param C AST context.
5371 /// \param N The number of variables.
5372 /// \param NumLoops Number of loops that is associated with this depend
5373 /// clause.
5374 static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N,
5375 unsigned NumLoops);
5376
5377 /// Get dependency type.
5379
5380 /// Get dependency type location.
5381 SourceLocation getDependencyLoc() const { return Data.DepLoc; }
5382
5383 /// Get colon location.
5384 SourceLocation getColonLoc() const { return Data.ColonLoc; }
5385
5386 /// Get 'omp_all_memory' location.
5387 SourceLocation getOmpAllMemoryLoc() const { return Data.OmpAllMemoryLoc; }
5388
5389 /// Return optional depend modifier.
5390 Expr *getModifier();
5391 const Expr *getModifier() const {
5392 return const_cast<OMPDependClause *>(this)->getModifier();
5393 }
5394
5395 /// Get number of loops associated with the clause.
5396 unsigned getNumLoops() const { return NumLoops; }
5397
5398 /// Set the loop data for the depend clauses with 'sink|source' kind of
5399 /// dependency.
5400 void setLoopData(unsigned NumLoop, Expr *Cnt);
5401
5402 /// Get the loop data.
5403 Expr *getLoopData(unsigned NumLoop);
5404 const Expr *getLoopData(unsigned NumLoop) const;
5405
5407 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5408 reinterpret_cast<Stmt **>(varlist_end()));
5409 }
5410
5412 auto Children = const_cast<OMPDependClause *>(this)->children();
5413 return const_child_range(Children.begin(), Children.end());
5414 }
5415
5418 }
5421 }
5422
5423 static bool classof(const OMPClause *T) {
5424 return T->getClauseKind() == llvm::omp::OMPC_depend;
5425 }
5426};
5427
5428/// This represents 'device' clause in the '#pragma omp ...'
5429/// directive.
5430///
5431/// \code
5432/// #pragma omp target device(a)
5433/// \endcode
5434/// In this example directive '#pragma omp target' has clause 'device'
5435/// with single expression 'a'.
5437 friend class OMPClauseReader;
5438
5439 /// Location of '('.
5440 SourceLocation LParenLoc;
5441
5442 /// Device clause modifier.
5444
5445 /// Location of the modifier.
5446 SourceLocation ModifierLoc;
5447
5448 /// Device number.
5449 Stmt *Device = nullptr;
5450
5451 /// Set the device number.
5452 ///
5453 /// \param E Device number.
5454 void setDevice(Expr *E) { Device = E; }
5455
5456 /// Sets modifier.
5457 void setModifier(OpenMPDeviceClauseModifier M) { Modifier = M; }
5458
5459 /// Setst modifier location.
5460 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
5461
5462public:
5463 /// Build 'device' clause.
5464 ///
5465 /// \param Modifier Clause modifier.
5466 /// \param E Expression associated with this clause.
5467 /// \param CaptureRegion Innermost OpenMP region where expressions in this
5468 /// clause must be captured.
5469 /// \param StartLoc Starting location of the clause.
5470 /// \param ModifierLoc Modifier location.
5471 /// \param LParenLoc Location of '('.
5472 /// \param EndLoc Ending location of the clause.
5474 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
5475 SourceLocation LParenLoc, SourceLocation ModifierLoc,
5476 SourceLocation EndLoc)
5477 : OMPClause(llvm::omp::OMPC_device, StartLoc, EndLoc),
5478 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
5479 ModifierLoc(ModifierLoc), Device(E) {
5480 setPreInitStmt(HelperE, CaptureRegion);
5481 }
5482
5483 /// Build an empty clause.
5485 : OMPClause(llvm::omp::OMPC_device, SourceLocation(), SourceLocation()),
5486 OMPClauseWithPreInit(this) {}
5487
5488 /// Sets the location of '('.
5489 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5490
5491 /// Returns the location of '('.
5492 SourceLocation getLParenLoc() const { return LParenLoc; }
5493
5494 /// Return device number.
5495 Expr *getDevice() { return cast<Expr>(Device); }
5496
5497 /// Return device number.
5498 Expr *getDevice() const { return cast<Expr>(Device); }
5499
5500 /// Gets modifier.
5501 OpenMPDeviceClauseModifier getModifier() const { return Modifier; }
5502
5503 /// Gets modifier location.
5504 SourceLocation getModifierLoc() const { return ModifierLoc; }
5505
5507
5509 return const_child_range(&Device, &Device + 1);
5510 }
5511
5514 }
5517 }
5518
5519 static bool classof(const OMPClause *T) {
5520 return T->getClauseKind() == llvm::omp::OMPC_device;
5521 }
5522};
5523
5524/// This represents 'threads' clause in the '#pragma omp ...' directive.
5525///
5526/// \code
5527/// #pragma omp ordered threads
5528/// \endcode
5529/// In this example directive '#pragma omp ordered' has simple 'threads' clause.
5531 : public OMPNoChildClause<llvm::omp::OMPC_threads> {
5532public:
5533 /// Build 'threads' clause.
5534 ///
5535 /// \param StartLoc Starting location of the clause.
5536 /// \param EndLoc Ending location of the clause.
5538 : OMPNoChildClause(StartLoc, EndLoc) {}
5539
5540 /// Build an empty clause.
5542};
5543
5544/// This represents 'simd' clause in the '#pragma omp ...' directive.
5545///
5546/// \code
5547/// #pragma omp ordered simd
5548/// \endcode
5549/// In this example directive '#pragma omp ordered' has simple 'simd' clause.
5550class OMPSIMDClause : public OMPClause {
5551public:
5552 /// Build 'simd' clause.
5553 ///
5554 /// \param StartLoc Starting location of the clause.
5555 /// \param EndLoc Ending location of the clause.
5557 : OMPClause(llvm::omp::OMPC_simd, StartLoc, EndLoc) {}
5558
5559 /// Build an empty clause.
5561 : OMPClause(llvm::omp::OMPC_simd, SourceLocation(), SourceLocation()) {}
5562
5565 }
5566
5569 }
5570
5573 }
5576 }
5577
5578 static bool classof(const OMPClause *T) {
5579 return T->getClauseKind() == llvm::omp::OMPC_simd;
5580 }
5581};
5582
5583/// Struct that defines common infrastructure to handle mappable
5584/// expressions used in OpenMP clauses.
5586public:
5587 /// Class that represents a component of a mappable expression. E.g.
5588 /// for an expression S.a, the first component is a declaration reference
5589 /// expression associated with 'S' and the second is a member expression
5590 /// associated with the field declaration 'a'. If the expression is an array
5591 /// subscript it may not have any associated declaration. In that case the
5592 /// associated declaration is set to nullptr.
5594 /// Pair of Expression and Non-contiguous pair associated with the
5595 /// component.
5596 llvm::PointerIntPair<Expr *, 1, bool> AssociatedExpressionNonContiguousPr;
5597
5598 /// Declaration associated with the declaration. If the component does
5599 /// not have a declaration (e.g. array subscripts or section), this is set
5600 /// to nullptr.
5601 ValueDecl *AssociatedDeclaration = nullptr;
5602
5603 public:
5604 explicit MappableComponent() = default;
5605 explicit MappableComponent(Expr *AssociatedExpression,
5606 ValueDecl *AssociatedDeclaration,
5607 bool IsNonContiguous)
5608 : AssociatedExpressionNonContiguousPr(AssociatedExpression,
5609 IsNonContiguous),
5610 AssociatedDeclaration(
5611 AssociatedDeclaration
5612 ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
5613 : nullptr) {}
5614
5616 return AssociatedExpressionNonContiguousPr.getPointer();
5617 }
5618
5619 bool isNonContiguous() const {
5620 return AssociatedExpressionNonContiguousPr.getInt();
5621 }
5622
5624 return AssociatedDeclaration;
5625 }
5626 };
5627
5628 // List of components of an expression. This first one is the whole
5629 // expression and the last one is the base expression.
5632
5633 // List of all component lists associated to the same base declaration.
5634 // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
5635 // their component list but the same base declaration 'S'.
5638
5639protected:
5640 // Return the total number of elements in a list of component lists.
5641 static unsigned
5643
5644 // Return the total number of elements in a list of declarations. All
5645 // declarations are expected to be canonical.
5646 static unsigned
5648};
5649
5650/// This structure contains all sizes needed for by an
5651/// OMPMappableExprListClause.
5653 /// Number of expressions listed.
5654 unsigned NumVars;
5655 /// Number of unique base declarations.
5657 /// Number of component lists.
5659 /// Total number of expression components.
5663 unsigned NumComponentLists, unsigned NumComponents)
5666};
5667
5668/// This represents clauses with a list of expressions that are mappable.
5669/// Examples of these clauses are 'map' in
5670/// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
5671/// in '#pragma omp target update...' directives.
5672template <class T>
5675 friend class OMPClauseReader;
5676
5677 /// Number of unique declarations in this clause.
5678 unsigned NumUniqueDeclarations;
5679
5680 /// Number of component lists in this clause.
5681 unsigned NumComponentLists;
5682
5683 /// Total number of components in this clause.
5684 unsigned NumComponents;
5685
5686 /// Whether this clause is possible to have user-defined mappers associated.
5687 /// It should be true for map, to, and from clauses, and false for
5688 /// use_device_ptr and is_device_ptr.
5689 const bool SupportsMapper;
5690
5691 /// C++ nested name specifier for the associated user-defined mapper.
5692 NestedNameSpecifierLoc MapperQualifierLoc;
5693
5694 /// The associated user-defined mapper identifier information.
5695 DeclarationNameInfo MapperIdInfo;
5696
5697protected:
5698 /// Build a clause for \a NumUniqueDeclarations declarations, \a
5699 /// NumComponentLists total component lists, and \a NumComponents total
5700 /// components.
5701 ///
5702 /// \param K Kind of the clause.
5703 /// \param Locs Locations needed to build a mappable clause. It includes 1)
5704 /// StartLoc: starting location of the clause (the clause keyword); 2)
5705 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5706 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5707 /// NumVars: number of expressions listed in this clause; 2)
5708 /// NumUniqueDeclarations: number of unique base declarations in this clause;
5709 /// 3) NumComponentLists: number of component lists in this clause; and 4)
5710 /// NumComponents: total number of expression components in the clause.
5711 /// \param SupportsMapper Indicates whether this clause is possible to have
5712 /// user-defined mappers associated.
5713 /// \param MapperQualifierLocPtr C++ nested name specifier for the associated
5714 /// user-defined mapper.
5715 /// \param MapperIdInfoPtr The identifier of associated user-defined mapper.
5717 OpenMPClauseKind K, const OMPVarListLocTy &Locs,
5718 const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false,
5719 NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr,
5720 DeclarationNameInfo *MapperIdInfoPtr = nullptr)
5721 : OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc,
5722 Sizes.NumVars),
5723 NumUniqueDeclarations(Sizes.NumUniqueDeclarations),
5724 NumComponentLists(Sizes.NumComponentLists),
5725 NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) {
5726 if (MapperQualifierLocPtr)
5727 MapperQualifierLoc = *MapperQualifierLocPtr;
5728 if (MapperIdInfoPtr)
5729 MapperIdInfo = *MapperIdInfoPtr;
5730 }
5731
5732 /// Get the unique declarations that are in the trailing objects of the
5733 /// class.
5736 static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(),
5737 NumUniqueDeclarations);
5738 }
5739
5740 /// Get the unique declarations that are in the trailing objects of the
5741 /// class.
5743 return ArrayRef<ValueDecl *>(
5744 static_cast<const T *>(this)
5745 ->template getTrailingObjects<ValueDecl *>(),
5746 NumUniqueDeclarations);
5747 }
5748
5749 /// Set the unique declarations that are in the trailing objects of the
5750 /// class.
5752 assert(UDs.size() == NumUniqueDeclarations &&
5753 "Unexpected amount of unique declarations.");
5754 std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin());
5755 }
5756
5757 /// Get the number of lists per declaration that are in the trailing
5758 /// objects of the class.
5761 static_cast<T *>(this)->template getTrailingObjects<unsigned>(),
5762 NumUniqueDeclarations);
5763 }
5764
5765 /// Get the number of lists per declaration that are in the trailing
5766 /// objects of the class.
5768 return ArrayRef<unsigned>(
5769 static_cast<const T *>(this)->template getTrailingObjects<unsigned>(),
5770 NumUniqueDeclarations);
5771 }
5772
5773 /// Set the number of lists per declaration that are in the trailing
5774 /// objects of the class.
5776 assert(DNLs.size() == NumUniqueDeclarations &&
5777 "Unexpected amount of list numbers.");
5778 std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin());
5779 }
5780
5781 /// Get the cumulative component lists sizes that are in the trailing
5782 /// objects of the class. They are appended after the number of lists.
5785 static_cast<T *>(this)->template getTrailingObjects<unsigned>() +
5786 NumUniqueDeclarations,
5787 NumComponentLists);
5788 }
5789
5790 /// Get the cumulative component lists sizes that are in the trailing
5791 /// objects of the class. They are appended after the number of lists.
5793 return ArrayRef<unsigned>(
5794 static_cast<const T *>(this)->template getTrailingObjects<unsigned>() +
5795 NumUniqueDeclarations,
5796 NumComponentLists);
5797 }
5798
5799 /// Set the cumulative component lists sizes that are in the trailing
5800 /// objects of the class.
5802 assert(CLSs.size() == NumComponentLists &&
5803 "Unexpected amount of component lists.");
5804 std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin());
5805 }
5806
5807 /// Get the components that are in the trailing objects of the class.
5810 static_cast<T *>(this)
5811 ->template getTrailingObjects<MappableComponent>(),
5812 NumComponents);
5813 }
5814
5815 /// Get the components that are in the trailing objects of the class.
5818 static_cast<const T *>(this)
5819 ->template getTrailingObjects<MappableComponent>(),
5820 NumComponents);
5821 }
5822
5823 /// Set the components that are in the trailing objects of the class.
5824 /// This requires the list sizes so that it can also fill the original
5825 /// expressions, which are the first component of each list.
5827 ArrayRef<unsigned> CLSs) {
5828 assert(Components.size() == NumComponents &&
5829 "Unexpected amount of component lists.");
5830 assert(CLSs.size() == NumComponentLists &&
5831 "Unexpected amount of list sizes.");
5832 std::copy(Components.begin(), Components.end(), getComponentsRef().begin());
5833 }
5834
5835 /// Fill the clause information from the list of declarations and
5836 /// associated component lists.
5838 MappableExprComponentListsRef ComponentLists) {
5839 // Perform some checks to make sure the data sizes are consistent with the
5840 // information available when the clause was created.
5841 assert(getUniqueDeclarationsTotalNumber(Declarations) ==
5842 NumUniqueDeclarations &&
5843 "Unexpected number of mappable expression info entries!");
5844 assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
5845 "Unexpected total number of components!");
5846 assert(Declarations.size() == ComponentLists.size() &&
5847 "Declaration and component lists size is not consistent!");
5848 assert(Declarations.size() == NumComponentLists &&
5849 "Unexpected declaration and component lists size!");
5850
5851 // Organize the components by declaration and retrieve the original
5852 // expression. Original expressions are always the first component of the
5853 // mappable component list.
5854 llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
5855 ComponentListMap;
5856 {
5857 auto CI = ComponentLists.begin();
5858 for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
5859 ++DI, ++CI) {
5860 assert(!CI->empty() && "Invalid component list!");
5861 ComponentListMap[*DI].push_back(*CI);
5862 }
5863 }
5864
5865 // Iterators of the target storage.
5866 auto UniqueDeclarations = getUniqueDeclsRef();
5867 auto UDI = UniqueDeclarations.begin();
5868
5869 auto DeclNumLists = getDeclNumListsRef();
5870 auto DNLI = DeclNumLists.begin();
5871
5872 auto ComponentListSizes = getComponentListSizesRef();
5873 auto CLSI = ComponentListSizes.begin();
5874
5875 auto Components = getComponentsRef();
5876 auto CI = Components.begin();
5877
5878 // Variable to compute the accumulation of the number of components.
5879 unsigned PrevSize = 0u;
5880
5881 // Scan all the declarations and associated component lists.
5882 for (auto &M : ComponentListMap) {
5883 // The declaration.
5884 auto *D = M.first;
5885 // The component lists.
5886 auto CL = M.second;
5887
5888 // Initialize the entry.
5889 *UDI = D;
5890 ++UDI;
5891
5892 *DNLI = CL.size();
5893 ++DNLI;
5894
5895 // Obtain the cumulative sizes and concatenate all the components in the
5896 // reserved storage.
5897 for (auto C : CL) {
5898 // Accumulate with the previous size.
5899 PrevSize += C.size();
5900
5901 // Save the size.
5902 *CLSI = PrevSize;
5903 ++CLSI;
5904
5905 // Append components after the current components iterator.
5906 CI = std::copy(C.begin(), C.end(), CI);
5907 }
5908 }
5909 }
5910
5911 /// Set the nested name specifier of associated user-defined mapper.
5913 MapperQualifierLoc = NNSL;
5914 }
5915
5916 /// Set the name of associated user-defined mapper.
5918 MapperIdInfo = MapperId;
5919 }
5920
5921 /// Get the user-defined mapper references that are in the trailing objects of
5922 /// the class.
5924 assert(SupportsMapper &&
5925 "Must be a clause that is possible to have user-defined mappers");
5927 static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
5930 }
5931
5932 /// Get the user-defined mappers references that are in the trailing objects
5933 /// of the class.
5935 assert(SupportsMapper &&
5936 "Must be a clause that is possible to have user-defined mappers");
5938 static_cast<const T *>(this)->template getTrailingObjects<Expr *>() +
5941 }
5942
5943 /// Set the user-defined mappers that are in the trailing objects of the
5944 /// class.
5946 assert(DMDs.size() == OMPVarListClause<T>::varlist_size() &&
5947 "Unexpected number of user-defined mappers.");
5948 assert(SupportsMapper &&
5949 "Must be a clause that is possible to have user-defined mappers");
5950 std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin());
5951 }
5952
5953public:
5954 /// Return the number of unique base declarations in this clause.
5955 unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
5956
5957 /// Return the number of lists derived from the clause expressions.
5958 unsigned getTotalComponentListNum() const { return NumComponentLists; }
5959
5960 /// Return the total number of components in all lists derived from the
5961 /// clause.
5962 unsigned getTotalComponentsNum() const { return NumComponents; }
5963
5964 /// Gets the nested name specifier for associated user-defined mapper.
5966 return MapperQualifierLoc;
5967 }
5968
5969 /// Gets the name info for associated user-defined mapper.
5970 const DeclarationNameInfo &getMapperIdInfo() const { return MapperIdInfo; }
5971
5972 /// Iterator that browse the components by lists. It also allows
5973 /// browsing components of a single declaration.
5975 : public llvm::iterator_adaptor_base<
5976 const_component_lists_iterator,
5977 MappableExprComponentListRef::const_iterator,
5978 std::forward_iterator_tag, MappableComponent, ptrdiff_t,
5979 MappableComponent, MappableComponent> {
5980 // The declaration the iterator currently refers to.
5982
5983 // The list number associated with the current declaration.
5984 ArrayRef<unsigned>::iterator NumListsCur;
5985
5986 // Whether this clause is possible to have user-defined mappers associated.
5987 const bool SupportsMapper;
5988
5989 // The user-defined mapper associated with the current declaration.
5991
5992 // Remaining lists for the current declaration.
5993 unsigned RemainingLists = 0;
5994
5995 // The cumulative size of the previous list, or zero if there is no previous
5996 // list.
5997 unsigned PrevListSize = 0;
5998
5999 // The cumulative sizes of the current list - it will delimit the remaining
6000 // range of interest.
6003
6004 // Iterator to the end of the components storage.
6005 MappableExprComponentListRef::const_iterator End;
6006
6007 public:
6008 /// Construct an iterator that scans all lists.
6010 ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
6011 ArrayRef<unsigned> CumulativeListSizes,
6012 MappableExprComponentListRef Components, bool SupportsMapper,
6013 ArrayRef<Expr *> Mappers)
6014 : const_component_lists_iterator::iterator_adaptor_base(
6015 Components.begin()),
6016 DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
6017 SupportsMapper(SupportsMapper),
6018 ListSizeCur(CumulativeListSizes.begin()),
6019 ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
6020 assert(UniqueDecls.size() == DeclsListNum.size() &&
6021 "Inconsistent number of declarations and list sizes!");
6022 if (!DeclsListNum.empty())
6023 RemainingLists = *NumListsCur;
6024 if (SupportsMapper)
6025 MapperCur = Mappers.begin();
6026 }
6027
6028 /// Construct an iterator that scan lists for a given declaration \a
6029 /// Declaration.
6031 const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
6032 ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
6033 MappableExprComponentListRef Components, bool SupportsMapper,
6034 ArrayRef<Expr *> Mappers)
6035 : const_component_lists_iterator(UniqueDecls, DeclsListNum,
6036 CumulativeListSizes, Components,
6037 SupportsMapper, Mappers) {
6038 // Look for the desired declaration. While we are looking for it, we
6039 // update the state so that we know the component where a given list
6040 // starts.
6041 for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
6042 if (*DeclCur == Declaration)
6043 break;
6044
6045 assert(*NumListsCur > 0 && "No lists associated with declaration??");
6046
6047 // Skip the lists associated with the current declaration, but save the
6048 // last list size that was skipped.
6049 std::advance(ListSizeCur, *NumListsCur - 1);
6050 PrevListSize = *ListSizeCur;
6051 ++ListSizeCur;
6052
6053 if (SupportsMapper)
6054 ++MapperCur;
6055 }
6056
6057 // If we didn't find any declaration, advance the iterator to after the
6058 // last component and set remaining lists to zero.
6059 if (ListSizeCur == CumulativeListSizes.end()) {
6060 this->I = End;
6061 RemainingLists = 0u;
6062 return;
6063 }
6064
6065 // Set the remaining lists with the total number of lists of the current
6066 // declaration.
6067 RemainingLists = *NumListsCur;
6068
6069 // Adjust the list size end iterator to the end of the relevant range.
6070 ListSizeEnd = ListSizeCur;
6071 std::advance(ListSizeEnd, RemainingLists);
6072
6073 // Given that the list sizes are cumulative, the index of the component
6074 // that start the list is the size of the previous list.
6075 std::advance(this->I, PrevListSize);
6076 }
6077
6078 // Return the array with the current list. The sizes are cumulative, so the
6079 // array size is the difference between the current size and previous one.
6080 std::tuple<const ValueDecl *, MappableExprComponentListRef,
6081 const ValueDecl *>
6082 operator*() const {
6083 assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
6084 const ValueDecl *Mapper = nullptr;
6085 if (SupportsMapper && *MapperCur)
6086 Mapper = cast<ValueDecl>(cast<DeclRefExpr>(*MapperCur)->getDecl());
6087 return std::make_tuple(
6088 *DeclCur,
6089 MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize),
6090 Mapper);
6091 }
6092 std::tuple<const ValueDecl *, MappableExprComponentListRef,
6093 const ValueDecl *>
6094 operator->() const {
6095 return **this;
6096 }
6097
6098 // Skip the components of the current list.
6100 assert(ListSizeCur != ListSizeEnd && RemainingLists &&
6101 "Invalid iterator!");
6102
6103 // If we don't have more lists just skip all the components. Otherwise,
6104 // advance the iterator by the number of components in the current list.
6105 if (std::next(ListSizeCur) == ListSizeEnd) {
6106 this->I = End;
6107 RemainingLists = 0;
6108 } else {
6109 std::advance(this->I, *ListSizeCur - PrevListSize);
6110 PrevListSize = *ListSizeCur;
6111
6112 // We are done with a declaration, move to the next one.
6113 if (!(--RemainingLists)) {
6114 ++DeclCur;
6115 ++NumListsCur;
6116 RemainingLists = *NumListsCur;
6117 assert(RemainingLists && "No lists in the following declaration??");
6118 }
6119 }
6120
6121 ++ListSizeCur;
6122 if (SupportsMapper)
6123 ++MapperCur;
6124 return *this;
6125 }
6126 };
6127
6129 llvm::iterator_range<const_component_lists_iterator>;
6130
6131 /// Iterators for all component lists.
6135 getComponentsRef(), SupportsMapper,
6136 SupportsMapper ? getUDMapperRefs() : ArrayRef<Expr *>());
6137 }
6142 getComponentsRef().end()),
6143 SupportsMapper, {});
6144 }
6147 }
6148
6149 /// Iterators for component lists associated with the provided
6150 /// declaration.
6151 const_component_lists_iterator
6155 getComponentListSizesRef(), getComponentsRef(), SupportsMapper,
6156 SupportsMapper ? getUDMapperRefs() : ArrayRef<Expr *>());
6157 }
6159 return component_lists_end();
6160 }
6163 }
6164
6165 /// Iterators to access all the declarations, number of lists, list sizes, and
6166 /// components.
6168 using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>;
6169
6171 auto A = getUniqueDeclsRef();
6172 return const_all_decls_range(A.begin(), A.end());
6173 }
6174
6177 llvm::iterator_range<const_all_num_lists_iterator>;
6178
6180 auto A = getDeclNumListsRef();
6181 return const_all_num_lists_range(A.begin(), A.end());
6182 }
6183
6186 llvm::iterator_range<const_all_lists_sizes_iterator>;
6187
6189 auto A = getComponentListSizesRef();
6190 return const_all_lists_sizes_range(A.begin(), A.end());
6191 }
6192
6195 llvm::iterator_range<const_all_components_iterator>;
6196
6198 auto A = getComponentsRef();
6199 return const_all_components_range(A.begin(), A.end());
6200 }
6201
6204 using mapperlist_range = llvm::iterator_range<mapperlist_iterator>;
6206 llvm::iterator_range<mapperlist_const_iterator>;
6207
6211 return getUDMapperRefs().begin();
6212 }
6214 return getUDMapperRefs().end();
6215 }
6218 }
6221 }
6222};
6223
6224/// This represents clause 'map' in the '#pragma omp ...'
6225/// directives.
6226///
6227/// \code
6228/// #pragma omp target map(a,b)
6229/// \endcode
6230/// In this example directive '#pragma omp target' has clause 'map'
6231/// with the variables 'a' and 'b'.
6232class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
6233 private llvm::TrailingObjects<
6234 OMPMapClause, Expr *, ValueDecl *, unsigned,
6235 OMPClauseMappableExprCommon::MappableComponent> {
6236 friend class OMPClauseReader;
6238 friend OMPVarListClause;
6239 friend TrailingObjects;
6240
6241 /// Define the sizes of each trailing object array except the last one. This
6242 /// is required for TrailingObjects to work properly.
6243 size_t numTrailingObjects(OverloadToken<Expr *>) const {
6244 // There are varlist_size() of expressions, and varlist_size() of
6245 // user-defined mappers.
6246 return 2 * varlist_size() + 1;
6247 }
6248 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
6249 return getUniqueDeclarationsNum();
6250 }
6251 size_t numTrailingObjects(OverloadToken<unsigned>) const {
6253 }
6254
6255private:
6256 /// Map-type-modifiers for the 'map' clause.
6261
6262 /// Location of map-type-modifiers for the 'map' clause.
6263 SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers];
6264
6265 /// Map type for the 'map' clause.
6267
6268 /// Is this an implicit map type or not.
6269 bool MapTypeIsImplicit = false;
6270
6271 /// Location of the map type.
6272 SourceLocation MapLoc;
6273
6274 /// Colon location.
6275 SourceLocation ColonLoc;
6276
6277 /// Build a clause for \a NumVars listed expressions, \a
6278 /// NumUniqueDeclarations declarations, \a NumComponentLists total component
6279 /// lists, and \a NumComponents total expression components.
6280 ///
6281 /// \param MapModifiers Map-type-modifiers.
6282 /// \param MapModifiersLoc Locations of map-type-modifiers.
6283 /// \param MapperQualifierLoc C++ nested name specifier for the associated
6284 /// user-defined mapper.
6285 /// \param MapperIdInfo The identifier of associated user-defined mapper.
6286 /// \param MapType Map type.
6287 /// \param MapTypeIsImplicit Map type is inferred implicitly.
6288 /// \param MapLoc Location of the map type.
6289 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6290 /// StartLoc: starting location of the clause (the clause keyword); 2)
6291 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6292 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6293 /// NumVars: number of expressions listed in this clause; 2)
6294 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6295 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6296 /// NumComponents: total number of expression components in the clause.
6297 explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers,
6298 ArrayRef<SourceLocation> MapModifiersLoc,
6299 NestedNameSpecifierLoc MapperQualifierLoc,
6300 DeclarationNameInfo MapperIdInfo,
6301 OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
6302 SourceLocation MapLoc, const OMPVarListLocTy &Locs,
6303 const OMPMappableExprListSizeTy &Sizes)
6304 : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes,
6305 /*SupportsMapper=*/true, &MapperQualifierLoc,
6306 &MapperIdInfo),
6307 MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {
6308 assert(std::size(MapTypeModifiers) == MapModifiers.size() &&
6309 "Unexpected number of map type modifiers.");
6310 llvm::copy(MapModifiers, std::begin(MapTypeModifiers));
6311
6312 assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() &&
6313 "Unexpected number of map type modifier locations.");
6314 llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc));
6315 }
6316
6317 /// Build an empty clause.
6318 ///
6319 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6320 /// NumVars: number of expressions listed in this clause; 2)
6321 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6322 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6323 /// NumComponents: total number of expression components in the clause.
6324 explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes)
6325 : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes,
6326 /*SupportsMapper=*/true) {}
6327
6328 /// Set map-type-modifier for the clause.
6329 ///
6330 /// \param I index for map-type-modifier.
6331 /// \param T map-type-modifier for the clause.
6332 void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) {
6333 assert(I < NumberOfOMPMapClauseModifiers &&
6334 "Unexpected index to store map type modifier, exceeds array size.");
6335 MapTypeModifiers[I] = T;
6336 }
6337
6338 /// Set location for the map-type-modifier.
6339 ///
6340 /// \param I index for map-type-modifier location.
6341 /// \param TLoc map-type-modifier location.
6342 void setMapTypeModifierLoc(unsigned I, SourceLocation TLoc) {
6343 assert(I < NumberOfOMPMapClauseModifiers &&
6344 "Index to store map type modifier location exceeds array size.");
6345 MapTypeModifiersLoc[I] = TLoc;
6346 }
6347
6348 /// Set type for the clause.
6349 ///
6350 /// \param T Type for the clause.
6351 void setMapType(OpenMPMapClauseKind T) { MapType = T; }
6352
6353 /// Set type location.
6354 ///
6355 /// \param TLoc Type location.
6356 void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
6357
6358 /// Set colon location.
6359 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
6360
6361 /// Set iterator modifier.
6362 void setIteratorModifier(Expr *IteratorModifier) {
6363 getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier;
6364 }
6365
6366public:
6367 /// Creates clause with a list of variables \a VL.
6368 ///
6369 /// \param C AST context.
6370 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6371 /// StartLoc: starting location of the clause (the clause keyword); 2)
6372 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6373 /// \param Vars The original expression used in the clause.
6374 /// \param Declarations Declarations used in the clause.
6375 /// \param ComponentLists Component lists used in the clause.
6376 /// \param UDMapperRefs References to user-defined mappers associated with
6377 /// expressions used in the clause.
6378 /// \param IteratorModifier Iterator modifier.
6379 /// \param MapModifiers Map-type-modifiers.
6380 /// \param MapModifiersLoc Location of map-type-modifiers.
6381 /// \param UDMQualifierLoc C++ nested name specifier for the associated
6382 /// user-defined mapper.
6383 /// \param MapperId The identifier of associated user-defined mapper.
6384 /// \param Type Map type.
6385 /// \param TypeIsImplicit Map type is inferred implicitly.
6386 /// \param TypeLoc Location of the map type.
6387 static OMPMapClause *
6388 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
6389 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
6390 MappableExprComponentListsRef ComponentLists,
6391 ArrayRef<Expr *> UDMapperRefs, Expr *IteratorModifier,
6392 ArrayRef<OpenMPMapModifierKind> MapModifiers,
6393 ArrayRef<SourceLocation> MapModifiersLoc,
6394 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
6395 OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc);
6396
6397 /// Creates an empty clause with the place for \a NumVars original
6398 /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
6399 /// lists, and \a NumComponents expression components.
6400 ///
6401 /// \param C AST context.
6402 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6403 /// NumVars: number of expressions listed in this clause; 2)
6404 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6405 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6406 /// NumComponents: total number of expression components in the clause.
6407 static OMPMapClause *CreateEmpty(const ASTContext &C,
6408 const OMPMappableExprListSizeTy &Sizes);
6409
6410 /// Fetches Expr * of iterator modifier.
6412 return getTrailingObjects<Expr *>()[2 * varlist_size()];
6413 }
6414
6415 /// Fetches mapping kind for the clause.
6416 OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
6417
6418 /// Is this an implicit map type?
6419 /// We have to capture 'IsMapTypeImplicit' from the parser for more
6420 /// informative error messages. It helps distinguish map(r) from
6421 /// map(tofrom: r), which is important to print more helpful error
6422 /// messages for some target directives.
6423 bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
6424
6425 /// Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
6426 ///
6427 /// \param Cnt index for map-type-modifier.
6428 OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY {
6429 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6430 "Requested modifier exceeds the total number of modifiers.");
6431 return MapTypeModifiers[Cnt];
6432 }
6433
6434 /// Fetches the map-type-modifier location at 'Cnt' index of array of
6435 /// modifiers' locations.
6436 ///
6437 /// \param Cnt index for map-type-modifier location.
6438 SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY {
6439 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6440 "Requested modifier location exceeds total number of modifiers.");
6441 return MapTypeModifiersLoc[Cnt];
6442 }
6443
6444 /// Fetches ArrayRef of map-type-modifiers.
6446 return llvm::ArrayRef(MapTypeModifiers);
6447 }
6448
6449 /// Fetches ArrayRef of location of map-type-modifiers.
6451 return llvm::ArrayRef(MapTypeModifiersLoc);
6452 }
6453
6454 /// Fetches location of clause mapping kind.
6455 SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
6456
6457 /// Get colon location.
6458 SourceLocation getColonLoc() const { return ColonLoc; }
6459
6461 return child_range(
6462 reinterpret_cast<Stmt **>(varlist_begin()),
6463 reinterpret_cast<Stmt **>(varlist_end()));
6464 }
6465
6467 auto Children = const_cast<OMPMapClause *>(this)->children();
6468 return const_child_range(Children.begin(), Children.end());
6469 }
6470
6472 if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom)
6473 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6474 reinterpret_cast<Stmt **>(varlist_end()));
6476 }
6478 auto Children = const_cast<OMPMapClause *>(this)->used_children();
6479 return const_child_range(Children.begin(), Children.end());
6480 }
6481
6482
6483 static bool classof(const OMPClause *T) {
6484 return T->getClauseKind() == llvm::omp::OMPC_map;
6485 }
6486};
6487
6488/// This represents 'num_teams' clause in the '#pragma omp ...'
6489/// directive.
6490///
6491/// \code
6492/// #pragma omp teams num_teams(n)
6493/// \endcode
6494/// In this example directive '#pragma omp teams' has clause 'num_teams'
6495/// with single expression 'n'.
6496///
6497/// When 'ompx_bare' clause exists on a 'target' directive, 'num_teams' clause
6498/// can accept up to three expressions.
6499///
6500/// \code
6501/// #pragma omp target teams ompx_bare num_teams(x, y, z)
6502/// \endcode
6504 : public OMPVarListClause<OMPNumTeamsClause>,
6505 public OMPClauseWithPreInit,
6506 private llvm::TrailingObjects<OMPNumTeamsClause, Expr *> {
6507 friend OMPVarListClause;
6508 friend TrailingObjects;
6509
6510 /// Location of '('.
6511 SourceLocation LParenLoc;
6512
6514 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
6515 : OMPVarListClause(llvm::omp::OMPC_num_teams, StartLoc, LParenLoc, EndLoc,
6516 N),
6517 OMPClauseWithPreInit(this) {}
6518
6519 /// Build an empty clause.
6520 OMPNumTeamsClause(unsigned N)
6521 : OMPVarListClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6523 OMPClauseWithPreInit(this) {}
6524
6525public:
6526 /// Creates clause with a list of variables \a VL.
6527 ///
6528 /// \param C AST context.
6529 /// \param StartLoc Starting location of the clause.
6530 /// \param LParenLoc Location of '('.
6531 /// \param EndLoc Ending location of the clause.
6532 /// \param VL List of references to the variables.
6533 /// \param PreInit
6534 static OMPNumTeamsClause *
6535 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6536 SourceLocation StartLoc, SourceLocation LParenLoc,
6537 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6538
6539 /// Creates an empty clause with \a N variables.
6540 ///
6541 /// \param C AST context.
6542 /// \param N The number of variables.
6543 static OMPNumTeamsClause *CreateEmpty(const ASTContext &C, unsigned N);
6544
6545 /// Sets the location of '('.
6546 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6547
6548 /// Returns the location of '('.
6549 SourceLocation getLParenLoc() const { return LParenLoc; }
6550
6551 /// Return NumTeams expressions.
6553
6554 /// Return NumTeams expressions.
6556 return const_cast<OMPNumTeamsClause *>(this)->getNumTeams();
6557 }
6558
6560 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6561 reinterpret_cast<Stmt **>(varlist_end()));
6562 }
6563
6565 auto Children = const_cast<OMPNumTeamsClause *>(this)->children();
6566 return const_child_range(Children.begin(), Children.end());
6567 }
6568
6571 }
6574 }
6575
6576 static bool classof(const OMPClause *T) {
6577 return T->getClauseKind() == llvm::omp::OMPC_num_teams;
6578 }
6579};
6580
6581/// This represents 'thread_limit' clause in the '#pragma omp ...'
6582/// directive.
6583///
6584/// \code
6585/// #pragma omp teams thread_limit(n)
6586/// \endcode
6587/// In this example directive '#pragma omp teams' has clause 'thread_limit'
6588/// with single expression 'n'.
6589///
6590/// When 'ompx_bare' clause exists on a 'target' directive, 'thread_limit'
6591/// clause can accept up to three expressions.
6592///
6593/// \code
6594/// #pragma omp target teams ompx_bare thread_limit(x, y, z)
6595/// \endcode
6597 : public OMPVarListClause<OMPThreadLimitClause>,
6598 public OMPClauseWithPreInit,
6599 private llvm::TrailingObjects<OMPThreadLimitClause, Expr *> {
6600 friend OMPVarListClause;
6601 friend TrailingObjects;
6602
6603 /// Location of '('.
6604 SourceLocation LParenLoc;
6605
6607 SourceLocation LParenLoc, SourceLocation EndLoc,
6608 unsigned N)
6609 : OMPVarListClause(llvm::omp::OMPC_thread_limit, StartLoc, LParenLoc,
6610 EndLoc, N),
6611 OMPClauseWithPreInit(this) {}
6612
6613 /// Build an empty clause.
6614 OMPThreadLimitClause(unsigned N)
6615 : OMPVarListClause(llvm::omp::OMPC_thread_limit, SourceLocation(),
6617 OMPClauseWithPreInit(this) {}
6618
6619public:
6620 /// Creates clause with a list of variables \a VL.
6621 ///
6622 /// \param C AST context.
6623 /// \param StartLoc Starting location of the clause.
6624 /// \param LParenLoc Location of '('.
6625 /// \param EndLoc Ending location of the clause.
6626 /// \param VL List of references to the variables.
6627 /// \param PreInit
6628 static OMPThreadLimitClause *
6629 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6630 SourceLocation StartLoc, SourceLocation LParenLoc,
6631 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6632
6633 /// Creates an empty clause with \a N variables.
6634 ///
6635 /// \param C AST context.
6636 /// \param N The number of variables.
6637 static OMPThreadLimitClause *CreateEmpty(const ASTContext &C, unsigned N);
6638
6639 /// Sets the location of '('.
6640 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6641
6642 /// Returns the location of '('.
6643 SourceLocation getLParenLoc() const { return LParenLoc; }
6644
6645 /// Return ThreadLimit expressions.
6647
6648 /// Return ThreadLimit expressions.
6650 return const_cast<OMPThreadLimitClause *>(this)->getThreadLimit();
6651 }
6652
6654 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6655 reinterpret_cast<Stmt **>(varlist_end()));
6656 }
6657
6659 auto Children = const_cast<OMPThreadLimitClause *>(this)->children();
6660 return const_child_range(Children.begin(), Children.end());
6661 }
6662
6665 }
6668 }
6669
6670 static bool classof(const OMPClause *T) {
6671 return T->getClauseKind() == llvm::omp::OMPC_thread_limit;
6672 }
6673};
6674
6675/// This represents 'priority' clause in the '#pragma omp ...'
6676/// directive.
6677///
6678/// \code
6679/// #pragma omp task priority(n)
6680/// \endcode
6681/// In this example directive '#pragma omp teams' has clause 'priority' with
6682/// single expression 'n'.
6684 friend class OMPClauseReader;
6685
6686 /// Location of '('.
6687 SourceLocation LParenLoc;
6688
6689 /// Priority number.
6690 Stmt *Priority = nullptr;
6691
6692 /// Set the Priority number.
6693 ///
6694 /// \param E Priority number.
6695 void setPriority(Expr *E) { Priority = E; }
6696
6697public:
6698 /// Build 'priority' clause.
6699 ///
6700 /// \param Priority Expression associated with this clause.
6701 /// \param HelperPriority Helper priority for the construct.
6702 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6703 /// clause must be captured.
6704 /// \param StartLoc Starting location of the clause.
6705 /// \param LParenLoc Location of '('.
6706 /// \param EndLoc Ending location of the clause.
6708 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
6709 SourceLocation LParenLoc, SourceLocation EndLoc)
6710 : OMPClause(llvm::omp::OMPC_priority, StartLoc, EndLoc),
6711 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Priority(Priority) {
6712 setPreInitStmt(HelperPriority, CaptureRegion);
6713 }
6714
6715 /// Build an empty clause.
6717 : OMPClause(llvm::omp::OMPC_priority, SourceLocation(), SourceLocation()),
6718 OMPClauseWithPreInit(this) {}
6719
6720 /// Sets the location of '('.
6721 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6722
6723 /// Returns the location of '('.
6724 SourceLocation getLParenLoc() const { return LParenLoc; }
6725
6726 /// Return Priority number.
6727 Expr *getPriority() { return cast<Expr>(Priority); }
6728
6729 /// Return Priority number.
6730 Expr *getPriority() const { return cast<Expr>(Priority); }
6731
6733
6735 return const_child_range(&Priority, &Priority + 1);
6736 }
6737
6740 auto Children = const_cast<OMPPriorityClause *>(this)->used_children();
6741 return const_child_range(Children.begin(), Children.end());
6742 }
6743
6744 static bool classof(const OMPClause *T) {
6745 return T->getClauseKind() == llvm::omp::OMPC_priority;
6746 }
6747};
6748
6749/// This represents 'grainsize' clause in the '#pragma omp ...'
6750/// directive.
6751///
6752/// \code
6753/// #pragma omp taskloop grainsize(4)
6754/// \endcode
6755/// In this example directive '#pragma omp taskloop' has clause 'grainsize'
6756/// with single expression '4'.
6758 friend class OMPClauseReader;
6759
6760 /// Location of '('.
6761 SourceLocation LParenLoc;
6762
6763 /// Modifiers for 'grainsize' clause.
6765
6766 /// Location of the modifier.
6767 SourceLocation ModifierLoc;
6768
6769 /// Safe iteration space distance.
6770 Stmt *Grainsize = nullptr;
6771
6772 /// Set safelen.
6773 void setGrainsize(Expr *Size) { Grainsize = Size; }
6774
6775 /// Sets modifier.
6776 void setModifier(OpenMPGrainsizeClauseModifier M) { Modifier = M; }
6777
6778 /// Sets modifier location.
6779 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
6780
6781public:
6782 /// Build 'grainsize' clause.
6783 ///
6784 /// \param Modifier Clause modifier.
6785 /// \param Size Expression associated with this clause.
6786 /// \param HelperSize Helper grainsize for the construct.
6787 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6788 /// clause must be captured.
6789 /// \param StartLoc Starting location of the clause.
6790 /// \param ModifierLoc Modifier location.
6791 /// \param LParenLoc Location of '('.
6792 /// \param EndLoc Ending location of the clause.
6794 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
6795 SourceLocation StartLoc, SourceLocation LParenLoc,
6796 SourceLocation ModifierLoc, SourceLocation EndLoc)
6797 : OMPClause(llvm::omp::OMPC_grainsize, StartLoc, EndLoc),
6798 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
6799 ModifierLoc(ModifierLoc), Grainsize(Size) {
6800 setPreInitStmt(HelperSize, CaptureRegion);
6801 }
6802
6803 /// Build an empty clause.
6805 : OMPClause(llvm::omp::OMPC_grainsize, SourceLocation(),
6806 SourceLocation()),
6807 OMPClauseWithPreInit(this) {}
6808
6809 /// Sets the location of '('.
6810 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6811
6812 /// Returns the location of '('.
6813 SourceLocation getLParenLoc() const { return LParenLoc; }
6814
6815 /// Return safe iteration space distance.
6816 Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
6817
6818 /// Gets modifier.
6819 OpenMPGrainsizeClauseModifier getModifier() const { return Modifier; }
6820
6821 /// Gets modifier location.
6822 SourceLocation getModifierLoc() const { return ModifierLoc; }
6823
6824 child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
6825
6827 return const_child_range(&Grainsize, &Grainsize + 1);
6828 }
6829
6832 auto Children = const_cast<OMPGrainsizeClause *>(this)->used_children();
6833 return const_child_range(Children.begin(), Children.end());
6834 }
6835
6836 static bool classof(const OMPClause *T) {
6837 return T->getClauseKind() == llvm::omp::OMPC_grainsize;
6838 }
6839};
6840
6841/// This represents 'nogroup' clause in the '#pragma omp ...' directive.
6842///
6843/// \code
6844/// #pragma omp taskloop nogroup
6845/// \endcode
6846/// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
6848public:
6849 /// Build 'nogroup' clause.
6850 ///
6851 /// \param StartLoc Starting location of the clause.
6852 /// \param EndLoc Ending location of the clause.
6854 : OMPClause(llvm::omp::OMPC_nogroup, StartLoc, EndLoc) {}
6855
6856 /// Build an empty clause.
6858 : OMPClause(llvm::omp::OMPC_nogroup, SourceLocation(), SourceLocation()) {
6859 }
6860
6863 }
6864
6867 }
6868
6871 }
6874 }
6875
6876 static bool classof(const OMPClause *T) {
6877 return T->getClauseKind() == llvm::omp::OMPC_nogroup;
6878 }
6879};
6880
6881/// This represents 'num_tasks' clause in the '#pragma omp ...'
6882/// directive.
6883///
6884/// \code
6885/// #pragma omp taskloop num_tasks(4)
6886/// \endcode
6887/// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
6888/// with single expression '4'.
6890 friend class OMPClauseReader;
6891
6892 /// Location of '('.
6893 SourceLocation LParenLoc;
6894
6895 /// Modifiers for 'num_tasks' clause.
6897
6898 /// Location of the modifier.
6899 SourceLocation ModifierLoc;
6900
6901 /// Safe iteration space distance.
6902 Stmt *NumTasks = nullptr;
6903
6904 /// Set safelen.
6905 void setNumTasks(Expr *Size) { NumTasks = Size; }
6906
6907 /// Sets modifier.
6908 void setModifier(OpenMPNumTasksClauseModifier M) { Modifier = M; }
6909
6910 /// Sets modifier location.
6911 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
6912
6913public:
6914 /// Build 'num_tasks' clause.
6915 ///
6916 /// \param Modifier Clause modifier.
6917 /// \param Size Expression associated with this clause.
6918 /// \param HelperSize Helper grainsize for the construct.
6919 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6920 /// clause must be captured.
6921 /// \param StartLoc Starting location of the clause.
6922 /// \param EndLoc Ending location of the clause.
6923 /// \param ModifierLoc Modifier location.
6924 /// \param LParenLoc Location of '('.
6926 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
6927 SourceLocation StartLoc, SourceLocation LParenLoc,
6928 SourceLocation ModifierLoc, SourceLocation EndLoc)
6929 : OMPClause(llvm::omp::OMPC_num_tasks, StartLoc, EndLoc),
6930 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
6931 ModifierLoc(ModifierLoc), NumTasks(Size) {
6932 setPreInitStmt(HelperSize, CaptureRegion);
6933 }
6934
6935 /// Build an empty clause.
6937 : OMPClause(llvm::omp::OMPC_num_tasks, SourceLocation(),
6938 SourceLocation()),
6939 OMPClauseWithPreInit(this) {}
6940
6941 /// Sets the location of '('.
6942 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6943
6944 /// Returns the location of '('.
6945 SourceLocation getLParenLoc() const { return LParenLoc; }
6946
6947 /// Return safe iteration space distance.
6948 Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
6949
6950 /// Gets modifier.
6951 OpenMPNumTasksClauseModifier getModifier() const { return Modifier; }
6952
6953 /// Gets modifier location.
6954 SourceLocation getModifierLoc() const { return ModifierLoc; }
6955
6956 child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
6957
6959 return const_child_range(&NumTasks, &NumTasks + 1);
6960 }
6961
6964 auto Children = const_cast<OMPNumTasksClause *>(this)->used_children();
6965 return const_child_range(Children.begin(), Children.end());
6966 }
6967
6968 static bool classof(const OMPClause *T) {
6969 return T->getClauseKind() == llvm::omp::OMPC_num_tasks;
6970 }
6971};
6972
6973/// This represents 'hint' clause in the '#pragma omp ...' directive.
6974///
6975/// \code
6976/// #pragma omp critical (name) hint(6)
6977/// \endcode
6978/// In this example directive '#pragma omp critical' has name 'name' and clause
6979/// 'hint' with argument '6'.
6980class OMPHintClause : public OMPClause {
6981 friend class OMPClauseReader;
6982
6983 /// Location of '('.
6984 SourceLocation LParenLoc;
6985
6986 /// Hint expression of the 'hint' clause.
6987 Stmt *Hint = nullptr;
6988
6989 /// Set hint expression.
6990 void setHint(Expr *H) { Hint = H; }
6991
6992public:
6993 /// Build 'hint' clause with expression \a Hint.
6994 ///
6995 /// \param Hint Hint expression.
6996 /// \param StartLoc Starting location of the clause.
6997 /// \param LParenLoc Location of '('.
6998 /// \param EndLoc Ending location of the clause.
7000 SourceLocation EndLoc)
7001 : OMPClause(llvm::omp::OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
7002 Hint(Hint) {}
7003
7004 /// Build an empty clause.
7006 : OMPClause(llvm::omp::OMPC_hint, SourceLocation(), SourceLocation()) {}
7007
7008 /// Sets the location of '('.
7009 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7010
7011 /// Returns the location of '('.
7012 SourceLocation getLParenLoc() const { return LParenLoc; }
7013
7014 /// Returns number of threads.
7015 Expr *getHint() const { return cast_or_null<Expr>(Hint); }
7016
7017 child_range children() { return child_range(&Hint, &Hint + 1); }
7018
7020 return const_child_range(&Hint, &Hint + 1);
7021 }
7022
7025 }
7028 }
7029
7030 static bool classof(const OMPClause *T) {
7031 return T->getClauseKind() == llvm::omp::OMPC_hint;
7032 }
7033};
7034
7035/// This represents 'dist_schedule' clause in the '#pragma omp ...'
7036/// directive.
7037///
7038/// \code
7039/// #pragma omp distribute dist_schedule(static, 3)
7040/// \endcode
7041/// In this example directive '#pragma omp distribute' has 'dist_schedule'
7042/// clause with arguments 'static' and '3'.
7044 friend class OMPClauseReader;
7045
7046 /// Location of '('.
7047 SourceLocation LParenLoc;
7048
7049 /// A kind of the 'schedule' clause.
7051
7052 /// Start location of the schedule kind in source code.
7053 SourceLocation KindLoc;
7054
7055 /// Location of ',' (if any).
7056 SourceLocation CommaLoc;
7057
7058 /// Chunk size.
7059 Expr *ChunkSize = nullptr;
7060
7061 /// Set schedule kind.
7062 ///
7063 /// \param K Schedule kind.
7064 void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
7065
7066 /// Sets the location of '('.
7067 ///
7068 /// \param Loc Location of '('.
7069 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7070
7071 /// Set schedule kind start location.
7072 ///
7073 /// \param KLoc Schedule kind location.
7074 void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
7075
7076 /// Set location of ','.
7077 ///
7078 /// \param Loc Location of ','.
7079 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
7080
7081 /// Set chunk size.
7082 ///
7083 /// \param E Chunk size.
7084 void setChunkSize(Expr *E) { ChunkSize = E; }
7085
7086public:
7087 /// Build 'dist_schedule' clause with schedule kind \a Kind and chunk
7088 /// size expression \a ChunkSize.
7089 ///
7090 /// \param StartLoc Starting location of the clause.
7091 /// \param LParenLoc Location of '('.
7092 /// \param KLoc Starting location of the argument.
7093 /// \param CommaLoc Location of ','.
7094 /// \param EndLoc Ending location of the clause.
7095 /// \param Kind DistSchedule kind.
7096 /// \param ChunkSize Chunk size.
7097 /// \param HelperChunkSize Helper chunk size for combined directives.
7099 SourceLocation KLoc, SourceLocation CommaLoc,
7100 SourceLocation EndLoc,
7102 Stmt *HelperChunkSize)
7103 : OMPClause(llvm::omp::OMPC_dist_schedule, StartLoc, EndLoc),
7104 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
7105 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
7106 setPreInitStmt(HelperChunkSize);
7107 }
7108
7109 /// Build an empty clause.
7111 : OMPClause(llvm::omp::OMPC_dist_schedule, SourceLocation(),
7112 SourceLocation()),
7113 OMPClauseWithPreInit(this) {}
7114
7115 /// Get kind of the clause.
7117
7118 /// Get location of '('.
7119 SourceLocation getLParenLoc() { return LParenLoc; }
7120
7121 /// Get kind location.
7123
7124 /// Get location of ','.
7125 SourceLocation getCommaLoc() { return CommaLoc; }
7126
7127 /// Get chunk size.
7128 Expr *getChunkSize() { return ChunkSize; }
7129
7130 /// Get chunk size.
7131 const Expr *getChunkSize() const { return ChunkSize; }
7132
7134 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
7135 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
7136 }
7137
7139 auto Children = const_cast<OMPDistScheduleClause *>(this)->children();
7140 return const_child_range(Children.begin(), Children.end());
7141 }
7142
7145 }
7148 }
7149
7150 static bool classof(const OMPClause *T) {
7151 return T->getClauseKind() == llvm::omp::OMPC_dist_schedule;
7152 }
7153};
7154
7155/// This represents 'defaultmap' clause in the '#pragma omp ...' directive.
7156///
7157/// \code
7158/// #pragma omp target defaultmap(tofrom: scalar)
7159/// \endcode
7160/// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
7161/// 'scalar' with modifier 'tofrom'.
7163 friend class OMPClauseReader;
7164
7165 /// Location of '('.
7166 SourceLocation LParenLoc;
7167
7168 /// Modifiers for 'defaultmap' clause.
7170
7171 /// Locations of modifiers.
7172 SourceLocation ModifierLoc;
7173
7174 /// A kind of the 'defaultmap' clause.
7176
7177 /// Start location of the defaultmap kind in source code.
7178 SourceLocation KindLoc;
7179
7180 /// Set defaultmap kind.
7181 ///
7182 /// \param K Defaultmap kind.
7183 void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
7184
7185 /// Set the defaultmap modifier.
7186 ///
7187 /// \param M Defaultmap modifier.
7188 void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
7189 Modifier = M;
7190 }
7191
7192 /// Set location of the defaultmap modifier.
7193 void setDefaultmapModifierLoc(SourceLocation Loc) {
7194 ModifierLoc = Loc;
7195 }
7196
7197 /// Sets the location of '('.
7198 ///
7199 /// \param Loc Location of '('.
7200 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7201
7202 /// Set defaultmap kind start location.
7203 ///
7204 /// \param KLoc Defaultmap kind location.
7205 void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
7206
7207public:
7208 /// Build 'defaultmap' clause with defaultmap kind \a Kind
7209 ///
7210 /// \param StartLoc Starting location of the clause.
7211 /// \param LParenLoc Location of '('.
7212 /// \param KLoc Starting location of the argument.
7213 /// \param EndLoc Ending location of the clause.
7214 /// \param Kind Defaultmap kind.
7215 /// \param M The modifier applied to 'defaultmap' clause.
7216 /// \param MLoc Location of the modifier
7218 SourceLocation MLoc, SourceLocation KLoc,
7221 : OMPClause(llvm::omp::OMPC_defaultmap, StartLoc, EndLoc),
7222 LParenLoc(LParenLoc), Modifier(M), ModifierLoc(MLoc), Kind(Kind),
7223 KindLoc(KLoc) {}
7224
7225 /// Build an empty clause.
7227 : OMPClause(llvm::omp::OMPC_defaultmap, SourceLocation(),
7228 SourceLocation()) {}
7229
7230 /// Get kind of the clause.
7232
7233 /// Get the modifier of the clause.
7235 return Modifier;
7236 }
7237
7238 /// Get location of '('.
7239 SourceLocation getLParenLoc() { return LParenLoc; }
7240
7241 /// Get kind location.
7243
7244 /// Get the modifier location.
7246 return ModifierLoc;
7247 }
7248
7251 }
7252
7255 }
7256
7259 }
7262 }
7263
7264 static bool classof(const OMPClause *T) {
7265 return T->getClauseKind() == llvm::omp::OMPC_defaultmap;
7266 }
7267};
7268
7269/// This represents clause 'to' in the '#pragma omp ...'
7270/// directives.
7271///
7272/// \code
7273/// #pragma omp target update to(a,b)
7274/// \endcode
7275/// In this example directive '#pragma omp target update' has clause 'to'
7276/// with the variables 'a' and 'b'.
7277class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
7278 private llvm::TrailingObjects<
7279 OMPToClause, Expr *, ValueDecl *, unsigned,
7280 OMPClauseMappableExprCommon::MappableComponent> {
7281 friend class OMPClauseReader;
7283 friend OMPVarListClause;
7284 friend TrailingObjects;
7285
7286 /// Motion-modifiers for the 'to' clause.
7289
7290 /// Location of motion-modifiers for the 'to' clause.
7291 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7292
7293 /// Colon location.
7294 SourceLocation ColonLoc;
7295
7296 /// Build clause with number of variables \a NumVars.
7297 ///
7298 /// \param TheMotionModifiers Motion-modifiers.
7299 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7300 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7301 /// user-defined mapper.
7302 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7303 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7304 /// StartLoc: starting location of the clause (the clause keyword); 2)
7305 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7306 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7307 /// NumVars: number of expressions listed in this clause; 2)
7308 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7309 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7310 /// NumComponents: total number of expression components in the clause.
7311 explicit OMPToClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7312 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7313 NestedNameSpecifierLoc MapperQualifierLoc,
7314 DeclarationNameInfo MapperIdInfo,
7315 const OMPVarListLocTy &Locs,
7316 const OMPMappableExprListSizeTy &Sizes)
7317 : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
7318 /*SupportsMapper=*/true, &MapperQualifierLoc,
7319 &MapperIdInfo) {
7320 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7321 "Unexpected number of motion modifiers.");
7322 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7323
7324 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7325 "Unexpected number of motion modifier locations.");
7326 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7327 }
7328
7329 /// Build an empty clause.
7330 ///
7331 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7332 /// NumVars: number of expressions listed in this clause; 2)
7333 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7334 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7335 /// NumComponents: total number of expression components in the clause.
7336 explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes)
7337 : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
7338 /*SupportsMapper=*/true) {}
7339
7340 /// Set motion-modifier for the clause.
7341 ///
7342 /// \param I index for motion-modifier.
7343 /// \param T motion-modifier for the clause.
7344 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7345 assert(I < NumberOfOMPMotionModifiers &&
7346 "Unexpected index to store motion modifier, exceeds array size.");
7347 MotionModifiers[I] = T;
7348 }
7349
7350 /// Set location for the motion-modifier.
7351 ///
7352 /// \param I index for motion-modifier location.
7353 /// \param TLoc motion-modifier location.
7354 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7355 assert(I < NumberOfOMPMotionModifiers &&
7356 "Index to store motion modifier location exceeds array size.");
7357 MotionModifiersLoc[I] = TLoc;
7358 }
7359
7360 /// Set colon location.
7361 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7362
7363 /// Define the sizes of each trailing object array except the last one. This
7364 /// is required for TrailingObjects to work properly.
7365 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7366 // There are varlist_size() of expressions, and varlist_size() of
7367 // user-defined mappers.
7368 return 2 * varlist_size();
7369 }
7370 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7371 return getUniqueDeclarationsNum();
7372 }
7373 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7375 }
7376
7377public:
7378 /// Creates clause with a list of variables \a Vars.
7379 ///
7380 /// \param C AST context.
7381 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7382 /// StartLoc: starting location of the clause (the clause keyword); 2)
7383 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7384 /// \param Vars The original expression used in the clause.
7385 /// \param Declarations Declarations used in the clause.
7386 /// \param ComponentLists Component lists used in the clause.
7387 /// \param MotionModifiers Motion-modifiers.
7388 /// \param MotionModifiersLoc Location of motion-modifiers.
7389 /// \param UDMapperRefs References to user-defined mappers associated with
7390 /// expressions used in the clause.
7391 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7392 /// user-defined mapper.
7393 /// \param MapperId The identifier of associated user-defined mapper.
7394 static OMPToClause *Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7395 ArrayRef<Expr *> Vars,
7396 ArrayRef<ValueDecl *> Declarations,
7397 MappableExprComponentListsRef ComponentLists,
7398 ArrayRef<Expr *> UDMapperRefs,
7399 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7400 ArrayRef<SourceLocation> MotionModifiersLoc,
7401 NestedNameSpecifierLoc UDMQualifierLoc,
7402 DeclarationNameInfo MapperId);
7403
7404 /// Creates an empty clause with the place for \a NumVars variables.
7405 ///
7406 /// \param C AST context.
7407 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7408 /// NumVars: number of expressions listed in this clause; 2)
7409 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7410 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7411 /// NumComponents: total number of expression components in the clause.
7412 static OMPToClause *CreateEmpty(const ASTContext &C,
7413 const OMPMappableExprListSizeTy &Sizes);
7414
7415 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7416 ///
7417 /// \param Cnt index for motion-modifier.
7418 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7419 assert(Cnt < NumberOfOMPMotionModifiers &&
7420 "Requested modifier exceeds the total number of modifiers.");
7421 return MotionModifiers[Cnt];
7422 }
7423
7424 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7425 /// locations.
7426 ///
7427 /// \param Cnt index for motion-modifier location.
7428 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7429 assert(Cnt < NumberOfOMPMotionModifiers &&
7430 "Requested modifier location exceeds total number of modifiers.");
7431 return MotionModifiersLoc[Cnt];
7432 }
7433
7434 /// Fetches ArrayRef of motion-modifiers.
7436 return llvm::ArrayRef(MotionModifiers);
7437 }
7438
7439 /// Fetches ArrayRef of location of motion-modifiers.
7441 return llvm::ArrayRef(MotionModifiersLoc);
7442 }
7443
7444 /// Get colon location.
7445 SourceLocation getColonLoc() const { return ColonLoc; }
7446
7448 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7449 reinterpret_cast<Stmt **>(varlist_end()));
7450 }
7451
7453 auto Children = const_cast<OMPToClause *>(this)->children();
7454 return const_child_range(Children.begin(), Children.end());
7455 }
7456
7459 }
7462 }
7463
7464 static bool classof(const OMPClause *T) {
7465 return T->getClauseKind() == llvm::omp::OMPC_to;
7466 }
7467};
7468
7469/// This represents clause 'from' in the '#pragma omp ...'
7470/// directives.
7471///
7472/// \code
7473/// #pragma omp target update from(a,b)
7474/// \endcode
7475/// In this example directive '#pragma omp target update' has clause 'from'
7476/// with the variables 'a' and 'b'.
7477class OMPFromClause final
7478 : public OMPMappableExprListClause<OMPFromClause>,
7479 private llvm::TrailingObjects<
7480 OMPFromClause, Expr *, ValueDecl *, unsigned,
7481 OMPClauseMappableExprCommon::MappableComponent> {
7482 friend class OMPClauseReader;
7484 friend OMPVarListClause;
7485 friend TrailingObjects;
7486
7487 /// Motion-modifiers for the 'from' clause.
7490
7491 /// Location of motion-modifiers for the 'from' clause.
7492 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7493
7494 /// Colon location.
7495 SourceLocation ColonLoc;
7496
7497 /// Build clause with number of variables \a NumVars.
7498 ///
7499 /// \param TheMotionModifiers Motion-modifiers.
7500 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7501 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7502 /// user-defined mapper.
7503 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7504 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7505 /// StartLoc: starting location of the clause (the clause keyword); 2)
7506 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7507 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7508 /// NumVars: number of expressions listed in this clause; 2)
7509 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7510 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7511 /// NumComponents: total number of expression components in the clause.
7512 explicit OMPFromClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7513 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7514 NestedNameSpecifierLoc MapperQualifierLoc,
7515 DeclarationNameInfo MapperIdInfo,
7516 const OMPVarListLocTy &Locs,
7517 const OMPMappableExprListSizeTy &Sizes)
7518 : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes,
7519 /*SupportsMapper=*/true, &MapperQualifierLoc,
7520 &MapperIdInfo) {
7521 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7522 "Unexpected number of motion modifiers.");
7523 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7524
7525 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7526 "Unexpected number of motion modifier locations.");
7527 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7528 }
7529
7530 /// Build an empty clause.
7531 ///
7532 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7533 /// NumVars: number of expressions listed in this clause; 2)
7534 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7535 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7536 /// NumComponents: total number of expression components in the clause.
7537 explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes)
7538 : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(),
7539 Sizes, /*SupportsMapper=*/true) {}
7540
7541 /// Set motion-modifier for the clause.
7542 ///
7543 /// \param I index for motion-modifier.
7544 /// \param T motion-modifier for the clause.
7545 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7546 assert(I < NumberOfOMPMotionModifiers &&
7547 "Unexpected index to store motion modifier, exceeds array size.");
7548 MotionModifiers[I] = T;
7549 }
7550
7551 /// Set location for the motion-modifier.
7552 ///
7553 /// \param I index for motion-modifier location.
7554 /// \param TLoc motion-modifier location.
7555 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7556 assert(I < NumberOfOMPMotionModifiers &&
7557 "Index to store motion modifier location exceeds array size.");
7558 MotionModifiersLoc[I] = TLoc;
7559 }
7560
7561 /// Set colon location.
7562 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7563
7564 /// Define the sizes of each trailing object array except the last one. This
7565 /// is required for TrailingObjects to work properly.
7566 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7567 // There are varlist_size() of expressions, and varlist_size() of
7568 // user-defined mappers.
7569 return 2 * varlist_size();
7570 }
7571 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7572 return getUniqueDeclarationsNum();
7573 }
7574 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7576 }
7577
7578public:
7579 /// Creates clause with a list of variables \a Vars.
7580 ///
7581 /// \param C AST context.
7582 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7583 /// StartLoc: starting location of the clause (the clause keyword); 2)
7584 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7585 /// \param Vars The original expression used in the clause.
7586 /// \param Declarations Declarations used in the clause.
7587 /// \param ComponentLists Component lists used in the clause.
7588 /// \param MotionModifiers Motion-modifiers.
7589 /// \param MotionModifiersLoc Location of motion-modifiers.
7590 /// \param UDMapperRefs References to user-defined mappers associated with
7591 /// expressions used in the clause.
7592 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7593 /// user-defined mapper.
7594 /// \param MapperId The identifier of associated user-defined mapper.
7595 static OMPFromClause *
7596 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7597 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7598 MappableExprComponentListsRef ComponentLists,
7599 ArrayRef<Expr *> UDMapperRefs,
7600 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7601 ArrayRef<SourceLocation> MotionModifiersLoc,
7602 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId);
7603
7604 /// Creates an empty clause with the place for \a NumVars variables.
7605 ///
7606 /// \param C AST context.
7607 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7608 /// NumVars: number of expressions listed in this clause; 2)
7609 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7610 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7611 /// NumComponents: total number of expression components in the clause.
7612 static OMPFromClause *CreateEmpty(const ASTContext &C,
7613 const OMPMappableExprListSizeTy &Sizes);
7614
7615 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7616 ///
7617 /// \param Cnt index for motion-modifier.
7618 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7619 assert(Cnt < NumberOfOMPMotionModifiers &&
7620 "Requested modifier exceeds the total number of modifiers.");
7621 return MotionModifiers[Cnt];
7622 }
7623
7624 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7625 /// locations.
7626 ///
7627 /// \param Cnt index for motion-modifier location.
7628 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7629 assert(Cnt < NumberOfOMPMotionModifiers &&
7630 "Requested modifier location exceeds total number of modifiers.");
7631 return MotionModifiersLoc[Cnt];
7632 }
7633
7634 /// Fetches ArrayRef of motion-modifiers.
7636 return llvm::ArrayRef(MotionModifiers);
7637 }
7638
7639 /// Fetches ArrayRef of location of motion-modifiers.
7641 return llvm::ArrayRef(MotionModifiersLoc);
7642 }
7643
7644 /// Get colon location.
7645 SourceLocation getColonLoc() const { return ColonLoc; }
7646
7648 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7649 reinterpret_cast<Stmt **>(varlist_end()));
7650 }
7651
7653 auto Children = const_cast<OMPFromClause *>(this)->children();
7654 return const_child_range(Children.begin(), Children.end());
7655 }
7656
7659 }
7662 }
7663
7664 static bool classof(const OMPClause *T) {
7665 return T->getClauseKind() == llvm::omp::OMPC_from;
7666 }
7667};
7668
7669/// This represents clause 'use_device_ptr' in the '#pragma omp ...'
7670/// directives.
7671///
7672/// \code
7673/// #pragma omp target data use_device_ptr(a,b)
7674/// \endcode
7675/// In this example directive '#pragma omp target data' has clause
7676/// 'use_device_ptr' with the variables 'a' and 'b'.
7678 : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
7679 private llvm::TrailingObjects<
7680 OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
7681 OMPClauseMappableExprCommon::MappableComponent> {
7682 friend class OMPClauseReader;
7684 friend OMPVarListClause;
7685 friend TrailingObjects;
7686
7687 /// Build clause with number of variables \a NumVars.
7688 ///
7689 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7690 /// StartLoc: starting location of the clause (the clause keyword); 2)
7691 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7692 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7693 /// NumVars: number of expressions listed in this clause; 2)
7694 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7695 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7696 /// NumComponents: total number of expression components in the clause.
7697 explicit OMPUseDevicePtrClause(const OMPVarListLocTy &Locs,
7698 const OMPMappableExprListSizeTy &Sizes)
7699 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr, Locs, Sizes) {
7700 }
7701
7702 /// Build an empty clause.
7703 ///
7704 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7705 /// NumVars: number of expressions listed in this clause; 2)
7706 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7707 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7708 /// NumComponents: total number of expression components in the clause.
7710 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr,
7711 OMPVarListLocTy(), Sizes) {}
7712
7713 /// Define the sizes of each trailing object array except the last one. This
7714 /// is required for TrailingObjects to work properly.
7715 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7716 return 3 * varlist_size();
7717 }
7718 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7719 return getUniqueDeclarationsNum();
7720 }
7721 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7723 }
7724
7725 /// Sets the list of references to private copies with initializers for new
7726 /// private variables.
7727 /// \param VL List of references.
7728 void setPrivateCopies(ArrayRef<Expr *> VL);
7729
7730 /// Gets the list of references to private copies with initializers for new
7731 /// private variables.
7732 MutableArrayRef<Expr *> getPrivateCopies() {
7733 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
7734 }
7735 ArrayRef<const Expr *> getPrivateCopies() const {
7737 }
7738
7739 /// Sets the list of references to initializer variables for new private
7740 /// variables.
7741 /// \param VL List of references.
7742 void setInits(ArrayRef<Expr *> VL);
7743
7744 /// Gets the list of references to initializer variables for new private
7745 /// variables.
7746 MutableArrayRef<Expr *> getInits() {
7747 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
7748 }
7749 ArrayRef<const Expr *> getInits() const {
7750 return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
7751 }
7752
7753public:
7754 /// Creates clause with a list of variables \a Vars.
7755 ///
7756 /// \param C AST context.
7757 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7758 /// StartLoc: starting location of the clause (the clause keyword); 2)
7759 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7760 /// \param Vars The original expression used in the clause.
7761 /// \param PrivateVars Expressions referring to private copies.
7762 /// \param Inits Expressions referring to private copy initializers.
7763 /// \param Declarations Declarations used in the clause.
7764 /// \param ComponentLists Component lists used in the clause.
7765 static OMPUseDevicePtrClause *
7766 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7767 ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
7768 ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
7769 MappableExprComponentListsRef ComponentLists);
7770
7771 /// Creates an empty clause with the place for \a NumVars variables.
7772 ///
7773 /// \param C AST context.
7774 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7775 /// NumVars: number of expressions listed in this clause; 2)
7776 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7777 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7778 /// NumComponents: total number of expression components in the clause.
7779 static OMPUseDevicePtrClause *
7780 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7781
7784 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
7786 llvm::iterator_range<private_copies_const_iterator>;
7787
7789 return private_copies_range(getPrivateCopies().begin(),
7790 getPrivateCopies().end());
7791 }
7792
7794 return private_copies_const_range(getPrivateCopies().begin(),
7795 getPrivateCopies().end());
7796 }
7797
7800 using inits_range = llvm::iterator_range<inits_iterator>;
7801 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
7802
7804 return inits_range(getInits().begin(), getInits().end());
7805 }
7806
7808 return inits_const_range(getInits().begin(), getInits().end());
7809 }
7810
7812 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7813 reinterpret_cast<Stmt **>(varlist_end()));
7814 }
7815
7817 auto Children = const_cast<OMPUseDevicePtrClause *>(this)->children();
7818 return const_child_range(Children.begin(), Children.end());
7819 }
7820
7823 }
7826 }
7827
7828 static bool classof(const OMPClause *T) {
7829 return T->getClauseKind() == llvm::omp::OMPC_use_device_ptr;
7830 }
7831};
7832
7833/// This represents clause 'use_device_addr' in the '#pragma omp ...'
7834/// directives.
7835///
7836/// \code
7837/// #pragma omp target data use_device_addr(a,b)
7838/// \endcode
7839/// In this example directive '#pragma omp target data' has clause
7840/// 'use_device_addr' with the variables 'a' and 'b'.
7842 : public OMPMappableExprListClause<OMPUseDeviceAddrClause>,
7843 private llvm::TrailingObjects<
7844 OMPUseDeviceAddrClause, Expr *, ValueDecl *, unsigned,
7845 OMPClauseMappableExprCommon::MappableComponent> {
7846 friend class OMPClauseReader;
7848 friend OMPVarListClause;
7849 friend TrailingObjects;
7850
7851 /// Build clause with number of variables \a NumVars.
7852 ///
7853 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7854 /// StartLoc: starting location of the clause (the clause keyword); 2)
7855 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7856 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7857 /// NumVars: number of expressions listed in this clause; 2)
7858 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7859 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7860 /// NumComponents: total number of expression components in the clause.
7861 explicit OMPUseDeviceAddrClause(const OMPVarListLocTy &Locs,
7862 const OMPMappableExprListSizeTy &Sizes)
7863 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr, Locs,
7864 Sizes) {}
7865
7866 /// Build an empty clause.
7867 ///
7868 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7869 /// NumVars: number of expressions listed in this clause; 2)
7870 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7871 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7872 /// NumComponents: total number of expression components in the clause.
7874 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr,
7875 OMPVarListLocTy(), Sizes) {}
7876
7877 /// Define the sizes of each trailing object array except the last one. This
7878 /// is required for TrailingObjects to work properly.
7879 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7880 return varlist_size();
7881 }
7882 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7883 return getUniqueDeclarationsNum();
7884 }
7885 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7887 }
7888
7889public:
7890 /// Creates clause with a list of variables \a Vars.
7891 ///
7892 /// \param C AST context.
7893 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7894 /// StartLoc: starting location of the clause (the clause keyword); 2)
7895 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7896 /// \param Vars The original expression used in the clause.
7897 /// \param Declarations Declarations used in the clause.
7898 /// \param ComponentLists Component lists used in the clause.
7899 static OMPUseDeviceAddrClause *
7900 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7901 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7902 MappableExprComponentListsRef ComponentLists);
7903
7904 /// Creates an empty clause with the place for \a NumVars variables.
7905 ///
7906 /// \param C AST context.
7907 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7908 /// NumVars: number of expressions listed in this clause; 2)
7909 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7910 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7911 /// NumComponents: total number of expression components in the clause.
7912 static OMPUseDeviceAddrClause *
7913 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7914
7916 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7917 reinterpret_cast<Stmt **>(varlist_end()));
7918 }
7919
7921 auto Children = const_cast<OMPUseDeviceAddrClause *>(this)->children();
7922 return const_child_range(Children.begin(), Children.end());
7923 }
7924
7927 }
7930 }
7931
7932 static bool classof(const OMPClause *T) {
7933 return T->getClauseKind() == llvm::omp::OMPC_use_device_addr;
7934 }
7935};
7936
7937/// This represents clause 'is_device_ptr' in the '#pragma omp ...'
7938/// directives.
7939///
7940/// \code
7941/// #pragma omp target is_device_ptr(a,b)
7942/// \endcode
7943/// In this example directive '#pragma omp target' has clause
7944/// 'is_device_ptr' with the variables 'a' and 'b'.
7946 : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
7947 private llvm::TrailingObjects<
7948 OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
7949 OMPClauseMappableExprCommon::MappableComponent> {
7950 friend class OMPClauseReader;
7952 friend OMPVarListClause;
7953 friend TrailingObjects;
7954
7955 /// Build clause with number of variables \a NumVars.
7956 ///
7957 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7958 /// StartLoc: starting location of the clause (the clause keyword); 2)
7959 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7960 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7961 /// NumVars: number of expressions listed in this clause; 2)
7962 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7963 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7964 /// NumComponents: total number of expression components in the clause.
7965 explicit OMPIsDevicePtrClause(const OMPVarListLocTy &Locs,
7966 const OMPMappableExprListSizeTy &Sizes)
7967 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr, Locs, Sizes) {}
7968
7969 /// Build an empty clause.
7970 ///
7971 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7972 /// NumVars: number of expressions listed in this clause; 2)
7973 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7974 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7975 /// NumComponents: total number of expression components in the clause.
7976 explicit OMPIsDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
7977 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr,
7978 OMPVarListLocTy(), Sizes) {}
7979
7980 /// Define the sizes of each trailing object array except the last one. This
7981 /// is required for TrailingObjects to work properly.
7982 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7983 return varlist_size();
7984 }
7985 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7986 return getUniqueDeclarationsNum();
7987 }
7988 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7990 }
7991
7992public:
7993 /// Creates clause with a list of variables \a Vars.
7994 ///
7995 /// \param C AST context.
7996 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7997 /// StartLoc: starting location of the clause (the clause keyword); 2)
7998 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7999 /// \param Vars The original expression used in the clause.
8000 /// \param Declarations Declarations used in the clause.
8001 /// \param ComponentLists Component lists used in the clause.
8002 static OMPIsDevicePtrClause *
8003 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8004 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8005 MappableExprComponentListsRef ComponentLists);
8006
8007 /// Creates an empty clause with the place for \a NumVars variables.
8008 ///
8009 /// \param C AST context.
8010 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8011 /// NumVars: number of expressions listed in this clause; 2)
8012 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8013 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8014 /// NumComponents: total number of expression components in the clause.
8015 static OMPIsDevicePtrClause *
8016 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8017
8019 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8020 reinterpret_cast<Stmt **>(varlist_end()));
8021 }
8022
8024 auto Children = const_cast<OMPIsDevicePtrClause *>(this)->children();
8025 return const_child_range(Children.begin(), Children.end());
8026 }
8027
8030 }
8033 }
8034
8035 static bool classof(const OMPClause *T) {
8036 return T->getClauseKind() == llvm::omp::OMPC_is_device_ptr;
8037 }
8038};
8039
8040/// This represents clause 'has_device_ptr' in the '#pragma omp ...'
8041/// directives.
8042///
8043/// \code
8044/// #pragma omp target has_device_addr(a,b)
8045/// \endcode
8046/// In this example directive '#pragma omp target' has clause
8047/// 'has_device_ptr' with the variables 'a' and 'b'.
8049 : public OMPMappableExprListClause<OMPHasDeviceAddrClause>,
8050 private llvm::TrailingObjects<
8051 OMPHasDeviceAddrClause, Expr *, ValueDecl *, unsigned,
8052 OMPClauseMappableExprCommon::MappableComponent> {
8053 friend class OMPClauseReader;
8055 friend OMPVarListClause;
8056 friend TrailingObjects;
8057
8058 /// Build clause with number of variables \a NumVars.
8059 ///
8060 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8061 /// StartLoc: starting location of the clause (the clause keyword); 2)
8062 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8063 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8064 /// NumVars: number of expressions listed in this clause; 2)
8065 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8066 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8067 /// NumComponents: total number of expression components in the clause.
8068 explicit OMPHasDeviceAddrClause(const OMPVarListLocTy &Locs,
8069 const OMPMappableExprListSizeTy &Sizes)
8070 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, Locs,
8071 Sizes) {}
8072
8073 /// Build an empty clause.
8074 ///
8075 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8076 /// NumVars: number of expressions listed in this clause; 2)
8077 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8078 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8079 /// NumComponents: total number of expression components in the clause.
8081 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr,
8082 OMPVarListLocTy(), Sizes) {}
8083
8084 /// Define the sizes of each trailing object array except the last one. This
8085 /// is required for TrailingObjects to work properly.
8086 size_t numTrailingObjects(OverloadToken<Expr *>) const {
8087 return varlist_size();
8088 }
8089 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
8090 return getUniqueDeclarationsNum();
8091 }
8092 size_t numTrailingObjects(OverloadToken<unsigned>) const {
8094 }
8095
8096public:
8097 /// Creates clause with a list of variables \a Vars.
8098 ///
8099 /// \param C AST context.
8100 /// \param Locs Locations needed to build a mappable clause. It includes 1)
8101 /// StartLoc: starting location of the clause (the clause keyword); 2)
8102 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
8103 /// \param Vars The original expression used in the clause.
8104 /// \param Declarations Declarations used in the clause.
8105 /// \param ComponentLists Component lists used in the clause.
8106 static OMPHasDeviceAddrClause *
8107 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
8108 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
8109 MappableExprComponentListsRef ComponentLists);
8110
8111 /// Creates an empty clause with the place for \a NumVars variables.
8112 ///
8113 /// \param C AST context.
8114 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
8115 /// NumVars: number of expressions listed in this clause; 2)
8116 /// NumUniqueDeclarations: number of unique base declarations in this clause;
8117 /// 3) NumComponentLists: number of component lists in this clause; and 4)
8118 /// NumComponents: total number of expression components in the clause.
8119 static OMPHasDeviceAddrClause *
8120 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
8121
8123 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8124 reinterpret_cast<Stmt **>(varlist_end()));
8125 }
8126
8128 auto Children = const_cast<OMPHasDeviceAddrClause *>(this)->children();
8129 return const_child_range(Children.begin(), Children.end());
8130 }
8131
8134 }
8137 }
8138
8139 static bool classof(const OMPClause *T) {
8140 return T->getClauseKind() == llvm::omp::OMPC_has_device_addr;
8141 }
8142};
8143
8144/// This represents clause 'nontemporal' in the '#pragma omp ...' directives.
8145///
8146/// \code
8147/// #pragma omp simd nontemporal(a)
8148/// \endcode
8149/// In this example directive '#pragma omp simd' has clause 'nontemporal' for
8150/// the variable 'a'.
8152 : public OMPVarListClause<OMPNontemporalClause>,
8153 private llvm::TrailingObjects<OMPNontemporalClause, Expr *> {
8154 friend class OMPClauseReader;
8155 friend OMPVarListClause;
8156 friend TrailingObjects;
8157
8158 /// Build clause with number of variables \a N.
8159 ///
8160 /// \param StartLoc Starting location of the clause.
8161 /// \param LParenLoc Location of '('.
8162 /// \param EndLoc Ending location of the clause.
8163 /// \param N Number of the variables in the clause.
8165 SourceLocation EndLoc, unsigned N)
8166 : OMPVarListClause<OMPNontemporalClause>(llvm::omp::OMPC_nontemporal,
8167 StartLoc, LParenLoc, EndLoc, N) {
8168 }
8169
8170 /// Build an empty clause.
8171 ///
8172 /// \param N Number of variables.
8173 explicit OMPNontemporalClause(unsigned N)
8175 llvm::omp::OMPC_nontemporal, SourceLocation(), SourceLocation(),
8176 SourceLocation(), N) {}
8177
8178 /// Get the list of privatied copies if the member expression was captured by
8179 /// one of the privatization clauses.
8180 MutableArrayRef<Expr *> getPrivateRefs() {
8181 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
8182 }
8183 ArrayRef<const Expr *> getPrivateRefs() const {
8185 }
8186
8187public:
8188 /// Creates clause with a list of variables \a VL.
8189 ///
8190 /// \param C AST context.
8191 /// \param StartLoc Starting location of the clause.
8192 /// \param LParenLoc Location of '('.
8193 /// \param EndLoc Ending location of the clause.
8194 /// \param VL List of references to the variables.
8195 static OMPNontemporalClause *
8196 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
8197 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8198
8199 /// Creates an empty clause with the place for \a N variables.
8200 ///
8201 /// \param C AST context.
8202 /// \param N The number of variables.
8203 static OMPNontemporalClause *CreateEmpty(const ASTContext &C, unsigned N);
8204
8205 /// Sets the list of references to private copies created in private clauses.
8206 /// \param VL List of references.
8207 void setPrivateRefs(ArrayRef<Expr *> VL);
8208
8210 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8211 reinterpret_cast<Stmt **>(varlist_end()));
8212 }
8213
8215 auto Children = const_cast<OMPNontemporalClause *>(this)->children();
8216 return const_child_range(Children.begin(), Children.end());
8217 }
8218
8220 return child_range(reinterpret_cast<Stmt **>(getPrivateRefs().begin()),
8221 reinterpret_cast<Stmt **>(getPrivateRefs().end()));
8222 }
8223
8225 auto Children = const_cast<OMPNontemporalClause *>(this)->private_refs();
8226 return const_child_range(Children.begin(), Children.end());
8227 }
8228
8231 }
8234 }
8235
8236 static bool classof(const OMPClause *T) {
8237 return T->getClauseKind() == llvm::omp::OMPC_nontemporal;
8238 }
8239};
8240
8241/// This represents 'order' clause in the '#pragma omp ...' directive.
8242///
8243/// \code
8244/// #pragma omp simd order(concurrent)
8245/// \endcode
8246/// In this example directive '#pragma omp parallel' has simple 'order'
8247/// clause with kind 'concurrent'.
8248class OMPOrderClause final : public OMPClause {
8249 friend class OMPClauseReader;
8250
8251 /// Location of '('.
8252 SourceLocation LParenLoc;
8253
8254 /// A kind of the 'order' clause.
8256
8257 /// Start location of the kind in source code.
8258 SourceLocation KindKwLoc;
8259
8260 /// A modifier for order clause
8262
8263 /// Start location of the modifier in source code.
8264 SourceLocation ModifierKwLoc;
8265
8266 /// Set kind of the clause.
8267 ///
8268 /// \param K Argument of clause.
8269 void setKind(OpenMPOrderClauseKind K) { Kind = K; }
8270
8271 /// Set argument location.
8272 ///
8273 /// \param KLoc Argument location.
8274 void setKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
8275
8276 /// Set modifier of the clause.
8277 ///
8278 /// \param M Argument of clause.
8279 void setModifier(OpenMPOrderClauseModifier M) { Modifier = M; }
8280
8281 /// Set modifier location.
8282 ///
8283 /// \param MLoc Modifier keyword location.
8284 void setModifierKwLoc(SourceLocation MLoc) { ModifierKwLoc = MLoc; }
8285
8286public:
8287 /// Build 'order' clause with argument \p A ('concurrent').
8288 ///
8289 /// \param A Argument of the clause ('concurrent').
8290 /// \param ALoc Starting location of the argument.
8291 /// \param StartLoc Starting location of the clause.
8292 /// \param LParenLoc Location of '('.
8293 /// \param EndLoc Ending location of the clause.
8294 /// \param Modifier The modifier applied to 'order' clause.
8295 /// \param MLoc Location of the modifier
8297 SourceLocation StartLoc, SourceLocation LParenLoc,
8299 SourceLocation MLoc)
8300 : OMPClause(llvm::omp::OMPC_order, StartLoc, EndLoc),
8301 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), Modifier(Modifier),
8302 ModifierKwLoc(MLoc) {}
8303
8304 /// Build an empty clause.
8306 : OMPClause(llvm::omp::OMPC_order, SourceLocation(), SourceLocation()) {}
8307
8308 /// Sets the location of '('.
8309 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8310
8311 /// Returns the location of '('.
8312 SourceLocation getLParenLoc() const { return LParenLoc; }
8313
8314 /// Returns kind of the clause.
8316
8317 /// Returns location of clause kind.
8318 SourceLocation getKindKwLoc() const { return KindKwLoc; }
8319
8320 /// Returns Modifier of the clause.
8321 OpenMPOrderClauseModifier getModifier() const { return Modifier; }
8322
8323 /// Returns location of clause modifier.
8324 SourceLocation getModifierKwLoc() const { return ModifierKwLoc; }
8325
8328 }
8329
8332 }
8333
8336 }
8339 }
8340
8341 static bool classof(const OMPClause *T) {
8342 return T->getClauseKind() == llvm::omp::OMPC_order;
8343 }
8344};
8345
8346/// This represents the 'init' clause in '#pragma omp ...' directives.
8347///
8348/// \code
8349/// #pragma omp interop init(target:obj)
8350/// \endcode
8351class OMPInitClause final
8352 : public OMPVarListClause<OMPInitClause>,
8353 private llvm::TrailingObjects<OMPInitClause, Expr *> {
8354 friend class OMPClauseReader;
8355 friend OMPVarListClause;
8356 friend TrailingObjects;
8357
8358 /// Location of interop variable.
8359 SourceLocation VarLoc;
8360
8361 bool IsTarget = false;
8362 bool IsTargetSync = false;
8363
8364 void setInteropVar(Expr *E) { varlist_begin()[0] = E; }
8365
8366 void setIsTarget(bool V) { IsTarget = V; }
8367
8368 void setIsTargetSync(bool V) { IsTargetSync = V; }
8369
8370 /// Sets the location of the interop variable.
8371 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8372
8373 /// Build 'init' clause.
8374 ///
8375 /// \param IsTarget Uses the 'target' interop-type.
8376 /// \param IsTargetSync Uses the 'targetsync' interop-type.
8377 /// \param StartLoc Starting location of the clause.
8378 /// \param LParenLoc Location of '('.
8379 /// \param VarLoc Location of the interop variable.
8380 /// \param EndLoc Ending location of the clause.
8381 /// \param N Number of expressions.
8382 OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc,
8383 SourceLocation LParenLoc, SourceLocation VarLoc,
8384 SourceLocation EndLoc, unsigned N)
8385 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc,
8386 LParenLoc, EndLoc, N),
8387 VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {}
8388
8389 /// Build an empty clause.
8390 OMPInitClause(unsigned N)
8391 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(),
8392 SourceLocation(), SourceLocation(), N) {
8393 }
8394
8395public:
8396 /// Creates a fully specified clause.
8397 ///
8398 /// \param C AST context.
8399 /// \param InteropVar The interop variable.
8400 /// \param InteropInfo The interop-type and prefer_type list.
8401 /// \param StartLoc Starting location of the clause.
8402 /// \param LParenLoc Location of '('.
8403 /// \param VarLoc Location of the interop variable.
8404 /// \param EndLoc Ending location of the clause.
8405 static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar,
8406 OMPInteropInfo &InteropInfo,
8407 SourceLocation StartLoc,
8408 SourceLocation LParenLoc, SourceLocation VarLoc,
8409 SourceLocation EndLoc);
8410
8411 /// Creates an empty clause with \a N expressions.
8412 ///
8413 /// \param C AST context.
8414 /// \param N Number of expression items.
8415 static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N);
8416
8417 /// Returns the location of the interop variable.
8418 SourceLocation getVarLoc() const { return VarLoc; }
8419
8420 /// Returns the interop variable.
8422 const Expr *getInteropVar() const { return varlist_begin()[0]; }
8423
8424 /// Returns true is interop-type 'target' is used.
8425 bool getIsTarget() const { return IsTarget; }
8426
8427 /// Returns true is interop-type 'targetsync' is used.
8428 bool getIsTargetSync() const { return IsTargetSync; }
8429
8431 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8432 reinterpret_cast<Stmt **>(varlist_end()));
8433 }
8434
8436 auto Children = const_cast<OMPInitClause *>(this)->children();
8437 return const_child_range(Children.begin(), Children.end());
8438 }
8439
8442 }
8445 }
8446
8449 using prefs_range = llvm::iterator_range<prefs_iterator>;
8450 using const_prefs_range = llvm::iterator_range<const_prefs_iterator>;
8451
8453 return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())),
8454 reinterpret_cast<Expr **>(varlist_end()));
8455 }
8456
8458 auto Prefs = const_cast<OMPInitClause *>(this)->prefs();
8459 return const_prefs_range(Prefs.begin(), Prefs.end());
8460 }
8461
8462 static bool classof(const OMPClause *T) {
8463 return T->getClauseKind() == llvm::omp::OMPC_init;
8464 }
8465};
8466
8467/// This represents the 'use' clause in '#pragma omp ...' directives.
8468///
8469/// \code
8470/// #pragma omp interop use(obj)
8471/// \endcode
8472class OMPUseClause final : public OMPClause {
8473 friend class OMPClauseReader;
8474
8475 /// Location of '('.
8476 SourceLocation LParenLoc;
8477
8478 /// Location of interop variable.
8479 SourceLocation VarLoc;
8480
8481 /// The interop variable.
8482 Stmt *InteropVar = nullptr;
8483
8484 /// Set the interop variable.
8485 void setInteropVar(Expr *E) { InteropVar = E; }
8486
8487 /// Sets the location of '('.
8488 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8489
8490 /// Sets the location of the interop variable.
8491 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8492
8493public:
8494 /// Build 'use' clause with and interop variable expression \a InteropVar.
8495 ///
8496 /// \param InteropVar The interop variable.
8497 /// \param StartLoc Starting location of the clause.
8498 /// \param LParenLoc Location of '('.
8499 /// \param VarLoc Location of the interop variable.
8500 /// \param EndLoc Ending location of the clause.
8501 OMPUseClause(Expr *InteropVar, SourceLocation StartLoc,
8502 SourceLocation LParenLoc, SourceLocation VarLoc,
8503 SourceLocation EndLoc)
8504 : OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc),
8505 VarLoc(VarLoc), InteropVar(InteropVar) {}
8506
8507 /// Build an empty clause.
8509 : OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {}
8510
8511 /// Returns the location of '('.
8512 SourceLocation getLParenLoc() const { return LParenLoc; }
8513
8514 /// Returns the location of the interop variable.
8515 SourceLocation getVarLoc() const { return VarLoc; }
8516
8517 /// Returns the interop variable.
8518 Expr *getInteropVar() const { return cast<Expr>(InteropVar); }
8519
8520 child_range children() { return child_range(&InteropVar, &InteropVar + 1); }
8521
8523 return const_child_range(&InteropVar, &InteropVar + 1);
8524 }
8525
8528 }
8531 }
8532
8533 static bool classof(const OMPClause *T) {
8534 return T->getClauseKind() == llvm::omp::OMPC_use;
8535 }
8536};
8537
8538/// This represents 'destroy' clause in the '#pragma omp depobj'
8539/// directive or the '#pragma omp interop' directive..
8540///
8541/// \code
8542/// #pragma omp depobj(a) destroy
8543/// #pragma omp interop destroy(obj)
8544/// \endcode
8545/// In these examples directive '#pragma omp depobj' and '#pragma omp interop'
8546/// have a 'destroy' clause. The 'interop' directive includes an object.
8547class OMPDestroyClause final : public OMPClause {
8548 friend class OMPClauseReader;
8549
8550 /// Location of '('.
8551 SourceLocation LParenLoc;
8552
8553 /// Location of interop variable.
8554 SourceLocation VarLoc;
8555
8556 /// The interop variable.
8557 Stmt *InteropVar = nullptr;
8558
8559 /// Set the interop variable.
8560 void setInteropVar(Expr *E) { InteropVar = E; }
8561
8562 /// Sets the location of '('.
8563 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8564
8565 /// Sets the location of the interop variable.
8566 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8567
8568public:
8569 /// Build 'destroy' clause with an interop variable expression \a InteropVar.
8570 ///
8571 /// \param InteropVar The interop variable.
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 OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc,
8577 SourceLocation LParenLoc, SourceLocation VarLoc,
8578 SourceLocation EndLoc)
8579 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc),
8580 LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {}
8581
8582 /// Build 'destroy' clause.
8583 ///
8584 /// \param StartLoc Starting location of the clause.
8585 /// \param EndLoc Ending location of the clause.
8587 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc) {}
8588
8589 /// Build an empty clause.
8591 : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) {
8592 }
8593
8594 /// Returns the location of '('.
8595 SourceLocation getLParenLoc() const { return LParenLoc; }
8596
8597 /// Returns the location of the interop variable.
8598 SourceLocation getVarLoc() const { return VarLoc; }
8599
8600 /// Returns the interop variable.
8601 Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); }
8602
8604 if (InteropVar)
8605 return child_range(&InteropVar, &InteropVar + 1);
8607 }
8608
8610 if (InteropVar)
8611 return const_child_range(&InteropVar, &InteropVar + 1);
8613 }
8614
8617 }
8620 }
8621
8622 static bool classof(const OMPClause *T) {
8623 return T->getClauseKind() == llvm::omp::OMPC_destroy;
8624 }
8625};
8626
8627/// This represents 'novariants' clause in the '#pragma omp ...' directive.
8628///
8629/// \code
8630/// #pragma omp dispatch novariants(a > 5)
8631/// \endcode
8632/// In this example directive '#pragma omp dispatch' has simple 'novariants'
8633/// clause with condition 'a > 5'.
8635 : public OMPOneStmtClause<llvm::omp::OMPC_novariants, OMPClause>,
8636 public OMPClauseWithPreInit {
8637 friend class OMPClauseReader;
8638
8639 /// Set condition.
8640 void setCondition(Expr *Cond) { setStmt(Cond); }
8641
8642public:
8643 /// Build 'novariants' clause with condition \a Cond.
8644 ///
8645 /// \param Cond Condition of the clause.
8646 /// \param HelperCond Helper condition for the construct.
8647 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8648 /// clause must be captured.
8649 /// \param StartLoc Starting location of the clause.
8650 /// \param LParenLoc Location of '('.
8651 /// \param EndLoc Ending location of the clause.
8652 OMPNovariantsClause(Expr *Cond, Stmt *HelperCond,
8653 OpenMPDirectiveKind CaptureRegion,
8654 SourceLocation StartLoc, SourceLocation LParenLoc,
8655 SourceLocation EndLoc)
8656 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8657 OMPClauseWithPreInit(this) {
8658 setPreInitStmt(HelperCond, CaptureRegion);
8659 }
8660
8661 /// Build an empty clause.
8663
8664 /// Returns condition.
8665 Expr *getCondition() const { return getStmtAs<Expr>(); }
8666
8669 auto Children = const_cast<OMPNovariantsClause *>(this)->used_children();
8670 return const_child_range(Children.begin(), Children.end());
8671 }
8672};
8673
8674/// This represents 'nocontext' clause in the '#pragma omp ...' directive.
8675///
8676/// \code
8677/// #pragma omp dispatch nocontext(a > 5)
8678/// \endcode
8679/// In this example directive '#pragma omp dispatch' has simple 'nocontext'
8680/// clause with condition 'a > 5'.
8682 : public OMPOneStmtClause<llvm::omp::OMPC_nocontext, OMPClause>,
8683 public OMPClauseWithPreInit {
8684 friend class OMPClauseReader;
8685
8686 /// Set condition.
8687 void setCondition(Expr *Cond) { setStmt(Cond); }
8688
8689public:
8690 /// Build 'nocontext' clause with condition \a Cond.
8691 ///
8692 /// \param Cond Condition of the clause.
8693 /// \param HelperCond Helper condition for the construct.
8694 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8695 /// clause must be captured.
8696 /// \param StartLoc Starting location of the clause.
8697 /// \param LParenLoc Location of '('.
8698 /// \param EndLoc Ending location of the clause.
8699 OMPNocontextClause(Expr *Cond, Stmt *HelperCond,
8700 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
8701 SourceLocation LParenLoc, SourceLocation EndLoc)
8702 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8703 OMPClauseWithPreInit(this) {
8704 setPreInitStmt(HelperCond, CaptureRegion);
8705 }
8706
8707 /// Build an empty clause.
8709
8710 /// Returns condition.
8711 Expr *getCondition() const { return getStmtAs<Expr>(); }
8712
8715 auto Children = const_cast<OMPNocontextClause *>(this)->used_children();
8716 return const_child_range(Children.begin(), Children.end());
8717 }
8718};
8719
8720/// This represents 'detach' clause in the '#pragma omp task' directive.
8721///
8722/// \code
8723/// #pragma omp task detach(evt)
8724/// \endcode
8725/// In this example directive '#pragma omp detach' has simple 'detach' clause
8726/// with the variable 'evt'.
8728 : public OMPOneStmtClause<llvm::omp::OMPC_detach, OMPClause> {
8729 friend class OMPClauseReader;
8730
8731 /// Set condition.
8732 void setEventHandler(Expr *E) { setStmt(E); }
8733
8734public:
8735 /// Build 'detach' clause with event-handler \a Evt.
8736 ///
8737 /// \param Evt Event handler expression.
8738 /// \param StartLoc Starting location of the clause.
8739 /// \param LParenLoc Location of '('.
8740 /// \param EndLoc Ending location of the clause.
8742 SourceLocation EndLoc)
8743 : OMPOneStmtClause(Evt, StartLoc, LParenLoc, EndLoc) {}
8744
8745 /// Build an empty clause.
8747
8748 /// Returns event-handler expression.
8749 Expr *getEventHandler() const { return getStmtAs<Expr>(); }
8750};
8751
8752/// This represents clause 'inclusive' in the '#pragma omp scan' directive.
8753///
8754/// \code
8755/// #pragma omp scan inclusive(a,b)
8756/// \endcode
8757/// In this example directive '#pragma omp scan' has clause 'inclusive'
8758/// with the variables 'a' and 'b'.
8760 : public OMPVarListClause<OMPInclusiveClause>,
8761 private llvm::TrailingObjects<OMPInclusiveClause, Expr *> {
8762 friend class OMPClauseReader;
8763 friend OMPVarListClause;
8764 friend TrailingObjects;
8765
8766 /// Build clause with number of variables \a N.
8767 ///
8768 /// \param StartLoc Starting location of the clause.
8769 /// \param LParenLoc Location of '('.
8770 /// \param EndLoc Ending location of the clause.
8771 /// \param N Number of the variables in the clause.
8773 SourceLocation EndLoc, unsigned N)
8774 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
8775 StartLoc, LParenLoc, EndLoc, N) {}
8776
8777 /// Build an empty clause.
8778 ///
8779 /// \param N Number of variables.
8780 explicit OMPInclusiveClause(unsigned N)
8781 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
8783 SourceLocation(), N) {}
8784
8785public:
8786 /// Creates clause with a list of variables \a VL.
8787 ///
8788 /// \param C AST context.
8789 /// \param StartLoc Starting location of the clause.
8790 /// \param LParenLoc Location of '('.
8791 /// \param EndLoc Ending location of the clause.
8792 /// \param VL List of references to the original variables.
8793 static OMPInclusiveClause *Create(const ASTContext &C,
8794 SourceLocation StartLoc,
8795 SourceLocation LParenLoc,
8796 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8797
8798 /// Creates an empty clause with the place for \a N variables.
8799 ///
8800 /// \param C AST context.
8801 /// \param N The number of variables.
8802 static OMPInclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
8803
8805 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8806 reinterpret_cast<Stmt **>(varlist_end()));
8807 }
8808
8810 auto Children = const_cast<OMPInclusiveClause *>(this)->children();
8811 return const_child_range(Children.begin(), Children.end());
8812 }
8813
8816 }
8819 }
8820
8821 static bool classof(const OMPClause *T) {
8822 return T->getClauseKind() == llvm::omp::OMPC_inclusive;
8823 }
8824};
8825
8826/// This represents clause 'exclusive' in the '#pragma omp scan' directive.
8827///
8828/// \code
8829/// #pragma omp scan exclusive(a,b)
8830/// \endcode
8831/// In this example directive '#pragma omp scan' has clause 'exclusive'
8832/// with the variables 'a' and 'b'.
8834 : public OMPVarListClause<OMPExclusiveClause>,
8835 private llvm::TrailingObjects<OMPExclusiveClause, Expr *> {
8836 friend class OMPClauseReader;
8837 friend OMPVarListClause;
8838 friend TrailingObjects;
8839
8840 /// Build clause with number of variables \a N.
8841 ///
8842 /// \param StartLoc Starting location of the clause.
8843 /// \param LParenLoc Location of '('.
8844 /// \param EndLoc Ending location of the clause.
8845 /// \param N Number of the variables in the clause.
8847 SourceLocation EndLoc, unsigned N)
8848 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
8849 StartLoc, LParenLoc, EndLoc, N) {}
8850
8851 /// Build an empty clause.
8852 ///
8853 /// \param N Number of variables.
8854 explicit OMPExclusiveClause(unsigned N)
8855 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
8857 SourceLocation(), N) {}
8858
8859public:
8860 /// Creates clause with a list of variables \a VL.
8861 ///
8862 /// \param C AST context.
8863 /// \param StartLoc Starting location of the clause.
8864 /// \param LParenLoc Location of '('.
8865 /// \param EndLoc Ending location of the clause.
8866 /// \param VL List of references to the original variables.
8867 static OMPExclusiveClause *Create(const ASTContext &C,
8868 SourceLocation StartLoc,
8869 SourceLocation LParenLoc,
8870 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8871
8872 /// Creates an empty clause with the place for \a N variables.
8873 ///
8874 /// \param C AST context.
8875 /// \param N The number of variables.
8876 static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
8877
8879 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8880 reinterpret_cast<Stmt **>(varlist_end()));
8881 }
8882
8884 auto Children = const_cast<OMPExclusiveClause *>(this)->children();
8885 return const_child_range(Children.begin(), Children.end());
8886 }
8887
8890 }
8893 }
8894
8895 static bool classof(const OMPClause *T) {
8896 return T->getClauseKind() == llvm::omp::OMPC_exclusive;
8897 }
8898};
8899
8900/// This represents clause 'uses_allocators' in the '#pragma omp target'-based
8901/// directives.
8902///
8903/// \code
8904/// #pragma omp target uses_allocators(default_allocator, my_allocator(traits))
8905/// \endcode
8906/// In this example directive '#pragma omp target' has clause 'uses_allocators'
8907/// with the allocators 'default_allocator' and user-defined 'my_allocator'.
8909 : public OMPClause,
8910 private llvm::TrailingObjects<OMPUsesAllocatorsClause, Expr *,
8911 SourceLocation> {
8912public:
8913 /// Data for list of allocators.
8914 struct Data {
8915 /// Allocator.
8916 Expr *Allocator = nullptr;
8917 /// Allocator traits.
8919 /// Locations of '(' and ')' symbols.
8921 };
8922
8923private:
8924 friend class OMPClauseReader;
8925 friend TrailingObjects;
8926
8927 enum class ExprOffsets {
8928 Allocator,
8929 AllocatorTraits,
8930 Total,
8931 };
8932
8933 enum class ParenLocsOffsets {
8934 LParen,
8935 RParen,
8936 Total,
8937 };
8938
8939 /// Location of '('.
8940 SourceLocation LParenLoc;
8941 /// Total number of allocators in the clause.
8942 unsigned NumOfAllocators = 0;
8943
8944 /// Build clause.
8945 ///
8946 /// \param StartLoc Starting location of the clause.
8947 /// \param LParenLoc Location of '('.
8948 /// \param EndLoc Ending location of the clause.
8949 /// \param N Number of allocators associated with the clause.
8950 OMPUsesAllocatorsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
8951 SourceLocation EndLoc, unsigned N)
8952 : OMPClause(llvm::omp::OMPC_uses_allocators, StartLoc, EndLoc),
8953 LParenLoc(LParenLoc), NumOfAllocators(N) {}
8954
8955 /// Build an empty clause.
8956 /// \param N Number of allocators associated with the clause.
8957 ///
8958 explicit OMPUsesAllocatorsClause(unsigned N)
8959 : OMPClause(llvm::omp::OMPC_uses_allocators, SourceLocation(),
8960 SourceLocation()),
8961 NumOfAllocators(N) {}
8962
8963 unsigned numTrailingObjects(OverloadToken<Expr *>) const {
8964 return NumOfAllocators * static_cast<int>(ExprOffsets::Total);
8965 }
8966
8967 /// Sets the location of '('.
8968 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8969
8970 /// Sets the allocators data for the clause.
8971 void setAllocatorsData(ArrayRef<OMPUsesAllocatorsClause::Data> Data);
8972
8973public:
8974 /// Creates clause with a list of allocators \p Data.
8975 ///
8976 /// \param C AST context.
8977 /// \param StartLoc Starting location of the clause.
8978 /// \param LParenLoc Location of '('.
8979 /// \param EndLoc Ending location of the clause.
8980 /// \param Data List of allocators.
8981 static OMPUsesAllocatorsClause *
8982 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
8983 SourceLocation EndLoc, ArrayRef<OMPUsesAllocatorsClause::Data> Data);
8984
8985 /// Creates an empty clause with the place for \p N allocators.
8986 ///
8987 /// \param C AST context.
8988 /// \param N The number of allocators.
8989 static OMPUsesAllocatorsClause *CreateEmpty(const ASTContext &C, unsigned N);
8990
8991 /// Returns the location of '('.
8992 SourceLocation getLParenLoc() const { return LParenLoc; }
8993
8994 /// Returns number of allocators associated with the clause.
8995 unsigned getNumberOfAllocators() const { return NumOfAllocators; }
8996
8997 /// Returns data for the specified allocator.
8999
9000 // Iterators
9002 Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
9003 return child_range(Begin, Begin + NumOfAllocators *
9004 static_cast<int>(ExprOffsets::Total));
9005 }
9007 Stmt *const *Begin =
9008 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
9009 return const_child_range(
9010 Begin, Begin + NumOfAllocators * static_cast<int>(ExprOffsets::Total));
9011 }
9012
9015 }
9018 }
9019
9020 static bool classof(const OMPClause *T) {
9021 return T->getClauseKind() == llvm::omp::OMPC_uses_allocators;
9022 }
9023};
9024
9025/// This represents clause 'affinity' in the '#pragma omp task'-based
9026/// directives.
9027///
9028/// \code
9029/// #pragma omp task affinity(iterator(i = 0:n) : ([3][n])a, b[:n], c[i])
9030/// \endcode
9031/// In this example directive '#pragma omp task' has clause 'affinity' with the
9032/// affinity modifer 'iterator(i = 0:n)' and locator items '([3][n])a', 'b[:n]'
9033/// and 'c[i]'.
9035 : public OMPVarListClause<OMPAffinityClause>,
9036 private llvm::TrailingObjects<OMPAffinityClause, Expr *> {
9037 friend class OMPClauseReader;
9038 friend OMPVarListClause;
9039 friend TrailingObjects;
9040
9041 /// Location of ':' symbol.
9042 SourceLocation ColonLoc;
9043
9044 /// Build clause.
9045 ///
9046 /// \param StartLoc Starting location of the clause.
9047 /// \param LParenLoc Location of '('.
9048 /// \param ColonLoc Location of ':'.
9049 /// \param EndLoc Ending location of the clause.
9050 /// \param N Number of locators associated with the clause.
9052 SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N)
9053 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, StartLoc,
9054 LParenLoc, EndLoc, N) {}
9055
9056 /// Build an empty clause.
9057 /// \param N Number of locators associated with the clause.
9058 ///
9059 explicit OMPAffinityClause(unsigned N)
9060 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity,
9062 SourceLocation(), N) {}
9063
9064 /// Sets the affinity modifier for the clause, if any.
9065 void setModifier(Expr *E) {
9066 getTrailingObjects<Expr *>()[varlist_size()] = E;
9067 }
9068
9069 /// Sets the location of ':' symbol.
9070 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
9071
9072public:
9073 /// Creates clause with a modifier a list of locator items.
9074 ///
9075 /// \param C AST context.
9076 /// \param StartLoc Starting location of the clause.
9077 /// \param LParenLoc Location of '('.
9078 /// \param ColonLoc Location of ':'.
9079 /// \param EndLoc Ending location of the clause.
9080 /// \param Locators List of locator items.
9081 static OMPAffinityClause *Create(const ASTContext &C, SourceLocation StartLoc,
9082 SourceLocation LParenLoc,
9083 SourceLocation ColonLoc,
9084 SourceLocation EndLoc, Expr *Modifier,
9085 ArrayRef<Expr *> Locators);
9086
9087 /// Creates an empty clause with the place for \p N locator items.
9088 ///
9089 /// \param C AST context.
9090 /// \param N The number of locator items.
9091 static OMPAffinityClause *CreateEmpty(const ASTContext &C, unsigned N);
9092
9093 /// Gets affinity modifier.
9094 Expr *getModifier() { return getTrailingObjects<Expr *>()[varlist_size()]; }
9096 return getTrailingObjects<Expr *>()[varlist_size()];
9097 }
9098
9099 /// Gets the location of ':' symbol.
9100 SourceLocation getColonLoc() const { return ColonLoc; }
9101
9102 // Iterators
9104 int Offset = getModifier() ? 1 : 0;
9105 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9106 reinterpret_cast<Stmt **>(varlist_end() + Offset));
9107 }
9108
9110 auto Children = const_cast<OMPAffinityClause *>(this)->children();
9111 return const_child_range(Children.begin(), Children.end());
9112 }
9113
9116 }
9119 }
9120
9121 static bool classof(const OMPClause *T) {
9122 return T->getClauseKind() == llvm::omp::OMPC_affinity;
9123 }
9124};
9125
9126/// This represents 'filter' clause in the '#pragma omp ...' directive.
9127///
9128/// \code
9129/// #pragma omp masked filter(tid)
9130/// \endcode
9131/// In this example directive '#pragma omp masked' has 'filter' clause with
9132/// thread id.
9134 : public OMPOneStmtClause<llvm::omp::OMPC_filter, OMPClause>,
9135 public OMPClauseWithPreInit {
9136 friend class OMPClauseReader;
9137
9138 /// Sets the thread identifier.
9139 void setThreadID(Expr *TID) { setStmt(TID); }
9140
9141public:
9142 /// Build 'filter' clause with thread-id \a ThreadID.
9143 ///
9144 /// \param ThreadID Thread identifier.
9145 /// \param HelperE Helper expression associated with this clause.
9146 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9147 /// clause must be captured.
9148 /// \param StartLoc Starting location of the clause.
9149 /// \param LParenLoc Location of '('.
9150 /// \param EndLoc Ending location of the clause.
9151 OMPFilterClause(Expr *ThreadID, Stmt *HelperE,
9152 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
9153 SourceLocation LParenLoc, SourceLocation EndLoc)
9154 : OMPOneStmtClause(ThreadID, StartLoc, LParenLoc, EndLoc),
9155 OMPClauseWithPreInit(this) {
9156 setPreInitStmt(HelperE, CaptureRegion);
9157 }
9158
9159 /// Build an empty clause.
9161
9162 /// Return thread identifier.
9163 Expr *getThreadID() const { return getStmtAs<Expr>(); }
9164
9165 /// Return thread identifier.
9166 Expr *getThreadID() { return getStmtAs<Expr>(); }
9167};
9168
9169/// This represents 'bind' clause in the '#pragma omp ...' directives.
9170///
9171/// \code
9172/// #pragma omp loop bind(parallel)
9173/// \endcode
9174class OMPBindClause final : public OMPNoChildClause<llvm::omp::OMPC_bind> {
9175 friend class OMPClauseReader;
9176
9177 /// Location of '('.
9178 SourceLocation LParenLoc;
9179
9180 /// The binding kind of 'bind' clause.
9182
9183 /// Start location of the kind in source code.
9184 SourceLocation KindLoc;
9185
9186 /// Sets the location of '('.
9187 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9188
9189 /// Set the binding kind.
9190 void setBindKind(OpenMPBindClauseKind K) { Kind = K; }
9191
9192 /// Set the binding kind location.
9193 void setBindKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
9194
9195 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9196 ///
9197 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9198 /// \param KLoc Starting location of the binding kind.
9199 /// \param StartLoc Starting location of the clause.
9200 /// \param LParenLoc Location of '('.
9201 /// \param EndLoc Ending location of the clause.
9202 OMPBindClause(OpenMPBindClauseKind K, SourceLocation KLoc,
9203 SourceLocation StartLoc, SourceLocation LParenLoc,
9204 SourceLocation EndLoc)
9205 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Kind(K),
9206 KindLoc(KLoc) {}
9207
9208 /// Build an empty clause.
9209 OMPBindClause() : OMPNoChildClause() {}
9210
9211public:
9212 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9213 ///
9214 /// \param C AST context
9215 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9216 /// \param KLoc Starting location of the binding kind.
9217 /// \param StartLoc Starting location of the clause.
9218 /// \param LParenLoc Location of '('.
9219 /// \param EndLoc Ending location of the clause.
9220 static OMPBindClause *Create(const ASTContext &C, OpenMPBindClauseKind K,
9221 SourceLocation KLoc, SourceLocation StartLoc,
9222 SourceLocation LParenLoc, SourceLocation EndLoc);
9223
9224 /// Build an empty 'bind' clause.
9225 ///
9226 /// \param C AST context
9227 static OMPBindClause *CreateEmpty(const ASTContext &C);
9228
9229 /// Returns the location of '('.
9230 SourceLocation getLParenLoc() const { return LParenLoc; }
9231
9232 /// Returns kind of the clause.
9234
9235 /// Returns location of clause kind.
9236 SourceLocation getBindKindLoc() const { return KindLoc; }
9237};
9238
9239/// This class implements a simple visitor for OMPClause
9240/// subclasses.
9241template<class ImplClass, template <typename> class Ptr, typename RetTy>
9243public:
9244#define PTR(CLASS) Ptr<CLASS>
9245#define DISPATCH(CLASS) \
9246 return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S))
9247
9248#define GEN_CLANG_CLAUSE_CLASS
9249#define CLAUSE_CLASS(Enum, Str, Class) \
9250 RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
9251#include "llvm/Frontend/OpenMP/OMP.inc"
9252
9253 RetTy Visit(PTR(OMPClause) S) {
9254 // Top switch clause: visit each OMPClause.
9255 switch (S->getClauseKind()) {
9256#define GEN_CLANG_CLAUSE_CLASS
9257#define CLAUSE_CLASS(Enum, Str, Class) \
9258 case llvm::omp::Clause::Enum: \
9259 return Visit##Class(static_cast<PTR(Class)>(S));
9260#define CLAUSE_NO_CLASS(Enum, Str) \
9261 case llvm::omp::Clause::Enum: \
9262 break;
9263#include "llvm/Frontend/OpenMP/OMP.inc"
9264 }
9265 }
9266 // Base case, ignore it. :)
9267 RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); }
9268#undef PTR
9269#undef DISPATCH
9270};
9271
9272template <typename T> using const_ptr = std::add_pointer_t<std::add_const_t<T>>;
9273
9274template <class ImplClass, typename RetTy = void>
9276 : public OMPClauseVisitorBase<ImplClass, std::add_pointer_t, RetTy> {};
9277template<class ImplClass, typename RetTy = void>
9279 public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {};
9280
9281class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
9282 raw_ostream &OS;
9283 const PrintingPolicy &Policy;
9284
9285 /// Process clauses with list of variables.
9286 template <typename T> void VisitOMPClauseList(T *Node, char StartSym);
9287 /// Process motion clauses.
9288 template <typename T> void VisitOMPMotionClause(T *Node);
9289
9290public:
9291 OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
9292 : OS(OS), Policy(Policy) {}
9293
9294#define GEN_CLANG_CLAUSE_CLASS
9295#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
9296#include "llvm/Frontend/OpenMP/OMP.inc"
9297};
9298
9300 llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
9301
9302 /// The raw string as we parsed it. This is needed for the `isa` trait set
9303 /// (which accepts anything) and (later) extensions.
9304 StringRef RawString;
9305};
9308 llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
9310};
9312 llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
9314};
9315
9316/// Helper data structure representing the traits in a match clause of an
9317/// `declare variant` or `metadirective`. The outer level is an ordered
9318/// collection of selector sets, each with an associated kind and an ordered
9319/// collection of selectors. A selector has a kind, an optional score/condition,
9320/// and an ordered collection of properties.
9322 /// Private constructor accesible only by ASTContext.
9323 OMPTraitInfo() {}
9324 friend class ASTContext;
9325
9326public:
9327 /// Reconstruct a (partial) OMPTraitInfo object from a mangled name.
9328 OMPTraitInfo(StringRef MangledName);
9329
9330 /// The outermost level of selector sets.
9332
9334 llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) {
9335 return llvm::any_of(Sets, [&](OMPTraitSet &Set) {
9336 return llvm::any_of(
9337 Set.Selectors, [&](OMPTraitSelector &Selector) {
9338 return Cond(Selector.ScoreOrCondition,
9339 /* IsScore */ Selector.Kind !=
9340 llvm::omp::TraitSelector::user_condition);
9341 });
9342 });
9343 }
9344
9345 /// Create a variant match info object from this trait info object. While the
9346 /// former is a flat representation the actual main difference is that the
9347 /// latter uses clang::Expr to store the score/condition while the former is
9348 /// independent of clang. Thus, expressions and conditions are evaluated in
9349 /// this method.
9350 void getAsVariantMatchInfo(ASTContext &ASTCtx,
9351 llvm::omp::VariantMatchInfo &VMI) const;
9352
9353 /// Return a string representation identifying this context selector.
9354 std::string getMangledName() const;
9355
9356 /// Check the extension trait \p TP is active.
9357 bool isExtensionActive(llvm::omp::TraitProperty TP) {
9358 for (const OMPTraitSet &Set : Sets) {
9359 if (Set.Kind != llvm::omp::TraitSet::implementation)
9360 continue;
9361 for (const OMPTraitSelector &Selector : Set.Selectors) {
9362 if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
9363 continue;
9364 for (const OMPTraitProperty &Property : Selector.Properties) {
9365 if (Property.Kind == TP)
9366 return true;
9367 }
9368 }
9369 }
9370 return false;
9371 }
9372
9373 /// Print a human readable representation into \p OS.
9374 void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
9375};
9376llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
9377llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
9378
9379/// Clang specific specialization of the OMPContext to lookup target features.
9382 std::function<void(StringRef)> &&DiagUnknownTrait,
9383 const FunctionDecl *CurrentFunctionDecl,
9384 ArrayRef<llvm::omp::TraitProperty> ConstructTraits);
9385
9386 virtual ~TargetOMPContext() = default;
9387
9388 /// See llvm::omp::OMPContext::matchesISATrait
9389 bool matchesISATrait(StringRef RawString) const override;
9390
9391private:
9392 std::function<bool(StringRef)> FeatureValidityCheck;
9393 std::function<void(StringRef)> DiagUnknownTrait;
9394 llvm::StringMap<bool> FeatureMap;
9395};
9396
9397/// Contains data for OpenMP directives: clauses, children
9398/// expressions/statements (helpers for codegen) and associated statement, if
9399/// any.
9400class OMPChildren final
9401 : private llvm::TrailingObjects<OMPChildren, OMPClause *, Stmt *> {
9402 friend TrailingObjects;
9403 friend class OMPClauseReader;
9405 template <typename T> friend class OMPDeclarativeDirective;
9406
9407 /// Numbers of clauses.
9408 unsigned NumClauses = 0;
9409 /// Number of child expressions/stmts.
9410 unsigned NumChildren = 0;
9411 /// true if the directive has associated statement.
9412 bool HasAssociatedStmt = false;
9413
9414 /// Define the sizes of each trailing object array except the last one. This
9415 /// is required for TrailingObjects to work properly.
9416 size_t numTrailingObjects(OverloadToken<OMPClause *>) const {
9417 return NumClauses;
9418 }
9419
9420 OMPChildren() = delete;
9421
9422 OMPChildren(unsigned NumClauses, unsigned NumChildren, bool HasAssociatedStmt)
9423 : NumClauses(NumClauses), NumChildren(NumChildren),
9424 HasAssociatedStmt(HasAssociatedStmt) {}
9425
9426 static size_t size(unsigned NumClauses, bool HasAssociatedStmt,
9427 unsigned NumChildren);
9428
9429 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses);
9430 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses, Stmt *S,
9431 unsigned NumChildren = 0);
9432 static OMPChildren *CreateEmpty(void *Mem, unsigned NumClauses,
9433 bool HasAssociatedStmt = false,
9434 unsigned NumChildren = 0);
9435
9436public:
9437 unsigned getNumClauses() const { return NumClauses; }
9438 unsigned getNumChildren() const { return NumChildren; }
9439 bool hasAssociatedStmt() const { return HasAssociatedStmt; }
9440
9441 /// Set associated statement.
9443 getTrailingObjects<Stmt *>()[NumChildren] = S;
9444 }
9445
9447
9448 /// Sets the list of variables for this clause.
9449 ///
9450 /// \param Clauses The list of clauses for the directive.
9451 ///
9452 void setClauses(ArrayRef<OMPClause *> Clauses);
9453
9454 /// Returns statement associated with the directive.
9455 const Stmt *getAssociatedStmt() const {
9456 return const_cast<OMPChildren *>(this)->getAssociatedStmt();
9457 }
9459 assert(HasAssociatedStmt &&
9460 "Expected directive with the associated statement.");
9461 return getTrailingObjects<Stmt *>()[NumChildren];
9462 }
9463
9464 /// Get the clauses storage.
9466 return llvm::MutableArrayRef(getTrailingObjects<OMPClause *>(),
9467 NumClauses);
9468 }
9470 return const_cast<OMPChildren *>(this)->getClauses();
9471 }
9472
9473 /// Returns the captured statement associated with the
9474 /// component region within the (combined) directive.
9475 ///
9476 /// \param RegionKind Component region kind.
9477 const CapturedStmt *
9479 ArrayRef<OpenMPDirectiveKind> CaptureRegions) const {
9480 assert(llvm::is_contained(CaptureRegions, RegionKind) &&
9481 "RegionKind not found in OpenMP CaptureRegions.");
9482 auto *CS = cast<CapturedStmt>(getAssociatedStmt());
9483 for (auto ThisCaptureRegion : CaptureRegions) {
9484 if (ThisCaptureRegion == RegionKind)
9485 return CS;
9486 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9487 }
9488 llvm_unreachable("Incorrect RegionKind specified for directive.");
9489 }
9490
9491 /// Get innermost captured statement for the construct.
9492 CapturedStmt *
9494 assert(hasAssociatedStmt() && "Must have associated captured statement.");
9495 assert(!CaptureRegions.empty() &&
9496 "At least one captured statement must be provided.");
9497 auto *CS = cast<CapturedStmt>(getAssociatedStmt());
9498 for (unsigned Level = CaptureRegions.size(); Level > 1; --Level)
9499 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9500 return CS;
9501 }
9502
9503 const CapturedStmt *
9505 return const_cast<OMPChildren *>(this)->getInnermostCapturedStmt(
9506 CaptureRegions);
9507 }
9508
9511 return const_cast<OMPChildren *>(this)->getChildren();
9512 }
9513
9515 assert(HasAssociatedStmt &&
9516 "Expected directive with the associated statement.");
9517 if (auto *CS = dyn_cast<CapturedStmt>(getAssociatedStmt())) {
9518 Stmt *S = nullptr;
9519 do {
9520 S = CS->getCapturedStmt();
9521 CS = dyn_cast<CapturedStmt>(S);
9522 } while (CS);
9523 return S;
9524 }
9525 return getAssociatedStmt();
9526 }
9527 const Stmt *getRawStmt() const {
9528 return const_cast<OMPChildren *>(this)->getRawStmt();
9529 }
9530
9532 if (!HasAssociatedStmt)
9534 return Stmt::child_range(&getTrailingObjects<Stmt *>()[NumChildren],
9535 &getTrailingObjects<Stmt *>()[NumChildren + 1]);
9536 }
9537};
9538
9539/// This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...'
9540/// directive.
9541///
9542/// \code
9543/// #pragma omp target [...] ompx_dyn_cgroup_mem(N)
9544/// \endcode
9546 : public OMPOneStmtClause<llvm::omp::OMPC_ompx_dyn_cgroup_mem, OMPClause>,
9547 public OMPClauseWithPreInit {
9548 friend class OMPClauseReader;
9549
9550 /// Set size.
9551 void setSize(Expr *E) { setStmt(E); }
9552
9553public:
9554 /// Build 'ompx_dyn_cgroup_mem' clause.
9555 ///
9556 /// \param Size Size expression.
9557 /// \param HelperSize Helper Size expression
9558 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9559 /// \param StartLoc Starting location of the clause.
9560 /// \param LParenLoc Location of '('.
9561 /// \param EndLoc Ending location of the clause.
9563 OpenMPDirectiveKind CaptureRegion,
9564 SourceLocation StartLoc, SourceLocation LParenLoc,
9565 SourceLocation EndLoc)
9566 : OMPOneStmtClause(Size, StartLoc, LParenLoc, EndLoc),
9567 OMPClauseWithPreInit(this) {
9568 setPreInitStmt(HelperSize, CaptureRegion);
9569 }
9570
9571 /// Build an empty clause.
9573
9574 /// Return the size expression.
9575 Expr *getSize() { return getStmtAs<Expr>(); }
9576
9577 /// Return the size expression.
9578 Expr *getSize() const { return getStmtAs<Expr>(); }
9579};
9580
9581/// This represents the 'doacross' clause for the '#pragma omp ordered'
9582/// directive.
9583///
9584/// \code
9585/// #pragma omp ordered doacross(sink: i-1, j-1)
9586/// \endcode
9587/// In this example directive '#pragma omp ordered' with clause 'doacross' with
9588/// a dependence-type 'sink' and loop-iteration vector expressions i-1 and j-1.
9590 : public OMPVarListClause<OMPDoacrossClause>,
9591 private llvm::TrailingObjects<OMPDoacrossClause, Expr *> {
9592 friend class OMPClauseReader;
9593 friend OMPVarListClause;
9594 friend TrailingObjects;
9595
9596 /// Dependence type (sink or source).
9598
9599 /// Dependence type location.
9600 SourceLocation DepLoc;
9601
9602 /// Colon location.
9603 SourceLocation ColonLoc;
9604
9605 /// Number of loops, associated with the doacross clause.
9606 unsigned NumLoops = 0;
9607
9608 /// Build clause with number of expressions \a N.
9609 ///
9610 /// \param StartLoc Starting location of the clause.
9611 /// \param LParenLoc Location of '('.
9612 /// \param EndLoc Ending location of the clause.
9613 /// \param N Number of expressions in the clause.
9614 /// \param NumLoops Number of loops associated with the clause.
9616 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
9617 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross, StartLoc,
9618 LParenLoc, EndLoc, N),
9619 NumLoops(NumLoops) {}
9620
9621 /// Build an empty clause.
9622 ///
9623 /// \param N Number of expressions in the clause.
9624 /// \param NumLoops Number of loops associated with the clause.
9625 explicit OMPDoacrossClause(unsigned N, unsigned NumLoops)
9626 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross,
9628 SourceLocation(), N),
9629 NumLoops(NumLoops) {}
9630
9631 /// Set dependence type.
9632 void setDependenceType(OpenMPDoacrossClauseModifier M) { DepType = M; }
9633
9634 /// Set dependence type location.
9635 void setDependenceLoc(SourceLocation Loc) { DepLoc = Loc; }
9636
9637 /// Set colon location.
9638 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
9639
9640public:
9641 /// Creates clause with a list of expressions \a VL.
9642 ///
9643 /// \param C AST context.
9644 /// \param StartLoc Starting location of the clause.
9645 /// \param LParenLoc Location of '('.
9646 /// \param EndLoc Ending location of the clause.
9647 /// \param DepType The dependence type.
9648 /// \param DepLoc Location of the dependence type.
9649 /// \param ColonLoc Location of ':'.
9650 /// \param VL List of references to the expressions.
9651 /// \param NumLoops Number of loops that associated with the clause.
9652 static OMPDoacrossClause *
9653 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
9654 SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType,
9655 SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
9656 unsigned NumLoops);
9657
9658 /// Creates an empty clause with \a N expressions.
9659 ///
9660 /// \param C AST context.
9661 /// \param N The number of expressions.
9662 /// \param NumLoops Number of loops that is associated with this clause.
9663 static OMPDoacrossClause *CreateEmpty(const ASTContext &C, unsigned N,
9664 unsigned NumLoops);
9665
9666 /// Get dependence type.
9668
9669 /// Get dependence type location.
9670 SourceLocation getDependenceLoc() const { return DepLoc; }
9671
9672 /// Get colon location.
9673 SourceLocation getColonLoc() const { return ColonLoc; }
9674
9675 /// Get number of loops associated with the clause.
9676 unsigned getNumLoops() const { return NumLoops; }
9677
9678 /// Set the loop data.
9679 void setLoopData(unsigned NumLoop, Expr *Cnt);
9680
9681 /// Get the loop data.
9682 Expr *getLoopData(unsigned NumLoop);
9683 const Expr *getLoopData(unsigned NumLoop) const;
9684
9686 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9687 reinterpret_cast<Stmt **>(varlist_end()));
9688 }
9689
9691 auto Children = const_cast<OMPDoacrossClause *>(this)->children();
9692 return const_child_range(Children.begin(), Children.end());
9693 }
9694
9697 }
9700 }
9701
9702 static bool classof(const OMPClause *T) {
9703 return T->getClauseKind() == llvm::omp::OMPC_doacross;
9704 }
9705};
9706
9707/// This represents 'ompx_attribute' clause in a directive that might generate
9708/// an outlined function. An example is given below.
9709///
9710/// \code
9711/// #pragma omp target [...] ompx_attribute(flatten)
9712/// \endcode
9714 : public OMPNoChildClause<llvm::omp::OMPC_ompx_attribute> {
9715 friend class OMPClauseReader;
9716
9717 /// Location of '('.
9718 SourceLocation LParenLoc;
9719
9720 /// The parsed attributes (clause arguments)
9722
9723public:
9724 /// Build 'ompx_attribute' clause.
9725 ///
9726 /// \param Attrs The parsed attributes (clause arguments)
9727 /// \param StartLoc Starting location of the clause.
9728 /// \param LParenLoc Location of '('.
9729 /// \param EndLoc Ending location of the clause.
9731 SourceLocation LParenLoc, SourceLocation EndLoc)
9732 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Attrs(Attrs) {
9733 }
9734
9735 /// Build an empty clause.
9737
9738 /// Sets the location of '('.
9739 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9740
9741 /// Returns the location of '('.
9742 SourceLocation getLParenLoc() const { return LParenLoc; }
9743
9744 /// Returned the attributes parsed from this clause.
9745 ArrayRef<const Attr *> getAttrs() const { return Attrs; }
9746
9747private:
9748 /// Replace the attributes with \p NewAttrs.
9749 void setAttrs(ArrayRef<Attr *> NewAttrs) {
9750 Attrs.clear();
9751 Attrs.append(NewAttrs.begin(), NewAttrs.end());
9752 }
9753};
9754
9755/// This represents 'ompx_bare' clause in the '#pragma omp target teams ...'
9756/// directive.
9757///
9758/// \code
9759/// #pragma omp target teams ompx_bare
9760/// \endcode
9761/// In this example directive '#pragma omp target teams' has a 'ompx_bare'
9762/// clause.
9763class OMPXBareClause : public OMPNoChildClause<llvm::omp::OMPC_ompx_bare> {
9764public:
9765 /// Build 'ompx_bare' clause.
9766 ///
9767 /// \param StartLoc Starting location of the clause.
9768 /// \param EndLoc Ending location of the clause.
9770 : OMPNoChildClause(StartLoc, EndLoc) {}
9771
9772 /// Build an empty clause.
9773 OMPXBareClause() = default;
9774};
9775
9776} // namespace clang
9777
9778#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
#define V(N, I)
Definition: ASTContext.h:3443
Forward declaration of all AST node types.
MatchType Type
DynTypedNode Node
#define PTR(CLASS)
Definition: AttrVisitor.h:27
const Decl * D
Expr * E
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
int Priority
Definition: Format.cpp:3036
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:759
Defines the clang::SourceLocation class and associated facilities.
const char * Data
SourceLocation Begin
#define bool
Definition: amdgpuintrin.h:20
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:3784
This represents one expression.
Definition: Expr.h:110
Represents a function declaration or definition.
Definition: Decl.h:1935
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:448
Expr * getAlignment() const
Returns alignment.
Definition: OpenMPClause.h:480
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:493
const_child_range children() const
Definition: OpenMPClause.h:588
SourceLocation getAllocatorModifierLoc() const
Return the location of the modifier.
Definition: OpenMPClause.h:573
const_child_range used_children() const
Definition: OpenMPClause.h:596
OpenMPAllocateClauseModifier getAllocatorModifier() const
Return 'allocate' modifier.
Definition: OpenMPClause.h:566
SourceLocation getColonLoc() const
Returns the location of the ':' delimiter.
Definition: OpenMPClause.h:571
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
Definition: OpenMPClause.h:563
child_range used_children()
Definition: OpenMPClause.h:593
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:600
This represents 'allocator' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:414
OMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'allocator' clause with the given allocator.
Definition: OpenMPClause.h:427
OMPAllocatorClause()
Build an empty clause.
Definition: OpenMPClause.h:432
Expr * getAllocator() const
Returns allocator.
Definition: OpenMPClause.h:435
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)
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:347
MutableArrayRef< OpenMPDirectiveKind > getDirectiveKinds()
Definition: OpenMPClause.h:384
void setDirectiveKinds(ArrayRef< OpenMPDirectiveKind > DK)
Definition: OpenMPClause.h:391
SourceLocation getLParenLoc()
Definition: OpenMPClause.h:400
const_child_range children() const
Definition: OpenMPClause.h:373
unsigned NumKinds
Number of directive kinds listed in the clause.
Definition: OpenMPClause.h:353
void setLParenLoc(SourceLocation S)
Definition: OpenMPClause.h:402
const_child_range used_children() const
Definition: OpenMPClause.h:380
OMPDirectiveListClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, unsigned NumKinds)
Build a clause with NumKinds directive kinds.
Definition: OpenMPClause.h:363
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:715
child_range used_children()
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:743
OMPFinalClause(Expr *Cond, Stmt *HelperCond, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'final' clause with condition Cond.
Definition: OpenMPClause.h:731
OMPFinalClause()
Build an empty clause.
Definition: OpenMPClause.h:740
const_child_range used_children() const
Definition: OpenMPClause.h:746
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:612
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:672
const_child_range used_children() const
Definition: OpenMPClause.h:696
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:675
SourceLocation getColonLoc() const
Return the location of ':'.
Definition: OpenMPClause.h:678
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:701
child_range used_children()
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:681
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Definition: OpenMPClause.h:684
OMPIfClause()
Build an empty clause.
Definition: OpenMPClause.h:667
child_range children()
Definition: OpenMPClause.h:689
const_child_range children() const
Definition: OpenMPClause.h:691
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:655
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
Definition: OpenMPClause.h:687
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 'message' clause in the '#pragma omp error' directive.
SourceLocation getLParenLoc() const
Returns the locaiton of '('.
Expr * getMessageString() const
Returns message string of the clause.
OMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'message' clause with message string argument.
static bool classof(const OMPClause *T)
const_child_range children() const
child_range used_children()
OMPMessageClause()
Build an empty clause.
const_child_range used_children() const
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_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:761
OMPNumThreadsClause()
Build an empty clause.
Definition: OpenMPClause.h:787
OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'num_threads' clause with condition NumThreads.
Definition: OpenMPClause.h:777
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:790
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.
Definition: OpenMPClause.h:968
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.
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
helper_expr_const_range privates() const
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)
helper_expr_const_range copy_array_elems() const
helper_expr_const_range copy_ops() 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.
helper_expr_range reduction_ops()
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:806
OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'safelen' clause.
Definition: OpenMPClause.h:818
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:826
OMPSafelenClause()
Build an empty clause.
Definition: OpenMPClause.h:823
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 '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 'severity' clause in the '#pragma omp error' directive.
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:841
OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'simdlen' clause.
Definition: OpenMPClause.h:853
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:861
OMPSimdlenClause()
Build an empty clause.
Definition: OpenMPClause.h:858
This represents the 'sizes' clause in the '#pragma omp tile' directive.
Definition: OpenMPClause.h:873
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:910
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:907
child_range children()
Definition: OpenMPClause.h:935
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:953
const_child_range used_children() const
Definition: OpenMPClause.h:949
void setSizesRefs(ArrayRef< Expr * > VL)
Sets the tile size expressions.
Definition: OpenMPClause.h:928
unsigned getNumSizes() const
Returns the number of list items.
Definition: OpenMPClause.h:913
child_range used_children()
Definition: OpenMPClause.h:946
MutableArrayRef< Expr * > getSizesRefs()
Returns the tile size expressions.
Definition: OpenMPClause.h:916
ArrayRef< Expr * > getSizesRefs() const
Definition: OpenMPClause.h:921
const_child_range children() const
Definition: OpenMPClause.h:940
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:322
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:332
ArrayRef< const Expr * > getVarRefs() const
Fetches list of all variables in the clause.
Definition: OpenMPClause.h:338
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:319
varlist_const_iterator varlist_end() const
Definition: OpenMPClause.h:329
varlist_iterator varlist_end()
Definition: OpenMPClause.h:327
llvm::iterator_range< varlist_const_iterator > varlist_const_range
Definition: OpenMPClause.h:314
MutableArrayRef< Expr * >::iterator varlist_iterator
Definition: OpenMPClause.h:311
varlist_iterator varlist_begin()
Definition: OpenMPClause.h:326
ArrayRef< const Expr * >::iterator varlist_const_iterator
Definition: OpenMPClause.h:312
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:335
bool varlist_empty() const
Definition: OpenMPClause.h:317
unsigned varlist_size() const
Definition: OpenMPClause.h:316
varlist_const_iterator varlist_begin() const
Definition: OpenMPClause.h:328
llvm::iterator_range< varlist_iterator > varlist_range
Definition: OpenMPClause.h:313
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:84
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1469
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:671
The JSON file list parser is used to communicate input to InstallAPI.
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
@ 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:220
@ OMPC_DOACROSS_unknown
Definition: OpenMPKinds.h:223
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:201
@ OMPC_BIND_unknown
Definition: OpenMPKinds.h:204
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:207
@ OMPC_GRAINSIZE_unknown
Definition: OpenMPKinds.h:210
OpenMPNumTasksClauseModifier
Definition: OpenMPKinds.h:213
@ OMPC_NUMTASKS_unknown
Definition: OpenMPKinds.h:216
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:227
@ OMPC_ALLOCATE_unknown
Definition: OpenMPKinds.h:230
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition: OpenMPKinds.h:63
const FunctionProtoType * T
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:325
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
#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
llvm::SmallVector< OMPTraitProperty, 1 > Properties
llvm::omp::TraitSet Kind
llvm::SmallVector< OMPTraitSelector, 2 > Selectors
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