clang 19.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/// 'shedule', '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/// This represents 'allocator' clause in the '#pragma omp ...'
346/// directive.
347///
348/// \code
349/// #pragma omp allocate(a) allocator(omp_default_mem_alloc)
350/// \endcode
351/// In this example directive '#pragma omp allocate' has simple 'allocator'
352/// clause with the allocator 'omp_default_mem_alloc'.
354 : public OMPOneStmtClause<llvm::omp::OMPC_allocator, OMPClause> {
355 friend class OMPClauseReader;
356
357 /// Set allocator.
358 void setAllocator(Expr *A) { setStmt(A); }
359
360public:
361 /// Build 'allocator' clause with the given allocator.
362 ///
363 /// \param A Allocator.
364 /// \param StartLoc Starting location of the clause.
365 /// \param LParenLoc Location of '('.
366 /// \param EndLoc Ending location of the clause.
368 SourceLocation EndLoc)
369 : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
370
371 /// Build an empty clause.
373
374 /// Returns allocator.
375 Expr *getAllocator() const { return getStmtAs<Expr>(); }
376};
377
378/// This represents the 'align' clause in the '#pragma omp allocate'
379/// directive.
380///
381/// \code
382/// #pragma omp allocate(a) allocator(omp_default_mem_alloc) align(8)
383/// \endcode
384/// In this example directive '#pragma omp allocate' has simple 'allocator'
385/// clause with the allocator 'omp_default_mem_alloc' and align clause with
386/// value of 8.
387class OMPAlignClause final
388 : public OMPOneStmtClause<llvm::omp::OMPC_align, OMPClause> {
389 friend class OMPClauseReader;
390
391 /// Set alignment value.
392 void setAlignment(Expr *A) { setStmt(A); }
393
394 /// Build 'align' clause with the given alignment
395 ///
396 /// \param A Alignment value.
397 /// \param StartLoc Starting location of the clause.
398 /// \param LParenLoc Location of '('.
399 /// \param EndLoc Ending location of the clause.
400 OMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc,
401 SourceLocation EndLoc)
402 : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {}
403
404 /// Build an empty clause.
405 OMPAlignClause() : OMPOneStmtClause() {}
406
407public:
408 /// Build 'align' clause with the given alignment
409 ///
410 /// \param A Alignment value.
411 /// \param StartLoc Starting location of the clause.
412 /// \param LParenLoc Location of '('.
413 /// \param EndLoc Ending location of the clause.
414 static OMPAlignClause *Create(const ASTContext &C, Expr *A,
415 SourceLocation StartLoc,
416 SourceLocation LParenLoc,
417 SourceLocation EndLoc);
418
419 /// Returns alignment
420 Expr *getAlignment() const { return getStmtAs<Expr>(); }
421};
422
423/// This represents clause 'allocate' in the '#pragma omp ...' directives.
424///
425/// \code
426/// #pragma omp parallel private(a) allocate(omp_default_mem_alloc :a)
427/// \endcode
428/// In this example directive '#pragma omp parallel' has clause 'private'
429/// and clause 'allocate' for the variable 'a'.
431 : public OMPVarListClause<OMPAllocateClause>,
432 private llvm::TrailingObjects<OMPAllocateClause, Expr *> {
433 friend class OMPClauseReader;
434 friend OMPVarListClause;
435 friend TrailingObjects;
436
437 /// Allocator specified in the clause, or 'nullptr' if the default one is
438 /// used.
439 Expr *Allocator = nullptr;
440 /// Position of the ':' delimiter in the clause;
441 SourceLocation ColonLoc;
442
443 /// Build clause with number of variables \a N.
444 ///
445 /// \param StartLoc Starting location of the clause.
446 /// \param LParenLoc Location of '('.
447 /// \param Allocator Allocator expression.
448 /// \param ColonLoc Location of ':' delimiter.
449 /// \param EndLoc Ending location of the clause.
450 /// \param N Number of the variables in the clause.
452 Expr *Allocator, SourceLocation ColonLoc,
453 SourceLocation EndLoc, unsigned N)
454 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate, StartLoc,
455 LParenLoc, EndLoc, N),
456 Allocator(Allocator), ColonLoc(ColonLoc) {}
457
458 /// Build an empty clause.
459 ///
460 /// \param N Number of variables.
461 explicit OMPAllocateClause(unsigned N)
462 : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate,
464 SourceLocation(), N) {}
465
466 /// Sets location of ':' symbol in clause.
467 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
468
469 void setAllocator(Expr *A) { Allocator = A; }
470
471public:
472 /// Creates clause with a list of variables \a VL.
473 ///
474 /// \param C AST context.
475 /// \param StartLoc Starting location of the clause.
476 /// \param LParenLoc Location of '('.
477 /// \param Allocator Allocator expression.
478 /// \param ColonLoc Location of ':' delimiter.
479 /// \param EndLoc Ending location of the clause.
480 /// \param VL List of references to the variables.
481 static OMPAllocateClause *Create(const ASTContext &C, SourceLocation StartLoc,
482 SourceLocation LParenLoc, Expr *Allocator,
483 SourceLocation ColonLoc,
484 SourceLocation EndLoc, ArrayRef<Expr *> VL);
485
486 /// Returns the allocator expression or nullptr, if no allocator is specified.
487 Expr *getAllocator() const { return Allocator; }
488
489 /// Returns the location of the ':' delimiter.
490 SourceLocation getColonLoc() const { return ColonLoc; }
491
492 /// Creates an empty clause with the place for \a N variables.
493 ///
494 /// \param C AST context.
495 /// \param N The number of variables.
496 static OMPAllocateClause *CreateEmpty(const ASTContext &C, unsigned N);
497
499 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
500 reinterpret_cast<Stmt **>(varlist_end()));
501 }
502
504 auto Children = const_cast<OMPAllocateClause *>(this)->children();
505 return const_child_range(Children.begin(), Children.end());
506 }
507
510 }
513 }
514
515 static bool classof(const OMPClause *T) {
516 return T->getClauseKind() == llvm::omp::OMPC_allocate;
517 }
518};
519
520/// This represents 'if' clause in the '#pragma omp ...' directive.
521///
522/// \code
523/// #pragma omp parallel if(parallel:a > 5)
524/// \endcode
525/// In this example directive '#pragma omp parallel' has simple 'if' clause with
526/// condition 'a > 5' and directive name modifier 'parallel'.
528 friend class OMPClauseReader;
529
530 /// Location of '('.
531 SourceLocation LParenLoc;
532
533 /// Condition of the 'if' clause.
534 Stmt *Condition = nullptr;
535
536 /// Location of ':' (if any).
537 SourceLocation ColonLoc;
538
539 /// Directive name modifier for the clause.
540 OpenMPDirectiveKind NameModifier = llvm::omp::OMPD_unknown;
541
542 /// Name modifier location.
543 SourceLocation NameModifierLoc;
544
545 /// Set condition.
546 void setCondition(Expr *Cond) { Condition = Cond; }
547
548 /// Set directive name modifier for the clause.
549 void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
550
551 /// Set location of directive name modifier for the clause.
552 void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
553
554 /// Set location of ':'.
555 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
556
557public:
558 /// Build 'if' clause with condition \a Cond.
559 ///
560 /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
561 /// \param Cond Condition of the clause.
562 /// \param HelperCond Helper condition for the clause.
563 /// \param CaptureRegion Innermost OpenMP region where expressions in this
564 /// clause must be captured.
565 /// \param StartLoc Starting location of the clause.
566 /// \param LParenLoc Location of '('.
567 /// \param NameModifierLoc Location of directive name modifier.
568 /// \param ColonLoc [OpenMP 4.1] Location of ':'.
569 /// \param EndLoc Ending location of the clause.
570 OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond,
571 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
572 SourceLocation LParenLoc, SourceLocation NameModifierLoc,
573 SourceLocation ColonLoc, SourceLocation EndLoc)
574 : OMPClause(llvm::omp::OMPC_if, StartLoc, EndLoc),
575 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond),
576 ColonLoc(ColonLoc), NameModifier(NameModifier),
577 NameModifierLoc(NameModifierLoc) {
578 setPreInitStmt(HelperCond, CaptureRegion);
579 }
580
581 /// Build an empty clause.
583 : OMPClause(llvm::omp::OMPC_if, SourceLocation(), SourceLocation()),
584 OMPClauseWithPreInit(this) {}
585
586 /// Sets the location of '('.
587 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
588
589 /// Returns the location of '('.
590 SourceLocation getLParenLoc() const { return LParenLoc; }
591
592 /// Return the location of ':'.
593 SourceLocation getColonLoc() const { return ColonLoc; }
594
595 /// Returns condition.
596 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
597
598 /// Return directive name modifier associated with the clause.
599 OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
600
601 /// Return the location of directive name modifier.
602 SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
603
605
608 }
609
612 auto Children = const_cast<OMPIfClause *>(this)->used_children();
613 return const_child_range(Children.begin(), Children.end());
614 }
615
616 static bool classof(const OMPClause *T) {
617 return T->getClauseKind() == llvm::omp::OMPC_if;
618 }
619};
620
621/// This represents 'final' clause in the '#pragma omp ...' directive.
622///
623/// \code
624/// #pragma omp task final(a > 5)
625/// \endcode
626/// In this example directive '#pragma omp task' has simple 'final'
627/// clause with condition 'a > 5'.
628class OMPFinalClause final
629 : public OMPOneStmtClause<llvm::omp::OMPC_final, OMPClause>,
630 public OMPClauseWithPreInit {
631 friend class OMPClauseReader;
632
633 /// Set condition.
634 void setCondition(Expr *Cond) { setStmt(Cond); }
635
636public:
637 /// Build 'final' clause with condition \a Cond.
638 ///
639 /// \param Cond Condition of the clause.
640 /// \param HelperCond Helper condition for the construct.
641 /// \param CaptureRegion Innermost OpenMP region where expressions in this
642 /// clause must be captured.
643 /// \param StartLoc Starting location of the clause.
644 /// \param LParenLoc Location of '('.
645 /// \param EndLoc Ending location of the clause.
646 OMPFinalClause(Expr *Cond, Stmt *HelperCond,
647 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
648 SourceLocation LParenLoc, SourceLocation EndLoc)
649 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
651 setPreInitStmt(HelperCond, CaptureRegion);
652 }
653
654 /// Build an empty clause.
656
657 /// Returns condition.
658 Expr *getCondition() const { return getStmtAs<Expr>(); }
659
662 auto Children = const_cast<OMPFinalClause *>(this)->used_children();
663 return const_child_range(Children.begin(), Children.end());
664 }
665};
666/// This represents 'num_threads' clause in the '#pragma omp ...'
667/// directive.
668///
669/// \code
670/// #pragma omp parallel num_threads(6)
671/// \endcode
672/// In this example directive '#pragma omp parallel' has simple 'num_threads'
673/// clause with number of threads '6'.
675 : public OMPOneStmtClause<llvm::omp::OMPC_num_threads, OMPClause>,
676 public OMPClauseWithPreInit {
677 friend class OMPClauseReader;
678
679 /// Set condition.
680 void setNumThreads(Expr *NThreads) { setStmt(NThreads); }
681
682public:
683 /// Build 'num_threads' clause with condition \a NumThreads.
684 ///
685 /// \param NumThreads Number of threads for the construct.
686 /// \param HelperNumThreads Helper Number of threads for the construct.
687 /// \param CaptureRegion Innermost OpenMP region where expressions in this
688 /// clause must be captured.
689 /// \param StartLoc Starting location of the clause.
690 /// \param LParenLoc Location of '('.
691 /// \param EndLoc Ending location of the clause.
692 OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads,
693 OpenMPDirectiveKind CaptureRegion,
694 SourceLocation StartLoc, SourceLocation LParenLoc,
695 SourceLocation EndLoc)
696 : OMPOneStmtClause(NumThreads, StartLoc, LParenLoc, EndLoc),
698 setPreInitStmt(HelperNumThreads, CaptureRegion);
699 }
700
701 /// Build an empty clause.
703
704 /// Returns number of threads.
705 Expr *getNumThreads() const { return getStmtAs<Expr>(); }
706};
707
708/// This represents 'safelen' clause in the '#pragma omp ...'
709/// directive.
710///
711/// \code
712/// #pragma omp simd safelen(4)
713/// \endcode
714/// In this example directive '#pragma omp simd' has clause 'safelen'
715/// with single expression '4'.
716/// If the safelen clause is used then no two iterations executed
717/// concurrently with SIMD instructions can have a greater distance
718/// in the logical iteration space than its value. The parameter of
719/// the safelen clause must be a constant positive integer expression.
721 : public OMPOneStmtClause<llvm::omp::OMPC_safelen, OMPClause> {
722 friend class OMPClauseReader;
723
724 /// Set safelen.
725 void setSafelen(Expr *Len) { setStmt(Len); }
726
727public:
728 /// Build 'safelen' clause.
729 ///
730 /// \param Len Expression associated with this clause.
731 /// \param StartLoc Starting location of the clause.
732 /// \param EndLoc Ending location of the clause.
734 SourceLocation EndLoc)
735 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
736
737 /// Build an empty clause.
739
740 /// Return safe iteration space distance.
741 Expr *getSafelen() const { return getStmtAs<Expr>(); }
742};
743
744/// This represents 'simdlen' clause in the '#pragma omp ...'
745/// directive.
746///
747/// \code
748/// #pragma omp simd simdlen(4)
749/// \endcode
750/// In this example directive '#pragma omp simd' has clause 'simdlen'
751/// with single expression '4'.
752/// If the 'simdlen' clause is used then it specifies the preferred number of
753/// iterations to be executed concurrently. The parameter of the 'simdlen'
754/// clause must be a constant positive integer expression.
756 : public OMPOneStmtClause<llvm::omp::OMPC_simdlen, OMPClause> {
757 friend class OMPClauseReader;
758
759 /// Set simdlen.
760 void setSimdlen(Expr *Len) { setStmt(Len); }
761
762public:
763 /// Build 'simdlen' clause.
764 ///
765 /// \param Len Expression associated with this clause.
766 /// \param StartLoc Starting location of the clause.
767 /// \param EndLoc Ending location of the clause.
769 SourceLocation EndLoc)
770 : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {}
771
772 /// Build an empty clause.
774
775 /// Return safe iteration space distance.
776 Expr *getSimdlen() const { return getStmtAs<Expr>(); }
777};
778
779/// This represents the 'sizes' clause in the '#pragma omp tile' directive.
780///
781/// \code
782/// #pragma omp tile sizes(5,5)
783/// for (int i = 0; i < 64; ++i)
784/// for (int j = 0; j < 64; ++j)
785/// \endcode
786class OMPSizesClause final
787 : public OMPClause,
788 private llvm::TrailingObjects<OMPSizesClause, Expr *> {
789 friend class OMPClauseReader;
790 friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
791
792 /// Location of '('.
793 SourceLocation LParenLoc;
794
795 /// Number of tile sizes in the clause.
796 unsigned NumSizes;
797
798 /// Build an empty clause.
799 explicit OMPSizesClause(int NumSizes)
800 : OMPClause(llvm::omp::OMPC_sizes, SourceLocation(), SourceLocation()),
801 NumSizes(NumSizes) {}
802
803public:
804 /// Build a 'sizes' AST node.
805 ///
806 /// \param C Context of the AST.
807 /// \param StartLoc Location of the 'sizes' identifier.
808 /// \param LParenLoc Location of '('.
809 /// \param EndLoc Location of ')'.
810 /// \param Sizes Content of the clause.
811 static OMPSizesClause *Create(const ASTContext &C, SourceLocation StartLoc,
812 SourceLocation LParenLoc, SourceLocation EndLoc,
813 ArrayRef<Expr *> Sizes);
814
815 /// Build an empty 'sizes' AST node for deserialization.
816 ///
817 /// \param C Context of the AST.
818 /// \param NumSizes Number of items in the clause.
819 static OMPSizesClause *CreateEmpty(const ASTContext &C, unsigned NumSizes);
820
821 /// Sets the location of '('.
822 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
823
824 /// Returns the location of '('.
825 SourceLocation getLParenLoc() const { return LParenLoc; }
826
827 /// Returns the number of list items.
828 unsigned getNumSizes() const { return NumSizes; }
829
830 /// Returns the tile size expressions.
832 return MutableArrayRef<Expr *>(static_cast<OMPSizesClause *>(this)
833 ->template getTrailingObjects<Expr *>(),
834 NumSizes);
835 }
837 return ArrayRef<Expr *>(static_cast<const OMPSizesClause *>(this)
838 ->template getTrailingObjects<Expr *>(),
839 NumSizes);
840 }
841
842 /// Sets the tile size expressions.
844 assert(VL.size() == NumSizes);
845 std::copy(VL.begin(), VL.end(),
846 static_cast<OMPSizesClause *>(this)
847 ->template getTrailingObjects<Expr *>());
848 }
849
852 return child_range(reinterpret_cast<Stmt **>(Sizes.begin()),
853 reinterpret_cast<Stmt **>(Sizes.end()));
854 }
857 return const_child_range(reinterpret_cast<Stmt *const *>(Sizes.begin()),
858 reinterpret_cast<Stmt *const *>(Sizes.end()));
859 }
860
863 }
866 }
867
868 static bool classof(const OMPClause *T) {
869 return T->getClauseKind() == llvm::omp::OMPC_sizes;
870 }
871};
872
873/// Representation of the 'full' clause of the '#pragma omp unroll' directive.
874///
875/// \code
876/// #pragma omp unroll full
877/// for (int i = 0; i < 64; ++i)
878/// \endcode
879class OMPFullClause final : public OMPNoChildClause<llvm::omp::OMPC_full> {
880 friend class OMPClauseReader;
881
882 /// Build an empty clause.
883 explicit OMPFullClause() : OMPNoChildClause() {}
884
885public:
886 /// Build an AST node for a 'full' clause.
887 ///
888 /// \param C Context of the AST.
889 /// \param StartLoc Starting location of the clause.
890 /// \param EndLoc Ending location of the clause.
891 static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc,
892 SourceLocation EndLoc);
893
894 /// Build an empty 'full' AST node for deserialization.
895 ///
896 /// \param C Context of the AST.
897 static OMPFullClause *CreateEmpty(const ASTContext &C);
898};
899
900/// Representation of the 'partial' clause of the '#pragma omp unroll'
901/// directive.
902///
903/// \code
904/// #pragma omp unroll partial(4)
905/// for (int i = start; i < end; ++i)
906/// \endcode
907class OMPPartialClause final : public OMPClause {
908 friend class OMPClauseReader;
909
910 /// Location of '('.
911 SourceLocation LParenLoc;
912
913 /// Optional argument to the clause (unroll factor).
914 Stmt *Factor;
915
916 /// Build an empty clause.
917 explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {}
918
919 /// Set the unroll factor.
920 void setFactor(Expr *E) { Factor = E; }
921
922 /// Sets the location of '('.
923 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
924
925public:
926 /// Build an AST node for a 'partial' clause.
927 ///
928 /// \param C Context of the AST.
929 /// \param StartLoc Location of the 'partial' identifier.
930 /// \param LParenLoc Location of '('.
931 /// \param EndLoc Location of ')'.
932 /// \param Factor Clause argument.
933 static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc,
934 SourceLocation LParenLoc,
935 SourceLocation EndLoc, Expr *Factor);
936
937 /// Build an empty 'partial' AST node for deserialization.
938 ///
939 /// \param C Context of the AST.
940 static OMPPartialClause *CreateEmpty(const ASTContext &C);
941
942 /// Returns the location of '('.
943 SourceLocation getLParenLoc() const { return LParenLoc; }
944
945 /// Returns the argument of the clause or nullptr if not set.
946 Expr *getFactor() const { return cast_or_null<Expr>(Factor); }
947
948 child_range children() { return child_range(&Factor, &Factor + 1); }
950 return const_child_range(&Factor, &Factor + 1);
951 }
952
955 }
958 }
959
960 static bool classof(const OMPClause *T) {
961 return T->getClauseKind() == llvm::omp::OMPC_partial;
962 }
963};
964
965/// This represents 'collapse' clause in the '#pragma omp ...'
966/// directive.
967///
968/// \code
969/// #pragma omp simd collapse(3)
970/// \endcode
971/// In this example directive '#pragma omp simd' has clause 'collapse'
972/// with single expression '3'.
973/// The parameter must be a constant positive integer expression, it specifies
974/// the number of nested loops that should be collapsed into a single iteration
975/// space.
977 : public OMPOneStmtClause<llvm::omp::OMPC_collapse, OMPClause> {
978 friend class OMPClauseReader;
979
980 /// Set the number of associated for-loops.
981 void setNumForLoops(Expr *Num) { setStmt(Num); }
982
983public:
984 /// Build 'collapse' clause.
985 ///
986 /// \param Num Expression associated with this clause.
987 /// \param StartLoc Starting location of the clause.
988 /// \param LParenLoc Location of '('.
989 /// \param EndLoc Ending location of the clause.
991 SourceLocation LParenLoc, SourceLocation EndLoc)
992 : OMPOneStmtClause(Num, StartLoc, LParenLoc, EndLoc) {}
993
994 /// Build an empty clause.
996
997 /// Return the number of associated for-loops.
998 Expr *getNumForLoops() const { return getStmtAs<Expr>(); }
999};
1000
1001/// This represents 'default' clause in the '#pragma omp ...' directive.
1002///
1003/// \code
1004/// #pragma omp parallel default(shared)
1005/// \endcode
1006/// In this example directive '#pragma omp parallel' has simple 'default'
1007/// clause with kind 'shared'.
1009 friend class OMPClauseReader;
1010
1011 /// Location of '('.
1012 SourceLocation LParenLoc;
1013
1014 /// A kind of the 'default' clause.
1015 llvm::omp::DefaultKind Kind = llvm::omp::OMP_DEFAULT_unknown;
1016
1017 /// Start location of the kind in source code.
1018 SourceLocation KindKwLoc;
1019
1020 /// Set kind of the clauses.
1021 ///
1022 /// \param K Argument of clause.
1023 void setDefaultKind(llvm::omp::DefaultKind K) { Kind = K; }
1024
1025 /// Set argument location.
1026 ///
1027 /// \param KLoc Argument location.
1028 void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1029
1030public:
1031 /// Build 'default' clause with argument \a A ('none' or 'shared').
1032 ///
1033 /// \param A Argument of the clause ('none' or 'shared').
1034 /// \param ALoc Starting location of the argument.
1035 /// \param StartLoc Starting location of the clause.
1036 /// \param LParenLoc Location of '('.
1037 /// \param EndLoc Ending location of the clause.
1038 OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc,
1039 SourceLocation StartLoc, SourceLocation LParenLoc,
1040 SourceLocation EndLoc)
1041 : OMPClause(llvm::omp::OMPC_default, StartLoc, EndLoc),
1042 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1043
1044 /// Build an empty clause.
1046 : OMPClause(llvm::omp::OMPC_default, SourceLocation(), SourceLocation()) {
1047 }
1048
1049 /// Sets the location of '('.
1050 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1051
1052 /// Returns the location of '('.
1053 SourceLocation getLParenLoc() const { return LParenLoc; }
1054
1055 /// Returns kind of the clause.
1056 llvm::omp::DefaultKind getDefaultKind() const { return Kind; }
1057
1058 /// Returns location of clause kind.
1059 SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
1060
1063 }
1064
1067 }
1068
1071 }
1074 }
1075
1076 static bool classof(const OMPClause *T) {
1077 return T->getClauseKind() == llvm::omp::OMPC_default;
1078 }
1079};
1080
1081/// This represents 'proc_bind' clause in the '#pragma omp ...'
1082/// directive.
1083///
1084/// \code
1085/// #pragma omp parallel proc_bind(master)
1086/// \endcode
1087/// In this example directive '#pragma omp parallel' has simple 'proc_bind'
1088/// clause with kind 'master'.
1090 friend class OMPClauseReader;
1091
1092 /// Location of '('.
1093 SourceLocation LParenLoc;
1094
1095 /// A kind of the 'proc_bind' clause.
1096 llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown;
1097
1098 /// Start location of the kind in source code.
1099 SourceLocation KindKwLoc;
1100
1101 /// Set kind of the clause.
1102 ///
1103 /// \param K Kind of clause.
1104 void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; }
1105
1106 /// Set clause kind location.
1107 ///
1108 /// \param KLoc Kind location.
1109 void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1110
1111public:
1112 /// Build 'proc_bind' clause with argument \a A ('master', 'close' or
1113 /// 'spread').
1114 ///
1115 /// \param A Argument of the clause ('master', 'close' or 'spread').
1116 /// \param ALoc Starting location of the argument.
1117 /// \param StartLoc Starting location of the clause.
1118 /// \param LParenLoc Location of '('.
1119 /// \param EndLoc Ending location of the clause.
1120 OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc,
1121 SourceLocation StartLoc, SourceLocation LParenLoc,
1122 SourceLocation EndLoc)
1123 : OMPClause(llvm::omp::OMPC_proc_bind, StartLoc, EndLoc),
1124 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1125
1126 /// Build an empty clause.
1128 : OMPClause(llvm::omp::OMPC_proc_bind, SourceLocation(),
1129 SourceLocation()) {}
1130
1131 /// Sets the location of '('.
1132 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1133
1134 /// Returns the location of '('.
1135 SourceLocation getLParenLoc() const { return LParenLoc; }
1136
1137 /// Returns kind of the clause.
1138 llvm::omp::ProcBindKind getProcBindKind() const { return Kind; }
1139
1140 /// Returns location of clause kind.
1141 SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
1142
1145 }
1146
1149 }
1150
1153 }
1156 }
1157
1158 static bool classof(const OMPClause *T) {
1159 return T->getClauseKind() == llvm::omp::OMPC_proc_bind;
1160 }
1161};
1162
1163/// This represents 'unified_address' clause in the '#pragma omp requires'
1164/// directive.
1165///
1166/// \code
1167/// #pragma omp requires unified_address
1168/// \endcode
1169/// In this example directive '#pragma omp requires' has 'unified_address'
1170/// clause.
1172 : public OMPNoChildClause<llvm::omp::OMPC_unified_address> {
1173public:
1174 friend class OMPClauseReader;
1175 /// Build 'unified_address' clause.
1176 ///
1177 /// \param StartLoc Starting location of the clause.
1178 /// \param EndLoc Ending location of the clause.
1180 : OMPNoChildClause(StartLoc, EndLoc) {}
1181
1182 /// Build an empty clause.
1184};
1185
1186/// This represents 'unified_shared_memory' clause in the '#pragma omp requires'
1187/// directive.
1188///
1189/// \code
1190/// #pragma omp requires unified_shared_memory
1191/// \endcode
1192/// In this example directive '#pragma omp requires' has 'unified_shared_memory'
1193/// clause.
1195public:
1196 friend class OMPClauseReader;
1197 /// Build 'unified_shared_memory' clause.
1198 ///
1199 /// \param StartLoc Starting location of the clause.
1200 /// \param EndLoc Ending location of the clause.
1202 : OMPClause(llvm::omp::OMPC_unified_shared_memory, StartLoc, EndLoc) {}
1203
1204 /// Build an empty clause.
1206 : OMPClause(llvm::omp::OMPC_unified_shared_memory, SourceLocation(),
1207 SourceLocation()) {}
1208
1211 }
1212
1215 }
1216
1219 }
1222 }
1223
1224 static bool classof(const OMPClause *T) {
1225 return T->getClauseKind() == llvm::omp::OMPC_unified_shared_memory;
1226 }
1227};
1228
1229/// This represents 'reverse_offload' clause in the '#pragma omp requires'
1230/// directive.
1231///
1232/// \code
1233/// #pragma omp requires reverse_offload
1234/// \endcode
1235/// In this example directive '#pragma omp requires' has 'reverse_offload'
1236/// clause.
1238public:
1239 friend class OMPClauseReader;
1240 /// Build 'reverse_offload' clause.
1241 ///
1242 /// \param StartLoc Starting location of the clause.
1243 /// \param EndLoc Ending location of the clause.
1245 : OMPClause(llvm::omp::OMPC_reverse_offload, StartLoc, EndLoc) {}
1246
1247 /// Build an empty clause.
1249 : OMPClause(llvm::omp::OMPC_reverse_offload, SourceLocation(),
1250 SourceLocation()) {}
1251
1254 }
1255
1258 }
1259
1262 }
1265 }
1266
1267 static bool classof(const OMPClause *T) {
1268 return T->getClauseKind() == llvm::omp::OMPC_reverse_offload;
1269 }
1270};
1271
1272/// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
1273/// directive.
1274///
1275/// \code
1276/// #pragma omp requires dynamic_allocators
1277/// \endcode
1278/// In this example directive '#pragma omp requires' has 'dynamic_allocators'
1279/// clause.
1281public:
1282 friend class OMPClauseReader;
1283 /// Build 'dynamic_allocators' clause.
1284 ///
1285 /// \param StartLoc Starting location of the clause.
1286 /// \param EndLoc Ending location of the clause.
1288 : OMPClause(llvm::omp::OMPC_dynamic_allocators, StartLoc, EndLoc) {}
1289
1290 /// Build an empty clause.
1292 : OMPClause(llvm::omp::OMPC_dynamic_allocators, SourceLocation(),
1293 SourceLocation()) {}
1294
1297 }
1298
1301 }
1302
1305 }
1308 }
1309
1310 static bool classof(const OMPClause *T) {
1311 return T->getClauseKind() == llvm::omp::OMPC_dynamic_allocators;
1312 }
1313};
1314
1315/// This represents 'atomic_default_mem_order' clause in the '#pragma omp
1316/// requires' directive.
1317///
1318/// \code
1319/// #pragma omp requires atomic_default_mem_order(seq_cst)
1320/// \endcode
1321/// In this example directive '#pragma omp requires' has simple
1322/// atomic_default_mem_order' clause with kind 'seq_cst'.
1324 friend class OMPClauseReader;
1325
1326 /// Location of '('
1327 SourceLocation LParenLoc;
1328
1329 /// A kind of the 'atomic_default_mem_order' clause.
1332
1333 /// Start location of the kind in source code.
1334 SourceLocation KindKwLoc;
1335
1336 /// Set kind of the clause.
1337 ///
1338 /// \param K Kind of clause.
1339 void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) {
1340 Kind = K;
1341 }
1342
1343 /// Set clause kind location.
1344 ///
1345 /// \param KLoc Kind location.
1346 void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) {
1347 KindKwLoc = KLoc;
1348 }
1349
1350public:
1351 /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst',
1352 /// 'acq_rel' or 'relaxed').
1353 ///
1354 /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed').
1355 /// \param ALoc Starting location of the argument.
1356 /// \param StartLoc Starting location of the clause.
1357 /// \param LParenLoc Location of '('.
1358 /// \param EndLoc Ending location of the clause.
1360 SourceLocation ALoc, SourceLocation StartLoc,
1361 SourceLocation LParenLoc,
1362 SourceLocation EndLoc)
1363 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, StartLoc, EndLoc),
1364 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1365
1366 /// Build an empty clause.
1368 : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, SourceLocation(),
1369 SourceLocation()) {}
1370
1371 /// Sets the location of '('.
1372 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1373
1374 /// Returns the locaiton of '('.
1375 SourceLocation getLParenLoc() const { return LParenLoc; }
1376
1377 /// Returns kind of the clause.
1379 return Kind;
1380 }
1381
1382 /// Returns location of clause kind.
1384
1387 }
1388
1391 }
1392
1395 }
1398 }
1399
1400 static bool classof(const OMPClause *T) {
1401 return T->getClauseKind() == llvm::omp::OMPC_atomic_default_mem_order;
1402 }
1403};
1404
1405/// This represents 'at' clause in the '#pragma omp error' directive
1406///
1407/// \code
1408/// #pragma omp error at(compilation)
1409/// \endcode
1410/// In this example directive '#pragma omp error' has simple
1411/// 'at' clause with kind 'complilation'.
1412class OMPAtClause final : public OMPClause {
1413 friend class OMPClauseReader;
1414
1415 /// Location of '('
1416 SourceLocation LParenLoc;
1417
1418 /// A kind of the 'at' clause.
1420
1421 /// Start location of the kind in source code.
1422 SourceLocation KindKwLoc;
1423
1424 /// Set kind of the clause.
1425 ///
1426 /// \param K Kind of clause.
1427 void setAtKind(OpenMPAtClauseKind K) { Kind = K; }
1428
1429 /// Set clause kind location.
1430 ///
1431 /// \param KLoc Kind location.
1432 void setAtKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1433
1434 /// Sets the location of '('.
1435 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1436
1437public:
1438 /// Build 'at' clause with argument \a A ('compilation' or 'execution').
1439 ///
1440 /// \param A Argument of the clause ('compilation' or 'execution').
1441 /// \param ALoc Starting location of the argument.
1442 /// \param StartLoc Starting location of the clause.
1443 /// \param LParenLoc Location of '('.
1444 /// \param EndLoc Ending location of the clause.
1446 SourceLocation StartLoc, SourceLocation LParenLoc,
1447 SourceLocation EndLoc)
1448 : OMPClause(llvm::omp::OMPC_at, StartLoc, EndLoc), LParenLoc(LParenLoc),
1449 Kind(A), KindKwLoc(ALoc) {}
1450
1451 /// Build an empty clause.
1453 : OMPClause(llvm::omp::OMPC_at, SourceLocation(), SourceLocation()) {}
1454
1455 /// Returns the locaiton of '('.
1456 SourceLocation getLParenLoc() const { return LParenLoc; }
1457
1458 /// Returns kind of the clause.
1459 OpenMPAtClauseKind getAtKind() const { return Kind; }
1460
1461 /// Returns location of clause kind.
1462 SourceLocation getAtKindKwLoc() const { return KindKwLoc; }
1463
1466 }
1467
1470 }
1471
1474 }
1477 }
1478
1479 static bool classof(const OMPClause *T) {
1480 return T->getClauseKind() == llvm::omp::OMPC_at;
1481 }
1482};
1483
1484/// This represents 'severity' clause in the '#pragma omp error' directive
1485///
1486/// \code
1487/// #pragma omp error severity(fatal)
1488/// \endcode
1489/// In this example directive '#pragma omp error' has simple
1490/// 'severity' clause with kind 'fatal'.
1491class OMPSeverityClause final : public OMPClause {
1492 friend class OMPClauseReader;
1493
1494 /// Location of '('
1495 SourceLocation LParenLoc;
1496
1497 /// A kind of the 'severity' clause.
1499
1500 /// Start location of the kind in source code.
1501 SourceLocation KindKwLoc;
1502
1503 /// Set kind of the clause.
1504 ///
1505 /// \param K Kind of clause.
1506 void setSeverityKind(OpenMPSeverityClauseKind K) { Kind = K; }
1507
1508 /// Set clause kind location.
1509 ///
1510 /// \param KLoc Kind location.
1511 void setSeverityKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
1512
1513 /// Sets the location of '('.
1514 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1515
1516public:
1517 /// Build 'severity' clause with argument \a A ('fatal' or 'warning').
1518 ///
1519 /// \param A Argument of the clause ('fatal' or 'warning').
1520 /// \param ALoc Starting location of the argument.
1521 /// \param StartLoc Starting location of the clause.
1522 /// \param LParenLoc Location of '('.
1523 /// \param EndLoc Ending location of the clause.
1525 SourceLocation StartLoc, SourceLocation LParenLoc,
1526 SourceLocation EndLoc)
1527 : OMPClause(llvm::omp::OMPC_severity, StartLoc, EndLoc),
1528 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1529
1530 /// Build an empty clause.
1532 : OMPClause(llvm::omp::OMPC_severity, SourceLocation(),
1533 SourceLocation()) {}
1534
1535 /// Returns the locaiton of '('.
1536 SourceLocation getLParenLoc() const { return LParenLoc; }
1537
1538 /// Returns kind of the clause.
1540
1541 /// Returns location of clause kind.
1542 SourceLocation getSeverityKindKwLoc() const { return KindKwLoc; }
1543
1546 }
1547
1550 }
1551
1554 }
1557 }
1558
1559 static bool classof(const OMPClause *T) {
1560 return T->getClauseKind() == llvm::omp::OMPC_severity;
1561 }
1562};
1563
1564/// This represents 'message' clause in the '#pragma omp error' directive
1565///
1566/// \code
1567/// #pragma omp error message("GNU compiler required.")
1568/// \endcode
1569/// In this example directive '#pragma omp error' has simple
1570/// 'message' clause with user error message of "GNU compiler required.".
1571class OMPMessageClause final : public OMPClause {
1572 friend class OMPClauseReader;
1573
1574 /// Location of '('
1575 SourceLocation LParenLoc;
1576
1577 // Expression of the 'message' clause.
1578 Stmt *MessageString = nullptr;
1579
1580 /// Set message string of the clause.
1581 void setMessageString(Expr *MS) { MessageString = MS; }
1582
1583 /// Sets the location of '('.
1584 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1585
1586public:
1587 /// Build 'message' clause with message string argument
1588 ///
1589 /// \param MS Argument of the clause (message string).
1590 /// \param StartLoc Starting location of the clause.
1591 /// \param LParenLoc Location of '('.
1592 /// \param EndLoc Ending location of the clause.
1594 SourceLocation EndLoc)
1595 : OMPClause(llvm::omp::OMPC_message, StartLoc, EndLoc),
1596 LParenLoc(LParenLoc), MessageString(MS) {}
1597
1598 /// Build an empty clause.
1600 : OMPClause(llvm::omp::OMPC_message, SourceLocation(), SourceLocation()) {
1601 }
1602
1603 /// Returns the locaiton of '('.
1604 SourceLocation getLParenLoc() const { return LParenLoc; }
1605
1606 /// Returns message string of the clause.
1607 Expr *getMessageString() const { return cast_or_null<Expr>(MessageString); }
1608
1610 return child_range(&MessageString, &MessageString + 1);
1611 }
1612
1614 return const_child_range(&MessageString, &MessageString + 1);
1615 }
1616
1619 }
1620
1623 }
1624
1625 static bool classof(const OMPClause *T) {
1626 return T->getClauseKind() == llvm::omp::OMPC_message;
1627 }
1628};
1629
1630/// This represents 'schedule' clause in the '#pragma omp ...' directive.
1631///
1632/// \code
1633/// #pragma omp for schedule(static, 3)
1634/// \endcode
1635/// In this example directive '#pragma omp for' has 'schedule' clause with
1636/// arguments 'static' and '3'.
1638 friend class OMPClauseReader;
1639
1640 /// Location of '('.
1641 SourceLocation LParenLoc;
1642
1643 /// A kind of the 'schedule' clause.
1645
1646 /// Modifiers for 'schedule' clause.
1647 enum {FIRST, SECOND, NUM_MODIFIERS};
1648 OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
1649
1650 /// Locations of modifiers.
1651 SourceLocation ModifiersLoc[NUM_MODIFIERS];
1652
1653 /// Start location of the schedule ind in source code.
1654 SourceLocation KindLoc;
1655
1656 /// Location of ',' (if any).
1657 SourceLocation CommaLoc;
1658
1659 /// Chunk size.
1660 Expr *ChunkSize = nullptr;
1661
1662 /// Set schedule kind.
1663 ///
1664 /// \param K Schedule kind.
1665 void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
1666
1667 /// Set the first schedule modifier.
1668 ///
1669 /// \param M Schedule modifier.
1670 void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
1671 Modifiers[FIRST] = M;
1672 }
1673
1674 /// Set the second schedule modifier.
1675 ///
1676 /// \param M Schedule modifier.
1677 void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
1678 Modifiers[SECOND] = M;
1679 }
1680
1681 /// Set location of the first schedule modifier.
1682 void setFirstScheduleModifierLoc(SourceLocation Loc) {
1683 ModifiersLoc[FIRST] = Loc;
1684 }
1685
1686 /// Set location of the second schedule modifier.
1687 void setSecondScheduleModifierLoc(SourceLocation Loc) {
1688 ModifiersLoc[SECOND] = Loc;
1689 }
1690
1691 /// Set schedule modifier location.
1692 ///
1693 /// \param M Schedule modifier location.
1694 void setScheduleModifer(OpenMPScheduleClauseModifier M) {
1695 if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
1696 Modifiers[FIRST] = M;
1697 else {
1698 assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
1699 Modifiers[SECOND] = M;
1700 }
1701 }
1702
1703 /// Sets the location of '('.
1704 ///
1705 /// \param Loc Location of '('.
1706 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1707
1708 /// Set schedule kind start location.
1709 ///
1710 /// \param KLoc Schedule kind location.
1711 void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
1712
1713 /// Set location of ','.
1714 ///
1715 /// \param Loc Location of ','.
1716 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
1717
1718 /// Set chunk size.
1719 ///
1720 /// \param E Chunk size.
1721 void setChunkSize(Expr *E) { ChunkSize = E; }
1722
1723public:
1724 /// Build 'schedule' clause with schedule kind \a Kind and chunk size
1725 /// expression \a ChunkSize.
1726 ///
1727 /// \param StartLoc Starting location of the clause.
1728 /// \param LParenLoc Location of '('.
1729 /// \param KLoc Starting location of the argument.
1730 /// \param CommaLoc Location of ','.
1731 /// \param EndLoc Ending location of the clause.
1732 /// \param Kind Schedule kind.
1733 /// \param ChunkSize Chunk size.
1734 /// \param HelperChunkSize Helper chunk size for combined directives.
1735 /// \param M1 The first modifier applied to 'schedule' clause.
1736 /// \param M1Loc Location of the first modifier
1737 /// \param M2 The second modifier applied to 'schedule' clause.
1738 /// \param M2Loc Location of the second modifier
1740 SourceLocation KLoc, SourceLocation CommaLoc,
1742 Expr *ChunkSize, Stmt *HelperChunkSize,
1745 : OMPClause(llvm::omp::OMPC_schedule, StartLoc, EndLoc),
1746 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
1747 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
1748 setPreInitStmt(HelperChunkSize);
1749 Modifiers[FIRST] = M1;
1750 Modifiers[SECOND] = M2;
1751 ModifiersLoc[FIRST] = M1Loc;
1752 ModifiersLoc[SECOND] = M2Loc;
1753 }
1754
1755 /// Build an empty clause.
1757 : OMPClause(llvm::omp::OMPC_schedule, SourceLocation(), SourceLocation()),
1758 OMPClauseWithPreInit(this) {
1759 Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
1760 Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
1761 }
1762
1763 /// Get kind of the clause.
1765
1766 /// Get the first modifier of the clause.
1768 return Modifiers[FIRST];
1769 }
1770
1771 /// Get the second modifier of the clause.
1773 return Modifiers[SECOND];
1774 }
1775
1776 /// Get location of '('.
1777 SourceLocation getLParenLoc() { return LParenLoc; }
1778
1779 /// Get kind location.
1781
1782 /// Get the first modifier location.
1784 return ModifiersLoc[FIRST];
1785 }
1786
1787 /// Get the second modifier location.
1789 return ModifiersLoc[SECOND];
1790 }
1791
1792 /// Get location of ','.
1793 SourceLocation getCommaLoc() { return CommaLoc; }
1794
1795 /// Get chunk size.
1796 Expr *getChunkSize() { return ChunkSize; }
1797
1798 /// Get chunk size.
1799 const Expr *getChunkSize() const { return ChunkSize; }
1800
1802 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
1803 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
1804 }
1805
1807 auto Children = const_cast<OMPScheduleClause *>(this)->children();
1808 return const_child_range(Children.begin(), Children.end());
1809 }
1810
1813 }
1816 }
1817
1818 static bool classof(const OMPClause *T) {
1819 return T->getClauseKind() == llvm::omp::OMPC_schedule;
1820 }
1821};
1822
1823/// This represents 'ordered' clause in the '#pragma omp ...' directive.
1824///
1825/// \code
1826/// #pragma omp for ordered (2)
1827/// \endcode
1828/// In this example directive '#pragma omp for' has 'ordered' clause with
1829/// parameter 2.
1831 : public OMPClause,
1832 private llvm::TrailingObjects<OMPOrderedClause, Expr *> {
1833 friend class OMPClauseReader;
1834 friend TrailingObjects;
1835
1836 /// Location of '('.
1837 SourceLocation LParenLoc;
1838
1839 /// Number of for-loops.
1840 Stmt *NumForLoops = nullptr;
1841
1842 /// Real number of loops.
1843 unsigned NumberOfLoops = 0;
1844
1845 /// Build 'ordered' clause.
1846 ///
1847 /// \param Num Expression, possibly associated with this clause.
1848 /// \param NumLoops Number of loops, associated with this clause.
1849 /// \param StartLoc Starting location of the clause.
1850 /// \param LParenLoc Location of '('.
1851 /// \param EndLoc Ending location of the clause.
1852 OMPOrderedClause(Expr *Num, unsigned NumLoops, SourceLocation StartLoc,
1853 SourceLocation LParenLoc, SourceLocation EndLoc)
1854 : OMPClause(llvm::omp::OMPC_ordered, StartLoc, EndLoc),
1855 LParenLoc(LParenLoc), NumForLoops(Num), NumberOfLoops(NumLoops) {}
1856
1857 /// Build an empty clause.
1858 explicit OMPOrderedClause(unsigned NumLoops)
1859 : OMPClause(llvm::omp::OMPC_ordered, SourceLocation(), SourceLocation()),
1860 NumberOfLoops(NumLoops) {}
1861
1862 /// Set the number of associated for-loops.
1863 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
1864
1865public:
1866 /// Build 'ordered' clause.
1867 ///
1868 /// \param Num Expression, possibly associated with this clause.
1869 /// \param NumLoops Number of loops, associated with this clause.
1870 /// \param StartLoc Starting location of the clause.
1871 /// \param LParenLoc Location of '('.
1872 /// \param EndLoc Ending location of the clause.
1873 static OMPOrderedClause *Create(const ASTContext &C, Expr *Num,
1874 unsigned NumLoops, SourceLocation StartLoc,
1875 SourceLocation LParenLoc,
1876 SourceLocation EndLoc);
1877
1878 /// Build an empty clause.
1879 static OMPOrderedClause* CreateEmpty(const ASTContext &C, unsigned NumLoops);
1880
1881 /// Sets the location of '('.
1882 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1883
1884 /// Returns the location of '('.
1885 SourceLocation getLParenLoc() const { return LParenLoc; }
1886
1887 /// Return the number of associated for-loops.
1888 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
1889
1890 /// Set number of iterations for the specified loop.
1891 void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations);
1892 /// Get number of iterations for all the loops.
1894
1895 /// Set loop counter for the specified loop.
1896 void setLoopCounter(unsigned NumLoop, Expr *Counter);
1897 /// Get loops counter for the specified loop.
1898 Expr *getLoopCounter(unsigned NumLoop);
1899 const Expr *getLoopCounter(unsigned NumLoop) const;
1900
1901 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
1902
1904 return const_child_range(&NumForLoops, &NumForLoops + 1);
1905 }
1906
1909 }
1912 }
1913
1914 static bool classof(const OMPClause *T) {
1915 return T->getClauseKind() == llvm::omp::OMPC_ordered;
1916 }
1917};
1918
1919/// This represents 'nowait' clause in the '#pragma omp ...' directive.
1920///
1921/// \code
1922/// #pragma omp for nowait
1923/// \endcode
1924/// In this example directive '#pragma omp for' has 'nowait' clause.
1925class OMPNowaitClause final : public OMPNoChildClause<llvm::omp::OMPC_nowait> {
1926public:
1927 /// Build 'nowait' clause.
1928 ///
1929 /// \param StartLoc Starting location of the clause.
1930 /// \param EndLoc Ending location of the clause.
1932 SourceLocation EndLoc = SourceLocation())
1933 : OMPNoChildClause(StartLoc, EndLoc) {}
1934};
1935
1936/// This represents 'untied' clause in the '#pragma omp ...' directive.
1937///
1938/// \code
1939/// #pragma omp task untied
1940/// \endcode
1941/// In this example directive '#pragma omp task' has 'untied' clause.
1943public:
1944 /// Build 'untied' clause.
1945 ///
1946 /// \param StartLoc Starting location of the clause.
1947 /// \param EndLoc Ending location of the clause.
1949 : OMPClause(llvm::omp::OMPC_untied, StartLoc, EndLoc) {}
1950
1951 /// Build an empty clause.
1953 : OMPClause(llvm::omp::OMPC_untied, SourceLocation(), SourceLocation()) {}
1954
1957 }
1958
1961 }
1962
1965 }
1968 }
1969
1970 static bool classof(const OMPClause *T) {
1971 return T->getClauseKind() == llvm::omp::OMPC_untied;
1972 }
1973};
1974
1975/// This represents 'mergeable' clause in the '#pragma omp ...'
1976/// directive.
1977///
1978/// \code
1979/// #pragma omp task mergeable
1980/// \endcode
1981/// In this example directive '#pragma omp task' has 'mergeable' clause.
1983public:
1984 /// Build 'mergeable' clause.
1985 ///
1986 /// \param StartLoc Starting location of the clause.
1987 /// \param EndLoc Ending location of the clause.
1989 : OMPClause(llvm::omp::OMPC_mergeable, StartLoc, EndLoc) {}
1990
1991 /// Build an empty clause.
1993 : OMPClause(llvm::omp::OMPC_mergeable, SourceLocation(),
1994 SourceLocation()) {}
1995
1998 }
1999
2002 }
2003
2006 }
2009 }
2010
2011 static bool classof(const OMPClause *T) {
2012 return T->getClauseKind() == llvm::omp::OMPC_mergeable;
2013 }
2014};
2015
2016/// This represents 'read' clause in the '#pragma omp atomic' directive.
2017///
2018/// \code
2019/// #pragma omp atomic read
2020/// \endcode
2021/// In this example directive '#pragma omp atomic' has 'read' clause.
2022class OMPReadClause : public OMPClause {
2023public:
2024 /// Build 'read' clause.
2025 ///
2026 /// \param StartLoc Starting location of the clause.
2027 /// \param EndLoc Ending location of the clause.
2029 : OMPClause(llvm::omp::OMPC_read, StartLoc, EndLoc) {}
2030
2031 /// Build an empty clause.
2033 : OMPClause(llvm::omp::OMPC_read, SourceLocation(), SourceLocation()) {}
2034
2037 }
2038
2041 }
2042
2045 }
2048 }
2049
2050 static bool classof(const OMPClause *T) {
2051 return T->getClauseKind() == llvm::omp::OMPC_read;
2052 }
2053};
2054
2055/// This represents 'write' clause in the '#pragma omp atomic' directive.
2056///
2057/// \code
2058/// #pragma omp atomic write
2059/// \endcode
2060/// In this example directive '#pragma omp atomic' has 'write' clause.
2062public:
2063 /// Build 'write' clause.
2064 ///
2065 /// \param StartLoc Starting location of the clause.
2066 /// \param EndLoc Ending location of the clause.
2068 : OMPClause(llvm::omp::OMPC_write, StartLoc, EndLoc) {}
2069
2070 /// Build an empty clause.
2072 : OMPClause(llvm::omp::OMPC_write, SourceLocation(), SourceLocation()) {}
2073
2076 }
2077
2080 }
2081
2084 }
2087 }
2088
2089 static bool classof(const OMPClause *T) {
2090 return T->getClauseKind() == llvm::omp::OMPC_write;
2091 }
2092};
2093
2094/// This represents 'update' clause in the '#pragma omp atomic'
2095/// directive.
2096///
2097/// \code
2098/// #pragma omp atomic update
2099/// \endcode
2100/// In this example directive '#pragma omp atomic' has 'update' clause.
2101/// Also, this class represents 'update' clause in '#pragma omp depobj'
2102/// directive.
2103///
2104/// \code
2105/// #pragma omp depobj(a) update(in)
2106/// \endcode
2107/// In this example directive '#pragma omp depobj' has 'update' clause with 'in'
2108/// dependence kind.
2110 : public OMPClause,
2111 private llvm::TrailingObjects<OMPUpdateClause, SourceLocation,
2112 OpenMPDependClauseKind> {
2113 friend class OMPClauseReader;
2114 friend TrailingObjects;
2115
2116 /// true if extended version of the clause for 'depobj' directive.
2117 bool IsExtended = false;
2118
2119 /// Define the sizes of each trailing object array except the last one. This
2120 /// is required for TrailingObjects to work properly.
2121 size_t numTrailingObjects(OverloadToken<SourceLocation>) const {
2122 // 2 locations: for '(' and argument location.
2123 return IsExtended ? 2 : 0;
2124 }
2125
2126 /// Sets the location of '(' in clause for 'depobj' directive.
2127 void setLParenLoc(SourceLocation Loc) {
2128 assert(IsExtended && "Expected extended clause.");
2129 *getTrailingObjects<SourceLocation>() = Loc;
2130 }
2131
2132 /// Sets the location of '(' in clause for 'depobj' directive.
2133 void setArgumentLoc(SourceLocation Loc) {
2134 assert(IsExtended && "Expected extended clause.");
2135 *std::next(getTrailingObjects<SourceLocation>(), 1) = Loc;
2136 }
2137
2138 /// Sets the dependence kind for the clause for 'depobj' directive.
2139 void setDependencyKind(OpenMPDependClauseKind DK) {
2140 assert(IsExtended && "Expected extended clause.");
2141 *getTrailingObjects<OpenMPDependClauseKind>() = DK;
2142 }
2143
2144 /// Build 'update' clause.
2145 ///
2146 /// \param StartLoc Starting location of the clause.
2147 /// \param EndLoc Ending location of the clause.
2148 OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc,
2149 bool IsExtended)
2150 : OMPClause(llvm::omp::OMPC_update, StartLoc, EndLoc),
2151 IsExtended(IsExtended) {}
2152
2153 /// Build an empty clause.
2154 OMPUpdateClause(bool IsExtended)
2155 : OMPClause(llvm::omp::OMPC_update, SourceLocation(), SourceLocation()),
2156 IsExtended(IsExtended) {}
2157
2158public:
2159 /// Creates clause for 'atomic' directive.
2160 ///
2161 /// \param C AST context.
2162 /// \param StartLoc Starting location of the clause.
2163 /// \param EndLoc Ending location of the clause.
2164 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2165 SourceLocation EndLoc);
2166
2167 /// Creates clause for 'depobj' directive.
2168 ///
2169 /// \param C AST context.
2170 /// \param StartLoc Starting location of the clause.
2171 /// \param LParenLoc Location of '('.
2172 /// \param ArgumentLoc Location of the argument.
2173 /// \param DK Dependence kind.
2174 /// \param EndLoc Ending location of the clause.
2175 static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2176 SourceLocation LParenLoc,
2177 SourceLocation ArgumentLoc,
2179 SourceLocation EndLoc);
2180
2181 /// Creates an empty clause with the place for \a N variables.
2182 ///
2183 /// \param C AST context.
2184 /// \param IsExtended true if extended clause for 'depobj' directive must be
2185 /// created.
2186 static OMPUpdateClause *CreateEmpty(const ASTContext &C, bool IsExtended);
2187
2188 /// Checks if the clause is the extended clauses for 'depobj' directive.
2189 bool isExtended() const { return IsExtended; }
2190
2193 }
2194
2197 }
2198
2201 }
2204 }
2205
2206 /// Gets the location of '(' in clause for 'depobj' directive.
2208 assert(IsExtended && "Expected extended clause.");
2209 return *getTrailingObjects<SourceLocation>();
2210 }
2211
2212 /// Gets the location of argument in clause for 'depobj' directive.
2214 assert(IsExtended && "Expected extended clause.");
2215 return *std::next(getTrailingObjects<SourceLocation>(), 1);
2216 }
2217
2218 /// Gets the dependence kind in clause for 'depobj' directive.
2220 assert(IsExtended && "Expected extended clause.");
2221 return *getTrailingObjects<OpenMPDependClauseKind>();
2222 }
2223
2224 static bool classof(const OMPClause *T) {
2225 return T->getClauseKind() == llvm::omp::OMPC_update;
2226 }
2227};
2228
2229/// This represents 'capture' clause in the '#pragma omp atomic'
2230/// directive.
2231///
2232/// \code
2233/// #pragma omp atomic capture
2234/// \endcode
2235/// In this example directive '#pragma omp atomic' has 'capture' clause.
2237public:
2238 /// Build 'capture' clause.
2239 ///
2240 /// \param StartLoc Starting location of the clause.
2241 /// \param EndLoc Ending location of the clause.
2243 : OMPClause(llvm::omp::OMPC_capture, StartLoc, EndLoc) {}
2244
2245 /// Build an empty clause.
2247 : OMPClause(llvm::omp::OMPC_capture, SourceLocation(), SourceLocation()) {
2248 }
2249
2252 }
2253
2256 }
2257
2260 }
2263 }
2264
2265 static bool classof(const OMPClause *T) {
2266 return T->getClauseKind() == llvm::omp::OMPC_capture;
2267 }
2268};
2269
2270/// This represents 'compare' clause in the '#pragma omp atomic'
2271/// directive.
2272///
2273/// \code
2274/// #pragma omp atomic compare
2275/// \endcode
2276/// In this example directive '#pragma omp atomic' has 'compare' clause.
2277class OMPCompareClause final : public OMPClause {
2278public:
2279 /// Build 'compare' clause.
2280 ///
2281 /// \param StartLoc Starting location of the clause.
2282 /// \param EndLoc Ending location of the clause.
2284 : OMPClause(llvm::omp::OMPC_compare, StartLoc, EndLoc) {}
2285
2286 /// Build an empty clause.
2288 : OMPClause(llvm::omp::OMPC_compare, SourceLocation(), SourceLocation()) {
2289 }
2290
2293 }
2294
2297 }
2298
2301 }
2304 }
2305
2306 static bool classof(const OMPClause *T) {
2307 return T->getClauseKind() == llvm::omp::OMPC_compare;
2308 }
2309};
2310
2311/// This represents 'seq_cst' clause in the '#pragma omp atomic'
2312/// directive.
2313///
2314/// \code
2315/// #pragma omp atomic seq_cst
2316/// \endcode
2317/// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
2319public:
2320 /// Build 'seq_cst' clause.
2321 ///
2322 /// \param StartLoc Starting location of the clause.
2323 /// \param EndLoc Ending location of the clause.
2325 : OMPClause(llvm::omp::OMPC_seq_cst, StartLoc, EndLoc) {}
2326
2327 /// Build an empty clause.
2329 : OMPClause(llvm::omp::OMPC_seq_cst, SourceLocation(), SourceLocation()) {
2330 }
2331
2334 }
2335
2338 }
2339
2342 }
2345 }
2346
2347 static bool classof(const OMPClause *T) {
2348 return T->getClauseKind() == llvm::omp::OMPC_seq_cst;
2349 }
2350};
2351
2352/// This represents 'acq_rel' clause in the '#pragma omp atomic|flush'
2353/// directives.
2354///
2355/// \code
2356/// #pragma omp flush acq_rel
2357/// \endcode
2358/// In this example directive '#pragma omp flush' has 'acq_rel' clause.
2359class OMPAcqRelClause final : public OMPClause {
2360public:
2361 /// Build 'ack_rel' clause.
2362 ///
2363 /// \param StartLoc Starting location of the clause.
2364 /// \param EndLoc Ending location of the clause.
2366 : OMPClause(llvm::omp::OMPC_acq_rel, StartLoc, EndLoc) {}
2367
2368 /// Build an empty clause.
2370 : OMPClause(llvm::omp::OMPC_acq_rel, SourceLocation(), SourceLocation()) {
2371 }
2372
2375 }
2376
2379 }
2380
2383 }
2386 }
2387
2388 static bool classof(const OMPClause *T) {
2389 return T->getClauseKind() == llvm::omp::OMPC_acq_rel;
2390 }
2391};
2392
2393/// This represents 'acquire' clause in the '#pragma omp atomic|flush'
2394/// directives.
2395///
2396/// \code
2397/// #pragma omp flush acquire
2398/// \endcode
2399/// In this example directive '#pragma omp flush' has 'acquire' clause.
2400class OMPAcquireClause final : public OMPClause {
2401public:
2402 /// Build 'acquire' clause.
2403 ///
2404 /// \param StartLoc Starting location of the clause.
2405 /// \param EndLoc Ending location of the clause.
2407 : OMPClause(llvm::omp::OMPC_acquire, StartLoc, EndLoc) {}
2408
2409 /// Build an empty clause.
2411 : OMPClause(llvm::omp::OMPC_acquire, SourceLocation(), SourceLocation()) {
2412 }
2413
2416 }
2417
2420 }
2421
2424 }
2427 }
2428
2429 static bool classof(const OMPClause *T) {
2430 return T->getClauseKind() == llvm::omp::OMPC_acquire;
2431 }
2432};
2433
2434/// This represents 'release' clause in the '#pragma omp atomic|flush'
2435/// directives.
2436///
2437/// \code
2438/// #pragma omp flush release
2439/// \endcode
2440/// In this example directive '#pragma omp flush' has 'release' clause.
2441class OMPReleaseClause final : public OMPClause {
2442public:
2443 /// Build 'release' clause.
2444 ///
2445 /// \param StartLoc Starting location of the clause.
2446 /// \param EndLoc Ending location of the clause.
2448 : OMPClause(llvm::omp::OMPC_release, StartLoc, EndLoc) {}
2449
2450 /// Build an empty clause.
2452 : OMPClause(llvm::omp::OMPC_release, SourceLocation(), SourceLocation()) {
2453 }
2454
2457 }
2458
2461 }
2462
2465 }
2468 }
2469
2470 static bool classof(const OMPClause *T) {
2471 return T->getClauseKind() == llvm::omp::OMPC_release;
2472 }
2473};
2474
2475/// This represents 'relaxed' clause in the '#pragma omp atomic'
2476/// directives.
2477///
2478/// \code
2479/// #pragma omp atomic relaxed
2480/// \endcode
2481/// In this example directive '#pragma omp atomic' has 'relaxed' clause.
2482class OMPRelaxedClause final : public OMPClause {
2483public:
2484 /// Build 'relaxed' clause.
2485 ///
2486 /// \param StartLoc Starting location of the clause.
2487 /// \param EndLoc Ending location of the clause.
2489 : OMPClause(llvm::omp::OMPC_relaxed, StartLoc, EndLoc) {}
2490
2491 /// Build an empty clause.
2493 : OMPClause(llvm::omp::OMPC_relaxed, SourceLocation(), SourceLocation()) {
2494 }
2495
2498 }
2499
2502 }
2503
2506 }
2509 }
2510
2511 static bool classof(const OMPClause *T) {
2512 return T->getClauseKind() == llvm::omp::OMPC_relaxed;
2513 }
2514};
2515
2516/// This represents 'weak' clause in the '#pragma omp atomic'
2517/// directives.
2518///
2519/// \code
2520/// #pragma omp atomic compare weak
2521/// \endcode
2522/// In this example directive '#pragma omp atomic' has 'weak' clause.
2523class OMPWeakClause final : public OMPClause {
2524public:
2525 /// Build 'weak' clause.
2526 ///
2527 /// \param StartLoc Starting location of the clause.
2528 /// \param EndLoc Ending location of the clause.
2530 : OMPClause(llvm::omp::OMPC_weak, StartLoc, EndLoc) {}
2531
2532 /// Build an empty clause.
2534 : OMPClause(llvm::omp::OMPC_weak, SourceLocation(), SourceLocation()) {}
2535
2538 }
2539
2542 }
2543
2546 }
2549 }
2550
2551 static bool classof(const OMPClause *T) {
2552 return T->getClauseKind() == llvm::omp::OMPC_weak;
2553 }
2554};
2555
2556/// This represents 'fail' clause in the '#pragma omp atomic'
2557/// directive.
2558///
2559/// \code
2560/// #pragma omp atomic compare fail
2561/// \endcode
2562/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
2563class OMPFailClause final : public OMPClause {
2564
2565 // FailParameter is a memory-order-clause. Storing the ClauseKind is
2566 // sufficient for our purpose.
2567 OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
2568 SourceLocation FailParameterLoc;
2569 SourceLocation LParenLoc;
2570
2571 friend class OMPClauseReader;
2572
2573 /// Sets the location of '(' in fail clause.
2574 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2575
2576 /// Sets the location of memoryOrder clause argument in fail clause.
2577 void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
2578
2579 /// Sets the mem_order clause for 'atomic compare fail' directive.
2580 void setFailParameter(OpenMPClauseKind FailParameter) {
2581 this->FailParameter = FailParameter;
2582 assert(checkFailClauseParameter(FailParameter) &&
2583 "Invalid fail clause parameter");
2584 }
2585
2586public:
2587 /// Build 'fail' clause.
2588 ///
2589 /// \param StartLoc Starting location of the clause.
2590 /// \param EndLoc Ending location of the clause.
2592 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
2593
2594 OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation FailParameterLoc,
2595 SourceLocation StartLoc, SourceLocation LParenLoc,
2596 SourceLocation EndLoc)
2597 : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
2598 FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
2599
2600 setFailParameter(FailParameter);
2601 }
2602
2603 /// Build an empty clause.
2605 : OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
2606
2609 }
2610
2613 }
2614
2617 }
2620 }
2621
2622 static bool classof(const OMPClause *T) {
2623 return T->getClauseKind() == llvm::omp::OMPC_fail;
2624 }
2625
2626 /// Gets the location of '(' (for the parameter) in fail clause.
2628 return LParenLoc;
2629 }
2630
2631 /// Gets the location of Fail Parameter (type memory-order-clause) in
2632 /// fail clause.
2633 SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
2634
2635 /// Gets the parameter (type memory-order-clause) in Fail clause.
2636 OpenMPClauseKind getFailParameter() const { return FailParameter; }
2637};
2638
2639/// This represents clause 'private' in the '#pragma omp ...' directives.
2640///
2641/// \code
2642/// #pragma omp parallel private(a,b)
2643/// \endcode
2644/// In this example directive '#pragma omp parallel' has clause 'private'
2645/// with the variables 'a' and 'b'.
2647 : public OMPVarListClause<OMPPrivateClause>,
2648 private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
2649 friend class OMPClauseReader;
2650 friend OMPVarListClause;
2651 friend TrailingObjects;
2652
2653 /// Build clause with number of variables \a N.
2654 ///
2655 /// \param StartLoc Starting location of the clause.
2656 /// \param LParenLoc Location of '('.
2657 /// \param EndLoc Ending location of the clause.
2658 /// \param N Number of the variables in the clause.
2660 SourceLocation EndLoc, unsigned N)
2661 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private, StartLoc,
2662 LParenLoc, EndLoc, N) {}
2663
2664 /// Build an empty clause.
2665 ///
2666 /// \param N Number of variables.
2667 explicit OMPPrivateClause(unsigned N)
2668 : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private,
2670 SourceLocation(), N) {}
2671
2672 /// Sets the list of references to private copies with initializers for
2673 /// new private variables.
2674 /// \param VL List of references.
2675 void setPrivateCopies(ArrayRef<Expr *> VL);
2676
2677 /// Gets the list of references to private copies with initializers for
2678 /// new private variables.
2679 MutableArrayRef<Expr *> getPrivateCopies() {
2680 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2681 }
2682 ArrayRef<const Expr *> getPrivateCopies() const {
2684 }
2685
2686public:
2687 /// Creates clause with a list of variables \a VL.
2688 ///
2689 /// \param C AST context.
2690 /// \param StartLoc Starting location of the clause.
2691 /// \param LParenLoc Location of '('.
2692 /// \param EndLoc Ending location of the clause.
2693 /// \param VL List of references to the variables.
2694 /// \param PrivateVL List of references to private copies with initializers.
2695 static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
2696 SourceLocation LParenLoc,
2697 SourceLocation EndLoc, ArrayRef<Expr *> VL,
2698 ArrayRef<Expr *> PrivateVL);
2699
2700 /// Creates an empty clause with the place for \a N variables.
2701 ///
2702 /// \param C AST context.
2703 /// \param N The number of variables.
2704 static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
2705
2708 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
2710 llvm::iterator_range<private_copies_const_iterator>;
2711
2713 return private_copies_range(getPrivateCopies().begin(),
2714 getPrivateCopies().end());
2715 }
2716
2718 return private_copies_const_range(getPrivateCopies().begin(),
2719 getPrivateCopies().end());
2720 }
2721
2723 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2724 reinterpret_cast<Stmt **>(varlist_end()));
2725 }
2726
2728 auto Children = const_cast<OMPPrivateClause *>(this)->children();
2729 return const_child_range(Children.begin(), Children.end());
2730 }
2731
2734 }
2737 }
2738
2739 static bool classof(const OMPClause *T) {
2740 return T->getClauseKind() == llvm::omp::OMPC_private;
2741 }
2742};
2743
2744/// This represents clause 'firstprivate' in the '#pragma omp ...'
2745/// directives.
2746///
2747/// \code
2748/// #pragma omp parallel firstprivate(a,b)
2749/// \endcode
2750/// In this example directive '#pragma omp parallel' has clause 'firstprivate'
2751/// with the variables 'a' and 'b'.
2753 : public OMPVarListClause<OMPFirstprivateClause>,
2754 public OMPClauseWithPreInit,
2755 private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
2756 friend class OMPClauseReader;
2757 friend OMPVarListClause;
2758 friend TrailingObjects;
2759
2760 /// Build clause with number of variables \a N.
2761 ///
2762 /// \param StartLoc Starting location of the clause.
2763 /// \param LParenLoc Location of '('.
2764 /// \param EndLoc Ending location of the clause.
2765 /// \param N Number of the variables in the clause.
2767 SourceLocation EndLoc, unsigned N)
2768 : OMPVarListClause<OMPFirstprivateClause>(llvm::omp::OMPC_firstprivate,
2769 StartLoc, LParenLoc, EndLoc, N),
2770 OMPClauseWithPreInit(this) {}
2771
2772 /// Build an empty clause.
2773 ///
2774 /// \param N Number of variables.
2775 explicit OMPFirstprivateClause(unsigned N)
2777 llvm::omp::OMPC_firstprivate, SourceLocation(), SourceLocation(),
2778 SourceLocation(), N),
2779 OMPClauseWithPreInit(this) {}
2780
2781 /// Sets the list of references to private copies with initializers for
2782 /// new private variables.
2783 /// \param VL List of references.
2784 void setPrivateCopies(ArrayRef<Expr *> VL);
2785
2786 /// Gets the list of references to private copies with initializers for
2787 /// new private variables.
2788 MutableArrayRef<Expr *> getPrivateCopies() {
2789 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2790 }
2791 ArrayRef<const Expr *> getPrivateCopies() const {
2793 }
2794
2795 /// Sets the list of references to initializer variables for new
2796 /// private variables.
2797 /// \param VL List of references.
2798 void setInits(ArrayRef<Expr *> VL);
2799
2800 /// Gets the list of references to initializer variables for new
2801 /// private variables.
2802 MutableArrayRef<Expr *> getInits() {
2803 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
2804 }
2805 ArrayRef<const Expr *> getInits() const {
2806 return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
2807 }
2808
2809public:
2810 /// Creates clause with a list of variables \a VL.
2811 ///
2812 /// \param C AST context.
2813 /// \param StartLoc Starting location of the clause.
2814 /// \param LParenLoc Location of '('.
2815 /// \param EndLoc Ending location of the clause.
2816 /// \param VL List of references to the original variables.
2817 /// \param PrivateVL List of references to private copies with initializers.
2818 /// \param InitVL List of references to auto generated variables used for
2819 /// initialization of a single array element. Used if firstprivate variable is
2820 /// of array type.
2821 /// \param PreInit Statement that must be executed before entering the OpenMP
2822 /// region with this clause.
2823 static OMPFirstprivateClause *
2824 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2825 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
2826 ArrayRef<Expr *> InitVL, Stmt *PreInit);
2827
2828 /// Creates an empty clause with the place for \a N variables.
2829 ///
2830 /// \param C AST context.
2831 /// \param N The number of variables.
2832 static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
2833
2836 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
2838 llvm::iterator_range<private_copies_const_iterator>;
2839
2841 return private_copies_range(getPrivateCopies().begin(),
2842 getPrivateCopies().end());
2843 }
2845 return private_copies_const_range(getPrivateCopies().begin(),
2846 getPrivateCopies().end());
2847 }
2848
2851 using inits_range = llvm::iterator_range<inits_iterator>;
2852 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
2853
2855 return inits_range(getInits().begin(), getInits().end());
2856 }
2858 return inits_const_range(getInits().begin(), getInits().end());
2859 }
2860
2862 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2863 reinterpret_cast<Stmt **>(varlist_end()));
2864 }
2865
2867 auto Children = const_cast<OMPFirstprivateClause *>(this)->children();
2868 return const_child_range(Children.begin(), Children.end());
2869 }
2870
2872 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2873 reinterpret_cast<Stmt **>(varlist_end()));
2874 }
2876 auto Children = const_cast<OMPFirstprivateClause *>(this)->used_children();
2877 return const_child_range(Children.begin(), Children.end());
2878 }
2879
2880 static bool classof(const OMPClause *T) {
2881 return T->getClauseKind() == llvm::omp::OMPC_firstprivate;
2882 }
2883};
2884
2885/// This represents clause 'lastprivate' in the '#pragma omp ...'
2886/// directives.
2887///
2888/// \code
2889/// #pragma omp simd lastprivate(a,b)
2890/// \endcode
2891/// In this example directive '#pragma omp simd' has clause 'lastprivate'
2892/// with the variables 'a' and 'b'.
2894 : public OMPVarListClause<OMPLastprivateClause>,
2896 private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
2897 // There are 4 additional tail-allocated arrays at the end of the class:
2898 // 1. Contains list of pseudo variables with the default initialization for
2899 // each non-firstprivate variables. Used in codegen for initialization of
2900 // lastprivate copies.
2901 // 2. List of helper expressions for proper generation of assignment operation
2902 // required for lastprivate clause. This list represents private variables
2903 // (for arrays, single array element).
2904 // 3. List of helper expressions for proper generation of assignment operation
2905 // required for lastprivate clause. This list represents original variables
2906 // (for arrays, single array element).
2907 // 4. List of helper expressions that represents assignment operation:
2908 // \code
2909 // DstExprs = SrcExprs;
2910 // \endcode
2911 // Required for proper codegen of final assignment performed by the
2912 // lastprivate clause.
2913 friend class OMPClauseReader;
2914 friend OMPVarListClause;
2915 friend TrailingObjects;
2916
2917 /// Optional lastprivate kind, e.g. 'conditional', if specified by user.
2919 /// Optional location of the lasptrivate kind, if specified by user.
2920 SourceLocation LPKindLoc;
2921 /// Optional colon location, if specified by user.
2922 SourceLocation ColonLoc;
2923
2924 /// Build clause with number of variables \a N.
2925 ///
2926 /// \param StartLoc Starting location of the clause.
2927 /// \param LParenLoc Location of '('.
2928 /// \param EndLoc Ending location of the clause.
2929 /// \param N Number of the variables in the clause.
2932 SourceLocation LPKindLoc, SourceLocation ColonLoc,
2933 unsigned N)
2934 : OMPVarListClause<OMPLastprivateClause>(llvm::omp::OMPC_lastprivate,
2935 StartLoc, LParenLoc, EndLoc, N),
2936 OMPClauseWithPostUpdate(this), LPKind(LPKind), LPKindLoc(LPKindLoc),
2937 ColonLoc(ColonLoc) {}
2938
2939 /// Build an empty clause.
2940 ///
2941 /// \param N Number of variables.
2942 explicit OMPLastprivateClause(unsigned N)
2944 llvm::omp::OMPC_lastprivate, SourceLocation(), SourceLocation(),
2945 SourceLocation(), N),
2947
2948 /// Get the list of helper expressions for initialization of private
2949 /// copies for lastprivate variables.
2950 MutableArrayRef<Expr *> getPrivateCopies() {
2951 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2952 }
2953 ArrayRef<const Expr *> getPrivateCopies() const {
2955 }
2956
2957 /// Set list of helper expressions, required for proper codegen of the
2958 /// clause. These expressions represent private variables (for arrays, single
2959 /// array element) in the final assignment statement performed by the
2960 /// lastprivate clause.
2961 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
2962
2963 /// Get the list of helper source expressions.
2964 MutableArrayRef<Expr *> getSourceExprs() {
2965 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
2966 }
2967 ArrayRef<const Expr *> getSourceExprs() const {
2968 return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
2969 }
2970
2971 /// Set list of helper expressions, required for proper codegen of the
2972 /// clause. These expressions represent original variables (for arrays, single
2973 /// array element) in the final assignment statement performed by the
2974 /// lastprivate clause.
2975 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
2976
2977 /// Get the list of helper destination expressions.
2978 MutableArrayRef<Expr *> getDestinationExprs() {
2979 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
2980 }
2981 ArrayRef<const Expr *> getDestinationExprs() const {
2982 return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
2983 }
2984
2985 /// Set list of helper assignment expressions, required for proper
2986 /// codegen of the clause. These expressions are assignment expressions that
2987 /// assign private copy of the variable to original variable.
2988 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
2989
2990 /// Get the list of helper assignment expressions.
2991 MutableArrayRef<Expr *> getAssignmentOps() {
2992 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
2993 }
2994 ArrayRef<const Expr *> getAssignmentOps() const {
2995 return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
2996 }
2997
2998 /// Sets lastprivate kind.
2999 void setKind(OpenMPLastprivateModifier Kind) { LPKind = Kind; }
3000 /// Sets location of the lastprivate kind.
3001 void setKindLoc(SourceLocation Loc) { LPKindLoc = Loc; }
3002 /// Sets colon symbol location.
3003 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3004
3005public:
3006 /// Creates clause with a list of variables \a VL.
3007 ///
3008 /// \param C AST context.
3009 /// \param StartLoc Starting location of the clause.
3010 /// \param LParenLoc Location of '('.
3011 /// \param EndLoc Ending location of the clause.
3012 /// \param VL List of references to the variables.
3013 /// \param SrcExprs List of helper expressions for proper generation of
3014 /// assignment operation required for lastprivate clause. This list represents
3015 /// private variables (for arrays, single array element).
3016 /// \param DstExprs List of helper expressions for proper generation of
3017 /// assignment operation required for lastprivate clause. This list represents
3018 /// original variables (for arrays, single array element).
3019 /// \param AssignmentOps List of helper expressions that represents assignment
3020 /// operation:
3021 /// \code
3022 /// DstExprs = SrcExprs;
3023 /// \endcode
3024 /// Required for proper codegen of final assignment performed by the
3025 /// lastprivate clause.
3026 /// \param LPKind Lastprivate kind, e.g. 'conditional'.
3027 /// \param LPKindLoc Location of the lastprivate kind.
3028 /// \param ColonLoc Location of the ':' symbol if lastprivate kind is used.
3029 /// \param PreInit Statement that must be executed before entering the OpenMP
3030 /// region with this clause.
3031 /// \param PostUpdate Expression that must be executed after exit from the
3032 /// OpenMP region with this clause.
3033 static OMPLastprivateClause *
3034 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3035 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
3036 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
3037 OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
3038 SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate);
3039
3040 /// Creates an empty clause with the place for \a N variables.
3041 ///
3042 /// \param C AST context.
3043 /// \param N The number of variables.
3044 static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
3045
3046 /// Lastprivate kind.
3047 OpenMPLastprivateModifier getKind() const { return LPKind; }
3048 /// Returns the location of the lastprivate kind.
3049 SourceLocation getKindLoc() const { return LPKindLoc; }
3050 /// Returns the location of the ':' symbol, if any.
3051 SourceLocation getColonLoc() const { return ColonLoc; }
3052
3055 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3057 llvm::iterator_range<helper_expr_const_iterator>;
3058
3059 /// Set list of helper expressions, required for generation of private
3060 /// copies of original lastprivate variables.
3061 void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
3062
3064 return helper_expr_const_range(getPrivateCopies().begin(),
3065 getPrivateCopies().end());
3066 }
3067
3069 return helper_expr_range(getPrivateCopies().begin(),
3070 getPrivateCopies().end());
3071 }
3072
3074 return helper_expr_const_range(getSourceExprs().begin(),
3075 getSourceExprs().end());
3076 }
3077
3079 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
3080 }
3081
3083 return helper_expr_const_range(getDestinationExprs().begin(),
3084 getDestinationExprs().end());
3085 }
3086
3088 return helper_expr_range(getDestinationExprs().begin(),
3089 getDestinationExprs().end());
3090 }
3091
3093 return helper_expr_const_range(getAssignmentOps().begin(),
3094 getAssignmentOps().end());
3095 }
3096
3098 return helper_expr_range(getAssignmentOps().begin(),
3099 getAssignmentOps().end());
3100 }
3101
3103 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3104 reinterpret_cast<Stmt **>(varlist_end()));
3105 }
3106
3108 auto Children = const_cast<OMPLastprivateClause *>(this)->children();
3109 return const_child_range(Children.begin(), Children.end());
3110 }
3111
3114 }
3117 }
3118
3119 static bool classof(const OMPClause *T) {
3120 return T->getClauseKind() == llvm::omp::OMPC_lastprivate;
3121 }
3122};
3123
3124/// This represents clause 'shared' in the '#pragma omp ...' directives.
3125///
3126/// \code
3127/// #pragma omp parallel shared(a,b)
3128/// \endcode
3129/// In this example directive '#pragma omp parallel' has clause 'shared'
3130/// with the variables 'a' and 'b'.
3132 : public OMPVarListClause<OMPSharedClause>,
3133 private llvm::TrailingObjects<OMPSharedClause, Expr *> {
3134 friend OMPVarListClause;
3135 friend TrailingObjects;
3136
3137 /// Build clause with number of variables \a N.
3138 ///
3139 /// \param StartLoc Starting location of the clause.
3140 /// \param LParenLoc Location of '('.
3141 /// \param EndLoc Ending location of the clause.
3142 /// \param N Number of the variables in the clause.
3143 OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3144 SourceLocation EndLoc, unsigned N)
3145 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared, StartLoc,
3146 LParenLoc, EndLoc, N) {}
3147
3148 /// Build an empty clause.
3149 ///
3150 /// \param N Number of variables.
3151 explicit OMPSharedClause(unsigned N)
3152 : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared,
3154 SourceLocation(), N) {}
3155
3156public:
3157 /// Creates clause with a list of variables \a VL.
3158 ///
3159 /// \param C AST context.
3160 /// \param StartLoc Starting location of the clause.
3161 /// \param LParenLoc Location of '('.
3162 /// \param EndLoc Ending location of the clause.
3163 /// \param VL List of references to the variables.
3164 static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
3165 SourceLocation LParenLoc,
3166 SourceLocation EndLoc, ArrayRef<Expr *> VL);
3167
3168 /// Creates an empty clause with \a N variables.
3169 ///
3170 /// \param C AST context.
3171 /// \param N The number of variables.
3172 static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
3173
3175 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3176 reinterpret_cast<Stmt **>(varlist_end()));
3177 }
3178
3180 auto Children = const_cast<OMPSharedClause *>(this)->children();
3181 return const_child_range(Children.begin(), Children.end());
3182 }
3183
3186 }
3189 }
3190
3191 static bool classof(const OMPClause *T) {
3192 return T->getClauseKind() == llvm::omp::OMPC_shared;
3193 }
3194};
3195
3196/// This represents clause 'reduction' in the '#pragma omp ...'
3197/// directives.
3198///
3199/// \code
3200/// #pragma omp parallel reduction(+:a,b)
3201/// \endcode
3202/// In this example directive '#pragma omp parallel' has clause 'reduction'
3203/// with operator '+' and the variables 'a' and 'b'.
3205 : public OMPVarListClause<OMPReductionClause>,
3207 private llvm::TrailingObjects<OMPReductionClause, Expr *> {
3208 friend class OMPClauseReader;
3209 friend OMPVarListClause;
3210 friend TrailingObjects;
3211
3212 /// Reduction modifier.
3214
3215 /// Reduction modifier location.
3216 SourceLocation ModifierLoc;
3217
3218 /// Location of ':'.
3219 SourceLocation ColonLoc;
3220
3221 /// Nested name specifier for C++.
3222 NestedNameSpecifierLoc QualifierLoc;
3223
3224 /// Name of custom operator.
3225 DeclarationNameInfo NameInfo;
3226
3227 /// Build clause with number of variables \a N.
3228 ///
3229 /// \param StartLoc Starting location of the clause.
3230 /// \param LParenLoc Location of '('.
3231 /// \param ModifierLoc Modifier location.
3232 /// \param ColonLoc Location of ':'.
3233 /// \param EndLoc Ending location of the clause.
3234 /// \param N Number of the variables in the clause.
3235 /// \param QualifierLoc The nested-name qualifier with location information
3236 /// \param NameInfo The full name info for reduction identifier.
3238 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3239 SourceLocation EndLoc,
3240 OpenMPReductionClauseModifier Modifier, unsigned N,
3241 NestedNameSpecifierLoc QualifierLoc,
3242 const DeclarationNameInfo &NameInfo)
3243 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3244 StartLoc, LParenLoc, EndLoc, N),
3245 OMPClauseWithPostUpdate(this), Modifier(Modifier),
3246 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
3247 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3248
3249 /// Build an empty clause.
3250 ///
3251 /// \param N Number of variables.
3252 explicit OMPReductionClause(unsigned N)
3253 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
3255 SourceLocation(), N),
3257
3258 /// Sets reduction modifier.
3259 void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; }
3260
3261 /// Sets location of the modifier.
3262 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
3263
3264 /// Sets location of ':' symbol in clause.
3265 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3266
3267 /// Sets the name info for specified reduction identifier.
3268 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3269
3270 /// Sets the nested name specifier.
3271 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3272
3273 /// Set list of helper expressions, required for proper codegen of the
3274 /// clause. These expressions represent private copy of the reduction
3275 /// variable.
3276 void setPrivates(ArrayRef<Expr *> Privates);
3277
3278 /// Get the list of helper privates.
3279 MutableArrayRef<Expr *> getPrivates() {
3280 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3281 }
3282 ArrayRef<const Expr *> getPrivates() const {
3284 }
3285
3286 /// Set list of helper expressions, required for proper codegen of the
3287 /// clause. These expressions represent LHS expression in the final
3288 /// reduction expression performed by the reduction clause.
3289 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3290
3291 /// Get the list of helper LHS expressions.
3292 MutableArrayRef<Expr *> getLHSExprs() {
3293 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
3294 }
3295 ArrayRef<const Expr *> getLHSExprs() const {
3296 return llvm::ArrayRef(getPrivates().end(), varlist_size());
3297 }
3298
3299 /// Set list of helper expressions, required for proper codegen of the
3300 /// clause. These expressions represent RHS expression in the final
3301 /// reduction expression performed by the reduction clause.
3302 /// Also, variables in these expressions are used for proper initialization of
3303 /// reduction copies.
3304 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3305
3306 /// Get the list of helper destination expressions.
3307 MutableArrayRef<Expr *> getRHSExprs() {
3308 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3309 }
3310 ArrayRef<const Expr *> getRHSExprs() const {
3311 return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
3312 }
3313
3314 /// Set list of helper reduction expressions, required for proper
3315 /// codegen of the clause. These expressions are binary expressions or
3316 /// operator/custom reduction call that calculates new value from source
3317 /// helper expressions to destination helper expressions.
3318 void setReductionOps(ArrayRef<Expr *> ReductionOps);
3319
3320 /// Get the list of helper reduction expressions.
3321 MutableArrayRef<Expr *> getReductionOps() {
3322 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
3323 }
3324 ArrayRef<const Expr *> getReductionOps() const {
3325 return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
3326 }
3327
3328 /// Set list of helper copy operations for inscan reductions.
3329 /// The form is: Temps[i] = LHS[i];
3330 void setInscanCopyOps(ArrayRef<Expr *> Ops);
3331
3332 /// Get the list of helper inscan copy operations.
3333 MutableArrayRef<Expr *> getInscanCopyOps() {
3334 return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size());
3335 }
3336 ArrayRef<const Expr *> getInscanCopyOps() const {
3337 return llvm::ArrayRef(getReductionOps().end(), varlist_size());
3338 }
3339
3340 /// Set list of helper temp vars for inscan copy array operations.
3341 void setInscanCopyArrayTemps(ArrayRef<Expr *> CopyArrayTemps);
3342
3343 /// Get the list of helper inscan copy temps.
3344 MutableArrayRef<Expr *> getInscanCopyArrayTemps() {
3345 return MutableArrayRef<Expr *>(getInscanCopyOps().end(), varlist_size());
3346 }
3347 ArrayRef<const Expr *> getInscanCopyArrayTemps() const {
3348 return llvm::ArrayRef(getInscanCopyOps().end(), varlist_size());
3349 }
3350
3351 /// Set list of helper temp elements vars for inscan copy array operations.
3352 void setInscanCopyArrayElems(ArrayRef<Expr *> CopyArrayElems);
3353
3354 /// Get the list of helper inscan copy temps.
3355 MutableArrayRef<Expr *> getInscanCopyArrayElems() {
3356 return MutableArrayRef<Expr *>(getInscanCopyArrayTemps().end(),
3357 varlist_size());
3358 }
3359 ArrayRef<const Expr *> getInscanCopyArrayElems() const {
3360 return llvm::ArrayRef(getInscanCopyArrayTemps().end(), varlist_size());
3361 }
3362
3363public:
3364 /// Creates clause with a list of variables \a VL.
3365 ///
3366 /// \param StartLoc Starting location of the clause.
3367 /// \param LParenLoc Location of '('.
3368 /// \param ModifierLoc Modifier location.
3369 /// \param ColonLoc Location of ':'.
3370 /// \param EndLoc Ending location of the clause.
3371 /// \param VL The variables in the clause.
3372 /// \param QualifierLoc The nested-name qualifier with location information
3373 /// \param NameInfo The full name info for reduction identifier.
3374 /// \param Privates List of helper expressions for proper generation of
3375 /// private copies.
3376 /// \param LHSExprs List of helper expressions for proper generation of
3377 /// assignment operation required for copyprivate clause. This list represents
3378 /// LHSs of the reduction expressions.
3379 /// \param RHSExprs List of helper expressions for proper generation of
3380 /// assignment operation required for copyprivate clause. This list represents
3381 /// RHSs of the reduction expressions.
3382 /// Also, variables in these expressions are used for proper initialization of
3383 /// reduction copies.
3384 /// \param ReductionOps List of helper expressions that represents reduction
3385 /// expressions:
3386 /// \code
3387 /// LHSExprs binop RHSExprs;
3388 /// operator binop(LHSExpr, RHSExpr);
3389 /// <CutomReduction>(LHSExpr, RHSExpr);
3390 /// \endcode
3391 /// Required for proper codegen of final reduction operation performed by the
3392 /// reduction clause.
3393 /// \param CopyOps List of copy operations for inscan reductions:
3394 /// \code
3395 /// TempExprs = LHSExprs;
3396 /// \endcode
3397 /// \param CopyArrayTemps Temp arrays for prefix sums.
3398 /// \param CopyArrayElems Temp arrays for prefix sums.
3399 /// \param PreInit Statement that must be executed before entering the OpenMP
3400 /// region with this clause.
3401 /// \param PostUpdate Expression that must be executed after exit from the
3402 /// OpenMP region with this clause.
3403 static OMPReductionClause *
3404 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3405 SourceLocation ModifierLoc, SourceLocation ColonLoc,
3406 SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier,
3407 ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc,
3408 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
3409 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
3410 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps,
3411 ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems,
3412 Stmt *PreInit, Expr *PostUpdate);
3413
3414 /// Creates an empty clause with the place for \a N variables.
3415 ///
3416 /// \param C AST context.
3417 /// \param N The number of variables.
3418 /// \param Modifier Reduction modifier.
3419 static OMPReductionClause *
3420 CreateEmpty(const ASTContext &C, unsigned N,
3422
3423 /// Returns modifier.
3424 OpenMPReductionClauseModifier getModifier() const { return Modifier; }
3425
3426 /// Returns modifier location.
3427 SourceLocation getModifierLoc() const { return ModifierLoc; }
3428
3429 /// Gets location of ':' symbol in clause.
3430 SourceLocation getColonLoc() const { return ColonLoc; }
3431
3432 /// Gets the name info for specified reduction identifier.
3433 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3434
3435 /// Gets the nested name specifier.
3436 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3437
3440 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3442 llvm::iterator_range<helper_expr_const_iterator>;
3443
3445 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
3446 }
3447
3449 return helper_expr_range(getPrivates().begin(), getPrivates().end());
3450 }
3451
3453 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
3454 }
3455
3457 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
3458 }
3459
3461 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
3462 }
3463
3465 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
3466 }
3467
3469 return helper_expr_const_range(getReductionOps().begin(),
3470 getReductionOps().end());
3471 }
3472
3474 return helper_expr_range(getReductionOps().begin(),
3475 getReductionOps().end());
3476 }
3477
3479 return helper_expr_const_range(getInscanCopyOps().begin(),
3480 getInscanCopyOps().end());
3481 }
3482
3484 return helper_expr_range(getInscanCopyOps().begin(),
3485 getInscanCopyOps().end());
3486 }
3487
3489 return helper_expr_const_range(getInscanCopyArrayTemps().begin(),
3490 getInscanCopyArrayTemps().end());
3491 }
3492
3494 return helper_expr_range(getInscanCopyArrayTemps().begin(),
3495 getInscanCopyArrayTemps().end());
3496 }
3497
3499 return helper_expr_const_range(getInscanCopyArrayElems().begin(),
3500 getInscanCopyArrayElems().end());
3501 }
3502
3504 return helper_expr_range(getInscanCopyArrayElems().begin(),
3505 getInscanCopyArrayElems().end());
3506 }
3507
3509 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3510 reinterpret_cast<Stmt **>(varlist_end()));
3511 }
3512
3514 auto Children = const_cast<OMPReductionClause *>(this)->children();
3515 return const_child_range(Children.begin(), Children.end());
3516 }
3517
3519 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3520 reinterpret_cast<Stmt **>(varlist_end()));
3521 }
3523 auto Children = const_cast<OMPReductionClause *>(this)->used_children();
3524 return const_child_range(Children.begin(), Children.end());
3525 }
3526
3527 static bool classof(const OMPClause *T) {
3528 return T->getClauseKind() == llvm::omp::OMPC_reduction;
3529 }
3530};
3531
3532/// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
3533/// directives.
3534///
3535/// \code
3536/// #pragma omp taskgroup task_reduction(+:a,b)
3537/// \endcode
3538/// In this example directive '#pragma omp taskgroup' has clause
3539/// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
3541 : public OMPVarListClause<OMPTaskReductionClause>,
3543 private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> {
3544 friend class OMPClauseReader;
3545 friend OMPVarListClause;
3546 friend TrailingObjects;
3547
3548 /// Location of ':'.
3549 SourceLocation ColonLoc;
3550
3551 /// Nested name specifier for C++.
3552 NestedNameSpecifierLoc QualifierLoc;
3553
3554 /// Name of custom operator.
3555 DeclarationNameInfo NameInfo;
3556
3557 /// Build clause with number of variables \a N.
3558 ///
3559 /// \param StartLoc Starting location of the clause.
3560 /// \param LParenLoc Location of '('.
3561 /// \param EndLoc Ending location of the clause.
3562 /// \param ColonLoc Location of ':'.
3563 /// \param N Number of the variables in the clause.
3564 /// \param QualifierLoc The nested-name qualifier with location information
3565 /// \param NameInfo The full name info for reduction identifier.
3567 SourceLocation ColonLoc, SourceLocation EndLoc,
3568 unsigned N, NestedNameSpecifierLoc QualifierLoc,
3569 const DeclarationNameInfo &NameInfo)
3571 llvm::omp::OMPC_task_reduction, StartLoc, LParenLoc, EndLoc, N),
3572 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
3573 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3574
3575 /// Build an empty clause.
3576 ///
3577 /// \param N Number of variables.
3578 explicit OMPTaskReductionClause(unsigned N)
3580 llvm::omp::OMPC_task_reduction, SourceLocation(), SourceLocation(),
3581 SourceLocation(), N),
3583
3584 /// Sets location of ':' symbol in clause.
3585 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3586
3587 /// Sets the name info for specified reduction identifier.
3588 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3589
3590 /// Sets the nested name specifier.
3591 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3592
3593 /// Set list of helper expressions, required for proper codegen of the clause.
3594 /// These expressions represent private copy of the reduction variable.
3595 void setPrivates(ArrayRef<Expr *> Privates);
3596
3597 /// Get the list of helper privates.
3598 MutableArrayRef<Expr *> getPrivates() {
3599 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3600 }
3601 ArrayRef<const Expr *> getPrivates() const {
3603 }
3604
3605 /// Set list of helper expressions, required for proper codegen of the clause.
3606 /// These expressions represent LHS expression in the final reduction
3607 /// expression performed by the reduction clause.
3608 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3609
3610 /// Get the list of helper LHS expressions.
3611 MutableArrayRef<Expr *> getLHSExprs() {
3612 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
3613 }
3614 ArrayRef<const Expr *> getLHSExprs() const {
3615 return llvm::ArrayRef(getPrivates().end(), varlist_size());
3616 }
3617
3618 /// Set list of helper expressions, required for proper codegen of the clause.
3619 /// These expressions represent RHS expression in the final reduction
3620 /// expression performed by the reduction clause. Also, variables in these
3621 /// expressions are used for proper initialization of reduction copies.
3622 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3623
3624 /// Get the list of helper destination expressions.
3625 MutableArrayRef<Expr *> getRHSExprs() {
3626 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3627 }
3628 ArrayRef<const Expr *> getRHSExprs() const {
3629 return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
3630 }
3631
3632 /// Set list of helper reduction expressions, required for proper
3633 /// codegen of the clause. These expressions are binary expressions or
3634 /// operator/custom reduction call that calculates new value from source
3635 /// helper expressions to destination helper expressions.
3636 void setReductionOps(ArrayRef<Expr *> ReductionOps);
3637
3638 /// Get the list of helper reduction expressions.
3639 MutableArrayRef<Expr *> getReductionOps() {
3640 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
3641 }
3642 ArrayRef<const Expr *> getReductionOps() const {
3643 return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
3644 }
3645
3646public:
3647 /// Creates clause with a list of variables \a VL.
3648 ///
3649 /// \param StartLoc Starting location of the clause.
3650 /// \param LParenLoc Location of '('.
3651 /// \param ColonLoc Location of ':'.
3652 /// \param EndLoc Ending location of the clause.
3653 /// \param VL The variables in the clause.
3654 /// \param QualifierLoc The nested-name qualifier with location information
3655 /// \param NameInfo The full name info for reduction identifier.
3656 /// \param Privates List of helper expressions for proper generation of
3657 /// private copies.
3658 /// \param LHSExprs List of helper expressions for proper generation of
3659 /// assignment operation required for copyprivate clause. This list represents
3660 /// LHSs of the reduction expressions.
3661 /// \param RHSExprs List of helper expressions for proper generation of
3662 /// assignment operation required for copyprivate clause. This list represents
3663 /// RHSs of the reduction expressions.
3664 /// Also, variables in these expressions are used for proper initialization of
3665 /// reduction copies.
3666 /// \param ReductionOps List of helper expressions that represents reduction
3667 /// expressions:
3668 /// \code
3669 /// LHSExprs binop RHSExprs;
3670 /// operator binop(LHSExpr, RHSExpr);
3671 /// <CutomReduction>(LHSExpr, RHSExpr);
3672 /// \endcode
3673 /// Required for proper codegen of final reduction operation performed by the
3674 /// reduction clause.
3675 /// \param PreInit Statement that must be executed before entering the OpenMP
3676 /// region with this clause.
3677 /// \param PostUpdate Expression that must be executed after exit from the
3678 /// OpenMP region with this clause.
3679 static OMPTaskReductionClause *
3680 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3681 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
3682 NestedNameSpecifierLoc QualifierLoc,
3683 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
3684 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
3685 ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
3686
3687 /// Creates an empty clause with the place for \a N variables.
3688 ///
3689 /// \param C AST context.
3690 /// \param N The number of variables.
3691 static OMPTaskReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
3692
3693 /// Gets location of ':' symbol in clause.
3694 SourceLocation getColonLoc() const { return ColonLoc; }
3695
3696 /// Gets the name info for specified reduction identifier.
3697 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3698
3699 /// Gets the nested name specifier.
3700 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3701
3704 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3706 llvm::iterator_range<helper_expr_const_iterator>;
3707
3709 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
3710 }
3711
3713 return helper_expr_range(getPrivates().begin(), getPrivates().end());
3714 }
3715
3717 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
3718 }
3719
3721 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
3722 }
3723
3725 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
3726 }
3727
3729 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
3730 }
3731
3733 return helper_expr_const_range(getReductionOps().begin(),
3734 getReductionOps().end());
3735 }
3736
3738 return helper_expr_range(getReductionOps().begin(),
3739 getReductionOps().end());
3740 }
3741
3743 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3744 reinterpret_cast<Stmt **>(varlist_end()));
3745 }
3746
3748 auto Children = const_cast<OMPTaskReductionClause *>(this)->children();
3749 return const_child_range(Children.begin(), Children.end());
3750 }
3751
3754 }
3757 }
3758
3759 static bool classof(const OMPClause *T) {
3760 return T->getClauseKind() == llvm::omp::OMPC_task_reduction;
3761 }
3762};
3763
3764/// This represents clause 'in_reduction' in the '#pragma omp task' directives.
3765///
3766/// \code
3767/// #pragma omp task in_reduction(+:a,b)
3768/// \endcode
3769/// In this example directive '#pragma omp task' has clause 'in_reduction' with
3770/// operator '+' and the variables 'a' and 'b'.
3772 : public OMPVarListClause<OMPInReductionClause>,
3774 private llvm::TrailingObjects<OMPInReductionClause, Expr *> {
3775 friend class OMPClauseReader;
3776 friend OMPVarListClause;
3777 friend TrailingObjects;
3778
3779 /// Location of ':'.
3780 SourceLocation ColonLoc;
3781
3782 /// Nested name specifier for C++.
3783 NestedNameSpecifierLoc QualifierLoc;
3784
3785 /// Name of custom operator.
3786 DeclarationNameInfo NameInfo;
3787
3788 /// Build clause with number of variables \a N.
3789 ///
3790 /// \param StartLoc Starting location of the clause.
3791 /// \param LParenLoc Location of '('.
3792 /// \param EndLoc Ending location of the clause.
3793 /// \param ColonLoc Location of ':'.
3794 /// \param N Number of the variables in the clause.
3795 /// \param QualifierLoc The nested-name qualifier with location information
3796 /// \param NameInfo The full name info for reduction identifier.
3798 SourceLocation ColonLoc, SourceLocation EndLoc,
3799 unsigned N, NestedNameSpecifierLoc QualifierLoc,
3800 const DeclarationNameInfo &NameInfo)
3801 : OMPVarListClause<OMPInReductionClause>(llvm::omp::OMPC_in_reduction,
3802 StartLoc, LParenLoc, EndLoc, N),
3803 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
3804 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
3805
3806 /// Build an empty clause.
3807 ///
3808 /// \param N Number of variables.
3809 explicit OMPInReductionClause(unsigned N)
3811 llvm::omp::OMPC_in_reduction, SourceLocation(), SourceLocation(),
3812 SourceLocation(), N),
3814
3815 /// Sets location of ':' symbol in clause.
3816 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
3817
3818 /// Sets the name info for specified reduction identifier.
3819 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
3820
3821 /// Sets the nested name specifier.
3822 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
3823
3824 /// Set list of helper expressions, required for proper codegen of the clause.
3825 /// These expressions represent private copy of the reduction variable.
3826 void setPrivates(ArrayRef<Expr *> Privates);
3827
3828 /// Get the list of helper privates.
3829 MutableArrayRef<Expr *> getPrivates() {
3830 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3831 }
3832 ArrayRef<const Expr *> getPrivates() const {
3834 }
3835
3836 /// Set list of helper expressions, required for proper codegen of the clause.
3837 /// These expressions represent LHS expression in the final reduction
3838 /// expression performed by the reduction clause.
3839 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
3840
3841 /// Get the list of helper LHS expressions.
3842 MutableArrayRef<Expr *> getLHSExprs() {
3843 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
3844 }
3845 ArrayRef<const Expr *> getLHSExprs() const {
3846 return llvm::ArrayRef(getPrivates().end(), varlist_size());
3847 }
3848
3849 /// Set list of helper expressions, required for proper codegen of the clause.
3850 /// These expressions represent RHS expression in the final reduction
3851 /// expression performed by the reduction clause. Also, variables in these
3852 /// expressions are used for proper initialization of reduction copies.
3853 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
3854
3855 /// Get the list of helper destination expressions.
3856 MutableArrayRef<Expr *> getRHSExprs() {
3857 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
3858 }
3859 ArrayRef<const Expr *> getRHSExprs() const {
3860 return llvm::ArrayRef(getLHSExprs().end(), varlist_size());
3861 }
3862
3863 /// Set list of helper reduction expressions, required for proper
3864 /// codegen of the clause. These expressions are binary expressions or
3865 /// operator/custom reduction call that calculates new value from source
3866 /// helper expressions to destination helper expressions.
3867 void setReductionOps(ArrayRef<Expr *> ReductionOps);
3868
3869 /// Get the list of helper reduction expressions.
3870 MutableArrayRef<Expr *> getReductionOps() {
3871 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
3872 }
3873 ArrayRef<const Expr *> getReductionOps() const {
3874 return llvm::ArrayRef(getRHSExprs().end(), varlist_size());
3875 }
3876
3877 /// Set list of helper reduction taskgroup descriptors.
3878 void setTaskgroupDescriptors(ArrayRef<Expr *> ReductionOps);
3879
3880 /// Get the list of helper reduction taskgroup descriptors.
3881 MutableArrayRef<Expr *> getTaskgroupDescriptors() {
3882 return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size());
3883 }
3884 ArrayRef<const Expr *> getTaskgroupDescriptors() const {
3885 return llvm::ArrayRef(getReductionOps().end(), varlist_size());
3886 }
3887
3888public:
3889 /// Creates clause with a list of variables \a VL.
3890 ///
3891 /// \param StartLoc Starting location of the clause.
3892 /// \param LParenLoc Location of '('.
3893 /// \param ColonLoc Location of ':'.
3894 /// \param EndLoc Ending location of the clause.
3895 /// \param VL The variables in the clause.
3896 /// \param QualifierLoc The nested-name qualifier with location information
3897 /// \param NameInfo The full name info for reduction identifier.
3898 /// \param Privates List of helper expressions for proper generation of
3899 /// private copies.
3900 /// \param LHSExprs List of helper expressions for proper generation of
3901 /// assignment operation required for copyprivate clause. This list represents
3902 /// LHSs of the reduction expressions.
3903 /// \param RHSExprs List of helper expressions for proper generation of
3904 /// assignment operation required for copyprivate clause. This list represents
3905 /// RHSs of the reduction expressions.
3906 /// Also, variables in these expressions are used for proper initialization of
3907 /// reduction copies.
3908 /// \param ReductionOps List of helper expressions that represents reduction
3909 /// expressions:
3910 /// \code
3911 /// LHSExprs binop RHSExprs;
3912 /// operator binop(LHSExpr, RHSExpr);
3913 /// <CutomReduction>(LHSExpr, RHSExpr);
3914 /// \endcode
3915 /// Required for proper codegen of final reduction operation performed by the
3916 /// reduction clause.
3917 /// \param TaskgroupDescriptors List of helper taskgroup descriptors for
3918 /// corresponding items in parent taskgroup task_reduction clause.
3919 /// \param PreInit Statement that must be executed before entering the OpenMP
3920 /// region with this clause.
3921 /// \param PostUpdate Expression that must be executed after exit from the
3922 /// OpenMP region with this clause.
3923 static OMPInReductionClause *
3924 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
3925 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
3926 NestedNameSpecifierLoc QualifierLoc,
3927 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
3928 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
3929 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> TaskgroupDescriptors,
3930 Stmt *PreInit, Expr *PostUpdate);
3931
3932 /// Creates an empty clause with the place for \a N variables.
3933 ///
3934 /// \param C AST context.
3935 /// \param N The number of variables.
3936 static OMPInReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
3937
3938 /// Gets location of ':' symbol in clause.
3939 SourceLocation getColonLoc() const { return ColonLoc; }
3940
3941 /// Gets the name info for specified reduction identifier.
3942 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3943
3944 /// Gets the nested name specifier.
3945 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3946
3949 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3951 llvm::iterator_range<helper_expr_const_iterator>;
3952
3954 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
3955 }
3956
3958 return helper_expr_range(getPrivates().begin(), getPrivates().end());
3959 }
3960
3962 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
3963 }
3964
3966 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
3967 }
3968
3970 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
3971 }
3972
3974 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
3975 }
3976
3978 return helper_expr_const_range(getReductionOps().begin(),
3979 getReductionOps().end());
3980 }
3981
3983 return helper_expr_range(getReductionOps().begin(),
3984 getReductionOps().end());
3985 }
3986
3988 return helper_expr_const_range(getTaskgroupDescriptors().begin(),
3989 getTaskgroupDescriptors().end());
3990 }
3991
3993 return helper_expr_range(getTaskgroupDescriptors().begin(),
3994 getTaskgroupDescriptors().end());
3995 }
3996
3998 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3999 reinterpret_cast<Stmt **>(varlist_end()));
4000 }
4001
4003 auto Children = const_cast<OMPInReductionClause *>(this)->children();
4004 return const_child_range(Children.begin(), Children.end());
4005 }
4006
4009 }
4012 }
4013
4014 static bool classof(const OMPClause *T) {
4015 return T->getClauseKind() == llvm::omp::OMPC_in_reduction;
4016 }
4017};
4018
4019/// This represents clause 'linear' in the '#pragma omp ...'
4020/// directives.
4021///
4022/// \code
4023/// #pragma omp simd linear(a,b : 2)
4024/// \endcode
4025/// In this example directive '#pragma omp simd' has clause 'linear'
4026/// with variables 'a', 'b' and linear step '2'.
4028 : public OMPVarListClause<OMPLinearClause>,
4030 private llvm::TrailingObjects<OMPLinearClause, Expr *> {
4031 friend class OMPClauseReader;
4032 friend OMPVarListClause;
4033 friend TrailingObjects;
4034
4035 /// Modifier of 'linear' clause.
4036 OpenMPLinearClauseKind Modifier = OMPC_LINEAR_val;
4037
4038 /// Location of linear modifier if any.
4039 SourceLocation ModifierLoc;
4040
4041 /// Location of ':'.
4042 SourceLocation ColonLoc;
4043
4044 /// Location of 'step' modifier.
4045 SourceLocation StepModifierLoc;
4046
4047 /// Sets the linear step for clause.
4048 void setStep(Expr *Step) { *(getFinals().end()) = Step; }
4049
4050 /// Sets the expression to calculate linear step for clause.
4051 void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
4052
4053 /// Build 'linear' clause with given number of variables \a NumVars.
4054 ///
4055 /// \param StartLoc Starting location of the clause.
4056 /// \param LParenLoc Location of '('.
4057 /// \param ColonLoc Location of ':'.
4058 /// \param StepModifierLoc Location of 'step' modifier.
4059 /// \param EndLoc Ending location of the clause.
4060 /// \param NumVars Number of variables.
4061 OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4062 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4063 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4064 SourceLocation EndLoc, unsigned NumVars)
4065 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear, StartLoc,
4066 LParenLoc, EndLoc, NumVars),
4067 OMPClauseWithPostUpdate(this), Modifier(Modifier),
4068 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
4069 StepModifierLoc(StepModifierLoc) {}
4070
4071 /// Build an empty clause.
4072 ///
4073 /// \param NumVars Number of variables.
4074 explicit OMPLinearClause(unsigned NumVars)
4075 : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear,
4076 SourceLocation(), SourceLocation(),
4077 SourceLocation(), NumVars),
4079
4080 /// Gets the list of initial values for linear variables.
4081 ///
4082 /// There are NumVars expressions with initial values allocated after the
4083 /// varlist, they are followed by NumVars update expressions (used to update
4084 /// the linear variable's value on current iteration) and they are followed by
4085 /// NumVars final expressions (used to calculate the linear variable's
4086 /// value after the loop body). After these lists, there are 2 helper
4087 /// expressions - linear step and a helper to calculate it before the
4088 /// loop body (used when the linear step is not constant):
4089 ///
4090 /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
4091 /// Finals[]; Step; CalcStep; }
4092 MutableArrayRef<Expr *> getPrivates() {
4093 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4094 }
4095 ArrayRef<const Expr *> getPrivates() const {
4097 }
4098
4099 MutableArrayRef<Expr *> getInits() {
4100 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
4101 }
4102 ArrayRef<const Expr *> getInits() const {
4103 return llvm::ArrayRef(getPrivates().end(), varlist_size());
4104 }
4105
4106 /// Sets the list of update expressions for linear variables.
4107 MutableArrayRef<Expr *> getUpdates() {
4108 return MutableArrayRef<Expr *>(getInits().end(), varlist_size());
4109 }
4110 ArrayRef<const Expr *> getUpdates() const {
4111 return llvm::ArrayRef(getInits().end(), varlist_size());
4112 }
4113
4114 /// Sets the list of final update expressions for linear variables.
4115 MutableArrayRef<Expr *> getFinals() {
4116 return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size());
4117 }
4118 ArrayRef<const Expr *> getFinals() const {
4119 return llvm::ArrayRef(getUpdates().end(), varlist_size());
4120 }
4121
4122 /// Gets the list of used expressions for linear variables.
4123 MutableArrayRef<Expr *> getUsedExprs() {
4124 return MutableArrayRef<Expr *>(getFinals().end() + 2, varlist_size() + 1);
4125 }
4126 ArrayRef<const Expr *> getUsedExprs() const {
4127 return llvm::ArrayRef(getFinals().end() + 2, varlist_size() + 1);
4128 }
4129
4130 /// Sets the list of the copies of original linear variables.
4131 /// \param PL List of expressions.
4132 void setPrivates(ArrayRef<Expr *> PL);
4133
4134 /// Sets the list of the initial values for linear variables.
4135 /// \param IL List of expressions.
4136 void setInits(ArrayRef<Expr *> IL);
4137
4138public:
4139 /// Creates clause with a list of variables \a VL and a linear step
4140 /// \a Step.
4141 ///
4142 /// \param C AST Context.
4143 /// \param StartLoc Starting location of the clause.
4144 /// \param LParenLoc Location of '('.
4145 /// \param Modifier Modifier of 'linear' clause.
4146 /// \param ModifierLoc Modifier location.
4147 /// \param ColonLoc Location of ':'.
4148 /// \param StepModifierLoc Location of 'step' modifier.
4149 /// \param EndLoc Ending location of the clause.
4150 /// \param VL List of references to the variables.
4151 /// \param PL List of private copies of original variables.
4152 /// \param IL List of initial values for the variables.
4153 /// \param Step Linear step.
4154 /// \param CalcStep Calculation of the linear step.
4155 /// \param PreInit Statement that must be executed before entering the OpenMP
4156 /// region with this clause.
4157 /// \param PostUpdate Expression that must be executed after exit from the
4158 /// OpenMP region with this clause.
4159 static OMPLinearClause *
4160 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4161 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
4162 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
4163 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PL,
4164 ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit,
4165 Expr *PostUpdate);
4166
4167 /// Creates an empty clause with the place for \a NumVars variables.
4168 ///
4169 /// \param C AST context.
4170 /// \param NumVars Number of variables.
4171 static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4172
4173 /// Set modifier.
4174 void setModifier(OpenMPLinearClauseKind Kind) { Modifier = Kind; }
4175
4176 /// Return modifier.
4177 OpenMPLinearClauseKind getModifier() const { return Modifier; }
4178
4179 /// Set modifier location.
4180 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
4181
4182 /// Return modifier location.
4183 SourceLocation getModifierLoc() const { return ModifierLoc; }
4184
4185 /// Sets the location of ':'.
4186 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4187
4188 /// Sets the location of 'step' modifier.
4189 void setStepModifierLoc(SourceLocation Loc) { StepModifierLoc = Loc; }
4190
4191 /// Returns the location of ':'.
4192 SourceLocation getColonLoc() const { return ColonLoc; }
4193
4194 /// Returns the location of 'step' modifier.
4195 SourceLocation getStepModifierLoc() const { return StepModifierLoc; }
4196
4197 /// Returns linear step.
4198 Expr *getStep() { return *(getFinals().end()); }
4199
4200 /// Returns linear step.
4201 const Expr *getStep() const { return *(getFinals().end()); }
4202
4203 /// Returns expression to calculate linear step.
4204 Expr *getCalcStep() { return *(getFinals().end() + 1); }
4205
4206 /// Returns expression to calculate linear step.
4207 const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
4208
4209 /// Sets the list of update expressions for linear variables.
4210 /// \param UL List of expressions.
4212
4213 /// Sets the list of final update expressions for linear variables.
4214 /// \param FL List of expressions.
4215 void setFinals(ArrayRef<Expr *> FL);
4216
4217 /// Sets the list of used expressions for the linear clause.
4219
4222 using privates_range = llvm::iterator_range<privates_iterator>;
4223 using privates_const_range = llvm::iterator_range<privates_const_iterator>;
4224
4226 return privates_range(getPrivates().begin(), getPrivates().end());
4227 }
4228
4230 return privates_const_range(getPrivates().begin(), getPrivates().end());
4231 }
4232
4235 using inits_range = llvm::iterator_range<inits_iterator>;
4236 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
4237
4239 return inits_range(getInits().begin(), getInits().end());
4240 }
4241
4243 return inits_const_range(getInits().begin(), getInits().end());
4244 }
4245
4248 using updates_range = llvm::iterator_range<updates_iterator>;
4249 using updates_const_range = llvm::iterator_range<updates_const_iterator>;
4250
4252 return updates_range(getUpdates().begin(), getUpdates().end());
4253 }
4254
4256 return updates_const_range(getUpdates().begin(), getUpdates().end());
4257 }
4258
4261 using finals_range = llvm::iterator_range<finals_iterator>;
4262 using finals_const_range = llvm::iterator_range<finals_const_iterator>;
4263
4265 return finals_range(getFinals().begin(), getFinals().end());
4266 }
4267
4269 return finals_const_range(getFinals().begin(), getFinals().end());
4270 }
4271
4275 llvm::iterator_range<used_expressions_iterator>;
4277 llvm::iterator_range<used_expressions_const_iterator>;
4278
4280 return finals_range(getUsedExprs().begin(), getUsedExprs().end());
4281 }
4282
4284 return finals_const_range(getUsedExprs().begin(), getUsedExprs().end());
4285 }
4286
4288 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4289 reinterpret_cast<Stmt **>(varlist_end()));
4290 }
4291
4293 auto Children = const_cast<OMPLinearClause *>(this)->children();
4294 return const_child_range(Children.begin(), Children.end());
4295 }
4296
4298
4300 auto Children = const_cast<OMPLinearClause *>(this)->used_children();
4301 return const_child_range(Children.begin(), Children.end());
4302 }
4303
4304 static bool classof(const OMPClause *T) {
4305 return T->getClauseKind() == llvm::omp::OMPC_linear;
4306 }
4307};
4308
4309/// This represents clause 'aligned' in the '#pragma omp ...'
4310/// directives.
4311///
4312/// \code
4313/// #pragma omp simd aligned(a,b : 8)
4314/// \endcode
4315/// In this example directive '#pragma omp simd' has clause 'aligned'
4316/// with variables 'a', 'b' and alignment '8'.
4318 : public OMPVarListClause<OMPAlignedClause>,
4319 private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
4320 friend class OMPClauseReader;
4321 friend OMPVarListClause;
4322 friend TrailingObjects;
4323
4324 /// Location of ':'.
4325 SourceLocation ColonLoc;
4326
4327 /// Sets the alignment for clause.
4328 void setAlignment(Expr *A) { *varlist_end() = A; }
4329
4330 /// Build 'aligned' clause with given number of variables \a NumVars.
4331 ///
4332 /// \param StartLoc Starting location of the clause.
4333 /// \param LParenLoc Location of '('.
4334 /// \param ColonLoc Location of ':'.
4335 /// \param EndLoc Ending location of the clause.
4336 /// \param NumVars Number of variables.
4338 SourceLocation ColonLoc, SourceLocation EndLoc,
4339 unsigned NumVars)
4340 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned, StartLoc,
4341 LParenLoc, EndLoc, NumVars),
4342 ColonLoc(ColonLoc) {}
4343
4344 /// Build an empty clause.
4345 ///
4346 /// \param NumVars Number of variables.
4347 explicit OMPAlignedClause(unsigned NumVars)
4348 : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned,
4349 SourceLocation(), SourceLocation(),
4350 SourceLocation(), NumVars) {}
4351
4352public:
4353 /// Creates clause with a list of variables \a VL and alignment \a A.
4354 ///
4355 /// \param C AST Context.
4356 /// \param StartLoc Starting location of the clause.
4357 /// \param LParenLoc Location of '('.
4358 /// \param ColonLoc Location of ':'.
4359 /// \param EndLoc Ending location of the clause.
4360 /// \param VL List of references to the variables.
4361 /// \param A Alignment.
4362 static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
4363 SourceLocation LParenLoc,
4364 SourceLocation ColonLoc,
4365 SourceLocation EndLoc, ArrayRef<Expr *> VL,
4366 Expr *A);
4367
4368 /// Creates an empty clause with the place for \a NumVars variables.
4369 ///
4370 /// \param C AST context.
4371 /// \param NumVars Number of variables.
4372 static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
4373
4374 /// Sets the location of ':'.
4375 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4376
4377 /// Returns the location of ':'.
4378 SourceLocation getColonLoc() const { return ColonLoc; }
4379
4380 /// Returns alignment.
4382
4383 /// Returns alignment.
4384 const Expr *getAlignment() const { return *varlist_end(); }
4385
4387 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4388 reinterpret_cast<Stmt **>(varlist_end()));
4389 }
4390
4392 auto Children = const_cast<OMPAlignedClause *>(this)->children();
4393 return const_child_range(Children.begin(), Children.end());
4394 }
4395
4398 }
4401 }
4402
4403 static bool classof(const OMPClause *T) {
4404 return T->getClauseKind() == llvm::omp::OMPC_aligned;
4405 }
4406};
4407
4408/// This represents clause 'copyin' in the '#pragma omp ...' directives.
4409///
4410/// \code
4411/// #pragma omp parallel copyin(a,b)
4412/// \endcode
4413/// In this example directive '#pragma omp parallel' has clause 'copyin'
4414/// with the variables 'a' and 'b'.
4416 : public OMPVarListClause<OMPCopyinClause>,
4417 private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
4418 // Class has 3 additional tail allocated arrays:
4419 // 1. List of helper expressions for proper generation of assignment operation
4420 // required for copyin clause. This list represents sources.
4421 // 2. List of helper expressions for proper generation of assignment operation
4422 // required for copyin clause. This list represents destinations.
4423 // 3. List of helper expressions that represents assignment operation:
4424 // \code
4425 // DstExprs = SrcExprs;
4426 // \endcode
4427 // Required for proper codegen of propagation of master's thread values of
4428 // threadprivate variables to local instances of that variables in other
4429 // implicit threads.
4430
4431 friend class OMPClauseReader;
4432 friend OMPVarListClause;
4433 friend TrailingObjects;
4434
4435 /// Build clause with number of variables \a N.
4436 ///
4437 /// \param StartLoc Starting location of the clause.
4438 /// \param LParenLoc Location of '('.
4439 /// \param EndLoc Ending location of the clause.
4440 /// \param N Number of the variables in the clause.
4441 OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4442 SourceLocation EndLoc, unsigned N)
4443 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin, StartLoc,
4444 LParenLoc, EndLoc, N) {}
4445
4446 /// Build an empty clause.
4447 ///
4448 /// \param N Number of variables.
4449 explicit OMPCopyinClause(unsigned N)
4450 : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin,
4452 SourceLocation(), N) {}
4453
4454 /// Set list of helper expressions, required for proper codegen of the
4455 /// clause. These expressions represent source expression in the final
4456 /// assignment statement performed by the copyin clause.
4457 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
4458
4459 /// Get the list of helper source expressions.
4460 MutableArrayRef<Expr *> getSourceExprs() {
4461 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4462 }
4463 ArrayRef<const Expr *> getSourceExprs() const {
4465 }
4466
4467 /// Set list of helper expressions, required for proper codegen of the
4468 /// clause. These expressions represent destination expression in the final
4469 /// assignment statement performed by the copyin clause.
4470 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
4471
4472 /// Get the list of helper destination expressions.
4473 MutableArrayRef<Expr *> getDestinationExprs() {
4474 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
4475 }
4476 ArrayRef<const Expr *> getDestinationExprs() const {
4477 return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
4478 }
4479
4480 /// Set list of helper assignment expressions, required for proper
4481 /// codegen of the clause. These expressions are assignment expressions that
4482 /// assign source helper expressions to destination helper expressions
4483 /// correspondingly.
4484 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
4485
4486 /// Get the list of helper assignment expressions.
4487 MutableArrayRef<Expr *> getAssignmentOps() {
4488 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
4489 }
4490 ArrayRef<const Expr *> getAssignmentOps() const {
4491 return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
4492 }
4493
4494public:
4495 /// Creates clause with a list of variables \a VL.
4496 ///
4497 /// \param C AST context.
4498 /// \param StartLoc Starting location of the clause.
4499 /// \param LParenLoc Location of '('.
4500 /// \param EndLoc Ending location of the clause.
4501 /// \param VL List of references to the variables.
4502 /// \param SrcExprs List of helper expressions for proper generation of
4503 /// assignment operation required for copyin clause. This list represents
4504 /// sources.
4505 /// \param DstExprs List of helper expressions for proper generation of
4506 /// assignment operation required for copyin clause. This list represents
4507 /// destinations.
4508 /// \param AssignmentOps List of helper expressions that represents assignment
4509 /// operation:
4510 /// \code
4511 /// DstExprs = SrcExprs;
4512 /// \endcode
4513 /// Required for proper codegen of propagation of master's thread values of
4514 /// threadprivate variables to local instances of that variables in other
4515 /// implicit threads.
4516 static OMPCopyinClause *
4517 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4518 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
4519 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
4520
4521 /// Creates an empty clause with \a N variables.
4522 ///
4523 /// \param C AST context.
4524 /// \param N The number of variables.
4525 static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
4526
4529 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4531 llvm::iterator_range<helper_expr_const_iterator>;
4532
4534 return helper_expr_const_range(getSourceExprs().begin(),
4535 getSourceExprs().end());
4536 }
4537
4539 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
4540 }
4541
4543 return helper_expr_const_range(getDestinationExprs().begin(),
4544 getDestinationExprs().end());
4545 }
4546
4548 return helper_expr_range(getDestinationExprs().begin(),
4549 getDestinationExprs().end());
4550 }
4551
4553 return helper_expr_const_range(getAssignmentOps().begin(),
4554 getAssignmentOps().end());
4555 }
4556
4558 return helper_expr_range(getAssignmentOps().begin(),
4559 getAssignmentOps().end());
4560 }
4561
4563 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4564 reinterpret_cast<Stmt **>(varlist_end()));
4565 }
4566
4568 auto Children = const_cast<OMPCopyinClause *>(this)->children();
4569 return const_child_range(Children.begin(), Children.end());
4570 }
4571
4574 }
4577 }
4578
4579 static bool classof(const OMPClause *T) {
4580 return T->getClauseKind() == llvm::omp::OMPC_copyin;
4581 }
4582};
4583
4584/// This represents clause 'copyprivate' in the '#pragma omp ...'
4585/// directives.
4586///
4587/// \code
4588/// #pragma omp single copyprivate(a,b)
4589/// \endcode
4590/// In this example directive '#pragma omp single' has clause 'copyprivate'
4591/// with the variables 'a' and 'b'.
4593 : public OMPVarListClause<OMPCopyprivateClause>,
4594 private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
4595 friend class OMPClauseReader;
4596 friend OMPVarListClause;
4597 friend TrailingObjects;
4598
4599 /// Build clause with number of variables \a N.
4600 ///
4601 /// \param StartLoc Starting location of the clause.
4602 /// \param LParenLoc Location of '('.
4603 /// \param EndLoc Ending location of the clause.
4604 /// \param N Number of the variables in the clause.
4606 SourceLocation EndLoc, unsigned N)
4607 : OMPVarListClause<OMPCopyprivateClause>(llvm::omp::OMPC_copyprivate,
4608 StartLoc, LParenLoc, EndLoc, N) {
4609 }
4610
4611 /// Build an empty clause.
4612 ///
4613 /// \param N Number of variables.
4614 explicit OMPCopyprivateClause(unsigned N)
4616 llvm::omp::OMPC_copyprivate, SourceLocation(), SourceLocation(),
4617 SourceLocation(), N) {}
4618
4619 /// Set list of helper expressions, required for proper codegen of the
4620 /// clause. These expressions represent source expression in the final
4621 /// assignment statement performed by the copyprivate clause.
4622 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
4623
4624 /// Get the list of helper source expressions.
4625 MutableArrayRef<Expr *> getSourceExprs() {
4626 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4627 }
4628 ArrayRef<const Expr *> getSourceExprs() const {
4630 }
4631
4632 /// Set list of helper expressions, required for proper codegen of the
4633 /// clause. These expressions represent destination expression in the final
4634 /// assignment statement performed by the copyprivate clause.
4635 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
4636
4637 /// Get the list of helper destination expressions.
4638 MutableArrayRef<Expr *> getDestinationExprs() {
4639 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
4640 }
4641 ArrayRef<const Expr *> getDestinationExprs() const {
4642 return llvm::ArrayRef(getSourceExprs().end(), varlist_size());
4643 }
4644
4645 /// Set list of helper assignment expressions, required for proper
4646 /// codegen of the clause. These expressions are assignment expressions that
4647 /// assign source helper expressions to destination helper expressions
4648 /// correspondingly.
4649 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
4650
4651 /// Get the list of helper assignment expressions.
4652 MutableArrayRef<Expr *> getAssignmentOps() {
4653 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
4654 }
4655 ArrayRef<const Expr *> getAssignmentOps() const {
4656 return llvm::ArrayRef(getDestinationExprs().end(), varlist_size());
4657 }
4658
4659public:
4660 /// Creates clause with a list of variables \a VL.
4661 ///
4662 /// \param C AST context.
4663 /// \param StartLoc Starting location of the clause.
4664 /// \param LParenLoc Location of '('.
4665 /// \param EndLoc Ending location of the clause.
4666 /// \param VL List of references to the variables.
4667 /// \param SrcExprs List of helper expressions for proper generation of
4668 /// assignment operation required for copyprivate clause. This list represents
4669 /// sources.
4670 /// \param DstExprs List of helper expressions for proper generation of
4671 /// assignment operation required for copyprivate clause. This list represents
4672 /// destinations.
4673 /// \param AssignmentOps List of helper expressions that represents assignment
4674 /// operation:
4675 /// \code
4676 /// DstExprs = SrcExprs;
4677 /// \endcode
4678 /// Required for proper codegen of final assignment performed by the
4679 /// copyprivate clause.
4680 static OMPCopyprivateClause *
4681 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4682 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
4683 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
4684
4685 /// Creates an empty clause with \a N variables.
4686 ///
4687 /// \param C AST context.
4688 /// \param N The number of variables.
4689 static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
4690
4693 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
4695 llvm::iterator_range<helper_expr_const_iterator>;
4696
4698 return helper_expr_const_range(getSourceExprs().begin(),
4699 getSourceExprs().end());
4700 }
4701
4703 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
4704 }
4705
4707 return helper_expr_const_range(getDestinationExprs().begin(),
4708 getDestinationExprs().end());
4709 }
4710
4712 return helper_expr_range(getDestinationExprs().begin(),
4713 getDestinationExprs().end());
4714 }
4715
4717 return helper_expr_const_range(getAssignmentOps().begin(),
4718 getAssignmentOps().end());
4719 }
4720
4722 return helper_expr_range(getAssignmentOps().begin(),
4723 getAssignmentOps().end());
4724 }
4725
4727 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4728 reinterpret_cast<Stmt **>(varlist_end()));
4729 }
4730
4732 auto Children = const_cast<OMPCopyprivateClause *>(this)->children();
4733 return const_child_range(Children.begin(), Children.end());
4734 }
4735
4738 }
4741 }
4742
4743 static bool classof(const OMPClause *T) {
4744 return T->getClauseKind() == llvm::omp::OMPC_copyprivate;
4745 }
4746};
4747
4748/// This represents implicit clause 'flush' for the '#pragma omp flush'
4749/// directive.
4750/// This clause does not exist by itself, it can be only as a part of 'omp
4751/// flush' directive. This clause is introduced to keep the original structure
4752/// of \a OMPExecutableDirective class and its derivatives and to use the
4753/// existing infrastructure of clauses with the list of variables.
4754///
4755/// \code
4756/// #pragma omp flush(a,b)
4757/// \endcode
4758/// In this example directive '#pragma omp flush' has implicit clause 'flush'
4759/// with the variables 'a' and 'b'.
4761 : public OMPVarListClause<OMPFlushClause>,
4762 private llvm::TrailingObjects<OMPFlushClause, Expr *> {
4763 friend OMPVarListClause;
4764 friend TrailingObjects;
4765
4766 /// Build clause with number of variables \a N.
4767 ///
4768 /// \param StartLoc Starting location of the clause.
4769 /// \param LParenLoc Location of '('.
4770 /// \param EndLoc Ending location of the clause.
4771 /// \param N Number of the variables in the clause.
4772 OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4773 SourceLocation EndLoc, unsigned N)
4774 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush, StartLoc,
4775 LParenLoc, EndLoc, N) {}
4776
4777 /// Build an empty clause.
4778 ///
4779 /// \param N Number of variables.
4780 explicit OMPFlushClause(unsigned N)
4781 : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush,
4783 SourceLocation(), N) {}
4784
4785public:
4786 /// Creates clause with a list of variables \a VL.
4787 ///
4788 /// \param C AST context.
4789 /// \param StartLoc Starting location of the clause.
4790 /// \param LParenLoc Location of '('.
4791 /// \param EndLoc Ending location of the clause.
4792 /// \param VL List of references to the variables.
4793 static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
4794 SourceLocation LParenLoc, SourceLocation EndLoc,
4795 ArrayRef<Expr *> VL);
4796
4797 /// Creates an empty clause with \a N variables.
4798 ///
4799 /// \param C AST context.
4800 /// \param N The number of variables.
4801 static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
4802
4804 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4805 reinterpret_cast<Stmt **>(varlist_end()));
4806 }
4807
4809 auto Children = const_cast<OMPFlushClause *>(this)->children();
4810 return const_child_range(Children.begin(), Children.end());
4811 }
4812
4815 }
4818 }
4819
4820 static bool classof(const OMPClause *T) {
4821 return T->getClauseKind() == llvm::omp::OMPC_flush;
4822 }
4823};
4824
4825/// This represents implicit clause 'depobj' for the '#pragma omp depobj'
4826/// directive.
4827/// This clause does not exist by itself, it can be only as a part of 'omp
4828/// depobj' directive. This clause is introduced to keep the original structure
4829/// of \a OMPExecutableDirective class and its derivatives and to use the
4830/// existing infrastructure of clauses with the list of variables.
4831///
4832/// \code
4833/// #pragma omp depobj(a) destroy
4834/// \endcode
4835/// In this example directive '#pragma omp depobj' has implicit clause 'depobj'
4836/// with the depobj 'a'.
4837class OMPDepobjClause final : public OMPClause {
4838 friend class OMPClauseReader;
4839
4840 /// Location of '('.
4841 SourceLocation LParenLoc;
4842
4843 /// Chunk size.
4844 Expr *Depobj = nullptr;
4845
4846 /// Build clause with number of variables \a N.
4847 ///
4848 /// \param StartLoc Starting location of the clause.
4849 /// \param LParenLoc Location of '('.
4850 /// \param EndLoc Ending location of the clause.
4851 OMPDepobjClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4852 SourceLocation EndLoc)
4853 : OMPClause(llvm::omp::OMPC_depobj, StartLoc, EndLoc),
4854 LParenLoc(LParenLoc) {}
4855
4856 /// Build an empty clause.
4857 ///
4858 explicit OMPDepobjClause()
4859 : OMPClause(llvm::omp::OMPC_depobj, SourceLocation(), SourceLocation()) {}
4860
4861 void setDepobj(Expr *E) { Depobj = E; }
4862
4863 /// Sets the location of '('.
4864 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4865
4866public:
4867 /// Creates clause.
4868 ///
4869 /// \param C AST context.
4870 /// \param StartLoc Starting location of the clause.
4871 /// \param LParenLoc Location of '('.
4872 /// \param EndLoc Ending location of the clause.
4873 /// \param Depobj depobj expression associated with the 'depobj' directive.
4874 static OMPDepobjClause *Create(const ASTContext &C, SourceLocation StartLoc,
4875 SourceLocation LParenLoc,
4876 SourceLocation EndLoc, Expr *Depobj);
4877
4878 /// Creates an empty clause.
4879 ///
4880 /// \param C AST context.
4881 static OMPDepobjClause *CreateEmpty(const ASTContext &C);
4882
4883 /// Returns depobj expression associated with the clause.
4884 Expr *getDepobj() { return Depobj; }
4885 const Expr *getDepobj() const { return Depobj; }
4886
4887 /// Returns the location of '('.
4888 SourceLocation getLParenLoc() const { return LParenLoc; }
4889
4891 return child_range(reinterpret_cast<Stmt **>(&Depobj),
4892 reinterpret_cast<Stmt **>(&Depobj) + 1);
4893 }
4894
4896 auto Children = const_cast<OMPDepobjClause *>(this)->children();
4897 return const_child_range(Children.begin(), Children.end());
4898 }
4899
4902 }
4905 }
4906
4907 static bool classof(const OMPClause *T) {
4908 return T->getClauseKind() == llvm::omp::OMPC_depobj;
4909 }
4910};
4911
4912/// This represents implicit clause 'depend' for the '#pragma omp task'
4913/// directive.
4914///
4915/// \code
4916/// #pragma omp task depend(in:a,b)
4917/// \endcode
4918/// In this example directive '#pragma omp task' with clause 'depend' with the
4919/// variables 'a' and 'b' with dependency 'in'.
4921 : public OMPVarListClause<OMPDependClause>,
4922 private llvm::TrailingObjects<OMPDependClause, Expr *> {
4923 friend class OMPClauseReader;
4924 friend OMPVarListClause;
4925 friend TrailingObjects;
4926
4927public:
4928 struct DependDataTy final {
4929 /// Dependency type (one of in, out, inout).
4931
4932 /// Dependency type location.
4934
4935 /// Colon location.
4937
4938 /// Location of 'omp_all_memory'.
4940 };
4941
4942private:
4943 /// Dependency type and source locations.
4944 DependDataTy Data;
4945
4946 /// Number of loops, associated with the depend clause.
4947 unsigned NumLoops = 0;
4948
4949 /// Build clause with number of variables \a N.
4950 ///
4951 /// \param StartLoc Starting location of the clause.
4952 /// \param LParenLoc Location of '('.
4953 /// \param EndLoc Ending location of the clause.
4954 /// \param N Number of the variables in the clause.
4955 /// \param NumLoops Number of loops that is associated with this depend
4956 /// clause.
4957 OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4958 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
4959 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend, StartLoc,
4960 LParenLoc, EndLoc, N),
4961 NumLoops(NumLoops) {}
4962
4963 /// Build an empty clause.
4964 ///
4965 /// \param N Number of variables.
4966 /// \param NumLoops Number of loops that is associated with this depend
4967 /// clause.
4968 explicit OMPDependClause(unsigned N, unsigned NumLoops)
4969 : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend,
4971 SourceLocation(), N),
4972 NumLoops(NumLoops) {}
4973
4974 /// Set dependency kind.
4975 void setDependencyKind(OpenMPDependClauseKind K) { Data.DepKind = K; }
4976
4977 /// Set dependency kind and its location.
4978 void setDependencyLoc(SourceLocation Loc) { Data.DepLoc = Loc; }
4979
4980 /// Set colon location.
4981 void setColonLoc(SourceLocation Loc) { Data.ColonLoc = Loc; }
4982
4983 /// Set the 'omp_all_memory' location.
4984 void setOmpAllMemoryLoc(SourceLocation Loc) { Data.OmpAllMemoryLoc = Loc; }
4985
4986 /// Sets optional dependency modifier.
4987 void setModifier(Expr *DepModifier);
4988
4989public:
4990 /// Creates clause with a list of variables \a VL.
4991 ///
4992 /// \param C AST context.
4993 /// \param StartLoc Starting location of the clause.
4994 /// \param LParenLoc Location of '('.
4995 /// \param EndLoc Ending location of the clause.
4996 /// \param Data Dependency type and source locations.
4997 /// \param VL List of references to the variables.
4998 /// \param NumLoops Number of loops that is associated with this depend
4999 /// clause.
5000 static OMPDependClause *Create(const ASTContext &C, SourceLocation StartLoc,
5001 SourceLocation LParenLoc,
5002 SourceLocation EndLoc, DependDataTy Data,
5003 Expr *DepModifier, ArrayRef<Expr *> VL,
5004 unsigned NumLoops);
5005
5006 /// Creates an empty clause with \a N variables.
5007 ///
5008 /// \param C AST context.
5009 /// \param N The number of variables.
5010 /// \param NumLoops Number of loops that is associated with this depend
5011 /// clause.
5012 static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N,
5013 unsigned NumLoops);
5014
5015 /// Get dependency type.
5017
5018 /// Get dependency type location.
5019 SourceLocation getDependencyLoc() const { return Data.DepLoc; }
5020
5021 /// Get colon location.
5022 SourceLocation getColonLoc() const { return Data.ColonLoc; }
5023
5024 /// Get 'omp_all_memory' location.
5025 SourceLocation getOmpAllMemoryLoc() const { return Data.OmpAllMemoryLoc; }
5026
5027 /// Return optional depend modifier.
5028 Expr *getModifier();
5029 const Expr *getModifier() const {
5030 return const_cast<OMPDependClause *>(this)->getModifier();
5031 }
5032
5033 /// Get number of loops associated with the clause.
5034 unsigned getNumLoops() const { return NumLoops; }
5035
5036 /// Set the loop data for the depend clauses with 'sink|source' kind of
5037 /// dependency.
5038 void setLoopData(unsigned NumLoop, Expr *Cnt);
5039
5040 /// Get the loop data.
5041 Expr *getLoopData(unsigned NumLoop);
5042 const Expr *getLoopData(unsigned NumLoop) const;
5043
5045 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5046 reinterpret_cast<Stmt **>(varlist_end()));
5047 }
5048
5050 auto Children = const_cast<OMPDependClause *>(this)->children();
5051 return const_child_range(Children.begin(), Children.end());
5052 }
5053
5056 }
5059 }
5060
5061 static bool classof(const OMPClause *T) {
5062 return T->getClauseKind() == llvm::omp::OMPC_depend;
5063 }
5064};
5065
5066/// This represents 'device' clause in the '#pragma omp ...'
5067/// directive.
5068///
5069/// \code
5070/// #pragma omp target device(a)
5071/// \endcode
5072/// In this example directive '#pragma omp target' has clause 'device'
5073/// with single expression 'a'.
5075 friend class OMPClauseReader;
5076
5077 /// Location of '('.
5078 SourceLocation LParenLoc;
5079
5080 /// Device clause modifier.
5082
5083 /// Location of the modifier.
5084 SourceLocation ModifierLoc;
5085
5086 /// Device number.
5087 Stmt *Device = nullptr;
5088
5089 /// Set the device number.
5090 ///
5091 /// \param E Device number.
5092 void setDevice(Expr *E) { Device = E; }
5093
5094 /// Sets modifier.
5095 void setModifier(OpenMPDeviceClauseModifier M) { Modifier = M; }
5096
5097 /// Setst modifier location.
5098 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
5099
5100public:
5101 /// Build 'device' clause.
5102 ///
5103 /// \param Modifier Clause modifier.
5104 /// \param E Expression associated with this clause.
5105 /// \param CaptureRegion Innermost OpenMP region where expressions in this
5106 /// clause must be captured.
5107 /// \param StartLoc Starting location of the clause.
5108 /// \param ModifierLoc Modifier location.
5109 /// \param LParenLoc Location of '('.
5110 /// \param EndLoc Ending location of the clause.
5112 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
5113 SourceLocation LParenLoc, SourceLocation ModifierLoc,
5114 SourceLocation EndLoc)
5115 : OMPClause(llvm::omp::OMPC_device, StartLoc, EndLoc),
5116 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
5117 ModifierLoc(ModifierLoc), Device(E) {
5118 setPreInitStmt(HelperE, CaptureRegion);
5119 }
5120
5121 /// Build an empty clause.
5123 : OMPClause(llvm::omp::OMPC_device, SourceLocation(), SourceLocation()),
5124 OMPClauseWithPreInit(this) {}
5125
5126 /// Sets the location of '('.
5127 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5128
5129 /// Returns the location of '('.
5130 SourceLocation getLParenLoc() const { return LParenLoc; }
5131
5132 /// Return device number.
5133 Expr *getDevice() { return cast<Expr>(Device); }
5134
5135 /// Return device number.
5136 Expr *getDevice() const { return cast<Expr>(Device); }
5137
5138 /// Gets modifier.
5139 OpenMPDeviceClauseModifier getModifier() const { return Modifier; }
5140
5141 /// Gets modifier location.
5142 SourceLocation getModifierLoc() const { return ModifierLoc; }
5143
5145
5147 return const_child_range(&Device, &Device + 1);
5148 }
5149
5152 }
5155 }
5156
5157 static bool classof(const OMPClause *T) {
5158 return T->getClauseKind() == llvm::omp::OMPC_device;
5159 }
5160};
5161
5162/// This represents 'threads' clause in the '#pragma omp ...' directive.
5163///
5164/// \code
5165/// #pragma omp ordered threads
5166/// \endcode
5167/// In this example directive '#pragma omp ordered' has simple 'threads' clause.
5169 : public OMPNoChildClause<llvm::omp::OMPC_threads> {
5170public:
5171 /// Build 'threads' clause.
5172 ///
5173 /// \param StartLoc Starting location of the clause.
5174 /// \param EndLoc Ending location of the clause.
5176 : OMPNoChildClause(StartLoc, EndLoc) {}
5177
5178 /// Build an empty clause.
5180};
5181
5182/// This represents 'simd' clause in the '#pragma omp ...' directive.
5183///
5184/// \code
5185/// #pragma omp ordered simd
5186/// \endcode
5187/// In this example directive '#pragma omp ordered' has simple 'simd' clause.
5188class OMPSIMDClause : public OMPClause {
5189public:
5190 /// Build 'simd' clause.
5191 ///
5192 /// \param StartLoc Starting location of the clause.
5193 /// \param EndLoc Ending location of the clause.
5195 : OMPClause(llvm::omp::OMPC_simd, StartLoc, EndLoc) {}
5196
5197 /// Build an empty clause.
5199 : OMPClause(llvm::omp::OMPC_simd, SourceLocation(), SourceLocation()) {}
5200
5203 }
5204
5207 }
5208
5211 }
5214 }
5215
5216 static bool classof(const OMPClause *T) {
5217 return T->getClauseKind() == llvm::omp::OMPC_simd;
5218 }
5219};
5220
5221/// Struct that defines common infrastructure to handle mappable
5222/// expressions used in OpenMP clauses.
5224public:
5225 /// Class that represents a component of a mappable expression. E.g.
5226 /// for an expression S.a, the first component is a declaration reference
5227 /// expression associated with 'S' and the second is a member expression
5228 /// associated with the field declaration 'a'. If the expression is an array
5229 /// subscript it may not have any associated declaration. In that case the
5230 /// associated declaration is set to nullptr.
5232 /// Pair of Expression and Non-contiguous pair associated with the
5233 /// component.
5234 llvm::PointerIntPair<Expr *, 1, bool> AssociatedExpressionNonContiguousPr;
5235
5236 /// Declaration associated with the declaration. If the component does
5237 /// not have a declaration (e.g. array subscripts or section), this is set
5238 /// to nullptr.
5239 ValueDecl *AssociatedDeclaration = nullptr;
5240
5241 public:
5242 explicit MappableComponent() = default;
5243 explicit MappableComponent(Expr *AssociatedExpression,
5244 ValueDecl *AssociatedDeclaration,
5245 bool IsNonContiguous)
5246 : AssociatedExpressionNonContiguousPr(AssociatedExpression,
5247 IsNonContiguous),
5248 AssociatedDeclaration(
5249 AssociatedDeclaration
5250 ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
5251 : nullptr) {}
5252
5254 return AssociatedExpressionNonContiguousPr.getPointer();
5255 }
5256
5257 bool isNonContiguous() const {
5258 return AssociatedExpressionNonContiguousPr.getInt();
5259 }
5260
5262 return AssociatedDeclaration;
5263 }
5264 };
5265
5266 // List of components of an expression. This first one is the whole
5267 // expression and the last one is the base expression.
5270
5271 // List of all component lists associated to the same base declaration.
5272 // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
5273 // their component list but the same base declaration 'S'.
5276
5277protected:
5278 // Return the total number of elements in a list of component lists.
5279 static unsigned
5281
5282 // Return the total number of elements in a list of declarations. All
5283 // declarations are expected to be canonical.
5284 static unsigned
5286};
5287
5288/// This structure contains all sizes needed for by an
5289/// OMPMappableExprListClause.
5291 /// Number of expressions listed.
5292 unsigned NumVars;
5293 /// Number of unique base declarations.
5295 /// Number of component lists.
5297 /// Total number of expression components.
5301 unsigned NumComponentLists, unsigned NumComponents)
5304};
5305
5306/// This represents clauses with a list of expressions that are mappable.
5307/// Examples of these clauses are 'map' in
5308/// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
5309/// in '#pragma omp target update...' directives.
5310template <class T>
5313 friend class OMPClauseReader;
5314
5315 /// Number of unique declarations in this clause.
5316 unsigned NumUniqueDeclarations;
5317
5318 /// Number of component lists in this clause.
5319 unsigned NumComponentLists;
5320
5321 /// Total number of components in this clause.
5322 unsigned NumComponents;
5323
5324 /// Whether this clause is possible to have user-defined mappers associated.
5325 /// It should be true for map, to, and from clauses, and false for
5326 /// use_device_ptr and is_device_ptr.
5327 const bool SupportsMapper;
5328
5329 /// C++ nested name specifier for the associated user-defined mapper.
5330 NestedNameSpecifierLoc MapperQualifierLoc;
5331
5332 /// The associated user-defined mapper identifier information.
5333 DeclarationNameInfo MapperIdInfo;
5334
5335protected:
5336 /// Build a clause for \a NumUniqueDeclarations declarations, \a
5337 /// NumComponentLists total component lists, and \a NumComponents total
5338 /// components.
5339 ///
5340 /// \param K Kind of the clause.
5341 /// \param Locs Locations needed to build a mappable clause. It includes 1)
5342 /// StartLoc: starting location of the clause (the clause keyword); 2)
5343 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5344 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5345 /// NumVars: number of expressions listed in this clause; 2)
5346 /// NumUniqueDeclarations: number of unique base declarations in this clause;
5347 /// 3) NumComponentLists: number of component lists in this clause; and 4)
5348 /// NumComponents: total number of expression components in the clause.
5349 /// \param SupportsMapper Indicates whether this clause is possible to have
5350 /// user-defined mappers associated.
5351 /// \param MapperQualifierLocPtr C++ nested name specifier for the associated
5352 /// user-defined mapper.
5353 /// \param MapperIdInfoPtr The identifier of associated user-defined mapper.
5355 OpenMPClauseKind K, const OMPVarListLocTy &Locs,
5356 const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false,
5357 NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr,
5358 DeclarationNameInfo *MapperIdInfoPtr = nullptr)
5359 : OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc,
5360 Sizes.NumVars),
5361 NumUniqueDeclarations(Sizes.NumUniqueDeclarations),
5362 NumComponentLists(Sizes.NumComponentLists),
5363 NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) {
5364 if (MapperQualifierLocPtr)
5365 MapperQualifierLoc = *MapperQualifierLocPtr;
5366 if (MapperIdInfoPtr)
5367 MapperIdInfo = *MapperIdInfoPtr;
5368 }
5369
5370 /// Get the unique declarations that are in the trailing objects of the
5371 /// class.
5374 static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(),
5375 NumUniqueDeclarations);
5376 }
5377
5378 /// Get the unique declarations that are in the trailing objects of the
5379 /// class.
5381 return ArrayRef<ValueDecl *>(
5382 static_cast<const T *>(this)
5383 ->template getTrailingObjects<ValueDecl *>(),
5384 NumUniqueDeclarations);
5385 }
5386
5387 /// Set the unique declarations that are in the trailing objects of the
5388 /// class.
5390 assert(UDs.size() == NumUniqueDeclarations &&
5391 "Unexpected amount of unique declarations.");
5392 std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin());
5393 }
5394
5395 /// Get the number of lists per declaration that are in the trailing
5396 /// objects of the class.
5399 static_cast<T *>(this)->template getTrailingObjects<unsigned>(),
5400 NumUniqueDeclarations);
5401 }
5402
5403 /// Get the number of lists per declaration that are in the trailing
5404 /// objects of the class.
5406 return ArrayRef<unsigned>(
5407 static_cast<const T *>(this)->template getTrailingObjects<unsigned>(),
5408 NumUniqueDeclarations);
5409 }
5410
5411 /// Set the number of lists per declaration that are in the trailing
5412 /// objects of the class.
5414 assert(DNLs.size() == NumUniqueDeclarations &&
5415 "Unexpected amount of list numbers.");
5416 std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin());
5417 }
5418
5419 /// Get the cumulative component lists sizes that are in the trailing
5420 /// objects of the class. They are appended after the number of lists.
5423 static_cast<T *>(this)->template getTrailingObjects<unsigned>() +
5424 NumUniqueDeclarations,
5425 NumComponentLists);
5426 }
5427
5428 /// Get the cumulative component lists sizes that are in the trailing
5429 /// objects of the class. They are appended after the number of lists.
5431 return ArrayRef<unsigned>(
5432 static_cast<const T *>(this)->template getTrailingObjects<unsigned>() +
5433 NumUniqueDeclarations,
5434 NumComponentLists);
5435 }
5436
5437 /// Set the cumulative component lists sizes that are in the trailing
5438 /// objects of the class.
5440 assert(CLSs.size() == NumComponentLists &&
5441 "Unexpected amount of component lists.");
5442 std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin());
5443 }
5444
5445 /// Get the components that are in the trailing objects of the class.
5448 static_cast<T *>(this)
5449 ->template getTrailingObjects<MappableComponent>(),
5450 NumComponents);
5451 }
5452
5453 /// Get the components that are in the trailing objects of the class.
5456 static_cast<const T *>(this)
5457 ->template getTrailingObjects<MappableComponent>(),
5458 NumComponents);
5459 }
5460
5461 /// Set the components that are in the trailing objects of the class.
5462 /// This requires the list sizes so that it can also fill the original
5463 /// expressions, which are the first component of each list.
5465 ArrayRef<unsigned> CLSs) {
5466 assert(Components.size() == NumComponents &&
5467 "Unexpected amount of component lists.");
5468 assert(CLSs.size() == NumComponentLists &&
5469 "Unexpected amount of list sizes.");
5470 std::copy(Components.begin(), Components.end(), getComponentsRef().begin());
5471 }
5472
5473 /// Fill the clause information from the list of declarations and
5474 /// associated component lists.
5476 MappableExprComponentListsRef ComponentLists) {
5477 // Perform some checks to make sure the data sizes are consistent with the
5478 // information available when the clause was created.
5479 assert(getUniqueDeclarationsTotalNumber(Declarations) ==
5480 NumUniqueDeclarations &&
5481 "Unexpected number of mappable expression info entries!");
5482 assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
5483 "Unexpected total number of components!");
5484 assert(Declarations.size() == ComponentLists.size() &&
5485 "Declaration and component lists size is not consistent!");
5486 assert(Declarations.size() == NumComponentLists &&
5487 "Unexpected declaration and component lists size!");
5488
5489 // Organize the components by declaration and retrieve the original
5490 // expression. Original expressions are always the first component of the
5491 // mappable component list.
5492 llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
5493 ComponentListMap;
5494 {
5495 auto CI = ComponentLists.begin();
5496 for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
5497 ++DI, ++CI) {
5498 assert(!CI->empty() && "Invalid component list!");
5499 ComponentListMap[*DI].push_back(*CI);
5500 }
5501 }
5502
5503 // Iterators of the target storage.
5504 auto UniqueDeclarations = getUniqueDeclsRef();
5505 auto UDI = UniqueDeclarations.begin();
5506
5507 auto DeclNumLists = getDeclNumListsRef();
5508 auto DNLI = DeclNumLists.begin();
5509
5510 auto ComponentListSizes = getComponentListSizesRef();
5511 auto CLSI = ComponentListSizes.begin();
5512
5513 auto Components = getComponentsRef();
5514 auto CI = Components.begin();
5515
5516 // Variable to compute the accumulation of the number of components.
5517 unsigned PrevSize = 0u;
5518
5519 // Scan all the declarations and associated component lists.
5520 for (auto &M : ComponentListMap) {
5521 // The declaration.
5522 auto *D = M.first;
5523 // The component lists.
5524 auto CL = M.second;
5525
5526 // Initialize the entry.
5527 *UDI = D;
5528 ++UDI;
5529
5530 *DNLI = CL.size();
5531 ++DNLI;
5532
5533 // Obtain the cumulative sizes and concatenate all the components in the
5534 // reserved storage.
5535 for (auto C : CL) {
5536 // Accumulate with the previous size.
5537 PrevSize += C.size();
5538
5539 // Save the size.
5540 *CLSI = PrevSize;
5541 ++CLSI;
5542
5543 // Append components after the current components iterator.
5544 CI = std::copy(C.begin(), C.end(), CI);
5545 }
5546 }
5547 }
5548
5549 /// Set the nested name specifier of associated user-defined mapper.
5551 MapperQualifierLoc = NNSL;
5552 }
5553
5554 /// Set the name of associated user-defined mapper.
5556 MapperIdInfo = MapperId;
5557 }
5558
5559 /// Get the user-defined mapper references that are in the trailing objects of
5560 /// the class.
5562 assert(SupportsMapper &&
5563 "Must be a clause that is possible to have user-defined mappers");
5565 static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
5568 }
5569
5570 /// Get the user-defined mappers references that are in the trailing objects
5571 /// of the class.
5573 assert(SupportsMapper &&
5574 "Must be a clause that is possible to have user-defined mappers");
5576 static_cast<const T *>(this)->template getTrailingObjects<Expr *>() +
5579 }
5580
5581 /// Set the user-defined mappers that are in the trailing objects of the
5582 /// class.
5584 assert(DMDs.size() == OMPVarListClause<T>::varlist_size() &&
5585 "Unexpected number of user-defined mappers.");
5586 assert(SupportsMapper &&
5587 "Must be a clause that is possible to have user-defined mappers");
5588 std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin());
5589 }
5590
5591public:
5592 /// Return the number of unique base declarations in this clause.
5593 unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
5594
5595 /// Return the number of lists derived from the clause expressions.
5596 unsigned getTotalComponentListNum() const { return NumComponentLists; }
5597
5598 /// Return the total number of components in all lists derived from the
5599 /// clause.
5600 unsigned getTotalComponentsNum() const { return NumComponents; }
5601
5602 /// Gets the nested name specifier for associated user-defined mapper.
5604 return MapperQualifierLoc;
5605 }
5606
5607 /// Gets the name info for associated user-defined mapper.
5608 const DeclarationNameInfo &getMapperIdInfo() const { return MapperIdInfo; }
5609
5610 /// Iterator that browse the components by lists. It also allows
5611 /// browsing components of a single declaration.
5613 : public llvm::iterator_adaptor_base<
5614 const_component_lists_iterator,
5615 MappableExprComponentListRef::const_iterator,
5616 std::forward_iterator_tag, MappableComponent, ptrdiff_t,
5617 MappableComponent, MappableComponent> {
5618 // The declaration the iterator currently refers to.
5620
5621 // The list number associated with the current declaration.
5622 ArrayRef<unsigned>::iterator NumListsCur;
5623
5624 // Whether this clause is possible to have user-defined mappers associated.
5625 const bool SupportsMapper;
5626
5627 // The user-defined mapper associated with the current declaration.
5629
5630 // Remaining lists for the current declaration.
5631 unsigned RemainingLists = 0;
5632
5633 // The cumulative size of the previous list, or zero if there is no previous
5634 // list.
5635 unsigned PrevListSize = 0;
5636
5637 // The cumulative sizes of the current list - it will delimit the remaining
5638 // range of interest.
5641
5642 // Iterator to the end of the components storage.
5643 MappableExprComponentListRef::const_iterator End;
5644
5645 public:
5646 /// Construct an iterator that scans all lists.
5648 ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
5649 ArrayRef<unsigned> CumulativeListSizes,
5650 MappableExprComponentListRef Components, bool SupportsMapper,
5651 ArrayRef<Expr *> Mappers)
5652 : const_component_lists_iterator::iterator_adaptor_base(
5653 Components.begin()),
5654 DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
5655 SupportsMapper(SupportsMapper),
5656 ListSizeCur(CumulativeListSizes.begin()),
5657 ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
5658 assert(UniqueDecls.size() == DeclsListNum.size() &&
5659 "Inconsistent number of declarations and list sizes!");
5660 if (!DeclsListNum.empty())
5661 RemainingLists = *NumListsCur;
5662 if (SupportsMapper)
5663 MapperCur = Mappers.begin();
5664 }
5665
5666 /// Construct an iterator that scan lists for a given declaration \a
5667 /// Declaration.
5669 const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
5670 ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
5671 MappableExprComponentListRef Components, bool SupportsMapper,
5672 ArrayRef<Expr *> Mappers)
5673 : const_component_lists_iterator(UniqueDecls, DeclsListNum,
5674 CumulativeListSizes, Components,
5675 SupportsMapper, Mappers) {
5676 // Look for the desired declaration. While we are looking for it, we
5677 // update the state so that we know the component where a given list
5678 // starts.
5679 for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
5680 if (*DeclCur == Declaration)
5681 break;
5682
5683 assert(*NumListsCur > 0 && "No lists associated with declaration??");
5684
5685 // Skip the lists associated with the current declaration, but save the
5686 // last list size that was skipped.
5687 std::advance(ListSizeCur, *NumListsCur - 1);
5688 PrevListSize = *ListSizeCur;
5689 ++ListSizeCur;
5690
5691 if (SupportsMapper)
5692 ++MapperCur;
5693 }
5694
5695 // If we didn't find any declaration, advance the iterator to after the
5696 // last component and set remaining lists to zero.
5697 if (ListSizeCur == CumulativeListSizes.end()) {
5698 this->I = End;
5699 RemainingLists = 0u;
5700 return;
5701 }
5702
5703 // Set the remaining lists with the total number of lists of the current
5704 // declaration.
5705 RemainingLists = *NumListsCur;
5706
5707 // Adjust the list size end iterator to the end of the relevant range.
5708 ListSizeEnd = ListSizeCur;
5709 std::advance(ListSizeEnd, RemainingLists);
5710
5711 // Given that the list sizes are cumulative, the index of the component
5712 // that start the list is the size of the previous list.
5713 std::advance(this->I, PrevListSize);
5714 }
5715
5716 // Return the array with the current list. The sizes are cumulative, so the
5717 // array size is the difference between the current size and previous one.
5718 std::tuple<const ValueDecl *, MappableExprComponentListRef,
5719 const ValueDecl *>
5720 operator*() const {
5721 assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
5722 const ValueDecl *Mapper = nullptr;
5723 if (SupportsMapper && *MapperCur)
5724 Mapper = cast<ValueDecl>(cast<DeclRefExpr>(*MapperCur)->getDecl());
5725 return std::make_tuple(
5726 *DeclCur,
5727 MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize),
5728 Mapper);
5729 }
5730 std::tuple<const ValueDecl *, MappableExprComponentListRef,
5731 const ValueDecl *>
5732 operator->() const {
5733 return **this;
5734 }
5735
5736 // Skip the components of the current list.
5738 assert(ListSizeCur != ListSizeEnd && RemainingLists &&
5739 "Invalid iterator!");
5740
5741 // If we don't have more lists just skip all the components. Otherwise,
5742 // advance the iterator by the number of components in the current list.
5743 if (std::next(ListSizeCur) == ListSizeEnd) {
5744 this->I = End;
5745 RemainingLists = 0;
5746 } else {
5747 std::advance(this->I, *ListSizeCur - PrevListSize);
5748 PrevListSize = *ListSizeCur;
5749
5750 // We are done with a declaration, move to the next one.
5751 if (!(--RemainingLists)) {
5752 ++DeclCur;
5753 ++NumListsCur;
5754 RemainingLists = *NumListsCur;
5755 assert(RemainingLists && "No lists in the following declaration??");
5756 }
5757 }
5758
5759 ++ListSizeCur;
5760 if (SupportsMapper)
5761 ++MapperCur;
5762 return *this;
5763 }
5764 };
5765
5767 llvm::iterator_range<const_component_lists_iterator>;
5768
5769 /// Iterators for all component lists.
5773 getComponentsRef(), SupportsMapper,
5774 SupportsMapper ? getUDMapperRefs() : std::nullopt);
5775 }
5780 getComponentsRef().end()),
5781 SupportsMapper, std::nullopt);
5782 }
5785 }
5786
5787 /// Iterators for component lists associated with the provided
5788 /// declaration.
5789 const_component_lists_iterator
5793 getComponentListSizesRef(), getComponentsRef(), SupportsMapper,
5794 SupportsMapper ? getUDMapperRefs() : std::nullopt);
5795 }
5797 return component_lists_end();
5798 }
5801 }
5802
5803 /// Iterators to access all the declarations, number of lists, list sizes, and
5804 /// components.
5806 using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>;
5807
5809 auto A = getUniqueDeclsRef();
5810 return const_all_decls_range(A.begin(), A.end());
5811 }
5812
5815 llvm::iterator_range<const_all_num_lists_iterator>;
5816
5818 auto A = getDeclNumListsRef();
5819 return const_all_num_lists_range(A.begin(), A.end());
5820 }
5821
5824 llvm::iterator_range<const_all_lists_sizes_iterator>;
5825
5827 auto A = getComponentListSizesRef();
5828 return const_all_lists_sizes_range(A.begin(), A.end());
5829 }
5830
5833 llvm::iterator_range<const_all_components_iterator>;
5834
5836 auto A = getComponentsRef();
5837 return const_all_components_range(A.begin(), A.end());
5838 }
5839
5842 using mapperlist_range = llvm::iterator_range<mapperlist_iterator>;
5844 llvm::iterator_range<mapperlist_const_iterator>;
5845
5849 return getUDMapperRefs().begin();
5850 }
5852 return getUDMapperRefs().end();
5853 }
5856 }
5859 }
5860};
5861
5862/// This represents clause 'map' in the '#pragma omp ...'
5863/// directives.
5864///
5865/// \code
5866/// #pragma omp target map(a,b)
5867/// \endcode
5868/// In this example directive '#pragma omp target' has clause 'map'
5869/// with the variables 'a' and 'b'.
5870class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
5871 private llvm::TrailingObjects<
5872 OMPMapClause, Expr *, ValueDecl *, unsigned,
5873 OMPClauseMappableExprCommon::MappableComponent> {
5874 friend class OMPClauseReader;
5876 friend OMPVarListClause;
5877 friend TrailingObjects;
5878
5879 /// Define the sizes of each trailing object array except the last one. This
5880 /// is required for TrailingObjects to work properly.
5881 size_t numTrailingObjects(OverloadToken<Expr *>) const {
5882 // There are varlist_size() of expressions, and varlist_size() of
5883 // user-defined mappers.
5884 return 2 * varlist_size() + 1;
5885 }
5886 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
5887 return getUniqueDeclarationsNum();
5888 }
5889 size_t numTrailingObjects(OverloadToken<unsigned>) const {
5891 }
5892
5893private:
5894 /// Map-type-modifiers for the 'map' clause.
5899
5900 /// Location of map-type-modifiers for the 'map' clause.
5901 SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers];
5902
5903 /// Map type for the 'map' clause.
5905
5906 /// Is this an implicit map type or not.
5907 bool MapTypeIsImplicit = false;
5908
5909 /// Location of the map type.
5910 SourceLocation MapLoc;
5911
5912 /// Colon location.
5913 SourceLocation ColonLoc;
5914
5915 /// Build a clause for \a NumVars listed expressions, \a
5916 /// NumUniqueDeclarations declarations, \a NumComponentLists total component
5917 /// lists, and \a NumComponents total expression components.
5918 ///
5919 /// \param MapModifiers Map-type-modifiers.
5920 /// \param MapModifiersLoc Locations of map-type-modifiers.
5921 /// \param MapperQualifierLoc C++ nested name specifier for the associated
5922 /// user-defined mapper.
5923 /// \param MapperIdInfo The identifier of associated user-defined mapper.
5924 /// \param MapType Map type.
5925 /// \param MapTypeIsImplicit Map type is inferred implicitly.
5926 /// \param MapLoc Location of the map type.
5927 /// \param Locs Locations needed to build a mappable clause. It includes 1)
5928 /// StartLoc: starting location of the clause (the clause keyword); 2)
5929 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5930 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5931 /// NumVars: number of expressions listed in this clause; 2)
5932 /// NumUniqueDeclarations: number of unique base declarations in this clause;
5933 /// 3) NumComponentLists: number of component lists in this clause; and 4)
5934 /// NumComponents: total number of expression components in the clause.
5935 explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers,
5936 ArrayRef<SourceLocation> MapModifiersLoc,
5937 NestedNameSpecifierLoc MapperQualifierLoc,
5938 DeclarationNameInfo MapperIdInfo,
5939 OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
5940 SourceLocation MapLoc, const OMPVarListLocTy &Locs,
5941 const OMPMappableExprListSizeTy &Sizes)
5942 : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes,
5943 /*SupportsMapper=*/true, &MapperQualifierLoc,
5944 &MapperIdInfo),
5945 MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {
5946 assert(std::size(MapTypeModifiers) == MapModifiers.size() &&
5947 "Unexpected number of map type modifiers.");
5948 llvm::copy(MapModifiers, std::begin(MapTypeModifiers));
5949
5950 assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() &&
5951 "Unexpected number of map type modifier locations.");
5952 llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc));
5953 }
5954
5955 /// Build an empty clause.
5956 ///
5957 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5958 /// NumVars: number of expressions listed in this clause; 2)
5959 /// NumUniqueDeclarations: number of unique base declarations in this clause;
5960 /// 3) NumComponentLists: number of component lists in this clause; and 4)
5961 /// NumComponents: total number of expression components in the clause.
5962 explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes)
5963 : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes,
5964 /*SupportsMapper=*/true) {}
5965
5966 /// Set map-type-modifier for the clause.
5967 ///
5968 /// \param I index for map-type-modifier.
5969 /// \param T map-type-modifier for the clause.
5970 void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) {
5971 assert(I < NumberOfOMPMapClauseModifiers &&
5972 "Unexpected index to store map type modifier, exceeds array size.");
5973 MapTypeModifiers[I] = T;
5974 }
5975
5976 /// Set location for the map-type-modifier.
5977 ///
5978 /// \param I index for map-type-modifier location.
5979 /// \param TLoc map-type-modifier location.
5980 void setMapTypeModifierLoc(unsigned I, SourceLocation TLoc) {
5981 assert(I < NumberOfOMPMapClauseModifiers &&
5982 "Index to store map type modifier location exceeds array size.");
5983 MapTypeModifiersLoc[I] = TLoc;
5984 }
5985
5986 /// Set type for the clause.
5987 ///
5988 /// \param T Type for the clause.
5989 void setMapType(OpenMPMapClauseKind T) { MapType = T; }
5990
5991 /// Set type location.
5992 ///
5993 /// \param TLoc Type location.
5994 void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
5995
5996 /// Set colon location.
5997 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
5998
5999 /// Set iterator modifier.
6000 void setIteratorModifier(Expr *IteratorModifier) {
6001 getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier;
6002 }
6003
6004public:
6005 /// Creates clause with a list of variables \a VL.
6006 ///
6007 /// \param C AST context.
6008 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6009 /// StartLoc: starting location of the clause (the clause keyword); 2)
6010 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6011 /// \param Vars The original expression used in the clause.
6012 /// \param Declarations Declarations used in the clause.
6013 /// \param ComponentLists Component lists used in the clause.
6014 /// \param UDMapperRefs References to user-defined mappers associated with
6015 /// expressions used in the clause.
6016 /// \param IteratorModifier Iterator modifier.
6017 /// \param MapModifiers Map-type-modifiers.
6018 /// \param MapModifiersLoc Location of map-type-modifiers.
6019 /// \param UDMQualifierLoc C++ nested name specifier for the associated
6020 /// user-defined mapper.
6021 /// \param MapperId The identifier of associated user-defined mapper.
6022 /// \param Type Map type.
6023 /// \param TypeIsImplicit Map type is inferred implicitly.
6024 /// \param TypeLoc Location of the map type.
6025 static OMPMapClause *
6026 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
6027 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
6028 MappableExprComponentListsRef ComponentLists,
6029 ArrayRef<Expr *> UDMapperRefs, Expr *IteratorModifier,
6030 ArrayRef<OpenMPMapModifierKind> MapModifiers,
6031 ArrayRef<SourceLocation> MapModifiersLoc,
6032 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
6033 OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc);
6034
6035 /// Creates an empty clause with the place for \a NumVars original
6036 /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
6037 /// lists, and \a NumComponents expression components.
6038 ///
6039 /// \param C AST context.
6040 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6041 /// NumVars: number of expressions listed in this clause; 2)
6042 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6043 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6044 /// NumComponents: total number of expression components in the clause.
6045 static OMPMapClause *CreateEmpty(const ASTContext &C,
6046 const OMPMappableExprListSizeTy &Sizes);
6047
6048 /// Fetches Expr * of iterator modifier.
6050 return getTrailingObjects<Expr *>()[2 * varlist_size()];
6051 }
6052
6053 /// Fetches mapping kind for the clause.
6054 OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
6055
6056 /// Is this an implicit map type?
6057 /// We have to capture 'IsMapTypeImplicit' from the parser for more
6058 /// informative error messages. It helps distinguish map(r) from
6059 /// map(tofrom: r), which is important to print more helpful error
6060 /// messages for some target directives.
6061 bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
6062
6063 /// Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
6064 ///
6065 /// \param Cnt index for map-type-modifier.
6066 OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY {
6067 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6068 "Requested modifier exceeds the total number of modifiers.");
6069 return MapTypeModifiers[Cnt];
6070 }
6071
6072 /// Fetches the map-type-modifier location at 'Cnt' index of array of
6073 /// modifiers' locations.
6074 ///
6075 /// \param Cnt index for map-type-modifier location.
6076 SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY {
6077 assert(Cnt < NumberOfOMPMapClauseModifiers &&
6078 "Requested modifier location exceeds total number of modifiers.");
6079 return MapTypeModifiersLoc[Cnt];
6080 }
6081
6082 /// Fetches ArrayRef of map-type-modifiers.
6084 return llvm::ArrayRef(MapTypeModifiers);
6085 }
6086
6087 /// Fetches ArrayRef of location of map-type-modifiers.
6089 return llvm::ArrayRef(MapTypeModifiersLoc);
6090 }
6091
6092 /// Fetches location of clause mapping kind.
6093 SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
6094
6095 /// Get colon location.
6096 SourceLocation getColonLoc() const { return ColonLoc; }
6097
6099 return child_range(
6100 reinterpret_cast<Stmt **>(varlist_begin()),
6101 reinterpret_cast<Stmt **>(varlist_end()));
6102 }
6103
6105 auto Children = const_cast<OMPMapClause *>(this)->children();
6106 return const_child_range(Children.begin(), Children.end());
6107 }
6108
6110 if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom)
6111 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
6112 reinterpret_cast<Stmt **>(varlist_end()));
6114 }
6116 auto Children = const_cast<OMPMapClause *>(this)->used_children();
6117 return const_child_range(Children.begin(), Children.end());
6118 }
6119
6120
6121 static bool classof(const OMPClause *T) {
6122 return T->getClauseKind() == llvm::omp::OMPC_map;
6123 }
6124};
6125
6126/// This represents 'num_teams' clause in the '#pragma omp ...'
6127/// directive.
6128///
6129/// \code
6130/// #pragma omp teams num_teams(n)
6131/// \endcode
6132/// In this example directive '#pragma omp teams' has clause 'num_teams'
6133/// with single expression 'n'.
6135 friend class OMPClauseReader;
6136
6137 /// Location of '('.
6138 SourceLocation LParenLoc;
6139
6140 /// NumTeams number.
6141 Stmt *NumTeams = nullptr;
6142
6143 /// Set the NumTeams number.
6144 ///
6145 /// \param E NumTeams number.
6146 void setNumTeams(Expr *E) { NumTeams = E; }
6147
6148public:
6149 /// Build 'num_teams' clause.
6150 ///
6151 /// \param E Expression associated with this clause.
6152 /// \param HelperE Helper Expression associated with this clause.
6153 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6154 /// clause must be captured.
6155 /// \param StartLoc Starting location of the clause.
6156 /// \param LParenLoc Location of '('.
6157 /// \param EndLoc Ending location of the clause.
6158 OMPNumTeamsClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion,
6159 SourceLocation StartLoc, SourceLocation LParenLoc,
6160 SourceLocation EndLoc)
6161 : OMPClause(llvm::omp::OMPC_num_teams, StartLoc, EndLoc),
6162 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), NumTeams(E) {
6163 setPreInitStmt(HelperE, CaptureRegion);
6164 }
6165
6166 /// Build an empty clause.
6168 : OMPClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6169 SourceLocation()),
6170 OMPClauseWithPreInit(this) {}
6171
6172 /// Sets the location of '('.
6173 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6174
6175 /// Returns the location of '('.
6176 SourceLocation getLParenLoc() const { return LParenLoc; }
6177
6178 /// Return NumTeams number.
6179 Expr *getNumTeams() { return cast<Expr>(NumTeams); }
6180
6181 /// Return NumTeams number.
6182 Expr *getNumTeams() const { return cast<Expr>(NumTeams); }
6183
6184 child_range children() { return child_range(&NumTeams, &NumTeams + 1); }
6185
6187 return const_child_range(&NumTeams, &NumTeams + 1);
6188 }
6189
6192 }
6195 }
6196
6197 static bool classof(const OMPClause *T) {
6198 return T->getClauseKind() == llvm::omp::OMPC_num_teams;
6199 }
6200};
6201
6202/// This represents 'thread_limit' clause in the '#pragma omp ...'
6203/// directive.
6204///
6205/// \code
6206/// #pragma omp teams thread_limit(n)
6207/// \endcode
6208/// In this example directive '#pragma omp teams' has clause 'thread_limit'
6209/// with single expression 'n'.
6211 friend class OMPClauseReader;
6212
6213 /// Location of '('.
6214 SourceLocation LParenLoc;
6215
6216 /// ThreadLimit number.
6217 Stmt *ThreadLimit = nullptr;
6218
6219 /// Set the ThreadLimit number.
6220 ///
6221 /// \param E ThreadLimit number.
6222 void setThreadLimit(Expr *E) { ThreadLimit = E; }
6223
6224public:
6225 /// Build 'thread_limit' clause.
6226 ///
6227 /// \param E Expression associated with this clause.
6228 /// \param HelperE Helper Expression associated with this clause.
6229 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6230 /// clause must be captured.
6231 /// \param StartLoc Starting location of the clause.
6232 /// \param LParenLoc Location of '('.
6233 /// \param EndLoc Ending location of the clause.
6235 OpenMPDirectiveKind CaptureRegion,
6236 SourceLocation StartLoc, SourceLocation LParenLoc,
6237 SourceLocation EndLoc)
6238 : OMPClause(llvm::omp::OMPC_thread_limit, StartLoc, EndLoc),
6239 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadLimit(E) {
6240 setPreInitStmt(HelperE, CaptureRegion);
6241 }
6242
6243 /// Build an empty clause.
6245 : OMPClause(llvm::omp::OMPC_thread_limit, SourceLocation(),
6246 SourceLocation()),
6247 OMPClauseWithPreInit(this) {}
6248
6249 /// Sets the location of '('.
6250 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6251
6252 /// Returns the location of '('.
6253 SourceLocation getLParenLoc() const { return LParenLoc; }
6254
6255 /// Return ThreadLimit number.
6256 Expr *getThreadLimit() { return cast<Expr>(ThreadLimit); }
6257
6258 /// Return ThreadLimit number.
6259 Expr *getThreadLimit() const { return cast<Expr>(ThreadLimit); }
6260
6261 child_range children() { return child_range(&ThreadLimit, &ThreadLimit + 1); }
6262
6264 return const_child_range(&ThreadLimit, &ThreadLimit + 1);
6265 }
6266
6269 }
6272 }
6273
6274 static bool classof(const OMPClause *T) {
6275 return T->getClauseKind() == llvm::omp::OMPC_thread_limit;
6276 }
6277};
6278
6279/// This represents 'priority' clause in the '#pragma omp ...'
6280/// directive.
6281///
6282/// \code
6283/// #pragma omp task priority(n)
6284/// \endcode
6285/// In this example directive '#pragma omp teams' has clause 'priority' with
6286/// single expression 'n'.
6288 friend class OMPClauseReader;
6289
6290 /// Location of '('.
6291 SourceLocation LParenLoc;
6292
6293 /// Priority number.
6294 Stmt *Priority = nullptr;
6295
6296 /// Set the Priority number.
6297 ///
6298 /// \param E Priority number.
6299 void setPriority(Expr *E) { Priority = E; }
6300
6301public:
6302 /// Build 'priority' clause.
6303 ///
6304 /// \param Priority Expression associated with this clause.
6305 /// \param HelperPriority Helper priority for the construct.
6306 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6307 /// clause must be captured.
6308 /// \param StartLoc Starting location of the clause.
6309 /// \param LParenLoc Location of '('.
6310 /// \param EndLoc Ending location of the clause.
6312 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
6313 SourceLocation LParenLoc, SourceLocation EndLoc)
6314 : OMPClause(llvm::omp::OMPC_priority, StartLoc, EndLoc),
6315 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Priority(Priority) {
6316 setPreInitStmt(HelperPriority, CaptureRegion);
6317 }
6318
6319 /// Build an empty clause.
6321 : OMPClause(llvm::omp::OMPC_priority, SourceLocation(), SourceLocation()),
6322 OMPClauseWithPreInit(this) {}
6323
6324 /// Sets the location of '('.
6325 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6326
6327 /// Returns the location of '('.
6328 SourceLocation getLParenLoc() const { return LParenLoc; }
6329
6330 /// Return Priority number.
6331 Expr *getPriority() { return cast<Expr>(Priority); }
6332
6333 /// Return Priority number.
6334 Expr *getPriority() const { return cast<Expr>(Priority); }
6335
6337
6339 return const_child_range(&Priority, &Priority + 1);
6340 }
6341
6344 auto Children = const_cast<OMPPriorityClause *>(this)->used_children();
6345 return const_child_range(Children.begin(), Children.end());
6346 }
6347
6348 static bool classof(const OMPClause *T) {
6349 return T->getClauseKind() == llvm::omp::OMPC_priority;
6350 }
6351};
6352
6353/// This represents 'grainsize' clause in the '#pragma omp ...'
6354/// directive.
6355///
6356/// \code
6357/// #pragma omp taskloop grainsize(4)
6358/// \endcode
6359/// In this example directive '#pragma omp taskloop' has clause 'grainsize'
6360/// with single expression '4'.
6362 friend class OMPClauseReader;
6363
6364 /// Location of '('.
6365 SourceLocation LParenLoc;
6366
6367 /// Modifiers for 'grainsize' clause.
6369
6370 /// Location of the modifier.
6371 SourceLocation ModifierLoc;
6372
6373 /// Safe iteration space distance.
6374 Stmt *Grainsize = nullptr;
6375
6376 /// Set safelen.
6377 void setGrainsize(Expr *Size) { Grainsize = Size; }
6378
6379 /// Sets modifier.
6380 void setModifier(OpenMPGrainsizeClauseModifier M) { Modifier = M; }
6381
6382 /// Sets modifier location.
6383 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
6384
6385public:
6386 /// Build 'grainsize' clause.
6387 ///
6388 /// \param Modifier Clause modifier.
6389 /// \param Size Expression associated with this clause.
6390 /// \param HelperSize Helper grainsize for the construct.
6391 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6392 /// clause must be captured.
6393 /// \param StartLoc Starting location of the clause.
6394 /// \param ModifierLoc Modifier location.
6395 /// \param LParenLoc Location of '('.
6396 /// \param EndLoc Ending location of the clause.
6398 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
6399 SourceLocation StartLoc, SourceLocation LParenLoc,
6400 SourceLocation ModifierLoc, SourceLocation EndLoc)
6401 : OMPClause(llvm::omp::OMPC_grainsize, StartLoc, EndLoc),
6402 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
6403 ModifierLoc(ModifierLoc), Grainsize(Size) {
6404 setPreInitStmt(HelperSize, CaptureRegion);
6405 }
6406
6407 /// Build an empty clause.
6409 : OMPClause(llvm::omp::OMPC_grainsize, SourceLocation(),
6410 SourceLocation()),
6411 OMPClauseWithPreInit(this) {}
6412
6413 /// Sets the location of '('.
6414 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6415
6416 /// Returns the location of '('.
6417 SourceLocation getLParenLoc() const { return LParenLoc; }
6418
6419 /// Return safe iteration space distance.
6420 Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
6421
6422 /// Gets modifier.
6423 OpenMPGrainsizeClauseModifier getModifier() const { return Modifier; }
6424
6425 /// Gets modifier location.
6426 SourceLocation getModifierLoc() const { return ModifierLoc; }
6427
6428 child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
6429
6431 return const_child_range(&Grainsize, &Grainsize + 1);
6432 }
6433
6436 auto Children = const_cast<OMPGrainsizeClause *>(this)->used_children();
6437 return const_child_range(Children.begin(), Children.end());
6438 }
6439
6440 static bool classof(const OMPClause *T) {
6441 return T->getClauseKind() == llvm::omp::OMPC_grainsize;
6442 }
6443};
6444
6445/// This represents 'nogroup' clause in the '#pragma omp ...' directive.
6446///
6447/// \code
6448/// #pragma omp taskloop nogroup
6449/// \endcode
6450/// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
6452public:
6453 /// Build 'nogroup' clause.
6454 ///
6455 /// \param StartLoc Starting location of the clause.
6456 /// \param EndLoc Ending location of the clause.
6458 : OMPClause(llvm::omp::OMPC_nogroup, StartLoc, EndLoc) {}
6459
6460 /// Build an empty clause.
6462 : OMPClause(llvm::omp::OMPC_nogroup, SourceLocation(), SourceLocation()) {
6463 }
6464
6467 }
6468
6471 }
6472
6475 }
6478 }
6479
6480 static bool classof(const OMPClause *T) {
6481 return T->getClauseKind() == llvm::omp::OMPC_nogroup;
6482 }
6483};
6484
6485/// This represents 'num_tasks' clause in the '#pragma omp ...'
6486/// directive.
6487///
6488/// \code
6489/// #pragma omp taskloop num_tasks(4)
6490/// \endcode
6491/// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
6492/// with single expression '4'.
6494 friend class OMPClauseReader;
6495
6496 /// Location of '('.
6497 SourceLocation LParenLoc;
6498
6499 /// Modifiers for 'num_tasks' clause.
6501
6502 /// Location of the modifier.
6503 SourceLocation ModifierLoc;
6504
6505 /// Safe iteration space distance.
6506 Stmt *NumTasks = nullptr;
6507
6508 /// Set safelen.
6509 void setNumTasks(Expr *Size) { NumTasks = Size; }
6510
6511 /// Sets modifier.
6512 void setModifier(OpenMPNumTasksClauseModifier M) { Modifier = M; }
6513
6514 /// Sets modifier location.
6515 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
6516
6517public:
6518 /// Build 'num_tasks' clause.
6519 ///
6520 /// \param Modifier Clause modifier.
6521 /// \param Size Expression associated with this clause.
6522 /// \param HelperSize Helper grainsize for the construct.
6523 /// \param CaptureRegion Innermost OpenMP region where expressions in this
6524 /// clause must be captured.
6525 /// \param StartLoc Starting location of the clause.
6526 /// \param EndLoc Ending location of the clause.
6527 /// \param ModifierLoc Modifier location.
6528 /// \param LParenLoc Location of '('.
6530 Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion,
6531 SourceLocation StartLoc, SourceLocation LParenLoc,
6532 SourceLocation ModifierLoc, SourceLocation EndLoc)
6533 : OMPClause(llvm::omp::OMPC_num_tasks, StartLoc, EndLoc),
6534 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier),
6535 ModifierLoc(ModifierLoc), NumTasks(Size) {
6536 setPreInitStmt(HelperSize, CaptureRegion);
6537 }
6538
6539 /// Build an empty clause.
6541 : OMPClause(llvm::omp::OMPC_num_tasks, SourceLocation(),
6542 SourceLocation()),
6543 OMPClauseWithPreInit(this) {}
6544
6545 /// Sets the location of '('.
6546 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6547
6548 /// Returns the location of '('.
6549 SourceLocation getLParenLoc() const { return LParenLoc; }
6550
6551 /// Return safe iteration space distance.
6552 Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
6553
6554 /// Gets modifier.
6555 OpenMPNumTasksClauseModifier getModifier() const { return Modifier; }
6556
6557 /// Gets modifier location.
6558 SourceLocation getModifierLoc() const { return ModifierLoc; }
6559
6560 child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
6561
6563 return const_child_range(&NumTasks, &NumTasks + 1);
6564 }
6565
6568 auto Children = const_cast<OMPNumTasksClause *>(this)->used_children();
6569 return const_child_range(Children.begin(), Children.end());
6570 }
6571
6572 static bool classof(const OMPClause *T) {
6573 return T->getClauseKind() == llvm::omp::OMPC_num_tasks;
6574 }
6575};
6576
6577/// This represents 'hint' clause in the '#pragma omp ...' directive.
6578///
6579/// \code
6580/// #pragma omp critical (name) hint(6)
6581/// \endcode
6582/// In this example directive '#pragma omp critical' has name 'name' and clause
6583/// 'hint' with argument '6'.
6584class OMPHintClause : public OMPClause {
6585 friend class OMPClauseReader;
6586
6587 /// Location of '('.
6588 SourceLocation LParenLoc;
6589
6590 /// Hint expression of the 'hint' clause.
6591 Stmt *Hint = nullptr;
6592
6593 /// Set hint expression.
6594 void setHint(Expr *H) { Hint = H; }
6595
6596public:
6597 /// Build 'hint' clause with expression \a Hint.
6598 ///
6599 /// \param Hint Hint expression.
6600 /// \param StartLoc Starting location of the clause.
6601 /// \param LParenLoc Location of '('.
6602 /// \param EndLoc Ending location of the clause.
6604 SourceLocation EndLoc)
6605 : OMPClause(llvm::omp::OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
6606 Hint(Hint) {}
6607
6608 /// Build an empty clause.
6610 : OMPClause(llvm::omp::OMPC_hint, SourceLocation(), SourceLocation()) {}
6611
6612 /// Sets the location of '('.
6613 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6614
6615 /// Returns the location of '('.
6616 SourceLocation getLParenLoc() const { return LParenLoc; }
6617
6618 /// Returns number of threads.
6619 Expr *getHint() const { return cast_or_null<Expr>(Hint); }
6620
6621 child_range children() { return child_range(&Hint, &Hint + 1); }
6622
6624 return const_child_range(&Hint, &Hint + 1);
6625 }
6626
6629 }
6632 }
6633
6634 static bool classof(const OMPClause *T) {
6635 return T->getClauseKind() == llvm::omp::OMPC_hint;
6636 }
6637};
6638
6639/// This represents 'dist_schedule' clause in the '#pragma omp ...'
6640/// directive.
6641///
6642/// \code
6643/// #pragma omp distribute dist_schedule(static, 3)
6644/// \endcode
6645/// In this example directive '#pragma omp distribute' has 'dist_schedule'
6646/// clause with arguments 'static' and '3'.
6648 friend class OMPClauseReader;
6649
6650 /// Location of '('.
6651 SourceLocation LParenLoc;
6652
6653 /// A kind of the 'schedule' clause.
6655
6656 /// Start location of the schedule kind in source code.
6657 SourceLocation KindLoc;
6658
6659 /// Location of ',' (if any).
6660 SourceLocation CommaLoc;
6661
6662 /// Chunk size.
6663 Expr *ChunkSize = nullptr;
6664
6665 /// Set schedule kind.
6666 ///
6667 /// \param K Schedule kind.
6668 void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
6669
6670 /// Sets the location of '('.
6671 ///
6672 /// \param Loc Location of '('.
6673 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6674
6675 /// Set schedule kind start location.
6676 ///
6677 /// \param KLoc Schedule kind location.
6678 void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
6679
6680 /// Set location of ','.
6681 ///
6682 /// \param Loc Location of ','.
6683 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
6684
6685 /// Set chunk size.
6686 ///
6687 /// \param E Chunk size.
6688 void setChunkSize(Expr *E) { ChunkSize = E; }
6689
6690public:
6691 /// Build 'dist_schedule' clause with schedule kind \a Kind and chunk
6692 /// size expression \a ChunkSize.
6693 ///
6694 /// \param StartLoc Starting location of the clause.
6695 /// \param LParenLoc Location of '('.
6696 /// \param KLoc Starting location of the argument.
6697 /// \param CommaLoc Location of ','.
6698 /// \param EndLoc Ending location of the clause.
6699 /// \param Kind DistSchedule kind.
6700 /// \param ChunkSize Chunk size.
6701 /// \param HelperChunkSize Helper chunk size for combined directives.
6703 SourceLocation KLoc, SourceLocation CommaLoc,
6704 SourceLocation EndLoc,
6705 OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
6706 Stmt *HelperChunkSize)
6707 : OMPClause(llvm::omp::OMPC_dist_schedule, StartLoc, EndLoc),
6708 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
6709 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
6710 setPreInitStmt(HelperChunkSize);
6711 }
6712
6713 /// Build an empty clause.
6715 : OMPClause(llvm::omp::OMPC_dist_schedule, SourceLocation(),
6716 SourceLocation()),
6717 OMPClauseWithPreInit(this) {}
6718
6719 /// Get kind of the clause.
6721
6722 /// Get location of '('.
6723 SourceLocation getLParenLoc() { return LParenLoc; }
6724
6725 /// Get kind location.
6727
6728 /// Get location of ','.
6729 SourceLocation getCommaLoc() { return CommaLoc; }
6730
6731 /// Get chunk size.
6732 Expr *getChunkSize() { return ChunkSize; }
6733
6734 /// Get chunk size.
6735 const Expr *getChunkSize() const { return ChunkSize; }
6736
6738 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
6739 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
6740 }
6741
6743 auto Children = const_cast<OMPDistScheduleClause *>(this)->children();
6744 return const_child_range(Children.begin(), Children.end());
6745 }
6746
6749 }
6752 }
6753
6754 static bool classof(const OMPClause *T) {
6755 return T->getClauseKind() == llvm::omp::OMPC_dist_schedule;
6756 }
6757};
6758
6759/// This represents 'defaultmap' clause in the '#pragma omp ...' directive.
6760///
6761/// \code
6762/// #pragma omp target defaultmap(tofrom: scalar)
6763/// \endcode
6764/// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
6765/// 'scalar' with modifier 'tofrom'.
6767 friend class OMPClauseReader;
6768
6769 /// Location of '('.
6770 SourceLocation LParenLoc;
6771
6772 /// Modifiers for 'defaultmap' clause.
6774
6775 /// Locations of modifiers.
6776 SourceLocation ModifierLoc;
6777
6778 /// A kind of the 'defaultmap' clause.
6780
6781 /// Start location of the defaultmap kind in source code.
6782 SourceLocation KindLoc;
6783
6784 /// Set defaultmap kind.
6785 ///
6786 /// \param K Defaultmap kind.
6787 void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
6788
6789 /// Set the defaultmap modifier.
6790 ///
6791 /// \param M Defaultmap modifier.
6792 void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
6793 Modifier = M;
6794 }
6795
6796 /// Set location of the defaultmap modifier.
6797 void setDefaultmapModifierLoc(SourceLocation Loc) {
6798 ModifierLoc = Loc;
6799 }
6800
6801 /// Sets the location of '('.
6802 ///
6803 /// \param Loc Location of '('.
6804 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
6805
6806 /// Set defaultmap kind start location.
6807 ///
6808 /// \param KLoc Defaultmap kind location.
6809 void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
6810
6811public:
6812 /// Build 'defaultmap' clause with defaultmap kind \a Kind
6813 ///
6814 /// \param StartLoc Starting location of the clause.
6815 /// \param LParenLoc Location of '('.
6816 /// \param KLoc Starting location of the argument.
6817 /// \param EndLoc Ending location of the clause.
6818 /// \param Kind Defaultmap kind.
6819 /// \param M The modifier applied to 'defaultmap' clause.
6820 /// \param MLoc Location of the modifier
6822 SourceLocation MLoc, SourceLocation KLoc,
6825 : OMPClause(llvm::omp::OMPC_defaultmap, StartLoc, EndLoc),
6826 LParenLoc(LParenLoc), Modifier(M), ModifierLoc(MLoc), Kind(Kind),
6827 KindLoc(KLoc) {}
6828
6829 /// Build an empty clause.
6831 : OMPClause(llvm::omp::OMPC_defaultmap, SourceLocation(),
6832 SourceLocation()) {}
6833
6834 /// Get kind of the clause.
6836
6837 /// Get the modifier of the clause.
6839 return Modifier;
6840 }
6841
6842 /// Get location of '('.
6843 SourceLocation getLParenLoc() { return LParenLoc; }
6844
6845 /// Get kind location.
6847
6848 /// Get the modifier location.
6850 return ModifierLoc;
6851 }
6852
6855 }
6856
6859 }
6860
6863 }
6866 }
6867
6868 static bool classof(const OMPClause *T) {
6869 return T->getClauseKind() == llvm::omp::OMPC_defaultmap;
6870 }
6871};
6872
6873/// This represents clause 'to' in the '#pragma omp ...'
6874/// directives.
6875///
6876/// \code
6877/// #pragma omp target update to(a,b)
6878/// \endcode
6879/// In this example directive '#pragma omp target update' has clause 'to'
6880/// with the variables 'a' and 'b'.
6881class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
6882 private llvm::TrailingObjects<
6883 OMPToClause, Expr *, ValueDecl *, unsigned,
6884 OMPClauseMappableExprCommon::MappableComponent> {
6885 friend class OMPClauseReader;
6887 friend OMPVarListClause;
6888 friend TrailingObjects;
6889
6890 /// Motion-modifiers for the 'to' clause.
6893
6894 /// Location of motion-modifiers for the 'to' clause.
6895 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
6896
6897 /// Colon location.
6898 SourceLocation ColonLoc;
6899
6900 /// Build clause with number of variables \a NumVars.
6901 ///
6902 /// \param TheMotionModifiers Motion-modifiers.
6903 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
6904 /// \param MapperQualifierLoc C++ nested name specifier for the associated
6905 /// user-defined mapper.
6906 /// \param MapperIdInfo The identifier of associated user-defined mapper.
6907 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6908 /// StartLoc: starting location of the clause (the clause keyword); 2)
6909 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6910 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6911 /// NumVars: number of expressions listed in this clause; 2)
6912 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6913 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6914 /// NumComponents: total number of expression components in the clause.
6915 explicit OMPToClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
6916 ArrayRef<SourceLocation> TheMotionModifiersLoc,
6917 NestedNameSpecifierLoc MapperQualifierLoc,
6918 DeclarationNameInfo MapperIdInfo,
6919 const OMPVarListLocTy &Locs,
6920 const OMPMappableExprListSizeTy &Sizes)
6921 : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
6922 /*SupportsMapper=*/true, &MapperQualifierLoc,
6923 &MapperIdInfo) {
6924 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
6925 "Unexpected number of motion modifiers.");
6926 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
6927
6928 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
6929 "Unexpected number of motion modifier locations.");
6930 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
6931 }
6932
6933 /// Build an empty clause.
6934 ///
6935 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
6936 /// NumVars: number of expressions listed in this clause; 2)
6937 /// NumUniqueDeclarations: number of unique base declarations in this clause;
6938 /// 3) NumComponentLists: number of component lists in this clause; and 4)
6939 /// NumComponents: total number of expression components in the clause.
6940 explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes)
6941 : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
6942 /*SupportsMapper=*/true) {}
6943
6944 /// Set motion-modifier for the clause.
6945 ///
6946 /// \param I index for motion-modifier.
6947 /// \param T motion-modifier for the clause.
6948 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
6949 assert(I < NumberOfOMPMotionModifiers &&
6950 "Unexpected index to store motion modifier, exceeds array size.");
6951 MotionModifiers[I] = T;
6952 }
6953
6954 /// Set location for the motion-modifier.
6955 ///
6956 /// \param I index for motion-modifier location.
6957 /// \param TLoc motion-modifier location.
6958 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
6959 assert(I < NumberOfOMPMotionModifiers &&
6960 "Index to store motion modifier location exceeds array size.");
6961 MotionModifiersLoc[I] = TLoc;
6962 }
6963
6964 /// Set colon location.
6965 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
6966
6967 /// Define the sizes of each trailing object array except the last one. This
6968 /// is required for TrailingObjects to work properly.
6969 size_t numTrailingObjects(OverloadToken<Expr *>) const {
6970 // There are varlist_size() of expressions, and varlist_size() of
6971 // user-defined mappers.
6972 return 2 * varlist_size();
6973 }
6974 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
6975 return getUniqueDeclarationsNum();
6976 }
6977 size_t numTrailingObjects(OverloadToken<unsigned>) const {
6979 }
6980
6981public:
6982 /// Creates clause with a list of variables \a Vars.
6983 ///
6984 /// \param C AST context.
6985 /// \param Locs Locations needed to build a mappable clause. It includes 1)
6986 /// StartLoc: starting location of the clause (the clause keyword); 2)
6987 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
6988 /// \param Vars The original expression used in the clause.
6989 /// \param Declarations Declarations used in the clause.
6990 /// \param ComponentLists Component lists used in the clause.
6991 /// \param MotionModifiers Motion-modifiers.
6992 /// \param MotionModifiersLoc Location of motion-modifiers.
6993 /// \param UDMapperRefs References to user-defined mappers associated with
6994 /// expressions used in the clause.
6995 /// \param UDMQualifierLoc C++ nested name specifier for the associated
6996 /// user-defined mapper.
6997 /// \param MapperId The identifier of associated user-defined mapper.
6998 static OMPToClause *Create(const ASTContext &C, const OMPVarListLocTy &Locs,
6999 ArrayRef<Expr *> Vars,
7000 ArrayRef<ValueDecl *> Declarations,
7001 MappableExprComponentListsRef ComponentLists,
7002 ArrayRef<Expr *> UDMapperRefs,
7003 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7004 ArrayRef<SourceLocation> MotionModifiersLoc,
7005 NestedNameSpecifierLoc UDMQualifierLoc,
7006 DeclarationNameInfo MapperId);
7007
7008 /// Creates an empty clause with the place for \a NumVars variables.
7009 ///
7010 /// \param C AST context.
7011 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7012 /// NumVars: number of expressions listed in this clause; 2)
7013 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7014 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7015 /// NumComponents: total number of expression components in the clause.
7016 static OMPToClause *CreateEmpty(const ASTContext &C,
7017 const OMPMappableExprListSizeTy &Sizes);
7018
7019 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7020 ///
7021 /// \param Cnt index for motion-modifier.
7022 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7023 assert(Cnt < NumberOfOMPMotionModifiers &&
7024 "Requested modifier exceeds the total number of modifiers.");
7025 return MotionModifiers[Cnt];
7026 }
7027
7028 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7029 /// locations.
7030 ///
7031 /// \param Cnt index for motion-modifier location.
7032 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7033 assert(Cnt < NumberOfOMPMotionModifiers &&
7034 "Requested modifier location exceeds total number of modifiers.");
7035 return MotionModifiersLoc[Cnt];
7036 }
7037
7038 /// Fetches ArrayRef of motion-modifiers.
7040 return llvm::ArrayRef(MotionModifiers);
7041 }
7042
7043 /// Fetches ArrayRef of location of motion-modifiers.
7045 return llvm::ArrayRef(MotionModifiersLoc);
7046 }
7047
7048 /// Get colon location.
7049 SourceLocation getColonLoc() const { return ColonLoc; }
7050
7052 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7053 reinterpret_cast<Stmt **>(varlist_end()));
7054 }
7055
7057 auto Children = const_cast<OMPToClause *>(this)->children();
7058 return const_child_range(Children.begin(), Children.end());
7059 }
7060
7063 }
7066 }
7067
7068 static bool classof(const OMPClause *T) {
7069 return T->getClauseKind() == llvm::omp::OMPC_to;
7070 }
7071};
7072
7073/// This represents clause 'from' in the '#pragma omp ...'
7074/// directives.
7075///
7076/// \code
7077/// #pragma omp target update from(a,b)
7078/// \endcode
7079/// In this example directive '#pragma omp target update' has clause 'from'
7080/// with the variables 'a' and 'b'.
7081class OMPFromClause final
7082 : public OMPMappableExprListClause<OMPFromClause>,
7083 private llvm::TrailingObjects<
7084 OMPFromClause, Expr *, ValueDecl *, unsigned,
7085 OMPClauseMappableExprCommon::MappableComponent> {
7086 friend class OMPClauseReader;
7088 friend OMPVarListClause;
7089 friend TrailingObjects;
7090
7091 /// Motion-modifiers for the 'from' clause.
7094
7095 /// Location of motion-modifiers for the 'from' clause.
7096 SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
7097
7098 /// Colon location.
7099 SourceLocation ColonLoc;
7100
7101 /// Build clause with number of variables \a NumVars.
7102 ///
7103 /// \param TheMotionModifiers Motion-modifiers.
7104 /// \param TheMotionModifiersLoc Locations of motion-modifiers.
7105 /// \param MapperQualifierLoc C++ nested name specifier for the associated
7106 /// user-defined mapper.
7107 /// \param MapperIdInfo The identifier of associated user-defined mapper.
7108 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7109 /// StartLoc: starting location of the clause (the clause keyword); 2)
7110 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7111 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7112 /// NumVars: number of expressions listed in this clause; 2)
7113 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7114 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7115 /// NumComponents: total number of expression components in the clause.
7116 explicit OMPFromClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers,
7117 ArrayRef<SourceLocation> TheMotionModifiersLoc,
7118 NestedNameSpecifierLoc MapperQualifierLoc,
7119 DeclarationNameInfo MapperIdInfo,
7120 const OMPVarListLocTy &Locs,
7121 const OMPMappableExprListSizeTy &Sizes)
7122 : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes,
7123 /*SupportsMapper=*/true, &MapperQualifierLoc,
7124 &MapperIdInfo) {
7125 assert(std::size(MotionModifiers) == TheMotionModifiers.size() &&
7126 "Unexpected number of motion modifiers.");
7127 llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
7128
7129 assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() &&
7130 "Unexpected number of motion modifier locations.");
7131 llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
7132 }
7133
7134 /// Build an empty clause.
7135 ///
7136 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7137 /// NumVars: number of expressions listed in this clause; 2)
7138 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7139 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7140 /// NumComponents: total number of expression components in the clause.
7141 explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes)
7142 : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(),
7143 Sizes, /*SupportsMapper=*/true) {}
7144
7145 /// Set motion-modifier for the clause.
7146 ///
7147 /// \param I index for motion-modifier.
7148 /// \param T motion-modifier for the clause.
7149 void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
7150 assert(I < NumberOfOMPMotionModifiers &&
7151 "Unexpected index to store motion modifier, exceeds array size.");
7152 MotionModifiers[I] = T;
7153 }
7154
7155 /// Set location for the motion-modifier.
7156 ///
7157 /// \param I index for motion-modifier location.
7158 /// \param TLoc motion-modifier location.
7159 void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
7160 assert(I < NumberOfOMPMotionModifiers &&
7161 "Index to store motion modifier location exceeds array size.");
7162 MotionModifiersLoc[I] = TLoc;
7163 }
7164
7165 /// Set colon location.
7166 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
7167
7168 /// Define the sizes of each trailing object array except the last one. This
7169 /// is required for TrailingObjects to work properly.
7170 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7171 // There are varlist_size() of expressions, and varlist_size() of
7172 // user-defined mappers.
7173 return 2 * varlist_size();
7174 }
7175 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7176 return getUniqueDeclarationsNum();
7177 }
7178 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7180 }
7181
7182public:
7183 /// Creates clause with a list of variables \a Vars.
7184 ///
7185 /// \param C AST context.
7186 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7187 /// StartLoc: starting location of the clause (the clause keyword); 2)
7188 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7189 /// \param Vars The original expression used in the clause.
7190 /// \param Declarations Declarations used in the clause.
7191 /// \param ComponentLists Component lists used in the clause.
7192 /// \param MotionModifiers Motion-modifiers.
7193 /// \param MotionModifiersLoc Location of motion-modifiers.
7194 /// \param UDMapperRefs References to user-defined mappers associated with
7195 /// expressions used in the clause.
7196 /// \param UDMQualifierLoc C++ nested name specifier for the associated
7197 /// user-defined mapper.
7198 /// \param MapperId The identifier of associated user-defined mapper.
7199 static OMPFromClause *
7200 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7201 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7202 MappableExprComponentListsRef ComponentLists,
7203 ArrayRef<Expr *> UDMapperRefs,
7204 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
7205 ArrayRef<SourceLocation> MotionModifiersLoc,
7206 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId);
7207
7208 /// Creates an empty clause with the place for \a NumVars variables.
7209 ///
7210 /// \param C AST context.
7211 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7212 /// NumVars: number of expressions listed in this clause; 2)
7213 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7214 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7215 /// NumComponents: total number of expression components in the clause.
7216 static OMPFromClause *CreateEmpty(const ASTContext &C,
7217 const OMPMappableExprListSizeTy &Sizes);
7218
7219 /// Fetches the motion-modifier at 'Cnt' index of array of modifiers.
7220 ///
7221 /// \param Cnt index for motion-modifier.
7222 OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY {
7223 assert(Cnt < NumberOfOMPMotionModifiers &&
7224 "Requested modifier exceeds the total number of modifiers.");
7225 return MotionModifiers[Cnt];
7226 }
7227
7228 /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers'
7229 /// locations.
7230 ///
7231 /// \param Cnt index for motion-modifier location.
7232 SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY {
7233 assert(Cnt < NumberOfOMPMotionModifiers &&
7234 "Requested modifier location exceeds total number of modifiers.");
7235 return MotionModifiersLoc[Cnt];
7236 }
7237
7238 /// Fetches ArrayRef of motion-modifiers.
7240 return llvm::ArrayRef(MotionModifiers);
7241 }
7242
7243 /// Fetches ArrayRef of location of motion-modifiers.
7245 return llvm::ArrayRef(MotionModifiersLoc);
7246 }
7247
7248 /// Get colon location.
7249 SourceLocation getColonLoc() const { return ColonLoc; }
7250
7252 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7253 reinterpret_cast<Stmt **>(varlist_end()));
7254 }
7255
7257 auto Children = const_cast<OMPFromClause *>(this)->children();
7258 return const_child_range(Children.begin(), Children.end());
7259 }
7260
7263 }
7266 }
7267
7268 static bool classof(const OMPClause *T) {
7269 return T->getClauseKind() == llvm::omp::OMPC_from;
7270 }
7271};
7272
7273/// This represents clause 'use_device_ptr' in the '#pragma omp ...'
7274/// directives.
7275///
7276/// \code
7277/// #pragma omp target data use_device_ptr(a,b)
7278/// \endcode
7279/// In this example directive '#pragma omp target data' has clause
7280/// 'use_device_ptr' with the variables 'a' and 'b'.
7282 : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
7283 private llvm::TrailingObjects<
7284 OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
7285 OMPClauseMappableExprCommon::MappableComponent> {
7286 friend class OMPClauseReader;
7288 friend OMPVarListClause;
7289 friend TrailingObjects;
7290
7291 /// Build clause with number of variables \a NumVars.
7292 ///
7293 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7294 /// StartLoc: starting location of the clause (the clause keyword); 2)
7295 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7296 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7297 /// NumVars: number of expressions listed in this clause; 2)
7298 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7299 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7300 /// NumComponents: total number of expression components in the clause.
7301 explicit OMPUseDevicePtrClause(const OMPVarListLocTy &Locs,
7302 const OMPMappableExprListSizeTy &Sizes)
7303 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr, Locs, Sizes) {
7304 }
7305
7306 /// Build an empty clause.
7307 ///
7308 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7309 /// NumVars: number of expressions listed in this clause; 2)
7310 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7311 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7312 /// NumComponents: total number of expression components in the clause.
7314 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr,
7315 OMPVarListLocTy(), Sizes) {}
7316
7317 /// Define the sizes of each trailing object array except the last one. This
7318 /// is required for TrailingObjects to work properly.
7319 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7320 return 3 * varlist_size();
7321 }
7322 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7323 return getUniqueDeclarationsNum();
7324 }
7325 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7327 }
7328
7329 /// Sets the list of references to private copies with initializers for new
7330 /// private variables.
7331 /// \param VL List of references.
7332 void setPrivateCopies(ArrayRef<Expr *> VL);
7333
7334 /// Gets the list of references to private copies with initializers for new
7335 /// private variables.
7336 MutableArrayRef<Expr *> getPrivateCopies() {
7337 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
7338 }
7339 ArrayRef<const Expr *> getPrivateCopies() const {
7341 }
7342
7343 /// Sets the list of references to initializer variables for new private
7344 /// variables.
7345 /// \param VL List of references.
7346 void setInits(ArrayRef<Expr *> VL);
7347
7348 /// Gets the list of references to initializer variables for new private
7349 /// variables.
7350 MutableArrayRef<Expr *> getInits() {
7351 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
7352 }
7353 ArrayRef<const Expr *> getInits() const {
7354 return llvm::ArrayRef(getPrivateCopies().end(), varlist_size());
7355 }
7356
7357public:
7358 /// Creates clause with a list of variables \a Vars.
7359 ///
7360 /// \param C AST context.
7361 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7362 /// StartLoc: starting location of the clause (the clause keyword); 2)
7363 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7364 /// \param Vars The original expression used in the clause.
7365 /// \param PrivateVars Expressions referring to private copies.
7366 /// \param Inits Expressions referring to private copy initializers.
7367 /// \param Declarations Declarations used in the clause.
7368 /// \param ComponentLists Component lists used in the clause.
7369 static OMPUseDevicePtrClause *
7370 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7371 ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
7372 ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
7373 MappableExprComponentListsRef ComponentLists);
7374
7375 /// Creates an empty clause with the place for \a NumVars variables.
7376 ///
7377 /// \param C AST context.
7378 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7379 /// NumVars: number of expressions listed in this clause; 2)
7380 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7381 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7382 /// NumComponents: total number of expression components in the clause.
7383 static OMPUseDevicePtrClause *
7384 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7385
7388 using private_copies_range = llvm::iterator_range<private_copies_iterator>;
7390 llvm::iterator_range<private_copies_const_iterator>;
7391
7393 return private_copies_range(getPrivateCopies().begin(),
7394 getPrivateCopies().end());
7395 }
7396
7398 return private_copies_const_range(getPrivateCopies().begin(),
7399 getPrivateCopies().end());
7400 }
7401
7404 using inits_range = llvm::iterator_range<inits_iterator>;
7405 using inits_const_range = llvm::iterator_range<inits_const_iterator>;
7406
7408 return inits_range(getInits().begin(), getInits().end());
7409 }
7410
7412 return inits_const_range(getInits().begin(), getInits().end());
7413 }
7414
7416 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7417 reinterpret_cast<Stmt **>(varlist_end()));
7418 }
7419
7421 auto Children = const_cast<OMPUseDevicePtrClause *>(this)->children();
7422 return const_child_range(Children.begin(), Children.end());
7423 }
7424
7427 }
7430 }
7431
7432 static bool classof(const OMPClause *T) {
7433 return T->getClauseKind() == llvm::omp::OMPC_use_device_ptr;
7434 }
7435};
7436
7437/// This represents clause 'use_device_addr' in the '#pragma omp ...'
7438/// directives.
7439///
7440/// \code
7441/// #pragma omp target data use_device_addr(a,b)
7442/// \endcode
7443/// In this example directive '#pragma omp target data' has clause
7444/// 'use_device_addr' with the variables 'a' and 'b'.
7446 : public OMPMappableExprListClause<OMPUseDeviceAddrClause>,
7447 private llvm::TrailingObjects<
7448 OMPUseDeviceAddrClause, Expr *, ValueDecl *, unsigned,
7449 OMPClauseMappableExprCommon::MappableComponent> {
7450 friend class OMPClauseReader;
7452 friend OMPVarListClause;
7453 friend TrailingObjects;
7454
7455 /// Build clause with number of variables \a NumVars.
7456 ///
7457 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7458 /// StartLoc: starting location of the clause (the clause keyword); 2)
7459 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7460 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7461 /// NumVars: number of expressions listed in this clause; 2)
7462 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7463 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7464 /// NumComponents: total number of expression components in the clause.
7465 explicit OMPUseDeviceAddrClause(const OMPVarListLocTy &Locs,
7466 const OMPMappableExprListSizeTy &Sizes)
7467 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr, Locs,
7468 Sizes) {}
7469
7470 /// Build an empty clause.
7471 ///
7472 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7473 /// NumVars: number of expressions listed in this clause; 2)
7474 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7475 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7476 /// NumComponents: total number of expression components in the clause.
7478 : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr,
7479 OMPVarListLocTy(), Sizes) {}
7480
7481 /// Define the sizes of each trailing object array except the last one. This
7482 /// is required for TrailingObjects to work properly.
7483 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7484 return varlist_size();
7485 }
7486 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7487 return getUniqueDeclarationsNum();
7488 }
7489 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7491 }
7492
7493public:
7494 /// Creates clause with a list of variables \a Vars.
7495 ///
7496 /// \param C AST context.
7497 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7498 /// StartLoc: starting location of the clause (the clause keyword); 2)
7499 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7500 /// \param Vars The original expression used in the clause.
7501 /// \param Declarations Declarations used in the clause.
7502 /// \param ComponentLists Component lists used in the clause.
7503 static OMPUseDeviceAddrClause *
7504 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7505 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7506 MappableExprComponentListsRef ComponentLists);
7507
7508 /// Creates an empty clause with the place for \a NumVars variables.
7509 ///
7510 /// \param C AST context.
7511 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7512 /// NumVars: number of expressions listed in this clause; 2)
7513 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7514 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7515 /// NumComponents: total number of expression components in the clause.
7516 static OMPUseDeviceAddrClause *
7517 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7518
7520 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7521 reinterpret_cast<Stmt **>(varlist_end()));
7522 }
7523
7525 auto Children = const_cast<OMPUseDeviceAddrClause *>(this)->children();
7526 return const_child_range(Children.begin(), Children.end());
7527 }
7528
7531 }
7534 }
7535
7536 static bool classof(const OMPClause *T) {
7537 return T->getClauseKind() == llvm::omp::OMPC_use_device_addr;
7538 }
7539};
7540
7541/// This represents clause 'is_device_ptr' in the '#pragma omp ...'
7542/// directives.
7543///
7544/// \code
7545/// #pragma omp target is_device_ptr(a,b)
7546/// \endcode
7547/// In this example directive '#pragma omp target' has clause
7548/// 'is_device_ptr' with the variables 'a' and 'b'.
7550 : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
7551 private llvm::TrailingObjects<
7552 OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
7553 OMPClauseMappableExprCommon::MappableComponent> {
7554 friend class OMPClauseReader;
7556 friend OMPVarListClause;
7557 friend TrailingObjects;
7558
7559 /// Build clause with number of variables \a NumVars.
7560 ///
7561 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7562 /// StartLoc: starting location of the clause (the clause keyword); 2)
7563 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7564 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7565 /// NumVars: number of expressions listed in this clause; 2)
7566 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7567 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7568 /// NumComponents: total number of expression components in the clause.
7569 explicit OMPIsDevicePtrClause(const OMPVarListLocTy &Locs,
7570 const OMPMappableExprListSizeTy &Sizes)
7571 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr, Locs, Sizes) {}
7572
7573 /// Build an empty clause.
7574 ///
7575 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7576 /// NumVars: number of expressions listed in this clause; 2)
7577 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7578 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7579 /// NumComponents: total number of expression components in the clause.
7580 explicit OMPIsDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
7581 : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr,
7582 OMPVarListLocTy(), Sizes) {}
7583
7584 /// Define the sizes of each trailing object array except the last one. This
7585 /// is required for TrailingObjects to work properly.
7586 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7587 return varlist_size();
7588 }
7589 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7590 return getUniqueDeclarationsNum();
7591 }
7592 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7594 }
7595
7596public:
7597 /// Creates clause with a list of variables \a Vars.
7598 ///
7599 /// \param C AST context.
7600 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7601 /// StartLoc: starting location of the clause (the clause keyword); 2)
7602 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7603 /// \param Vars The original expression used in the clause.
7604 /// \param Declarations Declarations used in the clause.
7605 /// \param ComponentLists Component lists used in the clause.
7606 static OMPIsDevicePtrClause *
7607 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7608 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7609 MappableExprComponentListsRef ComponentLists);
7610
7611 /// Creates an empty clause with the place for \a NumVars variables.
7612 ///
7613 /// \param C AST context.
7614 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7615 /// NumVars: number of expressions listed in this clause; 2)
7616 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7617 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7618 /// NumComponents: total number of expression components in the clause.
7619 static OMPIsDevicePtrClause *
7620 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7621
7623 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7624 reinterpret_cast<Stmt **>(varlist_end()));
7625 }
7626
7628 auto Children = const_cast<OMPIsDevicePtrClause *>(this)->children();
7629 return const_child_range(Children.begin(), Children.end());
7630 }
7631
7634 }
7637 }
7638
7639 static bool classof(const OMPClause *T) {
7640 return T->getClauseKind() == llvm::omp::OMPC_is_device_ptr;
7641 }
7642};
7643
7644/// This represents clause 'has_device_ptr' in the '#pragma omp ...'
7645/// directives.
7646///
7647/// \code
7648/// #pragma omp target has_device_addr(a,b)
7649/// \endcode
7650/// In this example directive '#pragma omp target' has clause
7651/// 'has_device_ptr' with the variables 'a' and 'b'.
7653 : public OMPMappableExprListClause<OMPHasDeviceAddrClause>,
7654 private llvm::TrailingObjects<
7655 OMPHasDeviceAddrClause, Expr *, ValueDecl *, unsigned,
7656 OMPClauseMappableExprCommon::MappableComponent> {
7657 friend class OMPClauseReader;
7659 friend OMPVarListClause;
7660 friend TrailingObjects;
7661
7662 /// Build clause with number of variables \a NumVars.
7663 ///
7664 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7665 /// StartLoc: starting location of the clause (the clause keyword); 2)
7666 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7667 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7668 /// NumVars: number of expressions listed in this clause; 2)
7669 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7670 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7671 /// NumComponents: total number of expression components in the clause.
7672 explicit OMPHasDeviceAddrClause(const OMPVarListLocTy &Locs,
7673 const OMPMappableExprListSizeTy &Sizes)
7674 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, Locs,
7675 Sizes) {}
7676
7677 /// Build an empty clause.
7678 ///
7679 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7680 /// NumVars: number of expressions listed in this clause; 2)
7681 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7682 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7683 /// NumComponents: total number of expression components in the clause.
7685 : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr,
7686 OMPVarListLocTy(), Sizes) {}
7687
7688 /// Define the sizes of each trailing object array except the last one. This
7689 /// is required for TrailingObjects to work properly.
7690 size_t numTrailingObjects(OverloadToken<Expr *>) const {
7691 return varlist_size();
7692 }
7693 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
7694 return getUniqueDeclarationsNum();
7695 }
7696 size_t numTrailingObjects(OverloadToken<unsigned>) const {
7698 }
7699
7700public:
7701 /// Creates clause with a list of variables \a Vars.
7702 ///
7703 /// \param C AST context.
7704 /// \param Locs Locations needed to build a mappable clause. It includes 1)
7705 /// StartLoc: starting location of the clause (the clause keyword); 2)
7706 /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
7707 /// \param Vars The original expression used in the clause.
7708 /// \param Declarations Declarations used in the clause.
7709 /// \param ComponentLists Component lists used in the clause.
7710 static OMPHasDeviceAddrClause *
7711 Create(const ASTContext &C, const OMPVarListLocTy &Locs,
7712 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
7713 MappableExprComponentListsRef ComponentLists);
7714
7715 /// Creates an empty clause with the place for \a NumVars variables.
7716 ///
7717 /// \param C AST context.
7718 /// \param Sizes All required sizes to build a mappable clause. It includes 1)
7719 /// NumVars: number of expressions listed in this clause; 2)
7720 /// NumUniqueDeclarations: number of unique base declarations in this clause;
7721 /// 3) NumComponentLists: number of component lists in this clause; and 4)
7722 /// NumComponents: total number of expression components in the clause.
7723 static OMPHasDeviceAddrClause *
7724 CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes);
7725
7727 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7728 reinterpret_cast<Stmt **>(varlist_end()));
7729 }
7730
7732 auto Children = const_cast<OMPHasDeviceAddrClause *>(this)->children();
7733 return const_child_range(Children.begin(), Children.end());
7734 }
7735
7738 }
7741 }
7742
7743 static bool classof(const OMPClause *T) {
7744 return T->getClauseKind() == llvm::omp::OMPC_has_device_addr;
7745 }
7746};
7747
7748/// This represents clause 'nontemporal' in the '#pragma omp ...' directives.
7749///
7750/// \code
7751/// #pragma omp simd nontemporal(a)
7752/// \endcode
7753/// In this example directive '#pragma omp simd' has clause 'nontemporal' for
7754/// the variable 'a'.
7756 : public OMPVarListClause<OMPNontemporalClause>,
7757 private llvm::TrailingObjects<OMPNontemporalClause, Expr *> {
7758 friend class OMPClauseReader;
7759 friend OMPVarListClause;
7760 friend TrailingObjects;
7761
7762 /// Build clause with number of variables \a N.
7763 ///
7764 /// \param StartLoc Starting location of the clause.
7765 /// \param LParenLoc Location of '('.
7766 /// \param EndLoc Ending location of the clause.
7767 /// \param N Number of the variables in the clause.
7769 SourceLocation EndLoc, unsigned N)
7770 : OMPVarListClause<OMPNontemporalClause>(llvm::omp::OMPC_nontemporal,
7771 StartLoc, LParenLoc, EndLoc, N) {
7772 }
7773
7774 /// Build an empty clause.
7775 ///
7776 /// \param N Number of variables.
7777 explicit OMPNontemporalClause(unsigned N)
7779 llvm::omp::OMPC_nontemporal, SourceLocation(), SourceLocation(),
7780 SourceLocation(), N) {}
7781
7782 /// Get the list of privatied copies if the member expression was captured by
7783 /// one of the privatization clauses.
7784 MutableArrayRef<Expr *> getPrivateRefs() {
7785 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
7786 }
7787 ArrayRef<const Expr *> getPrivateRefs() const {
7789 }
7790
7791public:
7792 /// Creates clause with a list of variables \a VL.
7793 ///
7794 /// \param C AST context.
7795 /// \param StartLoc Starting location of the clause.
7796 /// \param LParenLoc Location of '('.
7797 /// \param EndLoc Ending location of the clause.
7798 /// \param VL List of references to the variables.
7799 static OMPNontemporalClause *
7800 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
7801 SourceLocation EndLoc, ArrayRef<Expr *> VL);
7802
7803 /// Creates an empty clause with the place for \a N variables.
7804 ///
7805 /// \param C AST context.
7806 /// \param N The number of variables.
7807 static OMPNontemporalClause *CreateEmpty(const ASTContext &C, unsigned N);
7808
7809 /// Sets the list of references to private copies created in private clauses.
7810 /// \param VL List of references.
7811 void setPrivateRefs(ArrayRef<Expr *> VL);
7812
7814 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7815 reinterpret_cast<Stmt **>(varlist_end()));
7816 }
7817
7819 auto Children = const_cast<OMPNontemporalClause *>(this)->children();
7820 return const_child_range(Children.begin(), Children.end());
7821 }
7822
7824 return child_range(reinterpret_cast<Stmt **>(getPrivateRefs().begin()),
7825 reinterpret_cast<Stmt **>(getPrivateRefs().end()));
7826 }
7827
7829 auto Children = const_cast<OMPNontemporalClause *>(this)->private_refs();
7830 return const_child_range(Children.begin(), Children.end());
7831 }
7832
7835 }
7838 }
7839
7840 static bool classof(const OMPClause *T) {
7841 return T->getClauseKind() == llvm::omp::OMPC_nontemporal;
7842 }
7843};
7844
7845/// This represents 'order' clause in the '#pragma omp ...' directive.
7846///
7847/// \code
7848/// #pragma omp simd order(concurrent)
7849/// \endcode
7850/// In this example directive '#pragma omp parallel' has simple 'order'
7851/// clause with kind 'concurrent'.
7852class OMPOrderClause final : public OMPClause {
7853 friend class OMPClauseReader;
7854
7855 /// Location of '('.
7856 SourceLocation LParenLoc;
7857
7858 /// A kind of the 'order' clause.
7860
7861 /// Start location of the kind in source code.
7862 SourceLocation KindKwLoc;
7863
7864 /// A modifier for order clause
7866
7867 /// Start location of the modifier in source code.
7868 SourceLocation ModifierKwLoc;
7869
7870 /// Set kind of the clause.
7871 ///
7872 /// \param K Argument of clause.
7873 void setKind(OpenMPOrderClauseKind K) { Kind = K; }
7874
7875 /// Set argument location.
7876 ///
7877 /// \param KLoc Argument location.
7878 void setKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
7879
7880 /// Set modifier of the clause.
7881 ///
7882 /// \param M Argument of clause.
7883 void setModifier(OpenMPOrderClauseModifier M) { Modifier = M; }
7884
7885 /// Set modifier location.
7886 ///
7887 /// \param MLoc Modifier keyword location.
7888 void setModifierKwLoc(SourceLocation MLoc) { ModifierKwLoc = MLoc; }
7889
7890public:
7891 /// Build 'order' clause with argument \p A ('concurrent').
7892 ///
7893 /// \param A Argument of the clause ('concurrent').
7894 /// \param ALoc Starting location of the argument.
7895 /// \param StartLoc Starting location of the clause.
7896 /// \param LParenLoc Location of '('.
7897 /// \param EndLoc Ending location of the clause.
7898 /// \param Modifier The modifier applied to 'order' clause.
7899 /// \param MLoc Location of the modifier
7901 SourceLocation StartLoc, SourceLocation LParenLoc,
7903 SourceLocation MLoc)
7904 : OMPClause(llvm::omp::OMPC_order, StartLoc, EndLoc),
7905 LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), Modifier(Modifier),
7906 ModifierKwLoc(MLoc) {}
7907
7908 /// Build an empty clause.
7910 : OMPClause(llvm::omp::OMPC_order, SourceLocation(), SourceLocation()) {}
7911
7912 /// Sets the location of '('.
7913 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
7914
7915 /// Returns the location of '('.
7916 SourceLocation getLParenLoc() const { return LParenLoc; }
7917
7918 /// Returns kind of the clause.
7919 OpenMPOrderClauseKind getKind() const { return Kind; }
7920
7921 /// Returns location of clause kind.
7922 SourceLocation getKindKwLoc() const { return KindKwLoc; }
7923
7924 /// Returns Modifier of the clause.
7925 OpenMPOrderClauseModifier getModifier() const { return Modifier; }
7926
7927 /// Returns location of clause modifier.
7928 SourceLocation getModifierKwLoc() const { return ModifierKwLoc; }
7929
7932 }
7933
7936 }
7937
7940 }
7943 }
7944
7945 static bool classof(const OMPClause *T) {
7946 return T->getClauseKind() == llvm::omp::OMPC_order;
7947 }
7948};
7949
7950/// This represents the 'init' clause in '#pragma omp ...' directives.
7951///
7952/// \code
7953/// #pragma omp interop init(target:obj)
7954/// \endcode
7955class OMPInitClause final
7956 : public OMPVarListClause<OMPInitClause>,
7957 private llvm::TrailingObjects<OMPInitClause, Expr *> {
7958 friend class OMPClauseReader;
7959 friend OMPVarListClause;
7960 friend TrailingObjects;
7961
7962 /// Location of interop variable.
7963 SourceLocation VarLoc;
7964
7965 bool IsTarget = false;
7966 bool IsTargetSync = false;
7967
7968 void setInteropVar(Expr *E) { varlist_begin()[0] = E; }
7969
7970 void setIsTarget(bool V) { IsTarget = V; }
7971
7972 void setIsTargetSync(bool V) { IsTargetSync = V; }
7973
7974 /// Sets the location of the interop variable.
7975 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
7976
7977 /// Build 'init' clause.
7978 ///
7979 /// \param IsTarget Uses the 'target' interop-type.
7980 /// \param IsTargetSync Uses the 'targetsync' interop-type.
7981 /// \param StartLoc Starting location of the clause.
7982 /// \param LParenLoc Location of '('.
7983 /// \param VarLoc Location of the interop variable.
7984 /// \param EndLoc Ending location of the clause.
7985 /// \param N Number of expressions.
7986 OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc,
7987 SourceLocation LParenLoc, SourceLocation VarLoc,
7988 SourceLocation EndLoc, unsigned N)
7989 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc,
7990 LParenLoc, EndLoc, N),
7991 VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {}
7992
7993 /// Build an empty clause.
7994 OMPInitClause(unsigned N)
7995 : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(),
7996 SourceLocation(), SourceLocation(), N) {
7997 }
7998
7999public:
8000 /// Creates a fully specified clause.
8001 ///
8002 /// \param C AST context.
8003 /// \param InteropVar The interop variable.
8004 /// \param InteropInfo The interop-type and prefer_type list.
8005 /// \param StartLoc Starting location of the clause.
8006 /// \param LParenLoc Location of '('.
8007 /// \param VarLoc Location of the interop variable.
8008 /// \param EndLoc Ending location of the clause.
8009 static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar,
8010 OMPInteropInfo &InteropInfo,
8011 SourceLocation StartLoc,
8012 SourceLocation LParenLoc, SourceLocation VarLoc,
8013 SourceLocation EndLoc);
8014
8015 /// Creates an empty clause with \a N expressions.
8016 ///
8017 /// \param C AST context.
8018 /// \param N Number of expression items.
8019 static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N);
8020
8021 /// Returns the location of the interop variable.
8022 SourceLocation getVarLoc() const { return VarLoc; }
8023
8024 /// Returns the interop variable.
8026 const Expr *getInteropVar() const { return varlist_begin()[0]; }
8027
8028 /// Returns true is interop-type 'target' is used.
8029 bool getIsTarget() const { return IsTarget; }
8030
8031 /// Returns true is interop-type 'targetsync' is used.
8032 bool getIsTargetSync() const { return IsTargetSync; }
8033
8035 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8036 reinterpret_cast<Stmt **>(varlist_end()));
8037 }
8038
8040 auto Children = const_cast<OMPInitClause *>(this)->children();
8041 return const_child_range(Children.begin(), Children.end());
8042 }
8043
8046 }
8049 }
8050
8053 using prefs_range = llvm::iterator_range<prefs_iterator>;
8054 using const_prefs_range = llvm::iterator_range<const_prefs_iterator>;
8055
8057 return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())),
8058 reinterpret_cast<Expr **>(varlist_end()));
8059 }
8060
8062 auto Prefs = const_cast<OMPInitClause *>(this)->prefs();
8063 return const_prefs_range(Prefs.begin(), Prefs.end());
8064 }
8065
8066 static bool classof(const OMPClause *T) {
8067 return T->getClauseKind() == llvm::omp::OMPC_init;
8068 }
8069};
8070
8071/// This represents the 'use' clause in '#pragma omp ...' directives.
8072///
8073/// \code
8074/// #pragma omp interop use(obj)
8075/// \endcode
8076class OMPUseClause final : public OMPClause {
8077 friend class OMPClauseReader;
8078
8079 /// Location of '('.
8080 SourceLocation LParenLoc;
8081
8082 /// Location of interop variable.
8083 SourceLocation VarLoc;
8084
8085 /// The interop variable.
8086 Stmt *InteropVar = nullptr;
8087
8088 /// Set the interop variable.
8089 void setInteropVar(Expr *E) { InteropVar = E; }
8090
8091 /// Sets the location of '('.
8092 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8093
8094 /// Sets the location of the interop variable.
8095 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8096
8097public:
8098 /// Build 'use' clause with and interop variable expression \a InteropVar.
8099 ///
8100 /// \param InteropVar The interop variable.
8101 /// \param StartLoc Starting location of the clause.
8102 /// \param LParenLoc Location of '('.
8103 /// \param VarLoc Location of the interop variable.
8104 /// \param EndLoc Ending location of the clause.
8105 OMPUseClause(Expr *InteropVar, SourceLocation StartLoc,
8106 SourceLocation LParenLoc, SourceLocation VarLoc,
8107 SourceLocation EndLoc)
8108 : OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc),
8109 VarLoc(VarLoc), InteropVar(InteropVar) {}
8110
8111 /// Build an empty clause.
8113 : OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {}
8114
8115 /// Returns the location of '('.
8116 SourceLocation getLParenLoc() const { return LParenLoc; }
8117
8118 /// Returns the location of the interop variable.
8119 SourceLocation getVarLoc() const { return VarLoc; }
8120
8121 /// Returns the interop variable.
8122 Expr *getInteropVar() const { return cast<Expr>(InteropVar); }
8123
8124 child_range children() { return child_range(&InteropVar, &InteropVar + 1); }
8125
8127 return const_child_range(&InteropVar, &InteropVar + 1);
8128 }
8129
8132 }
8135 }
8136
8137 static bool classof(const OMPClause *T) {
8138 return T->getClauseKind() == llvm::omp::OMPC_use;
8139 }
8140};
8141
8142/// This represents 'destroy' clause in the '#pragma omp depobj'
8143/// directive or the '#pragma omp interop' directive..
8144///
8145/// \code
8146/// #pragma omp depobj(a) destroy
8147/// #pragma omp interop destroy(obj)
8148/// \endcode
8149/// In these examples directive '#pragma omp depobj' and '#pragma omp interop'
8150/// have a 'destroy' clause. The 'interop' directive includes an object.
8151class OMPDestroyClause final : public OMPClause {
8152 friend class OMPClauseReader;
8153
8154 /// Location of '('.
8155 SourceLocation LParenLoc;
8156
8157 /// Location of interop variable.
8158 SourceLocation VarLoc;
8159
8160 /// The interop variable.
8161 Stmt *InteropVar = nullptr;
8162
8163 /// Set the interop variable.
8164 void setInteropVar(Expr *E) { InteropVar = E; }
8165
8166 /// Sets the location of '('.
8167 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8168
8169 /// Sets the location of the interop variable.
8170 void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
8171
8172public:
8173 /// Build 'destroy' clause with an interop variable expression \a InteropVar.
8174 ///
8175 /// \param InteropVar The interop variable.
8176 /// \param StartLoc Starting location of the clause.
8177 /// \param LParenLoc Location of '('.
8178 /// \param VarLoc Location of the interop variable.
8179 /// \param EndLoc Ending location of the clause.
8180 OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc,
8181 SourceLocation LParenLoc, SourceLocation VarLoc,
8182 SourceLocation EndLoc)
8183 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc),
8184 LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {}
8185
8186 /// Build 'destroy' clause.
8187 ///
8188 /// \param StartLoc Starting location of the clause.
8189 /// \param EndLoc Ending location of the clause.
8191 : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc) {}
8192
8193 /// Build an empty clause.
8195 : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) {
8196 }
8197
8198 /// Returns the location of '('.
8199 SourceLocation getLParenLoc() const { return LParenLoc; }
8200
8201 /// Returns the location of the interop variable.
8202 SourceLocation getVarLoc() const { return VarLoc; }
8203
8204 /// Returns the interop variable.
8205 Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); }
8206
8208 if (InteropVar)
8209 return child_range(&InteropVar, &InteropVar + 1);
8211 }
8212
8214 if (InteropVar)
8215 return const_child_range(&InteropVar, &InteropVar + 1);
8217 }
8218
8221 }
8224 }
8225
8226 static bool classof(const OMPClause *T) {
8227 return T->getClauseKind() == llvm::omp::OMPC_destroy;
8228 }
8229};
8230
8231/// This represents 'novariants' clause in the '#pragma omp ...' directive.
8232///
8233/// \code
8234/// #pragma omp dispatch novariants(a > 5)
8235/// \endcode
8236/// In this example directive '#pragma omp dispatch' has simple 'novariants'
8237/// clause with condition 'a > 5'.
8239 : public OMPOneStmtClause<llvm::omp::OMPC_novariants, OMPClause>,
8240 public OMPClauseWithPreInit {
8241 friend class OMPClauseReader;
8242
8243 /// Set condition.
8244 void setCondition(Expr *Cond) { setStmt(Cond); }
8245
8246public:
8247 /// Build 'novariants' clause with condition \a Cond.
8248 ///
8249 /// \param Cond Condition of the clause.
8250 /// \param HelperCond Helper condition for the construct.
8251 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8252 /// clause must be captured.
8253 /// \param StartLoc Starting location of the clause.
8254 /// \param LParenLoc Location of '('.
8255 /// \param EndLoc Ending location of the clause.
8256 OMPNovariantsClause(Expr *Cond, Stmt *HelperCond,
8257 OpenMPDirectiveKind CaptureRegion,
8258 SourceLocation StartLoc, SourceLocation LParenLoc,
8259 SourceLocation EndLoc)
8260 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8261 OMPClauseWithPreInit(this) {
8262 setPreInitStmt(HelperCond, CaptureRegion);
8263 }
8264
8265 /// Build an empty clause.
8267
8268 /// Returns condition.
8269 Expr *getCondition() const { return getStmtAs<Expr>(); }
8270
8273 auto Children = const_cast<OMPNovariantsClause *>(this)->used_children();
8274 return const_child_range(Children.begin(), Children.end());
8275 }
8276};
8277
8278/// This represents 'nocontext' clause in the '#pragma omp ...' directive.
8279///
8280/// \code
8281/// #pragma omp dispatch nocontext(a > 5)
8282/// \endcode
8283/// In this example directive '#pragma omp dispatch' has simple 'nocontext'
8284/// clause with condition 'a > 5'.
8286 : public OMPOneStmtClause<llvm::omp::OMPC_nocontext, OMPClause>,
8287 public OMPClauseWithPreInit {
8288 friend class OMPClauseReader;
8289
8290 /// Set condition.
8291 void setCondition(Expr *Cond) { setStmt(Cond); }
8292
8293public:
8294 /// Build 'nocontext' clause with condition \a Cond.
8295 ///
8296 /// \param Cond Condition of the clause.
8297 /// \param HelperCond Helper condition for the construct.
8298 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8299 /// clause must be captured.
8300 /// \param StartLoc Starting location of the clause.
8301 /// \param LParenLoc Location of '('.
8302 /// \param EndLoc Ending location of the clause.
8303 OMPNocontextClause(Expr *Cond, Stmt *HelperCond,
8304 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
8305 SourceLocation LParenLoc, SourceLocation EndLoc)
8306 : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc),
8307 OMPClauseWithPreInit(this) {
8308 setPreInitStmt(HelperCond, CaptureRegion);
8309 }
8310
8311 /// Build an empty clause.
8313
8314 /// Returns condition.
8315 Expr *getCondition() const { return getStmtAs<Expr>(); }
8316
8319 auto Children = const_cast<OMPNocontextClause *>(this)->used_children();
8320 return const_child_range(Children.begin(), Children.end());
8321 }
8322};
8323
8324/// This represents 'detach' clause in the '#pragma omp task' directive.
8325///
8326/// \code
8327/// #pragma omp task detach(evt)
8328/// \endcode
8329/// In this example directive '#pragma omp detach' has simple 'detach' clause
8330/// with the variable 'evt'.
8332 : public OMPOneStmtClause<llvm::omp::OMPC_detach, OMPClause> {
8333 friend class OMPClauseReader;
8334
8335 /// Set condition.
8336 void setEventHandler(Expr *E) { setStmt(E); }
8337
8338public:
8339 /// Build 'detach' clause with event-handler \a Evt.
8340 ///
8341 /// \param Evt Event handler expression.
8342 /// \param StartLoc Starting location of the clause.
8343 /// \param LParenLoc Location of '('.
8344 /// \param EndLoc Ending location of the clause.
8346 SourceLocation EndLoc)
8347 : OMPOneStmtClause(Evt, StartLoc, LParenLoc, EndLoc) {}
8348
8349 /// Build an empty clause.
8351
8352 /// Returns event-handler expression.
8353 Expr *getEventHandler() const { return getStmtAs<Expr>(); }
8354};
8355
8356/// This represents clause 'inclusive' in the '#pragma omp scan' directive.
8357///
8358/// \code
8359/// #pragma omp scan inclusive(a,b)
8360/// \endcode
8361/// In this example directive '#pragma omp scan' has clause 'inclusive'
8362/// with the variables 'a' and 'b'.
8364 : public OMPVarListClause<OMPInclusiveClause>,
8365 private llvm::TrailingObjects<OMPInclusiveClause, Expr *> {
8366 friend class OMPClauseReader;
8367 friend OMPVarListClause;
8368 friend TrailingObjects;
8369
8370 /// Build clause with number of variables \a N.
8371 ///
8372 /// \param StartLoc Starting location of the clause.
8373 /// \param LParenLoc Location of '('.
8374 /// \param EndLoc Ending location of the clause.
8375 /// \param N Number of the variables in the clause.
8377 SourceLocation EndLoc, unsigned N)
8378 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
8379 StartLoc, LParenLoc, EndLoc, N) {}
8380
8381 /// Build an empty clause.
8382 ///
8383 /// \param N Number of variables.
8384 explicit OMPInclusiveClause(unsigned N)
8385 : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive,
8387 SourceLocation(), N) {}
8388
8389public:
8390 /// Creates clause with a list of variables \a VL.
8391 ///
8392 /// \param C AST context.
8393 /// \param StartLoc Starting location of the clause.
8394 /// \param LParenLoc Location of '('.
8395 /// \param EndLoc Ending location of the clause.
8396 /// \param VL List of references to the original variables.
8397 static OMPInclusiveClause *Create(const ASTContext &C,
8398 SourceLocation StartLoc,
8399 SourceLocation LParenLoc,
8400 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8401
8402 /// Creates an empty clause with the place for \a N variables.
8403 ///
8404 /// \param C AST context.
8405 /// \param N The number of variables.
8406 static OMPInclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
8407
8409 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8410 reinterpret_cast<Stmt **>(varlist_end()));
8411 }
8412
8414 auto Children = const_cast<OMPInclusiveClause *>(this)->children();
8415 return const_child_range(Children.begin(), Children.end());
8416 }
8417
8420 }
8423 }
8424
8425 static bool classof(const OMPClause *T) {
8426 return T->getClauseKind() == llvm::omp::OMPC_inclusive;
8427 }
8428};
8429
8430/// This represents clause 'exclusive' in the '#pragma omp scan' directive.
8431///
8432/// \code
8433/// #pragma omp scan exclusive(a,b)
8434/// \endcode
8435/// In this example directive '#pragma omp scan' has clause 'exclusive'
8436/// with the variables 'a' and 'b'.
8438 : public OMPVarListClause<OMPExclusiveClause>,
8439 private llvm::TrailingObjects<OMPExclusiveClause, Expr *> {
8440 friend class OMPClauseReader;
8441 friend OMPVarListClause;
8442 friend TrailingObjects;
8443
8444 /// Build clause with number of variables \a N.
8445 ///
8446 /// \param StartLoc Starting location of the clause.
8447 /// \param LParenLoc Location of '('.
8448 /// \param EndLoc Ending location of the clause.
8449 /// \param N Number of the variables in the clause.
8451 SourceLocation EndLoc, unsigned N)
8452 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
8453 StartLoc, LParenLoc, EndLoc, N) {}
8454
8455 /// Build an empty clause.
8456 ///
8457 /// \param N Number of variables.
8458 explicit OMPExclusiveClause(unsigned N)
8459 : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive,
8461 SourceLocation(), N) {}
8462
8463public:
8464 /// Creates clause with a list of variables \a VL.
8465 ///
8466 /// \param C AST context.
8467 /// \param StartLoc Starting location of the clause.
8468 /// \param LParenLoc Location of '('.
8469 /// \param EndLoc Ending location of the clause.
8470 /// \param VL List of references to the original variables.
8471 static OMPExclusiveClause *Create(const ASTContext &C,
8472 SourceLocation StartLoc,
8473 SourceLocation LParenLoc,
8474 SourceLocation EndLoc, ArrayRef<Expr *> VL);
8475
8476 /// Creates an empty clause with the place for \a N variables.
8477 ///
8478 /// \param C AST context.
8479 /// \param N The number of variables.
8480 static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
8481
8483 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8484 reinterpret_cast<Stmt **>(varlist_end()));
8485 }
8486
8488 auto Children = const_cast<OMPExclusiveClause *>(this)->children();
8489 return const_child_range(Children.begin(), Children.end());
8490 }
8491
8494 }
8497 }
8498
8499 static bool classof(const OMPClause *T) {
8500 return T->getClauseKind() == llvm::omp::OMPC_exclusive;
8501 }
8502};
8503
8504/// This represents clause 'uses_allocators' in the '#pragma omp target'-based
8505/// directives.
8506///
8507/// \code
8508/// #pragma omp target uses_allocators(default_allocator, my_allocator(traits))
8509/// \endcode
8510/// In this example directive '#pragma omp target' has clause 'uses_allocators'
8511/// with the allocators 'default_allocator' and user-defined 'my_allocator'.
8513 : public OMPClause,
8514 private llvm::TrailingObjects<OMPUsesAllocatorsClause, Expr *,
8515 SourceLocation> {
8516public:
8517 /// Data for list of allocators.
8518 struct Data {
8519 /// Allocator.
8520 Expr *Allocator = nullptr;
8521 /// Allocator traits.
8523 /// Locations of '(' and ')' symbols.
8525 };
8526
8527private:
8528 friend class OMPClauseReader;
8529 friend TrailingObjects;
8530
8531 enum class ExprOffsets {
8532 Allocator,
8533 AllocatorTraits,
8534 Total,
8535 };
8536
8537 enum class ParenLocsOffsets {
8538 LParen,
8539 RParen,
8540 Total,
8541 };
8542
8543 /// Location of '('.
8544 SourceLocation LParenLoc;
8545 /// Total number of allocators in the clause.
8546 unsigned NumOfAllocators = 0;
8547
8548 /// Build clause.
8549 ///
8550 /// \param StartLoc Starting location of the clause.
8551 /// \param LParenLoc Location of '('.
8552 /// \param EndLoc Ending location of the clause.
8553 /// \param N Number of allocators associated with the clause.
8554 OMPUsesAllocatorsClause(SourceLocation StartLoc, SourceLocation LParenLoc,
8555 SourceLocation EndLoc, unsigned N)
8556 : OMPClause(llvm::omp::OMPC_uses_allocators, StartLoc, EndLoc),
8557 LParenLoc(LParenLoc), NumOfAllocators(N) {}
8558
8559 /// Build an empty clause.
8560 /// \param N Number of allocators associated with the clause.
8561 ///
8562 explicit OMPUsesAllocatorsClause(unsigned N)
8563 : OMPClause(llvm::omp::OMPC_uses_allocators, SourceLocation(),
8564 SourceLocation()),
8565 NumOfAllocators(N) {}
8566
8567 unsigned numTrailingObjects(OverloadToken<Expr *>) const {
8568 return NumOfAllocators * static_cast<int>(ExprOffsets::Total);
8569 }
8570
8571 /// Sets the location of '('.
8572 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8573
8574 /// Sets the allocators data for the clause.
8575 void setAllocatorsData(ArrayRef<OMPUsesAllocatorsClause::Data> Data);
8576
8577public:
8578 /// Creates clause with a list of allocators \p Data.
8579 ///
8580 /// \param C AST context.
8581 /// \param StartLoc Starting location of the clause.
8582 /// \param LParenLoc Location of '('.
8583 /// \param EndLoc Ending location of the clause.
8584 /// \param Data List of allocators.
8585 static OMPUsesAllocatorsClause *
8586 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
8587 SourceLocation EndLoc, ArrayRef<OMPUsesAllocatorsClause::Data> Data);
8588
8589 /// Creates an empty clause with the place for \p N allocators.
8590 ///
8591 /// \param C AST context.
8592 /// \param N The number of allocators.
8593 static OMPUsesAllocatorsClause *CreateEmpty(const ASTContext &C, unsigned N);
8594
8595 /// Returns the location of '('.
8596 SourceLocation getLParenLoc() const { return LParenLoc; }
8597
8598 /// Returns number of allocators associated with the clause.
8599 unsigned getNumberOfAllocators() const { return NumOfAllocators; }
8600
8601 /// Returns data for the specified allocator.
8603
8604 // Iterators
8606 Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
8607 return child_range(Begin, Begin + NumOfAllocators *
8608 static_cast<int>(ExprOffsets::Total));
8609 }
8611 Stmt *const *Begin =
8612 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
8613 return const_child_range(
8614 Begin, Begin + NumOfAllocators * static_cast<int>(ExprOffsets::Total));
8615 }
8616
8619 }
8622 }
8623
8624 static bool classof(const OMPClause *T) {
8625 return T->getClauseKind() == llvm::omp::OMPC_uses_allocators;
8626 }
8627};
8628
8629/// This represents clause 'affinity' in the '#pragma omp task'-based
8630/// directives.
8631///
8632/// \code
8633/// #pragma omp task affinity(iterator(i = 0:n) : ([3][n])a, b[:n], c[i])
8634/// \endcode
8635/// In this example directive '#pragma omp task' has clause 'affinity' with the
8636/// affinity modifer 'iterator(i = 0:n)' and locator items '([3][n])a', 'b[:n]'
8637/// and 'c[i]'.
8639 : public OMPVarListClause<OMPAffinityClause>,
8640 private llvm::TrailingObjects<OMPAffinityClause, Expr *> {
8641 friend class OMPClauseReader;
8642 friend OMPVarListClause;
8643 friend TrailingObjects;
8644
8645 /// Location of ':' symbol.
8646 SourceLocation ColonLoc;
8647
8648 /// Build clause.
8649 ///
8650 /// \param StartLoc Starting location of the clause.
8651 /// \param LParenLoc Location of '('.
8652 /// \param ColonLoc Location of ':'.
8653 /// \param EndLoc Ending location of the clause.
8654 /// \param N Number of locators associated with the clause.
8656 SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N)
8657 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, StartLoc,
8658 LParenLoc, EndLoc, N) {}
8659
8660 /// Build an empty clause.
8661 /// \param N Number of locators associated with the clause.
8662 ///
8663 explicit OMPAffinityClause(unsigned N)
8664 : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity,
8666 SourceLocation(), N) {}
8667
8668 /// Sets the affinity modifier for the clause, if any.
8669 void setModifier(Expr *E) {
8670 getTrailingObjects<Expr *>()[varlist_size()] = E;
8671 }
8672
8673 /// Sets the location of ':' symbol.
8674 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
8675
8676public:
8677 /// Creates clause with a modifier a list of locator items.
8678 ///
8679 /// \param C AST context.
8680 /// \param StartLoc Starting location of the clause.
8681 /// \param LParenLoc Location of '('.
8682 /// \param ColonLoc Location of ':'.
8683 /// \param EndLoc Ending location of the clause.
8684 /// \param Locators List of locator items.
8685 static OMPAffinityClause *Create(const ASTContext &C, SourceLocation StartLoc,
8686 SourceLocation LParenLoc,
8687 SourceLocation ColonLoc,
8688 SourceLocation EndLoc, Expr *Modifier,
8689 ArrayRef<Expr *> Locators);
8690
8691 /// Creates an empty clause with the place for \p N locator items.
8692 ///
8693 /// \param C AST context.
8694 /// \param N The number of locator items.
8695 static OMPAffinityClause *CreateEmpty(const ASTContext &C, unsigned N);
8696
8697 /// Gets affinity modifier.
8698 Expr *getModifier() { return getTrailingObjects<Expr *>()[varlist_size()]; }
8700 return getTrailingObjects<Expr *>()[varlist_size()];
8701 }
8702
8703 /// Gets the location of ':' symbol.
8704 SourceLocation getColonLoc() const { return ColonLoc; }
8705
8706 // Iterators
8708 int Offset = getModifier() ? 1 : 0;
8709 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
8710 reinterpret_cast<Stmt **>(varlist_end() + Offset));
8711 }
8712
8714 auto Children = const_cast<OMPAffinityClause *>(this)->children();
8715 return const_child_range(Children.begin(), Children.end());
8716 }
8717
8720 }
8723 }
8724
8725 static bool classof(const OMPClause *T) {
8726 return T->getClauseKind() == llvm::omp::OMPC_affinity;
8727 }
8728};
8729
8730/// This represents 'filter' clause in the '#pragma omp ...' directive.
8731///
8732/// \code
8733/// #pragma omp masked filter(tid)
8734/// \endcode
8735/// In this example directive '#pragma omp masked' has 'filter' clause with
8736/// thread id.
8738 : public OMPOneStmtClause<llvm::omp::OMPC_filter, OMPClause>,
8739 public OMPClauseWithPreInit {
8740 friend class OMPClauseReader;
8741
8742 /// Sets the thread identifier.
8743 void setThreadID(Expr *TID) { setStmt(TID); }
8744
8745public:
8746 /// Build 'filter' clause with thread-id \a ThreadID.
8747 ///
8748 /// \param ThreadID Thread identifier.
8749 /// \param HelperE Helper expression associated with this clause.
8750 /// \param CaptureRegion Innermost OpenMP region where expressions in this
8751 /// clause must be captured.
8752 /// \param StartLoc Starting location of the clause.
8753 /// \param LParenLoc Location of '('.
8754 /// \param EndLoc Ending location of the clause.
8755 OMPFilterClause(Expr *ThreadID, Stmt *HelperE,
8756 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
8757 SourceLocation LParenLoc, SourceLocation EndLoc)
8758 : OMPOneStmtClause(ThreadID, StartLoc, LParenLoc, EndLoc),
8759 OMPClauseWithPreInit(this) {
8760 setPreInitStmt(HelperE, CaptureRegion);
8761 }
8762
8763 /// Build an empty clause.
8765
8766 /// Return thread identifier.
8767 Expr *getThreadID() const { return getStmtAs<Expr>(); }
8768
8769 /// Return thread identifier.
8770 Expr *getThreadID() { return getStmtAs<Expr>(); }
8771};
8772
8773/// This represents 'bind' clause in the '#pragma omp ...' directives.
8774///
8775/// \code
8776/// #pragma omp loop bind(parallel)
8777/// \endcode
8778class OMPBindClause final : public OMPNoChildClause<llvm::omp::OMPC_bind> {
8779 friend class OMPClauseReader;
8780
8781 /// Location of '('.
8782 SourceLocation LParenLoc;
8783
8784 /// The binding kind of 'bind' clause.
8786
8787 /// Start location of the kind in source code.
8788 SourceLocation KindLoc;
8789
8790 /// Sets the location of '('.
8791 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
8792
8793 /// Set the binding kind.
8794 void setBindKind(OpenMPBindClauseKind K) { Kind = K; }
8795
8796 /// Set the binding kind location.
8797 void setBindKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
8798
8799 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
8800 ///
8801 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
8802 /// \param KLoc Starting location of the binding kind.
8803 /// \param StartLoc Starting location of the clause.
8804 /// \param LParenLoc Location of '('.
8805 /// \param EndLoc Ending location of the clause.
8806 OMPBindClause(OpenMPBindClauseKind K, SourceLocation KLoc,
8807 SourceLocation StartLoc, SourceLocation LParenLoc,
8808 SourceLocation EndLoc)
8809 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Kind(K),
8810 KindLoc(KLoc) {}
8811
8812 /// Build an empty clause.
8813 OMPBindClause() : OMPNoChildClause() {}
8814
8815public:
8816 /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread').
8817 ///
8818 /// \param C AST context
8819 /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread').
8820 /// \param KLoc Starting location of the binding kind.
8821 /// \param StartLoc Starting location of the clause.
8822 /// \param LParenLoc Location of '('.
8823 /// \param EndLoc Ending location of the clause.
8824 static OMPBindClause *Create(const ASTContext &C, OpenMPBindClauseKind K,
8825 SourceLocation KLoc, SourceLocation StartLoc,
8826 SourceLocation LParenLoc, SourceLocation EndLoc);
8827
8828 /// Build an empty 'bind' clause.
8829 ///
8830 /// \param C AST context
8831 static OMPBindClause *CreateEmpty(const ASTContext &C);
8832
8833 /// Returns the location of '('.
8834 SourceLocation getLParenLoc() const { return LParenLoc; }
8835
8836 /// Returns kind of the clause.
8837 OpenMPBindClauseKind getBindKind() const { return Kind; }
8838
8839 /// Returns location of clause kind.
8840 SourceLocation getBindKindLoc() const { return KindLoc; }
8841};
8842
8843/// This class implements a simple visitor for OMPClause
8844/// subclasses.
8845template<class ImplClass, template <typename> class Ptr, typename RetTy>
8847public:
8848#define PTR(CLASS) Ptr<CLASS>
8849#define DISPATCH(CLASS) \
8850 return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S))
8851
8852#define GEN_CLANG_CLAUSE_CLASS
8853#define CLAUSE_CLASS(Enum, Str, Class) \
8854 RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
8855#include "llvm/Frontend/OpenMP/OMP.inc"
8856
8857 RetTy Visit(PTR(OMPClause) S) {
8858 // Top switch clause: visit each OMPClause.
8859 switch (S->getClauseKind()) {
8860#define GEN_CLANG_CLAUSE_CLASS
8861#define CLAUSE_CLASS(Enum, Str, Class) \
8862 case llvm::omp::Clause::Enum: \
8863 return Visit##Class(static_cast<PTR(Class)>(S));
8864#define CLAUSE_NO_CLASS(Enum, Str) \
8865 case llvm::omp::Clause::Enum: \
8866 break;
8867#include "llvm/Frontend/OpenMP/OMP.inc"
8868 }
8869 }
8870 // Base case, ignore it. :)
8871 RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); }
8872#undef PTR
8873#undef DISPATCH
8874};
8875
8876template <typename T> using const_ptr = std::add_pointer_t<std::add_const_t<T>>;
8877
8878template <class ImplClass, typename RetTy = void>
8880 : public OMPClauseVisitorBase<ImplClass, std::add_pointer_t, RetTy> {};
8881template<class ImplClass, typename RetTy = void>
8883 public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {};
8884
8885class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
8886 raw_ostream &OS;
8887 const PrintingPolicy &Policy;
8888
8889 /// Process clauses with list of variables.
8890 template <typename T> void VisitOMPClauseList(T *Node, char StartSym);
8891 /// Process motion clauses.
8892 template <typename T> void VisitOMPMotionClause(T *Node);
8893
8894public:
8895 OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
8896 : OS(OS), Policy(Policy) {}
8897
8898#define GEN_CLANG_CLAUSE_CLASS
8899#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
8900#include "llvm/Frontend/OpenMP/OMP.inc"
8901};
8902
8904 llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
8905
8906 /// The raw string as we parsed it. This is needed for the `isa` trait set
8907 /// (which accepts anything) and (later) extensions.
8908 StringRef RawString;
8909};
8912 llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
8914};
8916 llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
8918};
8919
8920/// Helper data structure representing the traits in a match clause of an
8921/// `declare variant` or `metadirective`. The outer level is an ordered
8922/// collection of selector sets, each with an associated kind and an ordered
8923/// collection of selectors. A selector has a kind, an optional score/condition,
8924/// and an ordered collection of properties.
8926 /// Private constructor accesible only by ASTContext.
8927 OMPTraitInfo() {}
8928 friend class ASTContext;
8929
8930public:
8931 /// Reconstruct a (partial) OMPTraitInfo object from a mangled name.
8932 OMPTraitInfo(StringRef MangledName);
8933
8934 /// The outermost level of selector sets.
8936
8938 llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) {
8939 return llvm::any_of(Sets, [&](OMPTraitSet &Set) {
8940 return llvm::any_of(
8941 Set.Selectors, [&](OMPTraitSelector &Selector) {
8942 return Cond(Selector.ScoreOrCondition,
8943 /* IsScore */ Selector.Kind !=
8944 llvm::omp::TraitSelector::user_condition);
8945 });
8946 });
8947 }
8948
8949 /// Create a variant match info object from this trait info object. While the
8950 /// former is a flat representation the actual main difference is that the
8951 /// latter uses clang::Expr to store the score/condition while the former is
8952 /// independent of clang. Thus, expressions and conditions are evaluated in
8953 /// this method.
8954 void getAsVariantMatchInfo(ASTContext &ASTCtx,
8955 llvm::omp::VariantMatchInfo &VMI) const;
8956
8957 /// Return a string representation identifying this context selector.
8958 std::string getMangledName() const;
8959
8960 /// Check the extension trait \p TP is active.
8961 bool isExtensionActive(llvm::omp::TraitProperty TP) {
8962 for (const OMPTraitSet &Set : Sets) {
8963 if (Set.Kind != llvm::omp::TraitSet::implementation)
8964 continue;
8965 for (const OMPTraitSelector &Selector : Set.Selectors) {
8966 if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
8967 continue;
8968 for (const OMPTraitProperty &Property : Selector.Properties) {
8969 if (Property.Kind == TP)
8970 return true;
8971 }
8972 }
8973 }
8974 return false;
8975 }
8976
8977 /// Print a human readable representation into \p OS.
8978 void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
8979};
8980llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
8981llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
8982
8983/// Clang specific specialization of the OMPContext to lookup target features.
8986 std::function<void(StringRef)> &&DiagUnknownTrait,
8987 const FunctionDecl *CurrentFunctionDecl,
8988 ArrayRef<llvm::omp::TraitProperty> ConstructTraits);
8989
8990 virtual ~TargetOMPContext() = default;
8991
8992 /// See llvm::omp::OMPContext::matchesISATrait
8993 bool matchesISATrait(StringRef RawString) const override;
8994
8995private:
8996 std::function<bool(StringRef)> FeatureValidityCheck;
8997 std::function<void(StringRef)> DiagUnknownTrait;
8998 llvm::StringMap<bool> FeatureMap;
8999};
9000
9001/// Contains data for OpenMP directives: clauses, children
9002/// expressions/statements (helpers for codegen) and associated statement, if
9003/// any.
9004class OMPChildren final
9005 : private llvm::TrailingObjects<OMPChildren, OMPClause *, Stmt *> {
9006 friend TrailingObjects;
9007 friend class OMPClauseReader;
9009 template <typename T> friend class OMPDeclarativeDirective;
9010
9011 /// Numbers of clauses.
9012 unsigned NumClauses = 0;
9013 /// Number of child expressions/stmts.
9014 unsigned NumChildren = 0;
9015 /// true if the directive has associated statement.
9016 bool HasAssociatedStmt = false;
9017
9018 /// Define the sizes of each trailing object array except the last one. This
9019 /// is required for TrailingObjects to work properly.
9020 size_t numTrailingObjects(OverloadToken<OMPClause *>) const {
9021 return NumClauses;
9022 }
9023
9024 OMPChildren() = delete;
9025
9026 OMPChildren(unsigned NumClauses, unsigned NumChildren, bool HasAssociatedStmt)
9027 : NumClauses(NumClauses), NumChildren(NumChildren),
9028 HasAssociatedStmt(HasAssociatedStmt) {}
9029
9030 static size_t size(unsigned NumClauses, bool HasAssociatedStmt,
9031 unsigned NumChildren);
9032
9033 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses);
9034 static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses, Stmt *S,
9035 unsigned NumChildren = 0);
9036 static OMPChildren *CreateEmpty(void *Mem, unsigned NumClauses,
9037 bool HasAssociatedStmt = false,
9038 unsigned NumChildren = 0);
9039
9040public:
9041 unsigned getNumClauses() const { return NumClauses; }
9042 unsigned getNumChildren() const { return NumChildren; }
9043 bool hasAssociatedStmt() const { return HasAssociatedStmt; }
9044
9045 /// Set associated statement.
9047 getTrailingObjects<Stmt *>()[NumChildren] = S;
9048 }
9049
9051
9052 /// Sets the list of variables for this clause.
9053 ///
9054 /// \param Clauses The list of clauses for the directive.
9055 ///
9056 void setClauses(ArrayRef<OMPClause *> Clauses);
9057
9058 /// Returns statement associated with the directive.
9059 const Stmt *getAssociatedStmt() const {
9060 return const_cast<OMPChildren *>(this)->getAssociatedStmt();
9061 }
9063 assert(HasAssociatedStmt &&
9064 "Expected directive with the associated statement.");
9065 return getTrailingObjects<Stmt *>()[NumChildren];
9066 }
9067
9068 /// Get the clauses storage.
9070 return llvm::MutableArrayRef(getTrailingObjects<OMPClause *>(),
9071 NumClauses);
9072 }
9074 return const_cast<OMPChildren *>(this)->getClauses();
9075 }
9076
9077 /// Returns the captured statement associated with the
9078 /// component region within the (combined) directive.
9079 ///
9080 /// \param RegionKind Component region kind.
9081 const CapturedStmt *
9083 ArrayRef<OpenMPDirectiveKind> CaptureRegions) const {
9084 assert(llvm::is_contained(CaptureRegions, RegionKind) &&
9085 "RegionKind not found in OpenMP CaptureRegions.");
9086 auto *CS = cast<CapturedStmt>(getAssociatedStmt());
9087 for (auto ThisCaptureRegion : CaptureRegions) {
9088 if (ThisCaptureRegion == RegionKind)
9089 return CS;
9090 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9091 }
9092 llvm_unreachable("Incorrect RegionKind specified for directive.");
9093 }
9094
9095 /// Get innermost captured statement for the construct.
9096 CapturedStmt *
9098 assert(hasAssociatedStmt() && "Must have associated captured statement.");
9099 assert(!CaptureRegions.empty() &&
9100 "At least one captured statement must be provided.");
9101 auto *CS = cast<CapturedStmt>(getAssociatedStmt());
9102 for (unsigned Level = CaptureRegions.size(); Level > 1; --Level)
9103 CS = cast<CapturedStmt>(CS->getCapturedStmt());
9104 return CS;
9105 }
9106
9107 const CapturedStmt *
9109 return const_cast<OMPChildren *>(this)->getInnermostCapturedStmt(
9110 CaptureRegions);
9111 }
9112
9115 return const_cast<OMPChildren *>(this)->getChildren();
9116 }
9117
9119 assert(HasAssociatedStmt &&
9120 "Expected directive with the associated statement.");
9121 if (auto *CS = dyn_cast<CapturedStmt>(getAssociatedStmt())) {
9122 Stmt *S = nullptr;
9123 do {
9124 S = CS->getCapturedStmt();
9125 CS = dyn_cast<CapturedStmt>(S);
9126 } while (CS);
9127 return S;
9128 }
9129 return getAssociatedStmt();
9130 }
9131 const Stmt *getRawStmt() const {
9132 return const_cast<OMPChildren *>(this)->getRawStmt();
9133 }
9134
9136 if (!HasAssociatedStmt)
9138 return Stmt::child_range(&getTrailingObjects<Stmt *>()[NumChildren],
9139 &getTrailingObjects<Stmt *>()[NumChildren + 1]);
9140 }
9141};
9142
9143/// This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...'
9144/// directive.
9145///
9146/// \code
9147/// #pragma omp target [...] ompx_dyn_cgroup_mem(N)
9148/// \endcode
9150 : public OMPOneStmtClause<llvm::omp::OMPC_ompx_dyn_cgroup_mem, OMPClause>,
9151 public OMPClauseWithPreInit {
9152 friend class OMPClauseReader;
9153
9154 /// Set size.
9155 void setSize(Expr *E) { setStmt(E); }
9156
9157public:
9158 /// Build 'ompx_dyn_cgroup_mem' clause.
9159 ///
9160 /// \param Size Size expression.
9161 /// \param HelperSize Helper Size expression
9162 /// \param CaptureRegion Innermost OpenMP region where expressions in this
9163 /// \param StartLoc Starting location of the clause.
9164 /// \param LParenLoc Location of '('.
9165 /// \param EndLoc Ending location of the clause.
9167 OpenMPDirectiveKind CaptureRegion,
9168 SourceLocation StartLoc, SourceLocation LParenLoc,
9169 SourceLocation EndLoc)
9170 : OMPOneStmtClause(Size, StartLoc, LParenLoc, EndLoc),
9171 OMPClauseWithPreInit(this) {
9172 setPreInitStmt(HelperSize, CaptureRegion);
9173 }
9174
9175 /// Build an empty clause.
9177
9178 /// Return the size expression.
9179 Expr *getSize() { return getStmtAs<Expr>(); }
9180
9181 /// Return the size expression.
9182 Expr *getSize() const { return getStmtAs<Expr>(); }
9183};
9184
9185/// This represents the 'doacross' clause for the '#pragma omp ordered'
9186/// directive.
9187///
9188/// \code
9189/// #pragma omp ordered doacross(sink: i-1, j-1)
9190/// \endcode
9191/// In this example directive '#pragma omp ordered' with clause 'doacross' with
9192/// a dependence-type 'sink' and loop-iteration vector expressions i-1 and j-1.
9194 : public OMPVarListClause<OMPDoacrossClause>,
9195 private llvm::TrailingObjects<OMPDoacrossClause, Expr *> {
9196 friend class OMPClauseReader;
9197 friend OMPVarListClause;
9198 friend TrailingObjects;
9199
9200 /// Dependence type (sink or source).
9202
9203 /// Dependence type location.
9204 SourceLocation DepLoc;
9205
9206 /// Colon location.
9207 SourceLocation ColonLoc;
9208
9209 /// Number of loops, associated with the doacross clause.
9210 unsigned NumLoops = 0;
9211
9212 /// Build clause with number of expressions \a N.
9213 ///
9214 /// \param StartLoc Starting location of the clause.
9215 /// \param LParenLoc Location of '('.
9216 /// \param EndLoc Ending location of the clause.
9217 /// \param N Number of expressions in the clause.
9218 /// \param NumLoops Number of loops associated with the clause.
9220 SourceLocation EndLoc, unsigned N, unsigned NumLoops)
9221 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross, StartLoc,
9222 LParenLoc, EndLoc, N),
9223 NumLoops(NumLoops) {}
9224
9225 /// Build an empty clause.
9226 ///
9227 /// \param N Number of expressions in the clause.
9228 /// \param NumLoops Number of loops associated with the clause.
9229 explicit OMPDoacrossClause(unsigned N, unsigned NumLoops)
9230 : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross,
9232 SourceLocation(), N),
9233 NumLoops(NumLoops) {}
9234
9235 /// Set dependence type.
9236 void setDependenceType(OpenMPDoacrossClauseModifier M) { DepType = M; }
9237
9238 /// Set dependence type location.
9239 void setDependenceLoc(SourceLocation Loc) { DepLoc = Loc; }
9240
9241 /// Set colon location.
9242 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
9243
9244public:
9245 /// Creates clause with a list of expressions \a VL.
9246 ///
9247 /// \param C AST context.
9248 /// \param StartLoc Starting location of the clause.
9249 /// \param LParenLoc Location of '('.
9250 /// \param EndLoc Ending location of the clause.
9251 /// \param DepType The dependence type.
9252 /// \param DepLoc Location of the dependence type.
9253 /// \param ColonLoc Location of ':'.
9254 /// \param VL List of references to the expressions.
9255 /// \param NumLoops Number of loops that associated with the clause.
9256 static OMPDoacrossClause *
9257 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
9258 SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType,
9259 SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
9260 unsigned NumLoops);
9261
9262 /// Creates an empty clause with \a N expressions.
9263 ///
9264 /// \param C AST context.
9265 /// \param N The number of expressions.
9266 /// \param NumLoops Number of loops that is associated with this clause.
9267 static OMPDoacrossClause *CreateEmpty(const ASTContext &C, unsigned N,
9268 unsigned NumLoops);
9269
9270 /// Get dependence type.
9272
9273 /// Get dependence type location.
9274 SourceLocation getDependenceLoc() const { return DepLoc; }
9275
9276 /// Get colon location.
9277 SourceLocation getColonLoc() const { return ColonLoc; }
9278
9279 /// Get number of loops associated with the clause.
9280 unsigned getNumLoops() const { return NumLoops; }
9281
9282 /// Set the loop data.
9283 void setLoopData(unsigned NumLoop, Expr *Cnt);
9284
9285 /// Get the loop data.
9286 Expr *getLoopData(unsigned NumLoop);
9287 const Expr *getLoopData(unsigned NumLoop) const;
9288
9290 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
9291 reinterpret_cast<Stmt **>(varlist_end()));
9292 }
9293
9295 auto Children = const_cast<OMPDoacrossClause *>(this)->children();
9296 return const_child_range(Children.begin(), Children.end());
9297 }
9298
9301 }
9304 }
9305
9306 static bool classof(const OMPClause *T) {
9307 return T->getClauseKind() == llvm::omp::OMPC_doacross;
9308 }
9309};
9310
9311/// This represents 'ompx_attribute' clause in a directive that might generate
9312/// an outlined function. An example is given below.
9313///
9314/// \code
9315/// #pragma omp target [...] ompx_attribute(flatten)
9316/// \endcode
9318 : public OMPNoChildClause<llvm::omp::OMPC_ompx_attribute> {
9319 friend class OMPClauseReader;
9320
9321 /// Location of '('.
9322 SourceLocation LParenLoc;
9323
9324 /// The parsed attributes (clause arguments)
9326
9327public:
9328 /// Build 'ompx_attribute' clause.
9329 ///
9330 /// \param Attrs The parsed attributes (clause arguments)
9331 /// \param StartLoc Starting location of the clause.
9332 /// \param LParenLoc Location of '('.
9333 /// \param EndLoc Ending location of the clause.
9335 SourceLocation LParenLoc, SourceLocation EndLoc)
9336 : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Attrs(Attrs) {
9337 }
9338
9339 /// Build an empty clause.
9341
9342 /// Sets the location of '('.
9343 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
9344
9345 /// Returns the location of '('.
9346 SourceLocation getLParenLoc() const { return LParenLoc; }
9347
9348 /// Returned the attributes parsed from this clause.
9349 ArrayRef<const Attr *> getAttrs() const { return Attrs; }
9350
9351private:
9352 /// Replace the attributes with \p NewAttrs.
9353 void setAttrs(ArrayRef<Attr *> NewAttrs) {
9354 Attrs.clear();
9355 Attrs.append(NewAttrs.begin(), NewAttrs.end());
9356 }
9357};
9358
9359/// This represents 'ompx_bare' clause in the '#pragma omp target teams ...'
9360/// directive.
9361///
9362/// \code
9363/// #pragma omp target teams ompx_bare
9364/// \endcode
9365/// In this example directive '#pragma omp target teams' has a 'ompx_bare'
9366/// clause.
9367class OMPXBareClause : public OMPNoChildClause<llvm::omp::OMPC_ompx_bare> {
9368public:
9369 /// Build 'ompx_bare' clause.
9370 ///
9371 /// \param StartLoc Starting location of the clause.
9372 /// \param EndLoc Ending location of the clause.
9374 : OMPNoChildClause(StartLoc, EndLoc) {}
9375
9376 /// Build an empty clause.
9377 OMPXBareClause() = default;
9378};
9379
9380} // namespace clang
9381
9382#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
#define V(N, I)
Definition: ASTContext.h:3284
Forward declaration of all AST node types.
MatchType Type
DynTypedNode Node
#define PTR(CLASS)
Definition: AttrVisitor.h:27
int Priority
Definition: Format.cpp:2975
static const Decl * getCanonicalDecl(const Decl *D)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines some OpenMP-specific enums and functions.
Defines the clang::SourceLocation class and associated facilities.
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:182
This captures a statement into a function.
Definition: Stmt.h:3757
This represents one expression.
Definition: Expr.h:110
Represents a function declaration or definition.
Definition: Decl.h:1971
A C++ nested-name-specifier augmented with source location information.
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:388
Expr * getAlignment() const
Returns alignment.
Definition: OpenMPClause.h:420
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:432
const_child_range children() const
Definition: OpenMPClause.h:503
const_child_range used_children() const
Definition: OpenMPClause.h:511
SourceLocation getColonLoc() const
Returns the location of the ':' delimiter.
Definition: OpenMPClause.h:490
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
Definition: OpenMPClause.h:487
child_range used_children()
Definition: OpenMPClause.h:508
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:515
This represents 'allocator' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:354
OMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'allocator' clause with the given allocator.
Definition: OpenMPClause.h:367
OMPAllocatorClause()
Build an empty clause.
Definition: OpenMPClause.h:372
Expr * getAllocator() const
Returns allocator.
Definition: OpenMPClause.h:375
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 'shedule', 'firstprivate' etc.
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.
Definition: OpenMPClause.h:977
OMPCollapseClause()
Build an empty clause.
Definition: OpenMPClause.h:995
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:998
OMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'collapse' clause.
Definition: OpenMPClause.h:990
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 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 '('.
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:630
child_range used_children()
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:658
OMPFinalClause(Expr *Cond, Stmt *HelperCond, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'final' clause with condition Cond.
Definition: OpenMPClause.h:646
OMPFinalClause()
Build an empty clause.
Definition: OpenMPClause.h:655
const_child_range used_children() const
Definition: OpenMPClause.h:661
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:879
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 'if' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:527
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:587
const_child_range used_children() const
Definition: OpenMPClause.h:611
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:590
SourceLocation getColonLoc() const
Return the location of ':'.
Definition: OpenMPClause.h:593
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:616
child_range used_children()
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:596
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Definition: OpenMPClause.h:599
OMPIfClause()
Build an empty clause.
Definition: OpenMPClause.h:582
child_range children()
Definition: OpenMPClause.h:604
const_child_range children() const
Definition: OpenMPClause.h:606
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:570
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
Definition: OpenMPClause.h:602
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 '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.
Expr * getNumTeams()
Return NumTeams number.
OMPNumTeamsClause()
Build an empty clause.
SourceLocation getLParenLoc() const
Returns the location of '('.
OMPNumTeamsClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'num_teams' clause.
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 '('.
Expr * getNumTeams() const
Return NumTeams number.
This represents 'num_threads' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:676
OMPNumThreadsClause()
Build an empty clause.
Definition: OpenMPClause.h:702
OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'num_threads' clause with condition NumThreads.
Definition: OpenMPClause.h:692
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:705
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:907
child_range used_children()
Definition: OpenMPClause.h:953
static OMPPartialClause * CreateEmpty(const ASTContext &C)
Build an empty 'partial' AST node for deserialization.
const_child_range used_children() const
Definition: OpenMPClause.h:956
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:943
const_child_range children() const
Definition: OpenMPClause.h:949
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:960
child_range children()
Definition: OpenMPClause.h:948
Expr * getFactor() const
Returns the argument of the clause or nullptr if not set.
Definition: OpenMPClause.h:946
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:721
OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'safelen' clause.
Definition: OpenMPClause.h:733
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:741
OMPSafelenClause()
Build an empty clause.
Definition: OpenMPClause.h:738
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:756
OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'simdlen' clause.
Definition: OpenMPClause.h:768
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:776
OMPSimdlenClause()
Build an empty clause.
Definition: OpenMPClause.h:773
This represents the 'sizes' clause in the '#pragma omp tile' directive.
Definition: OpenMPClause.h:788
SourceLocation getLParenLoc() const
Returns the location of '('.
Definition: OpenMPClause.h:825
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:822
child_range children()
Definition: OpenMPClause.h:850
static bool classof(const OMPClause *T)
Definition: OpenMPClause.h:868
const_child_range used_children() const
Definition: OpenMPClause.h:864
void setSizesRefs(ArrayRef< Expr * > VL)
Sets the tile size expressions.
Definition: OpenMPClause.h:843
unsigned getNumSizes() const
Returns the number of list items.
Definition: OpenMPClause.h:828
child_range used_children()
Definition: OpenMPClause.h:861
MutableArrayRef< Expr * > getSizesRefs()
Returns the tile size expressions.
Definition: OpenMPClause.h:831
ArrayRef< Expr * > getSizesRefs() const
Definition: OpenMPClause.h:836
const_child_range children() const
Definition: OpenMPClause.h:855
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 '('.
const_child_range children() const
OMPThreadLimitClause()
Build an empty clause.
SourceLocation getLParenLoc() const
Returns the location of '('.
Expr * getThreadLimit()
Return ThreadLimit number.
Expr * getThreadLimit() const
Return ThreadLimit number.
const_child_range used_children() const
static bool classof(const OMPClause *T)
OMPThreadLimitClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'thread_limit' clause.
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
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
varlist_const_range varlists() const
Definition: OpenMPClause.h:322
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_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
varlist_range varlists()
Definition: OpenMPClause.h:319
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:1447
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:706
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'copyin' 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:291
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:21
#define bool
Definition: stdbool.h:20
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