1 //===- OpenMPClause.h - Classes for OpenMP clauses --------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// \brief 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.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CLANG_AST_OPENMPCLAUSE_H
17 #define LLVM_CLANG_AST_OPENMPCLAUSE_H
19 #include "clang/AST/Expr.h"
20 #include "clang/AST/Stmt.h"
21 #include "clang/Basic/OpenMPKinds.h"
22 #include "clang/Basic/SourceLocation.h"
26 //===----------------------------------------------------------------------===//
27 // AST classes for clauses.
28 //===----------------------------------------------------------------------===//
30 /// \brief This is a basic class for representing single OpenMP clause.
33 /// \brief Starting location of the clause (the clause keyword).
34 SourceLocation StartLoc;
35 /// \brief Ending location of the clause.
36 SourceLocation EndLoc;
37 /// \brief Kind of the clause.
38 OpenMPClauseKind Kind;
41 OMPClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation EndLoc)
42 : StartLoc(StartLoc), EndLoc(EndLoc), Kind(K) {}
45 /// \brief Returns the starting location of the clause.
46 SourceLocation getLocStart() const { return StartLoc; }
47 /// \brief Returns the ending location of the clause.
48 SourceLocation getLocEnd() const { return EndLoc; }
50 /// \brief Sets the starting location of the clause.
51 void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
52 /// \brief Sets the ending location of the clause.
53 void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
55 /// \brief Returns kind of OpenMP clause (private, shared, reduction, etc.).
56 OpenMPClauseKind getClauseKind() const { return Kind; }
58 bool isImplicit() const { return StartLoc.isInvalid(); }
60 typedef StmtIterator child_iterator;
61 typedef ConstStmtIterator const_child_iterator;
62 typedef llvm::iterator_range<child_iterator> child_range;
63 typedef llvm::iterator_range<const_child_iterator> const_child_range;
65 child_range children();
66 const_child_range children() const {
67 auto Children = const_cast<OMPClause *>(this)->children();
68 return const_child_range(Children.begin(), Children.end());
70 static bool classof(const OMPClause *) { return true; }
73 /// Class that handles pre-initialization statement for some clauses, like
74 /// 'shedule', 'firstprivate' etc.
75 class OMPClauseWithPreInit {
76 friend class OMPClauseReader;
77 /// Pre-initialization statement for the clause.
79 /// Region that captures the associated stmt.
80 OpenMPDirectiveKind CaptureRegion;
83 /// Set pre-initialization statement for the clause.
84 void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion = OMPD_unknown) {
86 CaptureRegion = ThisRegion;
88 OMPClauseWithPreInit(const OMPClause *This)
89 : PreInit(nullptr), CaptureRegion(OMPD_unknown) {
90 assert(get(This) && "get is not tuned for pre-init.");
94 /// Get pre-initialization statement for the clause.
95 const Stmt *getPreInitStmt() const { return PreInit; }
96 /// Get pre-initialization statement for the clause.
97 Stmt *getPreInitStmt() { return PreInit; }
98 /// Get capture region for the stmt in the clause.
99 OpenMPDirectiveKind getCaptureRegion() { return CaptureRegion; }
100 static OMPClauseWithPreInit *get(OMPClause *C);
101 static const OMPClauseWithPreInit *get(const OMPClause *C);
104 /// Class that handles post-update expression for some clauses, like
105 /// 'lastprivate', 'reduction' etc.
106 class OMPClauseWithPostUpdate : public OMPClauseWithPreInit {
107 friend class OMPClauseReader;
108 /// Post-update expression for the clause.
111 /// Set pre-initialization statement for the clause.
112 void setPostUpdateExpr(Expr *S) { PostUpdate = S; }
113 OMPClauseWithPostUpdate(const OMPClause *This)
114 : OMPClauseWithPreInit(This), PostUpdate(nullptr) {
115 assert(get(This) && "get is not tuned for post-update.");
119 /// Get post-update expression for the clause.
120 const Expr *getPostUpdateExpr() const { return PostUpdate; }
121 /// Get post-update expression for the clause.
122 Expr *getPostUpdateExpr() { return PostUpdate; }
123 static OMPClauseWithPostUpdate *get(OMPClause *C);
124 static const OMPClauseWithPostUpdate *get(const OMPClause *C);
127 /// \brief This represents clauses with the list of variables like 'private',
128 /// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
129 /// '#pragma omp ...' directives.
130 template <class T> class OMPVarListClause : public OMPClause {
131 friend class OMPClauseReader;
132 /// \brief Location of '('.
133 SourceLocation LParenLoc;
134 /// \brief Number of variables in the list.
138 /// \brief Fetches list of variables associated with this clause.
139 MutableArrayRef<Expr *> getVarRefs() {
140 return MutableArrayRef<Expr *>(
141 static_cast<T *>(this)->template getTrailingObjects<Expr *>(), NumVars);
144 /// \brief Sets the list of variables for this clause.
145 void setVarRefs(ArrayRef<Expr *> VL) {
146 assert(VL.size() == NumVars &&
147 "Number of variables is not the same as the preallocated buffer");
148 std::copy(VL.begin(), VL.end(),
149 static_cast<T *>(this)->template getTrailingObjects<Expr *>());
152 /// \brief Build a clause with \a N variables
154 /// \param K Kind of the clause.
155 /// \param StartLoc Starting location of the clause (the clause keyword).
156 /// \param LParenLoc Location of '('.
157 /// \param EndLoc Ending location of the clause.
158 /// \param N Number of the variables in the clause.
160 OMPVarListClause(OpenMPClauseKind K, SourceLocation StartLoc,
161 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
162 : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {}
165 typedef MutableArrayRef<Expr *>::iterator varlist_iterator;
166 typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
167 typedef llvm::iterator_range<varlist_iterator> varlist_range;
168 typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
170 unsigned varlist_size() const { return NumVars; }
171 bool varlist_empty() const { return NumVars == 0; }
173 varlist_range varlists() {
174 return varlist_range(varlist_begin(), varlist_end());
176 varlist_const_range varlists() const {
177 return varlist_const_range(varlist_begin(), varlist_end());
180 varlist_iterator varlist_begin() { return getVarRefs().begin(); }
181 varlist_iterator varlist_end() { return getVarRefs().end(); }
182 varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
183 varlist_const_iterator varlist_end() const { return getVarRefs().end(); }
185 /// \brief Sets the location of '('.
186 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
187 /// \brief Returns the location of '('.
188 SourceLocation getLParenLoc() const { return LParenLoc; }
190 /// \brief Fetches list of all variables in the clause.
191 ArrayRef<const Expr *> getVarRefs() const {
192 return llvm::makeArrayRef(
193 static_cast<const T *>(this)->template getTrailingObjects<Expr *>(),
198 /// \brief This represents 'if' clause in the '#pragma omp ...' directive.
201 /// #pragma omp parallel if(parallel:a > 5)
203 /// In this example directive '#pragma omp parallel' has simple 'if' clause with
204 /// condition 'a > 5' and directive name modifier 'parallel'.
206 class OMPIfClause : public OMPClause, public OMPClauseWithPreInit {
207 friend class OMPClauseReader;
208 /// \brief Location of '('.
209 SourceLocation LParenLoc;
210 /// \brief Condition of the 'if' clause.
212 /// \brief Location of ':' (if any).
213 SourceLocation ColonLoc;
214 /// \brief Directive name modifier for the clause.
215 OpenMPDirectiveKind NameModifier;
216 /// \brief Name modifier location.
217 SourceLocation NameModifierLoc;
219 /// \brief Set condition.
221 void setCondition(Expr *Cond) { Condition = Cond; }
222 /// \brief Set directive name modifier for the clause.
224 void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
225 /// \brief Set location of directive name modifier for the clause.
227 void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
228 /// \brief Set location of ':'.
230 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
233 /// \brief Build 'if' clause with condition \a Cond.
235 /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
236 /// \param Cond Condition of the clause.
237 /// \param HelperCond Helper condition for the clause.
238 /// \param CaptureRegion Innermost OpenMP region where expressions in this
239 /// clause must be captured.
240 /// \param StartLoc Starting location of the clause.
241 /// \param LParenLoc Location of '('.
242 /// \param NameModifierLoc Location of directive name modifier.
243 /// \param ColonLoc [OpenMP 4.1] Location of ':'.
244 /// \param EndLoc Ending location of the clause.
246 OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond,
247 OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
248 SourceLocation LParenLoc, SourceLocation NameModifierLoc,
249 SourceLocation ColonLoc, SourceLocation EndLoc)
250 : OMPClause(OMPC_if, StartLoc, EndLoc), OMPClauseWithPreInit(this),
251 LParenLoc(LParenLoc), Condition(Cond), ColonLoc(ColonLoc),
252 NameModifier(NameModifier), NameModifierLoc(NameModifierLoc) {
253 setPreInitStmt(HelperCond, CaptureRegion);
256 /// \brief Build an empty clause.
259 : OMPClause(OMPC_if, SourceLocation(), SourceLocation()),
260 OMPClauseWithPreInit(this), LParenLoc(), Condition(nullptr), ColonLoc(),
261 NameModifier(OMPD_unknown), NameModifierLoc() {}
263 /// \brief Sets the location of '('.
264 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
265 /// \brief Returns the location of '('.
266 SourceLocation getLParenLoc() const { return LParenLoc; }
268 /// \brief Return the location of ':'.
269 SourceLocation getColonLoc() const { return ColonLoc; }
271 /// \brief Returns condition.
272 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
273 /// \brief Return directive name modifier associated with the clause.
274 OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
276 /// \brief Return the location of directive name modifier.
277 SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
279 static bool classof(const OMPClause *T) {
280 return T->getClauseKind() == OMPC_if;
283 child_range children() { return child_range(&Condition, &Condition + 1); }
286 /// \brief This represents 'final' clause in the '#pragma omp ...' directive.
289 /// #pragma omp task final(a > 5)
291 /// In this example directive '#pragma omp task' has simple 'final'
292 /// clause with condition 'a > 5'.
294 class OMPFinalClause : public OMPClause {
295 friend class OMPClauseReader;
296 /// \brief Location of '('.
297 SourceLocation LParenLoc;
298 /// \brief Condition of the 'if' clause.
301 /// \brief Set condition.
303 void setCondition(Expr *Cond) { Condition = Cond; }
306 /// \brief Build 'final' clause with condition \a Cond.
308 /// \param StartLoc Starting location of the clause.
309 /// \param LParenLoc Location of '('.
310 /// \param Cond Condition of the clause.
311 /// \param EndLoc Ending location of the clause.
313 OMPFinalClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,
314 SourceLocation EndLoc)
315 : OMPClause(OMPC_final, StartLoc, EndLoc), LParenLoc(LParenLoc),
318 /// \brief Build an empty clause.
321 : OMPClause(OMPC_final, SourceLocation(), SourceLocation()),
322 LParenLoc(SourceLocation()), Condition(nullptr) {}
324 /// \brief Sets the location of '('.
325 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
326 /// \brief Returns the location of '('.
327 SourceLocation getLParenLoc() const { return LParenLoc; }
329 /// \brief Returns condition.
330 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
332 static bool classof(const OMPClause *T) {
333 return T->getClauseKind() == OMPC_final;
336 child_range children() { return child_range(&Condition, &Condition + 1); }
339 /// \brief This represents 'num_threads' clause in the '#pragma omp ...'
343 /// #pragma omp parallel num_threads(6)
345 /// In this example directive '#pragma omp parallel' has simple 'num_threads'
346 /// clause with number of threads '6'.
348 class OMPNumThreadsClause : public OMPClause, public OMPClauseWithPreInit {
349 friend class OMPClauseReader;
350 /// \brief Location of '('.
351 SourceLocation LParenLoc;
352 /// \brief Condition of the 'num_threads' clause.
355 /// \brief Set condition.
357 void setNumThreads(Expr *NThreads) { NumThreads = NThreads; }
360 /// \brief Build 'num_threads' clause with condition \a NumThreads.
362 /// \param NumThreads Number of threads for the construct.
363 /// \param HelperNumThreads Helper Number of threads for the construct.
364 /// \param CaptureRegion Innermost OpenMP region where expressions in this
365 /// clause must be captured.
366 /// \param StartLoc Starting location of the clause.
367 /// \param LParenLoc Location of '('.
368 /// \param EndLoc Ending location of the clause.
370 OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads,
371 OpenMPDirectiveKind CaptureRegion,
372 SourceLocation StartLoc, SourceLocation LParenLoc,
373 SourceLocation EndLoc)
374 : OMPClause(OMPC_num_threads, StartLoc, EndLoc),
375 OMPClauseWithPreInit(this), LParenLoc(LParenLoc),
376 NumThreads(NumThreads) {
377 setPreInitStmt(HelperNumThreads, CaptureRegion);
380 /// \brief Build an empty clause.
382 OMPNumThreadsClause()
383 : OMPClause(OMPC_num_threads, SourceLocation(), SourceLocation()),
384 OMPClauseWithPreInit(this), LParenLoc(SourceLocation()),
385 NumThreads(nullptr) {}
387 /// \brief Sets the location of '('.
388 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
389 /// \brief Returns the location of '('.
390 SourceLocation getLParenLoc() const { return LParenLoc; }
392 /// \brief Returns number of threads.
393 Expr *getNumThreads() const { return cast_or_null<Expr>(NumThreads); }
395 static bool classof(const OMPClause *T) {
396 return T->getClauseKind() == OMPC_num_threads;
399 child_range children() { return child_range(&NumThreads, &NumThreads + 1); }
402 /// \brief This represents 'safelen' clause in the '#pragma omp ...'
406 /// #pragma omp simd safelen(4)
408 /// In this example directive '#pragma omp simd' has clause 'safelen'
409 /// with single expression '4'.
410 /// If the safelen clause is used then no two iterations executed
411 /// concurrently with SIMD instructions can have a greater distance
412 /// in the logical iteration space than its value. The parameter of
413 /// the safelen clause must be a constant positive integer expression.
415 class OMPSafelenClause : public OMPClause {
416 friend class OMPClauseReader;
417 /// \brief Location of '('.
418 SourceLocation LParenLoc;
419 /// \brief Safe iteration space distance.
422 /// \brief Set safelen.
423 void setSafelen(Expr *Len) { Safelen = Len; }
426 /// \brief Build 'safelen' clause.
428 /// \param Len Expression associated with this clause.
429 /// \param StartLoc Starting location of the clause.
430 /// \param EndLoc Ending location of the clause.
432 OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc,
433 SourceLocation EndLoc)
434 : OMPClause(OMPC_safelen, StartLoc, EndLoc), LParenLoc(LParenLoc),
437 /// \brief Build an empty clause.
439 explicit OMPSafelenClause()
440 : OMPClause(OMPC_safelen, SourceLocation(), SourceLocation()),
441 LParenLoc(SourceLocation()), Safelen(nullptr) {}
443 /// \brief Sets the location of '('.
444 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
445 /// \brief Returns the location of '('.
446 SourceLocation getLParenLoc() const { return LParenLoc; }
448 /// \brief Return safe iteration space distance.
449 Expr *getSafelen() const { return cast_or_null<Expr>(Safelen); }
451 static bool classof(const OMPClause *T) {
452 return T->getClauseKind() == OMPC_safelen;
455 child_range children() { return child_range(&Safelen, &Safelen + 1); }
458 /// \brief This represents 'simdlen' clause in the '#pragma omp ...'
462 /// #pragma omp simd simdlen(4)
464 /// In this example directive '#pragma omp simd' has clause 'simdlen'
465 /// with single expression '4'.
466 /// If the 'simdlen' clause is used then it specifies the preferred number of
467 /// iterations to be executed concurrently. The parameter of the 'simdlen'
468 /// clause must be a constant positive integer expression.
470 class OMPSimdlenClause : public OMPClause {
471 friend class OMPClauseReader;
472 /// \brief Location of '('.
473 SourceLocation LParenLoc;
474 /// \brief Safe iteration space distance.
477 /// \brief Set simdlen.
478 void setSimdlen(Expr *Len) { Simdlen = Len; }
481 /// \brief Build 'simdlen' clause.
483 /// \param Len Expression associated with this clause.
484 /// \param StartLoc Starting location of the clause.
485 /// \param EndLoc Ending location of the clause.
487 OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc,
488 SourceLocation EndLoc)
489 : OMPClause(OMPC_simdlen, StartLoc, EndLoc), LParenLoc(LParenLoc),
492 /// \brief Build an empty clause.
494 explicit OMPSimdlenClause()
495 : OMPClause(OMPC_simdlen, SourceLocation(), SourceLocation()),
496 LParenLoc(SourceLocation()), Simdlen(nullptr) {}
498 /// \brief Sets the location of '('.
499 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
500 /// \brief Returns the location of '('.
501 SourceLocation getLParenLoc() const { return LParenLoc; }
503 /// \brief Return safe iteration space distance.
504 Expr *getSimdlen() const { return cast_or_null<Expr>(Simdlen); }
506 static bool classof(const OMPClause *T) {
507 return T->getClauseKind() == OMPC_simdlen;
510 child_range children() { return child_range(&Simdlen, &Simdlen + 1); }
513 /// \brief This represents 'collapse' clause in the '#pragma omp ...'
517 /// #pragma omp simd collapse(3)
519 /// In this example directive '#pragma omp simd' has clause 'collapse'
520 /// with single expression '3'.
521 /// The parameter must be a constant positive integer expression, it specifies
522 /// the number of nested loops that should be collapsed into a single iteration
525 class OMPCollapseClause : public OMPClause {
526 friend class OMPClauseReader;
527 /// \brief Location of '('.
528 SourceLocation LParenLoc;
529 /// \brief Number of for-loops.
532 /// \brief Set the number of associated for-loops.
533 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
536 /// \brief Build 'collapse' clause.
538 /// \param Num Expression associated with this clause.
539 /// \param StartLoc Starting location of the clause.
540 /// \param LParenLoc Location of '('.
541 /// \param EndLoc Ending location of the clause.
543 OMPCollapseClause(Expr *Num, SourceLocation StartLoc,
544 SourceLocation LParenLoc, SourceLocation EndLoc)
545 : OMPClause(OMPC_collapse, StartLoc, EndLoc), LParenLoc(LParenLoc),
548 /// \brief Build an empty clause.
550 explicit OMPCollapseClause()
551 : OMPClause(OMPC_collapse, SourceLocation(), SourceLocation()),
552 LParenLoc(SourceLocation()), NumForLoops(nullptr) {}
554 /// \brief Sets the location of '('.
555 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
556 /// \brief Returns the location of '('.
557 SourceLocation getLParenLoc() const { return LParenLoc; }
559 /// \brief Return the number of associated for-loops.
560 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
562 static bool classof(const OMPClause *T) {
563 return T->getClauseKind() == OMPC_collapse;
566 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
569 /// \brief This represents 'default' clause in the '#pragma omp ...' directive.
572 /// #pragma omp parallel default(shared)
574 /// In this example directive '#pragma omp parallel' has simple 'default'
575 /// clause with kind 'shared'.
577 class OMPDefaultClause : public OMPClause {
578 friend class OMPClauseReader;
579 /// \brief Location of '('.
580 SourceLocation LParenLoc;
581 /// \brief A kind of the 'default' clause.
582 OpenMPDefaultClauseKind Kind;
583 /// \brief Start location of the kind in source code.
584 SourceLocation KindKwLoc;
586 /// \brief Set kind of the clauses.
588 /// \param K Argument of clause.
590 void setDefaultKind(OpenMPDefaultClauseKind K) { Kind = K; }
592 /// \brief Set argument location.
594 /// \param KLoc Argument location.
596 void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
599 /// \brief Build 'default' clause with argument \a A ('none' or 'shared').
601 /// \param A Argument of the clause ('none' or 'shared').
602 /// \param ALoc Starting location of the argument.
603 /// \param StartLoc Starting location of the clause.
604 /// \param LParenLoc Location of '('.
605 /// \param EndLoc Ending location of the clause.
607 OMPDefaultClause(OpenMPDefaultClauseKind A, SourceLocation ALoc,
608 SourceLocation StartLoc, SourceLocation LParenLoc,
609 SourceLocation EndLoc)
610 : OMPClause(OMPC_default, StartLoc, EndLoc), LParenLoc(LParenLoc),
611 Kind(A), KindKwLoc(ALoc) {}
613 /// \brief Build an empty clause.
616 : OMPClause(OMPC_default, SourceLocation(), SourceLocation()),
617 LParenLoc(SourceLocation()), Kind(OMPC_DEFAULT_unknown),
618 KindKwLoc(SourceLocation()) {}
620 /// \brief Sets the location of '('.
621 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
622 /// \brief Returns the location of '('.
623 SourceLocation getLParenLoc() const { return LParenLoc; }
625 /// \brief Returns kind of the clause.
626 OpenMPDefaultClauseKind getDefaultKind() const { return Kind; }
628 /// \brief Returns location of clause kind.
629 SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
631 static bool classof(const OMPClause *T) {
632 return T->getClauseKind() == OMPC_default;
635 child_range children() {
636 return child_range(child_iterator(), child_iterator());
640 /// \brief This represents 'proc_bind' clause in the '#pragma omp ...'
644 /// #pragma omp parallel proc_bind(master)
646 /// In this example directive '#pragma omp parallel' has simple 'proc_bind'
647 /// clause with kind 'master'.
649 class OMPProcBindClause : public OMPClause {
650 friend class OMPClauseReader;
651 /// \brief Location of '('.
652 SourceLocation LParenLoc;
653 /// \brief A kind of the 'proc_bind' clause.
654 OpenMPProcBindClauseKind Kind;
655 /// \brief Start location of the kind in source code.
656 SourceLocation KindKwLoc;
658 /// \brief Set kind of the clause.
660 /// \param K Kind of clause.
662 void setProcBindKind(OpenMPProcBindClauseKind K) { Kind = K; }
664 /// \brief Set clause kind location.
666 /// \param KLoc Kind location.
668 void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
671 /// \brief Build 'proc_bind' clause with argument \a A ('master', 'close' or
674 /// \param A Argument of the clause ('master', 'close' or 'spread').
675 /// \param ALoc Starting location of the argument.
676 /// \param StartLoc Starting location of the clause.
677 /// \param LParenLoc Location of '('.
678 /// \param EndLoc Ending location of the clause.
680 OMPProcBindClause(OpenMPProcBindClauseKind A, SourceLocation ALoc,
681 SourceLocation StartLoc, SourceLocation LParenLoc,
682 SourceLocation EndLoc)
683 : OMPClause(OMPC_proc_bind, StartLoc, EndLoc), LParenLoc(LParenLoc),
684 Kind(A), KindKwLoc(ALoc) {}
686 /// \brief Build an empty clause.
689 : OMPClause(OMPC_proc_bind, SourceLocation(), SourceLocation()),
690 LParenLoc(SourceLocation()), Kind(OMPC_PROC_BIND_unknown),
691 KindKwLoc(SourceLocation()) {}
693 /// \brief Sets the location of '('.
694 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
695 /// \brief Returns the location of '('.
696 SourceLocation getLParenLoc() const { return LParenLoc; }
698 /// \brief Returns kind of the clause.
699 OpenMPProcBindClauseKind getProcBindKind() const { return Kind; }
701 /// \brief Returns location of clause kind.
702 SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
704 static bool classof(const OMPClause *T) {
705 return T->getClauseKind() == OMPC_proc_bind;
708 child_range children() {
709 return child_range(child_iterator(), child_iterator());
713 /// \brief This represents 'schedule' clause in the '#pragma omp ...' directive.
716 /// #pragma omp for schedule(static, 3)
718 /// In this example directive '#pragma omp for' has 'schedule' clause with
719 /// arguments 'static' and '3'.
721 class OMPScheduleClause : public OMPClause, public OMPClauseWithPreInit {
722 friend class OMPClauseReader;
723 /// \brief Location of '('.
724 SourceLocation LParenLoc;
725 /// \brief A kind of the 'schedule' clause.
726 OpenMPScheduleClauseKind Kind;
727 /// \brief Modifiers for 'schedule' clause.
728 enum {FIRST, SECOND, NUM_MODIFIERS};
729 OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
730 /// \brief Locations of modifiers.
731 SourceLocation ModifiersLoc[NUM_MODIFIERS];
732 /// \brief Start location of the schedule ind in source code.
733 SourceLocation KindLoc;
734 /// \brief Location of ',' (if any).
735 SourceLocation CommaLoc;
736 /// \brief Chunk size.
739 /// \brief Set schedule kind.
741 /// \param K Schedule kind.
743 void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
744 /// \brief Set the first schedule modifier.
746 /// \param M Schedule modifier.
748 void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
749 Modifiers[FIRST] = M;
751 /// \brief Set the second schedule modifier.
753 /// \param M Schedule modifier.
755 void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
756 Modifiers[SECOND] = M;
758 /// \brief Set location of the first schedule modifier.
760 void setFirstScheduleModifierLoc(SourceLocation Loc) {
761 ModifiersLoc[FIRST] = Loc;
763 /// \brief Set location of the second schedule modifier.
765 void setSecondScheduleModifierLoc(SourceLocation Loc) {
766 ModifiersLoc[SECOND] = Loc;
768 /// \brief Set schedule modifier location.
770 /// \param M Schedule modifier location.
772 void setScheduleModifer(OpenMPScheduleClauseModifier M) {
773 if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
774 Modifiers[FIRST] = M;
776 assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
777 Modifiers[SECOND] = M;
780 /// \brief Sets the location of '('.
782 /// \param Loc Location of '('.
784 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
785 /// \brief Set schedule kind start location.
787 /// \param KLoc Schedule kind location.
789 void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
790 /// \brief Set location of ','.
792 /// \param Loc Location of ','.
794 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
795 /// \brief Set chunk size.
797 /// \param E Chunk size.
799 void setChunkSize(Expr *E) { ChunkSize = E; }
802 /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size
803 /// expression \a ChunkSize.
805 /// \param StartLoc Starting location of the clause.
806 /// \param LParenLoc Location of '('.
807 /// \param KLoc Starting location of the argument.
808 /// \param CommaLoc Location of ','.
809 /// \param EndLoc Ending location of the clause.
810 /// \param Kind Schedule kind.
811 /// \param ChunkSize Chunk size.
812 /// \param HelperChunkSize Helper chunk size for combined directives.
813 /// \param M1 The first modifier applied to 'schedule' clause.
814 /// \param M1Loc Location of the first modifier
815 /// \param M2 The second modifier applied to 'schedule' clause.
816 /// \param M2Loc Location of the second modifier
818 OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
819 SourceLocation KLoc, SourceLocation CommaLoc,
820 SourceLocation EndLoc, OpenMPScheduleClauseKind Kind,
821 Expr *ChunkSize, Stmt *HelperChunkSize,
822 OpenMPScheduleClauseModifier M1, SourceLocation M1Loc,
823 OpenMPScheduleClauseModifier M2, SourceLocation M2Loc)
824 : OMPClause(OMPC_schedule, StartLoc, EndLoc), OMPClauseWithPreInit(this),
825 LParenLoc(LParenLoc), Kind(Kind), KindLoc(KLoc), CommaLoc(CommaLoc),
826 ChunkSize(ChunkSize) {
827 setPreInitStmt(HelperChunkSize);
828 Modifiers[FIRST] = M1;
829 Modifiers[SECOND] = M2;
830 ModifiersLoc[FIRST] = M1Loc;
831 ModifiersLoc[SECOND] = M2Loc;
834 /// \brief Build an empty clause.
836 explicit OMPScheduleClause()
837 : OMPClause(OMPC_schedule, SourceLocation(), SourceLocation()),
838 OMPClauseWithPreInit(this), Kind(OMPC_SCHEDULE_unknown),
840 Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
841 Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
844 /// \brief Get kind of the clause.
846 OpenMPScheduleClauseKind getScheduleKind() const { return Kind; }
847 /// \brief Get the first modifier of the clause.
849 OpenMPScheduleClauseModifier getFirstScheduleModifier() const {
850 return Modifiers[FIRST];
852 /// \brief Get the second modifier of the clause.
854 OpenMPScheduleClauseModifier getSecondScheduleModifier() const {
855 return Modifiers[SECOND];
857 /// \brief Get location of '('.
859 SourceLocation getLParenLoc() { return LParenLoc; }
860 /// \brief Get kind location.
862 SourceLocation getScheduleKindLoc() { return KindLoc; }
863 /// \brief Get the first modifier location.
865 SourceLocation getFirstScheduleModifierLoc() const {
866 return ModifiersLoc[FIRST];
868 /// \brief Get the second modifier location.
870 SourceLocation getSecondScheduleModifierLoc() const {
871 return ModifiersLoc[SECOND];
873 /// \brief Get location of ','.
875 SourceLocation getCommaLoc() { return CommaLoc; }
876 /// \brief Get chunk size.
878 Expr *getChunkSize() { return ChunkSize; }
879 /// \brief Get chunk size.
881 const Expr *getChunkSize() const { return ChunkSize; }
883 static bool classof(const OMPClause *T) {
884 return T->getClauseKind() == OMPC_schedule;
887 child_range children() {
888 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
889 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
893 /// \brief This represents 'ordered' clause in the '#pragma omp ...' directive.
896 /// #pragma omp for ordered (2)
898 /// In this example directive '#pragma omp for' has 'ordered' clause with
901 class OMPOrderedClause : public OMPClause {
902 friend class OMPClauseReader;
903 /// \brief Location of '('.
904 SourceLocation LParenLoc;
905 /// \brief Number of for-loops.
908 /// \brief Set the number of associated for-loops.
909 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
912 /// \brief Build 'ordered' clause.
914 /// \param Num Expression, possibly associated with this clause.
915 /// \param StartLoc Starting location of the clause.
916 /// \param LParenLoc Location of '('.
917 /// \param EndLoc Ending location of the clause.
919 OMPOrderedClause(Expr *Num, SourceLocation StartLoc,
920 SourceLocation LParenLoc, SourceLocation EndLoc)
921 : OMPClause(OMPC_ordered, StartLoc, EndLoc), LParenLoc(LParenLoc),
924 /// \brief Build an empty clause.
926 explicit OMPOrderedClause()
927 : OMPClause(OMPC_ordered, SourceLocation(), SourceLocation()),
928 LParenLoc(SourceLocation()), NumForLoops(nullptr) {}
930 /// \brief Sets the location of '('.
931 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
932 /// \brief Returns the location of '('.
933 SourceLocation getLParenLoc() const { return LParenLoc; }
935 /// \brief Return the number of associated for-loops.
936 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
938 static bool classof(const OMPClause *T) {
939 return T->getClauseKind() == OMPC_ordered;
942 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
945 /// \brief This represents 'nowait' clause in the '#pragma omp ...' directive.
948 /// #pragma omp for nowait
950 /// In this example directive '#pragma omp for' has 'nowait' clause.
952 class OMPNowaitClause : public OMPClause {
954 /// \brief Build 'nowait' clause.
956 /// \param StartLoc Starting location of the clause.
957 /// \param EndLoc Ending location of the clause.
959 OMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc)
960 : OMPClause(OMPC_nowait, StartLoc, EndLoc) {}
962 /// \brief Build an empty clause.
965 : OMPClause(OMPC_nowait, SourceLocation(), SourceLocation()) {}
967 static bool classof(const OMPClause *T) {
968 return T->getClauseKind() == OMPC_nowait;
971 child_range children() {
972 return child_range(child_iterator(), child_iterator());
976 /// \brief This represents 'untied' clause in the '#pragma omp ...' directive.
979 /// #pragma omp task untied
981 /// In this example directive '#pragma omp task' has 'untied' clause.
983 class OMPUntiedClause : public OMPClause {
985 /// \brief Build 'untied' clause.
987 /// \param StartLoc Starting location of the clause.
988 /// \param EndLoc Ending location of the clause.
990 OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
991 : OMPClause(OMPC_untied, StartLoc, EndLoc) {}
993 /// \brief Build an empty clause.
996 : OMPClause(OMPC_untied, SourceLocation(), SourceLocation()) {}
998 static bool classof(const OMPClause *T) {
999 return T->getClauseKind() == OMPC_untied;
1002 child_range children() {
1003 return child_range(child_iterator(), child_iterator());
1007 /// \brief This represents 'mergeable' clause in the '#pragma omp ...'
1011 /// #pragma omp task mergeable
1013 /// In this example directive '#pragma omp task' has 'mergeable' clause.
1015 class OMPMergeableClause : public OMPClause {
1017 /// \brief Build 'mergeable' clause.
1019 /// \param StartLoc Starting location of the clause.
1020 /// \param EndLoc Ending location of the clause.
1022 OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc)
1023 : OMPClause(OMPC_mergeable, StartLoc, EndLoc) {}
1025 /// \brief Build an empty clause.
1027 OMPMergeableClause()
1028 : OMPClause(OMPC_mergeable, SourceLocation(), SourceLocation()) {}
1030 static bool classof(const OMPClause *T) {
1031 return T->getClauseKind() == OMPC_mergeable;
1034 child_range children() {
1035 return child_range(child_iterator(), child_iterator());
1039 /// \brief This represents 'read' clause in the '#pragma omp atomic' directive.
1042 /// #pragma omp atomic read
1044 /// In this example directive '#pragma omp atomic' has 'read' clause.
1046 class OMPReadClause : public OMPClause {
1048 /// \brief Build 'read' clause.
1050 /// \param StartLoc Starting location of the clause.
1051 /// \param EndLoc Ending location of the clause.
1053 OMPReadClause(SourceLocation StartLoc, SourceLocation EndLoc)
1054 : OMPClause(OMPC_read, StartLoc, EndLoc) {}
1056 /// \brief Build an empty clause.
1058 OMPReadClause() : OMPClause(OMPC_read, SourceLocation(), SourceLocation()) {}
1060 static bool classof(const OMPClause *T) {
1061 return T->getClauseKind() == OMPC_read;
1064 child_range children() {
1065 return child_range(child_iterator(), child_iterator());
1069 /// \brief This represents 'write' clause in the '#pragma omp atomic' directive.
1072 /// #pragma omp atomic write
1074 /// In this example directive '#pragma omp atomic' has 'write' clause.
1076 class OMPWriteClause : public OMPClause {
1078 /// \brief Build 'write' clause.
1080 /// \param StartLoc Starting location of the clause.
1081 /// \param EndLoc Ending location of the clause.
1083 OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc)
1084 : OMPClause(OMPC_write, StartLoc, EndLoc) {}
1086 /// \brief Build an empty clause.
1089 : OMPClause(OMPC_write, SourceLocation(), SourceLocation()) {}
1091 static bool classof(const OMPClause *T) {
1092 return T->getClauseKind() == OMPC_write;
1095 child_range children() {
1096 return child_range(child_iterator(), child_iterator());
1100 /// \brief This represents 'update' clause in the '#pragma omp atomic'
1104 /// #pragma omp atomic update
1106 /// In this example directive '#pragma omp atomic' has 'update' clause.
1108 class OMPUpdateClause : public OMPClause {
1110 /// \brief Build 'update' clause.
1112 /// \param StartLoc Starting location of the clause.
1113 /// \param EndLoc Ending location of the clause.
1115 OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc)
1116 : OMPClause(OMPC_update, StartLoc, EndLoc) {}
1118 /// \brief Build an empty clause.
1121 : OMPClause(OMPC_update, SourceLocation(), SourceLocation()) {}
1123 static bool classof(const OMPClause *T) {
1124 return T->getClauseKind() == OMPC_update;
1127 child_range children() {
1128 return child_range(child_iterator(), child_iterator());
1132 /// \brief This represents 'capture' clause in the '#pragma omp atomic'
1136 /// #pragma omp atomic capture
1138 /// In this example directive '#pragma omp atomic' has 'capture' clause.
1140 class OMPCaptureClause : public OMPClause {
1142 /// \brief Build 'capture' clause.
1144 /// \param StartLoc Starting location of the clause.
1145 /// \param EndLoc Ending location of the clause.
1147 OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc)
1148 : OMPClause(OMPC_capture, StartLoc, EndLoc) {}
1150 /// \brief Build an empty clause.
1153 : OMPClause(OMPC_capture, SourceLocation(), SourceLocation()) {}
1155 static bool classof(const OMPClause *T) {
1156 return T->getClauseKind() == OMPC_capture;
1159 child_range children() {
1160 return child_range(child_iterator(), child_iterator());
1164 /// \brief This represents 'seq_cst' clause in the '#pragma omp atomic'
1168 /// #pragma omp atomic seq_cst
1170 /// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
1172 class OMPSeqCstClause : public OMPClause {
1174 /// \brief Build 'seq_cst' clause.
1176 /// \param StartLoc Starting location of the clause.
1177 /// \param EndLoc Ending location of the clause.
1179 OMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc)
1180 : OMPClause(OMPC_seq_cst, StartLoc, EndLoc) {}
1182 /// \brief Build an empty clause.
1185 : OMPClause(OMPC_seq_cst, SourceLocation(), SourceLocation()) {}
1187 static bool classof(const OMPClause *T) {
1188 return T->getClauseKind() == OMPC_seq_cst;
1191 child_range children() {
1192 return child_range(child_iterator(), child_iterator());
1196 /// \brief This represents clause 'private' in the '#pragma omp ...' directives.
1199 /// #pragma omp parallel private(a,b)
1201 /// In this example directive '#pragma omp parallel' has clause 'private'
1202 /// with the variables 'a' and 'b'.
1204 class OMPPrivateClause final
1205 : public OMPVarListClause<OMPPrivateClause>,
1206 private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
1207 friend TrailingObjects;
1208 friend OMPVarListClause;
1209 friend class OMPClauseReader;
1210 /// \brief Build clause with number of variables \a N.
1212 /// \param StartLoc Starting location of the clause.
1213 /// \param LParenLoc Location of '('.
1214 /// \param EndLoc Ending location of the clause.
1215 /// \param N Number of the variables in the clause.
1217 OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1218 SourceLocation EndLoc, unsigned N)
1219 : OMPVarListClause<OMPPrivateClause>(OMPC_private, StartLoc, LParenLoc,
1222 /// \brief Build an empty clause.
1224 /// \param N Number of variables.
1226 explicit OMPPrivateClause(unsigned N)
1227 : OMPVarListClause<OMPPrivateClause>(OMPC_private, SourceLocation(),
1228 SourceLocation(), SourceLocation(),
1231 /// \brief Sets the list of references to private copies with initializers for
1232 /// new private variables.
1233 /// \param VL List of references.
1234 void setPrivateCopies(ArrayRef<Expr *> VL);
1236 /// \brief Gets the list of references to private copies with initializers for
1237 /// new private variables.
1238 MutableArrayRef<Expr *> getPrivateCopies() {
1239 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1241 ArrayRef<const Expr *> getPrivateCopies() const {
1242 return llvm::makeArrayRef(varlist_end(), varlist_size());
1246 /// \brief Creates clause with a list of variables \a VL.
1248 /// \param C AST context.
1249 /// \param StartLoc Starting location of the clause.
1250 /// \param LParenLoc Location of '('.
1251 /// \param EndLoc Ending location of the clause.
1252 /// \param VL List of references to the variables.
1253 /// \param PrivateVL List of references to private copies with initializers.
1255 static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
1256 SourceLocation LParenLoc,
1257 SourceLocation EndLoc, ArrayRef<Expr *> VL,
1258 ArrayRef<Expr *> PrivateVL);
1259 /// \brief Creates an empty clause with the place for \a N variables.
1261 /// \param C AST context.
1262 /// \param N The number of variables.
1264 static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1266 typedef MutableArrayRef<Expr *>::iterator private_copies_iterator;
1267 typedef ArrayRef<const Expr *>::iterator private_copies_const_iterator;
1268 typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
1269 typedef llvm::iterator_range<private_copies_const_iterator>
1270 private_copies_const_range;
1272 private_copies_range private_copies() {
1273 return private_copies_range(getPrivateCopies().begin(),
1274 getPrivateCopies().end());
1276 private_copies_const_range private_copies() const {
1277 return private_copies_const_range(getPrivateCopies().begin(),
1278 getPrivateCopies().end());
1281 child_range children() {
1282 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1283 reinterpret_cast<Stmt **>(varlist_end()));
1286 static bool classof(const OMPClause *T) {
1287 return T->getClauseKind() == OMPC_private;
1291 /// \brief This represents clause 'firstprivate' in the '#pragma omp ...'
1295 /// #pragma omp parallel firstprivate(a,b)
1297 /// In this example directive '#pragma omp parallel' has clause 'firstprivate'
1298 /// with the variables 'a' and 'b'.
1300 class OMPFirstprivateClause final
1301 : public OMPVarListClause<OMPFirstprivateClause>,
1302 public OMPClauseWithPreInit,
1303 private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
1304 friend TrailingObjects;
1305 friend OMPVarListClause;
1306 friend class OMPClauseReader;
1308 /// \brief Build clause with number of variables \a N.
1310 /// \param StartLoc Starting location of the clause.
1311 /// \param LParenLoc Location of '('.
1312 /// \param EndLoc Ending location of the clause.
1313 /// \param N Number of the variables in the clause.
1315 OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1316 SourceLocation EndLoc, unsigned N)
1317 : OMPVarListClause<OMPFirstprivateClause>(OMPC_firstprivate, StartLoc,
1318 LParenLoc, EndLoc, N),
1319 OMPClauseWithPreInit(this) {}
1321 /// \brief Build an empty clause.
1323 /// \param N Number of variables.
1325 explicit OMPFirstprivateClause(unsigned N)
1326 : OMPVarListClause<OMPFirstprivateClause>(
1327 OMPC_firstprivate, SourceLocation(), SourceLocation(),
1328 SourceLocation(), N),
1329 OMPClauseWithPreInit(this) {}
1330 /// \brief Sets the list of references to private copies with initializers for
1331 /// new private variables.
1332 /// \param VL List of references.
1333 void setPrivateCopies(ArrayRef<Expr *> VL);
1335 /// \brief Gets the list of references to private copies with initializers for
1336 /// new private variables.
1337 MutableArrayRef<Expr *> getPrivateCopies() {
1338 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1340 ArrayRef<const Expr *> getPrivateCopies() const {
1341 return llvm::makeArrayRef(varlist_end(), varlist_size());
1344 /// \brief Sets the list of references to initializer variables for new
1345 /// private variables.
1346 /// \param VL List of references.
1347 void setInits(ArrayRef<Expr *> VL);
1349 /// \brief Gets the list of references to initializer variables for new
1350 /// private variables.
1351 MutableArrayRef<Expr *> getInits() {
1352 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1354 ArrayRef<const Expr *> getInits() const {
1355 return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1359 /// \brief Creates clause with a list of variables \a VL.
1361 /// \param C AST context.
1362 /// \param StartLoc Starting location of the clause.
1363 /// \param LParenLoc Location of '('.
1364 /// \param EndLoc Ending location of the clause.
1365 /// \param VL List of references to the original variables.
1366 /// \param PrivateVL List of references to private copies with initializers.
1367 /// \param InitVL List of references to auto generated variables used for
1368 /// initialization of a single array element. Used if firstprivate variable is
1370 /// \param PreInit Statement that must be executed before entering the OpenMP
1371 /// region with this clause.
1373 static OMPFirstprivateClause *
1374 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1375 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
1376 ArrayRef<Expr *> InitVL, Stmt *PreInit);
1377 /// \brief Creates an empty clause with the place for \a N variables.
1379 /// \param C AST context.
1380 /// \param N The number of variables.
1382 static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1384 typedef MutableArrayRef<Expr *>::iterator private_copies_iterator;
1385 typedef ArrayRef<const Expr *>::iterator private_copies_const_iterator;
1386 typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
1387 typedef llvm::iterator_range<private_copies_const_iterator>
1388 private_copies_const_range;
1390 private_copies_range private_copies() {
1391 return private_copies_range(getPrivateCopies().begin(),
1392 getPrivateCopies().end());
1394 private_copies_const_range private_copies() const {
1395 return private_copies_const_range(getPrivateCopies().begin(),
1396 getPrivateCopies().end());
1399 typedef MutableArrayRef<Expr *>::iterator inits_iterator;
1400 typedef ArrayRef<const Expr *>::iterator inits_const_iterator;
1401 typedef llvm::iterator_range<inits_iterator> inits_range;
1402 typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
1404 inits_range inits() {
1405 return inits_range(getInits().begin(), getInits().end());
1407 inits_const_range inits() const {
1408 return inits_const_range(getInits().begin(), getInits().end());
1411 child_range children() {
1412 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1413 reinterpret_cast<Stmt **>(varlist_end()));
1416 static bool classof(const OMPClause *T) {
1417 return T->getClauseKind() == OMPC_firstprivate;
1421 /// \brief This represents clause 'lastprivate' in the '#pragma omp ...'
1425 /// #pragma omp simd lastprivate(a,b)
1427 /// In this example directive '#pragma omp simd' has clause 'lastprivate'
1428 /// with the variables 'a' and 'b'.
1429 class OMPLastprivateClause final
1430 : public OMPVarListClause<OMPLastprivateClause>,
1431 public OMPClauseWithPostUpdate,
1432 private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
1433 // There are 4 additional tail-allocated arrays at the end of the class:
1434 // 1. Contains list of pseudo variables with the default initialization for
1435 // each non-firstprivate variables. Used in codegen for initialization of
1436 // lastprivate copies.
1437 // 2. List of helper expressions for proper generation of assignment operation
1438 // required for lastprivate clause. This list represents private variables
1439 // (for arrays, single array element).
1440 // 3. List of helper expressions for proper generation of assignment operation
1441 // required for lastprivate clause. This list represents original variables
1442 // (for arrays, single array element).
1443 // 4. List of helper expressions that represents assignment operation:
1445 // DstExprs = SrcExprs;
1447 // Required for proper codegen of final assignment performed by the
1448 // lastprivate clause.
1450 friend TrailingObjects;
1451 friend OMPVarListClause;
1452 friend class OMPClauseReader;
1454 /// \brief Build clause with number of variables \a N.
1456 /// \param StartLoc Starting location of the clause.
1457 /// \param LParenLoc Location of '('.
1458 /// \param EndLoc Ending location of the clause.
1459 /// \param N Number of the variables in the clause.
1461 OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1462 SourceLocation EndLoc, unsigned N)
1463 : OMPVarListClause<OMPLastprivateClause>(OMPC_lastprivate, StartLoc,
1464 LParenLoc, EndLoc, N),
1465 OMPClauseWithPostUpdate(this) {}
1467 /// \brief Build an empty clause.
1469 /// \param N Number of variables.
1471 explicit OMPLastprivateClause(unsigned N)
1472 : OMPVarListClause<OMPLastprivateClause>(
1473 OMPC_lastprivate, SourceLocation(), SourceLocation(),
1474 SourceLocation(), N),
1475 OMPClauseWithPostUpdate(this) {}
1477 /// \brief Get the list of helper expressions for initialization of private
1478 /// copies for lastprivate variables.
1479 MutableArrayRef<Expr *> getPrivateCopies() {
1480 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1482 ArrayRef<const Expr *> getPrivateCopies() const {
1483 return llvm::makeArrayRef(varlist_end(), varlist_size());
1486 /// \brief Set list of helper expressions, required for proper codegen of the
1487 /// clause. These expressions represent private variables (for arrays, single
1488 /// array element) in the final assignment statement performed by the
1489 /// lastprivate clause.
1490 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
1492 /// \brief Get the list of helper source expressions.
1493 MutableArrayRef<Expr *> getSourceExprs() {
1494 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1496 ArrayRef<const Expr *> getSourceExprs() const {
1497 return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1500 /// \brief Set list of helper expressions, required for proper codegen of the
1501 /// clause. These expressions represent original variables (for arrays, single
1502 /// array element) in the final assignment statement performed by the
1503 /// lastprivate clause.
1504 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
1506 /// \brief Get the list of helper destination expressions.
1507 MutableArrayRef<Expr *> getDestinationExprs() {
1508 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
1510 ArrayRef<const Expr *> getDestinationExprs() const {
1511 return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
1514 /// \brief Set list of helper assignment expressions, required for proper
1515 /// codegen of the clause. These expressions are assignment expressions that
1516 /// assign private copy of the variable to original variable.
1517 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
1519 /// \brief Get the list of helper assignment expressions.
1520 MutableArrayRef<Expr *> getAssignmentOps() {
1521 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
1523 ArrayRef<const Expr *> getAssignmentOps() const {
1524 return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
1528 /// \brief Creates clause with a list of variables \a VL.
1530 /// \param C AST context.
1531 /// \param StartLoc Starting location of the clause.
1532 /// \param LParenLoc Location of '('.
1533 /// \param EndLoc Ending location of the clause.
1534 /// \param VL List of references to the variables.
1535 /// \param SrcExprs List of helper expressions for proper generation of
1536 /// assignment operation required for lastprivate clause. This list represents
1537 /// private variables (for arrays, single array element).
1538 /// \param DstExprs List of helper expressions for proper generation of
1539 /// assignment operation required for lastprivate clause. This list represents
1540 /// original variables (for arrays, single array element).
1541 /// \param AssignmentOps List of helper expressions that represents assignment
1544 /// DstExprs = SrcExprs;
1546 /// Required for proper codegen of final assignment performed by the
1547 /// lastprivate clause.
1548 /// \param PreInit Statement that must be executed before entering the OpenMP
1549 /// region with this clause.
1550 /// \param PostUpdate Expression that must be executed after exit from the
1551 /// OpenMP region with this clause.
1553 static OMPLastprivateClause *
1554 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1555 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
1556 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
1557 Stmt *PreInit, Expr *PostUpdate);
1558 /// \brief Creates an empty clause with the place for \a N variables.
1560 /// \param C AST context.
1561 /// \param N The number of variables.
1563 static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1565 typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
1566 typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
1567 typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
1568 typedef llvm::iterator_range<helper_expr_const_iterator>
1569 helper_expr_const_range;
1571 /// \brief Set list of helper expressions, required for generation of private
1572 /// copies of original lastprivate variables.
1573 void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
1575 helper_expr_const_range private_copies() const {
1576 return helper_expr_const_range(getPrivateCopies().begin(),
1577 getPrivateCopies().end());
1579 helper_expr_range private_copies() {
1580 return helper_expr_range(getPrivateCopies().begin(),
1581 getPrivateCopies().end());
1583 helper_expr_const_range source_exprs() const {
1584 return helper_expr_const_range(getSourceExprs().begin(),
1585 getSourceExprs().end());
1587 helper_expr_range source_exprs() {
1588 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
1590 helper_expr_const_range destination_exprs() const {
1591 return helper_expr_const_range(getDestinationExprs().begin(),
1592 getDestinationExprs().end());
1594 helper_expr_range destination_exprs() {
1595 return helper_expr_range(getDestinationExprs().begin(),
1596 getDestinationExprs().end());
1598 helper_expr_const_range assignment_ops() const {
1599 return helper_expr_const_range(getAssignmentOps().begin(),
1600 getAssignmentOps().end());
1602 helper_expr_range assignment_ops() {
1603 return helper_expr_range(getAssignmentOps().begin(),
1604 getAssignmentOps().end());
1607 child_range children() {
1608 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1609 reinterpret_cast<Stmt **>(varlist_end()));
1612 static bool classof(const OMPClause *T) {
1613 return T->getClauseKind() == OMPC_lastprivate;
1617 /// \brief This represents clause 'shared' in the '#pragma omp ...' directives.
1620 /// #pragma omp parallel shared(a,b)
1622 /// In this example directive '#pragma omp parallel' has clause 'shared'
1623 /// with the variables 'a' and 'b'.
1625 class OMPSharedClause final
1626 : public OMPVarListClause<OMPSharedClause>,
1627 private llvm::TrailingObjects<OMPSharedClause, Expr *> {
1628 friend TrailingObjects;
1629 friend OMPVarListClause;
1630 /// \brief Build clause with number of variables \a N.
1632 /// \param StartLoc Starting location of the clause.
1633 /// \param LParenLoc Location of '('.
1634 /// \param EndLoc Ending location of the clause.
1635 /// \param N Number of the variables in the clause.
1637 OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1638 SourceLocation EndLoc, unsigned N)
1639 : OMPVarListClause<OMPSharedClause>(OMPC_shared, StartLoc, LParenLoc,
1642 /// \brief Build an empty clause.
1644 /// \param N Number of variables.
1646 explicit OMPSharedClause(unsigned N)
1647 : OMPVarListClause<OMPSharedClause>(OMPC_shared, SourceLocation(),
1648 SourceLocation(), SourceLocation(),
1652 /// \brief Creates clause with a list of variables \a VL.
1654 /// \param C AST context.
1655 /// \param StartLoc Starting location of the clause.
1656 /// \param LParenLoc Location of '('.
1657 /// \param EndLoc Ending location of the clause.
1658 /// \param VL List of references to the variables.
1660 static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
1661 SourceLocation LParenLoc,
1662 SourceLocation EndLoc, ArrayRef<Expr *> VL);
1663 /// \brief Creates an empty clause with \a N variables.
1665 /// \param C AST context.
1666 /// \param N The number of variables.
1668 static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
1670 child_range children() {
1671 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1672 reinterpret_cast<Stmt **>(varlist_end()));
1675 static bool classof(const OMPClause *T) {
1676 return T->getClauseKind() == OMPC_shared;
1680 /// \brief This represents clause 'reduction' in the '#pragma omp ...'
1684 /// #pragma omp parallel reduction(+:a,b)
1686 /// In this example directive '#pragma omp parallel' has clause 'reduction'
1687 /// with operator '+' and the variables 'a' and 'b'.
1689 class OMPReductionClause final
1690 : public OMPVarListClause<OMPReductionClause>,
1691 public OMPClauseWithPostUpdate,
1692 private llvm::TrailingObjects<OMPReductionClause, Expr *> {
1693 friend TrailingObjects;
1694 friend OMPVarListClause;
1695 friend class OMPClauseReader;
1696 /// \brief Location of ':'.
1697 SourceLocation ColonLoc;
1698 /// \brief Nested name specifier for C++.
1699 NestedNameSpecifierLoc QualifierLoc;
1700 /// \brief Name of custom operator.
1701 DeclarationNameInfo NameInfo;
1703 /// \brief Build clause with number of variables \a N.
1705 /// \param StartLoc Starting location of the clause.
1706 /// \param LParenLoc Location of '('.
1707 /// \param EndLoc Ending location of the clause.
1708 /// \param ColonLoc Location of ':'.
1709 /// \param N Number of the variables in the clause.
1710 /// \param QualifierLoc The nested-name qualifier with location information
1711 /// \param NameInfo The full name info for reduction identifier.
1713 OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1714 SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N,
1715 NestedNameSpecifierLoc QualifierLoc,
1716 const DeclarationNameInfo &NameInfo)
1717 : OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
1718 LParenLoc, EndLoc, N),
1719 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
1720 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
1722 /// \brief Build an empty clause.
1724 /// \param N Number of variables.
1726 explicit OMPReductionClause(unsigned N)
1727 : OMPVarListClause<OMPReductionClause>(OMPC_reduction, SourceLocation(),
1728 SourceLocation(), SourceLocation(),
1730 OMPClauseWithPostUpdate(this), ColonLoc(), QualifierLoc(), NameInfo() {}
1732 /// \brief Sets location of ':' symbol in clause.
1733 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
1734 /// \brief Sets the name info for specified reduction identifier.
1735 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
1736 /// \brief Sets the nested name specifier.
1737 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
1739 /// \brief Set list of helper expressions, required for proper codegen of the
1740 /// clause. These expressions represent private copy of the reduction
1742 void setPrivates(ArrayRef<Expr *> Privates);
1744 /// \brief Get the list of helper privates.
1745 MutableArrayRef<Expr *> getPrivates() {
1746 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1748 ArrayRef<const Expr *> getPrivates() const {
1749 return llvm::makeArrayRef(varlist_end(), varlist_size());
1752 /// \brief Set list of helper expressions, required for proper codegen of the
1753 /// clause. These expressions represent LHS expression in the final
1754 /// reduction expression performed by the reduction clause.
1755 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
1757 /// \brief Get the list of helper LHS expressions.
1758 MutableArrayRef<Expr *> getLHSExprs() {
1759 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
1761 ArrayRef<const Expr *> getLHSExprs() const {
1762 return llvm::makeArrayRef(getPrivates().end(), varlist_size());
1765 /// \brief Set list of helper expressions, required for proper codegen of the
1766 /// clause. These expressions represent RHS expression in the final
1767 /// reduction expression performed by the reduction clause.
1768 /// Also, variables in these expressions are used for proper initialization of
1769 /// reduction copies.
1770 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
1772 /// \brief Get the list of helper destination expressions.
1773 MutableArrayRef<Expr *> getRHSExprs() {
1774 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
1776 ArrayRef<const Expr *> getRHSExprs() const {
1777 return llvm::makeArrayRef(getLHSExprs().end(), varlist_size());
1780 /// \brief Set list of helper reduction expressions, required for proper
1781 /// codegen of the clause. These expressions are binary expressions or
1782 /// operator/custom reduction call that calculates new value from source
1783 /// helper expressions to destination helper expressions.
1784 void setReductionOps(ArrayRef<Expr *> ReductionOps);
1786 /// \brief Get the list of helper reduction expressions.
1787 MutableArrayRef<Expr *> getReductionOps() {
1788 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
1790 ArrayRef<const Expr *> getReductionOps() const {
1791 return llvm::makeArrayRef(getRHSExprs().end(), varlist_size());
1795 /// \brief Creates clause with a list of variables \a VL.
1797 /// \param StartLoc Starting location of the clause.
1798 /// \param LParenLoc Location of '('.
1799 /// \param ColonLoc Location of ':'.
1800 /// \param EndLoc Ending location of the clause.
1801 /// \param VL The variables in the clause.
1802 /// \param QualifierLoc The nested-name qualifier with location information
1803 /// \param NameInfo The full name info for reduction identifier.
1804 /// \param Privates List of helper expressions for proper generation of
1806 /// \param LHSExprs List of helper expressions for proper generation of
1807 /// assignment operation required for copyprivate clause. This list represents
1808 /// LHSs of the reduction expressions.
1809 /// \param RHSExprs List of helper expressions for proper generation of
1810 /// assignment operation required for copyprivate clause. This list represents
1811 /// RHSs of the reduction expressions.
1812 /// Also, variables in these expressions are used for proper initialization of
1813 /// reduction copies.
1814 /// \param ReductionOps List of helper expressions that represents reduction
1817 /// LHSExprs binop RHSExprs;
1818 /// operator binop(LHSExpr, RHSExpr);
1819 /// <CutomReduction>(LHSExpr, RHSExpr);
1821 /// Required for proper codegen of final reduction operation performed by the
1822 /// reduction clause.
1823 /// \param PreInit Statement that must be executed before entering the OpenMP
1824 /// region with this clause.
1825 /// \param PostUpdate Expression that must be executed after exit from the
1826 /// OpenMP region with this clause.
1828 static OMPReductionClause *
1829 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1830 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
1831 NestedNameSpecifierLoc QualifierLoc,
1832 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
1833 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
1834 ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
1835 /// \brief Creates an empty clause with the place for \a N variables.
1837 /// \param C AST context.
1838 /// \param N The number of variables.
1840 static OMPReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
1842 /// \brief Gets location of ':' symbol in clause.
1843 SourceLocation getColonLoc() const { return ColonLoc; }
1844 /// \brief Gets the name info for specified reduction identifier.
1845 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
1846 /// \brief Gets the nested name specifier.
1847 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
1849 typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
1850 typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
1851 typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
1852 typedef llvm::iterator_range<helper_expr_const_iterator>
1853 helper_expr_const_range;
1855 helper_expr_const_range privates() const {
1856 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
1858 helper_expr_range privates() {
1859 return helper_expr_range(getPrivates().begin(), getPrivates().end());
1861 helper_expr_const_range lhs_exprs() const {
1862 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
1864 helper_expr_range lhs_exprs() {
1865 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
1867 helper_expr_const_range rhs_exprs() const {
1868 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
1870 helper_expr_range rhs_exprs() {
1871 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
1873 helper_expr_const_range reduction_ops() const {
1874 return helper_expr_const_range(getReductionOps().begin(),
1875 getReductionOps().end());
1877 helper_expr_range reduction_ops() {
1878 return helper_expr_range(getReductionOps().begin(),
1879 getReductionOps().end());
1882 child_range children() {
1883 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1884 reinterpret_cast<Stmt **>(varlist_end()));
1887 static bool classof(const OMPClause *T) {
1888 return T->getClauseKind() == OMPC_reduction;
1892 /// \brief This represents clause 'linear' in the '#pragma omp ...'
1896 /// #pragma omp simd linear(a,b : 2)
1898 /// In this example directive '#pragma omp simd' has clause 'linear'
1899 /// with variables 'a', 'b' and linear step '2'.
1901 class OMPLinearClause final
1902 : public OMPVarListClause<OMPLinearClause>,
1903 public OMPClauseWithPostUpdate,
1904 private llvm::TrailingObjects<OMPLinearClause, Expr *> {
1905 friend TrailingObjects;
1906 friend OMPVarListClause;
1907 friend class OMPClauseReader;
1908 /// \brief Modifier of 'linear' clause.
1909 OpenMPLinearClauseKind Modifier;
1910 /// \brief Location of linear modifier if any.
1911 SourceLocation ModifierLoc;
1912 /// \brief Location of ':'.
1913 SourceLocation ColonLoc;
1915 /// \brief Sets the linear step for clause.
1916 void setStep(Expr *Step) { *(getFinals().end()) = Step; }
1918 /// \brief Sets the expression to calculate linear step for clause.
1919 void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
1921 /// \brief Build 'linear' clause with given number of variables \a NumVars.
1923 /// \param StartLoc Starting location of the clause.
1924 /// \param LParenLoc Location of '('.
1925 /// \param ColonLoc Location of ':'.
1926 /// \param EndLoc Ending location of the clause.
1927 /// \param NumVars Number of variables.
1929 OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1930 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
1931 SourceLocation ColonLoc, SourceLocation EndLoc,
1933 : OMPVarListClause<OMPLinearClause>(OMPC_linear, StartLoc, LParenLoc,
1935 OMPClauseWithPostUpdate(this), Modifier(Modifier),
1936 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc) {}
1938 /// \brief Build an empty clause.
1940 /// \param NumVars Number of variables.
1942 explicit OMPLinearClause(unsigned NumVars)
1943 : OMPVarListClause<OMPLinearClause>(OMPC_linear, SourceLocation(),
1944 SourceLocation(), SourceLocation(),
1946 OMPClauseWithPostUpdate(this), Modifier(OMPC_LINEAR_val), ModifierLoc(),
1949 /// \brief Gets the list of initial values for linear variables.
1951 /// There are NumVars expressions with initial values allocated after the
1952 /// varlist, they are followed by NumVars update expressions (used to update
1953 /// the linear variable's value on current iteration) and they are followed by
1954 /// NumVars final expressions (used to calculate the linear variable's
1955 /// value after the loop body). After these lists, there are 2 helper
1956 /// expressions - linear step and a helper to calculate it before the
1957 /// loop body (used when the linear step is not constant):
1959 /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
1960 /// Finals[]; Step; CalcStep; }
1962 MutableArrayRef<Expr *> getPrivates() {
1963 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1965 ArrayRef<const Expr *> getPrivates() const {
1966 return llvm::makeArrayRef(varlist_end(), varlist_size());
1969 MutableArrayRef<Expr *> getInits() {
1970 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
1972 ArrayRef<const Expr *> getInits() const {
1973 return llvm::makeArrayRef(getPrivates().end(), varlist_size());
1976 /// \brief Sets the list of update expressions for linear variables.
1977 MutableArrayRef<Expr *> getUpdates() {
1978 return MutableArrayRef<Expr *>(getInits().end(), varlist_size());
1980 ArrayRef<const Expr *> getUpdates() const {
1981 return llvm::makeArrayRef(getInits().end(), varlist_size());
1984 /// \brief Sets the list of final update expressions for linear variables.
1985 MutableArrayRef<Expr *> getFinals() {
1986 return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size());
1988 ArrayRef<const Expr *> getFinals() const {
1989 return llvm::makeArrayRef(getUpdates().end(), varlist_size());
1992 /// \brief Sets the list of the copies of original linear variables.
1993 /// \param PL List of expressions.
1994 void setPrivates(ArrayRef<Expr *> PL);
1996 /// \brief Sets the list of the initial values for linear variables.
1997 /// \param IL List of expressions.
1998 void setInits(ArrayRef<Expr *> IL);
2001 /// \brief Creates clause with a list of variables \a VL and a linear step
2004 /// \param C AST Context.
2005 /// \param StartLoc Starting location of the clause.
2006 /// \param LParenLoc Location of '('.
2007 /// \param Modifier Modifier of 'linear' clause.
2008 /// \param ModifierLoc Modifier location.
2009 /// \param ColonLoc Location of ':'.
2010 /// \param EndLoc Ending location of the clause.
2011 /// \param VL List of references to the variables.
2012 /// \param PL List of private copies of original variables.
2013 /// \param IL List of initial values for the variables.
2014 /// \param Step Linear step.
2015 /// \param CalcStep Calculation of the linear step.
2016 /// \param PreInit Statement that must be executed before entering the OpenMP
2017 /// region with this clause.
2018 /// \param PostUpdate Expression that must be executed after exit from the
2019 /// OpenMP region with this clause.
2020 static OMPLinearClause *
2021 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2022 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
2023 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
2024 ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep,
2025 Stmt *PreInit, Expr *PostUpdate);
2027 /// \brief Creates an empty clause with the place for \a NumVars variables.
2029 /// \param C AST context.
2030 /// \param NumVars Number of variables.
2032 static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
2034 /// \brief Set modifier.
2035 void setModifier(OpenMPLinearClauseKind Kind) { Modifier = Kind; }
2036 /// \brief Return modifier.
2037 OpenMPLinearClauseKind getModifier() const { return Modifier; }
2039 /// \brief Set modifier location.
2040 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
2041 /// \brief Return modifier location.
2042 SourceLocation getModifierLoc() const { return ModifierLoc; }
2044 /// \brief Sets the location of ':'.
2045 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2046 /// \brief Returns the location of ':'.
2047 SourceLocation getColonLoc() const { return ColonLoc; }
2049 /// \brief Returns linear step.
2050 Expr *getStep() { return *(getFinals().end()); }
2051 /// \brief Returns linear step.
2052 const Expr *getStep() const { return *(getFinals().end()); }
2053 /// \brief Returns expression to calculate linear step.
2054 Expr *getCalcStep() { return *(getFinals().end() + 1); }
2055 /// \brief Returns expression to calculate linear step.
2056 const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
2058 /// \brief Sets the list of update expressions for linear variables.
2059 /// \param UL List of expressions.
2060 void setUpdates(ArrayRef<Expr *> UL);
2062 /// \brief Sets the list of final update expressions for linear variables.
2063 /// \param FL List of expressions.
2064 void setFinals(ArrayRef<Expr *> FL);
2066 typedef MutableArrayRef<Expr *>::iterator privates_iterator;
2067 typedef ArrayRef<const Expr *>::iterator privates_const_iterator;
2068 typedef llvm::iterator_range<privates_iterator> privates_range;
2069 typedef llvm::iterator_range<privates_const_iterator> privates_const_range;
2071 privates_range privates() {
2072 return privates_range(getPrivates().begin(), getPrivates().end());
2074 privates_const_range privates() const {
2075 return privates_const_range(getPrivates().begin(), getPrivates().end());
2078 typedef MutableArrayRef<Expr *>::iterator inits_iterator;
2079 typedef ArrayRef<const Expr *>::iterator inits_const_iterator;
2080 typedef llvm::iterator_range<inits_iterator> inits_range;
2081 typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
2083 inits_range inits() {
2084 return inits_range(getInits().begin(), getInits().end());
2086 inits_const_range inits() const {
2087 return inits_const_range(getInits().begin(), getInits().end());
2090 typedef MutableArrayRef<Expr *>::iterator updates_iterator;
2091 typedef ArrayRef<const Expr *>::iterator updates_const_iterator;
2092 typedef llvm::iterator_range<updates_iterator> updates_range;
2093 typedef llvm::iterator_range<updates_const_iterator> updates_const_range;
2095 updates_range updates() {
2096 return updates_range(getUpdates().begin(), getUpdates().end());
2098 updates_const_range updates() const {
2099 return updates_const_range(getUpdates().begin(), getUpdates().end());
2102 typedef MutableArrayRef<Expr *>::iterator finals_iterator;
2103 typedef ArrayRef<const Expr *>::iterator finals_const_iterator;
2104 typedef llvm::iterator_range<finals_iterator> finals_range;
2105 typedef llvm::iterator_range<finals_const_iterator> finals_const_range;
2107 finals_range finals() {
2108 return finals_range(getFinals().begin(), getFinals().end());
2110 finals_const_range finals() const {
2111 return finals_const_range(getFinals().begin(), getFinals().end());
2114 child_range children() {
2115 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2116 reinterpret_cast<Stmt **>(varlist_end()));
2119 static bool classof(const OMPClause *T) {
2120 return T->getClauseKind() == OMPC_linear;
2124 /// \brief This represents clause 'aligned' in the '#pragma omp ...'
2128 /// #pragma omp simd aligned(a,b : 8)
2130 /// In this example directive '#pragma omp simd' has clause 'aligned'
2131 /// with variables 'a', 'b' and alignment '8'.
2133 class OMPAlignedClause final
2134 : public OMPVarListClause<OMPAlignedClause>,
2135 private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
2136 friend TrailingObjects;
2137 friend OMPVarListClause;
2138 friend class OMPClauseReader;
2139 /// \brief Location of ':'.
2140 SourceLocation ColonLoc;
2142 /// \brief Sets the alignment for clause.
2143 void setAlignment(Expr *A) { *varlist_end() = A; }
2145 /// \brief Build 'aligned' clause with given number of variables \a NumVars.
2147 /// \param StartLoc Starting location of the clause.
2148 /// \param LParenLoc Location of '('.
2149 /// \param ColonLoc Location of ':'.
2150 /// \param EndLoc Ending location of the clause.
2151 /// \param NumVars Number of variables.
2153 OMPAlignedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2154 SourceLocation ColonLoc, SourceLocation EndLoc,
2156 : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, StartLoc, LParenLoc,
2158 ColonLoc(ColonLoc) {}
2160 /// \brief Build an empty clause.
2162 /// \param NumVars Number of variables.
2164 explicit OMPAlignedClause(unsigned NumVars)
2165 : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, SourceLocation(),
2166 SourceLocation(), SourceLocation(),
2168 ColonLoc(SourceLocation()) {}
2171 /// \brief Creates clause with a list of variables \a VL and alignment \a A.
2173 /// \param C AST Context.
2174 /// \param StartLoc Starting location of the clause.
2175 /// \param LParenLoc Location of '('.
2176 /// \param ColonLoc Location of ':'.
2177 /// \param EndLoc Ending location of the clause.
2178 /// \param VL List of references to the variables.
2179 /// \param A Alignment.
2180 static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
2181 SourceLocation LParenLoc,
2182 SourceLocation ColonLoc,
2183 SourceLocation EndLoc, ArrayRef<Expr *> VL,
2186 /// \brief Creates an empty clause with the place for \a NumVars variables.
2188 /// \param C AST context.
2189 /// \param NumVars Number of variables.
2191 static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
2193 /// \brief Sets the location of ':'.
2194 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2195 /// \brief Returns the location of ':'.
2196 SourceLocation getColonLoc() const { return ColonLoc; }
2198 /// \brief Returns alignment.
2199 Expr *getAlignment() { return *varlist_end(); }
2200 /// \brief Returns alignment.
2201 const Expr *getAlignment() const { return *varlist_end(); }
2203 child_range children() {
2204 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2205 reinterpret_cast<Stmt **>(varlist_end()));
2208 static bool classof(const OMPClause *T) {
2209 return T->getClauseKind() == OMPC_aligned;
2213 /// \brief This represents clause 'copyin' in the '#pragma omp ...' directives.
2216 /// #pragma omp parallel copyin(a,b)
2218 /// In this example directive '#pragma omp parallel' has clause 'copyin'
2219 /// with the variables 'a' and 'b'.
2221 class OMPCopyinClause final
2222 : public OMPVarListClause<OMPCopyinClause>,
2223 private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
2224 // Class has 3 additional tail allocated arrays:
2225 // 1. List of helper expressions for proper generation of assignment operation
2226 // required for copyin clause. This list represents sources.
2227 // 2. List of helper expressions for proper generation of assignment operation
2228 // required for copyin clause. This list represents destinations.
2229 // 3. List of helper expressions that represents assignment operation:
2231 // DstExprs = SrcExprs;
2233 // Required for proper codegen of propagation of master's thread values of
2234 // threadprivate variables to local instances of that variables in other
2235 // implicit threads.
2237 friend TrailingObjects;
2238 friend OMPVarListClause;
2239 friend class OMPClauseReader;
2240 /// \brief Build clause with number of variables \a N.
2242 /// \param StartLoc Starting location of the clause.
2243 /// \param LParenLoc Location of '('.
2244 /// \param EndLoc Ending location of the clause.
2245 /// \param N Number of the variables in the clause.
2247 OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2248 SourceLocation EndLoc, unsigned N)
2249 : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, StartLoc, LParenLoc,
2252 /// \brief Build an empty clause.
2254 /// \param N Number of variables.
2256 explicit OMPCopyinClause(unsigned N)
2257 : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, SourceLocation(),
2258 SourceLocation(), SourceLocation(),
2261 /// \brief Set list of helper expressions, required for proper codegen of the
2262 /// clause. These expressions represent source expression in the final
2263 /// assignment statement performed by the copyin clause.
2264 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
2266 /// \brief Get the list of helper source expressions.
2267 MutableArrayRef<Expr *> getSourceExprs() {
2268 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2270 ArrayRef<const Expr *> getSourceExprs() const {
2271 return llvm::makeArrayRef(varlist_end(), varlist_size());
2274 /// \brief Set list of helper expressions, required for proper codegen of the
2275 /// clause. These expressions represent destination expression in the final
2276 /// assignment statement performed by the copyin clause.
2277 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
2279 /// \brief Get the list of helper destination expressions.
2280 MutableArrayRef<Expr *> getDestinationExprs() {
2281 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
2283 ArrayRef<const Expr *> getDestinationExprs() const {
2284 return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
2287 /// \brief Set list of helper assignment expressions, required for proper
2288 /// codegen of the clause. These expressions are assignment expressions that
2289 /// assign source helper expressions to destination helper expressions
2290 /// correspondingly.
2291 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
2293 /// \brief Get the list of helper assignment expressions.
2294 MutableArrayRef<Expr *> getAssignmentOps() {
2295 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
2297 ArrayRef<const Expr *> getAssignmentOps() const {
2298 return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
2302 /// \brief Creates clause with a list of variables \a VL.
2304 /// \param C AST context.
2305 /// \param StartLoc Starting location of the clause.
2306 /// \param LParenLoc Location of '('.
2307 /// \param EndLoc Ending location of the clause.
2308 /// \param VL List of references to the variables.
2309 /// \param SrcExprs List of helper expressions for proper generation of
2310 /// assignment operation required for copyin clause. This list represents
2312 /// \param DstExprs List of helper expressions for proper generation of
2313 /// assignment operation required for copyin clause. This list represents
2315 /// \param AssignmentOps List of helper expressions that represents assignment
2318 /// DstExprs = SrcExprs;
2320 /// Required for proper codegen of propagation of master's thread values of
2321 /// threadprivate variables to local instances of that variables in other
2322 /// implicit threads.
2324 static OMPCopyinClause *
2325 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2326 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
2327 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
2328 /// \brief Creates an empty clause with \a N variables.
2330 /// \param C AST context.
2331 /// \param N The number of variables.
2333 static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
2335 typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
2336 typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
2337 typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
2338 typedef llvm::iterator_range<helper_expr_const_iterator>
2339 helper_expr_const_range;
2341 helper_expr_const_range source_exprs() const {
2342 return helper_expr_const_range(getSourceExprs().begin(),
2343 getSourceExprs().end());
2345 helper_expr_range source_exprs() {
2346 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
2348 helper_expr_const_range destination_exprs() const {
2349 return helper_expr_const_range(getDestinationExprs().begin(),
2350 getDestinationExprs().end());
2352 helper_expr_range destination_exprs() {
2353 return helper_expr_range(getDestinationExprs().begin(),
2354 getDestinationExprs().end());
2356 helper_expr_const_range assignment_ops() const {
2357 return helper_expr_const_range(getAssignmentOps().begin(),
2358 getAssignmentOps().end());
2360 helper_expr_range assignment_ops() {
2361 return helper_expr_range(getAssignmentOps().begin(),
2362 getAssignmentOps().end());
2365 child_range children() {
2366 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2367 reinterpret_cast<Stmt **>(varlist_end()));
2370 static bool classof(const OMPClause *T) {
2371 return T->getClauseKind() == OMPC_copyin;
2375 /// \brief This represents clause 'copyprivate' in the '#pragma omp ...'
2379 /// #pragma omp single copyprivate(a,b)
2381 /// In this example directive '#pragma omp single' has clause 'copyprivate'
2382 /// with the variables 'a' and 'b'.
2384 class OMPCopyprivateClause final
2385 : public OMPVarListClause<OMPCopyprivateClause>,
2386 private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
2387 friend TrailingObjects;
2388 friend OMPVarListClause;
2389 friend class OMPClauseReader;
2390 /// \brief Build clause with number of variables \a N.
2392 /// \param StartLoc Starting location of the clause.
2393 /// \param LParenLoc Location of '('.
2394 /// \param EndLoc Ending location of the clause.
2395 /// \param N Number of the variables in the clause.
2397 OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2398 SourceLocation EndLoc, unsigned N)
2399 : OMPVarListClause<OMPCopyprivateClause>(OMPC_copyprivate, StartLoc,
2400 LParenLoc, EndLoc, N) {}
2402 /// \brief Build an empty clause.
2404 /// \param N Number of variables.
2406 explicit OMPCopyprivateClause(unsigned N)
2407 : OMPVarListClause<OMPCopyprivateClause>(
2408 OMPC_copyprivate, SourceLocation(), SourceLocation(),
2409 SourceLocation(), N) {}
2411 /// \brief Set list of helper expressions, required for proper codegen of the
2412 /// clause. These expressions represent source expression in the final
2413 /// assignment statement performed by the copyprivate clause.
2414 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
2416 /// \brief Get the list of helper source expressions.
2417 MutableArrayRef<Expr *> getSourceExprs() {
2418 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2420 ArrayRef<const Expr *> getSourceExprs() const {
2421 return llvm::makeArrayRef(varlist_end(), varlist_size());
2424 /// \brief Set list of helper expressions, required for proper codegen of the
2425 /// clause. These expressions represent destination expression in the final
2426 /// assignment statement performed by the copyprivate clause.
2427 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
2429 /// \brief Get the list of helper destination expressions.
2430 MutableArrayRef<Expr *> getDestinationExprs() {
2431 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
2433 ArrayRef<const Expr *> getDestinationExprs() const {
2434 return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
2437 /// \brief Set list of helper assignment expressions, required for proper
2438 /// codegen of the clause. These expressions are assignment expressions that
2439 /// assign source helper expressions to destination helper expressions
2440 /// correspondingly.
2441 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
2443 /// \brief Get the list of helper assignment expressions.
2444 MutableArrayRef<Expr *> getAssignmentOps() {
2445 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
2447 ArrayRef<const Expr *> getAssignmentOps() const {
2448 return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
2452 /// \brief Creates clause with a list of variables \a VL.
2454 /// \param C AST context.
2455 /// \param StartLoc Starting location of the clause.
2456 /// \param LParenLoc Location of '('.
2457 /// \param EndLoc Ending location of the clause.
2458 /// \param VL List of references to the variables.
2459 /// \param SrcExprs List of helper expressions for proper generation of
2460 /// assignment operation required for copyprivate clause. This list represents
2462 /// \param DstExprs List of helper expressions for proper generation of
2463 /// assignment operation required for copyprivate clause. This list represents
2465 /// \param AssignmentOps List of helper expressions that represents assignment
2468 /// DstExprs = SrcExprs;
2470 /// Required for proper codegen of final assignment performed by the
2471 /// copyprivate clause.
2473 static OMPCopyprivateClause *
2474 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2475 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
2476 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
2477 /// \brief Creates an empty clause with \a N variables.
2479 /// \param C AST context.
2480 /// \param N The number of variables.
2482 static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
2484 typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
2485 typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
2486 typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
2487 typedef llvm::iterator_range<helper_expr_const_iterator>
2488 helper_expr_const_range;
2490 helper_expr_const_range source_exprs() const {
2491 return helper_expr_const_range(getSourceExprs().begin(),
2492 getSourceExprs().end());
2494 helper_expr_range source_exprs() {
2495 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
2497 helper_expr_const_range destination_exprs() const {
2498 return helper_expr_const_range(getDestinationExprs().begin(),
2499 getDestinationExprs().end());
2501 helper_expr_range destination_exprs() {
2502 return helper_expr_range(getDestinationExprs().begin(),
2503 getDestinationExprs().end());
2505 helper_expr_const_range assignment_ops() const {
2506 return helper_expr_const_range(getAssignmentOps().begin(),
2507 getAssignmentOps().end());
2509 helper_expr_range assignment_ops() {
2510 return helper_expr_range(getAssignmentOps().begin(),
2511 getAssignmentOps().end());
2514 child_range children() {
2515 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2516 reinterpret_cast<Stmt **>(varlist_end()));
2519 static bool classof(const OMPClause *T) {
2520 return T->getClauseKind() == OMPC_copyprivate;
2524 /// \brief This represents implicit clause 'flush' for the '#pragma omp flush'
2526 /// This clause does not exist by itself, it can be only as a part of 'omp
2527 /// flush' directive. This clause is introduced to keep the original structure
2528 /// of \a OMPExecutableDirective class and its derivatives and to use the
2529 /// existing infrastructure of clauses with the list of variables.
2532 /// #pragma omp flush(a,b)
2534 /// In this example directive '#pragma omp flush' has implicit clause 'flush'
2535 /// with the variables 'a' and 'b'.
2537 class OMPFlushClause final
2538 : public OMPVarListClause<OMPFlushClause>,
2539 private llvm::TrailingObjects<OMPFlushClause, Expr *> {
2540 friend TrailingObjects;
2541 friend OMPVarListClause;
2542 /// \brief Build clause with number of variables \a N.
2544 /// \param StartLoc Starting location of the clause.
2545 /// \param LParenLoc Location of '('.
2546 /// \param EndLoc Ending location of the clause.
2547 /// \param N Number of the variables in the clause.
2549 OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2550 SourceLocation EndLoc, unsigned N)
2551 : OMPVarListClause<OMPFlushClause>(OMPC_flush, StartLoc, LParenLoc,
2554 /// \brief Build an empty clause.
2556 /// \param N Number of variables.
2558 explicit OMPFlushClause(unsigned N)
2559 : OMPVarListClause<OMPFlushClause>(OMPC_flush, SourceLocation(),
2560 SourceLocation(), SourceLocation(),
2564 /// \brief Creates clause with a list of variables \a VL.
2566 /// \param C AST context.
2567 /// \param StartLoc Starting location of the clause.
2568 /// \param LParenLoc Location of '('.
2569 /// \param EndLoc Ending location of the clause.
2570 /// \param VL List of references to the variables.
2572 static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
2573 SourceLocation LParenLoc, SourceLocation EndLoc,
2574 ArrayRef<Expr *> VL);
2575 /// \brief Creates an empty clause with \a N variables.
2577 /// \param C AST context.
2578 /// \param N The number of variables.
2580 static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
2582 child_range children() {
2583 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2584 reinterpret_cast<Stmt **>(varlist_end()));
2587 static bool classof(const OMPClause *T) {
2588 return T->getClauseKind() == OMPC_flush;
2592 /// \brief This represents implicit clause 'depend' for the '#pragma omp task'
2596 /// #pragma omp task depend(in:a,b)
2598 /// In this example directive '#pragma omp task' with clause 'depend' with the
2599 /// variables 'a' and 'b' with dependency 'in'.
2601 class OMPDependClause final
2602 : public OMPVarListClause<OMPDependClause>,
2603 private llvm::TrailingObjects<OMPDependClause, Expr *> {
2604 friend TrailingObjects;
2605 friend OMPVarListClause;
2606 friend class OMPClauseReader;
2607 /// \brief Dependency type (one of in, out, inout).
2608 OpenMPDependClauseKind DepKind;
2609 /// \brief Dependency type location.
2610 SourceLocation DepLoc;
2611 /// \brief Colon location.
2612 SourceLocation ColonLoc;
2613 /// \brief Build clause with number of variables \a N.
2615 /// \param StartLoc Starting location of the clause.
2616 /// \param LParenLoc Location of '('.
2617 /// \param EndLoc Ending location of the clause.
2618 /// \param N Number of the variables in the clause.
2620 OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2621 SourceLocation EndLoc, unsigned N)
2622 : OMPVarListClause<OMPDependClause>(OMPC_depend, StartLoc, LParenLoc,
2624 DepKind(OMPC_DEPEND_unknown) {}
2626 /// \brief Build an empty clause.
2628 /// \param N Number of variables.
2630 explicit OMPDependClause(unsigned N)
2631 : OMPVarListClause<OMPDependClause>(OMPC_depend, SourceLocation(),
2632 SourceLocation(), SourceLocation(),
2634 DepKind(OMPC_DEPEND_unknown) {}
2635 /// \brief Set dependency kind.
2636 void setDependencyKind(OpenMPDependClauseKind K) { DepKind = K; }
2638 /// \brief Set dependency kind and its location.
2639 void setDependencyLoc(SourceLocation Loc) { DepLoc = Loc; }
2641 /// \brief Set colon location.
2642 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2645 /// \brief Creates clause with a list of variables \a VL.
2647 /// \param C AST context.
2648 /// \param StartLoc Starting location of the clause.
2649 /// \param LParenLoc Location of '('.
2650 /// \param EndLoc Ending location of the clause.
2651 /// \param DepKind Dependency type.
2652 /// \param DepLoc Location of the dependency type.
2653 /// \param ColonLoc Colon location.
2654 /// \param VL List of references to the variables.
2655 static OMPDependClause *
2656 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2657 SourceLocation EndLoc, OpenMPDependClauseKind DepKind,
2658 SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL);
2659 /// \brief Creates an empty clause with \a N variables.
2661 /// \param C AST context.
2662 /// \param N The number of variables.
2664 static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N);
2666 /// \brief Get dependency type.
2667 OpenMPDependClauseKind getDependencyKind() const { return DepKind; }
2668 /// \brief Get dependency type location.
2669 SourceLocation getDependencyLoc() const { return DepLoc; }
2670 /// \brief Get colon location.
2671 SourceLocation getColonLoc() const { return ColonLoc; }
2673 /// Set the loop counter value for the depend clauses with 'sink|source' kind
2674 /// of dependency. Required for codegen.
2675 void setCounterValue(Expr *V);
2676 /// Get the loop counter value.
2677 Expr *getCounterValue();
2678 /// Get the loop counter value.
2679 const Expr *getCounterValue() const;
2681 child_range children() {
2682 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2683 reinterpret_cast<Stmt **>(varlist_end()));
2686 static bool classof(const OMPClause *T) {
2687 return T->getClauseKind() == OMPC_depend;
2691 /// \brief This represents 'device' clause in the '#pragma omp ...'
2695 /// #pragma omp target device(a)
2697 /// In this example directive '#pragma omp target' has clause 'device'
2698 /// with single expression 'a'.
2700 class OMPDeviceClause : public OMPClause {
2701 friend class OMPClauseReader;
2702 /// \brief Location of '('.
2703 SourceLocation LParenLoc;
2704 /// \brief Device number.
2706 /// \brief Set the device number.
2708 /// \param E Device number.
2710 void setDevice(Expr *E) { Device = E; }
2713 /// \brief Build 'device' clause.
2715 /// \param E Expression associated with this clause.
2716 /// \param StartLoc Starting location of the clause.
2717 /// \param LParenLoc Location of '('.
2718 /// \param EndLoc Ending location of the clause.
2720 OMPDeviceClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc,
2721 SourceLocation EndLoc)
2722 : OMPClause(OMPC_device, StartLoc, EndLoc), LParenLoc(LParenLoc),
2725 /// \brief Build an empty clause.
2728 : OMPClause(OMPC_device, SourceLocation(), SourceLocation()),
2729 LParenLoc(SourceLocation()), Device(nullptr) {}
2730 /// \brief Sets the location of '('.
2731 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2732 /// \brief Returns the location of '('.
2733 SourceLocation getLParenLoc() const { return LParenLoc; }
2734 /// \brief Return device number.
2735 Expr *getDevice() { return cast<Expr>(Device); }
2736 /// \brief Return device number.
2737 Expr *getDevice() const { return cast<Expr>(Device); }
2739 static bool classof(const OMPClause *T) {
2740 return T->getClauseKind() == OMPC_device;
2743 child_range children() { return child_range(&Device, &Device + 1); }
2746 /// \brief This represents 'threads' clause in the '#pragma omp ...' directive.
2749 /// #pragma omp ordered threads
2751 /// In this example directive '#pragma omp ordered' has simple 'threads' clause.
2753 class OMPThreadsClause : public OMPClause {
2755 /// \brief Build 'threads' clause.
2757 /// \param StartLoc Starting location of the clause.
2758 /// \param EndLoc Ending location of the clause.
2760 OMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc)
2761 : OMPClause(OMPC_threads, StartLoc, EndLoc) {}
2763 /// \brief Build an empty clause.
2766 : OMPClause(OMPC_threads, SourceLocation(), SourceLocation()) {}
2768 static bool classof(const OMPClause *T) {
2769 return T->getClauseKind() == OMPC_threads;
2772 child_range children() {
2773 return child_range(child_iterator(), child_iterator());
2777 /// \brief This represents 'simd' clause in the '#pragma omp ...' directive.
2780 /// #pragma omp ordered simd
2782 /// In this example directive '#pragma omp ordered' has simple 'simd' clause.
2784 class OMPSIMDClause : public OMPClause {
2786 /// \brief Build 'simd' clause.
2788 /// \param StartLoc Starting location of the clause.
2789 /// \param EndLoc Ending location of the clause.
2791 OMPSIMDClause(SourceLocation StartLoc, SourceLocation EndLoc)
2792 : OMPClause(OMPC_simd, StartLoc, EndLoc) {}
2794 /// \brief Build an empty clause.
2796 OMPSIMDClause() : OMPClause(OMPC_simd, SourceLocation(), SourceLocation()) {}
2798 static bool classof(const OMPClause *T) {
2799 return T->getClauseKind() == OMPC_simd;
2802 child_range children() {
2803 return child_range(child_iterator(), child_iterator());
2807 /// \brief Struct that defines common infrastructure to handle mappable
2808 /// expressions used in OpenMP clauses.
2809 class OMPClauseMappableExprCommon {
2811 // \brief Class that represents a component of a mappable expression. E.g.
2812 // for an expression S.a, the first component is a declaration reference
2813 // expression associated with 'S' and the second is a member expression
2814 // associated with the field declaration 'a'. If the expression is an array
2815 // subscript it may not have any associated declaration. In that case the
2816 // associated declaration is set to nullptr.
2817 class MappableComponent {
2818 // \brief Expression associated with the component.
2819 Expr *AssociatedExpression = nullptr;
2820 // \brief Declaration associated with the declaration. If the component does
2821 // not have a declaration (e.g. array subscripts or section), this is set to
2823 ValueDecl *AssociatedDeclaration = nullptr;
2826 explicit MappableComponent() {}
2827 explicit MappableComponent(Expr *AssociatedExpression,
2828 ValueDecl *AssociatedDeclaration)
2829 : AssociatedExpression(AssociatedExpression),
2830 AssociatedDeclaration(
2831 AssociatedDeclaration
2832 ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
2835 Expr *getAssociatedExpression() const { return AssociatedExpression; }
2836 ValueDecl *getAssociatedDeclaration() const {
2837 return AssociatedDeclaration;
2841 // \brief List of components of an expression. This first one is the whole
2842 // expression and the last one is the base expression.
2843 typedef SmallVector<MappableComponent, 8> MappableExprComponentList;
2844 typedef ArrayRef<MappableComponent> MappableExprComponentListRef;
2846 // \brief List of all component lists associated to the same base declaration.
2847 // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
2848 // their component list but the same base declaration 'S'.
2849 typedef SmallVector<MappableExprComponentList, 8> MappableExprComponentLists;
2850 typedef ArrayRef<MappableExprComponentList> MappableExprComponentListsRef;
2853 // \brief Return the total number of elements in a list of component lists.
2855 getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists);
2857 // \brief Return the total number of elements in a list of declarations. All
2858 // declarations are expected to be canonical.
2860 getUniqueDeclarationsTotalNumber(ArrayRef<ValueDecl *> Declarations);
2863 /// \brief This represents clauses with a list of expressions that are mappable.
2864 /// Examples of these clauses are 'map' in
2865 /// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
2866 /// in '#pragma omp target update...' directives.
2868 class OMPMappableExprListClause : public OMPVarListClause<T>,
2869 public OMPClauseMappableExprCommon {
2870 friend class OMPClauseReader;
2872 /// \brief Number of unique declarations in this clause.
2873 unsigned NumUniqueDeclarations;
2875 /// \brief Number of component lists in this clause.
2876 unsigned NumComponentLists;
2878 /// \brief Total number of components in this clause.
2879 unsigned NumComponents;
2882 /// \brief Get the unique declarations that are in the trailing objects of the
2884 MutableArrayRef<ValueDecl *> getUniqueDeclsRef() {
2885 return MutableArrayRef<ValueDecl *>(
2886 static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(),
2887 NumUniqueDeclarations);
2890 /// \brief Get the unique declarations that are in the trailing objects of the
2892 ArrayRef<ValueDecl *> getUniqueDeclsRef() const {
2893 return ArrayRef<ValueDecl *>(
2894 static_cast<const T *>(this)
2895 ->template getTrailingObjects<ValueDecl *>(),
2896 NumUniqueDeclarations);
2899 /// \brief Set the unique declarations that are in the trailing objects of the
2901 void setUniqueDecls(ArrayRef<ValueDecl *> UDs) {
2902 assert(UDs.size() == NumUniqueDeclarations &&
2903 "Unexpected amount of unique declarations.");
2904 std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin());
2907 /// \brief Get the number of lists per declaration that are in the trailing
2908 /// objects of the class.
2909 MutableArrayRef<unsigned> getDeclNumListsRef() {
2910 return MutableArrayRef<unsigned>(
2911 static_cast<T *>(this)->template getTrailingObjects<unsigned>(),
2912 NumUniqueDeclarations);
2915 /// \brief Get the number of lists per declaration that are in the trailing
2916 /// objects of the class.
2917 ArrayRef<unsigned> getDeclNumListsRef() const {
2918 return ArrayRef<unsigned>(
2919 static_cast<const T *>(this)->template getTrailingObjects<unsigned>(),
2920 NumUniqueDeclarations);
2923 /// \brief Set the number of lists per declaration that are in the trailing
2924 /// objects of the class.
2925 void setDeclNumLists(ArrayRef<unsigned> DNLs) {
2926 assert(DNLs.size() == NumUniqueDeclarations &&
2927 "Unexpected amount of list numbers.");
2928 std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin());
2931 /// \brief Get the cumulative component lists sizes that are in the trailing
2932 /// objects of the class. They are appended after the number of lists.
2933 MutableArrayRef<unsigned> getComponentListSizesRef() {
2934 return MutableArrayRef<unsigned>(
2935 static_cast<T *>(this)->template getTrailingObjects<unsigned>() +
2936 NumUniqueDeclarations,
2940 /// \brief Get the cumulative component lists sizes that are in the trailing
2941 /// objects of the class. They are appended after the number of lists.
2942 ArrayRef<unsigned> getComponentListSizesRef() const {
2943 return ArrayRef<unsigned>(
2944 static_cast<const T *>(this)->template getTrailingObjects<unsigned>() +
2945 NumUniqueDeclarations,
2949 /// \brief Set the cumulative component lists sizes that are in the trailing
2950 /// objects of the class.
2951 void setComponentListSizes(ArrayRef<unsigned> CLSs) {
2952 assert(CLSs.size() == NumComponentLists &&
2953 "Unexpected amount of component lists.");
2954 std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin());
2957 /// \brief Get the components that are in the trailing objects of the class.
2958 MutableArrayRef<MappableComponent> getComponentsRef() {
2959 return MutableArrayRef<MappableComponent>(
2960 static_cast<T *>(this)
2961 ->template getTrailingObjects<MappableComponent>(),
2965 /// \brief Get the components that are in the trailing objects of the class.
2966 ArrayRef<MappableComponent> getComponentsRef() const {
2967 return ArrayRef<MappableComponent>(
2968 static_cast<const T *>(this)
2969 ->template getTrailingObjects<MappableComponent>(),
2973 /// \brief Set the components that are in the trailing objects of the class.
2974 /// This requires the list sizes so that it can also fill the original
2975 /// expressions, which are the first component of each list.
2976 void setComponents(ArrayRef<MappableComponent> Components,
2977 ArrayRef<unsigned> CLSs) {
2978 assert(Components.size() == NumComponents &&
2979 "Unexpected amount of component lists.");
2980 assert(CLSs.size() == NumComponentLists &&
2981 "Unexpected amount of list sizes.");
2982 std::copy(Components.begin(), Components.end(), getComponentsRef().begin());
2985 /// \brief Fill the clause information from the list of declarations and
2986 /// associated component lists.
2987 void setClauseInfo(ArrayRef<ValueDecl *> Declarations,
2988 MappableExprComponentListsRef ComponentLists) {
2989 // Perform some checks to make sure the data sizes are consistent with the
2990 // information available when the clause was created.
2991 assert(getUniqueDeclarationsTotalNumber(Declarations) ==
2992 NumUniqueDeclarations &&
2993 "Unexpected number of mappable expression info entries!");
2994 assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
2995 "Unexpected total number of components!");
2996 assert(Declarations.size() == ComponentLists.size() &&
2997 "Declaration and component lists size is not consistent!");
2998 assert(Declarations.size() == NumComponentLists &&
2999 "Unexpected declaration and component lists size!");
3001 // Organize the components by declaration and retrieve the original
3002 // expression. Original expressions are always the first component of the
3003 // mappable component list.
3004 llvm::DenseMap<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
3007 auto CI = ComponentLists.begin();
3008 for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
3010 assert(!CI->empty() && "Invalid component list!");
3011 ComponentListMap[*DI].push_back(*CI);
3015 // Iterators of the target storage.
3016 auto UniqueDeclarations = getUniqueDeclsRef();
3017 auto UDI = UniqueDeclarations.begin();
3019 auto DeclNumLists = getDeclNumListsRef();
3020 auto DNLI = DeclNumLists.begin();
3022 auto ComponentListSizes = getComponentListSizesRef();
3023 auto CLSI = ComponentListSizes.begin();
3025 auto Components = getComponentsRef();
3026 auto CI = Components.begin();
3028 // Variable to compute the accumulation of the number of components.
3029 unsigned PrevSize = 0u;
3031 // Scan all the declarations and associated component lists.
3032 for (auto &M : ComponentListMap) {
3035 // The component lists.
3038 // Initialize the entry.
3045 // Obtain the cumulative sizes and concatenate all the components in the
3046 // reserved storage.
3048 // Accumulate with the previous size.
3049 PrevSize += C.size();
3055 // Append components after the current components iterator.
3056 CI = std::copy(C.begin(), C.end(), CI);
3061 /// \brief Build a clause for \a NumUniqueDeclarations declarations, \a
3062 /// NumComponentLists total component lists, and \a NumComponents total
3065 /// \param K Kind of the clause.
3066 /// \param StartLoc Starting location of the clause (the clause keyword).
3067 /// \param LParenLoc Location of '('.
3068 /// \param EndLoc Ending location of the clause.
3069 /// \param NumVars Number of expressions listed in the clause.
3070 /// \param NumUniqueDeclarations Number of unique base declarations in this
3072 /// \param NumComponentLists Number of component lists in this clause - one
3073 /// list for each expression in the clause.
3074 /// \param NumComponents Total number of expression components in the clause.
3076 OMPMappableExprListClause(OpenMPClauseKind K, SourceLocation StartLoc,
3077 SourceLocation LParenLoc, SourceLocation EndLoc,
3078 unsigned NumVars, unsigned NumUniqueDeclarations,
3079 unsigned NumComponentLists, unsigned NumComponents)
3080 : OMPVarListClause<T>(K, StartLoc, LParenLoc, EndLoc, NumVars),
3081 NumUniqueDeclarations(NumUniqueDeclarations),
3082 NumComponentLists(NumComponentLists), NumComponents(NumComponents) {}
3085 /// \brief Return the number of unique base declarations in this clause.
3086 unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
3087 /// \brief Return the number of lists derived from the clause expressions.
3088 unsigned getTotalComponentListNum() const { return NumComponentLists; }
3089 /// \brief Return the total number of components in all lists derived from the
3091 unsigned getTotalComponentsNum() const { return NumComponents; }
3093 /// \brief Iterator that browse the components by lists. It also allows
3094 /// browsing components of a single declaration.
3095 class const_component_lists_iterator
3096 : public llvm::iterator_adaptor_base<
3097 const_component_lists_iterator,
3098 MappableExprComponentListRef::const_iterator,
3099 std::forward_iterator_tag, MappableComponent, ptrdiff_t,
3100 MappableComponent, MappableComponent> {
3101 // The declaration the iterator currently refers to.
3102 ArrayRef<ValueDecl *>::iterator DeclCur;
3104 // The list number associated with the current declaration.
3105 ArrayRef<unsigned>::iterator NumListsCur;
3107 // Remaining lists for the current declaration.
3108 unsigned RemainingLists;
3110 // The cumulative size of the previous list, or zero if there is no previous
3112 unsigned PrevListSize;
3114 // The cumulative sizes of the current list - it will delimit the remaining
3115 // range of interest.
3116 ArrayRef<unsigned>::const_iterator ListSizeCur;
3117 ArrayRef<unsigned>::const_iterator ListSizeEnd;
3119 // Iterator to the end of the components storage.
3120 MappableExprComponentListRef::const_iterator End;
3123 /// \brief Construct an iterator that scans all lists.
3124 explicit const_component_lists_iterator(
3125 ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
3126 ArrayRef<unsigned> CumulativeListSizes,
3127 MappableExprComponentListRef Components)
3128 : const_component_lists_iterator::iterator_adaptor_base(
3129 Components.begin()),
3130 DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
3131 RemainingLists(0u), PrevListSize(0u),
3132 ListSizeCur(CumulativeListSizes.begin()),
3133 ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
3134 assert(UniqueDecls.size() == DeclsListNum.size() &&
3135 "Inconsistent number of declarations and list sizes!");
3136 if (!DeclsListNum.empty())
3137 RemainingLists = *NumListsCur;
3140 /// \brief Construct an iterator that scan lists for a given declaration \a
3142 explicit const_component_lists_iterator(
3143 const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
3144 ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
3145 MappableExprComponentListRef Components)
3146 : const_component_lists_iterator(UniqueDecls, DeclsListNum,
3147 CumulativeListSizes, Components) {
3149 // Look for the desired declaration. While we are looking for it, we
3150 // update the state so that we know the component where a given list
3152 for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
3153 if (*DeclCur == Declaration)
3156 assert(*NumListsCur > 0 && "No lists associated with declaration??");
3158 // Skip the lists associated with the current declaration, but save the
3159 // last list size that was skipped.
3160 std::advance(ListSizeCur, *NumListsCur - 1);
3161 PrevListSize = *ListSizeCur;
3165 // If we didn't find any declaration, advance the iterator to after the
3166 // last component and set remaining lists to zero.
3167 if (ListSizeCur == CumulativeListSizes.end()) {
3169 RemainingLists = 0u;
3173 // Set the remaining lists with the total number of lists of the current
3175 RemainingLists = *NumListsCur;
3177 // Adjust the list size end iterator to the end of the relevant range.
3178 ListSizeEnd = ListSizeCur;
3179 std::advance(ListSizeEnd, RemainingLists);
3181 // Given that the list sizes are cumulative, the index of the component
3182 // that start the list is the size of the previous list.
3183 std::advance(this->I, PrevListSize);
3186 // Return the array with the current list. The sizes are cumulative, so the
3187 // array size is the difference between the current size and previous one.
3188 std::pair<const ValueDecl *, MappableExprComponentListRef>
3190 assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
3191 return std::make_pair(
3193 MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize));
3195 std::pair<const ValueDecl *, MappableExprComponentListRef>
3196 operator->() const {
3200 // Skip the components of the current list.
3201 const_component_lists_iterator &operator++() {
3202 assert(ListSizeCur != ListSizeEnd && RemainingLists &&
3203 "Invalid iterator!");
3205 // If we don't have more lists just skip all the components. Otherwise,
3206 // advance the iterator by the number of components in the current list.
3207 if (std::next(ListSizeCur) == ListSizeEnd) {
3211 std::advance(this->I, *ListSizeCur - PrevListSize);
3212 PrevListSize = *ListSizeCur;
3214 // We are done with a declaration, move to the next one.
3215 if (!(--RemainingLists)) {
3218 RemainingLists = *NumListsCur;
3219 assert(RemainingLists && "No lists in the following declaration??");
3228 typedef llvm::iterator_range<const_component_lists_iterator>
3229 const_component_lists_range;
3231 /// \brief Iterators for all component lists.
3232 const_component_lists_iterator component_lists_begin() const {
3233 return const_component_lists_iterator(
3234 getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(),
3235 getComponentsRef());
3237 const_component_lists_iterator component_lists_end() const {
3238 return const_component_lists_iterator(
3239 ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(),
3240 MappableExprComponentListRef(getComponentsRef().end(),
3241 getComponentsRef().end()));
3243 const_component_lists_range component_lists() const {
3244 return {component_lists_begin(), component_lists_end()};
3247 /// \brief Iterators for component lists associated with the provided
3249 const_component_lists_iterator
3250 decl_component_lists_begin(const ValueDecl *VD) const {
3251 return const_component_lists_iterator(
3252 VD, getUniqueDeclsRef(), getDeclNumListsRef(),
3253 getComponentListSizesRef(), getComponentsRef());
3255 const_component_lists_iterator decl_component_lists_end() const {
3256 return component_lists_end();
3258 const_component_lists_range decl_component_lists(const ValueDecl *VD) const {
3259 return {decl_component_lists_begin(VD), decl_component_lists_end()};
3262 /// Iterators to access all the declarations, number of lists, list sizes, and
3264 typedef ArrayRef<ValueDecl *>::iterator const_all_decls_iterator;
3265 typedef llvm::iterator_range<const_all_decls_iterator> const_all_decls_range;
3266 const_all_decls_range all_decls() const {
3267 auto A = getUniqueDeclsRef();
3268 return const_all_decls_range(A.begin(), A.end());
3271 typedef ArrayRef<unsigned>::iterator const_all_num_lists_iterator;
3272 typedef llvm::iterator_range<const_all_num_lists_iterator>
3273 const_all_num_lists_range;
3274 const_all_num_lists_range all_num_lists() const {
3275 auto A = getDeclNumListsRef();
3276 return const_all_num_lists_range(A.begin(), A.end());
3279 typedef ArrayRef<unsigned>::iterator const_all_lists_sizes_iterator;
3280 typedef llvm::iterator_range<const_all_lists_sizes_iterator>
3281 const_all_lists_sizes_range;
3282 const_all_lists_sizes_range all_lists_sizes() const {
3283 auto A = getComponentListSizesRef();
3284 return const_all_lists_sizes_range(A.begin(), A.end());
3287 typedef ArrayRef<MappableComponent>::iterator const_all_components_iterator;
3288 typedef llvm::iterator_range<const_all_components_iterator>
3289 const_all_components_range;
3290 const_all_components_range all_components() const {
3291 auto A = getComponentsRef();
3292 return const_all_components_range(A.begin(), A.end());
3296 /// \brief This represents clause 'map' in the '#pragma omp ...'
3300 /// #pragma omp target map(a,b)
3302 /// In this example directive '#pragma omp target' has clause 'map'
3303 /// with the variables 'a' and 'b'.
3305 class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
3306 private llvm::TrailingObjects<
3307 OMPMapClause, Expr *, ValueDecl *, unsigned,
3308 OMPClauseMappableExprCommon::MappableComponent> {
3309 friend TrailingObjects;
3310 friend OMPVarListClause;
3311 friend OMPMappableExprListClause;
3312 friend class OMPClauseReader;
3314 /// Define the sizes of each trailing object array except the last one. This
3315 /// is required for TrailingObjects to work properly.
3316 size_t numTrailingObjects(OverloadToken<Expr *>) const {
3317 return varlist_size();
3319 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
3320 return getUniqueDeclarationsNum();
3322 size_t numTrailingObjects(OverloadToken<unsigned>) const {
3323 return getUniqueDeclarationsNum() + getTotalComponentListNum();
3326 /// \brief Map type modifier for the 'map' clause.
3327 OpenMPMapClauseKind MapTypeModifier;
3328 /// \brief Map type for the 'map' clause.
3329 OpenMPMapClauseKind MapType;
3330 /// \brief Is this an implicit map type or not.
3331 bool MapTypeIsImplicit;
3332 /// \brief Location of the map type.
3333 SourceLocation MapLoc;
3334 /// \brief Colon location.
3335 SourceLocation ColonLoc;
3337 /// \brief Set type modifier for the clause.
3339 /// \param T Type Modifier for the clause.
3341 void setMapTypeModifier(OpenMPMapClauseKind T) { MapTypeModifier = T; }
3343 /// \brief Set type for the clause.
3345 /// \param T Type for the clause.
3347 void setMapType(OpenMPMapClauseKind T) { MapType = T; }
3349 /// \brief Set type location.
3351 /// \param TLoc Type location.
3353 void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
3355 /// \brief Set colon location.
3356 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3358 /// \brief Build a clause for \a NumVars listed expressions, \a
3359 /// NumUniqueDeclarations declarations, \a NumComponentLists total component
3360 /// lists, and \a NumComponents total expression components.
3362 /// \param MapTypeModifier Map type modifier.
3363 /// \param MapType Map type.
3364 /// \param MapTypeIsImplicit Map type is inferred implicitly.
3365 /// \param MapLoc Location of the map type.
3366 /// \param StartLoc Starting location of the clause.
3367 /// \param EndLoc Ending location of the clause.
3368 /// \param NumVars Number of expressions listed in this clause.
3369 /// \param NumUniqueDeclarations Number of unique base declarations in this
3371 /// \param NumComponentLists Number of component lists in this clause.
3372 /// \param NumComponents Total number of expression components in the clause.
3374 explicit OMPMapClause(OpenMPMapClauseKind MapTypeModifier,
3375 OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
3376 SourceLocation MapLoc, SourceLocation StartLoc,
3377 SourceLocation LParenLoc, SourceLocation EndLoc,
3378 unsigned NumVars, unsigned NumUniqueDeclarations,
3379 unsigned NumComponentLists, unsigned NumComponents)
3380 : OMPMappableExprListClause(OMPC_map, StartLoc, LParenLoc, EndLoc,
3381 NumVars, NumUniqueDeclarations,
3382 NumComponentLists, NumComponents),
3383 MapTypeModifier(MapTypeModifier), MapType(MapType),
3384 MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {}
3386 /// \brief Build an empty clause.
3388 /// \param NumVars Number of expressions listed in this clause.
3389 /// \param NumUniqueDeclarations Number of unique base declarations in this
3391 /// \param NumComponentLists Number of component lists in this clause.
3392 /// \param NumComponents Total number of expression components in the clause.
3394 explicit OMPMapClause(unsigned NumVars, unsigned NumUniqueDeclarations,
3395 unsigned NumComponentLists, unsigned NumComponents)
3396 : OMPMappableExprListClause(
3397 OMPC_map, SourceLocation(), SourceLocation(), SourceLocation(),
3398 NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents),
3399 MapTypeModifier(OMPC_MAP_unknown), MapType(OMPC_MAP_unknown),
3400 MapTypeIsImplicit(false), MapLoc() {}
3403 /// \brief Creates clause with a list of variables \a VL.
3405 /// \param C AST context.
3406 /// \param StartLoc Starting location of the clause.
3407 /// \param EndLoc Ending location of the clause.
3408 /// \param Vars The original expression used in the clause.
3409 /// \param Declarations Declarations used in the clause.
3410 /// \param ComponentLists Component lists used in the clause.
3411 /// \param TypeModifier Map type modifier.
3412 /// \param Type Map type.
3413 /// \param TypeIsImplicit Map type is inferred implicitly.
3414 /// \param TypeLoc Location of the map type.
3416 static OMPMapClause *Create(const ASTContext &C, SourceLocation StartLoc,
3417 SourceLocation LParenLoc, SourceLocation EndLoc,
3418 ArrayRef<Expr *> Vars,
3419 ArrayRef<ValueDecl *> Declarations,
3420 MappableExprComponentListsRef ComponentLists,
3421 OpenMPMapClauseKind TypeModifier,
3422 OpenMPMapClauseKind Type, bool TypeIsImplicit,
3423 SourceLocation TypeLoc);
3424 /// \brief Creates an empty clause with the place for for \a NumVars original
3425 /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
3426 /// lists, and \a NumComponents expression components.
3428 /// \param C AST context.
3429 /// \param NumVars Number of expressions listed in the clause.
3430 /// \param NumUniqueDeclarations Number of unique base declarations in this
3432 /// \param NumComponentLists Number of unique base declarations in this
3434 /// \param NumComponents Total number of expression components in the clause.
3436 static OMPMapClause *CreateEmpty(const ASTContext &C, unsigned NumVars,
3437 unsigned NumUniqueDeclarations,
3438 unsigned NumComponentLists,
3439 unsigned NumComponents);
3441 /// \brief Fetches mapping kind for the clause.
3442 OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
3444 /// \brief Is this an implicit map type?
3445 /// We have to capture 'IsMapTypeImplicit' from the parser for more
3446 /// informative error messages. It helps distinguish map(r) from
3447 /// map(tofrom: r), which is important to print more helpful error
3448 /// messages for some target directives.
3449 bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
3451 /// \brief Fetches the map type modifier for the clause.
3452 OpenMPMapClauseKind getMapTypeModifier() const LLVM_READONLY {
3453 return MapTypeModifier;
3456 /// \brief Fetches location of clause mapping kind.
3457 SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
3459 /// \brief Get colon location.
3460 SourceLocation getColonLoc() const { return ColonLoc; }
3462 static bool classof(const OMPClause *T) {
3463 return T->getClauseKind() == OMPC_map;
3466 child_range children() {
3468 reinterpret_cast<Stmt **>(varlist_begin()),
3469 reinterpret_cast<Stmt **>(varlist_end()));
3473 /// \brief This represents 'num_teams' clause in the '#pragma omp ...'
3477 /// #pragma omp teams num_teams(n)
3479 /// In this example directive '#pragma omp teams' has clause 'num_teams'
3480 /// with single expression 'n'.
3482 class OMPNumTeamsClause : public OMPClause, public OMPClauseWithPreInit {
3483 friend class OMPClauseReader;
3484 /// \brief Location of '('.
3485 SourceLocation LParenLoc;
3486 /// \brief NumTeams number.
3488 /// \brief Set the NumTeams number.
3490 /// \param E NumTeams number.
3492 void setNumTeams(Expr *E) { NumTeams = E; }
3495 /// \brief Build 'num_teams' clause.
3497 /// \param E Expression associated with this clause.
3498 /// \param HelperE Helper Expression associated with this clause.
3499 /// \param CaptureRegion Innermost OpenMP region where expressions in this
3500 /// clause must be captured.
3501 /// \param StartLoc Starting location of the clause.
3502 /// \param LParenLoc Location of '('.
3503 /// \param EndLoc Ending location of the clause.
3505 OMPNumTeamsClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion,
3506 SourceLocation StartLoc, SourceLocation LParenLoc,
3507 SourceLocation EndLoc)
3508 : OMPClause(OMPC_num_teams, StartLoc, EndLoc), OMPClauseWithPreInit(this),
3509 LParenLoc(LParenLoc), NumTeams(E) {
3510 setPreInitStmt(HelperE, CaptureRegion);
3513 /// \brief Build an empty clause.
3516 : OMPClause(OMPC_num_teams, SourceLocation(), SourceLocation()),
3517 OMPClauseWithPreInit(this), LParenLoc(SourceLocation()),
3518 NumTeams(nullptr) {}
3519 /// \brief Sets the location of '('.
3520 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3521 /// \brief Returns the location of '('.
3522 SourceLocation getLParenLoc() const { return LParenLoc; }
3523 /// \brief Return NumTeams number.
3524 Expr *getNumTeams() { return cast<Expr>(NumTeams); }
3525 /// \brief Return NumTeams number.
3526 Expr *getNumTeams() const { return cast<Expr>(NumTeams); }
3528 static bool classof(const OMPClause *T) {
3529 return T->getClauseKind() == OMPC_num_teams;
3532 child_range children() { return child_range(&NumTeams, &NumTeams + 1); }
3535 /// \brief This represents 'thread_limit' clause in the '#pragma omp ...'
3539 /// #pragma omp teams thread_limit(n)
3541 /// In this example directive '#pragma omp teams' has clause 'thread_limit'
3542 /// with single expression 'n'.
3544 class OMPThreadLimitClause : public OMPClause, public OMPClauseWithPreInit {
3545 friend class OMPClauseReader;
3546 /// \brief Location of '('.
3547 SourceLocation LParenLoc;
3548 /// \brief ThreadLimit number.
3550 /// \brief Set the ThreadLimit number.
3552 /// \param E ThreadLimit number.
3554 void setThreadLimit(Expr *E) { ThreadLimit = E; }
3557 /// \brief Build 'thread_limit' clause.
3559 /// \param E Expression associated with this clause.
3560 /// \param HelperE Helper Expression associated with this clause.
3561 /// \param CaptureRegion Innermost OpenMP region where expressions in this
3562 /// clause must be captured.
3563 /// \param StartLoc Starting location of the clause.
3564 /// \param LParenLoc Location of '('.
3565 /// \param EndLoc Ending location of the clause.
3567 OMPThreadLimitClause(Expr *E, Stmt *HelperE,
3568 OpenMPDirectiveKind CaptureRegion,
3569 SourceLocation StartLoc, SourceLocation LParenLoc,
3570 SourceLocation EndLoc)
3571 : OMPClause(OMPC_thread_limit, StartLoc, EndLoc),
3572 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadLimit(E) {
3573 setPreInitStmt(HelperE, CaptureRegion);
3576 /// \brief Build an empty clause.
3578 OMPThreadLimitClause()
3579 : OMPClause(OMPC_thread_limit, SourceLocation(), SourceLocation()),
3580 OMPClauseWithPreInit(this), LParenLoc(SourceLocation()),
3581 ThreadLimit(nullptr) {}
3582 /// \brief Sets the location of '('.
3583 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3584 /// \brief Returns the location of '('.
3585 SourceLocation getLParenLoc() const { return LParenLoc; }
3586 /// \brief Return ThreadLimit number.
3587 Expr *getThreadLimit() { return cast<Expr>(ThreadLimit); }
3588 /// \brief Return ThreadLimit number.
3589 Expr *getThreadLimit() const { return cast<Expr>(ThreadLimit); }
3591 static bool classof(const OMPClause *T) {
3592 return T->getClauseKind() == OMPC_thread_limit;
3595 child_range children() { return child_range(&ThreadLimit, &ThreadLimit + 1); }
3598 /// \brief This represents 'priority' clause in the '#pragma omp ...'
3602 /// #pragma omp task priority(n)
3604 /// In this example directive '#pragma omp teams' has clause 'priority' with
3605 /// single expression 'n'.
3607 class OMPPriorityClause : public OMPClause {
3608 friend class OMPClauseReader;
3609 /// \brief Location of '('.
3610 SourceLocation LParenLoc;
3611 /// \brief Priority number.
3613 /// \brief Set the Priority number.
3615 /// \param E Priority number.
3617 void setPriority(Expr *E) { Priority = E; }
3620 /// \brief Build 'priority' clause.
3622 /// \param E Expression associated with this clause.
3623 /// \param StartLoc Starting location of the clause.
3624 /// \param LParenLoc Location of '('.
3625 /// \param EndLoc Ending location of the clause.
3627 OMPPriorityClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc,
3628 SourceLocation EndLoc)
3629 : OMPClause(OMPC_priority, StartLoc, EndLoc), LParenLoc(LParenLoc),
3632 /// \brief Build an empty clause.
3635 : OMPClause(OMPC_priority, SourceLocation(), SourceLocation()),
3636 LParenLoc(SourceLocation()), Priority(nullptr) {}
3637 /// \brief Sets the location of '('.
3638 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3639 /// \brief Returns the location of '('.
3640 SourceLocation getLParenLoc() const { return LParenLoc; }
3641 /// \brief Return Priority number.
3642 Expr *getPriority() { return cast<Expr>(Priority); }
3643 /// \brief Return Priority number.
3644 Expr *getPriority() const { return cast<Expr>(Priority); }
3646 static bool classof(const OMPClause *T) {
3647 return T->getClauseKind() == OMPC_priority;
3650 child_range children() { return child_range(&Priority, &Priority + 1); }
3653 /// \brief This represents 'grainsize' clause in the '#pragma omp ...'
3657 /// #pragma omp taskloop grainsize(4)
3659 /// In this example directive '#pragma omp taskloop' has clause 'grainsize'
3660 /// with single expression '4'.
3662 class OMPGrainsizeClause : public OMPClause {
3663 friend class OMPClauseReader;
3664 /// \brief Location of '('.
3665 SourceLocation LParenLoc;
3666 /// \brief Safe iteration space distance.
3669 /// \brief Set safelen.
3670 void setGrainsize(Expr *Size) { Grainsize = Size; }
3673 /// \brief Build 'grainsize' clause.
3675 /// \param Size Expression associated with this clause.
3676 /// \param StartLoc Starting location of the clause.
3677 /// \param EndLoc Ending location of the clause.
3679 OMPGrainsizeClause(Expr *Size, SourceLocation StartLoc,
3680 SourceLocation LParenLoc, SourceLocation EndLoc)
3681 : OMPClause(OMPC_grainsize, StartLoc, EndLoc), LParenLoc(LParenLoc),
3684 /// \brief Build an empty clause.
3686 explicit OMPGrainsizeClause()
3687 : OMPClause(OMPC_grainsize, SourceLocation(), SourceLocation()),
3688 LParenLoc(SourceLocation()), Grainsize(nullptr) {}
3690 /// \brief Sets the location of '('.
3691 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3692 /// \brief Returns the location of '('.
3693 SourceLocation getLParenLoc() const { return LParenLoc; }
3695 /// \brief Return safe iteration space distance.
3696 Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
3698 static bool classof(const OMPClause *T) {
3699 return T->getClauseKind() == OMPC_grainsize;
3702 child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
3705 /// \brief This represents 'nogroup' clause in the '#pragma omp ...' directive.
3708 /// #pragma omp taskloop nogroup
3710 /// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
3712 class OMPNogroupClause : public OMPClause {
3714 /// \brief Build 'nogroup' clause.
3716 /// \param StartLoc Starting location of the clause.
3717 /// \param EndLoc Ending location of the clause.
3719 OMPNogroupClause(SourceLocation StartLoc, SourceLocation EndLoc)
3720 : OMPClause(OMPC_nogroup, StartLoc, EndLoc) {}
3722 /// \brief Build an empty clause.
3725 : OMPClause(OMPC_nogroup, SourceLocation(), SourceLocation()) {}
3727 static bool classof(const OMPClause *T) {
3728 return T->getClauseKind() == OMPC_nogroup;
3731 child_range children() {
3732 return child_range(child_iterator(), child_iterator());
3736 /// \brief This represents 'num_tasks' clause in the '#pragma omp ...'
3740 /// #pragma omp taskloop num_tasks(4)
3742 /// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
3743 /// with single expression '4'.
3745 class OMPNumTasksClause : public OMPClause {
3746 friend class OMPClauseReader;
3747 /// \brief Location of '('.
3748 SourceLocation LParenLoc;
3749 /// \brief Safe iteration space distance.
3752 /// \brief Set safelen.
3753 void setNumTasks(Expr *Size) { NumTasks = Size; }
3756 /// \brief Build 'num_tasks' clause.
3758 /// \param Size Expression associated with this clause.
3759 /// \param StartLoc Starting location of the clause.
3760 /// \param EndLoc Ending location of the clause.
3762 OMPNumTasksClause(Expr *Size, SourceLocation StartLoc,
3763 SourceLocation LParenLoc, SourceLocation EndLoc)
3764 : OMPClause(OMPC_num_tasks, StartLoc, EndLoc), LParenLoc(LParenLoc),
3767 /// \brief Build an empty clause.
3769 explicit OMPNumTasksClause()
3770 : OMPClause(OMPC_num_tasks, SourceLocation(), SourceLocation()),
3771 LParenLoc(SourceLocation()), NumTasks(nullptr) {}
3773 /// \brief Sets the location of '('.
3774 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3775 /// \brief Returns the location of '('.
3776 SourceLocation getLParenLoc() const { return LParenLoc; }
3778 /// \brief Return safe iteration space distance.
3779 Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
3781 static bool classof(const OMPClause *T) {
3782 return T->getClauseKind() == OMPC_num_tasks;
3785 child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
3788 /// \brief This represents 'hint' clause in the '#pragma omp ...' directive.
3791 /// #pragma omp critical (name) hint(6)
3793 /// In this example directive '#pragma omp critical' has name 'name' and clause
3794 /// 'hint' with argument '6'.
3796 class OMPHintClause : public OMPClause {
3797 friend class OMPClauseReader;
3798 /// \brief Location of '('.
3799 SourceLocation LParenLoc;
3800 /// \brief Hint expression of the 'hint' clause.
3803 /// \brief Set hint expression.
3805 void setHint(Expr *H) { Hint = H; }
3808 /// \brief Build 'hint' clause with expression \a Hint.
3810 /// \param Hint Hint expression.
3811 /// \param StartLoc Starting location of the clause.
3812 /// \param LParenLoc Location of '('.
3813 /// \param EndLoc Ending location of the clause.
3815 OMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc,
3816 SourceLocation EndLoc)
3817 : OMPClause(OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
3820 /// \brief Build an empty clause.
3823 : OMPClause(OMPC_hint, SourceLocation(), SourceLocation()),
3824 LParenLoc(SourceLocation()), Hint(nullptr) {}
3826 /// \brief Sets the location of '('.
3827 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3828 /// \brief Returns the location of '('.
3829 SourceLocation getLParenLoc() const { return LParenLoc; }
3831 /// \brief Returns number of threads.
3832 Expr *getHint() const { return cast_or_null<Expr>(Hint); }
3834 static bool classof(const OMPClause *T) {
3835 return T->getClauseKind() == OMPC_hint;
3838 child_range children() { return child_range(&Hint, &Hint + 1); }
3841 /// \brief This represents 'dist_schedule' clause in the '#pragma omp ...'
3845 /// #pragma omp distribute dist_schedule(static, 3)
3847 /// In this example directive '#pragma omp distribute' has 'dist_schedule'
3848 /// clause with arguments 'static' and '3'.
3850 class OMPDistScheduleClause : public OMPClause, public OMPClauseWithPreInit {
3851 friend class OMPClauseReader;
3852 /// \brief Location of '('.
3853 SourceLocation LParenLoc;
3854 /// \brief A kind of the 'schedule' clause.
3855 OpenMPDistScheduleClauseKind Kind;
3856 /// \brief Start location of the schedule kind in source code.
3857 SourceLocation KindLoc;
3858 /// \brief Location of ',' (if any).
3859 SourceLocation CommaLoc;
3860 /// \brief Chunk size.
3863 /// \brief Set schedule kind.
3865 /// \param K Schedule kind.
3867 void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
3868 /// \brief Sets the location of '('.
3870 /// \param Loc Location of '('.
3872 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3873 /// \brief Set schedule kind start location.
3875 /// \param KLoc Schedule kind location.
3877 void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
3878 /// \brief Set location of ','.
3880 /// \param Loc Location of ','.
3882 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
3883 /// \brief Set chunk size.
3885 /// \param E Chunk size.
3887 void setChunkSize(Expr *E) { ChunkSize = E; }
3890 /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk
3891 /// size expression \a ChunkSize.
3893 /// \param StartLoc Starting location of the clause.
3894 /// \param LParenLoc Location of '('.
3895 /// \param KLoc Starting location of the argument.
3896 /// \param CommaLoc Location of ','.
3897 /// \param EndLoc Ending location of the clause.
3898 /// \param Kind DistSchedule kind.
3899 /// \param ChunkSize Chunk size.
3900 /// \param HelperChunkSize Helper chunk size for combined directives.
3902 OMPDistScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3903 SourceLocation KLoc, SourceLocation CommaLoc,
3904 SourceLocation EndLoc,
3905 OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
3906 Stmt *HelperChunkSize)
3907 : OMPClause(OMPC_dist_schedule, StartLoc, EndLoc),
3908 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
3909 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
3910 setPreInitStmt(HelperChunkSize);
3913 /// \brief Build an empty clause.
3915 explicit OMPDistScheduleClause()
3916 : OMPClause(OMPC_dist_schedule, SourceLocation(), SourceLocation()),
3917 OMPClauseWithPreInit(this), Kind(OMPC_DIST_SCHEDULE_unknown),
3918 ChunkSize(nullptr) {}
3920 /// \brief Get kind of the clause.
3922 OpenMPDistScheduleClauseKind getDistScheduleKind() const { return Kind; }
3923 /// \brief Get location of '('.
3925 SourceLocation getLParenLoc() { return LParenLoc; }
3926 /// \brief Get kind location.
3928 SourceLocation getDistScheduleKindLoc() { return KindLoc; }
3929 /// \brief Get location of ','.
3931 SourceLocation getCommaLoc() { return CommaLoc; }
3932 /// \brief Get chunk size.
3934 Expr *getChunkSize() { return ChunkSize; }
3935 /// \brief Get chunk size.
3937 const Expr *getChunkSize() const { return ChunkSize; }
3939 static bool classof(const OMPClause *T) {
3940 return T->getClauseKind() == OMPC_dist_schedule;
3943 child_range children() {
3944 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
3945 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
3949 /// \brief This represents 'defaultmap' clause in the '#pragma omp ...' directive.
3952 /// #pragma omp target defaultmap(tofrom: scalar)
3954 /// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
3955 /// 'scalar' with modifier 'tofrom'.
3957 class OMPDefaultmapClause : public OMPClause {
3958 friend class OMPClauseReader;
3959 /// \brief Location of '('.
3960 SourceLocation LParenLoc;
3961 /// \brief Modifiers for 'defaultmap' clause.
3962 OpenMPDefaultmapClauseModifier Modifier;
3963 /// \brief Locations of modifiers.
3964 SourceLocation ModifierLoc;
3965 /// \brief A kind of the 'defaultmap' clause.
3966 OpenMPDefaultmapClauseKind Kind;
3967 /// \brief Start location of the defaultmap kind in source code.
3968 SourceLocation KindLoc;
3970 /// \brief Set defaultmap kind.
3972 /// \param K Defaultmap kind.
3974 void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
3975 /// \brief Set the defaultmap modifier.
3977 /// \param M Defaultmap modifier.
3979 void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
3982 /// \brief Set location of the defaultmap modifier.
3984 void setDefaultmapModifierLoc(SourceLocation Loc) {
3987 /// \brief Sets the location of '('.
3989 /// \param Loc Location of '('.
3991 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3992 /// \brief Set defaultmap kind start location.
3994 /// \param KLoc Defaultmap kind location.
3996 void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
3999 /// \brief Build 'defaultmap' clause with defaultmap kind \a Kind
4001 /// \param StartLoc Starting location of the clause.
4002 /// \param LParenLoc Location of '('.
4003 /// \param KLoc Starting location of the argument.
4004 /// \param EndLoc Ending location of the clause.
4005 /// \param Kind Defaultmap kind.
4006 /// \param M The modifier applied to 'defaultmap' clause.
4007 /// \param MLoc Location of the modifier
4009 OMPDefaultmapClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4010 SourceLocation MLoc, SourceLocation KLoc,
4011 SourceLocation EndLoc, OpenMPDefaultmapClauseKind Kind,
4012 OpenMPDefaultmapClauseModifier M)
4013 : OMPClause(OMPC_defaultmap, StartLoc, EndLoc), LParenLoc(LParenLoc),
4014 Modifier(M), ModifierLoc(MLoc), Kind(Kind), KindLoc(KLoc) {}
4016 /// \brief Build an empty clause.
4018 explicit OMPDefaultmapClause()
4019 : OMPClause(OMPC_defaultmap, SourceLocation(), SourceLocation()),
4020 Modifier(OMPC_DEFAULTMAP_MODIFIER_unknown),
4021 Kind(OMPC_DEFAULTMAP_unknown) {}
4023 /// \brief Get kind of the clause.
4025 OpenMPDefaultmapClauseKind getDefaultmapKind() const { return Kind; }
4026 /// \brief Get the modifier of the clause.
4028 OpenMPDefaultmapClauseModifier getDefaultmapModifier() const {
4031 /// \brief Get location of '('.
4033 SourceLocation getLParenLoc() { return LParenLoc; }
4034 /// \brief Get kind location.
4036 SourceLocation getDefaultmapKindLoc() { return KindLoc; }
4037 /// \brief Get the modifier location.
4039 SourceLocation getDefaultmapModifierLoc() const {
4043 static bool classof(const OMPClause *T) {
4044 return T->getClauseKind() == OMPC_defaultmap;
4047 child_range children() {
4048 return child_range(child_iterator(), child_iterator());
4052 /// \brief This represents clause 'to' in the '#pragma omp ...'
4056 /// #pragma omp target update to(a,b)
4058 /// In this example directive '#pragma omp target update' has clause 'to'
4059 /// with the variables 'a' and 'b'.
4061 class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
4062 private llvm::TrailingObjects<
4063 OMPToClause, Expr *, ValueDecl *, unsigned,
4064 OMPClauseMappableExprCommon::MappableComponent> {
4065 friend TrailingObjects;
4066 friend OMPVarListClause;
4067 friend OMPMappableExprListClause;
4068 friend class OMPClauseReader;
4070 /// Define the sizes of each trailing object array except the last one. This
4071 /// is required for TrailingObjects to work properly.
4072 size_t numTrailingObjects(OverloadToken<Expr *>) const {
4073 return varlist_size();
4075 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4076 return getUniqueDeclarationsNum();
4078 size_t numTrailingObjects(OverloadToken<unsigned>) const {
4079 return getUniqueDeclarationsNum() + getTotalComponentListNum();
4082 /// \brief Build clause with number of variables \a NumVars.
4084 /// \param StartLoc Starting location of the clause.
4085 /// \param EndLoc Ending location of the clause.
4086 /// \param NumVars Number of expressions listed in this clause.
4087 /// \param NumUniqueDeclarations Number of unique base declarations in this
4089 /// \param NumComponentLists Number of component lists in this clause.
4090 /// \param NumComponents Total number of expression components in the clause.
4092 explicit OMPToClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4093 SourceLocation EndLoc, unsigned NumVars,
4094 unsigned NumUniqueDeclarations,
4095 unsigned NumComponentLists, unsigned NumComponents)
4096 : OMPMappableExprListClause(OMPC_to, StartLoc, LParenLoc, EndLoc, NumVars,
4097 NumUniqueDeclarations, NumComponentLists,
4100 /// \brief Build an empty clause.
4102 /// \param NumVars Number of expressions listed in this clause.
4103 /// \param NumUniqueDeclarations Number of unique base declarations in this
4105 /// \param NumComponentLists Number of component lists in this clause.
4106 /// \param NumComponents Total number of expression components in the clause.
4108 explicit OMPToClause(unsigned NumVars, unsigned NumUniqueDeclarations,
4109 unsigned NumComponentLists, unsigned NumComponents)
4110 : OMPMappableExprListClause(
4111 OMPC_to, SourceLocation(), SourceLocation(), SourceLocation(),
4112 NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents) {}
4115 /// \brief Creates clause with a list of variables \a Vars.
4117 /// \param C AST context.
4118 /// \param StartLoc Starting location of the clause.
4119 /// \param EndLoc Ending location of the clause.
4120 /// \param Vars The original expression used in the clause.
4121 /// \param Declarations Declarations used in the clause.
4122 /// \param ComponentLists Component lists used in the clause.
4124 static OMPToClause *Create(const ASTContext &C, SourceLocation StartLoc,
4125 SourceLocation LParenLoc, SourceLocation EndLoc,
4126 ArrayRef<Expr *> Vars,
4127 ArrayRef<ValueDecl *> Declarations,
4128 MappableExprComponentListsRef ComponentLists);
4130 /// \brief Creates an empty clause with the place for \a NumVars variables.
4132 /// \param C AST context.
4133 /// \param NumVars Number of expressions listed in the clause.
4134 /// \param NumUniqueDeclarations Number of unique base declarations in this
4136 /// \param NumComponentLists Number of unique base declarations in this
4138 /// \param NumComponents Total number of expression components in the clause.
4140 static OMPToClause *CreateEmpty(const ASTContext &C, unsigned NumVars,
4141 unsigned NumUniqueDeclarations,
4142 unsigned NumComponentLists,
4143 unsigned NumComponents);
4145 static bool classof(const OMPClause *T) {
4146 return T->getClauseKind() == OMPC_to;
4149 child_range children() {
4150 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4151 reinterpret_cast<Stmt **>(varlist_end()));
4155 /// \brief This represents clause 'from' in the '#pragma omp ...'
4159 /// #pragma omp target update from(a,b)
4161 /// In this example directive '#pragma omp target update' has clause 'from'
4162 /// with the variables 'a' and 'b'.
4164 class OMPFromClause final
4165 : public OMPMappableExprListClause<OMPFromClause>,
4166 private llvm::TrailingObjects<
4167 OMPFromClause, Expr *, ValueDecl *, unsigned,
4168 OMPClauseMappableExprCommon::MappableComponent> {
4169 friend TrailingObjects;
4170 friend OMPVarListClause;
4171 friend OMPMappableExprListClause;
4172 friend class OMPClauseReader;
4174 /// Define the sizes of each trailing object array except the last one. This
4175 /// is required for TrailingObjects to work properly.
4176 size_t numTrailingObjects(OverloadToken<Expr *>) const {
4177 return varlist_size();
4179 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4180 return getUniqueDeclarationsNum();
4182 size_t numTrailingObjects(OverloadToken<unsigned>) const {
4183 return getUniqueDeclarationsNum() + getTotalComponentListNum();
4186 /// \brief Build clause with number of variables \a NumVars.
4188 /// \param StartLoc Starting location of the clause.
4189 /// \param EndLoc Ending location of the clause.
4190 /// \param NumVars Number of expressions listed in this clause.
4191 /// \param NumUniqueDeclarations Number of unique base declarations in this
4193 /// \param NumComponentLists Number of component lists in this clause.
4194 /// \param NumComponents Total number of expression components in the clause.
4196 explicit OMPFromClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4197 SourceLocation EndLoc, unsigned NumVars,
4198 unsigned NumUniqueDeclarations,
4199 unsigned NumComponentLists, unsigned NumComponents)
4200 : OMPMappableExprListClause(OMPC_from, StartLoc, LParenLoc, EndLoc,
4201 NumVars, NumUniqueDeclarations,
4202 NumComponentLists, NumComponents) {}
4204 /// \brief Build an empty clause.
4206 /// \param NumVars Number of expressions listed in this clause.
4207 /// \param NumUniqueDeclarations Number of unique base declarations in this
4209 /// \param NumComponentLists Number of component lists in this clause.
4210 /// \param NumComponents Total number of expression components in the clause.
4212 explicit OMPFromClause(unsigned NumVars, unsigned NumUniqueDeclarations,
4213 unsigned NumComponentLists, unsigned NumComponents)
4214 : OMPMappableExprListClause(
4215 OMPC_from, SourceLocation(), SourceLocation(), SourceLocation(),
4216 NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents) {}
4219 /// \brief Creates clause with a list of variables \a Vars.
4221 /// \param C AST context.
4222 /// \param StartLoc Starting location of the clause.
4223 /// \param EndLoc Ending location of the clause.
4224 /// \param Vars The original expression used in the clause.
4225 /// \param Declarations Declarations used in the clause.
4226 /// \param ComponentLists Component lists used in the clause.
4228 static OMPFromClause *Create(const ASTContext &C, SourceLocation StartLoc,
4229 SourceLocation LParenLoc, SourceLocation EndLoc,
4230 ArrayRef<Expr *> Vars,
4231 ArrayRef<ValueDecl *> Declarations,
4232 MappableExprComponentListsRef ComponentLists);
4234 /// \brief Creates an empty clause with the place for \a NumVars variables.
4236 /// \param C AST context.
4237 /// \param NumVars Number of expressions listed in the clause.
4238 /// \param NumUniqueDeclarations Number of unique base declarations in this
4240 /// \param NumComponentLists Number of unique base declarations in this
4242 /// \param NumComponents Total number of expression components in the clause.
4244 static OMPFromClause *CreateEmpty(const ASTContext &C, unsigned NumVars,
4245 unsigned NumUniqueDeclarations,
4246 unsigned NumComponentLists,
4247 unsigned NumComponents);
4249 static bool classof(const OMPClause *T) {
4250 return T->getClauseKind() == OMPC_from;
4253 child_range children() {
4254 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4255 reinterpret_cast<Stmt **>(varlist_end()));
4259 /// This represents clause 'use_device_ptr' in the '#pragma omp ...'
4263 /// #pragma omp target data use_device_ptr(a,b)
4265 /// In this example directive '#pragma omp target data' has clause
4266 /// 'use_device_ptr' with the variables 'a' and 'b'.
4268 class OMPUseDevicePtrClause final
4269 : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
4270 private llvm::TrailingObjects<
4271 OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
4272 OMPClauseMappableExprCommon::MappableComponent> {
4273 friend TrailingObjects;
4274 friend OMPVarListClause;
4275 friend OMPMappableExprListClause;
4276 friend class OMPClauseReader;
4278 /// Define the sizes of each trailing object array except the last one. This
4279 /// is required for TrailingObjects to work properly.
4280 size_t numTrailingObjects(OverloadToken<Expr *>) const {
4281 return 3 * varlist_size();
4283 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4284 return getUniqueDeclarationsNum();
4286 size_t numTrailingObjects(OverloadToken<unsigned>) const {
4287 return getUniqueDeclarationsNum() + getTotalComponentListNum();
4290 /// Build clause with number of variables \a NumVars.
4292 /// \param StartLoc Starting location of the clause.
4293 /// \param EndLoc Ending location of the clause.
4294 /// \param NumVars Number of expressions listed in this clause.
4295 /// \param NumUniqueDeclarations Number of unique base declarations in this
4297 /// \param NumComponentLists Number of component lists in this clause.
4298 /// \param NumComponents Total number of expression components in the clause.
4300 explicit OMPUseDevicePtrClause(SourceLocation StartLoc,
4301 SourceLocation LParenLoc,
4302 SourceLocation EndLoc, unsigned NumVars,
4303 unsigned NumUniqueDeclarations,
4304 unsigned NumComponentLists,
4305 unsigned NumComponents)
4306 : OMPMappableExprListClause(OMPC_use_device_ptr, StartLoc, LParenLoc,
4307 EndLoc, NumVars, NumUniqueDeclarations,
4308 NumComponentLists, NumComponents) {}
4310 /// Build an empty clause.
4312 /// \param NumVars Number of expressions listed in this clause.
4313 /// \param NumUniqueDeclarations Number of unique base declarations in this
4315 /// \param NumComponentLists Number of component lists in this clause.
4316 /// \param NumComponents Total number of expression components in the clause.
4318 explicit OMPUseDevicePtrClause(unsigned NumVars,
4319 unsigned NumUniqueDeclarations,
4320 unsigned NumComponentLists,
4321 unsigned NumComponents)
4322 : OMPMappableExprListClause(OMPC_use_device_ptr, SourceLocation(),
4323 SourceLocation(), SourceLocation(), NumVars,
4324 NumUniqueDeclarations, NumComponentLists,
4327 /// Sets the list of references to private copies with initializers for new
4328 /// private variables.
4329 /// \param VL List of references.
4330 void setPrivateCopies(ArrayRef<Expr *> VL);
4332 /// Gets the list of references to private copies with initializers for new
4333 /// private variables.
4334 MutableArrayRef<Expr *> getPrivateCopies() {
4335 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4337 ArrayRef<const Expr *> getPrivateCopies() const {
4338 return llvm::makeArrayRef(varlist_end(), varlist_size());
4341 /// Sets the list of references to initializer variables for new private
4343 /// \param VL List of references.
4344 void setInits(ArrayRef<Expr *> VL);
4346 /// Gets the list of references to initializer variables for new private
4348 MutableArrayRef<Expr *> getInits() {
4349 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
4351 ArrayRef<const Expr *> getInits() const {
4352 return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
4356 /// Creates clause with a list of variables \a Vars.
4358 /// \param C AST context.
4359 /// \param StartLoc Starting location of the clause.
4360 /// \param EndLoc Ending location of the clause.
4361 /// \param Vars The original expression used in the clause.
4362 /// \param PrivateVars Expressions referring to private copies.
4363 /// \param Inits Expressions referring to private copy initializers.
4364 /// \param Declarations Declarations used in the clause.
4365 /// \param ComponentLists Component lists used in the clause.
4367 static OMPUseDevicePtrClause *
4368 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4369 SourceLocation EndLoc, ArrayRef<Expr *> Vars,
4370 ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *> Inits,
4371 ArrayRef<ValueDecl *> Declarations,
4372 MappableExprComponentListsRef ComponentLists);
4374 /// Creates an empty clause with the place for \a NumVars variables.
4376 /// \param C AST context.
4377 /// \param NumVars Number of expressions listed in the clause.
4378 /// \param NumUniqueDeclarations Number of unique base declarations in this
4380 /// \param NumComponentLists Number of unique base declarations in this
4382 /// \param NumComponents Total number of expression components in the clause.
4384 static OMPUseDevicePtrClause *CreateEmpty(const ASTContext &C,
4386 unsigned NumUniqueDeclarations,
4387 unsigned NumComponentLists,
4388 unsigned NumComponents);
4390 typedef MutableArrayRef<Expr *>::iterator private_copies_iterator;
4391 typedef ArrayRef<const Expr *>::iterator private_copies_const_iterator;
4392 typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
4393 typedef llvm::iterator_range<private_copies_const_iterator>
4394 private_copies_const_range;
4396 private_copies_range private_copies() {
4397 return private_copies_range(getPrivateCopies().begin(),
4398 getPrivateCopies().end());
4400 private_copies_const_range private_copies() const {
4401 return private_copies_const_range(getPrivateCopies().begin(),
4402 getPrivateCopies().end());
4405 typedef MutableArrayRef<Expr *>::iterator inits_iterator;
4406 typedef ArrayRef<const Expr *>::iterator inits_const_iterator;
4407 typedef llvm::iterator_range<inits_iterator> inits_range;
4408 typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
4410 inits_range inits() {
4411 return inits_range(getInits().begin(), getInits().end());
4413 inits_const_range inits() const {
4414 return inits_const_range(getInits().begin(), getInits().end());
4417 child_range children() {
4418 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4419 reinterpret_cast<Stmt **>(varlist_end()));
4422 static bool classof(const OMPClause *T) {
4423 return T->getClauseKind() == OMPC_use_device_ptr;
4427 /// This represents clause 'is_device_ptr' in the '#pragma omp ...'
4431 /// #pragma omp target is_device_ptr(a,b)
4433 /// In this example directive '#pragma omp target' has clause
4434 /// 'is_device_ptr' with the variables 'a' and 'b'.
4436 class OMPIsDevicePtrClause final
4437 : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
4438 private llvm::TrailingObjects<
4439 OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
4440 OMPClauseMappableExprCommon::MappableComponent> {
4441 friend TrailingObjects;
4442 friend OMPVarListClause;
4443 friend OMPMappableExprListClause;
4444 friend class OMPClauseReader;
4446 /// Define the sizes of each trailing object array except the last one. This
4447 /// is required for TrailingObjects to work properly.
4448 size_t numTrailingObjects(OverloadToken<Expr *>) const {
4449 return varlist_size();
4451 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4452 return getUniqueDeclarationsNum();
4454 size_t numTrailingObjects(OverloadToken<unsigned>) const {
4455 return getUniqueDeclarationsNum() + getTotalComponentListNum();
4457 /// Build clause with number of variables \a NumVars.
4459 /// \param StartLoc Starting location of the clause.
4460 /// \param EndLoc Ending location of the clause.
4461 /// \param NumVars Number of expressions listed in this clause.
4462 /// \param NumUniqueDeclarations Number of unique base declarations in this
4464 /// \param NumComponentLists Number of component lists in this clause.
4465 /// \param NumComponents Total number of expression components in the clause.
4467 explicit OMPIsDevicePtrClause(SourceLocation StartLoc,
4468 SourceLocation LParenLoc, SourceLocation EndLoc,
4470 unsigned NumUniqueDeclarations,
4471 unsigned NumComponentLists,
4472 unsigned NumComponents)
4473 : OMPMappableExprListClause(OMPC_is_device_ptr, StartLoc, LParenLoc,
4474 EndLoc, NumVars, NumUniqueDeclarations,
4475 NumComponentLists, NumComponents) {}
4477 /// Build an empty clause.
4479 /// \param NumVars Number of expressions listed in this clause.
4480 /// \param NumUniqueDeclarations Number of unique base declarations in this
4482 /// \param NumComponentLists Number of component lists in this clause.
4483 /// \param NumComponents Total number of expression components in the clause.
4485 explicit OMPIsDevicePtrClause(unsigned NumVars,
4486 unsigned NumUniqueDeclarations,
4487 unsigned NumComponentLists,
4488 unsigned NumComponents)
4489 : OMPMappableExprListClause(OMPC_is_device_ptr, SourceLocation(),
4490 SourceLocation(), SourceLocation(), NumVars,
4491 NumUniqueDeclarations, NumComponentLists,
4495 /// Creates clause with a list of variables \a Vars.
4497 /// \param C AST context.
4498 /// \param StartLoc Starting location of the clause.
4499 /// \param EndLoc Ending location of the clause.
4500 /// \param Vars The original expression used in the clause.
4501 /// \param Declarations Declarations used in the clause.
4502 /// \param ComponentLists Component lists used in the clause.
4504 static OMPIsDevicePtrClause *
4505 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4506 SourceLocation EndLoc, ArrayRef<Expr *> Vars,
4507 ArrayRef<ValueDecl *> Declarations,
4508 MappableExprComponentListsRef ComponentLists);
4510 /// Creates an empty clause with the place for \a NumVars variables.
4512 /// \param C AST context.
4513 /// \param NumVars Number of expressions listed in the clause.
4514 /// \param NumUniqueDeclarations Number of unique base declarations in this
4516 /// \param NumComponentLists Number of unique base declarations in this
4518 /// \param NumComponents Total number of expression components in the clause.
4520 static OMPIsDevicePtrClause *CreateEmpty(const ASTContext &C,
4522 unsigned NumUniqueDeclarations,
4523 unsigned NumComponentLists,
4524 unsigned NumComponents);
4526 child_range children() {
4527 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4528 reinterpret_cast<Stmt **>(varlist_end()));
4531 static bool classof(const OMPClause *T) {
4532 return T->getClauseKind() == OMPC_is_device_ptr;
4535 } // end namespace clang
4537 #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H