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'.
491 : public OMPVarListClause<OMPAllocateClause>,
492 private llvm::TrailingObjects<OMPAllocateClause, Expr *> {
493 friend class OMPClauseReader;
494 friend OMPVarListClause;
495 friend TrailingObjects;
496
497 /// Allocator specified in the clause, or 'nullptr' if the default one is
498 /// used.
499 Expr *Allocator = nullptr;
500 /// Position of the ':' delimiter in the clause;
501 SourceLocation ColonLoc;
502
503 /// Build clause with number of variables \a N.
504 ///
505 /// \param StartLoc Starting location of the clause.
506 /// \param LParenLoc Location of '('.
507 /// \param Allocator Allocator expression.
508 /// \param ColonLoc Location of ':' delimiter.
509 /// \param EndLoc Ending location of the clause.
510 /// \param N Number of the variables in the clause.
512 Expr *Allocator, SourceLocation ColonLoc,
513 SourceLocation EndLoc, unsigned N)
514 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate, StartLoc,
515 LParenLoc, EndLoc, N),
516 Allocator(Allocator), ColonLoc(ColonLoc) {}
517
518 /// Build an empty clause.
519 ///
520 /// \param N Number of variables.
521 explicit OMPAllocateClause(unsigned N)
522 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate,
524 SourceLocation(), N) {}
525
526 /// Sets location of ':' symbol in clause.
527 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
528
529 void setAllocator(Expr *A) { Allocator = A; }
530
531public:
532 /// Creates clause with a list of variables \a VL.
533 ///
534 /// \param C AST context.
535 /// \param StartLoc Starting location of the clause.
536 /// \param LParenLoc Location of '('.
537 /// \param Allocator Allocator expression.
538 /// \param ColonLoc Location of ':' delimiter.
539 /// \param EndLoc Ending location of the clause.
540 /// \param VL List of references to the variables.
541 static OMPAllocateClause *Create(const ASTContext &C, SourceLocation StartLoc,
542 SourceLocation LParenLoc, Expr *Allocator,
543 SourceLocation ColonLoc,
544 SourceLocation EndLoc, ArrayRef<Expr *> VL);
545
546 /// Returns the allocator expression or nullptr, if no allocator is specified.
547 Expr *getAllocator() const { return Allocator; }
548
549 /// Returns the location of the ':' delimiter.
550 SourceLocation getColonLoc() const { return ColonLoc; }
551
552 /// Creates an empty clause with the place for \a N variables.
553 ///
554 /// \param C AST context.
555 /// \param N The number of variables.
556 static OMPAllocateClause *CreateEmpty(const ASTContext &C, unsigned N);
557
559 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
560 reinterpret_cast<Stmt **>(varlist_end()));
561 }
562
564 auto Children = const_cast<OMPAllocateClause *>(this)->children();
565 return const_child_range(Children.begin(), Children.end());
566 }
567
570 }
573 }
574
575 static bool classof(const OMPClause *T) {
576 return T->getClauseKind() == llvm::omp::OMPC_allocate;
577 }
578};
579
580/// This represents 'if' clause in the '#pragma omp ...' directive.
581///
582/// \code
583/// #pragma omp parallel if(parallel:a > 5)
584/// \endcode
585/// In this example directive '#pragma omp parallel' has simple 'if' clause with
586/// condition 'a > 5' and directive name modifier 'parallel'.
588 friend class OMPClauseReader;
589
590 /// Location of '('.
591 SourceLocation LParenLoc;
592
593 /// Condition of the 'if' clause.
594 Stmt *Condition = nullptr;
595
596 /// Location of ':' (if any).
597 SourceLocation ColonLoc;
598
599 /// Directive name modifier for the clause.
600 OpenMPDirectiveKind NameModifier = llvm::omp::OMPD_unknown;
601
602 /// Name modifier location.
603 SourceLocation NameModifierLoc;
604
605 /// Set condition.
606 void setCondition(Expr *Cond) { Condition = Cond; }
607
608 /// Set directive name modifier for the clause.
609 void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
610
611 /// Set location of directive name modifier for the clause.
612 void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
613
614 /// Set location of ':'.
615 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
616
617public:
618 /// Build 'if' clause with condition \a Cond.
619 ///
620 /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
621 /// \param Cond Condition of the clause.
622 /// \param HelperCond Helper condition for the clause.
623 /// \param CaptureRegion Innermost OpenMP region where expressions in this
624 /// clause must be captured.
625 /// \param StartLoc Starting location of the clause.
626 /// \param LParenLoc Location of '('.
627 /// \param NameModifierLoc Location of directive name modifier.
628 /// \param ColonLoc [OpenMP 4.1] Location of ':'.
629 /// \param EndLoc Ending location of the clause.
630 OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond,
631 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
632 SourceLocation LParenLoc, SourceLocation NameModifierLoc,
633 SourceLocation ColonLoc, SourceLocation EndLoc)
634 : OMPClause(llvm::omp::OMPC_if, StartLoc, EndLoc),
635 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond),
636 ColonLoc(ColonLoc), NameModifier(NameModifier),
637 NameModifierLoc(NameModifierLoc) {
638 setPreInitStmt(HelperCond, CaptureRegion);
639 }
640
641 /// Build an empty clause.
643 : OMPClause(llvm::omp::OMPC_if, SourceLocation(), SourceLocation()),
644 OMPClauseWithPreInit(this) {}
645
646 /// Sets the location of '('.
647 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
648
649 /// Returns the location of '('.
650 SourceLocation getLParenLoc() const { return LParenLoc; }
651
652 /// Return the location of ':'.
653 SourceLocation getColonLoc() const { return ColonLoc; }
654
655 /// Returns condition.
656 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
657
658 /// Return directive name modifier associated with the clause.
659 OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
660
661 /// Return the location of directive name modifier.
662 SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
663
665
668 }
669
672 auto Children = const_cast<OMPIfClause *>(this)->used_children();
673 return const_child_range(Children.begin(), Children.end());
674 }
675
676 static bool classof(const OMPClause *T) {
677 return T->getClauseKind() == llvm::omp::OMPC_if;
678 }
679};
680
681/// This represents 'final' clause in the '#pragma omp ...' directive.
682///
683/// \code
684/// #pragma omp task final(a > 5)
685/// \endcode
686/// In this example directive '#pragma omp task' has simple 'final'
687/// clause with condition 'a > 5'.
688class OMPFinalClause final
689 : public OMPOneStmtClause<llvm::omp::OMPC_final, OMPClause>,
690 public OMPClauseWithPreInit {
691 friend class OMPClauseReader;
692
693 /// Set condition.
694 void setCondition(Expr *Cond) { setStmt(Cond); }
695
696public:
697 /// Build 'final' clause with condition \a Cond.
698 ///
699 /// \param Cond Condition of the clause.
700 /// \param HelperCond Helper condition for the construct.
701 /// \param CaptureRegion Innermost OpenMP region where expressions in this
702 /// clause must be captured.
703 /// \param StartLoc Starting location of the clause.
704 /// \param LParenLoc Location of '('.
705 /// \param EndLoc Ending location of the clause.
706 OMPFinalClause(Expr *Cond, Stmt *HelperCond,
707 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
708 SourceLocation LParenLoc, SourceLocation EndLoc)
709 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
711 setPreInitStmt(HelperCond, CaptureRegion);
712 }
713
714 /// Build an empty clause.
716
717 /// Returns condition.
718 Expr *getCondition() const { return getStmtAs<Expr>(); }
719
722 auto Children = const_cast<OMPFinalClause *>(this)->used_children();
723 return const_child_range(Children.begin(), Children.end());
724 }
725};
726/// This represents 'num_threads' clause in the '#pragma omp ...'
727/// directive.
728///
729/// \code
730/// #pragma omp parallel num_threads(6)
731/// \endcode
732/// In this example directive '#pragma omp parallel' has simple 'num_threads'
733/// clause with number of threads '6'.
735 : public OMPOneStmtClause<llvm::omp::OMPC_num_threads, OMPClause>,
736 public OMPClauseWithPreInit {
737 friend class OMPClauseReader;
738
739 /// Set condition.
740 void setNumThreads(Expr *NThreads) { setStmt(NThreads); }
741
742public:
743 /// Build 'num_threads' clause with condition \a NumThreads.
744 ///
745 /// \param NumThreads Number of threads for the construct.
746 /// \param HelperNumThreads Helper Number of threads for the construct.
747 /// \param CaptureRegion Innermost OpenMP region where expressions in this
748 /// clause must be captured.
749 /// \param StartLoc Starting location of the clause.
750 /// \param LParenLoc Location of '('.
751 /// \param EndLoc Ending location of the clause.
752 OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads,
753 OpenMPDirectiveKind CaptureRegion,
754 SourceLocation StartLoc, SourceLocation LParenLoc,
755 SourceLocation EndLoc)
756 : OMPOneStmtClause(NumThreads, StartLoc, LParenLoc, EndLoc),
758 setPreInitStmt(HelperNumThreads, CaptureRegion);
759 }
760
761 /// Build an empty clause.
763
764 /// Returns number of threads.
765 Expr *getNumThreads() const { return getStmtAs<Expr>(); }
766};
767
768/// This represents 'safelen' clause in the '#pragma omp ...'
769/// directive.
770///
771/// \code
772/// #pragma omp simd safelen(4)
773/// \endcode
774/// In this example directive '#pragma omp simd' has clause 'safelen'
775/// with single expression '4'.
776/// If the safelen clause is used then no two iterations executed
777/// concurrently with SIMD instructions can have a greater distance
778/// in the logical iteration space than its value. The parameter of
779/// the safelen clause must be a constant positive integer expression.
781 : public OMPOneStmtClause<llvm::omp::OMPC_safelen, OMPClause> {
782 friend class OMPClauseReader;
783
784 /// Set safelen.
785 void setSafelen(Expr *Len) { setStmt(Len); }
786
787public:
788 /// Build 'safelen' clause.
789 ///
790 /// \param Len Expression associated with this clause.
791 /// \param StartLoc Starting location of the clause.
792 /// \param EndLoc Ending location of the clause.
794 SourceLocation EndLoc)
795 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
796
797 /// Build an empty clause.
799
800 /// Return safe iteration space distance.
801 Expr *getSafelen() const { return getStmtAs<Expr>(); }
802};
803
804/// This represents 'simdlen' clause in the '#pragma omp ...'
805/// directive.
806///
807/// \code
808/// #pragma omp simd simdlen(4)
809/// \endcode
810/// In this example directive '#pragma omp simd' has clause 'simdlen'
811/// with single expression '4'.
812/// If the 'simdlen' clause is used then it specifies the preferred number of
813/// iterations to be executed concurrently. The parameter of the 'simdlen'
814/// clause must be a constant positive integer expression.
816 : public OMPOneStmtClause<llvm::omp::OMPC_simdlen, OMPClause> {
817 friend class OMPClauseReader;
818
819 /// Set simdlen.
820 void setSimdlen(Expr *Len) { setStmt(Len); }
821
822public:
823 /// Build 'simdlen' clause.
824 ///
825 /// \param Len Expression associated with this clause.
826 /// \param StartLoc Starting location of the clause.
827 /// \param EndLoc Ending location of the clause.
829 SourceLocation EndLoc)
830 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
831
832 /// Build an empty clause.
834
835 /// Return safe iteration space distance.
836 Expr *getSimdlen() const { return getStmtAs<Expr>(); }
837};
838
839/// This represents the 'sizes' clause in the '#pragma omp tile' directive.
840///
841/// \code
842/// #pragma omp tile sizes(5,5)
843/// for (int i = 0; i < 64; ++i)
844/// for (int j = 0; j < 64; ++j)
845/// \endcode
846class OMPSizesClause final
847 : public OMPClause,
848 private llvm::TrailingObjects<OMPSizesClause, Expr *> {
849 friend class OMPClauseReader;
850 friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
851
852 /// Location of '('.
853 SourceLocation LParenLoc;
854
855 /// Number of tile sizes in the clause.
856 unsigned NumSizes;
857
858 /// Build an empty clause.
859 explicit OMPSizesClause(int NumSizes)
860 : OMPClause(llvm::omp::OMPC_sizes, SourceLocation(), SourceLocation()),
861 NumSizes(NumSizes) {}
862
863public:
864 /// Build a 'sizes' AST node.
865 ///
866 /// \param C Context of the AST.
867 /// \param StartLoc Location of the 'sizes' identifier.
868 /// \param LParenLoc Location of '('.
869 /// \param EndLoc Location of ')'.
870 /// \param Sizes Content of the clause.
871 static OMPSizesClause *Create(const ASTContext &C, SourceLocation StartLoc,
872 SourceLocation LParenLoc, SourceLocation EndLoc,
873 ArrayRef<Expr *> Sizes);
874
875 /// Build an empty 'sizes' AST node for deserialization.
876 ///
877 /// \param C Context of the AST.
878 /// \param NumSizes Number of items in the clause.
879 static OMPSizesClause *CreateEmpty(const ASTContext &C, unsigned NumSizes);
880
881 /// Sets the location of '('.
882 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
883
884 /// Returns the location of '('.
885 SourceLocation getLParenLoc() const { return LParenLoc; }
886
887 /// Returns the number of list items.
888 unsigned getNumSizes() const { return NumSizes; }
889
890 /// Returns the tile size expressions.
892 return MutableArrayRef<Expr *>(static_cast<OMPSizesClause *>(this)
893 ->template getTrailingObjects<Expr *>(),
894 NumSizes);
895 }
897 return ArrayRef<Expr *>(static_cast<const OMPSizesClause *>(this)
898 ->template getTrailingObjects<Expr *>(),
899 NumSizes);
900 }
901
902 /// Sets the tile size expressions.
904 assert(VL.size() == NumSizes);
905 std::copy(VL.begin(), VL.end(),
906 static_cast<OMPSizesClause *>(this)
907 ->template getTrailingObjects<Expr *>());
908 }
909
912 return child_range(reinterpret_cast<Stmt **>(Sizes.begin()),
913 reinterpret_cast<Stmt **>(Sizes.end()));
914 }
917 return const_child_range(reinterpret_cast<Stmt *const *>(Sizes.begin()),
918 reinterpret_cast<Stmt *const *>(Sizes.end()));
919 }
920
923 }
926 }
927
928 static bool classof(const OMPClause *T) {
929 return T->getClauseKind() == llvm::omp::OMPC_sizes;
930 }
931};
932
933/// Representation of the 'full' clause of the '#pragma omp unroll' directive.
934///
935/// \code
936/// #pragma omp unroll full
937/// for (int i = 0; i < 64; ++i)
938/// \endcode
939class OMPFullClause final : public OMPNoChildClause<llvm::omp::OMPC_full> {
940 friend class OMPClauseReader;
941
942 /// Build an empty clause.
943 explicit OMPFullClause() : OMPNoChildClause() {}
944
945public:
946 /// Build an AST node for a 'full' clause.
947 ///
948 /// \param C Context of the AST.
949 /// \param StartLoc Starting location of the clause.
950 /// \param EndLoc Ending location of the clause.
951 static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc,
952 SourceLocation EndLoc);
953
954 /// Build an empty 'full' AST node for deserialization.
955 ///
956 /// \param C Context of the AST.
957 static OMPFullClause *CreateEmpty(const ASTContext &C);
958};
959
960/// Representation of the 'partial' clause of the '#pragma omp unroll'
961/// directive.
962///
963/// \code
964/// #pragma omp unroll partial(4)
965/// for (int i = start; i < end; ++i)
966/// \endcode
967class OMPPartialClause final : public OMPClause {
968 friend class OMPClauseReader;
969
970 /// Location of '('.
971 SourceLocation LParenLoc;
972
973 /// Optional argument to the clause (unroll factor).
974 Stmt *Factor;
975
976 /// Build an empty clause.
977 explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {}
978
979 /// Set the unroll factor.
980 void setFactor(Expr *E) { Factor = E; }
981
982 /// Sets the location of '('.
983 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
984
985public:
986 /// Build an AST node for a 'partial' clause.
987 ///
988 /// \param C Context of the AST.
989 /// \param StartLoc Location of the 'partial' identifier.
990 /// \param LParenLoc Location of '('.
991 /// \param EndLoc Location of ')'.
992 /// \param Factor Clause argument.
993 static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc,
994 SourceLocation LParenLoc,
995 SourceLocation EndLoc, Expr *Factor);
996
997 /// Build an empty 'partial' AST node for deserialization.
998 ///
999 /// \param C Context of the AST.
1000 static OMPPartialClause *CreateEmpty(const ASTContext &C);
1001
1002 /// Returns the location of '('.
1003 SourceLocation getLParenLoc() const { return LParenLoc; }
1004
1005 /// Returns the argument of the clause or nullptr if not set.
1006 Expr *getFactor() const { return cast_or_null<Expr>(Factor); }
1007
1008 child_range children() { return child_range(&Factor, &Factor + 1); }
1010 return const_child_range(&Factor, &Factor + 1);
1011 }
1012
1015 }
1018 }
1019
1020 static bool classof(const OMPClause *T) {
1021 return T->getClauseKind() == llvm::omp::OMPC_partial;
1022 }
1023};
1024
1025/// This represents 'collapse' clause in the '#pragma omp ...'
1026/// directive.
1027///
1028/// \code
1029/// #pragma omp simd collapse(3)
1030/// \endcode
1031/// In this example directive '#pragma omp simd' has clause 'collapse'
1032/// with single expression '3'.
1033/// The parameter must be a constant positive integer expression, it specifies
1034/// the number of nested loops that should be collapsed into a single iteration
1035/// space.
1037 : public OMPOneStmtClause<llvm::omp::OMPC_collapse, OMPClause> {
1038 friend class OMPClauseReader;
1039
1040 /// Set the number of associated for-loops.
1041 void setNumForLoops(Expr *Num) { setStmt(Num); }
1042
1043public:
1044 /// Build 'collapse' clause.
1045 ///
1046 /// \param Num Expression associated with this clause.
1047 /// \param StartLoc Starting location of the clause.
1048 /// \param LParenLoc Location of '('.
1049 /// \param EndLoc Ending location of the clause.
1051 SourceLocation LParenLoc, SourceLocation EndLoc)
1052 : OMPOneStmtClause(Num, StartLoc, LParenLoc, EndLoc) {}
1053
1054 /// Build an empty clause.
1056
1057 /// Return the number of associated for-loops.
1058 Expr *getNumForLoops() const { return getStmtAs<Expr>(); }
1059};
1060
1061/// This represents 'default' clause in the '#pragma omp ...' directive.
1062///
1063/// \code
1064/// #pragma omp parallel default(shared)
1065/// \endcode
1066/// In this example directive '#pragma omp parallel' has simple 'default'
1067/// clause with kind 'shared'.
1069 friend class OMPClauseReader;
1070
1071 /// Location of '('.
1072 SourceLocation LParenLoc;
1073
1074 /// A kind of the 'default' clause.
1075 llvm::omp::DefaultKind Kind = llvm::omp::OMP_DEFAULT_unknown;
1076
1077 /// Start location of the kind in source code.
1078 SourceLocation KindKwLoc;
1079
1080 /// Set kind of the clauses.
1081 ///
1082 /// \param K Argument of clause.
1083 void setDefaultKind(llvm::omp::DefaultKind K) { Kind = K; }
1084
1085 /// Set argument location.
1086 ///
1087 /// \param KLoc Argument location.
1088 void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1089
1090public:
1091 /// Build 'default' clause with argument \a A ('none' or 'shared').
1092 ///
1093 /// \param A Argument of the clause ('none' or 'shared').
1094 /// \param ALoc Starting location of the argument.
1095 /// \param StartLoc Starting location of the clause.
1096 /// \param LParenLoc Location of '('.
1097 /// \param EndLoc Ending location of the clause.
1098 OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc,
1099 SourceLocation StartLoc, SourceLocation LParenLoc,
1100 SourceLocation EndLoc)
1101 : OMPClause(llvm::omp::OMPC_default, StartLoc, EndLoc),
1102 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1103
1104 /// Build an empty clause.
1106 : OMPClause(llvm::omp::OMPC_default, SourceLocation(), SourceLocation()) {
1107 }
1108
1109 /// Sets the location of '('.
1110 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1111
1112 /// Returns the location of '('.
1113 SourceLocation getLParenLoc() const { return LParenLoc; }
1114
1115 /// Returns kind of the clause.
1116 llvm::omp::DefaultKind getDefaultKind() const { return Kind; }
1117
1118 /// Returns location of clause kind.
1119 SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
1120
1123 }
1124
1127 }
1128
1131 }
1134 }
1135
1136 static bool classof(const OMPClause *T) {
1137 return T->getClauseKind() == llvm::omp::OMPC_default;
1138 }
1139};
1140
1141/// This represents 'proc_bind' clause in the '#pragma omp ...'
1142/// directive.
1143///
1144/// \code
1145/// #pragma omp parallel proc_bind(master)
1146/// \endcode
1147/// In this example directive '#pragma omp parallel' has simple 'proc_bind'
1148/// clause with kind 'master'.
1150 friend class OMPClauseReader;
1151
1152 /// Location of '('.
1153 SourceLocation LParenLoc;
1154
1155 /// A kind of the 'proc_bind' clause.
1156 llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown;
1157
1158 /// Start location of the kind in source code.
1159 SourceLocation KindKwLoc;
1160
1161 /// Set kind of the clause.
1162 ///
1163 /// \param K Kind of clause.
1164 void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; }
1165
1166 /// Set clause kind location.
1167 ///
1168 /// \param KLoc Kind location.
1169 void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1170
1171public:
1172 /// Build 'proc_bind' clause with argument \a A ('master', 'close' or
1173 /// 'spread').
1174 ///
1175 /// \param A Argument of the clause ('master', 'close' or 'spread').
1176 /// \param ALoc Starting location of the argument.
1177 /// \param StartLoc Starting location of the clause.
1178 /// \param LParenLoc Location of '('.
1179 /// \param EndLoc Ending location of the clause.
1180 OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc,
1181 SourceLocation StartLoc, SourceLocation LParenLoc,
1182 SourceLocation EndLoc)
1183 : OMPClause(llvm::omp::OMPC_proc_bind, StartLoc, EndLoc),
1184 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1185
1186 /// Build an empty clause.
1188 : OMPClause(llvm::omp::OMPC_proc_bind, SourceLocation(),
1189 SourceLocation()) {}
1190
1191 /// Sets the location of '('.
1192 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1193
1194 /// Returns the location of '('.
1195 SourceLocation getLParenLoc() const { return LParenLoc; }
1196
1197 /// Returns kind of the clause.
1198 llvm::omp::ProcBindKind getProcBindKind() const { return Kind; }
1199
1200 /// Returns location of clause kind.
1201 SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
1202
1205 }
1206
1209 }
1210
1213 }
1216 }
1217
1218 static bool classof(const OMPClause *T) {
1219 return T->getClauseKind() == llvm::omp::OMPC_proc_bind;
1220 }
1221};
1222
1223/// This represents 'unified_address' clause in the '#pragma omp requires'
1224/// directive.
1225///
1226/// \code
1227/// #pragma omp requires unified_address
1228/// \endcode
1229/// In this example directive '#pragma omp requires' has 'unified_address'
1230/// clause.
1232 : public OMPNoChildClause<llvm::omp::OMPC_unified_address> {
1233public:
1234 friend class OMPClauseReader;
1235 /// Build 'unified_address' clause.
1236 ///
1237 /// \param StartLoc Starting location of the clause.
1238 /// \param EndLoc Ending location of the clause.
1240 : OMPNoChildClause(StartLoc, EndLoc) {}
1241
1242 /// Build an empty clause.
1244};
1245
1246/// This represents 'unified_shared_memory' clause in the '#pragma omp requires'
1247/// directive.
1248///
1249/// \code
1250/// #pragma omp requires unified_shared_memory
1251/// \endcode
1252/// In this example directive '#pragma omp requires' has 'unified_shared_memory'
1253/// clause.
1255public:
1256 friend class OMPClauseReader;
1257 /// Build 'unified_shared_memory' clause.
1258 ///
1259 /// \param StartLoc Starting location of the clause.
1260 /// \param EndLoc Ending location of the clause.
1262 : OMPClause(llvm::omp::OMPC_unified_shared_memory, StartLoc, EndLoc) {}
1263
1264 /// Build an empty clause.
1266 : OMPClause(llvm::omp::OMPC_unified_shared_memory, SourceLocation(),
1267 SourceLocation()) {}
1268
1271 }
1272
1275 }
1276
1279 }
1282 }
1283
1284 static bool classof(const OMPClause *T) {
1285 return T->getClauseKind() == llvm::omp::OMPC_unified_shared_memory;
1286 }
1287};
1288
1289/// This represents 'reverse_offload' clause in the '#pragma omp requires'
1290/// directive.
1291///
1292/// \code
1293/// #pragma omp requires reverse_offload
1294/// \endcode
1295/// In this example directive '#pragma omp requires' has 'reverse_offload'
1296/// clause.
1298public:
1299 friend class OMPClauseReader;
1300 /// Build 'reverse_offload' clause.
1301 ///
1302 /// \param StartLoc Starting location of the clause.
1303 /// \param EndLoc Ending location of the clause.
1305 : OMPClause(llvm::omp::OMPC_reverse_offload, StartLoc, EndLoc) {}
1306
1307 /// Build an empty clause.
1309 : OMPClause(llvm::omp::OMPC_reverse_offload, SourceLocation(),
1310 SourceLocation()) {}
1311
1314 }
1315
1318 }
1319
1322 }
1325 }
1326
1327 static bool classof(const OMPClause *T) {
1328 return T->getClauseKind() == llvm::omp::OMPC_reverse_offload;
1329 }
1330};
1331
1332/// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
1333/// directive.
1334///
1335/// \code
1336/// #pragma omp requires dynamic_allocators
1337/// \endcode
1338/// In this example directive '#pragma omp requires' has 'dynamic_allocators'
1339/// clause.
1341public:
1342 friend class OMPClauseReader;
1343 /// Build 'dynamic_allocators' clause.
1344 ///
1345 /// \param StartLoc Starting location of the clause.
1346 /// \param EndLoc Ending location of the clause.
1348 : OMPClause(llvm::omp::OMPC_dynamic_allocators, StartLoc, EndLoc) {}
1349
1350 /// Build an empty clause.
1352 : OMPClause(llvm::omp::OMPC_dynamic_allocators, SourceLocation(),
1353 SourceLocation()) {}
1354
1357 }
1358
1361 }
1362
1365 }
1368 }
1369
1370 static bool classof(const OMPClause *T) {
1371 return T->getClauseKind() == llvm::omp::OMPC_dynamic_allocators;
1372 }
1373};
1374
1375/// This represents 'atomic_default_mem_order' clause in the '#pragma omp
1376/// requires' directive.
1377///
1378/// \code
1379/// #pragma omp requires atomic_default_mem_order(seq_cst)
1380/// \endcode
1381/// In this example directive '#pragma omp requires' has simple
1382/// atomic_default_mem_order' clause with kind 'seq_cst'.
1384 friend class OMPClauseReader;
1385
1386 /// Location of '('
1387 SourceLocation LParenLoc;
1388
1389 /// A kind of the 'atomic_default_mem_order' clause.
1392
1393 /// Start location of the kind in source code.
1394 SourceLocation KindKwLoc;
1395
1396 /// Set kind of the clause.
1397 ///
1398 /// \param K Kind of clause.
1399 void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) {
1400 Kind = K;
1401 }
1402
1403 /// Set clause kind location.
1404 ///
1405 /// \param KLoc Kind location.
1406 void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) {
1407 KindKwLoc = KLoc;
1408 }
1409
1410public:
1411 /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst',
1412 /// 'acq_rel' or 'relaxed').
1413 ///
1414 /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed').
1415 /// \param ALoc Starting location of the argument.
1416 /// \param StartLoc Starting location of the clause.
1417 /// \param LParenLoc Location of '('.
1418 /// \param EndLoc Ending location of the clause.
1420 SourceLocation ALoc, SourceLocation StartLoc,
1421 SourceLocation LParenLoc,
1422 SourceLocation EndLoc)
1423 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, StartLoc, EndLoc),
1424 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1425
1426 /// Build an empty clause.
1428 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, SourceLocation(),
1429 SourceLocation()) {}
1430
1431 /// Sets the location of '('.
1432 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1433
1434 /// Returns the locaiton of '('.
1435 SourceLocation getLParenLoc() const { return LParenLoc; }
1436
1437 /// Returns kind of the clause.
1439 return Kind;
1440 }
1441
1442 /// Returns location of clause kind.
1444
1447 }
1448
1451 }
1452
1455 }
1458 }
1459
1460 static bool classof(const OMPClause *T) {
1461 return T->getClauseKind() == llvm::omp::OMPC_atomic_default_mem_order;
1462 }
1463};
1464
1465/// This represents 'at' clause in the '#pragma omp error' directive
1466///
1467/// \code
1468/// #pragma omp error at(compilation)
1469/// \endcode
1470/// In this example directive '#pragma omp error' has simple
1471/// 'at' clause with kind 'complilation'.
1472class OMPAtClause final : public OMPClause {
1473 friend class OMPClauseReader;
1474
1475 /// Location of '('
1476 SourceLocation LParenLoc;
1477
1478 /// A kind of the 'at' clause.
1480
1481 /// Start location of the kind in source code.
1482 SourceLocation KindKwLoc;
1483
1484 /// Set kind of the clause.
1485 ///
1486 /// \param K Kind of clause.
1487 void setAtKind(OpenMPAtClauseKind K) { Kind = K; }
1488
1489 /// Set clause kind location.
1490 ///
1491 /// \param KLoc Kind location.
1492 void setAtKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1493
1494 /// Sets the location of '('.
1495 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1496
1497public:
1498 /// Build 'at' clause with argument \a A ('compilation' or 'execution').
1499 ///
1500 /// \param A Argument of the clause ('compilation' or 'execution').
1501 /// \param ALoc Starting location of the argument.
1502 /// \param StartLoc Starting location of the clause.
1503 /// \param LParenLoc Location of '('.
1504 /// \param EndLoc Ending location of the clause.
1506 SourceLocation StartLoc, SourceLocation LParenLoc,
1507 SourceLocation EndLoc)
1508 : OMPClause(llvm::omp::OMPC_at, StartLoc, EndLoc), LParenLoc(LParenLoc),
1509 Kind(A), KindKwLoc(ALoc) {}
1510
1511 /// Build an empty clause.
1513 : OMPClause(llvm::omp::OMPC_at, SourceLocation(), SourceLocation()) {}
1514
1515 /// Returns the locaiton of '('.
1516 SourceLocation getLParenLoc() const { return LParenLoc; }
1517
1518 /// Returns kind of the clause.
1520
1521 /// Returns location of clause kind.
1522 SourceLocation getAtKindKwLoc() const { return KindKwLoc; }
1523
1526 }
1527
1530 }
1531
1534 }
1537 }
1538
1539 static bool classof(const OMPClause *T) {
1540 return T->getClauseKind() == llvm::omp::OMPC_at;
1541 }
1542};
1543
1544/// This represents 'severity' clause in the '#pragma omp error' directive
1545///
1546/// \code
1547/// #pragma omp error severity(fatal)
1548/// \endcode
1549/// In this example directive '#pragma omp error' has simple
1550/// 'severity' clause with kind 'fatal'.
1551class OMPSeverityClause final : public OMPClause {
1552 friend class OMPClauseReader;
1553
1554 /// Location of '('
1555 SourceLocation LParenLoc;
1556
1557 /// A kind of the 'severity' clause.
1559
1560 /// Start location of the kind in source code.
1561 SourceLocation KindKwLoc;
1562
1563 /// Set kind of the clause.
1564 ///
1565 /// \param K Kind of clause.
1566 void setSeverityKind(OpenMPSeverityClauseKind K) { Kind = K; }
1567
1568 /// Set clause kind location.
1569 ///
1570 /// \param KLoc Kind location.
1571 void setSeverityKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1572
1573 /// Sets the location of '('.
1574 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1575
1576public:
1577 /// Build 'severity' clause with argument \a A ('fatal' or 'warning').
1578 ///
1579 /// \param A Argument of the clause ('fatal' or 'warning').
1580 /// \param ALoc Starting location of the argument.
1581 /// \param StartLoc Starting location of the clause.
1582 /// \param LParenLoc Location of '('.
1583 /// \param EndLoc Ending location of the clause.
1585 SourceLocation StartLoc, SourceLocation LParenLoc,
1586 SourceLocation EndLoc)
1587 : OMPClause(llvm::omp::OMPC_severity, StartLoc, EndLoc),
1588 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1589
1590 /// Build an empty clause.
1592 : OMPClause(llvm::omp::OMPC_severity, SourceLocation(),
1593 SourceLocation()) {}
1594
1595 /// Returns the locaiton of '('.
1596 SourceLocation getLParenLoc() const { return LParenLoc; }
1597
1598 /// Returns kind of the clause.
1600
1601 /// Returns location of clause kind.
1602 SourceLocation getSeverityKindKwLoc() const { return KindKwLoc; }
1603
1606 }
1607
1610 }
1611
1614 }
1617 }
1618
1619 static bool classof(const OMPClause *T) {
1620 return T->getClauseKind() == llvm::omp::OMPC_severity;
1621 }
1622};
1623
1624/// This represents 'message' clause in the '#pragma omp error' directive
1625///
1626/// \code
1627/// #pragma omp error message("GNU compiler required.")
1628/// \endcode
1629/// In this example directive '#pragma omp error' has simple
1630/// 'message' clause with user error message of "GNU compiler required.".
1631class OMPMessageClause final : public OMPClause {
1632 friend class OMPClauseReader;
1633
1634 /// Location of '('
1635 SourceLocation LParenLoc;
1636
1637 // Expression of the 'message' clause.
1638 Stmt *MessageString = nullptr;
1639
1640 /// Set message string of the clause.
1641 void setMessageString(Expr *MS) { MessageString = MS; }
1642
1643 /// Sets the location of '('.
1644 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1645
1646public:
1647 /// Build 'message' clause with message string argument
1648 ///
1649 /// \param MS Argument of the clause (message string).
1650 /// \param StartLoc Starting location of the clause.
1651 /// \param LParenLoc Location of '('.
1652 /// \param EndLoc Ending location of the clause.
1654 SourceLocation EndLoc)
1655 : OMPClause(llvm::omp::OMPC_message, StartLoc, EndLoc),
1656 LParenLoc(LParenLoc), MessageString(MS) {}
1657
1658 /// Build an empty clause.
1660 : OMPClause(llvm::omp::OMPC_message, SourceLocation(), SourceLocation()) {
1661 }
1662
1663 /// Returns the locaiton of '('.
1664 SourceLocation getLParenLoc() const { return LParenLoc; }
1665
1666 /// Returns message string of the clause.
1667 Expr *getMessageString() const { return cast_or_null<Expr>(MessageString); }
1668
1670 return child_range(&MessageString, &MessageString + 1);
1671 }
1672
1674 return const_child_range(&MessageString, &MessageString + 1);
1675 }
1676
1679 }
1680
1683 }
1684
1685 static bool classof(const OMPClause *T) {
1686 return T->getClauseKind() == llvm::omp::OMPC_message;
1687 }
1688};
1689
1690/// This represents 'schedule' clause in the '#pragma omp ...' directive.
1691///
1692/// \code
1693/// #pragma omp for schedule(static, 3)
1694/// \endcode
1695/// In this example directive '#pragma omp for' has 'schedule' clause with
1696/// arguments 'static' and '3'.
1698 friend class OMPClauseReader;
1699
1700 /// Location of '('.
1701 SourceLocation LParenLoc;
1702
1703 /// A kind of the 'schedule' clause.
1705
1706 /// Modifiers for 'schedule' clause.
1707 enum {FIRST, SECOND, NUM_MODIFIERS};
1708 OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
1709
1710 /// Locations of modifiers.
1711 SourceLocation ModifiersLoc[NUM_MODIFIERS];
1712
1713 /// Start location of the schedule ind in source code.
1714 SourceLocation KindLoc;
1715
1716 /// Location of ',' (if any).
1717 SourceLocation CommaLoc;
1718
1719 /// Chunk size.
1720 Expr *ChunkSize = nullptr;
1721
1722 /// Set schedule kind.
1723 ///
1724 /// \param K Schedule kind.
1725 void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
1726
1727 /// Set the first schedule modifier.
1728 ///
1729 /// \param M Schedule modifier.
1730 void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
1731 Modifiers[FIRST] = M;
1732 }
1733
1734 /// Set the second schedule modifier.
1735 ///
1736 /// \param M Schedule modifier.
1737 void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
1738 Modifiers[SECOND] = M;
1739 }
1740
1741 /// Set location of the first schedule modifier.
1742 void setFirstScheduleModifierLoc(SourceLocation Loc) {
1743 ModifiersLoc[FIRST] = Loc;
1744 }
1745
1746 /// Set location of the second schedule modifier.
1747 void setSecondScheduleModifierLoc(SourceLocation Loc) {
1748 ModifiersLoc[SECOND] = Loc;
1749 }
1750
1751 /// Set schedule modifier location.
1752 ///
1753 /// \param M Schedule modifier location.
1754 void setScheduleModifer(OpenMPScheduleClauseModifier M) {
1755 if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
1756 Modifiers[FIRST] = M;
1757 else {
1758 assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
1759 Modifiers[SECOND] = M;
1760 }
1761 }
1762
1763 /// Sets the location of '('.
1764 ///
1765 /// \param Loc Location of '('.
1766 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1767
1768 /// Set schedule kind start location.
1769 ///
1770 /// \param KLoc Schedule kind location.
1771 void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
1772
1773 /// Set location of ','.
1774 ///
1775 /// \param Loc Location of ','.
1776 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
1777
1778 /// Set chunk size.
1779 ///
1780 /// \param E Chunk size.
1781 void setChunkSize(Expr *E) { ChunkSize = E; }
1782
1783public:
1784 /// Build 'schedule' clause with schedule kind \a Kind and chunk size
1785 /// expression \a ChunkSize.
1786 ///
1787 /// \param StartLoc Starting location of the clause.
1788 /// \param LParenLoc Location of '('.
1789 /// \param KLoc Starting location of the argument.
1790 /// \param CommaLoc Location of ','.
1791 /// \param EndLoc Ending location of the clause.
1792 /// \param Kind Schedule kind.
1793 /// \param ChunkSize Chunk size.
1794 /// \param HelperChunkSize Helper chunk size for combined directives.
1795 /// \param M1 The first modifier applied to 'schedule' clause.
1796 /// \param M1Loc Location of the first modifier
1797 /// \param M2 The second modifier applied to 'schedule' clause.
1798 /// \param M2Loc Location of the second modifier
1800 SourceLocation KLoc, SourceLocation CommaLoc,
1802 Expr *ChunkSize, Stmt *HelperChunkSize,
1805 : OMPClause(llvm::omp::OMPC_schedule, StartLoc, EndLoc),
1806 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
1807 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
1808 setPreInitStmt(HelperChunkSize);
1809 Modifiers[FIRST] = M1;
1810 Modifiers[SECOND] = M2;
1811 ModifiersLoc[FIRST] = M1Loc;
1812 ModifiersLoc[SECOND] = M2Loc;
1813 }
1814
1815 /// Build an empty clause.
1817 : OMPClause(llvm::omp::OMPC_schedule, SourceLocation(), SourceLocation()),
1818 OMPClauseWithPreInit(this) {
1819 Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
1820 Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
1821 }
1822
1823 /// Get kind of the clause.
1825
1826 /// Get the first modifier of the clause.
1828 return Modifiers[FIRST];
1829 }
1830
1831 /// Get the second modifier of the clause.
1833 return Modifiers[SECOND];
1834 }
1835
1836 /// Get location of '('.
1837 SourceLocation getLParenLoc() { return LParenLoc; }
1838
1839 /// Get kind location.
1841
1842 /// Get the first modifier location.
1844 return ModifiersLoc[FIRST];
1845 }
1846
1847 /// Get the second modifier location.
1849 return ModifiersLoc[SECOND];
1850 }
1851
1852 /// Get location of ','.
1853 SourceLocation getCommaLoc() { return CommaLoc; }
1854
1855 /// Get chunk size.
1856 Expr *getChunkSize() { return ChunkSize; }
1857
1858 /// Get chunk size.
1859 const Expr *getChunkSize() const { return ChunkSize; }
1860
1862 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
1863 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
1864 }
1865
1867 auto Children = const_cast<OMPScheduleClause *>(this)->children();
1868 return const_child_range(Children.begin(), Children.end());
1869 }
1870
1873 }
1876 }
1877
1878 static bool classof(const OMPClause *T) {
1879 return T->getClauseKind() == llvm::omp::OMPC_schedule;
1880 }
1881};
1882
1883/// This represents 'ordered' clause in the '#pragma omp ...' directive.
1884///
1885/// \code
1886/// #pragma omp for ordered (2)
1887/// \endcode
1888/// In this example directive '#pragma omp for' has 'ordered' clause with
1889/// parameter 2.
1891 : public OMPClause,
1892 private llvm::TrailingObjects<OMPOrderedClause, Expr *> {
1893 friend class OMPClauseReader;
1894 friend TrailingObjects;
1895
1896 /// Location of '('.
1897 SourceLocation LParenLoc;
1898
1899 /// Number of for-loops.
1900 Stmt *NumForLoops = nullptr;
1901
1902 /// Real number of loops.
1903 unsigned NumberOfLoops = 0;
1904
1905 /// Build 'ordered' clause.
1906 ///
1907 /// \param Num Expression, possibly associated with this clause.
1908 /// \param NumLoops Number of loops, associated with this clause.
1909 /// \param StartLoc Starting location of the clause.
1910 /// \param LParenLoc Location of '('.
1911 /// \param EndLoc Ending location of the clause.
1912 OMPOrderedClause(Expr *Num, unsigned NumLoops, SourceLocation StartLoc,
1913 SourceLocation LParenLoc, SourceLocation EndLoc)
1914 : OMPClause(llvm::omp::OMPC_ordered, StartLoc, EndLoc),
1915 LParenLoc(LParenLoc), NumForLoops(Num), NumberOfLoops(NumLoops) {}
1916
1917 /// Build an empty clause.
1918 explicit OMPOrderedClause(unsigned NumLoops)
1919 : OMPClause(llvm::omp::OMPC_ordered, SourceLocation(), SourceLocation()),
1920 NumberOfLoops(NumLoops) {}
1921
1922 /// Set the number of associated for-loops.
1923 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
1924
1925public:
1926 /// Build 'ordered' clause.
1927 ///
1928 /// \param Num Expression, possibly associated with this clause.
1929 /// \param NumLoops Number of loops, associated with this clause.
1930 /// \param StartLoc Starting location of the clause.
1931 /// \param LParenLoc Location of '('.
1932 /// \param EndLoc Ending location of the clause.
1933 static OMPOrderedClause *Create(const ASTContext &C, Expr *Num,
1934 unsigned NumLoops, SourceLocation StartLoc,
1935 SourceLocation LParenLoc,
1936 SourceLocation EndLoc);
1937
1938 /// Build an empty clause.
1939 static OMPOrderedClause* CreateEmpty(const ASTContext &C, unsigned NumLoops);
1940
1941 /// Sets the location of '('.
1942 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1943
1944 /// Returns the location of '('.
1945 SourceLocation getLParenLoc() const { return LParenLoc; }
1946
1947 /// Return the number of associated for-loops.
1948 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
1949
1950 /// Set number of iterations for the specified loop.
1951 void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations);
1952 /// Get number of iterations for all the loops.
1954
1955 /// Set loop counter for the specified loop.
1956 void setLoopCounter(unsigned NumLoop, Expr *Counter);
1957 /// Get loops counter for the specified loop.
1958 Expr *getLoopCounter(unsigned NumLoop);
1959 const Expr *getLoopCounter(unsigned NumLoop) const;
1960
1961 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
1962
1964 return const_child_range(&NumForLoops, &NumForLoops + 1);
1965 }
1966
1969 }
1972 }
1973
1974 static bool classof(const OMPClause *T) {
1975 return T->getClauseKind() == llvm::omp::OMPC_ordered;
1976 }
1977};
1978
1979/// This represents 'nowait' clause in the '#pragma omp ...' directive.
1980///
1981/// \code
1982/// #pragma omp for nowait
1983/// \endcode
1984/// In this example directive '#pragma omp for' has 'nowait' clause.
1985class OMPNowaitClause final : public OMPNoChildClause<llvm::omp::OMPC_nowait> {
1986public:
1987 /// Build 'nowait' clause.
1988 ///
1989 /// \param StartLoc Starting location of the clause.
1990 /// \param EndLoc Ending location of the clause.
1992 SourceLocation EndLoc = SourceLocation())
1993 : OMPNoChildClause(StartLoc, EndLoc) {}
1994};
1995
1996/// This represents 'untied' clause in the '#pragma omp ...' directive.
1997///
1998/// \code
1999/// #pragma omp task untied
2000/// \endcode
2001/// In this example directive '#pragma omp task' has 'untied' clause.
2003public:
2004 /// Build 'untied' clause.
2005 ///
2006 /// \param StartLoc Starting location of the clause.
2007 /// \param EndLoc Ending location of the clause.
2009 : OMPClause(llvm::omp::OMPC_untied, StartLoc, EndLoc) {}
2010
2011 /// Build an empty clause.
2013 : OMPClause(llvm::omp::OMPC_untied, SourceLocation(), SourceLocation()) {}
2014
2017 }
2018
2021 }
2022
2025 }
2028 }
2029
2030 static bool classof(const OMPClause *T) {
2031 return T->getClauseKind() == llvm::omp::OMPC_untied;
2032 }
2033};
2034
2035/// This represents 'mergeable' clause in the '#pragma omp ...'
2036/// directive.
2037///
2038/// \code
2039/// #pragma omp task mergeable
2040/// \endcode
2041/// In this example directive '#pragma omp task' has 'mergeable' clause.
2043public:
2044 /// Build 'mergeable' clause.
2045 ///
2046 /// \param StartLoc Starting location of the clause.
2047 /// \param EndLoc Ending location of the clause.
2049 : OMPClause(llvm::omp::OMPC_mergeable, StartLoc, EndLoc) {}
2050
2051 /// Build an empty clause.
2053 : OMPClause(llvm::omp::OMPC_mergeable, SourceLocation(),
2054 SourceLocation()) {}
2055
2058 }
2059
2062 }
2063
2066 }
2069 }
2070
2071 static bool classof(const OMPClause *T) {
2072 return T->getClauseKind() == llvm::omp::OMPC_mergeable;
2073 }
2074};
2075
2076/// This represents the 'absent' clause in the '#pragma omp assume'
2077/// directive.
2078///
2079/// \code
2080/// #pragma omp assume absent(<directive-name list>)
2081/// \endcode
2082/// In this example directive '#pragma omp assume' has an 'absent' clause.
2084 : public OMPDirectiveListClause<OMPAbsentClause>,
2085 private llvm::TrailingObjects<OMPAbsentClause, OpenMPDirectiveKind> {
2087 friend TrailingObjects;
2088
2089 /// Build 'absent' clause.
2090 ///
2091 /// \param StartLoc Starting location of the clause.
2092 /// \param LParenLoc Location of '('.
2093 /// \param EndLoc Ending location of the clause.
2094 /// \param NumKinds Number of directive kinds listed in the clause.
2095 OMPAbsentClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2096 SourceLocation EndLoc, unsigned NumKinds)
2098 llvm::omp::OMPC_absent, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2099
2100 /// Build an empty clause.
2101 OMPAbsentClause(unsigned NumKinds)
2103 llvm::omp::OMPC_absent, SourceLocation(), SourceLocation(),
2105
2106public:
2107 static OMPAbsentClause *Create(const ASTContext &C,
2110 SourceLocation RLoc);
2111
2112 static OMPAbsentClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2113
2114 static bool classof(const OMPClause *C) {
2115 return C->getClauseKind() == llvm::omp::OMPC_absent;
2116 }
2117};
2118
2119/// This represents the 'contains' clause in the '#pragma omp assume'
2120/// directive.
2121///
2122/// \code
2123/// #pragma omp assume contains(<directive-name list>)
2124/// \endcode
2125/// In this example directive '#pragma omp assume' has a 'contains' clause.
2127 : public OMPDirectiveListClause<OMPContainsClause>,
2128 private llvm::TrailingObjects<OMPContainsClause, OpenMPDirectiveKind> {
2130 friend TrailingObjects;
2131
2132 /// Build 'contains' clause.
2133 ///
2134 /// \param StartLoc Starting location of the clause.
2135 /// \param LParenLoc Location of '('.
2136 /// \param EndLoc Ending location of the clause.
2137 /// \param NumKinds Number of directive kinds listed in the clause.
2139 SourceLocation EndLoc, unsigned NumKinds)
2141 llvm::omp::OMPC_contains, StartLoc, LParenLoc, EndLoc, NumKinds) {}
2142
2143 /// Build an empty clause.
2144 OMPContainsClause(unsigned NumKinds)
2146 llvm::omp::OMPC_contains, SourceLocation(), SourceLocation(),
2148
2149public:
2150 static OMPContainsClause *Create(const ASTContext &C,
2153 SourceLocation RLoc);
2154
2155 static OMPContainsClause *CreateEmpty(const ASTContext &C, unsigned NumKinds);
2156
2157 static bool classof(const OMPClause *C) {
2158 return C->getClauseKind() == llvm::omp::OMPC_contains;
2159 }
2160};
2161
2162/// This represents the 'holds' clause in the '#pragma omp assume'
2163/// directive.
2164///
2165/// \code
2166/// #pragma omp assume holds(<expr>)
2167/// \endcode
2168/// In this example directive '#pragma omp assume' has a 'holds' clause.
2170 : public OMPOneStmtClause<llvm::omp::OMPC_holds, OMPClause> {
2171 friend class OMPClauseReader;
2172
2173public:
2174 /// Build 'holds' clause.
2175 ///
2176 /// \param StartLoc Starting location of the clause.
2177 /// \param EndLoc Ending location of the clause.
2179 SourceLocation EndLoc)
2180 : OMPOneStmtClause(E, StartLoc, LParenLoc, EndLoc) {}
2181
2182 /// Build an empty clause.
2184
2185 Expr *getExpr() const { return getStmtAs<Expr>(); }
2186 void setExpr(Expr *E) { setStmt(E); }
2187};
2188
2189/// This represents the 'no_openmp' clause in the '#pragma omp assume'
2190/// directive.
2191///
2192/// \code
2193/// #pragma omp assume no_openmp
2194/// \endcode
2195/// In this example directive '#pragma omp assume' has a 'no_openmp' clause.
2197 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp> {
2198public:
2199 /// Build 'no_openmp' clause.
2200 ///
2201 /// \param StartLoc Starting location of the clause.
2202 /// \param EndLoc Ending location of the clause.
2204 : OMPNoChildClause(StartLoc, EndLoc) {}
2205
2206 /// Build an empty clause.
2208};
2209
2210/// This represents the 'no_openmp_routines' clause in the '#pragma omp assume'
2211/// directive.
2212///
2213/// \code
2214/// #pragma omp assume no_openmp_routines
2215/// \endcode
2216/// In this example directive '#pragma omp assume' has a 'no_openmp_routines'
2217/// clause.
2219 : public OMPNoChildClause<llvm::omp::OMPC_no_openmp_routines> {
2220public:
2221 /// Build 'no_openmp_routines' clause.
2222 ///
2223 /// \param StartLoc Starting location of the clause.
2224 /// \param EndLoc Ending location of the clause.
2226 : OMPNoChildClause(StartLoc, EndLoc) {}
2227
2228 /// Build an empty clause.
2230};
2231
2232/// This represents the 'no_parallelism' clause in the '#pragma omp assume'
2233/// directive.
2234///
2235/// \code
2236/// #pragma omp assume no_parallelism
2237/// \endcode
2238/// In this example directive '#pragma omp assume' has a 'no_parallelism'
2239/// clause.
2241 : public OMPNoChildClause<llvm::omp::OMPC_no_parallelism> {
2242public:
2243 /// Build 'no_parallelism' clause.
2244 ///
2245 /// \param StartLoc Starting location of the clause.
2246 /// \param EndLoc Ending location of the clause.
2248 : OMPNoChildClause(StartLoc, EndLoc) {}
2249
2250 /// Build an empty clause.
2252};
2253
2254/// This represents 'read' clause in the '#pragma omp atomic' directive.
2255///
2256/// \code
2257/// #pragma omp atomic read
2258/// \endcode
2259/// In this example directive '#pragma omp atomic' has 'read' clause.
2260class OMPReadClause : public OMPClause {
2261public:
2262 /// Build 'read' clause.
2263 ///
2264 /// \param StartLoc Starting location of the clause.
2265 /// \param EndLoc Ending location of the clause.
2267 : OMPClause(llvm::omp::OMPC_read, StartLoc, EndLoc) {}
2268
2269 /// Build an empty clause.
2271 : OMPClause(llvm::omp::OMPC_read, SourceLocation(), SourceLocation()) {}
2272
2275 }
2276
2279 }
2280
2283 }
2286 }
2287
2288 static bool classof(const OMPClause *T) {
2289 return T->getClauseKind() == llvm::omp::OMPC_read;
2290 }
2291};
2292
2293/// This represents 'write' clause in the '#pragma omp atomic' directive.
2294///
2295/// \code
2296/// #pragma omp atomic write
2297/// \endcode
2298/// In this example directive '#pragma omp atomic' has 'write' clause.
2300public:
2301 /// Build 'write' clause.
2302 ///
2303 /// \param StartLoc Starting location of the clause.
2304 /// \param EndLoc Ending location of the clause.
2306 : OMPClause(llvm::omp::OMPC_write, StartLoc, EndLoc) {}
2307
2308 /// Build an empty clause.
2310 : OMPClause(llvm::omp::OMPC_write, SourceLocation(), SourceLocation()) {}
2311
2314 }
2315
2318 }
2319
2322 }
2325 }
2326
2327 static bool classof(const OMPClause *T) {
2328 return T->getClauseKind() == llvm::omp::OMPC_write;
2329 }
2330};
2331
2332/// This represents 'update' clause in the '#pragma omp atomic'
2333/// directive.
2334///
2335/// \code
2336/// #pragma omp atomic update
2337/// \endcode
2338/// In this example directive '#pragma omp atomic' has 'update' clause.
2339/// Also, this class represents 'update' clause in '#pragma omp depobj'
2340/// directive.
2341///
2342/// \code
2343/// #pragma omp depobj(a) update(in)
2344/// \endcode
2345/// In this example directive '#pragma omp depobj' has 'update' clause with 'in'
2346/// dependence kind.
2348 : public OMPClause,
2349 private llvm::TrailingObjects<OMPUpdateClause, SourceLocation,
2350 OpenMPDependClauseKind> {
2351 friend class OMPClauseReader;
2352 friend TrailingObjects;
2353
2354 /// true if extended version of the clause for 'depobj' directive.
2355 bool IsExtended = false;
2356
2357 /// Define the sizes of each trailing object array except the last one. This
2358 /// is required for TrailingObjects to work properly.
2359 size_t numTrailingObjects(OverloadToken<SourceLocation>) const {
2360 // 2 locations: for '(' and argument location.
2361 return IsExtended ? 2 : 0;
2362 }
2363
2364 /// Sets the location of '(' in clause for 'depobj' directive.
2365 void setLParenLoc(SourceLocation Loc) {
2366 assert(IsExtended && "Expected extended clause.");
2367 *getTrailingObjects<SourceLocation>() = Loc;
2368 }
2369
2370 /// Sets the location of '(' in clause for 'depobj' directive.
2371 void setArgumentLoc(SourceLocation Loc) {
2372 assert(IsExtended && "Expected extended clause.");
2373 *std::next(getTrailingObjects<SourceLocation>(), 1) = Loc;
2374 }
2375
2376 /// Sets the dependence kind for the clause for 'depobj' directive.
2377 void setDependencyKind(OpenMPDependClauseKind DK) {
2378 assert(IsExtended && "Expected extended clause.");
2379 *getTrailingObjects<OpenMPDependClauseKind>() = DK;
2380 }
2381
2382 /// Build 'update' clause.
2383 ///
2384 /// \param StartLoc Starting location of the clause.
2385 /// \param EndLoc Ending location of the clause.
2386 OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc,
2387 bool IsExtended)
2388 : OMPClause(llvm::omp::OMPC_update, StartLoc, EndLoc),
2389 IsExtended(IsExtended) {}
2390
2391 /// Build an empty clause.
2392 OMPUpdateClause(bool IsExtended)
2393 : OMPClause(llvm::omp::OMPC_update, SourceLocation(), SourceLocation()),
2394 IsExtended(IsExtended) {}
2395
2396public:
2397 /// Creates clause for 'atomic' directive.
2398 ///
2399 /// \param C AST context.
2400 /// \param StartLoc Starting location of the clause.
2401 /// \param EndLoc Ending location of the clause.
2402 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2403 SourceLocation EndLoc);
2404
2405 /// Creates clause for 'depobj' directive.
2406 ///
2407 /// \param C AST context.
2408 /// \param StartLoc Starting location of the clause.
2409 /// \param LParenLoc Location of '('.
2410 /// \param ArgumentLoc Location of the argument.
2411 /// \param DK Dependence kind.
2412 /// \param EndLoc Ending location of the clause.
2413 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2414 SourceLocation LParenLoc,
2415 SourceLocation ArgumentLoc,
2417 SourceLocation EndLoc);
2418
2419 /// Creates an empty clause with the place for \a N variables.
2420 ///
2421 /// \param C AST context.
2422 /// \param IsExtended true if extended clause for 'depobj' directive must be
2423 /// created.
2424 static OMPUpdateClause *CreateEmpty(const ASTContext &C, bool IsExtended);
2425
2426 /// Checks if the clause is the extended clauses for 'depobj' directive.
2427 bool isExtended() const { return IsExtended; }
2428
2431 }
2432
2435 }
2436
2439 }
2442 }
2443
2444 /// Gets the location of '(' in clause for 'depobj' directive.
2446 assert(IsExtended && "Expected extended clause.");
2447 return *getTrailingObjects<SourceLocation>();
2448 }
2449
2450 /// Gets the location of argument in clause for 'depobj' directive.
2452 assert(IsExtended && "Expected extended clause.");
2453 return *std::next(getTrailingObjects<SourceLocation>(), 1);
2454 }
2455
2456 /// Gets the dependence kind in clause for 'depobj' directive.
2458 assert(IsExtended && "Expected extended clause.");
2459 return *getTrailingObjects<OpenMPDependClauseKind>();
2460 }
2461
2462 static bool classof(const OMPClause *T) {
2463 return T->getClauseKind() == llvm::omp::OMPC_update;
2464 }
2465};
2466
2467/// This represents 'capture' clause in the '#pragma omp atomic'
2468/// directive.
2469///
2470/// \code
2471/// #pragma omp atomic capture
2472/// \endcode
2473/// In this example directive '#pragma omp atomic' has 'capture' clause.
2475public:
2476 /// Build 'capture' clause.
2477 ///
2478 /// \param StartLoc Starting location of the clause.
2479 /// \param EndLoc Ending location of the clause.
2481 : OMPClause(llvm::omp::OMPC_capture, StartLoc, EndLoc) {}
2482
2483 /// Build an empty clause.
2485 : OMPClause(llvm::omp::OMPC_capture, SourceLocation(), SourceLocation()) {
2486 }
2487
2490 }
2491
2494 }
2495
2498 }
2501 }
2502
2503 static bool classof(const OMPClause *T) {
2504 return T->getClauseKind() == llvm::omp::OMPC_capture;
2505 }
2506};
2507
2508/// This represents 'compare' clause in the '#pragma omp atomic'
2509/// directive.
2510///
2511/// \code
2512/// #pragma omp atomic compare
2513/// \endcode
2514/// In this example directive '#pragma omp atomic' has 'compare' clause.
2515class OMPCompareClause final : public OMPClause {
2516public:
2517 /// Build 'compare' clause.
2518 ///
2519 /// \param StartLoc Starting location of the clause.
2520 /// \param EndLoc Ending location of the clause.
2522 : OMPClause(llvm::omp::OMPC_compare, StartLoc, EndLoc) {}
2523
2524 /// Build an empty clause.
2526 : OMPClause(llvm::omp::OMPC_compare, SourceLocation(), SourceLocation()) {
2527 }
2528
2531 }
2532
2535 }
2536
2539 }
2542 }
2543
2544 static bool classof(const OMPClause *T) {
2545 return T->getClauseKind() == llvm::omp::OMPC_compare;
2546 }
2547};
2548
2549/// This represents 'seq_cst' clause in the '#pragma omp atomic'
2550/// directive.
2551///
2552/// \code
2553/// #pragma omp atomic seq_cst
2554/// \endcode
2555/// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
2557public:
2558 /// Build 'seq_cst' clause.
2559 ///
2560 /// \param StartLoc Starting location of the clause.
2561 /// \param EndLoc Ending location of the clause.
2563 : OMPClause(llvm::omp::OMPC_seq_cst, StartLoc, EndLoc) {}
2564
2565 /// Build an empty clause.
2567 : OMPClause(llvm::omp::OMPC_seq_cst, SourceLocation(), SourceLocation()) {
2568 }
2569
2572 }
2573
2576 }
2577
2580 }
2583 }
2584
2585 static bool classof(const OMPClause *T) {
2586 return T->getClauseKind() == llvm::omp::OMPC_seq_cst;
2587 }
2588};
2589
2590/// This represents 'acq_rel' clause in the '#pragma omp atomic|flush'
2591/// directives.
2592///
2593/// \code
2594/// #pragma omp flush acq_rel
2595/// \endcode
2596/// In this example directive '#pragma omp flush' has 'acq_rel' clause.
2597class OMPAcqRelClause final : public OMPClause {
2598public:
2599 /// Build 'ack_rel' clause.
2600 ///
2601 /// \param StartLoc Starting location of the clause.
2602 /// \param EndLoc Ending location of the clause.
2604 : OMPClause(llvm::omp::OMPC_acq_rel, StartLoc, EndLoc) {}
2605
2606 /// Build an empty clause.
2608 : OMPClause(llvm::omp::OMPC_acq_rel, SourceLocation(), SourceLocation()) {
2609 }
2610
2613 }
2614
2617 }
2618
2621 }
2624 }
2625
2626 static bool classof(const OMPClause *T) {
2627 return T->getClauseKind() == llvm::omp::OMPC_acq_rel;
2628 }
2629};
2630
2631/// This represents 'acquire' clause in the '#pragma omp atomic|flush'
2632/// directives.
2633///
2634/// \code
2635/// #pragma omp flush acquire
2636/// \endcode
2637/// In this example directive '#pragma omp flush' has 'acquire' clause.
2638class OMPAcquireClause final : public OMPClause {
2639public:
2640 /// Build 'acquire' clause.
2641 ///
2642 /// \param StartLoc Starting location of the clause.
2643 /// \param EndLoc Ending location of the clause.
2645 : OMPClause(llvm::omp::OMPC_acquire, StartLoc, EndLoc) {}
2646
2647 /// Build an empty clause.
2649 : OMPClause(llvm::omp::OMPC_acquire, SourceLocation(), SourceLocation()) {
2650 }
2651
2654 }
2655
2658 }
2659
2662 }
2665 }
2666
2667 static bool classof(const OMPClause *T) {
2668 return T->getClauseKind() == llvm::omp::OMPC_acquire;
2669 }
2670};
2671
2672/// This represents 'release' clause in the '#pragma omp atomic|flush'
2673/// directives.
2674///
2675/// \code
2676/// #pragma omp flush release
2677/// \endcode
2678/// In this example directive '#pragma omp flush' has 'release' clause.
2679class OMPReleaseClause final : public OMPClause {
2680public:
2681 /// Build 'release' clause.
2682 ///
2683 /// \param StartLoc Starting location of the clause.
2684 /// \param EndLoc Ending location of the clause.
2686 : OMPClause(llvm::omp::OMPC_release, StartLoc, EndLoc) {}
2687
2688 /// Build an empty clause.
2690 : OMPClause(llvm::omp::OMPC_release, SourceLocation(), SourceLocation()) {
2691 }
2692
2695 }
2696
2699 }
2700
2703 }
2706 }
2707
2708 static bool classof(const OMPClause *T) {
2709 return T->getClauseKind() == llvm::omp::OMPC_release;
2710 }
2711};
2712
2713/// This represents 'relaxed' clause in the '#pragma omp atomic'
2714/// directives.
2715///
2716/// \code
2717/// #pragma omp atomic relaxed
2718/// \endcode
2719/// In this example directive '#pragma omp atomic' has 'relaxed' clause.
2720class OMPRelaxedClause final : public OMPClause {
2721public:
2722 /// Build 'relaxed' clause.
2723 ///
2724 /// \param StartLoc Starting location of the clause.
2725 /// \param EndLoc Ending location of the clause.
2727 : OMPClause(llvm::omp::OMPC_relaxed, StartLoc, EndLoc) {}
2728
2729 /// Build an empty clause.
2731 : OMPClause(llvm::omp::OMPC_relaxed, SourceLocation(), SourceLocation()) {
2732 }
2733
2736 }
2737
2740 }
2741
2744 }
2747 }
2748
2749 static bool classof(const OMPClause *T) {
2750 return T->getClauseKind() == llvm::omp::OMPC_relaxed;
2751 }
2752};
2753
2754/// This represents 'weak' clause in the '#pragma omp atomic'
2755/// directives.
2756///
2757/// \code
2758/// #pragma omp atomic compare weak
2759/// \endcode
2760/// In this example directive '#pragma omp atomic' has 'weak' clause.
2761class OMPWeakClause final : public OMPClause {
2762public:
2763 /// Build 'weak' clause.
2764 ///
2765 /// \param StartLoc Starting location of the clause.
2766 /// \param EndLoc Ending location of the clause.
2768 : OMPClause(llvm::omp::OMPC_weak, StartLoc, EndLoc) {}
2769
2770 /// Build an empty clause.
2772 : OMPClause(llvm::omp::OMPC_weak, SourceLocation(), SourceLocation()) {}
2773
2776 }
2777
2780 }
2781
2784 }
2787 }
2788
2789 static bool classof(const OMPClause *T) {
2790 return T->getClauseKind() == llvm::omp::OMPC_weak;
2791 }
2792};
2793
2794/// This represents 'fail' clause in the '#pragma omp atomic'
2795/// directive.
2796///
2797/// \code
2798/// #pragma omp atomic compare fail
2799/// \endcode
2800/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
2801class OMPFailClause final : public OMPClause {
2802
2803 // FailParameter is a memory-order-clause. Storing the ClauseKind is
2804 // sufficient for our purpose.
2805 OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
2806 SourceLocation FailParameterLoc;
2807 SourceLocation LParenLoc;
2808
2809 friend class OMPClauseReader;
2810
2811 /// Sets the location of '(' in fail clause.
2812 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2813
2814 /// Sets the location of memoryOrder clause argument in fail clause.
2815 void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
2816
2817 /// Sets the mem_order clause for 'atomic compare fail' directive.
2818 void setFailParameter(OpenMPClauseKind FailParameter) {
2819 this->FailParameter = FailParameter;
2820 assert(checkFailClauseParameter(FailParameter) &&
2821 "Invalid fail clause parameter");
2822 }
2823
2824public:
2825 /// Build 'fail' clause.
2826 ///
2827 /// \param StartLoc Starting location of the clause.
2828 /// \param EndLoc Ending location of the clause.
2830 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
2831
2832 OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation FailParameterLoc,
2833 SourceLocation StartLoc, SourceLocation LParenLoc,
2834 SourceLocation EndLoc)
2835 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
2836 FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
2837
2838 setFailParameter(FailParameter);
2839 }
2840
2841 /// Build an empty clause.
2843 : OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
2844
2847 }
2848
2851 }
2852
2855 }
2858 }
2859
2860 static bool classof(const OMPClause *T) {
2861 return T->getClauseKind() == llvm::omp::OMPC_fail;
2862 }
2863
2864 /// Gets the location of '(' (for the parameter) in fail clause.
2866 return LParenLoc;
2867 }
2868
2869 /// Gets the location of Fail Parameter (type memory-order-clause) in
2870 /// fail clause.
2871 SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
2872
2873 /// Gets the parameter (type memory-order-clause) in Fail clause.
2874 OpenMPClauseKind getFailParameter() const { return FailParameter; }
2875};
2876
2877/// This represents clause 'private' in the '#pragma omp ...' directives.
2878///
2879/// \code
2880/// #pragma omp parallel private(a,b)
2881/// \endcode
2882/// In this example directive '#pragma omp parallel' has clause 'private'
2883/// with the variables 'a' and 'b'.
2885 : public OMPVarListClause<OMPPrivateClause>,
2886 private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
2887 friend class OMPClauseReader;
2888 friend OMPVarListClause;
2889 friend TrailingObjects;
2890
2891 /// Build clause with number of variables \a N.
2892 ///
2893 /// \param StartLoc Starting location of the clause.
2894 /// \param LParenLoc Location of '('.
2895 /// \param EndLoc Ending location of the clause.
2896 /// \param N Number of the variables in the clause.
2898 SourceLocation EndLoc, unsigned N)
2899 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private, StartLoc,
2900 LParenLoc, EndLoc, N) {}
2901
2902 /// Build an empty clause.
2903 ///
2904 /// \param N Number of variables.
2905 explicit OMPPrivateClause(unsigned N)
2906 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private,
2908 SourceLocation(), N) {}
2909
2910 /// Sets the list of references to private copies with initializers for
2911 /// new private variables.
2912 /// \param VL List of references.
2913 void setPrivateCopies(ArrayRef<Expr *> VL);
2914
2915 /// Gets the list of references to private copies with initializers for
2916 /// new private variables.
2917 MutableArrayRef<Expr *> getPrivateCopies() {
2918 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2919 }
2920 ArrayRef<const Expr *> getPrivateCopies() const {
2922 }
2923
2924public:
2925 /// Creates clause with a list of variables \a VL.
2926 ///
2927 /// \param C AST context.
2928 /// \param StartLoc Starting location of the clause.
2929 /// \param LParenLoc Location of '('.
2930 /// \param EndLoc Ending location of the clause.
2931 /// \param VL List of references to the variables.
2932 /// \param PrivateVL List of references to private copies with initializers.
2933 static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2934 SourceLocation LParenLoc,
2935 SourceLocation EndLoc, ArrayRef<Expr *> VL,
2936 ArrayRef<Expr *> PrivateVL);
2937
2938 /// Creates an empty clause with the place for \a N variables.
2939 ///
2940 /// \param C AST context.
2941 /// \param N The number of variables.
2942 static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
2943
2946 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
2948 llvm::iterator_range<private_copies_const_iterator>;
2949
2951 return private_copies_range(getPrivateCopies().begin(),
2952 getPrivateCopies().end());
2953 }
2954
2956 return private_copies_const_range(getPrivateCopies().begin(),
2957 getPrivateCopies().end());
2958 }
2959
2961 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2962 reinterpret_cast<Stmt **>(varlist_end()));
2963 }
2964
2966 auto Children = const_cast<OMPPrivateClause *>(this)->children();
2967 return const_child_range(Children.begin(), Children.end());
2968 }
2969
2972 }
2975 }
2976
2977 static bool classof(const OMPClause *T) {
2978 return T->getClauseKind() == llvm::omp::OMPC_private;
2979 }
2980};
2981
2982/// This represents clause 'firstprivate' in the '#pragma omp ...'
2983/// directives.
2984///
2985/// \code
2986/// #pragma omp parallel firstprivate(a,b)
2987/// \endcode
2988/// In this example directive '#pragma omp parallel' has clause 'firstprivate'
2989/// with the variables 'a' and 'b'.
2991 : public OMPVarListClause<OMPFirstprivateClause>,
2992 public OMPClauseWithPreInit,
2993 private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
2994 friend class OMPClauseReader;
2995 friend OMPVarListClause;
2996 friend TrailingObjects;
2997
2998 /// Build clause with number of variables \a N.
2999 ///
3000 /// \param StartLoc Starting location of the clause.
3001 /// \param LParenLoc Location of '('.
3002 /// \param EndLoc Ending location of the clause.
3003 /// \param N Number of the variables in the clause.
3005 SourceLocation EndLoc, unsigned N)
3006 : OMPVarListClause<OMPFirstprivateClause>(llvm::omp::OMPC_firstprivate,
3007 StartLoc, LParenLoc, EndLoc, N),
3008 OMPClauseWithPreInit(this) {}
3009
3010 /// Build an empty clause.
3011 ///
3012 /// \param N Number of variables.
3013 explicit OMPFirstprivateClause(unsigned N)
3015 llvm::omp::OMPC_firstprivate, SourceLocation(), SourceLocation(),
3016 SourceLocation(), N),
3017 OMPClauseWithPreInit(this) {}
3018
3019 /// Sets the list of references to private copies with initializers for
3020 /// new private variables.
3021 /// \param VL List of references.
3022 void setPrivateCopies(ArrayRef<Expr *> VL);
3023
3024 /// Gets the list of references to private copies with initializers for
3025 /// new private variables.
3026 MutableArrayRef<Expr *> getPrivateCopies() {
3027 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3028 }
3029 ArrayRef<const Expr *> getPrivateCopies() const {
3031 }
3032
3033 /// Sets the list of references to initializer variables for new
3034 /// private variables.
3035 /// \param VL List of references.
3036 void setInits(ArrayRef<Expr *> VL);
3037
3038 /// Gets the list of references to initializer variables for new
3039 /// private variables.
3040 MutableArrayRef<Expr *> getInits() {
3041 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
3042 }
3043 ArrayRef<const Expr *> getInits() const {
3044 return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
3045 }
3046
3047public:
3048 /// Creates clause with a list of variables \a VL.
3049 ///
3050 /// \param C AST context.
3051 /// \param StartLoc Starting location of the clause.
3052 /// \param LParenLoc Location of '('.
3053 /// \param EndLoc Ending location of the clause.
3054 /// \param VL List of references to the original variables.
3055 /// \param PrivateVL List of references to private copies with initializers.
3056 /// \param InitVL List of references to auto generated variables used for
3057 /// initialization of a single array element. Used if firstprivate variable is
3058 /// of array type.
3059 /// \param PreInit Statement that must be executed before entering the OpenMP
3060 /// region with this clause.
3061 static OMPFirstprivateClause *
3062 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3063 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
3064 ArrayRef<Expr *> InitVL, Stmt *PreInit);
3065
3066 /// Creates an empty clause with the place for \a N variables.
3067 ///
3068 /// \param C AST context.
3069 /// \param N The number of variables.
3070 static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3071
3074 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
3076 llvm::iterator_range<private_copies_const_iterator>;
3077
3079 return private_copies_range(getPrivateCopies().begin(),
3080 getPrivateCopies().end());
3081 }
3083 return private_copies_const_range(getPrivateCopies().begin(),
3084 getPrivateCopies().end());
3085 }
3086
3089 using inits_range = llvm::iterator_range<inits_iterator>;
3090 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
3091
3093 return inits_range(getInits().begin(), getInits().end());
3094 }
3096 return inits_const_range(getInits().begin(), getInits().end());
3097 }
3098
3100 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3101 reinterpret_cast<Stmt **>(varlist_end()));
3102 }
3103
3105 auto Children = const_cast<OMPFirstprivateClause *>(this)->children();
3106 return const_child_range(Children.begin(), Children.end());
3107 }
3108
3110 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3111 reinterpret_cast<Stmt **>(varlist_end()));
3112 }
3114 auto Children = const_cast<OMPFirstprivateClause *>(this)->used_children();
3115 return const_child_range(Children.begin(), Children.end());
3116 }
3117
3118 static bool classof(const OMPClause *T) {
3119 return T->getClauseKind() == llvm::omp::OMPC_firstprivate;
3120 }
3121};
3122
3123/// This represents clause 'lastprivate' in the '#pragma omp ...'
3124/// directives.
3125///
3126/// \code
3127/// #pragma omp simd lastprivate(a,b)
3128/// \endcode
3129/// In this example directive '#pragma omp simd' has clause 'lastprivate'
3130/// with the variables 'a' and 'b'.
3132 : public OMPVarListClause<OMPLastprivateClause>,
3134 private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
3135 // There are 4 additional tail-allocated arrays at the end of the class:
3136 // 1. Contains list of pseudo variables with the default initialization for
3137 // each non-firstprivate variables. Used in codegen for initialization of
3138 // lastprivate copies.
3139 // 2. List of helper expressions for proper generation of assignment operation
3140 // required for lastprivate clause. This list represents private variables
3141 // (for arrays, single array element).
3142 // 3. List of helper expressions for proper generation of assignment operation
3143 // required for lastprivate clause. This list represents original variables
3144 // (for arrays, single array element).
3145 // 4. List of helper expressions that represents assignment operation:
3146 // \code
3147 // DstExprs = SrcExprs;
3148 // \endcode
3149 // Required for proper codegen of final assignment performed by the
3150 // lastprivate clause.
3151 friend class OMPClauseReader;
3152 friend OMPVarListClause;
3153 friend TrailingObjects;
3154
3155 /// Optional lastprivate kind, e.g. 'conditional', if specified by user.
3157 /// Optional location of the lasptrivate kind, if specified by user.
3158 SourceLocation LPKindLoc;
3159 /// Optional colon location, if specified by user.
3160 SourceLocation ColonLoc;
3161
3162 /// Build clause with number of variables \a N.
3163 ///
3164 /// \param StartLoc Starting location of the clause.
3165 /// \param LParenLoc Location of '('.
3166 /// \param EndLoc Ending location of the clause.
3167 /// \param N Number of the variables in the clause.
3170 SourceLocation LPKindLoc, SourceLocation ColonLoc,
3171 unsigned N)
3172 : OMPVarListClause<OMPLastprivateClause>(llvm::omp::OMPC_lastprivate,
3173 StartLoc, LParenLoc, EndLoc, N),
3174 OMPClauseWithPostUpdate(this), LPKind(LPKind), LPKindLoc(LPKindLoc),
3175 ColonLoc(ColonLoc) {}
3176
3177 /// Build an empty clause.
3178 ///
3179 /// \param N Number of variables.
3180 explicit OMPLastprivateClause(unsigned N)
3182 llvm::omp::OMPC_lastprivate, SourceLocation(), SourceLocation(),
3183 SourceLocation(), N),
3185
3186 /// Get the list of helper expressions for initialization of private
3187 /// copies for lastprivate variables.
3188 MutableArrayRef<Expr *> getPrivateCopies() {
3189 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3190 }
3191 ArrayRef<const Expr *> getPrivateCopies() const {
3193 }
3194
3195 /// Set list of helper expressions, required for proper codegen of the
3196 /// clause. These expressions represent private variables (for arrays, single
3197 /// array element) in the final assignment statement performed by the
3198 /// lastprivate clause.
3199 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
3200
3201 /// Get the list of helper source expressions.
3202 MutableArrayRef<Expr *> getSourceExprs() {
3203 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
3204 }
3205 ArrayRef<const Expr *> getSourceExprs() const {
3206 return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
3207 }
3208
3209 /// Set list of helper expressions, required for proper codegen of the
3210 /// clause. These expressions represent original variables (for arrays, single
3211 /// array element) in the final assignment statement performed by the
3212 /// lastprivate clause.
3213 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
3214
3215 /// Get the list of helper destination expressions.
3216 MutableArrayRef<Expr *> getDestinationExprs() {
3217 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
3218 }
3219 ArrayRef<const Expr *> getDestinationExprs() const {
3220 return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
3221 }
3222
3223 /// Set list of helper assignment expressions, required for proper
3224 /// codegen of the clause. These expressions are assignment expressions that
3225 /// assign private copy of the variable to original variable.
3226 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
3227
3228 /// Get the list of helper assignment expressions.
3229 MutableArrayRef<Expr *> getAssignmentOps() {
3230 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
3231 }
3232 ArrayRef<const Expr *> getAssignmentOps() const {
3233 return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
3234 }
3235
3236 /// Sets lastprivate kind.
3237 void setKind(OpenMPLastprivateModifier Kind) { LPKind = Kind; }
3238 /// Sets location of the lastprivate kind.
3239 void setKindLoc(SourceLocation Loc) { LPKindLoc = Loc; }
3240 /// Sets colon symbol location.
3241 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3242
3243public:
3244 /// Creates clause with a list of variables \a VL.
3245 ///
3246 /// \param C AST context.
3247 /// \param StartLoc Starting location of the clause.
3248 /// \param LParenLoc Location of '('.
3249 /// \param EndLoc Ending location of the clause.
3250 /// \param VL List of references to the variables.
3251 /// \param SrcExprs List of helper expressions for proper generation of
3252 /// assignment operation required for lastprivate clause. This list represents
3253 /// private variables (for arrays, single array element).
3254 /// \param DstExprs List of helper expressions for proper generation of
3255 /// assignment operation required for lastprivate clause. This list represents
3256 /// original variables (for arrays, single array element).
3257 /// \param AssignmentOps List of helper expressions that represents assignment
3258 /// operation:
3259 /// \code
3260 /// DstExprs = SrcExprs;
3261 /// \endcode
3262 /// Required for proper codegen of final assignment performed by the
3263 /// lastprivate clause.
3264 /// \param LPKind Lastprivate kind, e.g. 'conditional'.
3265 /// \param LPKindLoc Location of the lastprivate kind.
3266 /// \param ColonLoc Location of the ':' symbol if lastprivate kind is used.
3267 /// \param PreInit Statement that must be executed before entering the OpenMP
3268 /// region with this clause.
3269 /// \param PostUpdate Expression that must be executed after exit from the
3270 /// OpenMP region with this clause.
3271 static OMPLastprivateClause *
3272 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3273 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
3274 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
3275 OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
3276 SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate);
3277
3278 /// Creates an empty clause with the place for \a N variables.
3279 ///
3280 /// \param C AST context.
3281 /// \param N The number of variables.
3282 static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3283
3284 /// Lastprivate kind.
3285 OpenMPLastprivateModifier getKind() const { return LPKind; }
3286 /// Returns the location of the lastprivate kind.
3287 SourceLocation getKindLoc() const { return LPKindLoc; }
3288 /// Returns the location of the ':' symbol, if any.
3289 SourceLocation getColonLoc() const { return ColonLoc; }
3290
3293 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3295 llvm::iterator_range<helper_expr_const_iterator>;
3296
3297 /// Set list of helper expressions, required for generation of private
3298 /// copies of original lastprivate variables.
3299 void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
3300
3302 return helper_expr_const_range(getPrivateCopies().begin(),
3303 getPrivateCopies().end());
3304 }
3305
3307 return helper_expr_range(getPrivateCopies().begin(),
3308 getPrivateCopies().end());
3309 }
3310
3312 return helper_expr_const_range(getSourceExprs().begin(),
3313 getSourceExprs().end());
3314 }
3315
3317 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
3318 }
3319
3321 return helper_expr_const_range(getDestinationExprs().begin(),
3322 getDestinationExprs().end());
3323 }
3324
3326 return helper_expr_range(getDestinationExprs().begin(),
3327 getDestinationExprs().end());
3328 }
3329
3331 return helper_expr_const_range(getAssignmentOps().begin(),
3332 getAssignmentOps().end());
3333 }
3334
3336 return helper_expr_range(getAssignmentOps().begin(),
3337 getAssignmentOps().end());
3338 }
3339
3341 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3342 reinterpret_cast<Stmt **>(varlist_end()));
3343 }
3344
3346 auto Children = const_cast<OMPLastprivateClause *>(this)->children();
3347 return const_child_range(Children.begin(), Children.end());
3348 }
3349
3352 }
3355 }
3356
3357 static bool classof(const OMPClause *T) {
3358 return T->getClauseKind() == llvm::omp::OMPC_lastprivate;
3359 }
3360};
3361
3362/// This represents clause 'shared' in the '#pragma omp ...' directives.
3363///
3364/// \code
3365/// #pragma omp parallel shared(a,b)
3366/// \endcode
3367/// In this example directive '#pragma omp parallel' has clause 'shared'
3368/// with the variables 'a' and 'b'.
3370 : public OMPVarListClause<OMPSharedClause>,
3371 private llvm::TrailingObjects<OMPSharedClause, Expr *> {
3372 friend OMPVarListClause;
3373 friend TrailingObjects;
3374
3375 /// Build clause with number of variables \a N.
3376 ///
3377 /// \param StartLoc Starting location of the clause.
3378 /// \param LParenLoc Location of '('.
3379 /// \param EndLoc Ending location of the clause.
3380 /// \param N Number of the variables in the clause.
3381 OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3382 SourceLocation EndLoc, unsigned N)
3383 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared, StartLoc,
3384 LParenLoc, EndLoc, N) {}
3385
3386 /// Build an empty clause.
3387 ///
3388 /// \param N Number of variables.
3389 explicit OMPSharedClause(unsigned N)
3390 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared,
3392 SourceLocation(), N) {}
3393
3394public:
3395 /// Creates clause with a list of variables \a VL.
3396 ///
3397 /// \param C AST context.
3398 /// \param StartLoc Starting location of the clause.
3399 /// \param LParenLoc Location of '('.
3400 /// \param EndLoc Ending location of the clause.
3401 /// \param VL List of references to the variables.
3402 static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
3403 SourceLocation LParenLoc,
3404 SourceLocation EndLoc, ArrayRef<Expr *> VL);
3405
3406 /// Creates an empty clause with \a N variables.
3407 ///
3408 /// \param C AST context.
3409 /// \param N The number of variables.
3410 static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
3411
3413 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3414 reinterpret_cast<Stmt **>(varlist_end()));
3415 }
3416
3418 auto Children = const_cast<OMPSharedClause *>(this)->children();
3419 return const_child_range(Children.begin(), Children.end());
3420 }
3421
3424 }
3427 }
3428
3429 static bool classof(const OMPClause *T) {
3430 return T->getClauseKind() == llvm::omp::OMPC_shared;
3431 }
3432};
3433
3434/// This represents clause 'reduction' in the '#pragma omp ...'
3435/// directives.
3436///
3437/// \code
3438/// #pragma omp parallel reduction(+:a,b)
3439/// \endcode
3440/// In this example directive '#pragma omp parallel' has clause 'reduction'
3441/// with operator '+' and the variables 'a' and 'b'.
3443 : public OMPVarListClause<OMPReductionClause>,
3445 private llvm::TrailingObjects<OMPReductionClause, Expr *> {
3446 friend class OMPClauseReader;
3447 friend OMPVarListClause;
3448 friend TrailingObjects;
3449
3450 /// Reduction modifier.
3452
3453 /// Reduction modifier location.
3454 SourceLocation ModifierLoc;
3455
3456 /// Location of ':'.
3457 SourceLocation ColonLoc;
3458
3459 /// Nested name specifier for C++.
3460 NestedNameSpecifierLoc QualifierLoc;
3461
3462 /// Name of custom operator.
3463 DeclarationNameInfo NameInfo;
3464
3465 /// Build clause with number of variables \a N.
3466 ///
3467 /// \param StartLoc Starting location of the clause.
3468 /// \param LParenLoc Location of '('.
3469 /// \param ModifierLoc Modifier location.
3470 /// \param ColonLoc Location of ':'.
3471 /// \param EndLoc Ending location of the clause.
3472 /// \param N Number of the variables in the clause.
3473 /// \param QualifierLoc The nested-name qualifier with location information
3474 /// \param NameInfo The full name info for reduction identifier.
3476 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3477 SourceLocation EndLoc,
3478 OpenMPReductionClauseModifier Modifier, unsigned N,
3479 NestedNameSpecifierLoc QualifierLoc,
3480 const DeclarationNameInfo &NameInfo)
3481 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3482 StartLoc, LParenLoc, EndLoc, N),
3483 OMPClauseWithPostUpdate(this), Modifier(Modifier),
3484 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
3485 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3486
3487 /// Build an empty clause.
3488 ///
3489 /// \param N Number of variables.
3490 explicit OMPReductionClause(unsigned N)
3491 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3493 SourceLocation(), N),
3495
3496 /// Sets reduction modifier.
3497 void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; }
3498
3499 /// Sets location of the modifier.
3500 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
3501
3502 /// Sets location of ':' symbol in clause.
3503 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3504
3505 /// Sets the name info for specified reduction identifier.
3506 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3507
3508 /// Sets the nested name specifier.
3509 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3510
3511 /// Set list of helper expressions, required for proper codegen of the
3512 /// clause. These expressions represent private copy of the reduction
3513 /// variable.
3514 void setPrivates(ArrayRef<Expr *> Privates);
3515
3516 /// Get the list of helper privates.
3517 MutableArrayRef<Expr *> getPrivates() {
3518 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3519 }
3520 ArrayRef<const Expr *> getPrivates() const {
3522 }
3523
3524 /// Set list of helper expressions, required for proper codegen of the
3525 /// clause. These expressions represent LHS expression in the final
3526 /// reduction expression performed by the reduction clause.
3527 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3528
3529 /// Get the list of helper LHS expressions.
3530 MutableArrayRef<Expr *> getLHSExprs() {
3531 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
3532 }
3533 ArrayRef<const Expr *> getLHSExprs() const {
3534 return llvm::ArrayRef(getPrivates().end(), varlist_size());
3535 }
3536
3537 /// Set list of helper expressions, required for proper codegen of the
3538 /// clause. These expressions represent RHS expression in the final
3539 /// reduction expression performed by the reduction clause.
3540 /// Also, variables in these expressions are used for proper initialization of
3541 /// reduction copies.
3542 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3543
3544 /// Get the list of helper destination expressions.
3545 MutableArrayRef<Expr *> getRHSExprs() {
3546 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3547 }
3548 ArrayRef<const Expr *> getRHSExprs() const {
3549 return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
3550 }
3551
3552 /// Set list of helper reduction expressions, required for proper
3553 /// codegen of the clause. These expressions are binary expressions or
3554 /// operator/custom reduction call that calculates new value from source
3555 /// helper expressions to destination helper expressions.
3556 void setReductionOps(ArrayRef<Expr *> ReductionOps);
3557
3558 /// Get the list of helper reduction expressions.
3559 MutableArrayRef<Expr *> getReductionOps() {
3560 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
3561 }
3562 ArrayRef<const Expr *> getReductionOps() const {
3563 return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
3564 }
3565
3566 /// Set list of helper copy operations for inscan reductions.
3567 /// The form is: Temps[i] = LHS[i];
3568 void setInscanCopyOps(ArrayRef<Expr *> Ops);
3569
3570 /// Get the list of helper inscan copy operations.
3571 MutableArrayRef<Expr *> getInscanCopyOps() {
3572 return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size());
3573 }
3574 ArrayRef<const Expr *> getInscanCopyOps() const {
3575 return llvm::ArrayRef(getReductionOps().end(), varlist_size());
3576 }
3577
3578 /// Set list of helper temp vars for inscan copy array operations.
3579 void setInscanCopyArrayTemps(ArrayRef<Expr *> CopyArrayTemps);
3580
3581 /// Get the list of helper inscan copy temps.
3582 MutableArrayRef<Expr *> getInscanCopyArrayTemps() {
3583 return MutableArrayRef<Expr *>(getInscanCopyOps().end(), varlist_size());
3584 }
3585 ArrayRef<const Expr *> getInscanCopyArrayTemps() const {
3586 return llvm::ArrayRef(getInscanCopyOps().end(), varlist_size());
3587 }
3588
3589 /// Set list of helper temp elements vars for inscan copy array operations.
3590 void setInscanCopyArrayElems(ArrayRef<Expr *> CopyArrayElems);
3591
3592 /// Get the list of helper inscan copy temps.
3593 MutableArrayRef<Expr *> getInscanCopyArrayElems() {
3594 return MutableArrayRef<Expr *>(getInscanCopyArrayTemps().end(),
3595 varlist_size());
3596 }
3597 ArrayRef<const Expr *> getInscanCopyArrayElems() const {
3598 return llvm::ArrayRef(getInscanCopyArrayTemps().end(), varlist_size());
3599 }
3600
3601public:
3602 /// Creates clause with a list of variables \a VL.
3603 ///
3604 /// \param StartLoc Starting location of the clause.
3605 /// \param LParenLoc Location of '('.
3606 /// \param ModifierLoc Modifier location.
3607 /// \param ColonLoc Location of ':'.
3608 /// \param EndLoc Ending location of the clause.
3609 /// \param VL The variables in the clause.
3610 /// \param QualifierLoc The nested-name qualifier with location information
3611 /// \param NameInfo The full name info for reduction identifier.
3612 /// \param Privates List of helper expressions for proper generation of
3613 /// private copies.
3614 /// \param LHSExprs List of helper expressions for proper generation of
3615 /// assignment operation required for copyprivate clause. This list represents
3616 /// LHSs of the reduction expressions.
3617 /// \param RHSExprs List of helper expressions for proper generation of
3618 /// assignment operation required for copyprivate clause. This list represents
3619 /// RHSs of the reduction expressions.
3620 /// Also, variables in these expressions are used for proper initialization of
3621 /// reduction copies.
3622 /// \param ReductionOps List of helper expressions that represents reduction
3623 /// expressions:
3624 /// \code
3625 /// LHSExprs binop RHSExprs;
3626 /// operator binop(LHSExpr, RHSExpr);
3627 /// <CutomReduction>(LHSExpr, RHSExpr);
3628 /// \endcode
3629 /// Required for proper codegen of final reduction operation performed by the
3630 /// reduction clause.
3631 /// \param CopyOps List of copy operations for inscan reductions:
3632 /// \code
3633 /// TempExprs = LHSExprs;
3634 /// \endcode
3635 /// \param CopyArrayTemps Temp arrays for prefix sums.
3636 /// \param CopyArrayElems Temp arrays for prefix sums.
3637 /// \param PreInit Statement that must be executed before entering the OpenMP
3638 /// region with this clause.
3639 /// \param PostUpdate Expression that must be executed after exit from the
3640 /// OpenMP region with this clause.
3641 static OMPReductionClause *
3642 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3643 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3644 SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier,
3645 ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc,
3646 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
3647 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
3648 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps,
3649 ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems,
3650 Stmt *PreInit, Expr *PostUpdate);
3651
3652 /// Creates an empty clause with the place for \a N variables.
3653 ///
3654 /// \param C AST context.
3655 /// \param N The number of variables.
3656 /// \param Modifier Reduction modifier.
3657 static OMPReductionClause *
3658 CreateEmpty(const ASTContext &C, unsigned N,
3660
3661 /// Returns modifier.
3662 OpenMPReductionClauseModifier getModifier() const { return Modifier; }
3663
3664 /// Returns modifier location.
3665 SourceLocation getModifierLoc() const { return ModifierLoc; }
3666
3667 /// Gets location of ':' symbol in clause.
3668 SourceLocation getColonLoc() const { return ColonLoc; }
3669
3670 /// Gets the name info for specified reduction identifier.
3671 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3672
3673 /// Gets the nested name specifier.
3674 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3675
3678 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3680 llvm::iterator_range<helper_expr_const_iterator>;
3681
3683 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
3684 }
3685
3687 return helper_expr_range(getPrivates().begin(), getPrivates().end());
3688 }
3689
3691 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
3692 }
3693
3695 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
3696 }
3697
3699 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
3700 }
3701
3703 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
3704 }
3705
3707 return helper_expr_const_range(getReductionOps().begin(),
3708 getReductionOps().end());
3709 }
3710
3712 return helper_expr_range(getReductionOps().begin(),
3713 getReductionOps().end());
3714 }
3715
3717 return helper_expr_const_range(getInscanCopyOps().begin(),
3718 getInscanCopyOps().end());
3719 }
3720
3722 return helper_expr_range(getInscanCopyOps().begin(),
3723 getInscanCopyOps().end());
3724 }
3725
3727 return helper_expr_const_range(getInscanCopyArrayTemps().begin(),
3728 getInscanCopyArrayTemps().end());
3729 }
3730
3732 return helper_expr_range(getInscanCopyArrayTemps().begin(),
3733 getInscanCopyArrayTemps().end());
3734 }
3735
3737 return helper_expr_const_range(getInscanCopyArrayElems().begin(),
3738 getInscanCopyArrayElems().end());
3739 }
3740
3742 return helper_expr_range(getInscanCopyArrayElems().begin(),
3743 getInscanCopyArrayElems().end());
3744 }
3745
3747 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3748 reinterpret_cast<Stmt **>(varlist_end()));
3749 }
3750
3752 auto Children = const_cast<OMPReductionClause *>(this)->children();
3753 return const_child_range(Children.begin(), Children.end());
3754 }
3755
3757 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3758 reinterpret_cast<Stmt **>(varlist_end()));
3759 }
3761 auto Children = const_cast<OMPReductionClause *>(this)->used_children();
3762 return const_child_range(Children.begin(), Children.end());
3763 }
3764
3765 static bool classof(const OMPClause *T) {
3766 return T->getClauseKind() == llvm::omp::OMPC_reduction;
3767 }
3768};
3769
3770/// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
3771/// directives.
3772///
3773/// \code
3774/// #pragma omp taskgroup task_reduction(+:a,b)
3775/// \endcode
3776/// In this example directive '#pragma omp taskgroup' has clause
3777/// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
3779 : public OMPVarListClause<OMPTaskReductionClause>,
3781 private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> {
3782 friend class OMPClauseReader;
3783 friend OMPVarListClause;
3784 friend TrailingObjects;
3785
3786 /// Location of ':'.
3787 SourceLocation ColonLoc;
3788
3789 /// Nested name specifier for C++.
3790 NestedNameSpecifierLoc QualifierLoc;
3791
3792 /// Name of custom operator.
3793 DeclarationNameInfo NameInfo;
3794
3795 /// Build clause with number of variables \a N.
3796 ///
3797 /// \param StartLoc Starting location of the clause.
3798 /// \param LParenLoc Location of '('.
3799 /// \param EndLoc Ending location of the clause.
3800 /// \param ColonLoc Location of ':'.
3801 /// \param N Number of the variables in the clause.
3802 /// \param QualifierLoc The nested-name qualifier with location information
3803 /// \param NameInfo The full name info for reduction identifier.
3805 SourceLocation ColonLoc, SourceLocation EndLoc,
3806 unsigned N, NestedNameSpecifierLoc QualifierLoc,
3807 const DeclarationNameInfo &NameInfo)
3809 llvm::omp::OMPC_task_reduction, StartLoc, LParenLoc, EndLoc, N),
3810 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
3811 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3812
3813 /// Build an empty clause.
3814 ///
3815 /// \param N Number of variables.
3816 explicit OMPTaskReductionClause(unsigned N)
3818 llvm::omp::OMPC_task_reduction, SourceLocation(), SourceLocation(),
3819 SourceLocation(), N),
3821
3822 /// Sets location of ':' symbol in clause.
3823 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3824
3825 /// Sets the name info for specified reduction identifier.
3826 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3827
3828 /// Sets the nested name specifier.
3829 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3830
3831 /// Set list of helper expressions, required for proper codegen of the clause.
3832 /// These expressions represent private copy of the reduction variable.
3833 void setPrivates(ArrayRef<Expr *> Privates);
3834
3835 /// Get the list of helper privates.
3836 MutableArrayRef<Expr *> getPrivates() {
3837 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3838 }
3839 ArrayRef<const Expr *> getPrivates() const {
3841 }
3842
3843 /// Set list of helper expressions, required for proper codegen of the clause.
3844 /// These expressions represent LHS expression in the final reduction
3845 /// expression performed by the reduction clause.
3846 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3847
3848 /// Get the list of helper LHS expressions.
3849 MutableArrayRef<Expr *> getLHSExprs() {
3850 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
3851 }
3852 ArrayRef<const Expr *> getLHSExprs() const {
3853 return llvm::ArrayRef(getPrivates().end(), varlist_size());
3854 }
3855
3856 /// Set list of helper expressions, required for proper codegen of the clause.
3857 /// These expressions represent RHS expression in the final reduction
3858 /// expression performed by the reduction clause. Also, variables in these
3859 /// expressions are used for proper initialization of reduction copies.
3860 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3861
3862 /// Get the list of helper destination expressions.
3863 MutableArrayRef<Expr *> getRHSExprs() {
3864 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3865 }
3866 ArrayRef<const Expr *> getRHSExprs() const {
3867 return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
3868 }
3869
3870 /// Set list of helper reduction expressions, required for proper
3871 /// codegen of the clause. These expressions are binary expressions or
3872 /// operator/custom reduction call that calculates new value from source
3873 /// helper expressions to destination helper expressions.
3874 void setReductionOps(ArrayRef<Expr *> ReductionOps);
3875
3876 /// Get the list of helper reduction expressions.
3877 MutableArrayRef<Expr *> getReductionOps() {
3878 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
3879 }
3880 ArrayRef<const Expr *> getReductionOps() const {
3881 return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
3882 }
3883
3884public:
3885 /// Creates clause with a list of variables \a VL.
3886 ///
3887 /// \param StartLoc Starting location of the clause.
3888 /// \param LParenLoc Location of '('.
3889 /// \param ColonLoc Location of ':'.
3890 /// \param EndLoc Ending location of the clause.
3891 /// \param VL The variables in the clause.
3892 /// \param QualifierLoc The nested-name qualifier with location information
3893 /// \param NameInfo The full name info for reduction identifier.
3894 /// \param Privates List of helper expressions for proper generation of
3895 /// private copies.
3896 /// \param LHSExprs List of helper expressions for proper generation of
3897 /// assignment operation required for copyprivate clause. This list represents
3898 /// LHSs of the reduction expressions.
3899 /// \param RHSExprs List of helper expressions for proper generation of
3900 /// assignment operation required for copyprivate clause. This list represents
3901 /// RHSs of the reduction expressions.
3902 /// Also, variables in these expressions are used for proper initialization of
3903 /// reduction copies.
3904 /// \param ReductionOps List of helper expressions that represents reduction
3905 /// expressions:
3906 /// \code
3907 /// LHSExprs binop RHSExprs;
3908 /// operator binop(LHSExpr, RHSExpr);
3909 /// <CutomReduction>(LHSExpr, RHSExpr);
3910 /// \endcode
3911 /// Required for proper codegen of final reduction operation performed by the
3912 /// reduction clause.
3913 /// \param PreInit Statement that must be executed before entering the OpenMP
3914 /// region with this clause.
3915 /// \param PostUpdate Expression that must be executed after exit from the
3916 /// OpenMP region with this clause.
3917 static OMPTaskReductionClause *
3918 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3919 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
3920 NestedNameSpecifierLoc QualifierLoc,
3921 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
3922 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
3923 ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
3924
3925 /// Creates an empty clause with the place for \a N variables.
3926 ///
3927 /// \param C AST context.
3928 /// \param N The number of variables.
3929 static OMPTaskReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
3930
3931 /// Gets location of ':' symbol in clause.
3932 SourceLocation getColonLoc() const { return ColonLoc; }
3933
3934 /// Gets the name info for specified reduction identifier.
3935 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3936
3937 /// Gets the nested name specifier.
3938 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3939
3942 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3944 llvm::iterator_range<helper_expr_const_iterator>;
3945
3947 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
3948 }
3949
3951 return helper_expr_range(getPrivates().begin(), getPrivates().end());
3952 }
3953
3955 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
3956 }
3957
3959 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
3960 }
3961
3963 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
3964 }
3965
3967 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
3968 }
3969
3971 return helper_expr_const_range(getReductionOps().begin(),
3972 getReductionOps().end());
3973 }
3974
3976 return helper_expr_range(getReductionOps().begin(),
3977 getReductionOps().end());
3978 }
3979
3981 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3982 reinterpret_cast<Stmt **>(varlist_end()));
3983 }
3984
3986 auto Children = const_cast<OMPTaskReductionClause *>(this)->children();
3987 return const_child_range(Children.begin(), Children.end());
3988 }
3989
3992 }
3995 }
3996
3997 static bool classof(const OMPClause *T) {
3998 return T->getClauseKind() == llvm::omp::OMPC_task_reduction;
3999 }
4000};
4001
4002/// This represents clause 'in_reduction' in the '#pragma omp task' directives.
4003///
4004/// \code
4005/// #pragma omp task in_reduction(+:a,b)
4006/// \endcode
4007/// In this example directive '#pragma omp task' has clause 'in_reduction' with
4008/// operator '+' and the variables 'a' and 'b'.
4010 : public OMPVarListClause<OMPInReductionClause>,
4012 private llvm::TrailingObjects<OMPInReductionClause, Expr *> {
4013 friend class OMPClauseReader;
4014 friend OMPVarListClause;
4015 friend TrailingObjects;
4016
4017 /// Location of ':'.
4018 SourceLocation ColonLoc;
4019
4020 /// Nested name specifier for C++.
4021 NestedNameSpecifierLoc QualifierLoc;
4022
4023 /// Name of custom operator.
4024 DeclarationNameInfo NameInfo;
4025
4026 /// Build clause with number of variables \a N.
4027 ///
4028 /// \param StartLoc Starting location of the clause.
4029 /// \param LParenLoc Location of '('.
4030 /// \param EndLoc Ending location of the clause.
4031 /// \param ColonLoc Location of ':'.
4032 /// \param N Number of the variables in the clause.
4033 /// \param QualifierLoc The nested-name qualifier with location information
4034 /// \param NameInfo The full name info for reduction identifier.
4036 SourceLocation ColonLoc, SourceLocation EndLoc,
4037 unsigned N, NestedNameSpecifierLoc QualifierLoc,
4038 const DeclarationNameInfo &NameInfo)
4039 : OMPVarListClause<OMPInReductionClause>(llvm::omp::OMPC_in_reduction,
4040 StartLoc, LParenLoc, EndLoc, N),
4041 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
4042 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
4043
4044 /// Build an empty clause.
4045 ///
4046 /// \param N Number of variables.
4047 explicit OMPInReductionClause(unsigned N)
4049 llvm::omp::OMPC_in_reduction, SourceLocation(), SourceLocation(),
4050 SourceLocation(), N),
4052
4053 /// Sets location of ':' symbol in clause.
4054 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
4055
4056 /// Sets the name info for specified reduction identifier.
4057 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
4058
4059 /// Sets the nested name specifier.
4060 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
4061
4062 /// Set list of helper expressions, required for proper codegen of the clause.
4063 /// These expressions represent private copy of the reduction variable.
4064 void setPrivates(ArrayRef<Expr *> Privates);
4065
4066 /// Get the list of helper privates.
4067 MutableArrayRef<Expr *> getPrivates() {
4068 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4069 }
4070 ArrayRef<const Expr *> getPrivates() const {
4072 }
4073
4074 /// Set list of helper expressions, required for proper codegen of the clause.
4075 /// These expressions represent LHS expression in the final reduction
4076 /// expression performed by the reduction clause.
4077 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
4078
4079 /// Get the list of helper LHS expressions.
4080 MutableArrayRef<Expr *> getLHSExprs() {
4081 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
4082 }
4083 ArrayRef<const Expr *> getLHSExprs() const {
4084 return llvm::ArrayRef(getPrivates().end(), varlist_size());
4085 }
4086
4087 /// Set list of helper expressions, required for proper codegen of the clause.
4088 /// These expressions represent RHS expression in the final reduction
4089 /// expression performed by the reduction clause. Also, variables in these
4090 /// expressions are used for proper initialization of reduction copies.
4091 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
4092
4093 /// Get the list of helper destination expressions.
4094 MutableArrayRef<Expr *> getRHSExprs() {
4095 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
4096 }
4097 ArrayRef<const Expr *> getRHSExprs() const {
4098 return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
4099 }
4100
4101 /// Set list of helper reduction expressions, required for proper
4102 /// codegen of the clause. These expressions are binary expressions or
4103 /// operator/custom reduction call that calculates new value from source
4104 /// helper expressions to destination helper expressions.
4105 void setReductionOps(ArrayRef<Expr *> ReductionOps);
4106
4107 /// Get the list of helper reduction expressions.
4108 MutableArrayRef<Expr *> getReductionOps() {
4109 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
4110 }
4111 ArrayRef<const Expr *> getReductionOps() const {
4112 return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
4113 }
4114
4115 /// Set list of helper reduction taskgroup descriptors.
4116 void setTaskgroupDescriptors(ArrayRef<Expr *> ReductionOps);
4117
4118 /// Get the list of helper reduction taskgroup descriptors.
4119 MutableArrayRef<Expr *> getTaskgroupDescriptors() {
4120 return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size());
4121 }
4122 ArrayRef<const Expr *> getTaskgroupDescriptors() const {
4123 return llvm::ArrayRef(getReductionOps().end(), varlist_size());
4124 }
4125
4126public:
4127 /// Creates clause with a list of variables \a VL.
4128 ///
4129 /// \param StartLoc Starting location of the clause.
4130 /// \param LParenLoc Location of '('.
4131 /// \param ColonLoc Location of ':'.
4132 /// \param EndLoc Ending location of the clause.
4133 /// \param VL The variables in the clause.
4134 /// \param QualifierLoc The nested-name qualifier with location information
4135 /// \param NameInfo The full name info for reduction identifier.
4136 /// \param Privates List of helper expressions for proper generation of
4137 /// private copies.
4138 /// \param LHSExprs List of helper expressions for proper generation of
4139 /// assignment operation required for copyprivate clause. This list represents
4140 /// LHSs of the reduction expressions.
4141 /// \param RHSExprs List of helper expressions for proper generation of
4142 /// assignment operation required for copyprivate clause. This list represents
4143 /// RHSs of the reduction expressions.
4144 /// Also, variables in these expressions are used for proper initialization of
4145 /// reduction copies.
4146 /// \param ReductionOps List of helper expressions that represents reduction
4147 /// expressions:
4148 /// \code
4149 /// LHSExprs binop RHSExprs;
4150 /// operator binop(LHSExpr, RHSExpr);
4151 /// <CutomReduction>(LHSExpr, RHSExpr);
4152 /// \endcode
4153 /// Required for proper codegen of final reduction operation performed by the
4154 /// reduction clause.
4155 /// \param TaskgroupDescriptors List of helper taskgroup descriptors for
4156 /// corresponding items in parent taskgroup task_reduction clause.
4157 /// \param PreInit Statement that must be executed before entering the OpenMP
4158 /// region with this clause.
4159 /// \param PostUpdate Expression that must be executed after exit from the
4160 /// OpenMP region with this clause.
4161 static OMPInReductionClause *
4162 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4163 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
4164 NestedNameSpecifierLoc QualifierLoc,
4165 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
4166 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
4167 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> TaskgroupDescriptors,
4168 Stmt *PreInit, Expr *PostUpdate);
4169
4170 /// Creates an empty clause with the place for \a N variables.
4171 ///
4172 /// \param C AST context.
4173 /// \param N The number of variables.
4174 static OMPInReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
4175
4176 /// Gets location of ':' symbol in clause.
4177 SourceLocation getColonLoc() const { return ColonLoc; }
4178
4179 /// Gets the name info for specified reduction identifier.
4180 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
4181
4182 /// Gets the nested name specifier.
4183 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4184
4187 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4189 llvm::iterator_range<helper_expr_const_iterator>;
4190
4192 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
4193 }
4194
4196 return helper_expr_range(getPrivates().begin(), getPrivates().end());
4197 }
4198
4200 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
4201 }
4202
4204 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
4205 }
4206
4208 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
4209 }
4210
4212 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
4213 }
4214
4216 return helper_expr_const_range(getReductionOps().begin(),
4217 getReductionOps().end());
4218 }
4219
4221 return helper_expr_range(getReductionOps().begin(),
4222 getReductionOps().end());
4223 }
4224
4226 return helper_expr_const_range(getTaskgroupDescriptors().begin(),
4227 getTaskgroupDescriptors().end());
4228 }
4229
4231 return helper_expr_range(getTaskgroupDescriptors().begin(),
4232 getTaskgroupDescriptors().end());
4233 }
4234
4236 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4237 reinterpret_cast<Stmt **>(varlist_end()));
4238 }
4239
4241 auto Children = const_cast<OMPInReductionClause *>(this)->children();
4242 return const_child_range(Children.begin(), Children.end());
4243 }
4244
4247 }
4250 }
4251
4252 static bool classof(const OMPClause *T) {
4253 return T->getClauseKind() == llvm::omp::OMPC_in_reduction;
4254 }
4255};
4256
4257/// This represents clause 'linear' in the '#pragma omp ...'
4258/// directives.
4259///
4260/// \code
4261/// #pragma omp simd linear(a,b : 2)
4262/// \endcode
4263/// In this example directive '#pragma omp simd' has clause 'linear'
4264/// with variables 'a', 'b' and linear step '2'.
4266 : public OMPVarListClause<OMPLinearClause>,
4268 private llvm::TrailingObjects<OMPLinearClause, Expr *> {
4269 friend class OMPClauseReader;
4270 friend OMPVarListClause;
4271 friend TrailingObjects;
4272
4273 /// Modifier of 'linear' clause.
4274 OpenMPLinearClauseKind Modifier = OMPC_LINEAR_val;
4275
4276 /// Location of linear modifier if any.
4277 SourceLocation ModifierLoc;
4278
4279 /// Location of ':'.
4280 SourceLocation ColonLoc;
4281
4282 /// Location of 'step' modifier.
4283 SourceLocation StepModifierLoc;
4284
4285 /// Sets the linear step for clause.
4286 void setStep(Expr *Step) { *(getFinals().end()) = Step; }
4287
4288 /// Sets the expression to calculate linear step for clause.
4289 void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
4290
4291 /// Build 'linear' clause with given number of variables \a NumVars.
4292 ///
4293 /// \param StartLoc Starting location of the clause.
4294 /// \param LParenLoc Location of '('.
4295 /// \param ColonLoc Location of ':'.
4296 /// \param StepModifierLoc Location of 'step' modifier.
4297 /// \param EndLoc Ending location of the clause.
4298 /// \param NumVars Number of variables.
4299 OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4300 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4301 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4302 SourceLocation EndLoc, unsigned NumVars)
4303 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear, StartLoc,
4304 LParenLoc, EndLoc, NumVars),
4305 OMPClauseWithPostUpdate(this), Modifier(Modifier),
4306 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
4307 StepModifierLoc(StepModifierLoc) {}
4308
4309 /// Build an empty clause.
4310 ///
4311 /// \param NumVars Number of variables.
4312 explicit OMPLinearClause(unsigned NumVars)
4313 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear,
4314 SourceLocation(), SourceLocation(),
4315 SourceLocation(), NumVars),
4317
4318 /// Gets the list of initial values for linear variables.
4319 ///
4320 /// There are NumVars expressions with initial values allocated after the
4321 /// varlist, they are followed by NumVars update expressions (used to update
4322 /// the linear variable's value on current iteration) and they are followed by
4323 /// NumVars final expressions (used to calculate the linear variable's
4324 /// value after the loop body). After these lists, there are 2 helper
4325 /// expressions - linear step and a helper to calculate it before the
4326 /// loop body (used when the linear step is not constant):
4327 ///
4328 /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
4329 /// Finals[]; Step; CalcStep; }
4330 MutableArrayRef<Expr *> getPrivates() {
4331 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4332 }
4333 ArrayRef<const Expr *> getPrivates() const {
4335 }
4336
4337 MutableArrayRef<Expr *> getInits() {
4338 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
4339 }
4340 ArrayRef<const Expr *> getInits() const {
4341 return llvm::ArrayRef(getPrivates().end(), varlist_size());
4342 }
4343
4344 /// Sets the list of update expressions for linear variables.
4345 MutableArrayRef<Expr *> getUpdates() {
4346 return MutableArrayRef<Expr *>(getInits().end(), varlist_size());
4347 }
4348 ArrayRef<const Expr *> getUpdates() const {
4349 return llvm::ArrayRef(getInits().end(), varlist_size());
4350 }
4351
4352 /// Sets the list of final update expressions for linear variables.
4353 MutableArrayRef<Expr *> getFinals() {
4354 return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size());
4355 }
4356 ArrayRef<const Expr *> getFinals() const {
4357 return llvm::ArrayRef(getUpdates().end(), varlist_size());
4358 }
4359
4360 /// Gets the list of used expressions for linear variables.
4361 MutableArrayRef<Expr *> getUsedExprs() {
4362 return MutableArrayRef<Expr *>(getFinals().end() + 2, varlist_size() + 1);
4363 }
4364 ArrayRef<const Expr *> getUsedExprs() const {
4365 return llvm::ArrayRef(getFinals().end() + 2, varlist_size() + 1);
4366 }
4367
4368 /// Sets the list of the copies of original linear variables.
4369 /// \param PL List of expressions.
4370 void setPrivates(ArrayRef<Expr *> PL);
4371
4372 /// Sets the list of the initial values for linear variables.
4373 /// \param IL List of expressions.
4374 void setInits(ArrayRef<Expr *> IL);
4375
4376public:
4377 /// Creates clause with a list of variables \a VL and a linear step
4378 /// \a Step.
4379 ///
4380 /// \param C AST Context.
4381 /// \param StartLoc Starting location of the clause.
4382 /// \param LParenLoc Location of '('.
4383 /// \param Modifier Modifier of 'linear' clause.
4384 /// \param ModifierLoc Modifier location.
4385 /// \param ColonLoc Location of ':'.
4386 /// \param StepModifierLoc Location of 'step' modifier.
4387 /// \param EndLoc Ending location of the clause.
4388 /// \param VL List of references to the variables.
4389 /// \param PL List of private copies of original variables.
4390 /// \param IL List of initial values for the variables.
4391 /// \param Step Linear step.
4392 /// \param CalcStep Calculation of the linear step.
4393 /// \param PreInit Statement that must be executed before entering the OpenMP
4394 /// region with this clause.
4395 /// \param PostUpdate Expression that must be executed after exit from the
4396 /// OpenMP region with this clause.
4397 static OMPLinearClause *
4398 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4399 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4400 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4401 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PL,
4402 ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit,
4403 Expr *PostUpdate);
4404
4405 /// Creates an empty clause with the place for \a NumVars variables.
4406 ///
4407 /// \param C AST context.
4408 /// \param NumVars Number of variables.
4409 static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4410
4411 /// Set modifier.
4413
4414 /// Return modifier.
4415 OpenMPLinearClauseKind getModifier() const { return Modifier; }
4416
4417 /// Set modifier location.
4418 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
4419
4420 /// Return modifier location.
4421 SourceLocation getModifierLoc() const { return ModifierLoc; }
4422
4423 /// Sets the location of ':'.
4424 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4425
4426 /// Sets the location of 'step' modifier.
4427 void setStepModifierLoc(SourceLocation Loc) { StepModifierLoc = Loc; }
4428
4429 /// Returns the location of ':'.
4430 SourceLocation getColonLoc() const { return ColonLoc; }
4431
4432 /// Returns the location of 'step' modifier.
4433 SourceLocation getStepModifierLoc() const { return StepModifierLoc; }
4434
4435 /// Returns linear step.
4436 Expr *getStep() { return *(getFinals().end()); }
4437
4438 /// Returns linear step.
4439 const Expr *getStep() const { return *(getFinals().end()); }
4440
4441 /// Returns expression to calculate linear step.
4442 Expr *getCalcStep() { return *(getFinals().end() + 1); }
4443
4444 /// Returns expression to calculate linear step.
4445 const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
4446
4447 /// Sets the list of update expressions for linear variables.
4448 /// \param UL List of expressions.
4450
4451 /// Sets the list of final update expressions for linear variables.
4452 /// \param FL List of expressions.
4453 void setFinals(ArrayRef<Expr *> FL);
4454
4455 /// Sets the list of used expressions for the linear clause.
4457
4460 using privates_range = llvm::iterator_range<privates_iterator>;
4461 using privates_const_range = llvm::iterator_range<privates_const_iterator>;
4462
4464 return privates_range(getPrivates().begin(), getPrivates().end());
4465 }
4466
4468 return privates_const_range(getPrivates().begin(), getPrivates().end());
4469 }
4470
4473 using inits_range = llvm::iterator_range<inits_iterator>;
4474 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
4475
4477 return inits_range(getInits().begin(), getInits().end());
4478 }
4479
4481 return inits_const_range(getInits().begin(), getInits().end());
4482 }
4483
4486 using updates_range = llvm::iterator_range<updates_iterator>;
4487 using updates_const_range = llvm::iterator_range<updates_const_iterator>;
4488
4490 return updates_range(getUpdates().begin(), getUpdates().end());
4491 }
4492
4494 return updates_const_range(getUpdates().begin(), getUpdates().end());
4495 }
4496
4499 using finals_range = llvm::iterator_range<finals_iterator>;
4500 using finals_const_range = llvm::iterator_range<finals_const_iterator>;
4501
4503 return finals_range(getFinals().begin(), getFinals().end());
4504 }
4505
4507 return finals_const_range(getFinals().begin(), getFinals().end());
4508 }
4509
4513 llvm::iterator_range<used_expressions_iterator>;
4515 llvm::iterator_range<used_expressions_const_iterator>;
4516
4518 return finals_range(getUsedExprs().begin(), getUsedExprs().end());
4519 }
4520
4522 return finals_const_range(getUsedExprs().begin(), getUsedExprs().end());
4523 }
4524
4526 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4527 reinterpret_cast<Stmt **>(varlist_end()));
4528 }
4529
4531 auto Children = const_cast<OMPLinearClause *>(this)->children();
4532 return const_child_range(Children.begin(), Children.end());
4533 }
4534
4536
4538 auto Children = const_cast<OMPLinearClause *>(this)->used_children();
4539 return const_child_range(Children.begin(), Children.end());
4540 }
4541
4542 static bool classof(const OMPClause *T) {
4543 return T->getClauseKind() == llvm::omp::OMPC_linear;
4544 }
4545};
4546
4547/// This represents clause 'aligned' in the '#pragma omp ...'
4548/// directives.
4549///
4550/// \code
4551/// #pragma omp simd aligned(a,b : 8)
4552/// \endcode
4553/// In this example directive '#pragma omp simd' has clause 'aligned'
4554/// with variables 'a', 'b' and alignment '8'.
4556 : public OMPVarListClause<OMPAlignedClause>,
4557 private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
4558 friend class OMPClauseReader;
4559 friend OMPVarListClause;
4560 friend TrailingObjects;
4561
4562 /// Location of ':'.
4563 SourceLocation ColonLoc;
4564
4565 /// Sets the alignment for clause.
4566 void setAlignment(Expr *A) { *varlist_end() = A; }
4567
4568 /// Build 'aligned' clause with given number of variables \a NumVars.
4569 ///
4570 /// \param StartLoc Starting location of the clause.
4571 /// \param LParenLoc Location of '('.
4572 /// \param ColonLoc Location of ':'.
4573 /// \param EndLoc Ending location of the clause.
4574 /// \param NumVars Number of variables.
4576 SourceLocation ColonLoc, SourceLocation EndLoc,
4577 unsigned NumVars)
4578 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned, StartLoc,
4579 LParenLoc, EndLoc, NumVars),
4580 ColonLoc(ColonLoc) {}
4581
4582 /// Build an empty clause.
4583 ///
4584 /// \param NumVars Number of variables.
4585 explicit OMPAlignedClause(unsigned NumVars)
4586 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned,
4587 SourceLocation(), SourceLocation(),
4588 SourceLocation(), NumVars) {}
4589
4590public:
4591 /// Creates clause with a list of variables \a VL and alignment \a A.
4592 ///
4593 /// \param C AST Context.
4594 /// \param StartLoc Starting location of the clause.
4595 /// \param LParenLoc Location of '('.
4596 /// \param ColonLoc Location of ':'.
4597 /// \param EndLoc Ending location of the clause.
4598 /// \param VL List of references to the variables.
4599 /// \param A Alignment.
4600 static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
4601 SourceLocation LParenLoc,
4602 SourceLocation ColonLoc,
4603 SourceLocation EndLoc, ArrayRef<Expr *> VL,
4604 Expr *A);
4605
4606 /// Creates an empty clause with the place for \a NumVars variables.
4607 ///
4608 /// \param C AST context.
4609 /// \param NumVars Number of variables.
4610 static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4611
4612 /// Sets the location of ':'.
4613 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4614
4615 /// Returns the location of ':'.
4616 SourceLocation getColonLoc() const { return ColonLoc; }
4617
4618 /// Returns alignment.
4620
4621 /// Returns alignment.
4622 const Expr *getAlignment() const { return *varlist_end(); }
4623
4625 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4626 reinterpret_cast<Stmt **>(varlist_end()));
4627 }
4628
4630 auto Children = const_cast<OMPAlignedClause *>(this)->children();
4631 return const_child_range(Children.begin(), Children.end());
4632 }
4633
4636 }
4639 }
4640
4641 static bool classof(const OMPClause *T) {
4642 return T->getClauseKind() == llvm::omp::OMPC_aligned;
4643 }
4644};
4645
4646/// This represents clause 'copyin' in the '#pragma omp ...' directives.
4647///
4648/// \code
4649/// #pragma omp parallel copyin(a,b)
4650/// \endcode
4651/// In this example directive '#pragma omp parallel' has clause 'copyin'
4652/// with the variables 'a' and 'b'.
4654 : public OMPVarListClause<OMPCopyinClause>,
4655 private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
4656 // Class has 3 additional tail allocated arrays:
4657 // 1. List of helper expressions for proper generation of assignment operation
4658 // required for copyin clause. This list represents sources.
4659 // 2. List of helper expressions for proper generation of assignment operation
4660 // required for copyin clause. This list represents destinations.
4661 // 3. List of helper expressions that represents assignment operation:
4662 // \code
4663 // DstExprs = SrcExprs;
4664 // \endcode
4665 // Required for proper codegen of propagation of master's thread values of
4666 // threadprivate variables to local instances of that variables in other
4667 // implicit threads.
4668
4669 friend class OMPClauseReader;
4670 friend OMPVarListClause;
4671 friend TrailingObjects;
4672
4673 /// Build clause with number of variables \a N.
4674 ///
4675 /// \param StartLoc Starting location of the clause.
4676 /// \param LParenLoc Location of '('.
4677 /// \param EndLoc Ending location of the clause.
4678 /// \param N Number of the variables in the clause.
4679 OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4680 SourceLocation EndLoc, unsigned N)
4681 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin, StartLoc,
4682 LParenLoc, EndLoc, N) {}
4683
4684 /// Build an empty clause.
4685 ///
4686 /// \param N Number of variables.
4687 explicit OMPCopyinClause(unsigned N)
4688 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin,
4690 SourceLocation(), N) {}
4691
4692 /// Set list of helper expressions, required for proper codegen of the
4693 /// clause. These expressions represent source expression in the final
4694 /// assignment statement performed by the copyin clause.
4695 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
4696
4697 /// Get the list of helper source expressions.
4698 MutableArrayRef<Expr *> getSourceExprs() {
4699 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4700 }
4701 ArrayRef<const Expr *> getSourceExprs() const {
4703 }
4704
4705 /// Set list of helper expressions, required for proper codegen of the
4706 /// clause. These expressions represent destination expression in the final
4707 /// assignment statement performed by the copyin clause.
4708 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
4709
4710 /// Get the list of helper destination expressions.
4711 MutableArrayRef<Expr *> getDestinationExprs() {
4712 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
4713 }
4714 ArrayRef<const Expr *> getDestinationExprs() const {
4715 return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
4716 }
4717
4718 /// Set list of helper assignment expressions, required for proper
4719 /// codegen of the clause. These expressions are assignment expressions that
4720 /// assign source helper expressions to destination helper expressions
4721 /// correspondingly.
4722 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
4723
4724 /// Get the list of helper assignment expressions.
4725 MutableArrayRef<Expr *> getAssignmentOps() {
4726 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
4727 }
4728 ArrayRef<const Expr *> getAssignmentOps() const {
4729 return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
4730 }
4731
4732public:
4733 /// Creates clause with a list of variables \a VL.
4734 ///
4735 /// \param C AST context.
4736 /// \param StartLoc Starting location of the clause.
4737 /// \param LParenLoc Location of '('.
4738 /// \param EndLoc Ending location of the clause.
4739 /// \param VL List of references to the variables.
4740 /// \param SrcExprs List of helper expressions for proper generation of
4741 /// assignment operation required for copyin clause. This list represents
4742 /// sources.
4743 /// \param DstExprs List of helper expressions for proper generation of
4744 /// assignment operation required for copyin clause. This list represents
4745 /// destinations.
4746 /// \param AssignmentOps List of helper expressions that represents assignment
4747 /// operation:
4748 /// \code
4749 /// DstExprs = SrcExprs;
4750 /// \endcode
4751 /// Required for proper codegen of propagation of master's thread values of
4752 /// threadprivate variables to local instances of that variables in other
4753 /// implicit threads.
4754 static OMPCopyinClause *
4755 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4756 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
4757 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
4758
4759 /// Creates an empty clause with \a N variables.
4760 ///
4761 /// \param C AST context.
4762 /// \param N The number of variables.
4763 static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
4764
4767 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4769 llvm::iterator_range<helper_expr_const_iterator>;
4770
4772 return helper_expr_const_range(getSourceExprs().begin(),
4773 getSourceExprs().end());
4774 }
4775
4777 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
4778 }
4779
4781 return helper_expr_const_range(getDestinationExprs().begin(),
4782 getDestinationExprs().end());
4783 }
4784
4786 return helper_expr_range(getDestinationExprs().begin(),
4787 getDestinationExprs().end());
4788 }
4789
4791 return helper_expr_const_range(getAssignmentOps().begin(),
4792 getAssignmentOps().end());
4793 }
4794
4796 return helper_expr_range(getAssignmentOps().begin(),
4797 getAssignmentOps().end());
4798 }
4799
4801 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4802 reinterpret_cast<Stmt **>(varlist_end()));
4803 }
4804
4806 auto Children = const_cast<OMPCopyinClause *>(this)->children();
4807 return const_child_range(Children.begin(), Children.end());
4808 }
4809
4812 }
4815 }
4816
4817 static bool classof(const OMPClause *T) {
4818 return T->getClauseKind() == llvm::omp::OMPC_copyin;
4819 }
4820};
4821
4822/// This represents clause 'copyprivate' in the '#pragma omp ...'
4823/// directives.
4824///
4825/// \code
4826/// #pragma omp single copyprivate(a,b)
4827/// \endcode
4828/// In this example directive '#pragma omp single' has clause 'copyprivate'
4829/// with the variables 'a' and 'b'.
4831 : public OMPVarListClause<OMPCopyprivateClause>,
4832 private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
4833 friend class OMPClauseReader;
4834 friend OMPVarListClause;
4835 friend TrailingObjects;
4836
4837 /// Build clause with number of variables \a N.
4838 ///
4839 /// \param StartLoc Starting location of the clause.
4840 /// \param LParenLoc Location of '('.
4841 /// \param EndLoc Ending location of the clause.
4842 /// \param N Number of the variables in the clause.
4844 SourceLocation EndLoc, unsigned N)
4845 : OMPVarListClause<OMPCopyprivateClause>(llvm::omp::OMPC_copyprivate,
4846 StartLoc, LParenLoc, EndLoc, N) {
4847 }
4848
4849 /// Build an empty clause.
4850 ///
4851 /// \param N Number of variables.
4852 explicit OMPCopyprivateClause(unsigned N)
4854 llvm::omp::OMPC_copyprivate, SourceLocation(), SourceLocation(),
4855 SourceLocation(), N) {}
4856
4857 /// Set list of helper expressions, required for proper codegen of the
4858 /// clause. These expressions represent source expression in the final
4859 /// assignment statement performed by the copyprivate clause.
4860 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
4861
4862 /// Get the list of helper source expressions.
4863 MutableArrayRef<Expr *> getSourceExprs() {
4864 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4865 }
4866 ArrayRef<const Expr *> getSourceExprs() const {
4868 }
4869
4870 /// Set list of helper expressions, required for proper codegen of the
4871 /// clause. These expressions represent destination expression in the final
4872 /// assignment statement performed by the copyprivate clause.
4873 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
4874
4875 /// Get the list of helper destination expressions.
4876 MutableArrayRef<Expr *> getDestinationExprs() {
4877 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
4878 }
4879 ArrayRef<const Expr *> getDestinationExprs() const {
4880 return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
4881 }
4882
4883 /// Set list of helper assignment expressions, required for proper
4884 /// codegen of the clause. These expressions are assignment expressions that
4885 /// assign source helper expressions to destination helper expressions
4886 /// correspondingly.
4887 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
4888
4889 /// Get the list of helper assignment expressions.
4890 MutableArrayRef<Expr *> getAssignmentOps() {
4891 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
4892 }
4893 ArrayRef<const Expr *> getAssignmentOps() const {
4894 return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
4895 }
4896
4897public:
4898 /// Creates clause with a list of variables \a VL.
4899 ///
4900 /// \param C AST context.
4901 /// \param StartLoc Starting location of the clause.
4902 /// \param LParenLoc Location of '('.
4903 /// \param EndLoc Ending location of the clause.
4904 /// \param VL List of references to the variables.
4905 /// \param SrcExprs List of helper expressions for proper generation of
4906 /// assignment operation required for copyprivate clause. This list represents
4907 /// sources.
4908 /// \param DstExprs List of helper expressions for proper generation of
4909 /// assignment operation required for copyprivate clause. This list represents
4910 /// destinations.
4911 /// \param AssignmentOps List of helper expressions that represents assignment
4912 /// operation:
4913 /// \code
4914 /// DstExprs = SrcExprs;
4915 /// \endcode
4916 /// Required for proper codegen of final assignment performed by the
4917 /// copyprivate clause.
4918 static OMPCopyprivateClause *
4919 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4920 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
4921 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
4922
4923 /// Creates an empty clause with \a N variables.
4924 ///
4925 /// \param C AST context.
4926 /// \param N The number of variables.
4927 static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
4928
4931 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4933 llvm::iterator_range<helper_expr_const_iterator>;
4934
4936 return helper_expr_const_range(getSourceExprs().begin(),
4937 getSourceExprs().end());
4938 }
4939
4941 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
4942 }
4943
4945 return helper_expr_const_range(getDestinationExprs().begin(),
4946 getDestinationExprs().end());
4947 }
4948
4950 return helper_expr_range(getDestinationExprs().begin(),
4951 getDestinationExprs().end());
4952 }
4953
4955 return helper_expr_const_range(getAssignmentOps().begin(),
4956 getAssignmentOps().end());
4957 }
4958
4960 return helper_expr_range(getAssignmentOps().begin(),
4961 getAssignmentOps().end());
4962 }
4963
4965 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4966 reinterpret_cast<Stmt **>(varlist_end()));
4967 }
4968
4970 auto Children = const_cast<OMPCopyprivateClause *>(this)->children();
4971 return const_child_range(Children.begin(), Children.end());
4972 }
4973
4976 }
4979 }
4980
4981 static bool classof(const OMPClause *T) {
4982 return T->getClauseKind() == llvm::omp::OMPC_copyprivate;
4983 }
4984};
4985
4986/// This represents implicit clause 'flush' for the '#pragma omp flush'
4987/// directive.
4988/// This clause does not exist by itself, it can be only as a part of 'omp
4989/// flush' directive. This clause is introduced to keep the original structure
4990/// of \a OMPExecutableDirective class and its derivatives and to use the
4991/// existing infrastructure of clauses with the list of variables.
4992///
4993/// \code
4994/// #pragma omp flush(a,b)
4995/// \endcode
4996/// In this example directive '#pragma omp flush' has implicit clause 'flush'
4997/// with the variables 'a' and 'b'.
4999 : public OMPVarListClause<OMPFlushClause>,
5000 private llvm::TrailingObjects<OMPFlushClause, Expr *> {
5001 friend OMPVarListClause;
5002 friend TrailingObjects;
5003
5004 /// Build clause with number of variables \a N.
5005 ///
5006 /// \param StartLoc Starting location of the clause.
5007 /// \param LParenLoc Location of '('.
5008 /// \param EndLoc Ending location of the clause.
5009 /// \param N Number of the variables in the clause.
5010 OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5011 SourceLocation EndLoc, unsigned N)
5012 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush, StartLoc,
5013 LParenLoc, EndLoc, N) {}
5014
5015 /// Build an empty clause.
5016 ///
5017 /// \param N Number of variables.
5018 explicit OMPFlushClause(unsigned N)
5019 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush,
5021 SourceLocation(), N) {}
5022
5023public:
5024 /// Creates clause with a list of variables \a VL.
5025 ///
5026 /// \param C AST context.
5027 /// \param StartLoc Starting location of the clause.
5028 /// \param LParenLoc Location of '('.
5029 /// \param EndLoc Ending location of the clause.
5030 /// \param VL List of references to the variables.
5031 static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
5032 SourceLocation LParenLoc, SourceLocation EndLoc,
5033 ArrayRef<Expr *> VL);
5034
5035 /// Creates an empty clause with \a N variables.
5036 ///
5037 /// \param C AST context.
5038 /// \param N The number of variables.
5039 static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
5040
5042 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5043 reinterpret_cast<Stmt **>(varlist_end()));
5044 }
5045
5047 auto Children = const_cast<OMPFlushClause *>(this)->children();
5048 return const_child_range(Children.begin(), Children.end());
5049 }
5050
5053 }
5056 }
5057
5058 static bool classof(const OMPClause *T) {
5059 return T->getClauseKind() == llvm::omp::OMPC_flush;
5060 }
5061};
5062
5063/// This represents implicit clause 'depobj' for the '#pragma omp depobj'
5064/// directive.
5065/// This clause does not exist by itself, it can be only as a part of 'omp
5066/// depobj' directive. This clause is introduced to keep the original structure
5067/// of \a OMPExecutableDirective class and its derivatives and to use the
5068/// existing infrastructure of clauses with the list of variables.
5069///
5070/// \code
5071/// #pragma omp depobj(a) destroy
5072/// \endcode
5073/// In this example directive '#pragma omp depobj' has implicit clause 'depobj'
5074/// with the depobj 'a'.
5075class OMPDepobjClause final : public OMPClause {
5076 friend class OMPClauseReader;
5077
5078 /// Location of '('.
5079 SourceLocation LParenLoc;
5080
5081 /// Chunk size.
5082 Expr *Depobj = nullptr;
5083
5084 /// Build clause with number of variables \a N.
5085 ///
5086 /// \param StartLoc Starting location of the clause.
5087 /// \param LParenLoc Location of '('.
5088 /// \param EndLoc Ending location of the clause.
5089 OMPDepobjClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5090 SourceLocation EndLoc)
5091 : OMPClause(llvm::omp::OMPC_depobj, StartLoc, EndLoc),
5092 LParenLoc(LParenLoc) {}
5093
5094 /// Build an empty clause.
5095 ///
5096 explicit OMPDepobjClause()
5097 : OMPClause(llvm::omp::OMPC_depobj, SourceLocation(), SourceLocation()) {}
5098
5099 void setDepobj(Expr *E) { Depobj = E; }
5100
5101 /// Sets the location of '('.
5102 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5103
5104public:
5105 /// Creates clause.
5106 ///
5107 /// \param C AST context.
5108 /// \param StartLoc Starting location of the clause.
5109 /// \param LParenLoc Location of '('.
5110 /// \param EndLoc Ending location of the clause.
5111 /// \param Depobj depobj expression associated with the 'depobj' directive.
5112 static OMPDepobjClause *Create(const ASTContext &C, SourceLocation StartLoc,
5113 SourceLocation LParenLoc,
5114 SourceLocation EndLoc, Expr *Depobj);
5115
5116 /// Creates an empty clause.
5117 ///
5118 /// \param C AST context.
5119 static OMPDepobjClause *CreateEmpty(const ASTContext &C);
5120
5121 /// Returns depobj expression associated with the clause.
5122 Expr *getDepobj() { return Depobj; }
5123 const Expr *getDepobj() const { return Depobj; }
5124
5125 /// Returns the location of '('.
5126 SourceLocation getLParenLoc() const { return LParenLoc; }
5127
5129 return child_range(reinterpret_cast<Stmt **>(&Depobj),
5130 reinterpret_cast<Stmt **>(&Depobj) + 1);
5131 }
5132
5134 auto Children = const_cast<OMPDepobjClause *>(this)->children();
5135 return const_child_range(Children.begin(), Children.end());
5136 }
5137
5140 }
5143 }
5144
5145 static bool classof(const OMPClause *T) {
5146 return T->getClauseKind() == llvm::omp::OMPC_depobj;
5147 }
5148};
5149
5150/// This represents implicit clause 'depend' for the '#pragma omp task'
5151/// directive.
5152///
5153/// \code
5154/// #pragma omp task depend(in:a,b)
5155/// \endcode
5156/// In this example directive '#pragma omp task' with clause 'depend' with the
5157/// variables 'a' and 'b' with dependency 'in'.
5159 : public OMPVarListClause<OMPDependClause>,
5160 private llvm::TrailingObjects<OMPDependClause, Expr *> {
5161 friend class OMPClauseReader;
5162 friend OMPVarListClause;
5163 friend TrailingObjects;
5164
5165public:
5166 struct DependDataTy final {
5167 /// Dependency type (one of in, out, inout).
5169
5170 /// Dependency type location.
5172
5173 /// Colon location.
5175
5176 /// Location of 'omp_all_memory'.
5178 };
5179
5180private:
5181 /// Dependency type and source locations.
5182 DependDataTy Data;
5183
5184 /// Number of loops, associated with the depend clause.
5185 unsigned NumLoops = 0;
5186
5187 /// Build clause with number of variables \a N.
5188 ///
5189 /// \param StartLoc Starting location of the clause.
5190 /// \param LParenLoc Location of '('.
5191 /// \param EndLoc Ending location of the clause.
5192 /// \param N Number of the variables in the clause.
5193 /// \param NumLoops Number of loops that is associated with this depend
5194 /// clause.
5195 OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
5196 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
5197 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend, StartLoc,
5198 LParenLoc, EndLoc, N),
5199 NumLoops(NumLoops) {}
5200
5201 /// Build an empty clause.
5202 ///
5203 /// \param N Number of variables.
5204 /// \param NumLoops Number of loops that is associated with this depend
5205 /// clause.
5206 explicit OMPDependClause(unsigned N, unsigned NumLoops)
5207 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend,
5209 SourceLocation(), N),
5210 NumLoops(NumLoops) {}
5211
5212 /// Set dependency kind.
5213 void setDependencyKind(OpenMPDependClauseKind K) { Data.DepKind = K; }
5214
5215 /// Set dependency kind and its location.
5216 void setDependencyLoc(SourceLocation Loc) { Data.DepLoc = Loc; }
5217
5218 /// Set colon location.
5219 void setColonLoc(SourceLocation Loc) { Data.ColonLoc = Loc; }
5220
5221 /// Set the 'omp_all_memory' location.
5222 void setOmpAllMemoryLoc(SourceLocation Loc) { Data.OmpAllMemoryLoc = Loc; }
5223
5224 /// Sets optional dependency modifier.
5225 void setModifier(Expr *DepModifier);
5226
5227public:
5228 /// Creates clause with a list of variables \a VL.
5229 ///
5230 /// \param C AST context.
5231 /// \param StartLoc Starting location of the clause.
5232 /// \param LParenLoc Location of '('.
5233 /// \param EndLoc Ending location of the clause.
5234 /// \param Data Dependency type and source locations.
5235 /// \param VL List of references to the variables.
5236 /// \param NumLoops Number of loops that is associated with this depend
5237 /// clause.
5238 static OMPDependClause *Create(const ASTContext &C, SourceLocation StartLoc,
5239 SourceLocation LParenLoc,
5240 SourceLocation EndLoc, DependDataTy Data,
5241 Expr *DepModifier, ArrayRef<Expr *> VL,
5242 unsigned NumLoops);
5243
5244 /// Creates an empty clause with \a N variables.
5245 ///
5246 /// \param C AST context.
5247 /// \param N The number of variables.
5248 /// \param NumLoops Number of loops that is associated with this depend
5249 /// clause.
5250 static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N,
5251 unsigned NumLoops);
5252
5253 /// Get dependency type.
5255
5256 /// Get dependency type location.
5257 SourceLocation getDependencyLoc() const { return Data.DepLoc; }
5258
5259 /// Get colon location.
5260 SourceLocation getColonLoc() const { return Data.ColonLoc; }
5261
5262 /// Get 'omp_all_memory' location.
5263 SourceLocation getOmpAllMemoryLoc() const { return Data.OmpAllMemoryLoc; }
5264
5265 /// Return optional depend modifier.
5266 Expr *getModifier();
5267 const Expr *getModifier() const {
5268 return const_cast<OMPDependClause *>(this)->getModifier();
5269 }
5270
5271 /// Get number of loops associated with the clause.
5272 unsigned getNumLoops() const { return NumLoops; }
5273
5274 /// Set the loop data for the depend clauses with 'sink|source' kind of
5275 /// dependency.
5276 void setLoopData(unsigned NumLoop, Expr *Cnt);
5277
5278 /// Get the loop data.
5279 Expr *getLoopData(unsigned NumLoop);
5280 const Expr *getLoopData(unsigned NumLoop) const;
5281
5283 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5284 reinterpret_cast<Stmt **>(varlist_end()));
5285 }
5286
5288 auto Children = const_cast<OMPDependClause *>(this)->children();
5289 return const_child_range(Children.begin(), Children.end());
5290 }
5291
5294 }
5297 }
5298
5299 static bool classof(const OMPClause *T) {
5300 return T->getClauseKind() == llvm::omp::OMPC_depend;
5301 }
5302};
5303
5304/// This represents 'device' clause in the '#pragma omp ...'
5305/// directive.
5306///
5307/// \code
5308/// #pragma omp target device(a)
5309/// \endcode
5310/// In this example directive '#pragma omp target' has clause 'device'
5311/// with single expression 'a'.
5313 friend class OMPClauseReader;
5314
5315 /// Location of '('.
5316 SourceLocation LParenLoc;
5317
5318 /// Device clause modifier.
5320
5321 /// Location of the modifier.
5322 SourceLocation ModifierLoc;
5323
5324 /// Device number.
5325 Stmt *Device = nullptr;
5326
5327 /// Set the device number.
5328 ///
5329 /// \param E Device number.
5330 void setDevice(Expr *E) { Device = E; }
5331
5332 /// Sets modifier.
5333 void setModifier(OpenMPDeviceClauseModifier M) { Modifier = M; }
5334
5335 /// Setst modifier location.
5336 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
5337
5338public:
5339 /// Build 'device' clause.
5340 ///
5341 /// \param Modifier Clause modifier.
5342 /// \param E Expression associated with this clause.
5343 /// \param CaptureRegion Innermost OpenMP region where expressions in this
5344 /// clause must be captured.
5345 /// \param StartLoc Starting location of the clause.
5346 /// \param ModifierLoc Modifier location.
5347 /// \param LParenLoc Location of '('.
5348 /// \param EndLoc Ending location of the clause.
5350 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
5351 SourceLocation LParenLoc, SourceLocation ModifierLoc,
5352 SourceLocation EndLoc)
5353 : OMPClause(llvm::omp::OMPC_device, StartLoc, EndLoc),
5354 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
5355 ModifierLoc(ModifierLoc), Device(E) {
5356 setPreInitStmt(HelperE, CaptureRegion);
5357 }
5358
5359 /// Build an empty clause.
5361 : OMPClause(llvm::omp::OMPC_device, SourceLocation(), SourceLocation()),
5362 OMPClauseWithPreInit(this) {}
5363
5364 /// Sets the location of '('.
5365 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5366
5367 /// Returns the location of '('.
5368 SourceLocation getLParenLoc() const { return LParenLoc; }
5369
5370 /// Return device number.
5371 Expr *getDevice() { return cast<Expr>(Device); }
5372
5373 /// Return device number.
5374 Expr *getDevice() const { return cast<Expr>(Device); }
5375
5376 /// Gets modifier.
5377 OpenMPDeviceClauseModifier getModifier() const { return Modifier; }
5378
5379 /// Gets modifier location.
5380 SourceLocation getModifierLoc() const { return ModifierLoc; }
5381
5383
5385 return const_child_range(&Device, &Device + 1);
5386 }
5387
5390 }
5393 }
5394
5395 static bool classof(const OMPClause *T) {
5396 return T->getClauseKind() == llvm::omp::OMPC_device;
5397 }
5398};
5399
5400/// This represents 'threads' clause in the '#pragma omp ...' directive.
5401///
5402/// \code
5403/// #pragma omp ordered threads
5404/// \endcode
5405/// In this example directive '#pragma omp ordered' has simple 'threads' clause.
5407 : public OMPNoChildClause<llvm::omp::OMPC_threads> {
5408public:
5409 /// Build 'threads' clause.
5410 ///
5411 /// \param StartLoc Starting location of the clause.
5412 /// \param EndLoc Ending location of the clause.
5414 : OMPNoChildClause(StartLoc, EndLoc) {}
5415
5416 /// Build an empty clause.
5418};
5419
5420/// This represents 'simd' clause in the '#pragma omp ...' directive.
5421///
5422/// \code
5423/// #pragma omp ordered simd
5424/// \endcode
5425/// In this example directive '#pragma omp ordered' has simple 'simd' clause.
5426class OMPSIMDClause : public OMPClause {
5427public:
5428 /// Build 'simd' clause.
5429 ///
5430 /// \param StartLoc Starting location of the clause.
5431 /// \param EndLoc Ending location of the clause.
5433 : OMPClause(llvm::omp::OMPC_simd, StartLoc, EndLoc) {}
5434
5435 /// Build an empty clause.
5437 : OMPClause(llvm::omp::OMPC_simd, SourceLocation(), SourceLocation()) {}
5438
5441 }
5442
5445 }
5446
5449 }
5452 }
5453
5454 static bool classof(const OMPClause *T) {
5455 return T->getClauseKind() == llvm::omp::OMPC_simd;
5456 }
5457};
5458
5459/// Struct that defines common infrastructure to handle mappable
5460/// expressions used in OpenMP clauses.
5462public:
5463 /// Class that represents a component of a mappable expression. E.g.
5464 /// for an expression S.a, the first component is a declaration reference
5465 /// expression associated with 'S' and the second is a member expression
5466 /// associated with the field declaration 'a'. If the expression is an array
5467 /// subscript it may not have any associated declaration. In that case the
5468 /// associated declaration is set to nullptr.
5470 /// Pair of Expression and Non-contiguous pair associated with the
5471 /// component.
5472 llvm::PointerIntPair<Expr *, 1, bool> AssociatedExpressionNonContiguousPr;
5473
5474 /// Declaration associated with the declaration. If the component does
5475 /// not have a declaration (e.g. array subscripts or section), this is set
5476 /// to nullptr.
5477 ValueDecl *AssociatedDeclaration = nullptr;
5478
5479 public:
5480 explicit MappableComponent() = default;
5481 explicit MappableComponent(Expr *AssociatedExpression,
5482 ValueDecl *AssociatedDeclaration,
5483 bool IsNonContiguous)
5484 : AssociatedExpressionNonContiguousPr(AssociatedExpression,
5485 IsNonContiguous),
5486 AssociatedDeclaration(
5487 AssociatedDeclaration
5488 ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
5489 : nullptr) {}
5490
5492 return AssociatedExpressionNonContiguousPr.getPointer();
5493 }
5494
5495 bool isNonContiguous() const {
5496 return AssociatedExpressionNonContiguousPr.getInt();
5497 }
5498
5500 return AssociatedDeclaration;
5501 }
5502 };
5503
5504 // List of components of an expression. This first one is the whole
5505 // expression and the last one is the base expression.
5508
5509 // List of all component lists associated to the same base declaration.
5510 // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
5511 // their component list but the same base declaration 'S'.
5514
5515protected:
5516 // Return the total number of elements in a list of component lists.
5517 static unsigned
5519
5520 // Return the total number of elements in a list of declarations. All
5521 // declarations are expected to be canonical.
5522 static unsigned
5524};
5525
5526/// This structure contains all sizes needed for by an
5527/// OMPMappableExprListClause.
5529 /// Number of expressions listed.
5530 unsigned NumVars;
5531 /// Number of unique base declarations.
5533 /// Number of component lists.
5535 /// Total number of expression components.
5539 unsigned NumComponentLists, unsigned NumComponents)
5542};
5543
5544/// This represents clauses with a list of expressions that are mappable.
5545/// Examples of these clauses are 'map' in
5546/// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
5547/// in '#pragma omp target update...' directives.
5548template <class T>
5551 friend class OMPClauseReader;
5552
5553 /// Number of unique declarations in this clause.
5554 unsigned NumUniqueDeclarations;
5555
5556 /// Number of component lists in this clause.
5557 unsigned NumComponentLists;
5558
5559 /// Total number of components in this clause.
5560 unsigned NumComponents;
5561
5562 /// Whether this clause is possible to have user-defined mappers associated.
5563 /// It should be true for map, to, and from clauses, and false for
5564 /// use_device_ptr and is_device_ptr.
5565 const bool SupportsMapper;
5566
5567 /// C++ nested name specifier for the associated user-defined mapper.
5568 NestedNameSpecifierLoc MapperQualifierLoc;
5569
5570 /// The associated user-defined mapper identifier information.
5571 DeclarationNameInfo MapperIdInfo;
5572
5573protected:
5574 /// Build a clause for \a NumUniqueDeclarations declarations, \a
5575 /// NumComponentLists total component lists, and \a NumComponents total
5576 /// components.
5577 ///
5578 /// \param K Kind of the clause.
5579 /// \param Locs Locations needed to build a mappable clause. It includes 1)
5580 /// StartLoc: starting location of the clause (the clause keyword); 2)
5581 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5582 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5583 /// NumVars: number of expressions listed in this clause; 2)
5584 /// NumUniqueDeclarations: number of unique base declarations in this clause;
5585 /// 3) NumComponentLists: number of component lists in this clause; and 4)
5586 /// NumComponents: total number of expression components in the clause.
5587 /// \param SupportsMapper Indicates whether this clause is possible to have
5588 /// user-defined mappers associated.
5589 /// \param MapperQualifierLocPtr C++ nested name specifier for the associated
5590 /// user-defined mapper.
5591 /// \param MapperIdInfoPtr The identifier of associated user-defined mapper.
5593 OpenMPClauseKind K, const OMPVarListLocTy &Locs,
5594 const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false,
5595 NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr,
5596 DeclarationNameInfo *MapperIdInfoPtr = nullptr)
5597 : OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc,
5598 Sizes.NumVars),
5599 NumUniqueDeclarations(Sizes.NumUniqueDeclarations),
5600 NumComponentLists(Sizes.NumComponentLists),
5601 NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) {
5602 if (MapperQualifierLocPtr)
5603 MapperQualifierLoc = *MapperQualifierLocPtr;
5604 if (MapperIdInfoPtr)
5605 MapperIdInfo = *MapperIdInfoPtr;
5606 }
5607
5608 /// Get the unique declarations that are in the trailing objects of the
5609 /// class.
5612 static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(),
5613 NumUniqueDeclarations);
5614 }
5615
5616 /// Get the unique declarations that are in the trailing objects of the
5617 /// class.
5619 return ArrayRef<ValueDecl *>(
5620 static_cast<const T *>(this)
5621 ->template getTrailingObjects<ValueDecl *>(),
5622 NumUniqueDeclarations);
5623 }
5624
5625 /// Set the unique declarations that are in the trailing objects of the
5626 /// class.
5628 assert(UDs.size() == NumUniqueDeclarations &&
5629 "Unexpected amount of unique declarations.");
5630 std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin());
5631 }
5632
5633 /// Get the number of lists per declaration that are in the trailing
5634 /// objects of the class.
5637 static_cast<T *>(this)->template getTrailingObjects<unsigned>(),
5638 NumUniqueDeclarations);
5639 }
5640
5641 /// Get the number of lists per declaration that are in the trailing
5642 /// objects of the class.
5644 return ArrayRef<unsigned>(
5645 static_cast<const T *>(this)->template getTrailingObjects<unsigned>(),
5646 NumUniqueDeclarations);
5647 }
5648
5649 /// Set the number of lists per declaration that are in the trailing
5650 /// objects of the class.
5652 assert(DNLs.size() == NumUniqueDeclarations &&
5653 "Unexpected amount of list numbers.");
5654 std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin());
5655 }
5656
5657 /// Get the cumulative component lists sizes that are in the trailing
5658 /// objects of the class. They are appended after the number of lists.
5661 static_cast<T *>(this)->template getTrailingObjects<unsigned>() +
5662 NumUniqueDeclarations,
5663 NumComponentLists);
5664 }
5665
5666 /// Get the cumulative component lists sizes that are in the trailing
5667 /// objects of the class. They are appended after the number of lists.
5669 return ArrayRef<unsigned>(
5670 static_cast<const T *>(this)->template getTrailingObjects<unsigned>() +
5671 NumUniqueDeclarations,
5672 NumComponentLists);
5673 }
5674
5675 /// Set the cumulative component lists sizes that are in the trailing
5676 /// objects of the class.
5678 assert(CLSs.size() == NumComponentLists &&
5679 "Unexpected amount of component lists.");
5680 std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin());
5681 }
5682
5683 /// Get the components that are in the trailing objects of the class.
5686 static_cast<T *>(this)
5687 ->template getTrailingObjects<MappableComponent>(),
5688 NumComponents);
5689 }
5690
5691 /// Get the components that are in the trailing objects of the class.
5694 static_cast<const T *>(this)
5695 ->template getTrailingObjects<MappableComponent>(),
5696 NumComponents);
5697 }
5698
5699 /// Set the components that are in the trailing objects of the class.
5700 /// This requires the list sizes so that it can also fill the original
5701 /// expressions, which are the first component of each list.
5703 ArrayRef<unsigned> CLSs) {
5704 assert(Components.size() == NumComponents &&
5705 "Unexpected amount of component lists.");
5706 assert(CLSs.size() == NumComponentLists &&
5707 "Unexpected amount of list sizes.");
5708 std::copy(Components.begin(), Components.end(), getComponentsRef().begin());
5709 }
5710
5711 /// Fill the clause information from the list of declarations and
5712 /// associated component lists.
5714 MappableExprComponentListsRef ComponentLists) {
5715 // Perform some checks to make sure the data sizes are consistent with the
5716 // information available when the clause was created.
5717 assert(getUniqueDeclarationsTotalNumber(Declarations) ==
5718 NumUniqueDeclarations &&
5719 "Unexpected number of mappable expression info entries!");
5720 assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
5721 "Unexpected total number of components!");
5722 assert(Declarations.size() == ComponentLists.size() &&
5723 "Declaration and component lists size is not consistent!");
5724 assert(Declarations.size() == NumComponentLists &&
5725 "Unexpected declaration and component lists size!");
5726
5727 // Organize the components by declaration and retrieve the original
5728 // expression. Original expressions are always the first component of the
5729 // mappable component list.
5730 llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
5731 ComponentListMap;
5732 {
5733 auto CI = ComponentLists.begin();
5734 for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
5735 ++DI, ++CI) {
5736 assert(!CI->empty() && "Invalid component list!");
5737 ComponentListMap[*DI].push_back(*CI);
5738 }
5739 }
5740
5741 // Iterators of the target storage.
5742 auto UniqueDeclarations = getUniqueDeclsRef();
5743 auto UDI = UniqueDeclarations.begin();
5744
5745 auto DeclNumLists = getDeclNumListsRef();
5746 auto DNLI = DeclNumLists.begin();
5747
5748 auto ComponentListSizes = getComponentListSizesRef();
5749 auto CLSI = ComponentListSizes.begin();
5750
5751 auto Components = getComponentsRef();
5752 auto CI = Components.begin();
5753
5754 // Variable to compute the accumulation of the number of components.
5755 unsigned PrevSize = 0u;
5756
5757 // Scan all the declarations and associated component lists.
5758 for (auto &M : ComponentListMap) {
5759 // The declaration.
5760 auto *D = M.first;
5761 // The component lists.
5762 auto CL = M.second;
5763
5764 // Initialize the entry.
5765 *UDI = D;
5766 ++UDI;
5767
5768 *DNLI = CL.size();
5769 ++DNLI;
5770
5771 // Obtain the cumulative sizes and concatenate all the components in the
5772 // reserved storage.
5773 for (auto C : CL) {
5774 // Accumulate with the previous size.
5775 PrevSize += C.size();
5776
5777 // Save the size.
5778 *CLSI = PrevSize;
5779 ++CLSI;
5780
5781 // Append components after the current components iterator.
5782 CI = std::copy(C.begin(), C.end(), CI);
5783 }
5784 }
5785 }
5786
5787 /// Set the nested name specifier of associated user-defined mapper.
5789 MapperQualifierLoc = NNSL;
5790 }
5791
5792 /// Set the name of associated user-defined mapper.
5794 MapperIdInfo = MapperId;
5795 }
5796
5797 /// Get the user-defined mapper references that are in the trailing objects of
5798 /// the class.
5800 assert(SupportsMapper &&
5801 "Must be a clause that is possible to have user-defined mappers");
5803 static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
5806 }
5807
5808 /// Get the user-defined mappers references that are in the trailing objects
5809 /// of the class.
5811 assert(SupportsMapper &&
5812 "Must be a clause that is possible to have user-defined mappers");
5814 static_cast<const T *>(this)->template getTrailingObjects<Expr *>() +
5817 }
5818
5819 /// Set the user-defined mappers that are in the trailing objects of the
5820 /// class.
5822 assert(DMDs.size() == OMPVarListClause<T>::varlist_size() &&
5823 "Unexpected number of user-defined mappers.");
5824 assert(SupportsMapper &&
5825 "Must be a clause that is possible to have user-defined mappers");
5826 std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin());
5827 }
5828
5829public:
5830 /// Return the number of unique base declarations in this clause.
5831 unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
5832
5833 /// Return the number of lists derived from the clause expressions.
5834 unsigned getTotalComponentListNum() const { return NumComponentLists; }
5835
5836 /// Return the total number of components in all lists derived from the
5837 /// clause.
5838 unsigned getTotalComponentsNum() const { return NumComponents; }
5839
5840 /// Gets the nested name specifier for associated user-defined mapper.
5842 return MapperQualifierLoc;
5843 }
5844
5845 /// Gets the name info for associated user-defined mapper.
5846 const DeclarationNameInfo &getMapperIdInfo() const { return MapperIdInfo; }
5847
5848 /// Iterator that browse the components by lists. It also allows
5849 /// browsing components of a single declaration.
5851 : public llvm::iterator_adaptor_base<
5852 const_component_lists_iterator,
5853 MappableExprComponentListRef::const_iterator,
5854 std::forward_iterator_tag, MappableComponent, ptrdiff_t,
5855 MappableComponent, MappableComponent> {
5856 // The declaration the iterator currently refers to.
5858
5859 // The list number associated with the current declaration.
5860 ArrayRef<unsigned>::iterator NumListsCur;
5861
5862 // Whether this clause is possible to have user-defined mappers associated.
5863 const bool SupportsMapper;
5864
5865 // The user-defined mapper associated with the current declaration.
5867
5868 // Remaining lists for the current declaration.
5869 unsigned RemainingLists = 0;
5870
5871 // The cumulative size of the previous list, or zero if there is no previous
5872 // list.
5873 unsigned PrevListSize = 0;
5874
5875 // The cumulative sizes of the current list - it will delimit the remaining
5876 // range of interest.
5879
5880 // Iterator to the end of the components storage.
5881 MappableExprComponentListRef::const_iterator End;
5882
5883 public:
5884 /// Construct an iterator that scans all lists.
5886 ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
5887 ArrayRef<unsigned> CumulativeListSizes,
5888 MappableExprComponentListRef Components, bool SupportsMapper,
5889 ArrayRef<Expr *> Mappers)
5890 : const_component_lists_iterator::iterator_adaptor_base(
5891 Components.begin()),
5892 DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
5893 SupportsMapper(SupportsMapper),
5894 ListSizeCur(CumulativeListSizes.begin()),
5895 ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
5896 assert(UniqueDecls.size() == DeclsListNum.size() &&
5897 "Inconsistent number of declarations and list sizes!");
5898 if (!DeclsListNum.empty())
5899 RemainingLists = *NumListsCur;
5900 if (SupportsMapper)
5901 MapperCur = Mappers.begin();
5902 }
5903
5904 /// Construct an iterator that scan lists for a given declaration \a
5905 /// Declaration.
5907 const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
5908 ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
5909 MappableExprComponentListRef Components, bool SupportsMapper,
5910 ArrayRef<Expr *> Mappers)
5911 : const_component_lists_iterator(UniqueDecls, DeclsListNum,
5912 CumulativeListSizes, Components,
5913 SupportsMapper, Mappers) {
5914 // Look for the desired declaration. While we are looking for it, we
5915 // update the state so that we know the component where a given list
5916 // starts.
5917 for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
5918 if (*DeclCur == Declaration)
5919 break;
5920
5921 assert(*NumListsCur > 0 && "No lists associated with declaration??");
5922
5923 // Skip the lists associated with the current declaration, but save the
5924 // last list size that was skipped.
5925 std::advance(ListSizeCur, *NumListsCur - 1);
5926 PrevListSize = *ListSizeCur;
5927 ++ListSizeCur;
5928
5929 if (SupportsMapper)
5930 ++MapperCur;
5931 }
5932
5933 // If we didn't find any declaration, advance the iterator to after the
5934 // last component and set remaining lists to zero.
5935 if (ListSizeCur == CumulativeListSizes.end()) {
5936 this->I = End;
5937 RemainingLists = 0u;
5938 return;
5939 }
5940
5941 // Set the remaining lists with the total number of lists of the current
5942 // declaration.
5943 RemainingLists = *NumListsCur;
5944
5945 // Adjust the list size end iterator to the end of the relevant range.
5946 ListSizeEnd = ListSizeCur;
5947 std::advance(ListSizeEnd, RemainingLists);
5948
5949 // Given that the list sizes are cumulative, the index of the component
5950 // that start the list is the size of the previous list.
5951 std::advance(this->I, PrevListSize);
5952 }
5953
5954 // Return the array with the current list. The sizes are cumulative, so the
5955 // array size is the difference between the current size and previous one.
5956 std::tuple<const ValueDecl *, MappableExprComponentListRef,
5957 const ValueDecl *>
5958 operator*() const {
5959 assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
5960 const ValueDecl *Mapper = nullptr;
5961 if (SupportsMapper && *MapperCur)
5962 Mapper = cast<ValueDecl>(cast<DeclRefExpr>(*MapperCur)->getDecl());
5963 return std::make_tuple(
5964 *DeclCur,
5965 MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize),
5966 Mapper);
5967 }
5968 std::tuple<const ValueDecl *, MappableExprComponentListRef,
5969 const ValueDecl *>
5970 operator->() const {
5971 return **this;
5972 }
5973
5974 // Skip the components of the current list.
5976 assert(ListSizeCur != ListSizeEnd && RemainingLists &&
5977 "Invalid iterator!");
5978
5979 // If we don't have more lists just skip all the components. Otherwise,
5980 // advance the iterator by the number of components in the current list.
5981 if (std::next(ListSizeCur) == ListSizeEnd) {
5982 this->I = End;
5983 RemainingLists = 0;
5984 } else {
5985 std::advance(this->I, *ListSizeCur - PrevListSize);
5986 PrevListSize = *ListSizeCur;
5987
5988 // We are done with a declaration, move to the next one.
5989 if (!(--RemainingLists)) {
5990 ++DeclCur;
5991 ++NumListsCur;
5992 RemainingLists = *NumListsCur;
5993 assert(RemainingLists && "No lists in the following declaration??");
5994 }
5995 }
5996
5997 ++ListSizeCur;
5998 if (SupportsMapper)
5999 ++MapperCur;
6000 return *this;
6001 }
6002 };
6003
6005 llvm::iterator_range<const_component_lists_iterator>;
6006
6007 /// Iterators for all component lists.
6011 getComponentsRef(), SupportsMapper,
6012 SupportsMapper ? getUDMapperRefs() : std::nullopt);
6013 }
6018 getComponentsRef().end()),
6019 SupportsMapper, std::nullopt);
6020 }
6023 }
6024
6025 /// Iterators for component lists associated with the provided
6026 /// declaration.
6027 const_component_lists_iterator
6031 getComponentListSizesRef(), getComponentsRef(), SupportsMapper,
6032 SupportsMapper ? getUDMapperRefs() : std::nullopt);
6033 }
6035 return component_lists_end();
6036 }
6039 }
6040
6041 /// Iterators to access all the declarations, number of lists, list sizes, and
6042 /// components.
6044 using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>;
6045
6047 auto A = getUniqueDeclsRef();
6048 return const_all_decls_range(A.begin(), A.end());
6049 }
6050
6053 llvm::iterator_range<const_all_num_lists_iterator>;
6054
6056 auto A = getDeclNumListsRef();
6057 return const_all_num_lists_range(A.begin(), A.end());
6058 }
6059
6062 llvm::iterator_range<const_all_lists_sizes_iterator>;
6063
6065 auto A = getComponentListSizesRef();
6066 return const_all_lists_sizes_range(A.begin(), A.end());
6067 }
6068
6071 llvm::iterator_range<const_all_components_iterator>;
6072
6074 auto A = getComponentsRef();
6075 return const_all_components_range(A.begin(), A.end());
6076 }
6077
6080 using mapperlist_range = llvm::iterator_range<mapperlist_iterator>;
6082 llvm::iterator_range<mapperlist_const_iterator>;
6083
6087 return getUDMapperRefs().begin();
6088 }
6090 return getUDMapperRefs().end();
6091 }
6094 }
6097 }
6098};
6099
6100/// This represents clause 'map' in the '#pragma omp ...'
6101/// directives.
6102///
6103/// \code
6104/// #pragma omp target map(a,b)
6105/// \endcode
6106/// In this example directive '#pragma omp target' has clause 'map'
6107/// with the variables 'a' and 'b'.
6108class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
6109 private llvm::TrailingObjects<
6110 OMPMapClause, Expr *, ValueDecl *, unsigned,
6111 OMPClauseMappableExprCommon::MappableComponent> {
6112 friend class OMPClauseReader;
6114 friend OMPVarListClause;
6115 friend TrailingObjects;
6116
6117 /// Define the sizes of each trailing object array except the last one. This
6118 /// is required for TrailingObjects to work properly.
6119 size_t numTrailingObjects(OverloadToken<Expr *>) const {
6120 // There are varlist_size() of expressions, and varlist_size() of
6121 // user-defined mappers.
6122 return 2 * varlist_size() + 1;
6123 }
6124 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
6125 return getUniqueDeclarationsNum();
6126 }
6127 size_t numTrailingObjects(OverloadToken<unsigned>) const {
6129 }
6130
6131private:
6132 /// Map-type-modifiers for the 'map' clause.
6137
6138 /// Location of map-type-modifiers for the 'map' clause.
6139 SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers];
6140
6141 /// Map type for the 'map' clause.
6143
6144 /// Is this an implicit map type or not.
6145 bool MapTypeIsImplicit = false;
6146
6147 /// Location of the map type.
6148 SourceLocation MapLoc;
6149
6150 /// Colon location.
6151 SourceLocation ColonLoc;
6152
6153 /// Build a clause for \a NumVars listed expressions, \a
6154 /// NumUniqueDeclarations declarations, \a NumComponentLists total component
6155 /// lists, and \a NumComponents total expression components.
6156 ///
6157 /// \param MapModifiers Map-type-modifiers.
6158 /// \param MapModifiersLoc Locations of map-type-modifiers.
6159 /// \param MapperQualifierLoc C++ nested name specifier for the associated
6160 /// user-defined mapper.
6161 /// \param MapperIdInfo The identifier of associated user-defined mapper.
6162 /// \param MapType Map type.
6163 /// \param MapTypeIsImplicit Map type is inferred implicitly.
6164 /// \param MapLoc Location of the map type.
6165 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6166 /// StartLoc: starting location of the clause (the clause keyword); 2)
6167 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6168 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6169 /// NumVars: number of expressions listed in this clause; 2)
6170 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6171 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6172 /// NumComponents: total number of expression components in the clause.
6173 explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers,
6174 ArrayRef<SourceLocation> MapModifiersLoc,
6175 NestedNameSpecifierLoc MapperQualifierLoc,
6176 DeclarationNameInfo MapperIdInfo,
6177 OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
6178 SourceLocation MapLoc, const OMPVarListLocTy &Locs,
6179 const OMPMappableExprListSizeTy &Sizes)
6180 : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes,
6181 /*SupportsMapper=*/true, &MapperQualifierLoc,
6182 &MapperIdInfo),
6183 MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {
6184 assert(std::size(MapTypeModifiers) == MapModifiers.size() &&
6185 "Unexpected number of map type modifiers.");
6186 llvm::copy(MapModifiers, std::begin(MapTypeModifiers));
6187
6188 assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() &&
6189 "Unexpected number of map type modifier locations.");
6190 llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc));
6191 }
6192
6193 /// Build an empty clause.
6194 ///
6195 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6196 /// NumVars: number of expressions listed in this clause; 2)
6197 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6198 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6199 /// NumComponents: total number of expression components in the clause.
6200 explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes)
6201 : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes,
6202 /*SupportsMapper=*/true) {}
6203
6204 /// Set map-type-modifier for the clause.
6205 ///
6206 /// \param I index for map-type-modifier.
6207 /// \param T map-type-modifier for the clause.
6208 void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) {
6209 assert(I < NumberOfOMPMapClauseModifiers &&
6210 "Unexpected index to store map type modifier, exceeds array size.");
6211 MapTypeModifiers[I] = T;
6212 }
6213
6214 /// Set location for the map-type-modifier.
6215 ///
6216 /// \param I index for map-type-modifier location.
6217 /// \param TLoc map-type-modifier location.
6218 void setMapTypeModifierLoc(unsigned I, SourceLocation TLoc) {
6219 assert(I < NumberOfOMPMapClauseModifiers &&
6220 "Index to store map type modifier location exceeds array size.");
6221 MapTypeModifiersLoc[I] = TLoc;
6222 }
6223
6224 /// Set type for the clause.
6225 ///
6226 /// \param T Type for the clause.
6227 void setMapType(OpenMPMapClauseKind T) { MapType = T; }
6228
6229 /// Set type location.
6230 ///
6231 /// \param TLoc Type location.
6232 void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
6233
6234 /// Set colon location.
6235 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
6236
6237 /// Set iterator modifier.
6238 void setIteratorModifier(Expr *IteratorModifier) {
6239 getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier;
6240 }
6241
6242public:
6243 /// Creates clause with a list of variables \a VL.
6244 ///
6245 /// \param C AST context.
6246 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6247 /// StartLoc: starting location of the clause (the clause keyword); 2)
6248 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6249 /// \param Vars The original expression used in the clause.
6250 /// \param Declarations Declarations used in the clause.
6251 /// \param ComponentLists Component lists used in the clause.
6252 /// \param UDMapperRefs References to user-defined mappers associated with
6253 /// expressions used in the clause.
6254 /// \param IteratorModifier Iterator modifier.
6255 /// \param MapModifiers Map-type-modifiers.
6256 /// \param MapModifiersLoc Location of map-type-modifiers.
6257 /// \param UDMQualifierLoc C++ nested name specifier for the associated
6258 /// user-defined mapper.
6259 /// \param MapperId The identifier of associated user-defined mapper.
6260 /// \param Type Map type.
6261 /// \param TypeIsImplicit Map type is inferred implicitly.
6262 /// \param TypeLoc Location of the map type.
6263 static OMPMapClause *
6264 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
6265 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
6266 MappableExprComponentListsRef ComponentLists,
6267 ArrayRef<Expr *> UDMapperRefs, Expr *IteratorModifier,
6268 ArrayRef<OpenMPMapModifierKind> MapModifiers,
6269 ArrayRef<SourceLocation> MapModifiersLoc,
6270 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
6271 OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc);
6272
6273 /// Creates an empty clause with the place for \a NumVars original
6274 /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
6275 /// lists, and \a NumComponents expression components.
6276 ///
6277 /// \param C AST context.
6278 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6279 /// NumVars: number of expressions listed in this clause; 2)
6280 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6281 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6282 /// NumComponents: total number of expression components in the clause.
6283 static OMPMapClause *CreateEmpty(const ASTContext &C,
6284 const OMPMappableExprListSizeTy &Sizes);
6285
6286 /// Fetches Expr * of iterator modifier.
6288 return getTrailingObjects<Expr *>()[2 * varlist_size()];
6289 }
6290
6291 /// Fetches mapping kind for the clause.
6292 OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
6293
6294 /// Is this an implicit map type?
6295 /// We have to capture 'IsMapTypeImplicit' from the parser for more
6296 /// informative error messages. It helps distinguish map(r) from
6297 /// map(tofrom: r), which is important to print more helpful error
6298 /// messages for some target directives.
6299 bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
6300
6301 /// Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
6302 ///
6303 /// \param Cnt index for map-type-modifier.
6304 OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY {
6305 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6306 "Requested modifier exceeds the total number of modifiers.");
6307 return MapTypeModifiers[Cnt];
6308 }
6309
6310 /// Fetches the map-type-modifier location at 'Cnt' index of array of
6311 /// modifiers' locations.
6312 ///
6313 /// \param Cnt index for map-type-modifier location.
6314 SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY {
6315 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6316 "Requested modifier location exceeds total number of modifiers.");
6317 return MapTypeModifiersLoc[Cnt];
6318 }
6319
6320 /// Fetches ArrayRef of map-type-modifiers.
6322 return llvm::ArrayRef(MapTypeModifiers);
6323 }
6324
6325 /// Fetches ArrayRef of location of map-type-modifiers.
6327 return llvm::ArrayRef(MapTypeModifiersLoc);
6328 }
6329
6330 /// Fetches location of clause mapping kind.
6331 SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
6332
6333 /// Get colon location.
6334 SourceLocation getColonLoc() const { return ColonLoc; }
6335
6337 return child_range(
6338 reinterpret_cast<Stmt **>(varlist_begin()),
6339 reinterpret_cast<Stmt **>(varlist_end()));
6340 }
6341
6343 auto Children = const_cast<OMPMapClause *>(this)->children();
6344 return const_child_range(Children.begin(), Children.end());
6345 }
6346
6348 if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom)
6349 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6350 reinterpret_cast<Stmt **>(varlist_end()));
6352 }
6354 auto Children = const_cast<OMPMapClause *>(this)->used_children();
6355 return const_child_range(Children.begin(), Children.end());
6356 }
6357
6358
6359 static bool classof(const OMPClause *T) {
6360 return T->getClauseKind() == llvm::omp::OMPC_map;
6361 }
6362};
6363
6364/// This represents 'num_teams' clause in the '#pragma omp ...'
6365/// directive.
6366///
6367/// \code
6368/// #pragma omp teams num_teams(n)
6369/// \endcode
6370/// In this example directive '#pragma omp teams' has clause 'num_teams'
6371/// with single expression 'n'.
6372///
6373/// When 'ompx_bare' clause exists on a 'target' directive, 'num_teams' clause
6374/// can accept up to three expressions.
6375///
6376/// \code
6377/// #pragma omp target teams ompx_bare num_teams(x, y, z)
6378/// \endcode
6380 : public OMPVarListClause<OMPNumTeamsClause>,
6381 public OMPClauseWithPreInit,
6382 private llvm::TrailingObjects<OMPNumTeamsClause, Expr *> {
6383 friend OMPVarListClause;
6384 friend TrailingObjects;
6385
6386 /// Location of '('.
6387 SourceLocation LParenLoc;
6388
6390 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
6391 : OMPVarListClause(llvm::omp::OMPC_num_teams, StartLoc, LParenLoc, EndLoc,
6392 N),
6393 OMPClauseWithPreInit(this) {}
6394
6395 /// Build an empty clause.
6396 OMPNumTeamsClause(unsigned N)
6397 : OMPVarListClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6399 OMPClauseWithPreInit(this) {}
6400
6401public:
6402 /// Creates clause with a list of variables \a VL.
6403 ///
6404 /// \param C AST context.
6405 /// \param StartLoc Starting location of the clause.
6406 /// \param LParenLoc Location of '('.
6407 /// \param EndLoc Ending location of the clause.
6408 /// \param VL List of references to the variables.
6409 /// \param PreInit
6410 static OMPNumTeamsClause *
6411 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6412 SourceLocation StartLoc, SourceLocation LParenLoc,
6413 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6414
6415 /// Creates an empty clause with \a N variables.
6416 ///
6417 /// \param C AST context.
6418 /// \param N The number of variables.
6419 static OMPNumTeamsClause *CreateEmpty(const ASTContext &C, unsigned N);
6420
6421 /// Sets the location of '('.
6422 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6423
6424 /// Returns the location of '('.
6425 SourceLocation getLParenLoc() const { return LParenLoc; }
6426
6427 /// Return NumTeams expressions.
6429
6430 /// Return NumTeams expressions.
6432 return const_cast<OMPNumTeamsClause *>(this)->getNumTeams();
6433 }
6434
6436 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6437 reinterpret_cast<Stmt **>(varlist_end()));
6438 }
6439
6441 auto Children = const_cast<OMPNumTeamsClause *>(this)->children();
6442 return const_child_range(Children.begin(), Children.end());
6443 }
6444
6447 }
6450 }
6451
6452 static bool classof(const OMPClause *T) {
6453 return T->getClauseKind() == llvm::omp::OMPC_num_teams;
6454 }
6455};
6456
6457/// This represents 'thread_limit' clause in the '#pragma omp ...'
6458/// directive.
6459///
6460/// \code
6461/// #pragma omp teams thread_limit(n)
6462/// \endcode
6463/// In this example directive '#pragma omp teams' has clause 'thread_limit'
6464/// with single expression 'n'.
6465///
6466/// When 'ompx_bare' clause exists on a 'target' directive, 'thread_limit'
6467/// clause can accept up to three expressions.
6468///
6469/// \code
6470/// #pragma omp target teams ompx_bare thread_limit(x, y, z)
6471/// \endcode
6473 : public OMPVarListClause<OMPThreadLimitClause>,
6474 public OMPClauseWithPreInit,
6475 private llvm::TrailingObjects<OMPThreadLimitClause, Expr *> {
6476 friend OMPVarListClause;
6477 friend TrailingObjects;
6478
6479 /// Location of '('.
6480 SourceLocation LParenLoc;
6481
6483 SourceLocation LParenLoc, SourceLocation EndLoc,
6484 unsigned N)
6485 : OMPVarListClause(llvm::omp::OMPC_thread_limit, StartLoc, LParenLoc,
6486 EndLoc, N),
6487 OMPClauseWithPreInit(this) {}
6488
6489 /// Build an empty clause.
6490 OMPThreadLimitClause(unsigned N)
6491 : OMPVarListClause(llvm::omp::OMPC_thread_limit, SourceLocation(),
6493 OMPClauseWithPreInit(this) {}
6494
6495public:
6496 /// Creates clause with a list of variables \a VL.
6497 ///
6498 /// \param C AST context.
6499 /// \param StartLoc Starting location of the clause.
6500 /// \param LParenLoc Location of '('.
6501 /// \param EndLoc Ending location of the clause.
6502 /// \param VL List of references to the variables.
6503 /// \param PreInit
6504 static OMPThreadLimitClause *
6505 Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6506 SourceLocation StartLoc, SourceLocation LParenLoc,
6507 SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6508
6509 /// Creates an empty clause with \a N variables.
6510 ///
6511 /// \param C AST context.
6512 /// \param N The number of variables.
6513 static OMPThreadLimitClause *CreateEmpty(const ASTContext &C, unsigned N);
6514
6515 /// Sets the location of '('.
6516 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6517
6518 /// Returns the location of '('.
6519 SourceLocation getLParenLoc() const { return LParenLoc; }
6520
6521 /// Return ThreadLimit expressions.
6523
6524 /// Return ThreadLimit expressions.
6526 return const_cast<OMPThreadLimitClause *>(this)->getThreadLimit();
6527 }
6528
6530 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6531 reinterpret_cast<Stmt **>(varlist_end()));
6532 }
6533
6535 auto Children = const_cast<OMPThreadLimitClause *>(this)->children();
6536 return const_child_range(Children.begin(), Children.end());
6537 }
6538
6541 }
6544 }
6545
6546 static bool classof(const OMPClause *T) {
6547 return T->getClauseKind() == llvm::omp::OMPC_thread_limit;
6548 }
6549};
6550
6551/// This represents 'priority' clause in the '#pragma omp ...'
6552/// directive.
6553///
6554/// \code
6555/// #pragma omp task priority(n)
6556/// \endcode
6557/// In this example directive '#pragma omp teams' has clause 'priority' with
6558/// single expression 'n'.
6560 friend class OMPClauseReader;
6561
6562 /// Location of '('.
6563 SourceLocation LParenLoc;
6564
6565 /// Priority number.
6566 Stmt *Priority = nullptr;
6567
6568 /// Set the Priority number.
6569 ///
6570 /// \param E Priority number.
6571 void setPriority(Expr *E) { Priority = E; }
6572
6573public:
6574 /// Build 'priority' clause.
6575 ///
6576 /// \param Priority Expression associated with this clause.
6577 /// \param HelperPriority Helper priority for the construct.
6578 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6579 /// clause must be captured.
6580 /// \param StartLoc Starting location of the clause.
6581 /// \param LParenLoc Location of '('.
6582 /// \param EndLoc Ending location of the clause.
6584 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
6585 SourceLocation LParenLoc, SourceLocation EndLoc)
6586 : OMPClause(llvm::omp::OMPC_priority, StartLoc, EndLoc),
6587 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Priority(Priority) {
6588 setPreInitStmt(HelperPriority, CaptureRegion);
6589 }
6590
6591 /// Build an empty clause.
6593 : OMPClause(llvm::omp::OMPC_priority, SourceLocation(), SourceLocation()),
6594 OMPClauseWithPreInit(this) {}
6595
6596 /// Sets the location of '('.
6597 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6598
6599 /// Returns the location of '('.
6600 SourceLocation getLParenLoc() const { return LParenLoc; }
6601
6602 /// Return Priority number.
6603 Expr *getPriority() { return cast<Expr>(Priority); }
6604
6605 /// Return Priority number.
6606 Expr *getPriority() const { return cast<Expr>(Priority); }
6607
6609
6611 return const_child_range(&Priority, &Priority + 1);
6612 }
6613
6616 auto Children = const_cast<OMPPriorityClause *>(this)->used_children();
6617 return const_child_range(Children.begin(), Children.end());
6618 }
6619
6620 static bool classof(const OMPClause *T) {
6621 return T->getClauseKind() == llvm::omp::OMPC_priority;
6622 }
6623};
6624
6625/// This represents 'grainsize' clause in the '#pragma omp ...'
6626/// directive.
6627///
6628/// \code
6629/// #pragma omp taskloop grainsize(4)
6630/// \endcode
6631/// In this example directive '#pragma omp taskloop' has clause 'grainsize'
6632/// with single expression '4'.
6634 friend class OMPClauseReader;
6635
6636 /// Location of '('.
6637 SourceLocation LParenLoc;
6638
6639 /// Modifiers for 'grainsize' clause.
6641
6642 /// Location of the modifier.
6643 SourceLocation ModifierLoc;
6644
6645 /// Safe iteration space distance.
6646 Stmt *Grainsize = nullptr;
6647
6648 /// Set safelen.
6649 void setGrainsize(Expr *Size) { Grainsize = Size; }
6650
6651 /// Sets modifier.
6652 void setModifier(OpenMPGrainsizeClauseModifier M) { Modifier = M; }
6653
6654 /// Sets modifier location.
6655 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
6656
6657public:
6658 /// Build 'grainsize' clause.
6659 ///
6660 /// \param Modifier Clause modifier.
6661 /// \param Size Expression associated with this clause.
6662 /// \param HelperSize Helper grainsize for the construct.
6663 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6664 /// clause must be captured.
6665 /// \param StartLoc Starting location of the clause.
6666 /// \param ModifierLoc Modifier location.
6667 /// \param LParenLoc Location of '('.
6668 /// \param EndLoc Ending location of the clause.
6670 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
6671 SourceLocation StartLoc, SourceLocation LParenLoc,
6672 SourceLocation ModifierLoc, SourceLocation EndLoc)
6673 : OMPClause(llvm::omp::OMPC_grainsize, StartLoc, EndLoc),
6674 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
6675 ModifierLoc(ModifierLoc), Grainsize(Size) {
6676 setPreInitStmt(HelperSize, CaptureRegion);
6677 }
6678
6679 /// Build an empty clause.
6681 : OMPClause(llvm::omp::OMPC_grainsize, SourceLocation(),
6682 SourceLocation()),
6683 OMPClauseWithPreInit(this) {}
6684
6685 /// Sets the location of '('.
6686 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6687
6688 /// Returns the location of '('.
6689 SourceLocation getLParenLoc() const { return LParenLoc; }
6690
6691 /// Return safe iteration space distance.
6692 Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
6693
6694 /// Gets modifier.
6695 OpenMPGrainsizeClauseModifier getModifier() const { return Modifier; }
6696
6697 /// Gets modifier location.
6698 SourceLocation getModifierLoc() const { return ModifierLoc; }
6699
6700 child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
6701
6703 return const_child_range(&Grainsize, &Grainsize + 1);
6704 }
6705
6708 auto Children = const_cast<OMPGrainsizeClause *>(this)->used_children();
6709 return const_child_range(Children.begin(), Children.end());
6710 }
6711
6712 static bool classof(const OMPClause *T) {
6713 return T->getClauseKind() == llvm::omp::OMPC_grainsize;
6714 }
6715};
6716
6717/// This represents 'nogroup' clause in the '#pragma omp ...' directive.
6718///
6719/// \code
6720/// #pragma omp taskloop nogroup
6721/// \endcode
6722/// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
6724public:
6725 /// Build 'nogroup' clause.
6726 ///
6727 /// \param StartLoc Starting location of the clause.
6728 /// \param EndLoc Ending location of the clause.
6730 : OMPClause(llvm::omp::OMPC_nogroup, StartLoc, EndLoc) {}
6731
6732 /// Build an empty clause.
6734 : OMPClause(llvm::omp::OMPC_nogroup, SourceLocation(), SourceLocation()) {
6735 }
6736
6739 }
6740
6743 }
6744
6747 }
6750 }
6751
6752 static bool classof(const OMPClause *T) {
6753 return T->getClauseKind() == llvm::omp::OMPC_nogroup;
6754 }
6755};
6756
6757/// This represents 'num_tasks' clause in the '#pragma omp ...'
6758/// directive.
6759///
6760/// \code
6761/// #pragma omp taskloop num_tasks(4)
6762/// \endcode
6763/// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
6764/// with single expression '4'.
6766 friend class OMPClauseReader;
6767
6768 /// Location of '('.
6769 SourceLocation LParenLoc;
6770
6771 /// Modifiers for 'num_tasks' clause.
6773
6774 /// Location of the modifier.
6775 SourceLocation ModifierLoc;
6776
6777 /// Safe iteration space distance.
6778 Stmt *NumTasks = nullptr;
6779
6780 /// Set safelen.
6781 void setNumTasks(Expr *Size) { NumTasks = Size; }
6782
6783 /// Sets modifier.
6784 void setModifier(OpenMPNumTasksClauseModifier M) { Modifier = M; }
6785
6786 /// Sets modifier location.
6787 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
6788
6789public:
6790 /// Build 'num_tasks' clause.
6791 ///
6792 /// \param Modifier Clause modifier.
6793 /// \param Size Expression associated with this clause.
6794 /// \param HelperSize Helper grainsize for the construct.
6795 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6796 /// clause must be captured.
6797 /// \param StartLoc Starting location of the clause.
6798 /// \param EndLoc Ending location of the clause.
6799 /// \param ModifierLoc Modifier location.
6800 /// \param LParenLoc Location of '('.
6802 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
6803 SourceLocation StartLoc, SourceLocation LParenLoc,
6804 SourceLocation ModifierLoc, SourceLocation EndLoc)
6805 : OMPClause(llvm::omp::OMPC_num_tasks, StartLoc, EndLoc),
6806 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
6807 ModifierLoc(ModifierLoc), NumTasks(Size) {
6808 setPreInitStmt(HelperSize, CaptureRegion);
6809 }
6810
6811 /// Build an empty clause.
6813 : OMPClause(llvm::omp::OMPC_num_tasks, SourceLocation(),
6814 SourceLocation()),
6815 OMPClauseWithPreInit(this) {}
6816
6817 /// Sets the location of '('.
6818 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6819
6820 /// Returns the location of '('.
6821 SourceLocation getLParenLoc() const { return LParenLoc; }
6822
6823 /// Return safe iteration space distance.
6824 Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
6825
6826 /// Gets modifier.
6827 OpenMPNumTasksClauseModifier getModifier() const { return Modifier; }
6828
6829 /// Gets modifier location.
6830 SourceLocation getModifierLoc() const { return ModifierLoc; }
6831
6832 child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
6833
6835 return const_child_range(&NumTasks, &NumTasks + 1);
6836 }
6837
6840 auto Children = const_cast<OMPNumTasksClause *>(this)->used_children();
6841 return const_child_range(Children.begin(), Children.end());
6842 }
6843
6844 static bool classof(const OMPClause *T) {
6845 return T->getClauseKind() == llvm::omp::OMPC_num_tasks;
6846 }
6847};
6848
6849/// This represents 'hint' clause in the '#pragma omp ...' directive.
6850///
6851/// \code
6852/// #pragma omp critical (name) hint(6)
6853/// \endcode
6854/// In this example directive '#pragma omp critical' has name 'name' and clause
6855/// 'hint' with argument '6'.
6856class OMPHintClause : public OMPClause {
6857 friend class OMPClauseReader;
6858
6859 /// Location of '('.
6860 SourceLocation LParenLoc;
6861
6862 /// Hint expression of the 'hint' clause.
6863 Stmt *Hint = nullptr;
6864
6865 /// Set hint expression.
6866 void setHint(Expr *H) { Hint = H; }
6867
6868public:
6869 /// Build 'hint' clause with expression \a Hint.
6870 ///
6871 /// \param Hint Hint expression.
6872 /// \param StartLoc Starting location of the clause.
6873 /// \param LParenLoc Location of '('.
6874 /// \param EndLoc Ending location of the clause.
6876 SourceLocation EndLoc)
6877 : OMPClause(llvm::omp::OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
6878 Hint(Hint) {}
6879
6880 /// Build an empty clause.
6882 : OMPClause(llvm::omp::OMPC_hint, SourceLocation(), SourceLocation()) {}
6883
6884 /// Sets the location of '('.
6885 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6886
6887 /// Returns the location of '('.
6888 SourceLocation getLParenLoc() const { return LParenLoc; }
6889
6890 /// Returns number of threads.
6891 Expr *getHint() const { return cast_or_null<Expr>(Hint); }
6892
6893 child_range children() { return child_range(&Hint, &Hint + 1); }
6894
6896 return const_child_range(&Hint, &Hint + 1);
6897 }
6898
6901 }
6904 }
6905
6906 static bool classof(const OMPClause *T) {
6907 return T->getClauseKind() == llvm::omp::OMPC_hint;
6908 }
6909};
6910
6911/// This represents 'dist_schedule' clause in the '#pragma omp ...'
6912/// directive.
6913///
6914/// \code
6915/// #pragma omp distribute dist_schedule(static, 3)
6916/// \endcode
6917/// In this example directive '#pragma omp distribute' has 'dist_schedule'
6918/// clause with arguments 'static' and '3'.
6920 friend class OMPClauseReader;
6921
6922 /// Location of '('.
6923 SourceLocation LParenLoc;
6924
6925 /// A kind of the 'schedule' clause.
6927
6928 /// Start location of the schedule kind in source code.
6929 SourceLocation KindLoc;
6930
6931 /// Location of ',' (if any).
6932 SourceLocation CommaLoc;
6933
6934 /// Chunk size.
6935 Expr *ChunkSize = nullptr;
6936
6937 /// Set schedule kind.
6938 ///
6939 /// \param K Schedule kind.
6940 void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
6941
6942 /// Sets the location of '('.
6943 ///
6944 /// \param Loc Location of '('.
6945 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6946
6947 /// Set schedule kind start location.
6948 ///
6949 /// \param KLoc Schedule kind location.
6950 void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
6951
6952 /// Set location of ','.
6953 ///
6954 /// \param Loc Location of ','.
6955 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
6956
6957 /// Set chunk size.
6958 ///
6959 /// \param E Chunk size.
6960 void setChunkSize(Expr *E) { ChunkSize = E; }
6961
6962public:
6963 /// Build 'dist_schedule' clause with schedule kind \a Kind and chunk
6964 /// size expression \a ChunkSize.
6965 ///
6966 /// \param StartLoc Starting location of the clause.
6967 /// \param LParenLoc Location of '('.
6968 /// \param KLoc Starting location of the argument.
6969 /// \param CommaLoc Location of ','.
6970 /// \param EndLoc Ending location of the clause.
6971 /// \param Kind DistSchedule kind.
6972 /// \param ChunkSize Chunk size.
6973 /// \param HelperChunkSize Helper chunk size for combined directives.
6975 SourceLocation KLoc, SourceLocation CommaLoc,
6976 SourceLocation EndLoc,
6978 Stmt *HelperChunkSize)
6979 : OMPClause(llvm::omp::OMPC_dist_schedule, StartLoc, EndLoc),
6980 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
6981 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
6982 setPreInitStmt(HelperChunkSize);
6983 }
6984
6985 /// Build an empty clause.
6987 : OMPClause(llvm::omp::OMPC_dist_schedule, SourceLocation(),
6988 SourceLocation()),
6989 OMPClauseWithPreInit(this) {}
6990
6991 /// Get kind of the clause.
6993
6994 /// Get location of '('.
6995 SourceLocation getLParenLoc() { return LParenLoc; }
6996
6997 /// Get kind location.
6999
7000 /// Get location of ','.
7001 SourceLocation getCommaLoc() { return CommaLoc; }
7002
7003 /// Get chunk size.
7004 Expr *getChunkSize() { return ChunkSize; }
7005
7006 /// Get chunk size.
7007 const Expr *getChunkSize() const { return ChunkSize; }
7008
7010 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
7011 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
7012 }
7013
7015 auto Children = const_cast<OMPDistScheduleClause *>(this)->children();
7016 return const_child_range(Children.begin(), Children.end());
7017 }
7018
7021 }
7024 }
7025
7026 static bool classof(const OMPClause *T) {
7027 return T->getClauseKind() == llvm::omp::OMPC_dist_schedule;
7028 }
7029};
7030
7031/// This represents 'defaultmap' clause in the '#pragma omp ...' directive.
7032///
7033/// \code
7034/// #pragma omp target defaultmap(tofrom: scalar)
7035/// \endcode
7036/// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
7037/// 'scalar' with modifier 'tofrom'.
7039 friend class OMPClauseReader;
7040
7041 /// Location of '('.
7042 SourceLocation LParenLoc;
7043
7044 /// Modifiers for 'defaultmap' clause.
7046
7047 /// Locations of modifiers.
7048 SourceLocation ModifierLoc;
7049
7050 /// A kind of the 'defaultmap' clause.
7052
7053 /// Start location of the defaultmap kind in source code.
7054 SourceLocation KindLoc;
7055
7056 /// Set defaultmap kind.
7057 ///
7058 /// \param K Defaultmap kind.
7059 void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
7060
7061 /// Set the defaultmap modifier.
7062 ///
7063 /// \param M Defaultmap modifier.
7064 void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
7065 Modifier = M;
7066 }
7067
7068 /// Set location of the defaultmap modifier.
7069 void setDefaultmapModifierLoc(SourceLocation Loc) {
7070 ModifierLoc = Loc;
7071 }
7072
7073 /// Sets the location of '('.
7074 ///
7075 /// \param Loc Location of '('.
7076 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7077
7078 /// Set defaultmap kind start location.
7079 ///
7080 /// \param KLoc Defaultmap kind location.
7081 void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
7082
7083public:
7084 /// Build 'defaultmap' clause with defaultmap kind \a Kind
7085 ///
7086 /// \param StartLoc Starting location of the clause.
7087 /// \param LParenLoc Location of '('.
7088 /// \param KLoc Starting location of the argument.
7089 /// \param EndLoc Ending location of the clause.
7090 /// \param Kind Defaultmap kind.
7091 /// \param M The modifier applied to 'defaultmap' clause.
7092 /// \param MLoc Location of the modifier
7094 SourceLocation MLoc, SourceLocation KLoc,
7097 : OMPClause(llvm::omp::OMPC_defaultmap, StartLoc, EndLoc),
7098 LParenLoc(LParenLoc), Modifier(M), ModifierLoc(MLoc), Kind(Kind),
7099 KindLoc(KLoc) {}
7100
7101 /// Build an empty clause.
7103 : OMPClause(llvm::omp::OMPC_defaultmap, SourceLocation(),
7104 SourceLocation()) {}
7105
7106 /// Get kind of the clause.
7108
7109 /// Get the modifier of the clause.
7111 return Modifier;
7112 }
7113
7114 /// Get location of '('.
7115 SourceLocation getLParenLoc() { return LParenLoc; }
7116
7117 /// Get kind location.
7119
7120 /// Get the modifier location.
7122 return ModifierLoc;
7123 }
7124
7127 }
7128
7131 }
7132
7135 }
7138 }
7139
7140 static bool classof(const OMPClause *T) {
7141 return T->getClauseKind() == llvm::omp::OMPC_defaultmap;
7142 }
7143};
7144
7145/// This represents clause 'to' in the '#pragma omp ...'
7146/// directives.
7147///
7148/// \code
7149/// #pragma omp target update to(a,b)
7150/// \endcode
7151/// In this example directive '#pragma omp target update' has clause 'to'
7152/// with the variables 'a' and 'b'.
7153class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
7154 private llvm::TrailingObjects<
7155 OMPToClause, Expr *, ValueDecl *, unsigned,
7156 OMPClauseMappableExprCommon::MappableComponent> {
7157 friend class OMPClauseReader;
7159 friend OMPVarListClause;
7160 friend TrailingObjects;
7161
7162 /// Motion-modifiers for the 'to' clause.
7165
7166 /// Location of motion-modifiers for the 'to' clause.
7167 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7168
7169 /// Colon location.
7170 SourceLocation ColonLoc;
7171
7172 /// Build clause with number of variables \a NumVars.
7173 ///
7174 /// \param TheMotionModifiers Motion-modifiers.
7175 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7176 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7177 /// user-defined mapper.
7178 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7179 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7180 /// StartLoc: starting location of the clause (the clause keyword); 2)
7181 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7182 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7183 /// NumVars: number of expressions listed in this clause; 2)
7184 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7185 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7186 /// NumComponents: total number of expression components in the clause.
7187 explicit OMPToClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7188 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7189 NestedNameSpecifierLoc MapperQualifierLoc,
7190 DeclarationNameInfo MapperIdInfo,
7191 const OMPVarListLocTy &Locs,
7192 const OMPMappableExprListSizeTy &Sizes)
7193 : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
7194 /*SupportsMapper=*/true, &MapperQualifierLoc,
7195 &MapperIdInfo) {
7196 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7197 "Unexpected number of motion modifiers.");
7198 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7199
7200 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7201 "Unexpected number of motion modifier locations.");
7202 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7203 }
7204
7205 /// Build an empty clause.
7206 ///
7207 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7208 /// NumVars: number of expressions listed in this clause; 2)
7209 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7210 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7211 /// NumComponents: total number of expression components in the clause.
7212 explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes)
7213 : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
7214 /*SupportsMapper=*/true) {}
7215
7216 /// Set motion-modifier for the clause.
7217 ///
7218 /// \param I index for motion-modifier.
7219 /// \param T motion-modifier for the clause.
7220 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7221 assert(I < NumberOfOMPMotionModifiers &&
7222 "Unexpected index to store motion modifier, exceeds array size.");
7223 MotionModifiers[I] = T;
7224 }
7225
7226 /// Set location for the motion-modifier.
7227 ///
7228 /// \param I index for motion-modifier location.
7229 /// \param TLoc motion-modifier location.
7230 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7231 assert(I < NumberOfOMPMotionModifiers &&
7232 "Index to store motion modifier location exceeds array size.");
7233 MotionModifiersLoc[I] = TLoc;
7234 }
7235
7236 /// Set colon location.
7237 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7238
7239 /// Define the sizes of each trailing object array except the last one. This
7240 /// is required for TrailingObjects to work properly.
7241 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7242 // There are varlist_size() of expressions, and varlist_size() of
7243 // user-defined mappers.
7244 return 2 * varlist_size();
7245 }
7246 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7247 return getUniqueDeclarationsNum();
7248 }
7249 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7251 }
7252
7253public:
7254 /// Creates clause with a list of variables \a Vars.
7255 ///
7256 /// \param C AST context.
7257 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7258 /// StartLoc: starting location of the clause (the clause keyword); 2)
7259 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7260 /// \param Vars The original expression used in the clause.
7261 /// \param Declarations Declarations used in the clause.
7262 /// \param ComponentLists Component lists used in the clause.
7263 /// \param MotionModifiers Motion-modifiers.
7264 /// \param MotionModifiersLoc Location of motion-modifiers.
7265 /// \param UDMapperRefs References to user-defined mappers associated with
7266 /// expressions used in the clause.
7267 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7268 /// user-defined mapper.
7269 /// \param MapperId The identifier of associated user-defined mapper.
7270 static OMPToClause *Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7271 ArrayRef<Expr *> Vars,
7272 ArrayRef<ValueDecl *> Declarations,
7273 MappableExprComponentListsRef ComponentLists,
7274 ArrayRef<Expr *> UDMapperRefs,
7275 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7276 ArrayRef<SourceLocation> MotionModifiersLoc,
7277 NestedNameSpecifierLoc UDMQualifierLoc,
7278 DeclarationNameInfo MapperId);
7279
7280 /// Creates an empty clause with the place for \a NumVars variables.
7281 ///
7282 /// \param C AST context.
7283 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7284 /// NumVars: number of expressions listed in this clause; 2)
7285 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7286 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7287 /// NumComponents: total number of expression components in the clause.
7288 static OMPToClause *CreateEmpty(const ASTContext &C,
7289 const OMPMappableExprListSizeTy &Sizes);
7290
7291 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7292 ///
7293 /// \param Cnt index for motion-modifier.
7294 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7295 assert(Cnt < NumberOfOMPMotionModifiers &&
7296 "Requested modifier exceeds the total number of modifiers.");
7297 return MotionModifiers[Cnt];
7298 }
7299
7300 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7301 /// locations.
7302 ///
7303 /// \param Cnt index for motion-modifier location.
7304 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7305 assert(Cnt < NumberOfOMPMotionModifiers &&
7306 "Requested modifier location exceeds total number of modifiers.");
7307 return MotionModifiersLoc[Cnt];
7308 }
7309
7310 /// Fetches ArrayRef of motion-modifiers.
7312 return llvm::ArrayRef(MotionModifiers);
7313 }
7314
7315 /// Fetches ArrayRef of location of motion-modifiers.
7317 return llvm::ArrayRef(MotionModifiersLoc);
7318 }
7319
7320 /// Get colon location.
7321 SourceLocation getColonLoc() const { return ColonLoc; }
7322
7324 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7325 reinterpret_cast<Stmt **>(varlist_end()));
7326 }
7327
7329 auto Children = const_cast<OMPToClause *>(this)->children();
7330 return const_child_range(Children.begin(), Children.end());
7331 }
7332
7335 }
7338 }
7339
7340 static bool classof(const OMPClause *T) {
7341 return T->getClauseKind() == llvm::omp::OMPC_to;
7342 }
7343};
7344
7345/// This represents clause 'from' in the '#pragma omp ...'
7346/// directives.
7347///
7348/// \code
7349/// #pragma omp target update from(a,b)
7350/// \endcode
7351/// In this example directive '#pragma omp target update' has clause 'from'
7352/// with the variables 'a' and 'b'.
7353class OMPFromClause final
7354 : public OMPMappableExprListClause<OMPFromClause>,
7355 private llvm::TrailingObjects<
7356 OMPFromClause, Expr *, ValueDecl *, unsigned,
7357 OMPClauseMappableExprCommon::MappableComponent> {
7358 friend class OMPClauseReader;
7360 friend OMPVarListClause;
7361 friend TrailingObjects;
7362
7363 /// Motion-modifiers for the 'from' clause.
7366
7367 /// Location of motion-modifiers for the 'from' clause.
7368 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7369
7370 /// Colon location.
7371 SourceLocation ColonLoc;
7372
7373 /// Build clause with number of variables \a NumVars.
7374 ///
7375 /// \param TheMotionModifiers Motion-modifiers.
7376 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7377 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7378 /// user-defined mapper.
7379 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7380 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7381 /// StartLoc: starting location of the clause (the clause keyword); 2)
7382 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7383 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7384 /// NumVars: number of expressions listed in this clause; 2)
7385 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7386 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7387 /// NumComponents: total number of expression components in the clause.
7388 explicit OMPFromClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7389 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7390 NestedNameSpecifierLoc MapperQualifierLoc,
7391 DeclarationNameInfo MapperIdInfo,
7392 const OMPVarListLocTy &Locs,
7393 const OMPMappableExprListSizeTy &Sizes)
7394 : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes,
7395 /*SupportsMapper=*/true, &MapperQualifierLoc,
7396 &MapperIdInfo) {
7397 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7398 "Unexpected number of motion modifiers.");
7399 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7400
7401 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7402 "Unexpected number of motion modifier locations.");
7403 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7404 }
7405
7406 /// Build an empty clause.
7407 ///
7408 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7409 /// NumVars: number of expressions listed in this clause; 2)
7410 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7411 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7412 /// NumComponents: total number of expression components in the clause.
7413 explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes)
7414 : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(),
7415 Sizes, /*SupportsMapper=*/true) {}
7416
7417 /// Set motion-modifier for the clause.
7418 ///
7419 /// \param I index for motion-modifier.
7420 /// \param T motion-modifier for the clause.
7421 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7422 assert(I < NumberOfOMPMotionModifiers &&
7423 "Unexpected index to store motion modifier, exceeds array size.");
7424 MotionModifiers[I] = T;
7425 }
7426
7427 /// Set location for the motion-modifier.
7428 ///
7429 /// \param I index for motion-modifier location.
7430 /// \param TLoc motion-modifier location.
7431 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7432 assert(I < NumberOfOMPMotionModifiers &&
7433 "Index to store motion modifier location exceeds array size.");
7434 MotionModifiersLoc[I] = TLoc;
7435 }
7436
7437 /// Set colon location.
7438 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7439
7440 /// Define the sizes of each trailing object array except the last one. This
7441 /// is required for TrailingObjects to work properly.
7442 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7443 // There are varlist_size() of expressions, and varlist_size() of
7444 // user-defined mappers.
7445 return 2 * varlist_size();
7446 }
7447 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7448 return getUniqueDeclarationsNum();
7449 }
7450 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7452 }
7453
7454public:
7455 /// Creates clause with a list of variables \a Vars.
7456 ///
7457 /// \param C AST context.
7458 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7459 /// StartLoc: starting location of the clause (the clause keyword); 2)
7460 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7461 /// \param Vars The original expression used in the clause.
7462 /// \param Declarations Declarations used in the clause.
7463 /// \param ComponentLists Component lists used in the clause.
7464 /// \param MotionModifiers Motion-modifiers.
7465 /// \param MotionModifiersLoc Location of motion-modifiers.
7466 /// \param UDMapperRefs References to user-defined mappers associated with
7467 /// expressions used in the clause.
7468 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7469 /// user-defined mapper.
7470 /// \param MapperId The identifier of associated user-defined mapper.
7471 static OMPFromClause *
7472 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7473 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7474 MappableExprComponentListsRef ComponentLists,
7475 ArrayRef<Expr *> UDMapperRefs,
7476 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7477 ArrayRef<SourceLocation> MotionModifiersLoc,
7478 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId);
7479
7480 /// Creates an empty clause with the place for \a NumVars variables.
7481 ///
7482 /// \param C AST context.
7483 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7484 /// NumVars: number of expressions listed in this clause; 2)
7485 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7486 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7487 /// NumComponents: total number of expression components in the clause.
7488 static OMPFromClause *CreateEmpty(const ASTContext &C,
7489 const OMPMappableExprListSizeTy &Sizes);
7490
7491 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7492 ///
7493 /// \param Cnt index for motion-modifier.
7494 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7495 assert(Cnt < NumberOfOMPMotionModifiers &&
7496 "Requested modifier exceeds the total number of modifiers.");
7497 return MotionModifiers[Cnt];
7498 }
7499
7500 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7501 /// locations.
7502 ///
7503 /// \param Cnt index for motion-modifier location.
7504 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7505 assert(Cnt < NumberOfOMPMotionModifiers &&
7506 "Requested modifier location exceeds total number of modifiers.");
7507 return MotionModifiersLoc[Cnt];
7508 }
7509
7510 /// Fetches ArrayRef of motion-modifiers.
7512 return llvm::ArrayRef(MotionModifiers);
7513 }
7514
7515 /// Fetches ArrayRef of location of motion-modifiers.
7517 return llvm::ArrayRef(MotionModifiersLoc);
7518 }
7519
7520 /// Get colon location.
7521 SourceLocation getColonLoc() const { return ColonLoc; }
7522
7524 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7525 reinterpret_cast<Stmt **>(varlist_end()));
7526 }
7527
7529 auto Children = const_cast<OMPFromClause *>(this)->children();
7530 return const_child_range(Children.begin(), Children.end());
7531 }
7532
7535 }
7538 }
7539
7540 static bool classof(const OMPClause *T) {
7541 return T->getClauseKind() == llvm::omp::OMPC_from;
7542 }
7543};
7544
7545/// This represents clause 'use_device_ptr' in the '#pragma omp ...'
7546/// directives.
7547///
7548/// \code
7549/// #pragma omp target data use_device_ptr(a,b)
7550/// \endcode
7551/// In this example directive '#pragma omp target data' has clause
7552/// 'use_device_ptr' with the variables 'a' and 'b'.
7554 : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
7555 private llvm::TrailingObjects<
7556 OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
7557 OMPClauseMappableExprCommon::MappableComponent> {
7558 friend class OMPClauseReader;
7560 friend OMPVarListClause;
7561 friend TrailingObjects;
7562
7563 /// Build clause with number of variables \a NumVars.
7564 ///
7565 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7566 /// StartLoc: starting location of the clause (the clause keyword); 2)
7567 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7568 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7569 /// NumVars: number of expressions listed in this clause; 2)
7570 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7571 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7572 /// NumComponents: total number of expression components in the clause.
7573 explicit OMPUseDevicePtrClause(const OMPVarListLocTy &Locs,
7574 const OMPMappableExprListSizeTy &Sizes)
7575 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr, Locs, Sizes) {
7576 }
7577
7578 /// Build an empty clause.
7579 ///
7580 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7581 /// NumVars: number of expressions listed in this clause; 2)
7582 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7583 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7584 /// NumComponents: total number of expression components in the clause.
7586 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr,
7587 OMPVarListLocTy(), Sizes) {}
7588
7589 /// Define the sizes of each trailing object array except the last one. This
7590 /// is required for TrailingObjects to work properly.
7591 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7592 return 3 * varlist_size();
7593 }
7594 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7595 return getUniqueDeclarationsNum();
7596 }
7597 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7599 }
7600
7601 /// Sets the list of references to private copies with initializers for new
7602 /// private variables.
7603 /// \param VL List of references.
7604 void setPrivateCopies(ArrayRef<Expr *> VL);
7605
7606 /// Gets the list of references to private copies with initializers for new
7607 /// private variables.
7608 MutableArrayRef<Expr *> getPrivateCopies() {
7609 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
7610 }
7611 ArrayRef<const Expr *> getPrivateCopies() const {
7613 }
7614
7615 /// Sets the list of references to initializer variables for new private
7616 /// variables.
7617 /// \param VL List of references.
7618 void setInits(ArrayRef<Expr *> VL);
7619
7620 /// Gets the list of references to initializer variables for new private
7621 /// variables.
7622 MutableArrayRef<Expr *> getInits() {
7623 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
7624 }
7625 ArrayRef<const Expr *> getInits() const {
7626 return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
7627 }
7628
7629public:
7630 /// Creates clause with a list of variables \a Vars.
7631 ///
7632 /// \param C AST context.
7633 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7634 /// StartLoc: starting location of the clause (the clause keyword); 2)
7635 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7636 /// \param Vars The original expression used in the clause.
7637 /// \param PrivateVars Expressions referring to private copies.
7638 /// \param Inits Expressions referring to private copy initializers.
7639 /// \param Declarations Declarations used in the clause.
7640 /// \param ComponentLists Component lists used in the clause.
7641 static OMPUseDevicePtrClause *
7642 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7643 ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
7644 ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
7645 MappableExprComponentListsRef ComponentLists);
7646
7647 /// Creates an empty clause with the place for \a NumVars variables.
7648 ///
7649 /// \param C AST context.
7650 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7651 /// NumVars: number of expressions listed in this clause; 2)
7652 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7653 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7654 /// NumComponents: total number of expression components in the clause.
7655 static OMPUseDevicePtrClause *
7656 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7657
7660 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
7662 llvm::iterator_range<private_copies_const_iterator>;
7663
7665 return private_copies_range(getPrivateCopies().begin(),
7666 getPrivateCopies().end());
7667 }
7668
7670 return private_copies_const_range(getPrivateCopies().begin(),
7671 getPrivateCopies().end());
7672 }
7673
7676 using inits_range = llvm::iterator_range<inits_iterator>;
7677 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
7678
7680 return inits_range(getInits().begin(), getInits().end());
7681 }
7682
7684 return inits_const_range(getInits().begin(), getInits().end());
7685 }
7686
7688 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7689 reinterpret_cast<Stmt **>(varlist_end()));
7690 }
7691
7693 auto Children = const_cast<OMPUseDevicePtrClause *>(this)->children();
7694 return const_child_range(Children.begin(), Children.end());
7695 }
7696
7699 }
7702 }
7703
7704 static bool classof(const OMPClause *T) {
7705 return T->getClauseKind() == llvm::omp::OMPC_use_device_ptr;
7706 }
7707};
7708
7709/// This represents clause 'use_device_addr' in the '#pragma omp ...'
7710/// directives.
7711///
7712/// \code
7713/// #pragma omp target data use_device_addr(a,b)
7714/// \endcode
7715/// In this example directive '#pragma omp target data' has clause
7716/// 'use_device_addr' with the variables 'a' and 'b'.
7718 : public OMPMappableExprListClause<OMPUseDeviceAddrClause>,
7719 private llvm::TrailingObjects<
7720 OMPUseDeviceAddrClause, Expr *, ValueDecl *, unsigned,
7721 OMPClauseMappableExprCommon::MappableComponent> {
7722 friend class OMPClauseReader;
7724 friend OMPVarListClause;
7725 friend TrailingObjects;
7726
7727 /// Build clause with number of variables \a NumVars.
7728 ///
7729 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7730 /// StartLoc: starting location of the clause (the clause keyword); 2)
7731 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7732 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7733 /// NumVars: number of expressions listed in this clause; 2)
7734 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7735 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7736 /// NumComponents: total number of expression components in the clause.
7737 explicit OMPUseDeviceAddrClause(const OMPVarListLocTy &Locs,
7738 const OMPMappableExprListSizeTy &Sizes)
7739 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr, Locs,
7740 Sizes) {}
7741
7742 /// Build an empty clause.
7743 ///
7744 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7745 /// NumVars: number of expressions listed in this clause; 2)
7746 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7747 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7748 /// NumComponents: total number of expression components in the clause.
7750 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr,
7751 OMPVarListLocTy(), Sizes) {}
7752
7753 /// Define the sizes of each trailing object array except the last one. This
7754 /// is required for TrailingObjects to work properly.
7755 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7756 return varlist_size();
7757 }
7758 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7759 return getUniqueDeclarationsNum();
7760 }
7761 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7763 }
7764
7765public:
7766 /// Creates clause with a list of variables \a Vars.
7767 ///
7768 /// \param C AST context.
7769 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7770 /// StartLoc: starting location of the clause (the clause keyword); 2)
7771 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7772 /// \param Vars The original expression used in the clause.
7773 /// \param Declarations Declarations used in the clause.
7774 /// \param ComponentLists Component lists used in the clause.
7775 static OMPUseDeviceAddrClause *
7776 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7777 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7778 MappableExprComponentListsRef ComponentLists);
7779
7780 /// Creates an empty clause with the place for \a NumVars variables.
7781 ///
7782 /// \param C AST context.
7783 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7784 /// NumVars: number of expressions listed in this clause; 2)
7785 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7786 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7787 /// NumComponents: total number of expression components in the clause.
7788 static OMPUseDeviceAddrClause *
7789 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7790
7792 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7793 reinterpret_cast<Stmt **>(varlist_end()));
7794 }
7795
7797 auto Children = const_cast<OMPUseDeviceAddrClause *>(this)->children();
7798 return const_child_range(Children.begin(), Children.end());
7799 }
7800
7803 }
7806 }
7807
7808 static bool classof(const OMPClause *T) {
7809 return T->getClauseKind() == llvm::omp::OMPC_use_device_addr;
7810 }
7811};
7812
7813/// This represents clause 'is_device_ptr' in the '#pragma omp ...'
7814/// directives.
7815///
7816/// \code
7817/// #pragma omp target is_device_ptr(a,b)
7818/// \endcode
7819/// In this example directive '#pragma omp target' has clause
7820/// 'is_device_ptr' with the variables 'a' and 'b'.
7822 : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
7823 private llvm::TrailingObjects<
7824 OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
7825 OMPClauseMappableExprCommon::MappableComponent> {
7826 friend class OMPClauseReader;
7828 friend OMPVarListClause;
7829 friend TrailingObjects;
7830
7831 /// Build clause with number of variables \a NumVars.
7832 ///
7833 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7834 /// StartLoc: starting location of the clause (the clause keyword); 2)
7835 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7836 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7837 /// NumVars: number of expressions listed in this clause; 2)
7838 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7839 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7840 /// NumComponents: total number of expression components in the clause.
7841 explicit OMPIsDevicePtrClause(const OMPVarListLocTy &Locs,
7842 const OMPMappableExprListSizeTy &Sizes)
7843 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr, Locs, Sizes) {}
7844
7845 /// Build an empty clause.
7846 ///
7847 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7848 /// NumVars: number of expressions listed in this clause; 2)
7849 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7850 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7851 /// NumComponents: total number of expression components in the clause.
7852 explicit OMPIsDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
7853 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr,
7854 OMPVarListLocTy(), Sizes) {}
7855
7856 /// Define the sizes of each trailing object array except the last one. This
7857 /// is required for TrailingObjects to work properly.
7858 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7859 return varlist_size();
7860 }
7861 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7862 return getUniqueDeclarationsNum();
7863 }
7864 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7866 }
7867
7868public:
7869 /// Creates clause with a list of variables \a Vars.
7870 ///
7871 /// \param C AST context.
7872 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7873 /// StartLoc: starting location of the clause (the clause keyword); 2)
7874 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7875 /// \param Vars The original expression used in the clause.
7876 /// \param Declarations Declarations used in the clause.
7877 /// \param ComponentLists Component lists used in the clause.
7878 static OMPIsDevicePtrClause *
7879 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7880 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7881 MappableExprComponentListsRef ComponentLists);
7882
7883 /// Creates an empty clause with the place for \a NumVars variables.
7884 ///
7885 /// \param C AST context.
7886 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7887 /// NumVars: number of expressions listed in this clause; 2)
7888 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7889 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7890 /// NumComponents: total number of expression components in the clause.
7891 static OMPIsDevicePtrClause *
7892 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7893
7895 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7896 reinterpret_cast<Stmt **>(varlist_end()));
7897 }
7898
7900 auto Children = const_cast<OMPIsDevicePtrClause *>(this)->children();
7901 return const_child_range(Children.begin(), Children.end());
7902 }
7903
7906 }
7909 }
7910
7911 static bool classof(const OMPClause *T) {
7912 return T->getClauseKind() == llvm::omp::OMPC_is_device_ptr;
7913 }
7914};
7915
7916/// This represents clause 'has_device_ptr' in the '#pragma omp ...'
7917/// directives.
7918///
7919/// \code
7920/// #pragma omp target has_device_addr(a,b)
7921/// \endcode
7922/// In this example directive '#pragma omp target' has clause
7923/// 'has_device_ptr' with the variables 'a' and 'b'.
7925 : public OMPMappableExprListClause<OMPHasDeviceAddrClause>,
7926 private llvm::TrailingObjects<
7927 OMPHasDeviceAddrClause, Expr *, ValueDecl *, unsigned,
7928 OMPClauseMappableExprCommon::MappableComponent> {
7929 friend class OMPClauseReader;
7931 friend OMPVarListClause;
7932 friend TrailingObjects;
7933
7934 /// Build clause with number of variables \a NumVars.
7935 ///
7936 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7937 /// StartLoc: starting location of the clause (the clause keyword); 2)
7938 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7939 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7940 /// NumVars: number of expressions listed in this clause; 2)
7941 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7942 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7943 /// NumComponents: total number of expression components in the clause.
7944 explicit OMPHasDeviceAddrClause(const OMPVarListLocTy &Locs,
7945 const OMPMappableExprListSizeTy &Sizes)
7946 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, Locs,
7947 Sizes) {}
7948
7949 /// Build an empty clause.
7950 ///
7951 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7952 /// NumVars: number of expressions listed in this clause; 2)
7953 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7954 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7955 /// NumComponents: total number of expression components in the clause.
7957 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr,
7958 OMPVarListLocTy(), Sizes) {}
7959
7960 /// Define the sizes of each trailing object array except the last one. This
7961 /// is required for TrailingObjects to work properly.
7962 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7963 return varlist_size();
7964 }
7965 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7966 return getUniqueDeclarationsNum();
7967 }
7968 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7970 }
7971
7972public:
7973 /// Creates clause with a list of variables \a Vars.
7974 ///
7975 /// \param C AST context.
7976 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7977 /// StartLoc: starting location of the clause (the clause keyword); 2)
7978 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7979 /// \param Vars The original expression used in the clause.
7980 /// \param Declarations Declarations used in the clause.
7981 /// \param ComponentLists Component lists used in the clause.
7982 static OMPHasDeviceAddrClause *
7983 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7984 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7985 MappableExprComponentListsRef ComponentLists);
7986
7987 /// Creates an empty clause with the place for \a NumVars variables.
7988 ///
7989 /// \param C AST context.
7990 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7991 /// NumVars: number of expressions listed in this clause; 2)
7992 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7993 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7994 /// NumComponents: total number of expression components in the clause.
7995 static OMPHasDeviceAddrClause *
7996 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7997
7999 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8000 reinterpret_cast<Stmt **>(varlist_end()));
8001 }
8002
8004 auto Children = const_cast<OMPHasDeviceAddrClause *>(this)->children();
8005 return const_child_range(Children.begin(), Children.end());
8006 }
8007
8010 }
8013 }
8014
8015 static bool classof(const OMPClause *T) {
8016 return T->getClauseKind() == llvm::omp::OMPC_has_device_addr;
8017 }
8018};
8019
8020/// This represents clause 'nontemporal' in the '#pragma omp ...' directives.
8021///
8022/// \code
8023/// #pragma omp simd nontemporal(a)
8024/// \endcode
8025/// In this example directive '#pragma omp simd' has clause 'nontemporal' for
8026/// the variable 'a'.
8028 : public OMPVarListClause<OMPNontemporalClause>,
8029 private llvm::TrailingObjects<OMPNontemporalClause, Expr *> {
8030 friend class OMPClauseReader;
8031 friend OMPVarListClause;
8032 friend TrailingObjects;
8033
8034 /// Build clause with number of variables \a N.
8035 ///
8036 /// \param StartLoc Starting location of the clause.
8037 /// \param LParenLoc Location of '('.
8038 /// \param EndLoc Ending location of the clause.
8039 /// \param N Number of the variables in the clause.
8041 SourceLocation EndLoc, unsigned N)
8042 : OMPVarListClause<OMPNontemporalClause>(llvm::omp::OMPC_nontemporal,
8043 StartLoc, LParenLoc, EndLoc, N) {
8044 }
8045
8046 /// Build an empty clause.
8047 ///
8048 /// \param N Number of variables.
8049 explicit OMPNontemporalClause(unsigned N)
8051 llvm::omp::OMPC_nontemporal, SourceLocation(), SourceLocation(),
8052 SourceLocation(), N) {}
8053
8054 /// Get the list of privatied copies if the member expression was captured by
8055 /// one of the privatization clauses.
8056 MutableArrayRef<Expr *> getPrivateRefs() {
8057 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
8058 }
8059 ArrayRef<const Expr *> getPrivateRefs() const {
8061 }
8062
8063public:
8064 /// Creates clause with a list of variables \a VL.
8065 ///
8066 /// \param C AST context.
8067 /// \param StartLoc Starting location of the clause.
8068 /// \param LParenLoc Location of '('.
8069 /// \param EndLoc Ending location of the clause.
8070 /// \param VL List of references to the variables.
8071 static OMPNontemporalClause *
8072 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
8073 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8074
8075 /// Creates an empty clause with the place for \a N variables.
8076 ///
8077 /// \param C AST context.
8078 /// \param N The number of variables.
8079 static OMPNontemporalClause *CreateEmpty(const ASTContext &C, unsigned N);
8080
8081 /// Sets the list of references to private copies created in private clauses.
8082 /// \param VL List of references.
8083 void setPrivateRefs(ArrayRef<Expr *> VL);
8084
8086 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8087 reinterpret_cast<Stmt **>(varlist_end()));
8088 }
8089
8091 auto Children = const_cast<OMPNontemporalClause *>(this)->children();
8092 return const_child_range(Children.begin(), Children.end());
8093 }
8094
8096 return child_range(reinterpret_cast<Stmt **>(getPrivateRefs().begin()),
8097 reinterpret_cast<Stmt **>(getPrivateRefs().end()));
8098 }
8099
8101 auto Children = const_cast<OMPNontemporalClause *>(this)->private_refs();
8102 return const_child_range(Children.begin(), Children.end());
8103 }
8104
8107 }
8110 }
8111
8112 static bool classof(const OMPClause *T) {
8113 return T->getClauseKind() == llvm::omp::OMPC_nontemporal;
8114 }
8115};
8116
8117/// This represents 'order' clause in the '#pragma omp ...' directive.
8118///
8119/// \code
8120/// #pragma omp simd order(concurrent)
8121/// \endcode
8122/// In this example directive '#pragma omp parallel' has simple 'order'
8123/// clause with kind 'concurrent'.
8124class OMPOrderClause final : public OMPClause {
8125 friend class OMPClauseReader;
8126
8127 /// Location of '('.
8128 SourceLocation LParenLoc;
8129
8130 /// A kind of the 'order' clause.
8132
8133 /// Start location of the kind in source code.
8134 SourceLocation KindKwLoc;
8135
8136 /// A modifier for order clause
8138
8139 /// Start location of the modifier in source code.
8140 SourceLocation ModifierKwLoc;
8141
8142 /// Set kind of the clause.
8143 ///
8144 /// \param K Argument of clause.
8145 void setKind(OpenMPOrderClauseKind K) { Kind = K; }
8146
8147 /// Set argument location.
8148 ///
8149 /// \param KLoc Argument location.
8150 void setKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
8151
8152 /// Set modifier of the clause.
8153 ///
8154 /// \param M Argument of clause.
8155 void setModifier(OpenMPOrderClauseModifier M) { Modifier = M; }
8156
8157 /// Set modifier location.
8158 ///
8159 /// \param MLoc Modifier keyword location.
8160 void setModifierKwLoc(SourceLocation MLoc) { ModifierKwLoc = MLoc; }
8161
8162public:
8163 /// Build 'order' clause with argument \p A ('concurrent').
8164 ///
8165 /// \param A Argument of the clause ('concurrent').
8166 /// \param ALoc Starting location of the argument.
8167 /// \param StartLoc Starting location of the clause.
8168 /// \param LParenLoc Location of '('.
8169 /// \param EndLoc Ending location of the clause.
8170 /// \param Modifier The modifier applied to 'order' clause.
8171 /// \param MLoc Location of the modifier
8173 SourceLocation StartLoc, SourceLocation LParenLoc,
8175 SourceLocation MLoc)
8176 : OMPClause(llvm::omp::OMPC_order, StartLoc, EndLoc),
8177 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), Modifier(Modifier),
8178 ModifierKwLoc(MLoc) {}
8179
8180 /// Build an empty clause.
8182 : OMPClause(llvm::omp::OMPC_order, SourceLocation(), SourceLocation()) {}
8183
8184 /// Sets the location of '('.
8185 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8186
8187 /// Returns the location of '('.
8188 SourceLocation getLParenLoc() const { return LParenLoc; }
8189
8190 /// Returns kind of the clause.
8192
8193 /// Returns location of clause kind.
8194 SourceLocation getKindKwLoc() const { return KindKwLoc; }
8195
8196 /// Returns Modifier of the clause.
8197 OpenMPOrderClauseModifier getModifier() const { return Modifier; }
8198
8199 /// Returns location of clause modifier.
8200 SourceLocation getModifierKwLoc() const { return ModifierKwLoc; }
8201
8204 }
8205
8208 }
8209
8212 }
8215 }
8216
8217 static bool classof(const OMPClause *T) {
8218 return T->getClauseKind() == llvm::omp::OMPC_order;
8219 }
8220};
8221
8222/// This represents the 'init' clause in '#pragma omp ...' directives.
8223///
8224/// \code
8225/// #pragma omp interop init(target:obj)
8226/// \endcode
8227class OMPInitClause final
8228 : public OMPVarListClause<OMPInitClause>,
8229 private llvm::TrailingObjects<OMPInitClause, Expr *> {
8230 friend class OMPClauseReader;
8231 friend OMPVarListClause;
8232 friend TrailingObjects;
8233
8234 /// Location of interop variable.
8235 SourceLocation VarLoc;
8236
8237 bool IsTarget = false;
8238 bool IsTargetSync = false;
8239
8240 void setInteropVar(Expr *E) { varlist_begin()[0] = E; }
8241
8242 void setIsTarget(bool V) { IsTarget = V; }
8243
8244 void setIsTargetSync(bool V) { IsTargetSync = V; }
8245
8246 /// Sets the location of the interop variable.
8247 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8248
8249 /// Build 'init' clause.
8250 ///
8251 /// \param IsTarget Uses the 'target' interop-type.
8252 /// \param IsTargetSync Uses the 'targetsync' interop-type.
8253 /// \param StartLoc Starting location of the clause.
8254 /// \param LParenLoc Location of '('.
8255 /// \param VarLoc Location of the interop variable.
8256 /// \param EndLoc Ending location of the clause.
8257 /// \param N Number of expressions.
8258 OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc,
8259 SourceLocation LParenLoc, SourceLocation VarLoc,
8260 SourceLocation EndLoc, unsigned N)
8261 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc,
8262 LParenLoc, EndLoc, N),
8263 VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {}
8264
8265 /// Build an empty clause.
8266 OMPInitClause(unsigned N)
8267 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(),
8268 SourceLocation(), SourceLocation(), N) {
8269 }
8270
8271public:
8272 /// Creates a fully specified clause.
8273 ///
8274 /// \param C AST context.
8275 /// \param InteropVar The interop variable.
8276 /// \param InteropInfo The interop-type and prefer_type list.
8277 /// \param StartLoc Starting location of the clause.
8278 /// \param LParenLoc Location of '('.
8279 /// \param VarLoc Location of the interop variable.
8280 /// \param EndLoc Ending location of the clause.
8281 static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar,
8282 OMPInteropInfo &InteropInfo,
8283 SourceLocation StartLoc,
8284 SourceLocation LParenLoc, SourceLocation VarLoc,
8285 SourceLocation EndLoc);
8286
8287 /// Creates an empty clause with \a N expressions.
8288 ///
8289 /// \param C AST context.
8290 /// \param N Number of expression items.
8291 static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N);
8292
8293 /// Returns the location of the interop variable.
8294 SourceLocation getVarLoc() const { return VarLoc; }
8295
8296 /// Returns the interop variable.
8298 const Expr *getInteropVar() const { return varlist_begin()[0]; }
8299
8300 /// Returns true is interop-type 'target' is used.
8301 bool getIsTarget() const { return IsTarget; }
8302
8303 /// Returns true is interop-type 'targetsync' is used.
8304 bool getIsTargetSync() const { return IsTargetSync; }
8305
8307 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8308 reinterpret_cast<Stmt **>(varlist_end()));
8309 }
8310
8312 auto Children = const_cast<OMPInitClause *>(this)->children();
8313 return const_child_range(Children.begin(), Children.end());
8314 }
8315
8318 }
8321 }
8322
8325 using prefs_range = llvm::iterator_range<prefs_iterator>;
8326 using const_prefs_range = llvm::iterator_range<const_prefs_iterator>;
8327
8329 return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())),
8330 reinterpret_cast<Expr **>(varlist_end()));
8331 }
8332
8334 auto Prefs = const_cast<OMPInitClause *>(this)->prefs();
8335 return const_prefs_range(Prefs.begin(), Prefs.end());
8336 }
8337
8338 static bool classof(const OMPClause *T) {
8339 return T->getClauseKind() == llvm::omp::OMPC_init;
8340 }
8341};
8342
8343/// This represents the 'use' clause in '#pragma omp ...' directives.
8344///
8345/// \code
8346/// #pragma omp interop use(obj)
8347/// \endcode
8348class OMPUseClause final : public OMPClause {
8349 friend class OMPClauseReader;
8350
8351 /// Location of '('.
8352 SourceLocation LParenLoc;
8353
8354 /// Location of interop variable.
8355 SourceLocation VarLoc;
8356
8357 /// The interop variable.
8358 Stmt *InteropVar = nullptr;
8359
8360 /// Set the interop variable.
8361 void setInteropVar(Expr *E) { InteropVar = E; }
8362
8363 /// Sets the location of '('.
8364 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8365
8366 /// Sets the location of the interop variable.
8367 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8368
8369public:
8370 /// Build 'use' clause with and interop variable expression \a InteropVar.
8371 ///
8372 /// \param InteropVar The interop variable.
8373 /// \param StartLoc Starting location of the clause.
8374 /// \param LParenLoc Location of '('.
8375 /// \param VarLoc Location of the interop variable.
8376 /// \param EndLoc Ending location of the clause.
8377 OMPUseClause(Expr *InteropVar, SourceLocation StartLoc,
8378 SourceLocation LParenLoc, SourceLocation VarLoc,
8379 SourceLocation EndLoc)
8380 : OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc),
8381 VarLoc(VarLoc), InteropVar(InteropVar) {}
8382
8383 /// Build an empty clause.
8385 : OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {}
8386
8387 /// Returns the location of '('.
8388 SourceLocation getLParenLoc() const { return LParenLoc; }
8389
8390 /// Returns the location of the interop variable.
8391 SourceLocation getVarLoc() const { return VarLoc; }
8392
8393 /// Returns the interop variable.
8394 Expr *getInteropVar() const { return cast<Expr>(InteropVar); }
8395
8396 child_range children() { return child_range(&InteropVar, &InteropVar + 1); }
8397
8399 return const_child_range(&InteropVar, &InteropVar + 1);
8400 }
8401
8404 }
8407 }
8408
8409 static bool classof(const OMPClause *T) {
8410 return T->getClauseKind() == llvm::omp::OMPC_use;
8411 }
8412};
8413
8414/// This represents 'destroy' clause in the '#pragma omp depobj'
8415/// directive or the '#pragma omp interop' directive..
8416///
8417/// \code
8418/// #pragma omp depobj(a) destroy
8419/// #pragma omp interop destroy(obj)
8420/// \endcode
8421/// In these examples directive '#pragma omp depobj' and '#pragma omp interop'
8422/// have a 'destroy' clause. The 'interop' directive includes an object.
8423class OMPDestroyClause final : public OMPClause {
8424 friend class OMPClauseReader;
8425
8426 /// Location of '('.
8427 SourceLocation LParenLoc;
8428
8429 /// Location of interop variable.
8430 SourceLocation VarLoc;
8431
8432 /// The interop variable.
8433 Stmt *InteropVar = nullptr;
8434
8435 /// Set the interop variable.
8436 void setInteropVar(Expr *E) { InteropVar = E; }
8437
8438 /// Sets the location of '('.
8439 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8440
8441 /// Sets the location of the interop variable.
8442 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8443
8444public:
8445 /// Build 'destroy' clause with an interop variable expression \a InteropVar.
8446 ///
8447 /// \param InteropVar The interop variable.
8448 /// \param StartLoc Starting location of the clause.
8449 /// \param LParenLoc Location of '('.
8450 /// \param VarLoc Location of the interop variable.
8451 /// \param EndLoc Ending location of the clause.
8452 OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc,
8453 SourceLocation LParenLoc, SourceLocation VarLoc,
8454 SourceLocation EndLoc)
8455 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc),
8456 LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {}
8457
8458 /// Build 'destroy' clause.
8459 ///
8460 /// \param StartLoc Starting location of the clause.
8461 /// \param EndLoc Ending location of the clause.
8463 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc) {}
8464
8465 /// Build an empty clause.
8467 : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) {
8468 }
8469
8470 /// Returns the location of '('.
8471 SourceLocation getLParenLoc() const { return LParenLoc; }
8472
8473 /// Returns the location of the interop variable.
8474 SourceLocation getVarLoc() const { return VarLoc; }
8475
8476 /// Returns the interop variable.
8477 Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); }
8478
8480 if (InteropVar)
8481 return child_range(&InteropVar, &InteropVar + 1);
8483 }
8484
8486 if (InteropVar)
8487 return const_child_range(&InteropVar, &InteropVar + 1);
8489 }
8490
8493 }
8496 }
8497
8498 static bool classof(const OMPClause *T) {
8499 return T->getClauseKind() == llvm::omp::OMPC_destroy;
8500 }
8501};
8502
8503/// This represents 'novariants' clause in the '#pragma omp ...' directive.
8504///
8505/// \code
8506/// #pragma omp dispatch novariants(a > 5)
8507/// \endcode
8508/// In this example directive '#pragma omp dispatch' has simple 'novariants'
8509/// clause with condition 'a > 5'.
8511 : public OMPOneStmtClause<llvm::omp::OMPC_novariants, OMPClause>,
8512 public OMPClauseWithPreInit {
8513 friend class OMPClauseReader;
8514
8515 /// Set condition.
8516 void setCondition(Expr *Cond) { setStmt(Cond); }
8517
8518public:
8519 /// Build 'novariants' clause with condition \a Cond.
8520 ///
8521 /// \param Cond Condition of the clause.
8522 /// \param HelperCond Helper condition for the construct.
8523 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8524 /// clause must be captured.
8525 /// \param StartLoc Starting location of the clause.
8526 /// \param LParenLoc Location of '('.
8527 /// \param EndLoc Ending location of the clause.
8528 OMPNovariantsClause(Expr *Cond, Stmt *HelperCond,
8529 OpenMPDirectiveKind CaptureRegion,
8530 SourceLocation StartLoc, SourceLocation LParenLoc,
8531 SourceLocation EndLoc)
8532 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8533 OMPClauseWithPreInit(this) {
8534 setPreInitStmt(HelperCond, CaptureRegion);
8535 }
8536
8537 /// Build an empty clause.
8539
8540 /// Returns condition.
8541 Expr *getCondition() const { return getStmtAs<Expr>(); }
8542
8545 auto Children = const_cast<OMPNovariantsClause *>(this)->used_children();
8546 return const_child_range(Children.begin(), Children.end());
8547 }
8548};
8549
8550/// This represents 'nocontext' clause in the '#pragma omp ...' directive.
8551///
8552/// \code
8553/// #pragma omp dispatch nocontext(a > 5)
8554/// \endcode
8555/// In this example directive '#pragma omp dispatch' has simple 'nocontext'
8556/// clause with condition 'a > 5'.
8558 : public OMPOneStmtClause<llvm::omp::OMPC_nocontext, OMPClause>,
8559 public OMPClauseWithPreInit {
8560 friend class OMPClauseReader;
8561
8562 /// Set condition.
8563 void setCondition(Expr *Cond) { setStmt(Cond); }
8564
8565public:
8566 /// Build 'nocontext' clause with condition \a Cond.
8567 ///
8568 /// \param Cond Condition of the clause.
8569 /// \param HelperCond Helper condition for the construct.
8570 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8571 /// clause must be captured.
8572 /// \param StartLoc Starting location of the clause.
8573 /// \param LParenLoc Location of '('.
8574 /// \param EndLoc Ending location of the clause.
8575 OMPNocontextClause(Expr *Cond, Stmt *HelperCond,
8576 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
8577 SourceLocation LParenLoc, SourceLocation EndLoc)
8578 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8579 OMPClauseWithPreInit(this) {
8580 setPreInitStmt(HelperCond, CaptureRegion);
8581 }
8582
8583 /// Build an empty clause.
8585
8586 /// Returns condition.
8587 Expr *getCondition() const { return getStmtAs<Expr>(); }
8588
8591 auto Children = const_cast<OMPNocontextClause *>(this)->used_children();
8592 return const_child_range(Children.begin(), Children.end());
8593 }
8594};
8595
8596/// This represents 'detach' clause in the '#pragma omp task' directive.
8597///
8598/// \code
8599/// #pragma omp task detach(evt)
8600/// \endcode
8601/// In this example directive '#pragma omp detach' has simple 'detach' clause
8602/// with the variable 'evt'.
8604 : public OMPOneStmtClause<llvm::omp::OMPC_detach, OMPClause> {
8605 friend class OMPClauseReader;
8606
8607 /// Set condition.
8608 void setEventHandler(Expr *E) { setStmt(E); }
8609
8610public:
8611 /// Build 'detach' clause with event-handler \a Evt.
8612 ///
8613 /// \param Evt Event handler expression.
8614 /// \param StartLoc Starting location of the clause.
8615 /// \param LParenLoc Location of '('.
8616 /// \param EndLoc Ending location of the clause.
8618 SourceLocation EndLoc)
8619 : OMPOneStmtClause(Evt, StartLoc, LParenLoc, EndLoc) {}
8620
8621 /// Build an empty clause.
8623
8624 /// Returns event-handler expression.
8625 Expr *getEventHandler() const { return getStmtAs<Expr>(); }
8626};
8627
8628/// This represents clause 'inclusive' in the '#pragma omp scan' directive.
8629///
8630/// \code
8631/// #pragma omp scan inclusive(a,b)
8632/// \endcode
8633/// In this example directive '#pragma omp scan' has clause 'inclusive'
8634/// with the variables 'a' and 'b'.
8636 : public OMPVarListClause<OMPInclusiveClause>,
8637 private llvm::TrailingObjects<OMPInclusiveClause, Expr *> {
8638 friend class OMPClauseReader;
8639 friend OMPVarListClause;
8640 friend TrailingObjects;
8641
8642 /// Build clause with number of variables \a N.
8643 ///
8644 /// \param StartLoc Starting location of the clause.
8645 /// \param LParenLoc Location of '('.
8646 /// \param EndLoc Ending location of the clause.
8647 /// \param N Number of the variables in the clause.
8649 SourceLocation EndLoc, unsigned N)
8650 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
8651 StartLoc, LParenLoc, EndLoc, N) {}
8652
8653 /// Build an empty clause.
8654 ///
8655 /// \param N Number of variables.
8656 explicit OMPInclusiveClause(unsigned N)
8657 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
8659 SourceLocation(), N) {}
8660
8661public:
8662 /// Creates clause with a list of variables \a VL.
8663 ///
8664 /// \param C AST context.
8665 /// \param StartLoc Starting location of the clause.
8666 /// \param LParenLoc Location of '('.
8667 /// \param EndLoc Ending location of the clause.
8668 /// \param VL List of references to the original variables.
8669 static OMPInclusiveClause *Create(const ASTContext &C,
8670 SourceLocation StartLoc,
8671 SourceLocation LParenLoc,
8672 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8673
8674 /// Creates an empty clause with the place for \a N variables.
8675 ///
8676 /// \param C AST context.
8677 /// \param N The number of variables.
8678 static OMPInclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
8679
8681 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8682 reinterpret_cast<Stmt **>(varlist_end()));
8683 }
8684
8686 auto Children = const_cast<OMPInclusiveClause *>(this)->children();
8687 return const_child_range(Children.begin(), Children.end());
8688 }
8689
8692 }
8695 }
8696
8697 static bool classof(const OMPClause *T) {
8698 return T->getClauseKind() == llvm::omp::OMPC_inclusive;
8699 }
8700};
8701
8702/// This represents clause 'exclusive' in the '#pragma omp scan' directive.
8703///
8704/// \code
8705/// #pragma omp scan exclusive(a,b)
8706/// \endcode
8707/// In this example directive '#pragma omp scan' has clause 'exclusive'
8708/// with the variables 'a' and 'b'.
8710 : public OMPVarListClause<OMPExclusiveClause>,
8711 private llvm::TrailingObjects<OMPExclusiveClause, Expr *> {
8712 friend class OMPClauseReader;
8713 friend OMPVarListClause;
8714 friend TrailingObjects;
8715
8716 /// Build clause with number of variables \a N.
8717 ///
8718 /// \param StartLoc Starting location of the clause.
8719 /// \param LParenLoc Location of '('.
8720 /// \param EndLoc Ending location of the clause.
8721 /// \param N Number of the variables in the clause.
8723 SourceLocation EndLoc, unsigned N)
8724 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
8725 StartLoc, LParenLoc, EndLoc, N) {}
8726
8727 /// Build an empty clause.
8728 ///
8729 /// \param N Number of variables.
8730 explicit OMPExclusiveClause(unsigned N)
8731 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
8733 SourceLocation(), N) {}
8734
8735public:
8736 /// Creates clause with a list of variables \a VL.
8737 ///
8738 /// \param C AST context.
8739 /// \param StartLoc Starting location of the clause.
8740 /// \param LParenLoc Location of '('.
8741 /// \param EndLoc Ending location of the clause.
8742 /// \param VL List of references to the original variables.
8743 static OMPExclusiveClause *Create(const ASTContext &C,
8744 SourceLocation StartLoc,
8745 SourceLocation LParenLoc,
8746 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8747
8748 /// Creates an empty clause with the place for \a N variables.
8749 ///
8750 /// \param C AST context.
8751 /// \param N The number of variables.
8752 static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
8753
8755 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8756 reinterpret_cast<Stmt **>(varlist_end()));
8757 }
8758
8760 auto Children = const_cast<OMPExclusiveClause *>(this)->children();
8761 return const_child_range(Children.begin(), Children.end());
8762 }
8763
8766 }
8769 }
8770
8771 static bool classof(const OMPClause *T) {
8772 return T->getClauseKind() == llvm::omp::OMPC_exclusive;
8773 }
8774};
8775
8776/// This represents clause 'uses_allocators' in the '#pragma omp target'-based
8777/// directives.
8778///
8779/// \code
8780/// #pragma omp target uses_allocators(default_allocator, my_allocator(traits))
8781/// \endcode
8782/// In this example directive '#pragma omp target' has clause 'uses_allocators'
8783/// with the allocators 'default_allocator' and user-defined 'my_allocator'.
8785 : public OMPClause,
8786 private llvm::TrailingObjects<OMPUsesAllocatorsClause, Expr *,
8787 SourceLocation> {
8788public:
8789 /// Data for list of allocators.
8790 struct Data {
8791 /// Allocator.
8792 Expr *Allocator = nullptr;
8793 /// Allocator traits.
8795 /// Locations of '(' and ')' symbols.
8797 };
8798
8799private:
8800 friend class OMPClauseReader;
8801 friend TrailingObjects;
8802
8803 enum class ExprOffsets {
8804 Allocator,
8805 AllocatorTraits,
8806 Total,
8807 };
8808
8809 enum class ParenLocsOffsets {
8810 LParen,
8811 RParen,
8812 Total,
8813 };
8814
8815 /// Location of '('.
8816 SourceLocation LParenLoc;
8817 /// Total number of allocators in the clause.
8818 unsigned NumOfAllocators = 0;
8819
8820 /// Build clause.
8821 ///
8822 /// \param StartLoc Starting location of the clause.
8823 /// \param LParenLoc Location of '('.
8824 /// \param EndLoc Ending location of the clause.
8825 /// \param N Number of allocators associated with the clause.
8826 OMPUsesAllocatorsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
8827 SourceLocation EndLoc, unsigned N)
8828 : OMPClause(llvm::omp::OMPC_uses_allocators, StartLoc, EndLoc),
8829 LParenLoc(LParenLoc), NumOfAllocators(N) {}
8830
8831 /// Build an empty clause.
8832 /// \param N Number of allocators associated with the clause.
8833 ///
8834 explicit OMPUsesAllocatorsClause(unsigned N)
8835 : OMPClause(llvm::omp::OMPC_uses_allocators, SourceLocation(),
8836 SourceLocation()),
8837 NumOfAllocators(N) {}
8838
8839 unsigned numTrailingObjects(OverloadToken<Expr *>) const {
8840 return NumOfAllocators * static_cast<int>(ExprOffsets::Total);
8841 }
8842
8843 /// Sets the location of '('.
8844 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8845
8846 /// Sets the allocators data for the clause.
8847 void setAllocatorsData(ArrayRef<OMPUsesAllocatorsClause::Data> Data);
8848
8849public:
8850 /// Creates clause with a list of allocators \p Data.
8851 ///
8852 /// \param C AST context.
8853 /// \param StartLoc Starting location of the clause.
8854 /// \param LParenLoc Location of '('.
8855 /// \param EndLoc Ending location of the clause.
8856 /// \param Data List of allocators.
8857 static OMPUsesAllocatorsClause *
8858 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
8859 SourceLocation EndLoc, ArrayRef<OMPUsesAllocatorsClause::Data> Data);
8860
8861 /// Creates an empty clause with the place for \p N allocators.
8862 ///
8863 /// \param C AST context.
8864 /// \param N The number of allocators.
8865 static OMPUsesAllocatorsClause *CreateEmpty(const ASTContext &C, unsigned N);
8866
8867 /// Returns the location of '('.
8868 SourceLocation getLParenLoc() const { return LParenLoc; }
8869
8870 /// Returns number of allocators associated with the clause.
8871 unsigned getNumberOfAllocators() const { return NumOfAllocators; }
8872
8873 /// Returns data for the specified allocator.
8875
8876 // Iterators
8878 Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
8879 return child_range(Begin, Begin + NumOfAllocators *
8880 static_cast<int>(ExprOffsets::Total));
8881 }
8883 Stmt *const *Begin =
8884 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
8885 return const_child_range(
8886 Begin, Begin + NumOfAllocators * static_cast<int>(ExprOffsets::Total));
8887 }
8888
8891 }
8894 }
8895
8896 static bool classof(const OMPClause *T) {
8897 return T->getClauseKind() == llvm::omp::OMPC_uses_allocators;
8898 }
8899};
8900
8901/// This represents clause 'affinity' in the '#pragma omp task'-based
8902/// directives.
8903///
8904/// \code
8905/// #pragma omp task affinity(iterator(i = 0:n) : ([3][n])a, b[:n], c[i])
8906/// \endcode
8907/// In this example directive '#pragma omp task' has clause 'affinity' with the
8908/// affinity modifer 'iterator(i = 0:n)' and locator items '([3][n])a', 'b[:n]'
8909/// and 'c[i]'.
8911 : public OMPVarListClause<OMPAffinityClause>,
8912 private llvm::TrailingObjects<OMPAffinityClause, Expr *> {
8913 friend class OMPClauseReader;
8914 friend OMPVarListClause;
8915 friend TrailingObjects;
8916
8917 /// Location of ':' symbol.
8918 SourceLocation ColonLoc;
8919
8920 /// Build clause.
8921 ///
8922 /// \param StartLoc Starting location of the clause.
8923 /// \param LParenLoc Location of '('.
8924 /// \param ColonLoc Location of ':'.
8925 /// \param EndLoc Ending location of the clause.
8926 /// \param N Number of locators associated with the clause.
8928 SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N)
8929 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, StartLoc,
8930 LParenLoc, EndLoc, N) {}
8931
8932 /// Build an empty clause.
8933 /// \param N Number of locators associated with the clause.
8934 ///
8935 explicit OMPAffinityClause(unsigned N)
8936 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity,
8938 SourceLocation(), N) {}
8939
8940 /// Sets the affinity modifier for the clause, if any.
8941 void setModifier(Expr *E) {
8942 getTrailingObjects<Expr *>()[varlist_size()] = E;
8943 }
8944
8945 /// Sets the location of ':' symbol.
8946 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
8947
8948public:
8949 /// Creates clause with a modifier a list of locator items.
8950 ///
8951 /// \param C AST context.
8952 /// \param StartLoc Starting location of the clause.
8953 /// \param LParenLoc Location of '('.
8954 /// \param ColonLoc Location of ':'.
8955 /// \param EndLoc Ending location of the clause.
8956 /// \param Locators List of locator items.
8957 static OMPAffinityClause *Create(const ASTContext &C, SourceLocation StartLoc,
8958 SourceLocation LParenLoc,
8959 SourceLocation ColonLoc,
8960 SourceLocation EndLoc, Expr *Modifier,
8961 ArrayRef<Expr *> Locators);
8962
8963 /// Creates an empty clause with the place for \p N locator items.
8964 ///
8965 /// \param C AST context.
8966 /// \param N The number of locator items.
8967 static OMPAffinityClause *CreateEmpty(const ASTContext &C, unsigned N);
8968
8969 /// Gets affinity modifier.
8970 Expr *getModifier() { return getTrailingObjects<Expr *>()[varlist_size()]; }
8972 return getTrailingObjects<Expr *>()[varlist_size()];
8973 }
8974
8975 /// Gets the location of ':' symbol.
8976 SourceLocation getColonLoc() const { return ColonLoc; }
8977
8978 // Iterators
8980 int Offset = getModifier() ? 1 : 0;
8981 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8982 reinterpret_cast<Stmt **>(varlist_end() + Offset));
8983 }
8984
8986 auto Children = const_cast<OMPAffinityClause *>(this)->children();
8987 return const_child_range(Children.begin(), Children.end());
8988 }
8989
8992 }
8995 }
8996
8997 static bool classof(const OMPClause *T) {
8998 return T->getClauseKind() == llvm::omp::OMPC_affinity;
8999 }
9000};
9001
9002/// This represents 'filter' clause in the '#pragma omp ...' directive.
9003///
9004/// \code
9005/// #pragma omp masked filter(tid)
9006/// \endcode
9007/// In this example directive '#pragma omp masked' has 'filter' clause with
9008/// thread id.
9010 : public OMPOneStmtClause<llvm::omp::OMPC_filter, OMPClause>,
9011 public OMPClauseWithPreInit {
9012 friend class OMPClauseReader;
9013
9014 /// Sets the thread identifier.
9015 void setThreadID(Expr *TID) { setStmt(TID); }
9016
9017public:
9018 /// Build 'filter' clause with thread-id \a ThreadID.
9019 ///
9020 /// \param ThreadID Thread identifier.
9021 /// \param HelperE Helper expression associated with this clause.
9022 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9023 /// clause must be captured.
9024 /// \param StartLoc Starting location of the clause.
9025 /// \param LParenLoc Location of '('.
9026 /// \param EndLoc Ending location of the clause.
9027 OMPFilterClause(Expr *ThreadID, Stmt *HelperE,
9028 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
9029 SourceLocation LParenLoc, SourceLocation EndLoc)
9030 : OMPOneStmtClause(ThreadID, StartLoc, LParenLoc, EndLoc),
9031 OMPClauseWithPreInit(this) {
9032 setPreInitStmt(HelperE, CaptureRegion);
9033 }
9034
9035 /// Build an empty clause.
9037
9038 /// Return thread identifier.
9039 Expr *getThreadID() const { return getStmtAs<Expr>(); }
9040
9041 /// Return thread identifier.
9042 Expr *getThreadID() { return getStmtAs<Expr>(); }
9043};
9044
9045/// This represents 'bind' clause in the '#pragma omp ...' directives.
9046///
9047/// \code
9048/// #pragma omp loop bind(parallel)
9049/// \endcode
9050class OMPBindClause final : public OMPNoChildClause<llvm::omp::OMPC_bind> {
9051 friend class OMPClauseReader;
9052
9053 /// Location of '('.
9054 SourceLocation LParenLoc;
9055
9056 /// The binding kind of 'bind' clause.
9058
9059 /// Start location of the kind in source code.
9060 SourceLocation KindLoc;
9061
9062 /// Sets the location of '('.
9063 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9064
9065 /// Set the binding kind.
9066 void setBindKind(OpenMPBindClauseKind K) { Kind = K; }
9067
9068 /// Set the binding kind location.
9069 void setBindKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
9070
9071 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9072 ///
9073 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9074 /// \param KLoc Starting location of the binding kind.
9075 /// \param StartLoc Starting location of the clause.
9076 /// \param LParenLoc Location of '('.
9077 /// \param EndLoc Ending location of the clause.
9078 OMPBindClause(OpenMPBindClauseKind K, SourceLocation KLoc,
9079 SourceLocation StartLoc, SourceLocation LParenLoc,
9080 SourceLocation EndLoc)
9081 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Kind(K),
9082 KindLoc(KLoc) {}
9083
9084 /// Build an empty clause.
9085 OMPBindClause() : OMPNoChildClause() {}
9086
9087public:
9088 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
9089 ///
9090 /// \param C AST context
9091 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
9092 /// \param KLoc Starting location of the binding kind.
9093 /// \param StartLoc Starting location of the clause.
9094 /// \param LParenLoc Location of '('.
9095 /// \param EndLoc Ending location of the clause.
9096 static OMPBindClause *Create(const ASTContext &C, OpenMPBindClauseKind K,
9097 SourceLocation KLoc, SourceLocation StartLoc,
9098 SourceLocation LParenLoc, SourceLocation EndLoc);
9099
9100 /// Build an empty 'bind' clause.
9101 ///
9102 /// \param C AST context
9103 static OMPBindClause *CreateEmpty(const ASTContext &C);
9104
9105 /// Returns the location of '('.
9106 SourceLocation getLParenLoc() const { return LParenLoc; }
9107
9108 /// Returns kind of the clause.
9110
9111 /// Returns location of clause kind.
9112 SourceLocation getBindKindLoc() const { return KindLoc; }
9113};
9114
9115/// This class implements a simple visitor for OMPClause
9116/// subclasses.
9117template<class ImplClass, template <typename> class Ptr, typename RetTy>
9119public:
9120#define PTR(CLASS) Ptr<CLASS>
9121#define DISPATCH(CLASS) \
9122 return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S))
9123
9124#define GEN_CLANG_CLAUSE_CLASS
9125#define CLAUSE_CLASS(Enum, Str, Class) \
9126 RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
9127#include "llvm/Frontend/OpenMP/OMP.inc"
9128
9129 RetTy Visit(PTR(OMPClause) S) {
9130 // Top switch clause: visit each OMPClause.
9131 switch (S->getClauseKind()) {
9132#define GEN_CLANG_CLAUSE_CLASS
9133#define CLAUSE_CLASS(Enum, Str, Class) \
9134 case llvm::omp::Clause::Enum: \
9135 return Visit##Class(static_cast<PTR(Class)>(S));
9136#define CLAUSE_NO_CLASS(Enum, Str) \
9137 case llvm::omp::Clause::Enum: \
9138 break;
9139#include "llvm/Frontend/OpenMP/OMP.inc"
9140 }
9141 }
9142 // Base case, ignore it. :)
9143 RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); }
9144#undef PTR
9145#undef DISPATCH
9146};
9147
9148template <typename T> using const_ptr = std::add_pointer_t<std::add_const_t<T>>;
9149
9150template <class ImplClass, typename RetTy = void>
9152 : public OMPClauseVisitorBase<ImplClass, std::add_pointer_t, RetTy> {};
9153template<class ImplClass, typename RetTy = void>
9155 public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {};
9156
9157class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
9158 raw_ostream &OS;
9159 const PrintingPolicy &Policy;
9160
9161 /// Process clauses with list of variables.
9162 template <typename T> void VisitOMPClauseList(T *Node, char StartSym);
9163 /// Process motion clauses.
9164 template <typename T> void VisitOMPMotionClause(T *Node);
9165
9166public:
9167 OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
9168 : OS(OS), Policy(Policy) {}
9169
9170#define GEN_CLANG_CLAUSE_CLASS
9171#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
9172#include "llvm/Frontend/OpenMP/OMP.inc"
9173};
9174
9176 llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
9177
9178 /// The raw string as we parsed it. This is needed for the `isa` trait set
9179 /// (which accepts anything) and (later) extensions.
9180 StringRef RawString;
9181};
9184 llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
9186};
9188 llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
9190};
9191
9192/// Helper data structure representing the traits in a match clause of an
9193/// `declare variant` or `metadirective`. The outer level is an ordered
9194/// collection of selector sets, each with an associated kind and an ordered
9195/// collection of selectors. A selector has a kind, an optional score/condition,
9196/// and an ordered collection of properties.
9198 /// Private constructor accesible only by ASTContext.
9199 OMPTraitInfo() {}
9200 friend class ASTContext;
9201
9202public:
9203 /// Reconstruct a (partial) OMPTraitInfo object from a mangled name.
9204 OMPTraitInfo(StringRef MangledName);
9205
9206 /// The outermost level of selector sets.
9208
9210 llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) {
9211 return llvm::any_of(Sets, [&](OMPTraitSet &Set) {
9212 return llvm::any_of(
9213 Set.Selectors, [&](OMPTraitSelector &Selector) {
9214 return Cond(Selector.ScoreOrCondition,
9215 /* IsScore */ Selector.Kind !=
9216 llvm::omp::TraitSelector::user_condition);
9217 });
9218 });
9219 }
9220
9221 /// Create a variant match info object from this trait info object. While the
9222 /// former is a flat representation the actual main difference is that the
9223 /// latter uses clang::Expr to store the score/condition while the former is
9224 /// independent of clang. Thus, expressions and conditions are evaluated in
9225 /// this method.
9226 void getAsVariantMatchInfo(ASTContext &ASTCtx,
9227 llvm::omp::VariantMatchInfo &VMI) const;
9228
9229 /// Return a string representation identifying this context selector.
9230 std::string getMangledName() const;
9231
9232 /// Check the extension trait \p TP is active.
9233 bool isExtensionActive(llvm::omp::TraitProperty TP) {
9234 for (const OMPTraitSet &Set : Sets) {
9235 if (Set.Kind != llvm::omp::TraitSet::implementation)
9236 continue;
9237 for (const OMPTraitSelector &Selector : Set.Selectors) {
9238 if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
9239 continue;
9240 for (const OMPTraitProperty &Property : Selector.Properties) {
9241 if (Property.Kind == TP)
9242 return true;
9243 }
9244 }
9245 }
9246 return false;
9247 }
9248
9249 /// Print a human readable representation into \p OS.
9250 void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
9251};
9252llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
9253llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
9254
9255/// Clang specific specialization of the OMPContext to lookup target features.
9258 std::function<void(StringRef)> &&DiagUnknownTrait,
9259 const FunctionDecl *CurrentFunctionDecl,
9260 ArrayRef<llvm::omp::TraitProperty> ConstructTraits);
9261
9262 virtual ~TargetOMPContext() = default;
9263
9264 /// See llvm::omp::OMPContext::matchesISATrait
9265 bool matchesISATrait(StringRef RawString) const override;
9266
9267private:
9268 std::function<bool(StringRef)> FeatureValidityCheck;
9269 std::function<void(StringRef)> DiagUnknownTrait;
9270 llvm::StringMap<bool> FeatureMap;
9271};
9272
9273/// Contains data for OpenMP directives: clauses, children
9274/// expressions/statements (helpers for codegen) and associated statement, if
9275/// any.
9276class OMPChildren final
9277 : private llvm::TrailingObjects<OMPChildren, OMPClause *, Stmt *> {
9278 friend TrailingObjects;
9279 friend class OMPClauseReader;
9281 template <typename T> friend class OMPDeclarativeDirective;
9282
9283 /// Numbers of clauses.
9284 unsigned NumClauses = 0;
9285 /// Number of child expressions/stmts.
9286 unsigned NumChildren = 0;
9287 /// true if the directive has associated statement.
9288 bool HasAssociatedStmt = false;
9289
9290 /// Define the sizes of each trailing object array except the last one. This
9291 /// is required for TrailingObjects to work properly.
9292 size_t numTrailingObjects(OverloadToken<OMPClause *>) const {
9293 return NumClauses;
9294 }
9295
9296 OMPChildren() = delete;
9297
9298 OMPChildren(unsigned NumClauses, unsigned NumChildren, bool HasAssociatedStmt)
9299 : NumClauses(NumClauses), NumChildren(NumChildren),
9300 HasAssociatedStmt(HasAssociatedStmt) {}
9301
9302 static size_t size(unsigned NumClauses, bool HasAssociatedStmt,
9303 unsigned NumChildren);
9304
9305 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses);
9306 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses, Stmt *S,
9307 unsigned NumChildren = 0);
9308 static OMPChildren *CreateEmpty(void *Mem, unsigned NumClauses,
9309 bool HasAssociatedStmt = false,
9310 unsigned NumChildren = 0);
9311
9312public:
9313 unsigned getNumClauses() const { return NumClauses; }
9314 unsigned getNumChildren() const { return NumChildren; }
9315 bool hasAssociatedStmt() const { return HasAssociatedStmt; }
9316
9317 /// Set associated statement.
9319 getTrailingObjects<Stmt *>()[NumChildren] = S;
9320 }
9321
9323
9324 /// Sets the list of variables for this clause.
9325 ///
9326 /// \param Clauses The list of clauses for the directive.
9327 ///
9328 void setClauses(ArrayRef<OMPClause *> Clauses);
9329
9330 /// Returns statement associated with the directive.
9331 const Stmt *getAssociatedStmt() const {
9332 return const_cast<OMPChildren *>(this)->getAssociatedStmt();
9333 }
9335 assert(HasAssociatedStmt &&
9336 "Expected directive with the associated statement.");
9337 return getTrailingObjects<Stmt *>()[NumChildren];
9338 }
9339
9340 /// Get the clauses storage.
9342 return llvm::MutableArrayRef(getTrailingObjects<OMPClause *>(),
9343 NumClauses);
9344 }
9346 return const_cast<OMPChildren *>(this)->getClauses();
9347 }
9348
9349 /// Returns the captured statement associated with the
9350 /// component region within the (combined) directive.
9351 ///
9352 /// \param RegionKind Component region kind.
9353 const CapturedStmt *
9355 ArrayRef<OpenMPDirectiveKind> CaptureRegions) const {
9356 assert(llvm::is_contained(CaptureRegions, RegionKind) &&
9357 "RegionKind not found in OpenMP CaptureRegions.");
9358 auto *CS = cast<CapturedStmt>(getAssociatedStmt());
9359 for (auto ThisCaptureRegion : CaptureRegions) {
9360 if (ThisCaptureRegion == RegionKind)
9361 return CS;
9362 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9363 }
9364 llvm_unreachable("Incorrect RegionKind specified for directive.");
9365 }
9366
9367 /// Get innermost captured statement for the construct.
9368 CapturedStmt *
9370 assert(hasAssociatedStmt() && "Must have associated captured statement.");
9371 assert(!CaptureRegions.empty() &&
9372 "At least one captured statement must be provided.");
9373 auto *CS = cast<CapturedStmt>(getAssociatedStmt());
9374 for (unsigned Level = CaptureRegions.size(); Level > 1; --Level)
9375 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9376 return CS;
9377 }
9378
9379 const CapturedStmt *
9381 return const_cast<OMPChildren *>(this)->getInnermostCapturedStmt(
9382 CaptureRegions);
9383 }
9384
9387 return const_cast<OMPChildren *>(this)->getChildren();
9388 }
9389
9391 assert(HasAssociatedStmt &&
9392 "Expected directive with the associated statement.");
9393 if (auto *CS = dyn_cast<CapturedStmt>(getAssociatedStmt())) {
9394 Stmt *S = nullptr;
9395 do {
9396 S = CS->getCapturedStmt();
9397 CS = dyn_cast<CapturedStmt>(S);
9398 } while (CS);
9399 return S;
9400 }
9401 return getAssociatedStmt();
9402 }
9403 const Stmt *getRawStmt() const {
9404 return const_cast<OMPChildren *>(this)->getRawStmt();
9405 }
9406
9408 if (!HasAssociatedStmt)
9410 return Stmt::child_range(&getTrailingObjects<Stmt *>()[NumChildren],
9411 &getTrailingObjects<Stmt *>()[NumChildren + 1]);
9412 }
9413};
9414
9415/// This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...'
9416/// directive.
9417///
9418/// \code
9419/// #pragma omp target [...] ompx_dyn_cgroup_mem(N)
9420/// \endcode
9422 : public OMPOneStmtClause<llvm::omp::OMPC_ompx_dyn_cgroup_mem, OMPClause>,
9423 public OMPClauseWithPreInit {
9424 friend class OMPClauseReader;
9425
9426 /// Set size.
9427 void setSize(Expr *E) { setStmt(E); }
9428
9429public:
9430 /// Build 'ompx_dyn_cgroup_mem' clause.
9431 ///
9432 /// \param Size Size expression.
9433 /// \param HelperSize Helper Size expression
9434 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9435 /// \param StartLoc Starting location of the clause.
9436 /// \param LParenLoc Location of '('.
9437 /// \param EndLoc Ending location of the clause.
9439 OpenMPDirectiveKind CaptureRegion,
9440 SourceLocation StartLoc, SourceLocation LParenLoc,
9441 SourceLocation EndLoc)
9442 : OMPOneStmtClause(Size, StartLoc, LParenLoc, EndLoc),
9443 OMPClauseWithPreInit(this) {
9444 setPreInitStmt(HelperSize, CaptureRegion);
9445 }
9446
9447 /// Build an empty clause.
9449
9450 /// Return the size expression.
9451 Expr *getSize() { return getStmtAs<Expr>(); }
9452
9453 /// Return the size expression.
9454 Expr *getSize() const { return getStmtAs<Expr>(); }
9455};
9456
9457/// This represents the 'doacross' clause for the '#pragma omp ordered'
9458/// directive.
9459///
9460/// \code
9461/// #pragma omp ordered doacross(sink: i-1, j-1)
9462/// \endcode
9463/// In this example directive '#pragma omp ordered' with clause 'doacross' with
9464/// a dependence-type 'sink' and loop-iteration vector expressions i-1 and j-1.
9466 : public OMPVarListClause<OMPDoacrossClause>,
9467 private llvm::TrailingObjects<OMPDoacrossClause, Expr *> {
9468 friend class OMPClauseReader;
9469 friend OMPVarListClause;
9470 friend TrailingObjects;
9471
9472 /// Dependence type (sink or source).
9474
9475 /// Dependence type location.
9476 SourceLocation DepLoc;
9477
9478 /// Colon location.
9479 SourceLocation ColonLoc;
9480
9481 /// Number of loops, associated with the doacross clause.
9482 unsigned NumLoops = 0;
9483
9484 /// Build clause with number of expressions \a N.
9485 ///
9486 /// \param StartLoc Starting location of the clause.
9487 /// \param LParenLoc Location of '('.
9488 /// \param EndLoc Ending location of the clause.
9489 /// \param N Number of expressions in the clause.
9490 /// \param NumLoops Number of loops associated with the clause.
9492 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
9493 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross, StartLoc,
9494 LParenLoc, EndLoc, N),
9495 NumLoops(NumLoops) {}
9496
9497 /// Build an empty clause.
9498 ///
9499 /// \param N Number of expressions in the clause.
9500 /// \param NumLoops Number of loops associated with the clause.
9501 explicit OMPDoacrossClause(unsigned N, unsigned NumLoops)
9502 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross,
9504 SourceLocation(), N),
9505 NumLoops(NumLoops) {}
9506
9507 /// Set dependence type.
9508 void setDependenceType(OpenMPDoacrossClauseModifier M) { DepType = M; }
9509
9510 /// Set dependence type location.
9511 void setDependenceLoc(SourceLocation Loc) { DepLoc = Loc; }
9512
9513 /// Set colon location.
9514 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
9515
9516public:
9517 /// Creates clause with a list of expressions \a VL.
9518 ///
9519 /// \param C AST context.
9520 /// \param StartLoc Starting location of the clause.
9521 /// \param LParenLoc Location of '('.
9522 /// \param EndLoc Ending location of the clause.
9523 /// \param DepType The dependence type.
9524 /// \param DepLoc Location of the dependence type.
9525 /// \param ColonLoc Location of ':'.
9526 /// \param VL List of references to the expressions.
9527 /// \param NumLoops Number of loops that associated with the clause.
9528 static OMPDoacrossClause *
9529 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
9530 SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType,
9531 SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
9532 unsigned NumLoops);
9533
9534 /// Creates an empty clause with \a N expressions.
9535 ///
9536 /// \param C AST context.
9537 /// \param N The number of expressions.
9538 /// \param NumLoops Number of loops that is associated with this clause.
9539 static OMPDoacrossClause *CreateEmpty(const ASTContext &C, unsigned N,
9540 unsigned NumLoops);
9541
9542 /// Get dependence type.
9544
9545 /// Get dependence type location.
9546 SourceLocation getDependenceLoc() const { return DepLoc; }
9547
9548 /// Get colon location.
9549 SourceLocation getColonLoc() const { return ColonLoc; }
9550
9551 /// Get number of loops associated with the clause.
9552 unsigned getNumLoops() const { return NumLoops; }
9553
9554 /// Set the loop data.
9555 void setLoopData(unsigned NumLoop, Expr *Cnt);
9556
9557 /// Get the loop data.
9558 Expr *getLoopData(unsigned NumLoop);
9559 const Expr *getLoopData(unsigned NumLoop) const;
9560
9562 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9563 reinterpret_cast<Stmt **>(varlist_end()));
9564 }
9565
9567 auto Children = const_cast<OMPDoacrossClause *>(this)->children();
9568 return const_child_range(Children.begin(), Children.end());
9569 }
9570
9573 }
9576 }
9577
9578 static bool classof(const OMPClause *T) {
9579 return T->getClauseKind() == llvm::omp::OMPC_doacross;
9580 }
9581};
9582
9583/// This represents 'ompx_attribute' clause in a directive that might generate
9584/// an outlined function. An example is given below.
9585///
9586/// \code
9587/// #pragma omp target [...] ompx_attribute(flatten)
9588/// \endcode
9590 : public OMPNoChildClause<llvm::omp::OMPC_ompx_attribute> {
9591 friend class OMPClauseReader;
9592
9593 /// Location of '('.
9594 SourceLocation LParenLoc;
9595
9596 /// The parsed attributes (clause arguments)
9598
9599public:
9600 /// Build 'ompx_attribute' clause.
9601 ///
9602 /// \param Attrs The parsed attributes (clause arguments)
9603 /// \param StartLoc Starting location of the clause.
9604 /// \param LParenLoc Location of '('.
9605 /// \param EndLoc Ending location of the clause.
9607 SourceLocation LParenLoc, SourceLocation EndLoc)
9608 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Attrs(Attrs) {
9609 }
9610
9611 /// Build an empty clause.
9613
9614 /// Sets the location of '('.
9615 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9616
9617 /// Returns the location of '('.
9618 SourceLocation getLParenLoc() const { return LParenLoc; }
9619
9620 /// Returned the attributes parsed from this clause.
9621 ArrayRef<const Attr *> getAttrs() const { return Attrs; }
9622
9623private:
9624 /// Replace the attributes with \p NewAttrs.
9625 void setAttrs(ArrayRef<Attr *> NewAttrs) {
9626 Attrs.clear();
9627 Attrs.append(NewAttrs.begin(), NewAttrs.end());
9628 }
9629};
9630
9631/// This represents 'ompx_bare' clause in the '#pragma omp target teams ...'
9632/// directive.
9633///
9634/// \code
9635/// #pragma omp target teams ompx_bare
9636/// \endcode
9637/// In this example directive '#pragma omp target teams' has a 'ompx_bare'
9638/// clause.
9639class OMPXBareClause : public OMPNoChildClause<llvm::omp::OMPC_ompx_bare> {
9640public:
9641 /// Build 'ompx_bare' clause.
9642 ///
9643 /// \param StartLoc Starting location of the clause.
9644 /// \param EndLoc Ending location of the clause.
9646 : OMPNoChildClause(StartLoc, EndLoc) {}
9647
9648 /// Build an empty clause.
9649 OMPXBareClause() = default;
9650};
9651
9652} // namespace clang
9653
9654#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
#define V(N, I)
Definition: ASTContext.h:3341
Forward declaration of all AST node types.
MatchType Type
DynTypedNode Node
#define PTR(CLASS)
Definition: AttrVisitor.h:27
const Decl * D
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
Expr * E
int Priority
Definition: Format.cpp:3005
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
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:187
This captures a statement into a function.
Definition: Stmt.h:3767
This represents one expression.
Definition: Expr.h:110
Represents a function declaration or definition.
Definition: Decl.h:1932
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:492
const_child_range children() const
Definition: OpenMPClause.h:563
const_child_range used_children() const
Definition: OpenMPClause.h:571
SourceLocation getColonLoc() const
Returns the location of the ':' delimiter.
Definition: OpenMPClause.h:550
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
Definition: OpenMPClause.h:547
child_range used_children()
Definition: OpenMPClause.h:568
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:575
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:690
child_range used_children()
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:718
OMPFinalClause(Expr *Cond, Stmt *HelperCond, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'final' clause with condition Cond.
Definition: OpenMPClause.h:706
OMPFinalClause()
Build an empty clause.
Definition: OpenMPClause.h:715
const_child_range used_children() const
Definition: OpenMPClause.h:721
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.
Definition: OpenMPClause.h:939
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:587
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:647
const_child_range used_children() const
Definition: OpenMPClause.h:671
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:650
SourceLocation getColonLoc() const
Return the location of ':'.
Definition: OpenMPClause.h:653
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:676
child_range used_children()
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:656
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Definition: OpenMPClause.h:659
OMPIfClause()
Build an empty clause.
Definition: OpenMPClause.h:642
child_range children()
Definition: OpenMPClause.h:664
const_child_range children() const
Definition: OpenMPClause.h:666
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:630
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
Definition: OpenMPClause.h:662
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:736
OMPNumThreadsClause()
Build an empty clause.
Definition: OpenMPClause.h:762
OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'num_threads' clause with condition NumThreads.
Definition: OpenMPClause.h:752
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:765
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.
Definition: OpenMPClause.h:967
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 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:781
OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'safelen' clause.
Definition: OpenMPClause.h:793
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:801
OMPSafelenClause()
Build an empty clause.
Definition: OpenMPClause.h:798
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' directive.
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:816
OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'simdlen' clause.
Definition: OpenMPClause.h:828
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:836
OMPSimdlenClause()
Build an empty clause.
Definition: OpenMPClause.h:833
This represents the 'sizes' clause in the '#pragma omp tile' directive.
Definition: OpenMPClause.h:848
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:885
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:882
child_range children()
Definition: OpenMPClause.h:910
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:928
const_child_range used_children() const
Definition: OpenMPClause.h:924
void setSizesRefs(ArrayRef< Expr * > VL)
Sets the tile size expressions.
Definition: OpenMPClause.h:903
unsigned getNumSizes() const
Returns the number of list items.
Definition: OpenMPClause.h:888
child_range used_children()
Definition: OpenMPClause.h:921
MutableArrayRef< Expr * > getSizesRefs()
Returns the tile size expressions.
Definition: OpenMPClause.h:891
ArrayRef< Expr * > getSizesRefs() const
Definition: OpenMPClause.h:896
const_child_range children() const
Definition: OpenMPClause.h:915
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:1452
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:667
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
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:24
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
Definition: OpenMPKinds.h:118
@ OMPC_DEFAULTMAP_MODIFIER_unknown
Definition: OpenMPKinds.h:119
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
Definition: OpenMPKinds.h:171
@ OMPC_ORDER_MODIFIER_unknown
Definition: OpenMPKinds.h:172
std::add_pointer_t< std::add_const_t< T > > const_ptr
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
Definition: OpenMPKinds.h:135
@ OMPC_AT_unknown
Definition: OpenMPKinds.h:138
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
Definition: OpenMPKinds.h:186
@ OMPC_REDUCTION_unknown
Definition: OpenMPKinds.h:189
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition: OpenMPKinds.h:38
@ OMPC_SCHEDULE_MODIFIER_unknown
Definition: OpenMPKinds.h:39
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:27
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Definition: OpenMPKinds.h:103
@ OMPC_DIST_SCHEDULE_unknown
Definition: OpenMPKinds.h:106
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
Definition: OpenMPKinds.h:219
@ OMPC_DOACROSS_unknown
Definition: OpenMPKinds.h:222
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:87
@ Property
The type of a property.
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
Definition: OpenMPKinds.h:200
@ OMPC_BIND_unknown
Definition: OpenMPKinds.h:203
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
Definition: OpenMPKinds.h:157
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition: OpenMPKinds.h:54
@ OMPC_DEPEND_unknown
Definition: OpenMPKinds.h:58
OpenMPGrainsizeClauseModifier
Definition: OpenMPKinds.h:206
@ OMPC_GRAINSIZE_unknown
Definition: OpenMPKinds.h:209
OpenMPNumTasksClauseModifier
Definition: OpenMPKinds.h:212
@ OMPC_NUMTASKS_unknown
Definition: OpenMPKinds.h:215
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
Definition: OpenMPKinds.h:142
@ OMPC_SEVERITY_unknown
Definition: OpenMPKinds.h:145
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
Definition: OpenMPKinds.h:99
OpenMPMotionModifierKind
OpenMP modifier kind for 'to' or 'from' clause.
Definition: OpenMPKinds.h:91
@ OMPC_MOTION_MODIFIER_unknown
Definition: OpenMPKinds.h:95
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
Definition: OpenMPKinds.h:110
@ OMPC_DEFAULTMAP_unknown
Definition: OpenMPKinds.h:114
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition: OpenMPKinds.h:62
const FunctionProtoType * T
OpenMPAtomicDefaultMemOrderClauseKind
OpenMP attributes for 'atomic_default_mem_order' clause.
Definition: OpenMPKinds.h:127
@ OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
Definition: OpenMPKinds.h:131
U cast(CodeGen::Address addr)
Definition: Address.h:325
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition: OpenMPKinds.h:47
@ OMPC_DEVICE_unknown
Definition: OpenMPKinds.h:50
OpenMPMapModifierKind
OpenMP modifier kind for 'map' clause.
Definition: OpenMPKinds.h:78
@ OMPC_MAP_MODIFIER_unknown
Definition: OpenMPKinds.h:79
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
Definition: OpenMPKinds.h:164
@ OMPC_ORDER_unknown
Definition: OpenMPKinds.h:167
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition: OpenMPKinds.h:30
@ OMPC_SCHEDULE_unknown
Definition: OpenMPKinds.h:34
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition: OpenMPKinds.h:70
@ OMPC_MAP_unknown
Definition: OpenMPKinds.h:74
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
#define true
Definition: stdbool.h:25
#define bool
Definition: stdbool.h:24
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