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.
80 /// Set pre-initialization statement for the clause.
81 void setPreInitStmt(Stmt *S) { PreInit = S; }
82 OMPClauseWithPreInit(const OMPClause *This) : PreInit(nullptr) {
83 assert(get(This) && "get is not tuned for pre-init.");
87 /// Get pre-initialization statement for the clause.
88 const Stmt *getPreInitStmt() const { return PreInit; }
89 /// Get pre-initialization statement for the clause.
90 Stmt *getPreInitStmt() { return PreInit; }
91 static OMPClauseWithPreInit *get(OMPClause *C);
92 static const OMPClauseWithPreInit *get(const OMPClause *C);
95 /// Class that handles post-update expression for some clauses, like
96 /// 'lastprivate', 'reduction' etc.
97 class OMPClauseWithPostUpdate : public OMPClauseWithPreInit {
98 friend class OMPClauseReader;
99 /// Post-update expression for the clause.
102 /// Set pre-initialization statement for the clause.
103 void setPostUpdateExpr(Expr *S) { PostUpdate = S; }
104 OMPClauseWithPostUpdate(const OMPClause *This)
105 : OMPClauseWithPreInit(This), PostUpdate(nullptr) {
106 assert(get(This) && "get is not tuned for post-update.");
110 /// Get post-update expression for the clause.
111 const Expr *getPostUpdateExpr() const { return PostUpdate; }
112 /// Get post-update expression for the clause.
113 Expr *getPostUpdateExpr() { return PostUpdate; }
114 static OMPClauseWithPostUpdate *get(OMPClause *C);
115 static const OMPClauseWithPostUpdate *get(const OMPClause *C);
118 /// \brief This represents clauses with the list of variables like 'private',
119 /// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
120 /// '#pragma omp ...' directives.
121 template <class T> class OMPVarListClause : public OMPClause {
122 friend class OMPClauseReader;
123 /// \brief Location of '('.
124 SourceLocation LParenLoc;
125 /// \brief Number of variables in the list.
129 /// \brief Fetches list of variables associated with this clause.
130 MutableArrayRef<Expr *> getVarRefs() {
131 return MutableArrayRef<Expr *>(
132 static_cast<T *>(this)->template getTrailingObjects<Expr *>(), NumVars);
135 /// \brief Sets the list of variables for this clause.
136 void setVarRefs(ArrayRef<Expr *> VL) {
137 assert(VL.size() == NumVars &&
138 "Number of variables is not the same as the preallocated buffer");
139 std::copy(VL.begin(), VL.end(),
140 static_cast<T *>(this)->template getTrailingObjects<Expr *>());
143 /// \brief Build a clause with \a N variables
145 /// \param K Kind of the clause.
146 /// \param StartLoc Starting location of the clause (the clause keyword).
147 /// \param LParenLoc Location of '('.
148 /// \param EndLoc Ending location of the clause.
149 /// \param N Number of the variables in the clause.
151 OMPVarListClause(OpenMPClauseKind K, SourceLocation StartLoc,
152 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
153 : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {}
156 typedef MutableArrayRef<Expr *>::iterator varlist_iterator;
157 typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
158 typedef llvm::iterator_range<varlist_iterator> varlist_range;
159 typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
161 unsigned varlist_size() const { return NumVars; }
162 bool varlist_empty() const { return NumVars == 0; }
164 varlist_range varlists() {
165 return varlist_range(varlist_begin(), varlist_end());
167 varlist_const_range varlists() const {
168 return varlist_const_range(varlist_begin(), varlist_end());
171 varlist_iterator varlist_begin() { return getVarRefs().begin(); }
172 varlist_iterator varlist_end() { return getVarRefs().end(); }
173 varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
174 varlist_const_iterator varlist_end() const { return getVarRefs().end(); }
176 /// \brief Sets the location of '('.
177 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
178 /// \brief Returns the location of '('.
179 SourceLocation getLParenLoc() const { return LParenLoc; }
181 /// \brief Fetches list of all variables in the clause.
182 ArrayRef<const Expr *> getVarRefs() const {
183 return llvm::makeArrayRef(
184 static_cast<const T *>(this)->template getTrailingObjects<Expr *>(),
189 /// \brief This represents 'if' clause in the '#pragma omp ...' directive.
192 /// #pragma omp parallel if(parallel:a > 5)
194 /// In this example directive '#pragma omp parallel' has simple 'if' clause with
195 /// condition 'a > 5' and directive name modifier 'parallel'.
197 class OMPIfClause : public OMPClause {
198 friend class OMPClauseReader;
199 /// \brief Location of '('.
200 SourceLocation LParenLoc;
201 /// \brief Condition of the 'if' clause.
203 /// \brief Location of ':' (if any).
204 SourceLocation ColonLoc;
205 /// \brief Directive name modifier for the clause.
206 OpenMPDirectiveKind NameModifier;
207 /// \brief Name modifier location.
208 SourceLocation NameModifierLoc;
210 /// \brief Set condition.
212 void setCondition(Expr *Cond) { Condition = Cond; }
213 /// \brief Set directive name modifier for the clause.
215 void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
216 /// \brief Set location of directive name modifier for the clause.
218 void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
219 /// \brief Set location of ':'.
221 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
224 /// \brief Build 'if' clause with condition \a Cond.
226 /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
227 /// \param Cond Condition of the clause.
228 /// \param StartLoc Starting location of the clause.
229 /// \param LParenLoc Location of '('.
230 /// \param NameModifierLoc Location of directive name modifier.
231 /// \param ColonLoc [OpenMP 4.1] Location of ':'.
232 /// \param EndLoc Ending location of the clause.
234 OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond,
235 SourceLocation StartLoc, SourceLocation LParenLoc,
236 SourceLocation NameModifierLoc, SourceLocation ColonLoc,
237 SourceLocation EndLoc)
238 : OMPClause(OMPC_if, StartLoc, EndLoc), LParenLoc(LParenLoc),
239 Condition(Cond), ColonLoc(ColonLoc), NameModifier(NameModifier),
240 NameModifierLoc(NameModifierLoc) {}
242 /// \brief Build an empty clause.
245 : OMPClause(OMPC_if, SourceLocation(), SourceLocation()), LParenLoc(),
246 Condition(nullptr), ColonLoc(), NameModifier(OMPD_unknown),
249 /// \brief Sets the location of '('.
250 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
251 /// \brief Returns the location of '('.
252 SourceLocation getLParenLoc() const { return LParenLoc; }
254 /// \brief Return the location of ':'.
255 SourceLocation getColonLoc() const { return ColonLoc; }
257 /// \brief Returns condition.
258 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
259 /// \brief Return directive name modifier associated with the clause.
260 OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
262 /// \brief Return the location of directive name modifier.
263 SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
265 static bool classof(const OMPClause *T) {
266 return T->getClauseKind() == OMPC_if;
269 child_range children() { return child_range(&Condition, &Condition + 1); }
272 /// \brief This represents 'final' clause in the '#pragma omp ...' directive.
275 /// #pragma omp task final(a > 5)
277 /// In this example directive '#pragma omp task' has simple 'final'
278 /// clause with condition 'a > 5'.
280 class OMPFinalClause : public OMPClause {
281 friend class OMPClauseReader;
282 /// \brief Location of '('.
283 SourceLocation LParenLoc;
284 /// \brief Condition of the 'if' clause.
287 /// \brief Set condition.
289 void setCondition(Expr *Cond) { Condition = Cond; }
292 /// \brief Build 'final' clause with condition \a Cond.
294 /// \param StartLoc Starting location of the clause.
295 /// \param LParenLoc Location of '('.
296 /// \param Cond Condition of the clause.
297 /// \param EndLoc Ending location of the clause.
299 OMPFinalClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,
300 SourceLocation EndLoc)
301 : OMPClause(OMPC_final, StartLoc, EndLoc), LParenLoc(LParenLoc),
304 /// \brief Build an empty clause.
307 : OMPClause(OMPC_final, SourceLocation(), SourceLocation()),
308 LParenLoc(SourceLocation()), Condition(nullptr) {}
310 /// \brief Sets the location of '('.
311 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
312 /// \brief Returns the location of '('.
313 SourceLocation getLParenLoc() const { return LParenLoc; }
315 /// \brief Returns condition.
316 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
318 static bool classof(const OMPClause *T) {
319 return T->getClauseKind() == OMPC_final;
322 child_range children() { return child_range(&Condition, &Condition + 1); }
325 /// \brief This represents 'num_threads' clause in the '#pragma omp ...'
329 /// #pragma omp parallel num_threads(6)
331 /// In this example directive '#pragma omp parallel' has simple 'num_threads'
332 /// clause with number of threads '6'.
334 class OMPNumThreadsClause : public OMPClause {
335 friend class OMPClauseReader;
336 /// \brief Location of '('.
337 SourceLocation LParenLoc;
338 /// \brief Condition of the 'num_threads' clause.
341 /// \brief Set condition.
343 void setNumThreads(Expr *NThreads) { NumThreads = NThreads; }
346 /// \brief Build 'num_threads' clause with condition \a NumThreads.
348 /// \param NumThreads Number of threads for the construct.
349 /// \param StartLoc Starting location of the clause.
350 /// \param LParenLoc Location of '('.
351 /// \param EndLoc Ending location of the clause.
353 OMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc,
354 SourceLocation LParenLoc, SourceLocation EndLoc)
355 : OMPClause(OMPC_num_threads, StartLoc, EndLoc), LParenLoc(LParenLoc),
356 NumThreads(NumThreads) {}
358 /// \brief Build an empty clause.
360 OMPNumThreadsClause()
361 : OMPClause(OMPC_num_threads, SourceLocation(), SourceLocation()),
362 LParenLoc(SourceLocation()), NumThreads(nullptr) {}
364 /// \brief Sets the location of '('.
365 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
366 /// \brief Returns the location of '('.
367 SourceLocation getLParenLoc() const { return LParenLoc; }
369 /// \brief Returns number of threads.
370 Expr *getNumThreads() const { return cast_or_null<Expr>(NumThreads); }
372 static bool classof(const OMPClause *T) {
373 return T->getClauseKind() == OMPC_num_threads;
376 child_range children() { return child_range(&NumThreads, &NumThreads + 1); }
379 /// \brief This represents 'safelen' clause in the '#pragma omp ...'
383 /// #pragma omp simd safelen(4)
385 /// In this example directive '#pragma omp simd' has clause 'safelen'
386 /// with single expression '4'.
387 /// If the safelen clause is used then no two iterations executed
388 /// concurrently with SIMD instructions can have a greater distance
389 /// in the logical iteration space than its value. The parameter of
390 /// the safelen clause must be a constant positive integer expression.
392 class OMPSafelenClause : public OMPClause {
393 friend class OMPClauseReader;
394 /// \brief Location of '('.
395 SourceLocation LParenLoc;
396 /// \brief Safe iteration space distance.
399 /// \brief Set safelen.
400 void setSafelen(Expr *Len) { Safelen = Len; }
403 /// \brief Build 'safelen' clause.
405 /// \param Len Expression associated with this clause.
406 /// \param StartLoc Starting location of the clause.
407 /// \param EndLoc Ending location of the clause.
409 OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc,
410 SourceLocation EndLoc)
411 : OMPClause(OMPC_safelen, StartLoc, EndLoc), LParenLoc(LParenLoc),
414 /// \brief Build an empty clause.
416 explicit OMPSafelenClause()
417 : OMPClause(OMPC_safelen, SourceLocation(), SourceLocation()),
418 LParenLoc(SourceLocation()), Safelen(nullptr) {}
420 /// \brief Sets the location of '('.
421 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
422 /// \brief Returns the location of '('.
423 SourceLocation getLParenLoc() const { return LParenLoc; }
425 /// \brief Return safe iteration space distance.
426 Expr *getSafelen() const { return cast_or_null<Expr>(Safelen); }
428 static bool classof(const OMPClause *T) {
429 return T->getClauseKind() == OMPC_safelen;
432 child_range children() { return child_range(&Safelen, &Safelen + 1); }
435 /// \brief This represents 'simdlen' clause in the '#pragma omp ...'
439 /// #pragma omp simd simdlen(4)
441 /// In this example directive '#pragma omp simd' has clause 'simdlen'
442 /// with single expression '4'.
443 /// If the 'simdlen' clause is used then it specifies the preferred number of
444 /// iterations to be executed concurrently. The parameter of the 'simdlen'
445 /// clause must be a constant positive integer expression.
447 class OMPSimdlenClause : public OMPClause {
448 friend class OMPClauseReader;
449 /// \brief Location of '('.
450 SourceLocation LParenLoc;
451 /// \brief Safe iteration space distance.
454 /// \brief Set simdlen.
455 void setSimdlen(Expr *Len) { Simdlen = Len; }
458 /// \brief Build 'simdlen' clause.
460 /// \param Len Expression associated with this clause.
461 /// \param StartLoc Starting location of the clause.
462 /// \param EndLoc Ending location of the clause.
464 OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc,
465 SourceLocation EndLoc)
466 : OMPClause(OMPC_simdlen, StartLoc, EndLoc), LParenLoc(LParenLoc),
469 /// \brief Build an empty clause.
471 explicit OMPSimdlenClause()
472 : OMPClause(OMPC_simdlen, SourceLocation(), SourceLocation()),
473 LParenLoc(SourceLocation()), Simdlen(nullptr) {}
475 /// \brief Sets the location of '('.
476 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
477 /// \brief Returns the location of '('.
478 SourceLocation getLParenLoc() const { return LParenLoc; }
480 /// \brief Return safe iteration space distance.
481 Expr *getSimdlen() const { return cast_or_null<Expr>(Simdlen); }
483 static bool classof(const OMPClause *T) {
484 return T->getClauseKind() == OMPC_simdlen;
487 child_range children() { return child_range(&Simdlen, &Simdlen + 1); }
490 /// \brief This represents 'collapse' clause in the '#pragma omp ...'
494 /// #pragma omp simd collapse(3)
496 /// In this example directive '#pragma omp simd' has clause 'collapse'
497 /// with single expression '3'.
498 /// The parameter must be a constant positive integer expression, it specifies
499 /// the number of nested loops that should be collapsed into a single iteration
502 class OMPCollapseClause : public OMPClause {
503 friend class OMPClauseReader;
504 /// \brief Location of '('.
505 SourceLocation LParenLoc;
506 /// \brief Number of for-loops.
509 /// \brief Set the number of associated for-loops.
510 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
513 /// \brief Build 'collapse' clause.
515 /// \param Num Expression associated with this clause.
516 /// \param StartLoc Starting location of the clause.
517 /// \param LParenLoc Location of '('.
518 /// \param EndLoc Ending location of the clause.
520 OMPCollapseClause(Expr *Num, SourceLocation StartLoc,
521 SourceLocation LParenLoc, SourceLocation EndLoc)
522 : OMPClause(OMPC_collapse, StartLoc, EndLoc), LParenLoc(LParenLoc),
525 /// \brief Build an empty clause.
527 explicit OMPCollapseClause()
528 : OMPClause(OMPC_collapse, SourceLocation(), SourceLocation()),
529 LParenLoc(SourceLocation()), NumForLoops(nullptr) {}
531 /// \brief Sets the location of '('.
532 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
533 /// \brief Returns the location of '('.
534 SourceLocation getLParenLoc() const { return LParenLoc; }
536 /// \brief Return the number of associated for-loops.
537 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
539 static bool classof(const OMPClause *T) {
540 return T->getClauseKind() == OMPC_collapse;
543 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
546 /// \brief This represents 'default' clause in the '#pragma omp ...' directive.
549 /// #pragma omp parallel default(shared)
551 /// In this example directive '#pragma omp parallel' has simple 'default'
552 /// clause with kind 'shared'.
554 class OMPDefaultClause : public OMPClause {
555 friend class OMPClauseReader;
556 /// \brief Location of '('.
557 SourceLocation LParenLoc;
558 /// \brief A kind of the 'default' clause.
559 OpenMPDefaultClauseKind Kind;
560 /// \brief Start location of the kind in source code.
561 SourceLocation KindKwLoc;
563 /// \brief Set kind of the clauses.
565 /// \param K Argument of clause.
567 void setDefaultKind(OpenMPDefaultClauseKind K) { Kind = K; }
569 /// \brief Set argument location.
571 /// \param KLoc Argument location.
573 void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
576 /// \brief Build 'default' clause with argument \a A ('none' or 'shared').
578 /// \param A Argument of the clause ('none' or 'shared').
579 /// \param ALoc Starting location of the argument.
580 /// \param StartLoc Starting location of the clause.
581 /// \param LParenLoc Location of '('.
582 /// \param EndLoc Ending location of the clause.
584 OMPDefaultClause(OpenMPDefaultClauseKind A, SourceLocation ALoc,
585 SourceLocation StartLoc, SourceLocation LParenLoc,
586 SourceLocation EndLoc)
587 : OMPClause(OMPC_default, StartLoc, EndLoc), LParenLoc(LParenLoc),
588 Kind(A), KindKwLoc(ALoc) {}
590 /// \brief Build an empty clause.
593 : OMPClause(OMPC_default, SourceLocation(), SourceLocation()),
594 LParenLoc(SourceLocation()), Kind(OMPC_DEFAULT_unknown),
595 KindKwLoc(SourceLocation()) {}
597 /// \brief Sets the location of '('.
598 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
599 /// \brief Returns the location of '('.
600 SourceLocation getLParenLoc() const { return LParenLoc; }
602 /// \brief Returns kind of the clause.
603 OpenMPDefaultClauseKind getDefaultKind() const { return Kind; }
605 /// \brief Returns location of clause kind.
606 SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
608 static bool classof(const OMPClause *T) {
609 return T->getClauseKind() == OMPC_default;
612 child_range children() {
613 return child_range(child_iterator(), child_iterator());
617 /// \brief This represents 'proc_bind' clause in the '#pragma omp ...'
621 /// #pragma omp parallel proc_bind(master)
623 /// In this example directive '#pragma omp parallel' has simple 'proc_bind'
624 /// clause with kind 'master'.
626 class OMPProcBindClause : public OMPClause {
627 friend class OMPClauseReader;
628 /// \brief Location of '('.
629 SourceLocation LParenLoc;
630 /// \brief A kind of the 'proc_bind' clause.
631 OpenMPProcBindClauseKind Kind;
632 /// \brief Start location of the kind in source code.
633 SourceLocation KindKwLoc;
635 /// \brief Set kind of the clause.
637 /// \param K Kind of clause.
639 void setProcBindKind(OpenMPProcBindClauseKind K) { Kind = K; }
641 /// \brief Set clause kind location.
643 /// \param KLoc Kind location.
645 void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
648 /// \brief Build 'proc_bind' clause with argument \a A ('master', 'close' or
651 /// \param A Argument of the clause ('master', 'close' or 'spread').
652 /// \param ALoc Starting location of the argument.
653 /// \param StartLoc Starting location of the clause.
654 /// \param LParenLoc Location of '('.
655 /// \param EndLoc Ending location of the clause.
657 OMPProcBindClause(OpenMPProcBindClauseKind A, SourceLocation ALoc,
658 SourceLocation StartLoc, SourceLocation LParenLoc,
659 SourceLocation EndLoc)
660 : OMPClause(OMPC_proc_bind, StartLoc, EndLoc), LParenLoc(LParenLoc),
661 Kind(A), KindKwLoc(ALoc) {}
663 /// \brief Build an empty clause.
666 : OMPClause(OMPC_proc_bind, SourceLocation(), SourceLocation()),
667 LParenLoc(SourceLocation()), Kind(OMPC_PROC_BIND_unknown),
668 KindKwLoc(SourceLocation()) {}
670 /// \brief Sets the location of '('.
671 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
672 /// \brief Returns the location of '('.
673 SourceLocation getLParenLoc() const { return LParenLoc; }
675 /// \brief Returns kind of the clause.
676 OpenMPProcBindClauseKind getProcBindKind() const { return Kind; }
678 /// \brief Returns location of clause kind.
679 SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
681 static bool classof(const OMPClause *T) {
682 return T->getClauseKind() == OMPC_proc_bind;
685 child_range children() {
686 return child_range(child_iterator(), child_iterator());
690 /// \brief This represents 'schedule' clause in the '#pragma omp ...' directive.
693 /// #pragma omp for schedule(static, 3)
695 /// In this example directive '#pragma omp for' has 'schedule' clause with
696 /// arguments 'static' and '3'.
698 class OMPScheduleClause : public OMPClause, public OMPClauseWithPreInit {
699 friend class OMPClauseReader;
700 /// \brief Location of '('.
701 SourceLocation LParenLoc;
702 /// \brief A kind of the 'schedule' clause.
703 OpenMPScheduleClauseKind Kind;
704 /// \brief Modifiers for 'schedule' clause.
705 enum {FIRST, SECOND, NUM_MODIFIERS};
706 OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
707 /// \brief Locations of modifiers.
708 SourceLocation ModifiersLoc[NUM_MODIFIERS];
709 /// \brief Start location of the schedule ind in source code.
710 SourceLocation KindLoc;
711 /// \brief Location of ',' (if any).
712 SourceLocation CommaLoc;
713 /// \brief Chunk size.
716 /// \brief Set schedule kind.
718 /// \param K Schedule kind.
720 void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
721 /// \brief Set the first schedule modifier.
723 /// \param M Schedule modifier.
725 void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
726 Modifiers[FIRST] = M;
728 /// \brief Set the second schedule modifier.
730 /// \param M Schedule modifier.
732 void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
733 Modifiers[SECOND] = M;
735 /// \brief Set location of the first schedule modifier.
737 void setFirstScheduleModifierLoc(SourceLocation Loc) {
738 ModifiersLoc[FIRST] = Loc;
740 /// \brief Set location of the second schedule modifier.
742 void setSecondScheduleModifierLoc(SourceLocation Loc) {
743 ModifiersLoc[SECOND] = Loc;
745 /// \brief Set schedule modifier location.
747 /// \param M Schedule modifier location.
749 void setScheduleModifer(OpenMPScheduleClauseModifier M) {
750 if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
751 Modifiers[FIRST] = M;
753 assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
754 Modifiers[SECOND] = M;
757 /// \brief Sets the location of '('.
759 /// \param Loc Location of '('.
761 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
762 /// \brief Set schedule kind start location.
764 /// \param KLoc Schedule kind location.
766 void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
767 /// \brief Set location of ','.
769 /// \param Loc Location of ','.
771 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
772 /// \brief Set chunk size.
774 /// \param E Chunk size.
776 void setChunkSize(Expr *E) { ChunkSize = E; }
779 /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size
780 /// expression \a ChunkSize.
782 /// \param StartLoc Starting location of the clause.
783 /// \param LParenLoc Location of '('.
784 /// \param KLoc Starting location of the argument.
785 /// \param CommaLoc Location of ','.
786 /// \param EndLoc Ending location of the clause.
787 /// \param Kind Schedule kind.
788 /// \param ChunkSize Chunk size.
789 /// \param HelperChunkSize Helper chunk size for combined directives.
790 /// \param M1 The first modifier applied to 'schedule' clause.
791 /// \param M1Loc Location of the first modifier
792 /// \param M2 The second modifier applied to 'schedule' clause.
793 /// \param M2Loc Location of the second modifier
795 OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
796 SourceLocation KLoc, SourceLocation CommaLoc,
797 SourceLocation EndLoc, OpenMPScheduleClauseKind Kind,
798 Expr *ChunkSize, Stmt *HelperChunkSize,
799 OpenMPScheduleClauseModifier M1, SourceLocation M1Loc,
800 OpenMPScheduleClauseModifier M2, SourceLocation M2Loc)
801 : OMPClause(OMPC_schedule, StartLoc, EndLoc), OMPClauseWithPreInit(this),
802 LParenLoc(LParenLoc), Kind(Kind), KindLoc(KLoc), CommaLoc(CommaLoc),
803 ChunkSize(ChunkSize) {
804 setPreInitStmt(HelperChunkSize);
805 Modifiers[FIRST] = M1;
806 Modifiers[SECOND] = M2;
807 ModifiersLoc[FIRST] = M1Loc;
808 ModifiersLoc[SECOND] = M2Loc;
811 /// \brief Build an empty clause.
813 explicit OMPScheduleClause()
814 : OMPClause(OMPC_schedule, SourceLocation(), SourceLocation()),
815 OMPClauseWithPreInit(this), Kind(OMPC_SCHEDULE_unknown),
817 Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
818 Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
821 /// \brief Get kind of the clause.
823 OpenMPScheduleClauseKind getScheduleKind() const { return Kind; }
824 /// \brief Get the first modifier of the clause.
826 OpenMPScheduleClauseModifier getFirstScheduleModifier() const {
827 return Modifiers[FIRST];
829 /// \brief Get the second modifier of the clause.
831 OpenMPScheduleClauseModifier getSecondScheduleModifier() const {
832 return Modifiers[SECOND];
834 /// \brief Get location of '('.
836 SourceLocation getLParenLoc() { return LParenLoc; }
837 /// \brief Get kind location.
839 SourceLocation getScheduleKindLoc() { return KindLoc; }
840 /// \brief Get the first modifier location.
842 SourceLocation getFirstScheduleModifierLoc() const {
843 return ModifiersLoc[FIRST];
845 /// \brief Get the second modifier location.
847 SourceLocation getSecondScheduleModifierLoc() const {
848 return ModifiersLoc[SECOND];
850 /// \brief Get location of ','.
852 SourceLocation getCommaLoc() { return CommaLoc; }
853 /// \brief Get chunk size.
855 Expr *getChunkSize() { return ChunkSize; }
856 /// \brief Get chunk size.
858 const Expr *getChunkSize() const { return ChunkSize; }
860 static bool classof(const OMPClause *T) {
861 return T->getClauseKind() == OMPC_schedule;
864 child_range children() {
865 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
866 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
870 /// \brief This represents 'ordered' clause in the '#pragma omp ...' directive.
873 /// #pragma omp for ordered (2)
875 /// In this example directive '#pragma omp for' has 'ordered' clause with
878 class OMPOrderedClause : public OMPClause {
879 friend class OMPClauseReader;
880 /// \brief Location of '('.
881 SourceLocation LParenLoc;
882 /// \brief Number of for-loops.
885 /// \brief Set the number of associated for-loops.
886 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
889 /// \brief Build 'ordered' clause.
891 /// \param Num Expression, possibly associated with this clause.
892 /// \param StartLoc Starting location of the clause.
893 /// \param LParenLoc Location of '('.
894 /// \param EndLoc Ending location of the clause.
896 OMPOrderedClause(Expr *Num, SourceLocation StartLoc,
897 SourceLocation LParenLoc, SourceLocation EndLoc)
898 : OMPClause(OMPC_ordered, StartLoc, EndLoc), LParenLoc(LParenLoc),
901 /// \brief Build an empty clause.
903 explicit OMPOrderedClause()
904 : OMPClause(OMPC_ordered, SourceLocation(), SourceLocation()),
905 LParenLoc(SourceLocation()), NumForLoops(nullptr) {}
907 /// \brief Sets the location of '('.
908 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
909 /// \brief Returns the location of '('.
910 SourceLocation getLParenLoc() const { return LParenLoc; }
912 /// \brief Return the number of associated for-loops.
913 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
915 static bool classof(const OMPClause *T) {
916 return T->getClauseKind() == OMPC_ordered;
919 child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
922 /// \brief This represents 'nowait' clause in the '#pragma omp ...' directive.
925 /// #pragma omp for nowait
927 /// In this example directive '#pragma omp for' has 'nowait' clause.
929 class OMPNowaitClause : public OMPClause {
931 /// \brief Build 'nowait' clause.
933 /// \param StartLoc Starting location of the clause.
934 /// \param EndLoc Ending location of the clause.
936 OMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc)
937 : OMPClause(OMPC_nowait, StartLoc, EndLoc) {}
939 /// \brief Build an empty clause.
942 : OMPClause(OMPC_nowait, SourceLocation(), SourceLocation()) {}
944 static bool classof(const OMPClause *T) {
945 return T->getClauseKind() == OMPC_nowait;
948 child_range children() {
949 return child_range(child_iterator(), child_iterator());
953 /// \brief This represents 'untied' clause in the '#pragma omp ...' directive.
956 /// #pragma omp task untied
958 /// In this example directive '#pragma omp task' has 'untied' clause.
960 class OMPUntiedClause : public OMPClause {
962 /// \brief Build 'untied' clause.
964 /// \param StartLoc Starting location of the clause.
965 /// \param EndLoc Ending location of the clause.
967 OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
968 : OMPClause(OMPC_untied, StartLoc, EndLoc) {}
970 /// \brief Build an empty clause.
973 : OMPClause(OMPC_untied, SourceLocation(), SourceLocation()) {}
975 static bool classof(const OMPClause *T) {
976 return T->getClauseKind() == OMPC_untied;
979 child_range children() {
980 return child_range(child_iterator(), child_iterator());
984 /// \brief This represents 'mergeable' clause in the '#pragma omp ...'
988 /// #pragma omp task mergeable
990 /// In this example directive '#pragma omp task' has 'mergeable' clause.
992 class OMPMergeableClause : public OMPClause {
994 /// \brief Build 'mergeable' clause.
996 /// \param StartLoc Starting location of the clause.
997 /// \param EndLoc Ending location of the clause.
999 OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc)
1000 : OMPClause(OMPC_mergeable, StartLoc, EndLoc) {}
1002 /// \brief Build an empty clause.
1004 OMPMergeableClause()
1005 : OMPClause(OMPC_mergeable, SourceLocation(), SourceLocation()) {}
1007 static bool classof(const OMPClause *T) {
1008 return T->getClauseKind() == OMPC_mergeable;
1011 child_range children() {
1012 return child_range(child_iterator(), child_iterator());
1016 /// \brief This represents 'read' clause in the '#pragma omp atomic' directive.
1019 /// #pragma omp atomic read
1021 /// In this example directive '#pragma omp atomic' has 'read' clause.
1023 class OMPReadClause : public OMPClause {
1025 /// \brief Build 'read' clause.
1027 /// \param StartLoc Starting location of the clause.
1028 /// \param EndLoc Ending location of the clause.
1030 OMPReadClause(SourceLocation StartLoc, SourceLocation EndLoc)
1031 : OMPClause(OMPC_read, StartLoc, EndLoc) {}
1033 /// \brief Build an empty clause.
1035 OMPReadClause() : OMPClause(OMPC_read, SourceLocation(), SourceLocation()) {}
1037 static bool classof(const OMPClause *T) {
1038 return T->getClauseKind() == OMPC_read;
1041 child_range children() {
1042 return child_range(child_iterator(), child_iterator());
1046 /// \brief This represents 'write' clause in the '#pragma omp atomic' directive.
1049 /// #pragma omp atomic write
1051 /// In this example directive '#pragma omp atomic' has 'write' clause.
1053 class OMPWriteClause : public OMPClause {
1055 /// \brief Build 'write' clause.
1057 /// \param StartLoc Starting location of the clause.
1058 /// \param EndLoc Ending location of the clause.
1060 OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc)
1061 : OMPClause(OMPC_write, StartLoc, EndLoc) {}
1063 /// \brief Build an empty clause.
1066 : OMPClause(OMPC_write, SourceLocation(), SourceLocation()) {}
1068 static bool classof(const OMPClause *T) {
1069 return T->getClauseKind() == OMPC_write;
1072 child_range children() {
1073 return child_range(child_iterator(), child_iterator());
1077 /// \brief This represents 'update' clause in the '#pragma omp atomic'
1081 /// #pragma omp atomic update
1083 /// In this example directive '#pragma omp atomic' has 'update' clause.
1085 class OMPUpdateClause : public OMPClause {
1087 /// \brief Build 'update' clause.
1089 /// \param StartLoc Starting location of the clause.
1090 /// \param EndLoc Ending location of the clause.
1092 OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc)
1093 : OMPClause(OMPC_update, StartLoc, EndLoc) {}
1095 /// \brief Build an empty clause.
1098 : OMPClause(OMPC_update, SourceLocation(), SourceLocation()) {}
1100 static bool classof(const OMPClause *T) {
1101 return T->getClauseKind() == OMPC_update;
1104 child_range children() {
1105 return child_range(child_iterator(), child_iterator());
1109 /// \brief This represents 'capture' clause in the '#pragma omp atomic'
1113 /// #pragma omp atomic capture
1115 /// In this example directive '#pragma omp atomic' has 'capture' clause.
1117 class OMPCaptureClause : public OMPClause {
1119 /// \brief Build 'capture' clause.
1121 /// \param StartLoc Starting location of the clause.
1122 /// \param EndLoc Ending location of the clause.
1124 OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc)
1125 : OMPClause(OMPC_capture, StartLoc, EndLoc) {}
1127 /// \brief Build an empty clause.
1130 : OMPClause(OMPC_capture, SourceLocation(), SourceLocation()) {}
1132 static bool classof(const OMPClause *T) {
1133 return T->getClauseKind() == OMPC_capture;
1136 child_range children() {
1137 return child_range(child_iterator(), child_iterator());
1141 /// \brief This represents 'seq_cst' clause in the '#pragma omp atomic'
1145 /// #pragma omp atomic seq_cst
1147 /// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
1149 class OMPSeqCstClause : public OMPClause {
1151 /// \brief Build 'seq_cst' clause.
1153 /// \param StartLoc Starting location of the clause.
1154 /// \param EndLoc Ending location of the clause.
1156 OMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc)
1157 : OMPClause(OMPC_seq_cst, StartLoc, EndLoc) {}
1159 /// \brief Build an empty clause.
1162 : OMPClause(OMPC_seq_cst, SourceLocation(), SourceLocation()) {}
1164 static bool classof(const OMPClause *T) {
1165 return T->getClauseKind() == OMPC_seq_cst;
1168 child_range children() {
1169 return child_range(child_iterator(), child_iterator());
1173 /// \brief This represents clause 'private' in the '#pragma omp ...' directives.
1176 /// #pragma omp parallel private(a,b)
1178 /// In this example directive '#pragma omp parallel' has clause 'private'
1179 /// with the variables 'a' and 'b'.
1181 class OMPPrivateClause final
1182 : public OMPVarListClause<OMPPrivateClause>,
1183 private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
1184 friend TrailingObjects;
1185 friend OMPVarListClause;
1186 friend class OMPClauseReader;
1187 /// \brief Build clause with number of variables \a N.
1189 /// \param StartLoc Starting location of the clause.
1190 /// \param LParenLoc Location of '('.
1191 /// \param EndLoc Ending location of the clause.
1192 /// \param N Number of the variables in the clause.
1194 OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1195 SourceLocation EndLoc, unsigned N)
1196 : OMPVarListClause<OMPPrivateClause>(OMPC_private, StartLoc, LParenLoc,
1199 /// \brief Build an empty clause.
1201 /// \param N Number of variables.
1203 explicit OMPPrivateClause(unsigned N)
1204 : OMPVarListClause<OMPPrivateClause>(OMPC_private, SourceLocation(),
1205 SourceLocation(), SourceLocation(),
1208 /// \brief Sets the list of references to private copies with initializers for
1209 /// new private variables.
1210 /// \param VL List of references.
1211 void setPrivateCopies(ArrayRef<Expr *> VL);
1213 /// \brief Gets the list of references to private copies with initializers for
1214 /// new private variables.
1215 MutableArrayRef<Expr *> getPrivateCopies() {
1216 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1218 ArrayRef<const Expr *> getPrivateCopies() const {
1219 return llvm::makeArrayRef(varlist_end(), varlist_size());
1223 /// \brief Creates clause with a list of variables \a VL.
1225 /// \param C AST context.
1226 /// \param StartLoc Starting location of the clause.
1227 /// \param LParenLoc Location of '('.
1228 /// \param EndLoc Ending location of the clause.
1229 /// \param VL List of references to the variables.
1230 /// \param PrivateVL List of references to private copies with initializers.
1232 static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
1233 SourceLocation LParenLoc,
1234 SourceLocation EndLoc, ArrayRef<Expr *> VL,
1235 ArrayRef<Expr *> PrivateVL);
1236 /// \brief Creates an empty clause with the place for \a N variables.
1238 /// \param C AST context.
1239 /// \param N The number of variables.
1241 static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1243 typedef MutableArrayRef<Expr *>::iterator private_copies_iterator;
1244 typedef ArrayRef<const Expr *>::iterator private_copies_const_iterator;
1245 typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
1246 typedef llvm::iterator_range<private_copies_const_iterator>
1247 private_copies_const_range;
1249 private_copies_range private_copies() {
1250 return private_copies_range(getPrivateCopies().begin(),
1251 getPrivateCopies().end());
1253 private_copies_const_range private_copies() const {
1254 return private_copies_const_range(getPrivateCopies().begin(),
1255 getPrivateCopies().end());
1258 child_range children() {
1259 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1260 reinterpret_cast<Stmt **>(varlist_end()));
1263 static bool classof(const OMPClause *T) {
1264 return T->getClauseKind() == OMPC_private;
1268 /// \brief This represents clause 'firstprivate' in the '#pragma omp ...'
1272 /// #pragma omp parallel firstprivate(a,b)
1274 /// In this example directive '#pragma omp parallel' has clause 'firstprivate'
1275 /// with the variables 'a' and 'b'.
1277 class OMPFirstprivateClause final
1278 : public OMPVarListClause<OMPFirstprivateClause>,
1279 public OMPClauseWithPreInit,
1280 private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
1281 friend TrailingObjects;
1282 friend OMPVarListClause;
1283 friend class OMPClauseReader;
1285 /// \brief Build clause with number of variables \a N.
1287 /// \param StartLoc Starting location of the clause.
1288 /// \param LParenLoc Location of '('.
1289 /// \param EndLoc Ending location of the clause.
1290 /// \param N Number of the variables in the clause.
1292 OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1293 SourceLocation EndLoc, unsigned N)
1294 : OMPVarListClause<OMPFirstprivateClause>(OMPC_firstprivate, StartLoc,
1295 LParenLoc, EndLoc, N),
1296 OMPClauseWithPreInit(this) {}
1298 /// \brief Build an empty clause.
1300 /// \param N Number of variables.
1302 explicit OMPFirstprivateClause(unsigned N)
1303 : OMPVarListClause<OMPFirstprivateClause>(
1304 OMPC_firstprivate, SourceLocation(), SourceLocation(),
1305 SourceLocation(), N),
1306 OMPClauseWithPreInit(this) {}
1307 /// \brief Sets the list of references to private copies with initializers for
1308 /// new private variables.
1309 /// \param VL List of references.
1310 void setPrivateCopies(ArrayRef<Expr *> VL);
1312 /// \brief Gets the list of references to private copies with initializers for
1313 /// new private variables.
1314 MutableArrayRef<Expr *> getPrivateCopies() {
1315 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1317 ArrayRef<const Expr *> getPrivateCopies() const {
1318 return llvm::makeArrayRef(varlist_end(), varlist_size());
1321 /// \brief Sets the list of references to initializer variables for new
1322 /// private variables.
1323 /// \param VL List of references.
1324 void setInits(ArrayRef<Expr *> VL);
1326 /// \brief Gets the list of references to initializer variables for new
1327 /// private variables.
1328 MutableArrayRef<Expr *> getInits() {
1329 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1331 ArrayRef<const Expr *> getInits() const {
1332 return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1336 /// \brief Creates clause with a list of variables \a VL.
1338 /// \param C AST context.
1339 /// \param StartLoc Starting location of the clause.
1340 /// \param LParenLoc Location of '('.
1341 /// \param EndLoc Ending location of the clause.
1342 /// \param VL List of references to the original variables.
1343 /// \param PrivateVL List of references to private copies with initializers.
1344 /// \param InitVL List of references to auto generated variables used for
1345 /// initialization of a single array element. Used if firstprivate variable is
1347 /// \param PreInit Statement that must be executed before entering the OpenMP
1348 /// region with this clause.
1350 static OMPFirstprivateClause *
1351 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1352 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
1353 ArrayRef<Expr *> InitVL, Stmt *PreInit);
1354 /// \brief Creates an empty clause with the place for \a N variables.
1356 /// \param C AST context.
1357 /// \param N The number of variables.
1359 static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1361 typedef MutableArrayRef<Expr *>::iterator private_copies_iterator;
1362 typedef ArrayRef<const Expr *>::iterator private_copies_const_iterator;
1363 typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
1364 typedef llvm::iterator_range<private_copies_const_iterator>
1365 private_copies_const_range;
1367 private_copies_range private_copies() {
1368 return private_copies_range(getPrivateCopies().begin(),
1369 getPrivateCopies().end());
1371 private_copies_const_range private_copies() const {
1372 return private_copies_const_range(getPrivateCopies().begin(),
1373 getPrivateCopies().end());
1376 typedef MutableArrayRef<Expr *>::iterator inits_iterator;
1377 typedef ArrayRef<const Expr *>::iterator inits_const_iterator;
1378 typedef llvm::iterator_range<inits_iterator> inits_range;
1379 typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
1381 inits_range inits() {
1382 return inits_range(getInits().begin(), getInits().end());
1384 inits_const_range inits() const {
1385 return inits_const_range(getInits().begin(), getInits().end());
1388 child_range children() {
1389 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1390 reinterpret_cast<Stmt **>(varlist_end()));
1393 static bool classof(const OMPClause *T) {
1394 return T->getClauseKind() == OMPC_firstprivate;
1398 /// \brief This represents clause 'lastprivate' in the '#pragma omp ...'
1402 /// #pragma omp simd lastprivate(a,b)
1404 /// In this example directive '#pragma omp simd' has clause 'lastprivate'
1405 /// with the variables 'a' and 'b'.
1406 class OMPLastprivateClause final
1407 : public OMPVarListClause<OMPLastprivateClause>,
1408 public OMPClauseWithPostUpdate,
1409 private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
1410 // There are 4 additional tail-allocated arrays at the end of the class:
1411 // 1. Contains list of pseudo variables with the default initialization for
1412 // each non-firstprivate variables. Used in codegen for initialization of
1413 // lastprivate copies.
1414 // 2. List of helper expressions for proper generation of assignment operation
1415 // required for lastprivate clause. This list represents private variables
1416 // (for arrays, single array element).
1417 // 3. List of helper expressions for proper generation of assignment operation
1418 // required for lastprivate clause. This list represents original variables
1419 // (for arrays, single array element).
1420 // 4. List of helper expressions that represents assignment operation:
1422 // DstExprs = SrcExprs;
1424 // Required for proper codegen of final assignment performed by the
1425 // lastprivate clause.
1427 friend TrailingObjects;
1428 friend OMPVarListClause;
1429 friend class OMPClauseReader;
1431 /// \brief Build clause with number of variables \a N.
1433 /// \param StartLoc Starting location of the clause.
1434 /// \param LParenLoc Location of '('.
1435 /// \param EndLoc Ending location of the clause.
1436 /// \param N Number of the variables in the clause.
1438 OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1439 SourceLocation EndLoc, unsigned N)
1440 : OMPVarListClause<OMPLastprivateClause>(OMPC_lastprivate, StartLoc,
1441 LParenLoc, EndLoc, N),
1442 OMPClauseWithPostUpdate(this) {}
1444 /// \brief Build an empty clause.
1446 /// \param N Number of variables.
1448 explicit OMPLastprivateClause(unsigned N)
1449 : OMPVarListClause<OMPLastprivateClause>(
1450 OMPC_lastprivate, SourceLocation(), SourceLocation(),
1451 SourceLocation(), N),
1452 OMPClauseWithPostUpdate(this) {}
1454 /// \brief Get the list of helper expressions for initialization of private
1455 /// copies for lastprivate variables.
1456 MutableArrayRef<Expr *> getPrivateCopies() {
1457 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1459 ArrayRef<const Expr *> getPrivateCopies() const {
1460 return llvm::makeArrayRef(varlist_end(), varlist_size());
1463 /// \brief Set list of helper expressions, required for proper codegen of the
1464 /// clause. These expressions represent private variables (for arrays, single
1465 /// array element) in the final assignment statement performed by the
1466 /// lastprivate clause.
1467 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
1469 /// \brief Get the list of helper source expressions.
1470 MutableArrayRef<Expr *> getSourceExprs() {
1471 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1473 ArrayRef<const Expr *> getSourceExprs() const {
1474 return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1477 /// \brief Set list of helper expressions, required for proper codegen of the
1478 /// clause. These expressions represent original variables (for arrays, single
1479 /// array element) in the final assignment statement performed by the
1480 /// lastprivate clause.
1481 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
1483 /// \brief Get the list of helper destination expressions.
1484 MutableArrayRef<Expr *> getDestinationExprs() {
1485 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
1487 ArrayRef<const Expr *> getDestinationExprs() const {
1488 return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
1491 /// \brief Set list of helper assignment expressions, required for proper
1492 /// codegen of the clause. These expressions are assignment expressions that
1493 /// assign private copy of the variable to original variable.
1494 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
1496 /// \brief Get the list of helper assignment expressions.
1497 MutableArrayRef<Expr *> getAssignmentOps() {
1498 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
1500 ArrayRef<const Expr *> getAssignmentOps() const {
1501 return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
1505 /// \brief Creates clause with a list of variables \a VL.
1507 /// \param C AST context.
1508 /// \param StartLoc Starting location of the clause.
1509 /// \param LParenLoc Location of '('.
1510 /// \param EndLoc Ending location of the clause.
1511 /// \param VL List of references to the variables.
1512 /// \param SrcExprs List of helper expressions for proper generation of
1513 /// assignment operation required for lastprivate clause. This list represents
1514 /// private variables (for arrays, single array element).
1515 /// \param DstExprs List of helper expressions for proper generation of
1516 /// assignment operation required for lastprivate clause. This list represents
1517 /// original variables (for arrays, single array element).
1518 /// \param AssignmentOps List of helper expressions that represents assignment
1521 /// DstExprs = SrcExprs;
1523 /// Required for proper codegen of final assignment performed by the
1524 /// lastprivate clause.
1525 /// \param PreInit Statement that must be executed before entering the OpenMP
1526 /// region with this clause.
1527 /// \param PostUpdate Expression that must be executed after exit from the
1528 /// OpenMP region with this clause.
1530 static OMPLastprivateClause *
1531 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1532 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
1533 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
1534 Stmt *PreInit, Expr *PostUpdate);
1535 /// \brief Creates an empty clause with the place for \a N variables.
1537 /// \param C AST context.
1538 /// \param N The number of variables.
1540 static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1542 typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
1543 typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
1544 typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
1545 typedef llvm::iterator_range<helper_expr_const_iterator>
1546 helper_expr_const_range;
1548 /// \brief Set list of helper expressions, required for generation of private
1549 /// copies of original lastprivate variables.
1550 void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
1552 helper_expr_const_range private_copies() const {
1553 return helper_expr_const_range(getPrivateCopies().begin(),
1554 getPrivateCopies().end());
1556 helper_expr_range private_copies() {
1557 return helper_expr_range(getPrivateCopies().begin(),
1558 getPrivateCopies().end());
1560 helper_expr_const_range source_exprs() const {
1561 return helper_expr_const_range(getSourceExprs().begin(),
1562 getSourceExprs().end());
1564 helper_expr_range source_exprs() {
1565 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
1567 helper_expr_const_range destination_exprs() const {
1568 return helper_expr_const_range(getDestinationExprs().begin(),
1569 getDestinationExprs().end());
1571 helper_expr_range destination_exprs() {
1572 return helper_expr_range(getDestinationExprs().begin(),
1573 getDestinationExprs().end());
1575 helper_expr_const_range assignment_ops() const {
1576 return helper_expr_const_range(getAssignmentOps().begin(),
1577 getAssignmentOps().end());
1579 helper_expr_range assignment_ops() {
1580 return helper_expr_range(getAssignmentOps().begin(),
1581 getAssignmentOps().end());
1584 child_range children() {
1585 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1586 reinterpret_cast<Stmt **>(varlist_end()));
1589 static bool classof(const OMPClause *T) {
1590 return T->getClauseKind() == OMPC_lastprivate;
1594 /// \brief This represents clause 'shared' in the '#pragma omp ...' directives.
1597 /// #pragma omp parallel shared(a,b)
1599 /// In this example directive '#pragma omp parallel' has clause 'shared'
1600 /// with the variables 'a' and 'b'.
1602 class OMPSharedClause final
1603 : public OMPVarListClause<OMPSharedClause>,
1604 private llvm::TrailingObjects<OMPSharedClause, Expr *> {
1605 friend TrailingObjects;
1606 friend OMPVarListClause;
1607 /// \brief Build clause with number of variables \a N.
1609 /// \param StartLoc Starting location of the clause.
1610 /// \param LParenLoc Location of '('.
1611 /// \param EndLoc Ending location of the clause.
1612 /// \param N Number of the variables in the clause.
1614 OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1615 SourceLocation EndLoc, unsigned N)
1616 : OMPVarListClause<OMPSharedClause>(OMPC_shared, StartLoc, LParenLoc,
1619 /// \brief Build an empty clause.
1621 /// \param N Number of variables.
1623 explicit OMPSharedClause(unsigned N)
1624 : OMPVarListClause<OMPSharedClause>(OMPC_shared, SourceLocation(),
1625 SourceLocation(), SourceLocation(),
1629 /// \brief Creates clause with a list of variables \a VL.
1631 /// \param C AST context.
1632 /// \param StartLoc Starting location of the clause.
1633 /// \param LParenLoc Location of '('.
1634 /// \param EndLoc Ending location of the clause.
1635 /// \param VL List of references to the variables.
1637 static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
1638 SourceLocation LParenLoc,
1639 SourceLocation EndLoc, ArrayRef<Expr *> VL);
1640 /// \brief Creates an empty clause with \a N variables.
1642 /// \param C AST context.
1643 /// \param N The number of variables.
1645 static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
1647 child_range children() {
1648 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1649 reinterpret_cast<Stmt **>(varlist_end()));
1652 static bool classof(const OMPClause *T) {
1653 return T->getClauseKind() == OMPC_shared;
1657 /// \brief This represents clause 'reduction' in the '#pragma omp ...'
1661 /// #pragma omp parallel reduction(+:a,b)
1663 /// In this example directive '#pragma omp parallel' has clause 'reduction'
1664 /// with operator '+' and the variables 'a' and 'b'.
1666 class OMPReductionClause final
1667 : public OMPVarListClause<OMPReductionClause>,
1668 public OMPClauseWithPostUpdate,
1669 private llvm::TrailingObjects<OMPReductionClause, Expr *> {
1670 friend TrailingObjects;
1671 friend OMPVarListClause;
1672 friend class OMPClauseReader;
1673 /// \brief Location of ':'.
1674 SourceLocation ColonLoc;
1675 /// \brief Nested name specifier for C++.
1676 NestedNameSpecifierLoc QualifierLoc;
1677 /// \brief Name of custom operator.
1678 DeclarationNameInfo NameInfo;
1680 /// \brief Build clause with number of variables \a N.
1682 /// \param StartLoc Starting location of the clause.
1683 /// \param LParenLoc Location of '('.
1684 /// \param EndLoc Ending location of the clause.
1685 /// \param ColonLoc Location of ':'.
1686 /// \param N Number of the variables in the clause.
1687 /// \param QualifierLoc The nested-name qualifier with location information
1688 /// \param NameInfo The full name info for reduction identifier.
1690 OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1691 SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N,
1692 NestedNameSpecifierLoc QualifierLoc,
1693 const DeclarationNameInfo &NameInfo)
1694 : OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
1695 LParenLoc, EndLoc, N),
1696 OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
1697 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
1699 /// \brief Build an empty clause.
1701 /// \param N Number of variables.
1703 explicit OMPReductionClause(unsigned N)
1704 : OMPVarListClause<OMPReductionClause>(OMPC_reduction, SourceLocation(),
1705 SourceLocation(), SourceLocation(),
1707 OMPClauseWithPostUpdate(this), ColonLoc(), QualifierLoc(), NameInfo() {}
1709 /// \brief Sets location of ':' symbol in clause.
1710 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
1711 /// \brief Sets the name info for specified reduction identifier.
1712 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
1713 /// \brief Sets the nested name specifier.
1714 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
1716 /// \brief Set list of helper expressions, required for proper codegen of the
1717 /// clause. These expressions represent private copy of the reduction
1719 void setPrivates(ArrayRef<Expr *> Privates);
1721 /// \brief Get the list of helper privates.
1722 MutableArrayRef<Expr *> getPrivates() {
1723 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1725 ArrayRef<const Expr *> getPrivates() const {
1726 return llvm::makeArrayRef(varlist_end(), varlist_size());
1729 /// \brief Set list of helper expressions, required for proper codegen of the
1730 /// clause. These expressions represent LHS expression in the final
1731 /// reduction expression performed by the reduction clause.
1732 void setLHSExprs(ArrayRef<Expr *> LHSExprs);
1734 /// \brief Get the list of helper LHS expressions.
1735 MutableArrayRef<Expr *> getLHSExprs() {
1736 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
1738 ArrayRef<const Expr *> getLHSExprs() const {
1739 return llvm::makeArrayRef(getPrivates().end(), varlist_size());
1742 /// \brief Set list of helper expressions, required for proper codegen of the
1743 /// clause. These expressions represent RHS expression in the final
1744 /// reduction expression performed by the reduction clause.
1745 /// Also, variables in these expressions are used for proper initialization of
1746 /// reduction copies.
1747 void setRHSExprs(ArrayRef<Expr *> RHSExprs);
1749 /// \brief Get the list of helper destination expressions.
1750 MutableArrayRef<Expr *> getRHSExprs() {
1751 return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
1753 ArrayRef<const Expr *> getRHSExprs() const {
1754 return llvm::makeArrayRef(getLHSExprs().end(), varlist_size());
1757 /// \brief Set list of helper reduction expressions, required for proper
1758 /// codegen of the clause. These expressions are binary expressions or
1759 /// operator/custom reduction call that calculates new value from source
1760 /// helper expressions to destination helper expressions.
1761 void setReductionOps(ArrayRef<Expr *> ReductionOps);
1763 /// \brief Get the list of helper reduction expressions.
1764 MutableArrayRef<Expr *> getReductionOps() {
1765 return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
1767 ArrayRef<const Expr *> getReductionOps() const {
1768 return llvm::makeArrayRef(getRHSExprs().end(), varlist_size());
1772 /// \brief Creates clause with a list of variables \a VL.
1774 /// \param StartLoc Starting location of the clause.
1775 /// \param LParenLoc Location of '('.
1776 /// \param ColonLoc Location of ':'.
1777 /// \param EndLoc Ending location of the clause.
1778 /// \param VL The variables in the clause.
1779 /// \param QualifierLoc The nested-name qualifier with location information
1780 /// \param NameInfo The full name info for reduction identifier.
1781 /// \param Privates List of helper expressions for proper generation of
1783 /// \param LHSExprs List of helper expressions for proper generation of
1784 /// assignment operation required for copyprivate clause. This list represents
1785 /// LHSs of the reduction expressions.
1786 /// \param RHSExprs List of helper expressions for proper generation of
1787 /// assignment operation required for copyprivate clause. This list represents
1788 /// RHSs of the reduction expressions.
1789 /// Also, variables in these expressions are used for proper initialization of
1790 /// reduction copies.
1791 /// \param ReductionOps List of helper expressions that represents reduction
1794 /// LHSExprs binop RHSExprs;
1795 /// operator binop(LHSExpr, RHSExpr);
1796 /// <CutomReduction>(LHSExpr, RHSExpr);
1798 /// Required for proper codegen of final reduction operation performed by the
1799 /// reduction clause.
1800 /// \param PreInit Statement that must be executed before entering the OpenMP
1801 /// region with this clause.
1802 /// \param PostUpdate Expression that must be executed after exit from the
1803 /// OpenMP region with this clause.
1805 static OMPReductionClause *
1806 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1807 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
1808 NestedNameSpecifierLoc QualifierLoc,
1809 const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
1810 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
1811 ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
1812 /// \brief Creates an empty clause with the place for \a N variables.
1814 /// \param C AST context.
1815 /// \param N The number of variables.
1817 static OMPReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
1819 /// \brief Gets location of ':' symbol in clause.
1820 SourceLocation getColonLoc() const { return ColonLoc; }
1821 /// \brief Gets the name info for specified reduction identifier.
1822 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
1823 /// \brief Gets the nested name specifier.
1824 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
1826 typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
1827 typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
1828 typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
1829 typedef llvm::iterator_range<helper_expr_const_iterator>
1830 helper_expr_const_range;
1832 helper_expr_const_range privates() const {
1833 return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
1835 helper_expr_range privates() {
1836 return helper_expr_range(getPrivates().begin(), getPrivates().end());
1838 helper_expr_const_range lhs_exprs() const {
1839 return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
1841 helper_expr_range lhs_exprs() {
1842 return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
1844 helper_expr_const_range rhs_exprs() const {
1845 return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
1847 helper_expr_range rhs_exprs() {
1848 return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
1850 helper_expr_const_range reduction_ops() const {
1851 return helper_expr_const_range(getReductionOps().begin(),
1852 getReductionOps().end());
1854 helper_expr_range reduction_ops() {
1855 return helper_expr_range(getReductionOps().begin(),
1856 getReductionOps().end());
1859 child_range children() {
1860 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1861 reinterpret_cast<Stmt **>(varlist_end()));
1864 static bool classof(const OMPClause *T) {
1865 return T->getClauseKind() == OMPC_reduction;
1869 /// \brief This represents clause 'linear' in the '#pragma omp ...'
1873 /// #pragma omp simd linear(a,b : 2)
1875 /// In this example directive '#pragma omp simd' has clause 'linear'
1876 /// with variables 'a', 'b' and linear step '2'.
1878 class OMPLinearClause final
1879 : public OMPVarListClause<OMPLinearClause>,
1880 public OMPClauseWithPostUpdate,
1881 private llvm::TrailingObjects<OMPLinearClause, Expr *> {
1882 friend TrailingObjects;
1883 friend OMPVarListClause;
1884 friend class OMPClauseReader;
1885 /// \brief Modifier of 'linear' clause.
1886 OpenMPLinearClauseKind Modifier;
1887 /// \brief Location of linear modifier if any.
1888 SourceLocation ModifierLoc;
1889 /// \brief Location of ':'.
1890 SourceLocation ColonLoc;
1892 /// \brief Sets the linear step for clause.
1893 void setStep(Expr *Step) { *(getFinals().end()) = Step; }
1895 /// \brief Sets the expression to calculate linear step for clause.
1896 void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
1898 /// \brief Build 'linear' clause with given number of variables \a NumVars.
1900 /// \param StartLoc Starting location of the clause.
1901 /// \param LParenLoc Location of '('.
1902 /// \param ColonLoc Location of ':'.
1903 /// \param EndLoc Ending location of the clause.
1904 /// \param NumVars Number of variables.
1906 OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1907 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
1908 SourceLocation ColonLoc, SourceLocation EndLoc,
1910 : OMPVarListClause<OMPLinearClause>(OMPC_linear, StartLoc, LParenLoc,
1912 OMPClauseWithPostUpdate(this), Modifier(Modifier),
1913 ModifierLoc(ModifierLoc), ColonLoc(ColonLoc) {}
1915 /// \brief Build an empty clause.
1917 /// \param NumVars Number of variables.
1919 explicit OMPLinearClause(unsigned NumVars)
1920 : OMPVarListClause<OMPLinearClause>(OMPC_linear, SourceLocation(),
1921 SourceLocation(), SourceLocation(),
1923 OMPClauseWithPostUpdate(this), Modifier(OMPC_LINEAR_val), ModifierLoc(),
1926 /// \brief Gets the list of initial values for linear variables.
1928 /// There are NumVars expressions with initial values allocated after the
1929 /// varlist, they are followed by NumVars update expressions (used to update
1930 /// the linear variable's value on current iteration) and they are followed by
1931 /// NumVars final expressions (used to calculate the linear variable's
1932 /// value after the loop body). After these lists, there are 2 helper
1933 /// expressions - linear step and a helper to calculate it before the
1934 /// loop body (used when the linear step is not constant):
1936 /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
1937 /// Finals[]; Step; CalcStep; }
1939 MutableArrayRef<Expr *> getPrivates() {
1940 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1942 ArrayRef<const Expr *> getPrivates() const {
1943 return llvm::makeArrayRef(varlist_end(), varlist_size());
1946 MutableArrayRef<Expr *> getInits() {
1947 return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
1949 ArrayRef<const Expr *> getInits() const {
1950 return llvm::makeArrayRef(getPrivates().end(), varlist_size());
1953 /// \brief Sets the list of update expressions for linear variables.
1954 MutableArrayRef<Expr *> getUpdates() {
1955 return MutableArrayRef<Expr *>(getInits().end(), varlist_size());
1957 ArrayRef<const Expr *> getUpdates() const {
1958 return llvm::makeArrayRef(getInits().end(), varlist_size());
1961 /// \brief Sets the list of final update expressions for linear variables.
1962 MutableArrayRef<Expr *> getFinals() {
1963 return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size());
1965 ArrayRef<const Expr *> getFinals() const {
1966 return llvm::makeArrayRef(getUpdates().end(), varlist_size());
1969 /// \brief Sets the list of the copies of original linear variables.
1970 /// \param PL List of expressions.
1971 void setPrivates(ArrayRef<Expr *> PL);
1973 /// \brief Sets the list of the initial values for linear variables.
1974 /// \param IL List of expressions.
1975 void setInits(ArrayRef<Expr *> IL);
1978 /// \brief Creates clause with a list of variables \a VL and a linear step
1981 /// \param C AST Context.
1982 /// \param StartLoc Starting location of the clause.
1983 /// \param LParenLoc Location of '('.
1984 /// \param Modifier Modifier of 'linear' clause.
1985 /// \param ModifierLoc Modifier location.
1986 /// \param ColonLoc Location of ':'.
1987 /// \param EndLoc Ending location of the clause.
1988 /// \param VL List of references to the variables.
1989 /// \param PL List of private copies of original variables.
1990 /// \param IL List of initial values for the variables.
1991 /// \param Step Linear step.
1992 /// \param CalcStep Calculation of the linear step.
1993 /// \param PreInit Statement that must be executed before entering the OpenMP
1994 /// region with this clause.
1995 /// \param PostUpdate Expression that must be executed after exit from the
1996 /// OpenMP region with this clause.
1997 static OMPLinearClause *
1998 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1999 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
2000 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
2001 ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep,
2002 Stmt *PreInit, Expr *PostUpdate);
2004 /// \brief Creates an empty clause with the place for \a NumVars variables.
2006 /// \param C AST context.
2007 /// \param NumVars Number of variables.
2009 static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
2011 /// \brief Set modifier.
2012 void setModifier(OpenMPLinearClauseKind Kind) { Modifier = Kind; }
2013 /// \brief Return modifier.
2014 OpenMPLinearClauseKind getModifier() const { return Modifier; }
2016 /// \brief Set modifier location.
2017 void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
2018 /// \brief Return modifier location.
2019 SourceLocation getModifierLoc() const { return ModifierLoc; }
2021 /// \brief Sets the location of ':'.
2022 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2023 /// \brief Returns the location of ':'.
2024 SourceLocation getColonLoc() const { return ColonLoc; }
2026 /// \brief Returns linear step.
2027 Expr *getStep() { return *(getFinals().end()); }
2028 /// \brief Returns linear step.
2029 const Expr *getStep() const { return *(getFinals().end()); }
2030 /// \brief Returns expression to calculate linear step.
2031 Expr *getCalcStep() { return *(getFinals().end() + 1); }
2032 /// \brief Returns expression to calculate linear step.
2033 const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
2035 /// \brief Sets the list of update expressions for linear variables.
2036 /// \param UL List of expressions.
2037 void setUpdates(ArrayRef<Expr *> UL);
2039 /// \brief Sets the list of final update expressions for linear variables.
2040 /// \param FL List of expressions.
2041 void setFinals(ArrayRef<Expr *> FL);
2043 typedef MutableArrayRef<Expr *>::iterator privates_iterator;
2044 typedef ArrayRef<const Expr *>::iterator privates_const_iterator;
2045 typedef llvm::iterator_range<privates_iterator> privates_range;
2046 typedef llvm::iterator_range<privates_const_iterator> privates_const_range;
2048 privates_range privates() {
2049 return privates_range(getPrivates().begin(), getPrivates().end());
2051 privates_const_range privates() const {
2052 return privates_const_range(getPrivates().begin(), getPrivates().end());
2055 typedef MutableArrayRef<Expr *>::iterator inits_iterator;
2056 typedef ArrayRef<const Expr *>::iterator inits_const_iterator;
2057 typedef llvm::iterator_range<inits_iterator> inits_range;
2058 typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
2060 inits_range inits() {
2061 return inits_range(getInits().begin(), getInits().end());
2063 inits_const_range inits() const {
2064 return inits_const_range(getInits().begin(), getInits().end());
2067 typedef MutableArrayRef<Expr *>::iterator updates_iterator;
2068 typedef ArrayRef<const Expr *>::iterator updates_const_iterator;
2069 typedef llvm::iterator_range<updates_iterator> updates_range;
2070 typedef llvm::iterator_range<updates_const_iterator> updates_const_range;
2072 updates_range updates() {
2073 return updates_range(getUpdates().begin(), getUpdates().end());
2075 updates_const_range updates() const {
2076 return updates_const_range(getUpdates().begin(), getUpdates().end());
2079 typedef MutableArrayRef<Expr *>::iterator finals_iterator;
2080 typedef ArrayRef<const Expr *>::iterator finals_const_iterator;
2081 typedef llvm::iterator_range<finals_iterator> finals_range;
2082 typedef llvm::iterator_range<finals_const_iterator> finals_const_range;
2084 finals_range finals() {
2085 return finals_range(getFinals().begin(), getFinals().end());
2087 finals_const_range finals() const {
2088 return finals_const_range(getFinals().begin(), getFinals().end());
2091 child_range children() {
2092 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2093 reinterpret_cast<Stmt **>(varlist_end()));
2096 static bool classof(const OMPClause *T) {
2097 return T->getClauseKind() == OMPC_linear;
2101 /// \brief This represents clause 'aligned' in the '#pragma omp ...'
2105 /// #pragma omp simd aligned(a,b : 8)
2107 /// In this example directive '#pragma omp simd' has clause 'aligned'
2108 /// with variables 'a', 'b' and alignment '8'.
2110 class OMPAlignedClause final
2111 : public OMPVarListClause<OMPAlignedClause>,
2112 private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
2113 friend TrailingObjects;
2114 friend OMPVarListClause;
2115 friend class OMPClauseReader;
2116 /// \brief Location of ':'.
2117 SourceLocation ColonLoc;
2119 /// \brief Sets the alignment for clause.
2120 void setAlignment(Expr *A) { *varlist_end() = A; }
2122 /// \brief Build 'aligned' clause with given number of variables \a NumVars.
2124 /// \param StartLoc Starting location of the clause.
2125 /// \param LParenLoc Location of '('.
2126 /// \param ColonLoc Location of ':'.
2127 /// \param EndLoc Ending location of the clause.
2128 /// \param NumVars Number of variables.
2130 OMPAlignedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2131 SourceLocation ColonLoc, SourceLocation EndLoc,
2133 : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, StartLoc, LParenLoc,
2135 ColonLoc(ColonLoc) {}
2137 /// \brief Build an empty clause.
2139 /// \param NumVars Number of variables.
2141 explicit OMPAlignedClause(unsigned NumVars)
2142 : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, SourceLocation(),
2143 SourceLocation(), SourceLocation(),
2145 ColonLoc(SourceLocation()) {}
2148 /// \brief Creates clause with a list of variables \a VL and alignment \a A.
2150 /// \param C AST Context.
2151 /// \param StartLoc Starting location of the clause.
2152 /// \param LParenLoc Location of '('.
2153 /// \param ColonLoc Location of ':'.
2154 /// \param EndLoc Ending location of the clause.
2155 /// \param VL List of references to the variables.
2156 /// \param A Alignment.
2157 static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
2158 SourceLocation LParenLoc,
2159 SourceLocation ColonLoc,
2160 SourceLocation EndLoc, ArrayRef<Expr *> VL,
2163 /// \brief Creates an empty clause with the place for \a NumVars variables.
2165 /// \param C AST context.
2166 /// \param NumVars Number of variables.
2168 static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
2170 /// \brief Sets the location of ':'.
2171 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2172 /// \brief Returns the location of ':'.
2173 SourceLocation getColonLoc() const { return ColonLoc; }
2175 /// \brief Returns alignment.
2176 Expr *getAlignment() { return *varlist_end(); }
2177 /// \brief Returns alignment.
2178 const Expr *getAlignment() const { return *varlist_end(); }
2180 child_range children() {
2181 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2182 reinterpret_cast<Stmt **>(varlist_end()));
2185 static bool classof(const OMPClause *T) {
2186 return T->getClauseKind() == OMPC_aligned;
2190 /// \brief This represents clause 'copyin' in the '#pragma omp ...' directives.
2193 /// #pragma omp parallel copyin(a,b)
2195 /// In this example directive '#pragma omp parallel' has clause 'copyin'
2196 /// with the variables 'a' and 'b'.
2198 class OMPCopyinClause final
2199 : public OMPVarListClause<OMPCopyinClause>,
2200 private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
2201 // Class has 3 additional tail allocated arrays:
2202 // 1. List of helper expressions for proper generation of assignment operation
2203 // required for copyin clause. This list represents sources.
2204 // 2. List of helper expressions for proper generation of assignment operation
2205 // required for copyin clause. This list represents destinations.
2206 // 3. List of helper expressions that represents assignment operation:
2208 // DstExprs = SrcExprs;
2210 // Required for proper codegen of propagation of master's thread values of
2211 // threadprivate variables to local instances of that variables in other
2212 // implicit threads.
2214 friend TrailingObjects;
2215 friend OMPVarListClause;
2216 friend class OMPClauseReader;
2217 /// \brief Build clause with number of variables \a N.
2219 /// \param StartLoc Starting location of the clause.
2220 /// \param LParenLoc Location of '('.
2221 /// \param EndLoc Ending location of the clause.
2222 /// \param N Number of the variables in the clause.
2224 OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2225 SourceLocation EndLoc, unsigned N)
2226 : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, StartLoc, LParenLoc,
2229 /// \brief Build an empty clause.
2231 /// \param N Number of variables.
2233 explicit OMPCopyinClause(unsigned N)
2234 : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, SourceLocation(),
2235 SourceLocation(), SourceLocation(),
2238 /// \brief Set list of helper expressions, required for proper codegen of the
2239 /// clause. These expressions represent source expression in the final
2240 /// assignment statement performed by the copyin clause.
2241 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
2243 /// \brief Get the list of helper source expressions.
2244 MutableArrayRef<Expr *> getSourceExprs() {
2245 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2247 ArrayRef<const Expr *> getSourceExprs() const {
2248 return llvm::makeArrayRef(varlist_end(), varlist_size());
2251 /// \brief Set list of helper expressions, required for proper codegen of the
2252 /// clause. These expressions represent destination expression in the final
2253 /// assignment statement performed by the copyin clause.
2254 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
2256 /// \brief Get the list of helper destination expressions.
2257 MutableArrayRef<Expr *> getDestinationExprs() {
2258 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
2260 ArrayRef<const Expr *> getDestinationExprs() const {
2261 return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
2264 /// \brief Set list of helper assignment expressions, required for proper
2265 /// codegen of the clause. These expressions are assignment expressions that
2266 /// assign source helper expressions to destination helper expressions
2267 /// correspondingly.
2268 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
2270 /// \brief Get the list of helper assignment expressions.
2271 MutableArrayRef<Expr *> getAssignmentOps() {
2272 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
2274 ArrayRef<const Expr *> getAssignmentOps() const {
2275 return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
2279 /// \brief Creates clause with a list of variables \a VL.
2281 /// \param C AST context.
2282 /// \param StartLoc Starting location of the clause.
2283 /// \param LParenLoc Location of '('.
2284 /// \param EndLoc Ending location of the clause.
2285 /// \param VL List of references to the variables.
2286 /// \param SrcExprs List of helper expressions for proper generation of
2287 /// assignment operation required for copyin clause. This list represents
2289 /// \param DstExprs List of helper expressions for proper generation of
2290 /// assignment operation required for copyin clause. This list represents
2292 /// \param AssignmentOps List of helper expressions that represents assignment
2295 /// DstExprs = SrcExprs;
2297 /// Required for proper codegen of propagation of master's thread values of
2298 /// threadprivate variables to local instances of that variables in other
2299 /// implicit threads.
2301 static OMPCopyinClause *
2302 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2303 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
2304 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
2305 /// \brief Creates an empty clause with \a N variables.
2307 /// \param C AST context.
2308 /// \param N The number of variables.
2310 static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
2312 typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
2313 typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
2314 typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
2315 typedef llvm::iterator_range<helper_expr_const_iterator>
2316 helper_expr_const_range;
2318 helper_expr_const_range source_exprs() const {
2319 return helper_expr_const_range(getSourceExprs().begin(),
2320 getSourceExprs().end());
2322 helper_expr_range source_exprs() {
2323 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
2325 helper_expr_const_range destination_exprs() const {
2326 return helper_expr_const_range(getDestinationExprs().begin(),
2327 getDestinationExprs().end());
2329 helper_expr_range destination_exprs() {
2330 return helper_expr_range(getDestinationExprs().begin(),
2331 getDestinationExprs().end());
2333 helper_expr_const_range assignment_ops() const {
2334 return helper_expr_const_range(getAssignmentOps().begin(),
2335 getAssignmentOps().end());
2337 helper_expr_range assignment_ops() {
2338 return helper_expr_range(getAssignmentOps().begin(),
2339 getAssignmentOps().end());
2342 child_range children() {
2343 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2344 reinterpret_cast<Stmt **>(varlist_end()));
2347 static bool classof(const OMPClause *T) {
2348 return T->getClauseKind() == OMPC_copyin;
2352 /// \brief This represents clause 'copyprivate' in the '#pragma omp ...'
2356 /// #pragma omp single copyprivate(a,b)
2358 /// In this example directive '#pragma omp single' has clause 'copyprivate'
2359 /// with the variables 'a' and 'b'.
2361 class OMPCopyprivateClause final
2362 : public OMPVarListClause<OMPCopyprivateClause>,
2363 private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
2364 friend TrailingObjects;
2365 friend OMPVarListClause;
2366 friend class OMPClauseReader;
2367 /// \brief Build clause with number of variables \a N.
2369 /// \param StartLoc Starting location of the clause.
2370 /// \param LParenLoc Location of '('.
2371 /// \param EndLoc Ending location of the clause.
2372 /// \param N Number of the variables in the clause.
2374 OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2375 SourceLocation EndLoc, unsigned N)
2376 : OMPVarListClause<OMPCopyprivateClause>(OMPC_copyprivate, StartLoc,
2377 LParenLoc, EndLoc, N) {}
2379 /// \brief Build an empty clause.
2381 /// \param N Number of variables.
2383 explicit OMPCopyprivateClause(unsigned N)
2384 : OMPVarListClause<OMPCopyprivateClause>(
2385 OMPC_copyprivate, SourceLocation(), SourceLocation(),
2386 SourceLocation(), N) {}
2388 /// \brief Set list of helper expressions, required for proper codegen of the
2389 /// clause. These expressions represent source expression in the final
2390 /// assignment statement performed by the copyprivate clause.
2391 void setSourceExprs(ArrayRef<Expr *> SrcExprs);
2393 /// \brief Get the list of helper source expressions.
2394 MutableArrayRef<Expr *> getSourceExprs() {
2395 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2397 ArrayRef<const Expr *> getSourceExprs() const {
2398 return llvm::makeArrayRef(varlist_end(), varlist_size());
2401 /// \brief Set list of helper expressions, required for proper codegen of the
2402 /// clause. These expressions represent destination expression in the final
2403 /// assignment statement performed by the copyprivate clause.
2404 void setDestinationExprs(ArrayRef<Expr *> DstExprs);
2406 /// \brief Get the list of helper destination expressions.
2407 MutableArrayRef<Expr *> getDestinationExprs() {
2408 return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
2410 ArrayRef<const Expr *> getDestinationExprs() const {
2411 return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
2414 /// \brief Set list of helper assignment expressions, required for proper
2415 /// codegen of the clause. These expressions are assignment expressions that
2416 /// assign source helper expressions to destination helper expressions
2417 /// correspondingly.
2418 void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
2420 /// \brief Get the list of helper assignment expressions.
2421 MutableArrayRef<Expr *> getAssignmentOps() {
2422 return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
2424 ArrayRef<const Expr *> getAssignmentOps() const {
2425 return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
2429 /// \brief Creates clause with a list of variables \a VL.
2431 /// \param C AST context.
2432 /// \param StartLoc Starting location of the clause.
2433 /// \param LParenLoc Location of '('.
2434 /// \param EndLoc Ending location of the clause.
2435 /// \param VL List of references to the variables.
2436 /// \param SrcExprs List of helper expressions for proper generation of
2437 /// assignment operation required for copyprivate clause. This list represents
2439 /// \param DstExprs List of helper expressions for proper generation of
2440 /// assignment operation required for copyprivate clause. This list represents
2442 /// \param AssignmentOps List of helper expressions that represents assignment
2445 /// DstExprs = SrcExprs;
2447 /// Required for proper codegen of final assignment performed by the
2448 /// copyprivate clause.
2450 static OMPCopyprivateClause *
2451 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2452 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
2453 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps);
2454 /// \brief Creates an empty clause with \a N variables.
2456 /// \param C AST context.
2457 /// \param N The number of variables.
2459 static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
2461 typedef MutableArrayRef<Expr *>::iterator helper_expr_iterator;
2462 typedef ArrayRef<const Expr *>::iterator helper_expr_const_iterator;
2463 typedef llvm::iterator_range<helper_expr_iterator> helper_expr_range;
2464 typedef llvm::iterator_range<helper_expr_const_iterator>
2465 helper_expr_const_range;
2467 helper_expr_const_range source_exprs() const {
2468 return helper_expr_const_range(getSourceExprs().begin(),
2469 getSourceExprs().end());
2471 helper_expr_range source_exprs() {
2472 return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
2474 helper_expr_const_range destination_exprs() const {
2475 return helper_expr_const_range(getDestinationExprs().begin(),
2476 getDestinationExprs().end());
2478 helper_expr_range destination_exprs() {
2479 return helper_expr_range(getDestinationExprs().begin(),
2480 getDestinationExprs().end());
2482 helper_expr_const_range assignment_ops() const {
2483 return helper_expr_const_range(getAssignmentOps().begin(),
2484 getAssignmentOps().end());
2486 helper_expr_range assignment_ops() {
2487 return helper_expr_range(getAssignmentOps().begin(),
2488 getAssignmentOps().end());
2491 child_range children() {
2492 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2493 reinterpret_cast<Stmt **>(varlist_end()));
2496 static bool classof(const OMPClause *T) {
2497 return T->getClauseKind() == OMPC_copyprivate;
2501 /// \brief This represents implicit clause 'flush' for the '#pragma omp flush'
2503 /// This clause does not exist by itself, it can be only as a part of 'omp
2504 /// flush' directive. This clause is introduced to keep the original structure
2505 /// of \a OMPExecutableDirective class and its derivatives and to use the
2506 /// existing infrastructure of clauses with the list of variables.
2509 /// #pragma omp flush(a,b)
2511 /// In this example directive '#pragma omp flush' has implicit clause 'flush'
2512 /// with the variables 'a' and 'b'.
2514 class OMPFlushClause final
2515 : public OMPVarListClause<OMPFlushClause>,
2516 private llvm::TrailingObjects<OMPFlushClause, Expr *> {
2517 friend TrailingObjects;
2518 friend OMPVarListClause;
2519 /// \brief Build clause with number of variables \a N.
2521 /// \param StartLoc Starting location of the clause.
2522 /// \param LParenLoc Location of '('.
2523 /// \param EndLoc Ending location of the clause.
2524 /// \param N Number of the variables in the clause.
2526 OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2527 SourceLocation EndLoc, unsigned N)
2528 : OMPVarListClause<OMPFlushClause>(OMPC_flush, StartLoc, LParenLoc,
2531 /// \brief Build an empty clause.
2533 /// \param N Number of variables.
2535 explicit OMPFlushClause(unsigned N)
2536 : OMPVarListClause<OMPFlushClause>(OMPC_flush, SourceLocation(),
2537 SourceLocation(), SourceLocation(),
2541 /// \brief Creates clause with a list of variables \a VL.
2543 /// \param C AST context.
2544 /// \param StartLoc Starting location of the clause.
2545 /// \param LParenLoc Location of '('.
2546 /// \param EndLoc Ending location of the clause.
2547 /// \param VL List of references to the variables.
2549 static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
2550 SourceLocation LParenLoc, SourceLocation EndLoc,
2551 ArrayRef<Expr *> VL);
2552 /// \brief Creates an empty clause with \a N variables.
2554 /// \param C AST context.
2555 /// \param N The number of variables.
2557 static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
2559 child_range children() {
2560 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2561 reinterpret_cast<Stmt **>(varlist_end()));
2564 static bool classof(const OMPClause *T) {
2565 return T->getClauseKind() == OMPC_flush;
2569 /// \brief This represents implicit clause 'depend' for the '#pragma omp task'
2573 /// #pragma omp task depend(in:a,b)
2575 /// In this example directive '#pragma omp task' with clause 'depend' with the
2576 /// variables 'a' and 'b' with dependency 'in'.
2578 class OMPDependClause final
2579 : public OMPVarListClause<OMPDependClause>,
2580 private llvm::TrailingObjects<OMPDependClause, Expr *> {
2581 friend TrailingObjects;
2582 friend OMPVarListClause;
2583 friend class OMPClauseReader;
2584 /// \brief Dependency type (one of in, out, inout).
2585 OpenMPDependClauseKind DepKind;
2586 /// \brief Dependency type location.
2587 SourceLocation DepLoc;
2588 /// \brief Colon location.
2589 SourceLocation ColonLoc;
2590 /// \brief Build clause with number of variables \a N.
2592 /// \param StartLoc Starting location of the clause.
2593 /// \param LParenLoc Location of '('.
2594 /// \param EndLoc Ending location of the clause.
2595 /// \param N Number of the variables in the clause.
2597 OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2598 SourceLocation EndLoc, unsigned N)
2599 : OMPVarListClause<OMPDependClause>(OMPC_depend, StartLoc, LParenLoc,
2601 DepKind(OMPC_DEPEND_unknown) {}
2603 /// \brief Build an empty clause.
2605 /// \param N Number of variables.
2607 explicit OMPDependClause(unsigned N)
2608 : OMPVarListClause<OMPDependClause>(OMPC_depend, SourceLocation(),
2609 SourceLocation(), SourceLocation(),
2611 DepKind(OMPC_DEPEND_unknown) {}
2612 /// \brief Set dependency kind.
2613 void setDependencyKind(OpenMPDependClauseKind K) { DepKind = K; }
2615 /// \brief Set dependency kind and its location.
2616 void setDependencyLoc(SourceLocation Loc) { DepLoc = Loc; }
2618 /// \brief Set colon location.
2619 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2622 /// \brief Creates clause with a list of variables \a VL.
2624 /// \param C AST context.
2625 /// \param StartLoc Starting location of the clause.
2626 /// \param LParenLoc Location of '('.
2627 /// \param EndLoc Ending location of the clause.
2628 /// \param DepKind Dependency type.
2629 /// \param DepLoc Location of the dependency type.
2630 /// \param ColonLoc Colon location.
2631 /// \param VL List of references to the variables.
2632 static OMPDependClause *
2633 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2634 SourceLocation EndLoc, OpenMPDependClauseKind DepKind,
2635 SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL);
2636 /// \brief Creates an empty clause with \a N variables.
2638 /// \param C AST context.
2639 /// \param N The number of variables.
2641 static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N);
2643 /// \brief Get dependency type.
2644 OpenMPDependClauseKind getDependencyKind() const { return DepKind; }
2645 /// \brief Get dependency type location.
2646 SourceLocation getDependencyLoc() const { return DepLoc; }
2647 /// \brief Get colon location.
2648 SourceLocation getColonLoc() const { return ColonLoc; }
2650 /// Set the loop counter value for the depend clauses with 'sink|source' kind
2651 /// of dependency. Required for codegen.
2652 void setCounterValue(Expr *V);
2653 /// Get the loop counter value.
2654 Expr *getCounterValue();
2655 /// Get the loop counter value.
2656 const Expr *getCounterValue() const;
2658 child_range children() {
2659 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2660 reinterpret_cast<Stmt **>(varlist_end()));
2663 static bool classof(const OMPClause *T) {
2664 return T->getClauseKind() == OMPC_depend;
2668 /// \brief This represents 'device' clause in the '#pragma omp ...'
2672 /// #pragma omp target device(a)
2674 /// In this example directive '#pragma omp target' has clause 'device'
2675 /// with single expression 'a'.
2677 class OMPDeviceClause : public OMPClause {
2678 friend class OMPClauseReader;
2679 /// \brief Location of '('.
2680 SourceLocation LParenLoc;
2681 /// \brief Device number.
2683 /// \brief Set the device number.
2685 /// \param E Device number.
2687 void setDevice(Expr *E) { Device = E; }
2690 /// \brief Build 'device' clause.
2692 /// \param E Expression associated with this clause.
2693 /// \param StartLoc Starting location of the clause.
2694 /// \param LParenLoc Location of '('.
2695 /// \param EndLoc Ending location of the clause.
2697 OMPDeviceClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc,
2698 SourceLocation EndLoc)
2699 : OMPClause(OMPC_device, StartLoc, EndLoc), LParenLoc(LParenLoc),
2702 /// \brief Build an empty clause.
2705 : OMPClause(OMPC_device, SourceLocation(), SourceLocation()),
2706 LParenLoc(SourceLocation()), Device(nullptr) {}
2707 /// \brief Sets the location of '('.
2708 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2709 /// \brief Returns the location of '('.
2710 SourceLocation getLParenLoc() const { return LParenLoc; }
2711 /// \brief Return device number.
2712 Expr *getDevice() { return cast<Expr>(Device); }
2713 /// \brief Return device number.
2714 Expr *getDevice() const { return cast<Expr>(Device); }
2716 static bool classof(const OMPClause *T) {
2717 return T->getClauseKind() == OMPC_device;
2720 child_range children() { return child_range(&Device, &Device + 1); }
2723 /// \brief This represents 'threads' clause in the '#pragma omp ...' directive.
2726 /// #pragma omp ordered threads
2728 /// In this example directive '#pragma omp ordered' has simple 'threads' clause.
2730 class OMPThreadsClause : public OMPClause {
2732 /// \brief Build 'threads' clause.
2734 /// \param StartLoc Starting location of the clause.
2735 /// \param EndLoc Ending location of the clause.
2737 OMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc)
2738 : OMPClause(OMPC_threads, StartLoc, EndLoc) {}
2740 /// \brief Build an empty clause.
2743 : OMPClause(OMPC_threads, SourceLocation(), SourceLocation()) {}
2745 static bool classof(const OMPClause *T) {
2746 return T->getClauseKind() == OMPC_threads;
2749 child_range children() {
2750 return child_range(child_iterator(), child_iterator());
2754 /// \brief This represents 'simd' clause in the '#pragma omp ...' directive.
2757 /// #pragma omp ordered simd
2759 /// In this example directive '#pragma omp ordered' has simple 'simd' clause.
2761 class OMPSIMDClause : public OMPClause {
2763 /// \brief Build 'simd' clause.
2765 /// \param StartLoc Starting location of the clause.
2766 /// \param EndLoc Ending location of the clause.
2768 OMPSIMDClause(SourceLocation StartLoc, SourceLocation EndLoc)
2769 : OMPClause(OMPC_simd, StartLoc, EndLoc) {}
2771 /// \brief Build an empty clause.
2773 OMPSIMDClause() : OMPClause(OMPC_simd, SourceLocation(), SourceLocation()) {}
2775 static bool classof(const OMPClause *T) {
2776 return T->getClauseKind() == OMPC_simd;
2779 child_range children() {
2780 return child_range(child_iterator(), child_iterator());
2784 /// \brief Struct that defines common infrastructure to handle mappable
2785 /// expressions used in OpenMP clauses.
2786 class OMPClauseMappableExprCommon {
2788 // \brief Class that represents a component of a mappable expression. E.g.
2789 // for an expression S.a, the first component is a declaration reference
2790 // expression associated with 'S' and the second is a member expression
2791 // associated with the field declaration 'a'. If the expression is an array
2792 // subscript it may not have any associated declaration. In that case the
2793 // associated declaration is set to nullptr.
2794 class MappableComponent {
2795 // \brief Expression associated with the component.
2796 Expr *AssociatedExpression = nullptr;
2797 // \brief Declaration associated with the declaration. If the component does
2798 // not have a declaration (e.g. array subscripts or section), this is set to
2800 ValueDecl *AssociatedDeclaration = nullptr;
2803 explicit MappableComponent() {}
2804 explicit MappableComponent(Expr *AssociatedExpression,
2805 ValueDecl *AssociatedDeclaration)
2806 : AssociatedExpression(AssociatedExpression),
2807 AssociatedDeclaration(
2808 AssociatedDeclaration
2809 ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
2812 Expr *getAssociatedExpression() const { return AssociatedExpression; }
2813 ValueDecl *getAssociatedDeclaration() const {
2814 return AssociatedDeclaration;
2818 // \brief List of components of an expression. This first one is the whole
2819 // expression and the last one is the base expression.
2820 typedef SmallVector<MappableComponent, 8> MappableExprComponentList;
2821 typedef ArrayRef<MappableComponent> MappableExprComponentListRef;
2823 // \brief List of all component lists associated to the same base declaration.
2824 // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
2825 // their component list but the same base declaration 'S'.
2826 typedef SmallVector<MappableExprComponentList, 8> MappableExprComponentLists;
2827 typedef ArrayRef<MappableExprComponentList> MappableExprComponentListsRef;
2830 // \brief Return the total number of elements in a list of component lists.
2832 getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists);
2834 // \brief Return the total number of elements in a list of declarations. All
2835 // declarations are expected to be canonical.
2837 getUniqueDeclarationsTotalNumber(ArrayRef<ValueDecl *> Declarations);
2840 /// \brief This represents clauses with a list of expressions that are mappable.
2841 /// Examples of these clauses are 'map' in
2842 /// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from
2843 /// in '#pragma omp target update...' directives.
2845 class OMPMappableExprListClause : public OMPVarListClause<T>,
2846 public OMPClauseMappableExprCommon {
2847 friend class OMPClauseReader;
2849 /// \brief Number of unique declarations in this clause.
2850 unsigned NumUniqueDeclarations;
2852 /// \brief Number of component lists in this clause.
2853 unsigned NumComponentLists;
2855 /// \brief Total number of components in this clause.
2856 unsigned NumComponents;
2859 /// \brief Get the unique declarations that are in the trailing objects of the
2861 MutableArrayRef<ValueDecl *> getUniqueDeclsRef() {
2862 return MutableArrayRef<ValueDecl *>(
2863 static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(),
2864 NumUniqueDeclarations);
2867 /// \brief Get the unique declarations that are in the trailing objects of the
2869 ArrayRef<ValueDecl *> getUniqueDeclsRef() const {
2870 return ArrayRef<ValueDecl *>(
2871 static_cast<const T *>(this)
2872 ->template getTrailingObjects<ValueDecl *>(),
2873 NumUniqueDeclarations);
2876 /// \brief Set the unique declarations that are in the trailing objects of the
2878 void setUniqueDecls(ArrayRef<ValueDecl *> UDs) {
2879 assert(UDs.size() == NumUniqueDeclarations &&
2880 "Unexpected amount of unique declarations.");
2881 std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin());
2884 /// \brief Get the number of lists per declaration that are in the trailing
2885 /// objects of the class.
2886 MutableArrayRef<unsigned> getDeclNumListsRef() {
2887 return MutableArrayRef<unsigned>(
2888 static_cast<T *>(this)->template getTrailingObjects<unsigned>(),
2889 NumUniqueDeclarations);
2892 /// \brief Get the number of lists per declaration that are in the trailing
2893 /// objects of the class.
2894 ArrayRef<unsigned> getDeclNumListsRef() const {
2895 return ArrayRef<unsigned>(
2896 static_cast<const T *>(this)->template getTrailingObjects<unsigned>(),
2897 NumUniqueDeclarations);
2900 /// \brief Set the number of lists per declaration that are in the trailing
2901 /// objects of the class.
2902 void setDeclNumLists(ArrayRef<unsigned> DNLs) {
2903 assert(DNLs.size() == NumUniqueDeclarations &&
2904 "Unexpected amount of list numbers.");
2905 std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin());
2908 /// \brief Get the cumulative component lists sizes that are in the trailing
2909 /// objects of the class. They are appended after the number of lists.
2910 MutableArrayRef<unsigned> getComponentListSizesRef() {
2911 return MutableArrayRef<unsigned>(
2912 static_cast<T *>(this)->template getTrailingObjects<unsigned>() +
2913 NumUniqueDeclarations,
2917 /// \brief Get the cumulative component lists sizes that are in the trailing
2918 /// objects of the class. They are appended after the number of lists.
2919 ArrayRef<unsigned> getComponentListSizesRef() const {
2920 return ArrayRef<unsigned>(
2921 static_cast<const T *>(this)->template getTrailingObjects<unsigned>() +
2922 NumUniqueDeclarations,
2926 /// \brief Set the cumulative component lists sizes that are in the trailing
2927 /// objects of the class.
2928 void setComponentListSizes(ArrayRef<unsigned> CLSs) {
2929 assert(CLSs.size() == NumComponentLists &&
2930 "Unexpected amount of component lists.");
2931 std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin());
2934 /// \brief Get the components that are in the trailing objects of the class.
2935 MutableArrayRef<MappableComponent> getComponentsRef() {
2936 return MutableArrayRef<MappableComponent>(
2937 static_cast<T *>(this)
2938 ->template getTrailingObjects<MappableComponent>(),
2942 /// \brief Get the components that are in the trailing objects of the class.
2943 ArrayRef<MappableComponent> getComponentsRef() const {
2944 return ArrayRef<MappableComponent>(
2945 static_cast<const T *>(this)
2946 ->template getTrailingObjects<MappableComponent>(),
2950 /// \brief Set the components that are in the trailing objects of the class.
2951 /// This requires the list sizes so that it can also fill the original
2952 /// expressions, which are the first component of each list.
2953 void setComponents(ArrayRef<MappableComponent> Components,
2954 ArrayRef<unsigned> CLSs) {
2955 assert(Components.size() == NumComponents &&
2956 "Unexpected amount of component lists.");
2957 assert(CLSs.size() == NumComponentLists &&
2958 "Unexpected amount of list sizes.");
2959 std::copy(Components.begin(), Components.end(), getComponentsRef().begin());
2962 /// \brief Fill the clause information from the list of declarations and
2963 /// associated component lists.
2964 void setClauseInfo(ArrayRef<ValueDecl *> Declarations,
2965 MappableExprComponentListsRef ComponentLists) {
2966 // Perform some checks to make sure the data sizes are consistent with the
2967 // information available when the clause was created.
2968 assert(getUniqueDeclarationsTotalNumber(Declarations) ==
2969 NumUniqueDeclarations &&
2970 "Unexpected number of mappable expression info entries!");
2971 assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
2972 "Unexpected total number of components!");
2973 assert(Declarations.size() == ComponentLists.size() &&
2974 "Declaration and component lists size is not consistent!");
2975 assert(Declarations.size() == NumComponentLists &&
2976 "Unexpected declaration and component lists size!");
2978 // Organize the components by declaration and retrieve the original
2979 // expression. Original expressions are always the first component of the
2980 // mappable component list.
2981 llvm::DenseMap<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
2984 auto CI = ComponentLists.begin();
2985 for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
2987 assert(!CI->empty() && "Invalid component list!");
2988 ComponentListMap[*DI].push_back(*CI);
2992 // Iterators of the target storage.
2993 auto UniqueDeclarations = getUniqueDeclsRef();
2994 auto UDI = UniqueDeclarations.begin();
2996 auto DeclNumLists = getDeclNumListsRef();
2997 auto DNLI = DeclNumLists.begin();
2999 auto ComponentListSizes = getComponentListSizesRef();
3000 auto CLSI = ComponentListSizes.begin();
3002 auto Components = getComponentsRef();
3003 auto CI = Components.begin();
3005 // Variable to compute the accumulation of the number of components.
3006 unsigned PrevSize = 0u;
3008 // Scan all the declarations and associated component lists.
3009 for (auto &M : ComponentListMap) {
3012 // The component lists.
3015 // Initialize the entry.
3022 // Obtain the cumulative sizes and concatenate all the components in the
3023 // reserved storage.
3025 // Accumulate with the previous size.
3026 PrevSize += C.size();
3032 // Append components after the current components iterator.
3033 CI = std::copy(C.begin(), C.end(), CI);
3038 /// \brief Build a clause for \a NumUniqueDeclarations declarations, \a
3039 /// NumComponentLists total component lists, and \a NumComponents total
3042 /// \param K Kind of the clause.
3043 /// \param StartLoc Starting location of the clause (the clause keyword).
3044 /// \param LParenLoc Location of '('.
3045 /// \param EndLoc Ending location of the clause.
3046 /// \param NumVars Number of expressions listed in the clause.
3047 /// \param NumUniqueDeclarations Number of unique base declarations in this
3049 /// \param NumComponentLists Number of component lists in this clause - one
3050 /// list for each expression in the clause.
3051 /// \param NumComponents Total number of expression components in the clause.
3053 OMPMappableExprListClause(OpenMPClauseKind K, SourceLocation StartLoc,
3054 SourceLocation LParenLoc, SourceLocation EndLoc,
3055 unsigned NumVars, unsigned NumUniqueDeclarations,
3056 unsigned NumComponentLists, unsigned NumComponents)
3057 : OMPVarListClause<T>(K, StartLoc, LParenLoc, EndLoc, NumVars),
3058 NumUniqueDeclarations(NumUniqueDeclarations),
3059 NumComponentLists(NumComponentLists), NumComponents(NumComponents) {}
3062 /// \brief Return the number of unique base declarations in this clause.
3063 unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
3064 /// \brief Return the number of lists derived from the clause expressions.
3065 unsigned getTotalComponentListNum() const { return NumComponentLists; }
3066 /// \brief Return the total number of components in all lists derived from the
3068 unsigned getTotalComponentsNum() const { return NumComponents; }
3070 /// \brief Iterator that browse the components by lists. It also allows
3071 /// browsing components of a single declaration.
3072 class const_component_lists_iterator
3073 : public llvm::iterator_adaptor_base<
3074 const_component_lists_iterator,
3075 MappableExprComponentListRef::const_iterator,
3076 std::forward_iterator_tag, MappableComponent, ptrdiff_t,
3077 MappableComponent, MappableComponent> {
3078 // The declaration the iterator currently refers to.
3079 ArrayRef<ValueDecl *>::iterator DeclCur;
3081 // The list number associated with the current declaration.
3082 ArrayRef<unsigned>::iterator NumListsCur;
3084 // Remaining lists for the current declaration.
3085 unsigned RemainingLists;
3087 // The cumulative size of the previous list, or zero if there is no previous
3089 unsigned PrevListSize;
3091 // The cumulative sizes of the current list - it will delimit the remaining
3092 // range of interest.
3093 ArrayRef<unsigned>::const_iterator ListSizeCur;
3094 ArrayRef<unsigned>::const_iterator ListSizeEnd;
3096 // Iterator to the end of the components storage.
3097 MappableExprComponentListRef::const_iterator End;
3100 /// \brief Construct an iterator that scans all lists.
3101 explicit const_component_lists_iterator(
3102 ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum,
3103 ArrayRef<unsigned> CumulativeListSizes,
3104 MappableExprComponentListRef Components)
3105 : const_component_lists_iterator::iterator_adaptor_base(
3106 Components.begin()),
3107 DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
3108 RemainingLists(0u), PrevListSize(0u),
3109 ListSizeCur(CumulativeListSizes.begin()),
3110 ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
3111 assert(UniqueDecls.size() == DeclsListNum.size() &&
3112 "Inconsistent number of declarations and list sizes!");
3113 if (!DeclsListNum.empty())
3114 RemainingLists = *NumListsCur;
3117 /// \brief Construct an iterator that scan lists for a given declaration \a
3119 explicit const_component_lists_iterator(
3120 const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls,
3121 ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes,
3122 MappableExprComponentListRef Components)
3123 : const_component_lists_iterator(UniqueDecls, DeclsListNum,
3124 CumulativeListSizes, Components) {
3126 // Look for the desired declaration. While we are looking for it, we
3127 // update the state so that we know the component where a given list
3129 for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
3130 if (*DeclCur == Declaration)
3133 assert(*NumListsCur > 0 && "No lists associated with declaration??");
3135 // Skip the lists associated with the current declaration, but save the
3136 // last list size that was skipped.
3137 std::advance(ListSizeCur, *NumListsCur - 1);
3138 PrevListSize = *ListSizeCur;
3142 // If we didn't find any declaration, advance the iterator to after the
3143 // last component and set remaining lists to zero.
3144 if (ListSizeCur == CumulativeListSizes.end()) {
3146 RemainingLists = 0u;
3150 // Set the remaining lists with the total number of lists of the current
3152 RemainingLists = *NumListsCur;
3154 // Adjust the list size end iterator to the end of the relevant range.
3155 ListSizeEnd = ListSizeCur;
3156 std::advance(ListSizeEnd, RemainingLists);
3158 // Given that the list sizes are cumulative, the index of the component
3159 // that start the list is the size of the previous list.
3160 std::advance(this->I, PrevListSize);
3163 // Return the array with the current list. The sizes are cumulative, so the
3164 // array size is the difference between the current size and previous one.
3165 std::pair<const ValueDecl *, MappableExprComponentListRef>
3167 assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
3168 return std::make_pair(
3170 MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize));
3172 std::pair<const ValueDecl *, MappableExprComponentListRef>
3173 operator->() const {
3177 // Skip the components of the current list.
3178 const_component_lists_iterator &operator++() {
3179 assert(ListSizeCur != ListSizeEnd && RemainingLists &&
3180 "Invalid iterator!");
3182 // If we don't have more lists just skip all the components. Otherwise,
3183 // advance the iterator by the number of components in the current list.
3184 if (std::next(ListSizeCur) == ListSizeEnd) {
3188 std::advance(this->I, *ListSizeCur - PrevListSize);
3189 PrevListSize = *ListSizeCur;
3191 // We are done with a declaration, move to the next one.
3192 if (!(--RemainingLists)) {
3195 RemainingLists = *NumListsCur;
3196 assert(RemainingLists && "No lists in the following declaration??");
3205 typedef llvm::iterator_range<const_component_lists_iterator>
3206 const_component_lists_range;
3208 /// \brief Iterators for all component lists.
3209 const_component_lists_iterator component_lists_begin() const {
3210 return const_component_lists_iterator(
3211 getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(),
3212 getComponentsRef());
3214 const_component_lists_iterator component_lists_end() const {
3215 return const_component_lists_iterator(
3216 ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(),
3217 MappableExprComponentListRef(getComponentsRef().end(),
3218 getComponentsRef().end()));
3220 const_component_lists_range component_lists() const {
3221 return {component_lists_begin(), component_lists_end()};
3224 /// \brief Iterators for component lists associated with the provided
3226 const_component_lists_iterator
3227 decl_component_lists_begin(const ValueDecl *VD) const {
3228 return const_component_lists_iterator(
3229 VD, getUniqueDeclsRef(), getDeclNumListsRef(),
3230 getComponentListSizesRef(), getComponentsRef());
3232 const_component_lists_iterator decl_component_lists_end() const {
3233 return component_lists_end();
3235 const_component_lists_range decl_component_lists(const ValueDecl *VD) const {
3236 return {decl_component_lists_begin(VD), decl_component_lists_end()};
3239 /// Iterators to access all the declarations, number of lists, list sizes, and
3241 typedef ArrayRef<ValueDecl *>::iterator const_all_decls_iterator;
3242 typedef llvm::iterator_range<const_all_decls_iterator> const_all_decls_range;
3243 const_all_decls_range all_decls() const {
3244 auto A = getUniqueDeclsRef();
3245 return const_all_decls_range(A.begin(), A.end());
3248 typedef ArrayRef<unsigned>::iterator const_all_num_lists_iterator;
3249 typedef llvm::iterator_range<const_all_num_lists_iterator>
3250 const_all_num_lists_range;
3251 const_all_num_lists_range all_num_lists() const {
3252 auto A = getDeclNumListsRef();
3253 return const_all_num_lists_range(A.begin(), A.end());
3256 typedef ArrayRef<unsigned>::iterator const_all_lists_sizes_iterator;
3257 typedef llvm::iterator_range<const_all_lists_sizes_iterator>
3258 const_all_lists_sizes_range;
3259 const_all_lists_sizes_range all_lists_sizes() const {
3260 auto A = getComponentListSizesRef();
3261 return const_all_lists_sizes_range(A.begin(), A.end());
3264 typedef ArrayRef<MappableComponent>::iterator const_all_components_iterator;
3265 typedef llvm::iterator_range<const_all_components_iterator>
3266 const_all_components_range;
3267 const_all_components_range all_components() const {
3268 auto A = getComponentsRef();
3269 return const_all_components_range(A.begin(), A.end());
3273 /// \brief This represents clause 'map' in the '#pragma omp ...'
3277 /// #pragma omp target map(a,b)
3279 /// In this example directive '#pragma omp target' has clause 'map'
3280 /// with the variables 'a' and 'b'.
3282 class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
3283 private llvm::TrailingObjects<
3284 OMPMapClause, Expr *, ValueDecl *, unsigned,
3285 OMPClauseMappableExprCommon::MappableComponent> {
3286 friend TrailingObjects;
3287 friend OMPVarListClause;
3288 friend OMPMappableExprListClause;
3289 friend class OMPClauseReader;
3291 /// Define the sizes of each trailing object array except the last one. This
3292 /// is required for TrailingObjects to work properly.
3293 size_t numTrailingObjects(OverloadToken<Expr *>) const {
3294 return varlist_size();
3296 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
3297 return getUniqueDeclarationsNum();
3299 size_t numTrailingObjects(OverloadToken<unsigned>) const {
3300 return getUniqueDeclarationsNum() + getTotalComponentListNum();
3303 /// \brief Map type modifier for the 'map' clause.
3304 OpenMPMapClauseKind MapTypeModifier;
3305 /// \brief Map type for the 'map' clause.
3306 OpenMPMapClauseKind MapType;
3307 /// \brief Is this an implicit map type or not.
3308 bool MapTypeIsImplicit;
3309 /// \brief Location of the map type.
3310 SourceLocation MapLoc;
3311 /// \brief Colon location.
3312 SourceLocation ColonLoc;
3314 /// \brief Set type modifier for the clause.
3316 /// \param T Type Modifier for the clause.
3318 void setMapTypeModifier(OpenMPMapClauseKind T) { MapTypeModifier = T; }
3320 /// \brief Set type for the clause.
3322 /// \param T Type for the clause.
3324 void setMapType(OpenMPMapClauseKind T) { MapType = T; }
3326 /// \brief Set type location.
3328 /// \param TLoc Type location.
3330 void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
3332 /// \brief Set colon location.
3333 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3335 /// \brief Build a clause for \a NumVars listed expressions, \a
3336 /// NumUniqueDeclarations declarations, \a NumComponentLists total component
3337 /// lists, and \a NumComponents total expression components.
3339 /// \param MapTypeModifier Map type modifier.
3340 /// \param MapType Map type.
3341 /// \param MapTypeIsImplicit Map type is inferred implicitly.
3342 /// \param MapLoc Location of the map type.
3343 /// \param StartLoc Starting location of the clause.
3344 /// \param EndLoc Ending location of the clause.
3345 /// \param NumVars Number of expressions listed in this clause.
3346 /// \param NumUniqueDeclarations Number of unique base declarations in this
3348 /// \param NumComponentLists Number of component lists in this clause.
3349 /// \param NumComponents Total number of expression components in the clause.
3351 explicit OMPMapClause(OpenMPMapClauseKind MapTypeModifier,
3352 OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
3353 SourceLocation MapLoc, SourceLocation StartLoc,
3354 SourceLocation LParenLoc, SourceLocation EndLoc,
3355 unsigned NumVars, unsigned NumUniqueDeclarations,
3356 unsigned NumComponentLists, unsigned NumComponents)
3357 : OMPMappableExprListClause(OMPC_map, StartLoc, LParenLoc, EndLoc,
3358 NumVars, NumUniqueDeclarations,
3359 NumComponentLists, NumComponents),
3360 MapTypeModifier(MapTypeModifier), MapType(MapType),
3361 MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {}
3363 /// \brief Build an empty clause.
3365 /// \param NumVars Number of expressions listed in this clause.
3366 /// \param NumUniqueDeclarations Number of unique base declarations in this
3368 /// \param NumComponentLists Number of component lists in this clause.
3369 /// \param NumComponents Total number of expression components in the clause.
3371 explicit OMPMapClause(unsigned NumVars, unsigned NumUniqueDeclarations,
3372 unsigned NumComponentLists, unsigned NumComponents)
3373 : OMPMappableExprListClause(
3374 OMPC_map, SourceLocation(), SourceLocation(), SourceLocation(),
3375 NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents),
3376 MapTypeModifier(OMPC_MAP_unknown), MapType(OMPC_MAP_unknown),
3377 MapTypeIsImplicit(false), MapLoc() {}
3380 /// \brief Creates clause with a list of variables \a VL.
3382 /// \param C AST context.
3383 /// \param StartLoc Starting location of the clause.
3384 /// \param EndLoc Ending location of the clause.
3385 /// \param Vars The original expression used in the clause.
3386 /// \param Declarations Declarations used in the clause.
3387 /// \param ComponentLists Component lists used in the clause.
3388 /// \param TypeModifier Map type modifier.
3389 /// \param Type Map type.
3390 /// \param TypeIsImplicit Map type is inferred implicitly.
3391 /// \param TypeLoc Location of the map type.
3393 static OMPMapClause *Create(const ASTContext &C, SourceLocation StartLoc,
3394 SourceLocation LParenLoc, SourceLocation EndLoc,
3395 ArrayRef<Expr *> Vars,
3396 ArrayRef<ValueDecl *> Declarations,
3397 MappableExprComponentListsRef ComponentLists,
3398 OpenMPMapClauseKind TypeModifier,
3399 OpenMPMapClauseKind Type, bool TypeIsImplicit,
3400 SourceLocation TypeLoc);
3401 /// \brief Creates an empty clause with the place for for \a NumVars original
3402 /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
3403 /// lists, and \a NumComponents expression components.
3405 /// \param C AST context.
3406 /// \param NumVars Number of expressions listed in the clause.
3407 /// \param NumUniqueDeclarations Number of unique base declarations in this
3409 /// \param NumComponentLists Number of unique base declarations in this
3411 /// \param NumComponents Total number of expression components in the clause.
3413 static OMPMapClause *CreateEmpty(const ASTContext &C, unsigned NumVars,
3414 unsigned NumUniqueDeclarations,
3415 unsigned NumComponentLists,
3416 unsigned NumComponents);
3418 /// \brief Fetches mapping kind for the clause.
3419 OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
3421 /// \brief Is this an implicit map type?
3422 /// We have to capture 'IsMapTypeImplicit' from the parser for more
3423 /// informative error messages. It helps distinguish map(r) from
3424 /// map(tofrom: r), which is important to print more helpful error
3425 /// messages for some target directives.
3426 bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
3428 /// \brief Fetches the map type modifier for the clause.
3429 OpenMPMapClauseKind getMapTypeModifier() const LLVM_READONLY {
3430 return MapTypeModifier;
3433 /// \brief Fetches location of clause mapping kind.
3434 SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
3436 /// \brief Get colon location.
3437 SourceLocation getColonLoc() const { return ColonLoc; }
3439 static bool classof(const OMPClause *T) {
3440 return T->getClauseKind() == OMPC_map;
3443 child_range children() {
3445 reinterpret_cast<Stmt **>(varlist_begin()),
3446 reinterpret_cast<Stmt **>(varlist_end()));
3450 /// \brief This represents 'num_teams' clause in the '#pragma omp ...'
3454 /// #pragma omp teams num_teams(n)
3456 /// In this example directive '#pragma omp teams' has clause 'num_teams'
3457 /// with single expression 'n'.
3459 class OMPNumTeamsClause : public OMPClause {
3460 friend class OMPClauseReader;
3461 /// \brief Location of '('.
3462 SourceLocation LParenLoc;
3463 /// \brief NumTeams number.
3465 /// \brief Set the NumTeams number.
3467 /// \param E NumTeams number.
3469 void setNumTeams(Expr *E) { NumTeams = E; }
3472 /// \brief Build 'num_teams' clause.
3474 /// \param E Expression associated with this clause.
3475 /// \param StartLoc Starting location of the clause.
3476 /// \param LParenLoc Location of '('.
3477 /// \param EndLoc Ending location of the clause.
3479 OMPNumTeamsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc,
3480 SourceLocation EndLoc)
3481 : OMPClause(OMPC_num_teams, StartLoc, EndLoc), LParenLoc(LParenLoc),
3484 /// \brief Build an empty clause.
3487 : OMPClause(OMPC_num_teams, SourceLocation(), SourceLocation()),
3488 LParenLoc(SourceLocation()), NumTeams(nullptr) {}
3489 /// \brief Sets the location of '('.
3490 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3491 /// \brief Returns the location of '('.
3492 SourceLocation getLParenLoc() const { return LParenLoc; }
3493 /// \brief Return NumTeams number.
3494 Expr *getNumTeams() { return cast<Expr>(NumTeams); }
3495 /// \brief Return NumTeams number.
3496 Expr *getNumTeams() const { return cast<Expr>(NumTeams); }
3498 static bool classof(const OMPClause *T) {
3499 return T->getClauseKind() == OMPC_num_teams;
3502 child_range children() { return child_range(&NumTeams, &NumTeams + 1); }
3505 /// \brief This represents 'thread_limit' clause in the '#pragma omp ...'
3509 /// #pragma omp teams thread_limit(n)
3511 /// In this example directive '#pragma omp teams' has clause 'thread_limit'
3512 /// with single expression 'n'.
3514 class OMPThreadLimitClause : public OMPClause {
3515 friend class OMPClauseReader;
3516 /// \brief Location of '('.
3517 SourceLocation LParenLoc;
3518 /// \brief ThreadLimit number.
3520 /// \brief Set the ThreadLimit number.
3522 /// \param E ThreadLimit number.
3524 void setThreadLimit(Expr *E) { ThreadLimit = E; }
3527 /// \brief Build 'thread_limit' clause.
3529 /// \param E Expression associated with this clause.
3530 /// \param StartLoc Starting location of the clause.
3531 /// \param LParenLoc Location of '('.
3532 /// \param EndLoc Ending location of the clause.
3534 OMPThreadLimitClause(Expr *E, SourceLocation StartLoc,
3535 SourceLocation LParenLoc, SourceLocation EndLoc)
3536 : OMPClause(OMPC_thread_limit, StartLoc, EndLoc), LParenLoc(LParenLoc),
3539 /// \brief Build an empty clause.
3541 OMPThreadLimitClause()
3542 : OMPClause(OMPC_thread_limit, SourceLocation(), SourceLocation()),
3543 LParenLoc(SourceLocation()), ThreadLimit(nullptr) {}
3544 /// \brief Sets the location of '('.
3545 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3546 /// \brief Returns the location of '('.
3547 SourceLocation getLParenLoc() const { return LParenLoc; }
3548 /// \brief Return ThreadLimit number.
3549 Expr *getThreadLimit() { return cast<Expr>(ThreadLimit); }
3550 /// \brief Return ThreadLimit number.
3551 Expr *getThreadLimit() const { return cast<Expr>(ThreadLimit); }
3553 static bool classof(const OMPClause *T) {
3554 return T->getClauseKind() == OMPC_thread_limit;
3557 child_range children() { return child_range(&ThreadLimit, &ThreadLimit + 1); }
3560 /// \brief This represents 'priority' clause in the '#pragma omp ...'
3564 /// #pragma omp task priority(n)
3566 /// In this example directive '#pragma omp teams' has clause 'priority' with
3567 /// single expression 'n'.
3569 class OMPPriorityClause : public OMPClause {
3570 friend class OMPClauseReader;
3571 /// \brief Location of '('.
3572 SourceLocation LParenLoc;
3573 /// \brief Priority number.
3575 /// \brief Set the Priority number.
3577 /// \param E Priority number.
3579 void setPriority(Expr *E) { Priority = E; }
3582 /// \brief Build 'priority' clause.
3584 /// \param E Expression associated with this clause.
3585 /// \param StartLoc Starting location of the clause.
3586 /// \param LParenLoc Location of '('.
3587 /// \param EndLoc Ending location of the clause.
3589 OMPPriorityClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc,
3590 SourceLocation EndLoc)
3591 : OMPClause(OMPC_priority, StartLoc, EndLoc), LParenLoc(LParenLoc),
3594 /// \brief Build an empty clause.
3597 : OMPClause(OMPC_priority, SourceLocation(), SourceLocation()),
3598 LParenLoc(SourceLocation()), Priority(nullptr) {}
3599 /// \brief Sets the location of '('.
3600 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3601 /// \brief Returns the location of '('.
3602 SourceLocation getLParenLoc() const { return LParenLoc; }
3603 /// \brief Return Priority number.
3604 Expr *getPriority() { return cast<Expr>(Priority); }
3605 /// \brief Return Priority number.
3606 Expr *getPriority() const { return cast<Expr>(Priority); }
3608 static bool classof(const OMPClause *T) {
3609 return T->getClauseKind() == OMPC_priority;
3612 child_range children() { return child_range(&Priority, &Priority + 1); }
3615 /// \brief This represents 'grainsize' clause in the '#pragma omp ...'
3619 /// #pragma omp taskloop grainsize(4)
3621 /// In this example directive '#pragma omp taskloop' has clause 'grainsize'
3622 /// with single expression '4'.
3624 class OMPGrainsizeClause : public OMPClause {
3625 friend class OMPClauseReader;
3626 /// \brief Location of '('.
3627 SourceLocation LParenLoc;
3628 /// \brief Safe iteration space distance.
3631 /// \brief Set safelen.
3632 void setGrainsize(Expr *Size) { Grainsize = Size; }
3635 /// \brief Build 'grainsize' clause.
3637 /// \param Size Expression associated with this clause.
3638 /// \param StartLoc Starting location of the clause.
3639 /// \param EndLoc Ending location of the clause.
3641 OMPGrainsizeClause(Expr *Size, SourceLocation StartLoc,
3642 SourceLocation LParenLoc, SourceLocation EndLoc)
3643 : OMPClause(OMPC_grainsize, StartLoc, EndLoc), LParenLoc(LParenLoc),
3646 /// \brief Build an empty clause.
3648 explicit OMPGrainsizeClause()
3649 : OMPClause(OMPC_grainsize, SourceLocation(), SourceLocation()),
3650 LParenLoc(SourceLocation()), Grainsize(nullptr) {}
3652 /// \brief Sets the location of '('.
3653 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3654 /// \brief Returns the location of '('.
3655 SourceLocation getLParenLoc() const { return LParenLoc; }
3657 /// \brief Return safe iteration space distance.
3658 Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
3660 static bool classof(const OMPClause *T) {
3661 return T->getClauseKind() == OMPC_grainsize;
3664 child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
3667 /// \brief This represents 'nogroup' clause in the '#pragma omp ...' directive.
3670 /// #pragma omp taskloop nogroup
3672 /// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
3674 class OMPNogroupClause : public OMPClause {
3676 /// \brief Build 'nogroup' clause.
3678 /// \param StartLoc Starting location of the clause.
3679 /// \param EndLoc Ending location of the clause.
3681 OMPNogroupClause(SourceLocation StartLoc, SourceLocation EndLoc)
3682 : OMPClause(OMPC_nogroup, StartLoc, EndLoc) {}
3684 /// \brief Build an empty clause.
3687 : OMPClause(OMPC_nogroup, SourceLocation(), SourceLocation()) {}
3689 static bool classof(const OMPClause *T) {
3690 return T->getClauseKind() == OMPC_nogroup;
3693 child_range children() {
3694 return child_range(child_iterator(), child_iterator());
3698 /// \brief This represents 'num_tasks' clause in the '#pragma omp ...'
3702 /// #pragma omp taskloop num_tasks(4)
3704 /// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
3705 /// with single expression '4'.
3707 class OMPNumTasksClause : public OMPClause {
3708 friend class OMPClauseReader;
3709 /// \brief Location of '('.
3710 SourceLocation LParenLoc;
3711 /// \brief Safe iteration space distance.
3714 /// \brief Set safelen.
3715 void setNumTasks(Expr *Size) { NumTasks = Size; }
3718 /// \brief Build 'num_tasks' clause.
3720 /// \param Size Expression associated with this clause.
3721 /// \param StartLoc Starting location of the clause.
3722 /// \param EndLoc Ending location of the clause.
3724 OMPNumTasksClause(Expr *Size, SourceLocation StartLoc,
3725 SourceLocation LParenLoc, SourceLocation EndLoc)
3726 : OMPClause(OMPC_num_tasks, StartLoc, EndLoc), LParenLoc(LParenLoc),
3729 /// \brief Build an empty clause.
3731 explicit OMPNumTasksClause()
3732 : OMPClause(OMPC_num_tasks, SourceLocation(), SourceLocation()),
3733 LParenLoc(SourceLocation()), NumTasks(nullptr) {}
3735 /// \brief Sets the location of '('.
3736 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3737 /// \brief Returns the location of '('.
3738 SourceLocation getLParenLoc() const { return LParenLoc; }
3740 /// \brief Return safe iteration space distance.
3741 Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
3743 static bool classof(const OMPClause *T) {
3744 return T->getClauseKind() == OMPC_num_tasks;
3747 child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
3750 /// \brief This represents 'hint' clause in the '#pragma omp ...' directive.
3753 /// #pragma omp critical (name) hint(6)
3755 /// In this example directive '#pragma omp critical' has name 'name' and clause
3756 /// 'hint' with argument '6'.
3758 class OMPHintClause : public OMPClause {
3759 friend class OMPClauseReader;
3760 /// \brief Location of '('.
3761 SourceLocation LParenLoc;
3762 /// \brief Hint expression of the 'hint' clause.
3765 /// \brief Set hint expression.
3767 void setHint(Expr *H) { Hint = H; }
3770 /// \brief Build 'hint' clause with expression \a Hint.
3772 /// \param Hint Hint expression.
3773 /// \param StartLoc Starting location of the clause.
3774 /// \param LParenLoc Location of '('.
3775 /// \param EndLoc Ending location of the clause.
3777 OMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc,
3778 SourceLocation EndLoc)
3779 : OMPClause(OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc),
3782 /// \brief Build an empty clause.
3785 : OMPClause(OMPC_hint, SourceLocation(), SourceLocation()),
3786 LParenLoc(SourceLocation()), Hint(nullptr) {}
3788 /// \brief Sets the location of '('.
3789 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3790 /// \brief Returns the location of '('.
3791 SourceLocation getLParenLoc() const { return LParenLoc; }
3793 /// \brief Returns number of threads.
3794 Expr *getHint() const { return cast_or_null<Expr>(Hint); }
3796 static bool classof(const OMPClause *T) {
3797 return T->getClauseKind() == OMPC_hint;
3800 child_range children() { return child_range(&Hint, &Hint + 1); }
3803 /// \brief This represents 'dist_schedule' clause in the '#pragma omp ...'
3807 /// #pragma omp distribute dist_schedule(static, 3)
3809 /// In this example directive '#pragma omp distribute' has 'dist_schedule'
3810 /// clause with arguments 'static' and '3'.
3812 class OMPDistScheduleClause : public OMPClause, public OMPClauseWithPreInit {
3813 friend class OMPClauseReader;
3814 /// \brief Location of '('.
3815 SourceLocation LParenLoc;
3816 /// \brief A kind of the 'schedule' clause.
3817 OpenMPDistScheduleClauseKind Kind;
3818 /// \brief Start location of the schedule kind in source code.
3819 SourceLocation KindLoc;
3820 /// \brief Location of ',' (if any).
3821 SourceLocation CommaLoc;
3822 /// \brief Chunk size.
3825 /// \brief Set schedule kind.
3827 /// \param K Schedule kind.
3829 void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
3830 /// \brief Sets the location of '('.
3832 /// \param Loc Location of '('.
3834 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3835 /// \brief Set schedule kind start location.
3837 /// \param KLoc Schedule kind location.
3839 void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
3840 /// \brief Set location of ','.
3842 /// \param Loc Location of ','.
3844 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
3845 /// \brief Set chunk size.
3847 /// \param E Chunk size.
3849 void setChunkSize(Expr *E) { ChunkSize = E; }
3852 /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk
3853 /// size expression \a ChunkSize.
3855 /// \param StartLoc Starting location of the clause.
3856 /// \param LParenLoc Location of '('.
3857 /// \param KLoc Starting location of the argument.
3858 /// \param CommaLoc Location of ','.
3859 /// \param EndLoc Ending location of the clause.
3860 /// \param Kind DistSchedule kind.
3861 /// \param ChunkSize Chunk size.
3862 /// \param HelperChunkSize Helper chunk size for combined directives.
3864 OMPDistScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3865 SourceLocation KLoc, SourceLocation CommaLoc,
3866 SourceLocation EndLoc,
3867 OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize,
3868 Stmt *HelperChunkSize)
3869 : OMPClause(OMPC_dist_schedule, StartLoc, EndLoc),
3870 OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
3871 KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
3872 setPreInitStmt(HelperChunkSize);
3875 /// \brief Build an empty clause.
3877 explicit OMPDistScheduleClause()
3878 : OMPClause(OMPC_dist_schedule, SourceLocation(), SourceLocation()),
3879 OMPClauseWithPreInit(this), Kind(OMPC_DIST_SCHEDULE_unknown),
3880 ChunkSize(nullptr) {}
3882 /// \brief Get kind of the clause.
3884 OpenMPDistScheduleClauseKind getDistScheduleKind() const { return Kind; }
3885 /// \brief Get location of '('.
3887 SourceLocation getLParenLoc() { return LParenLoc; }
3888 /// \brief Get kind location.
3890 SourceLocation getDistScheduleKindLoc() { return KindLoc; }
3891 /// \brief Get location of ','.
3893 SourceLocation getCommaLoc() { return CommaLoc; }
3894 /// \brief Get chunk size.
3896 Expr *getChunkSize() { return ChunkSize; }
3897 /// \brief Get chunk size.
3899 const Expr *getChunkSize() const { return ChunkSize; }
3901 static bool classof(const OMPClause *T) {
3902 return T->getClauseKind() == OMPC_dist_schedule;
3905 child_range children() {
3906 return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
3907 reinterpret_cast<Stmt **>(&ChunkSize) + 1);
3911 /// \brief This represents 'defaultmap' clause in the '#pragma omp ...' directive.
3914 /// #pragma omp target defaultmap(tofrom: scalar)
3916 /// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
3917 /// 'scalar' with modifier 'tofrom'.
3919 class OMPDefaultmapClause : public OMPClause {
3920 friend class OMPClauseReader;
3921 /// \brief Location of '('.
3922 SourceLocation LParenLoc;
3923 /// \brief Modifiers for 'defaultmap' clause.
3924 OpenMPDefaultmapClauseModifier Modifier;
3925 /// \brief Locations of modifiers.
3926 SourceLocation ModifierLoc;
3927 /// \brief A kind of the 'defaultmap' clause.
3928 OpenMPDefaultmapClauseKind Kind;
3929 /// \brief Start location of the defaultmap kind in source code.
3930 SourceLocation KindLoc;
3932 /// \brief Set defaultmap kind.
3934 /// \param K Defaultmap kind.
3936 void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
3937 /// \brief Set the defaultmap modifier.
3939 /// \param M Defaultmap modifier.
3941 void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
3944 /// \brief Set location of the defaultmap modifier.
3946 void setDefaultmapModifierLoc(SourceLocation Loc) {
3949 /// \brief Sets the location of '('.
3951 /// \param Loc Location of '('.
3953 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3954 /// \brief Set defaultmap kind start location.
3956 /// \param KLoc Defaultmap kind location.
3958 void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
3961 /// \brief Build 'defaultmap' clause with defaultmap kind \a Kind
3963 /// \param StartLoc Starting location of the clause.
3964 /// \param LParenLoc Location of '('.
3965 /// \param KLoc Starting location of the argument.
3966 /// \param EndLoc Ending location of the clause.
3967 /// \param Kind Defaultmap kind.
3968 /// \param M The modifier applied to 'defaultmap' clause.
3969 /// \param MLoc Location of the modifier
3971 OMPDefaultmapClause(SourceLocation StartLoc, SourceLocation LParenLoc,
3972 SourceLocation MLoc, SourceLocation KLoc,
3973 SourceLocation EndLoc, OpenMPDefaultmapClauseKind Kind,
3974 OpenMPDefaultmapClauseModifier M)
3975 : OMPClause(OMPC_defaultmap, StartLoc, EndLoc), LParenLoc(LParenLoc),
3976 Modifier(M), ModifierLoc(MLoc), Kind(Kind), KindLoc(KLoc) {}
3978 /// \brief Build an empty clause.
3980 explicit OMPDefaultmapClause()
3981 : OMPClause(OMPC_defaultmap, SourceLocation(), SourceLocation()),
3982 Modifier(OMPC_DEFAULTMAP_MODIFIER_unknown),
3983 Kind(OMPC_DEFAULTMAP_unknown) {}
3985 /// \brief Get kind of the clause.
3987 OpenMPDefaultmapClauseKind getDefaultmapKind() const { return Kind; }
3988 /// \brief Get the modifier of the clause.
3990 OpenMPDefaultmapClauseModifier getDefaultmapModifier() const {
3993 /// \brief Get location of '('.
3995 SourceLocation getLParenLoc() { return LParenLoc; }
3996 /// \brief Get kind location.
3998 SourceLocation getDefaultmapKindLoc() { return KindLoc; }
3999 /// \brief Get the modifier location.
4001 SourceLocation getDefaultmapModifierLoc() const {
4005 static bool classof(const OMPClause *T) {
4006 return T->getClauseKind() == OMPC_defaultmap;
4009 child_range children() {
4010 return child_range(child_iterator(), child_iterator());
4014 /// \brief This represents clause 'to' in the '#pragma omp ...'
4018 /// #pragma omp target update to(a,b)
4020 /// In this example directive '#pragma omp target update' has clause 'to'
4021 /// with the variables 'a' and 'b'.
4023 class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
4024 private llvm::TrailingObjects<
4025 OMPToClause, Expr *, ValueDecl *, unsigned,
4026 OMPClauseMappableExprCommon::MappableComponent> {
4027 friend TrailingObjects;
4028 friend OMPVarListClause;
4029 friend OMPMappableExprListClause;
4030 friend class OMPClauseReader;
4032 /// Define the sizes of each trailing object array except the last one. This
4033 /// is required for TrailingObjects to work properly.
4034 size_t numTrailingObjects(OverloadToken<Expr *>) const {
4035 return varlist_size();
4037 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4038 return getUniqueDeclarationsNum();
4040 size_t numTrailingObjects(OverloadToken<unsigned>) const {
4041 return getUniqueDeclarationsNum() + getTotalComponentListNum();
4044 /// \brief Build clause with number of variables \a NumVars.
4046 /// \param StartLoc Starting location of the clause.
4047 /// \param EndLoc Ending location of the clause.
4048 /// \param NumVars Number of expressions listed in this clause.
4049 /// \param NumUniqueDeclarations Number of unique base declarations in this
4051 /// \param NumComponentLists Number of component lists in this clause.
4052 /// \param NumComponents Total number of expression components in the clause.
4054 explicit OMPToClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4055 SourceLocation EndLoc, unsigned NumVars,
4056 unsigned NumUniqueDeclarations,
4057 unsigned NumComponentLists, unsigned NumComponents)
4058 : OMPMappableExprListClause(OMPC_to, StartLoc, LParenLoc, EndLoc, NumVars,
4059 NumUniqueDeclarations, NumComponentLists,
4062 /// \brief Build an empty clause.
4064 /// \param NumVars Number of expressions listed in this clause.
4065 /// \param NumUniqueDeclarations Number of unique base declarations in this
4067 /// \param NumComponentLists Number of component lists in this clause.
4068 /// \param NumComponents Total number of expression components in the clause.
4070 explicit OMPToClause(unsigned NumVars, unsigned NumUniqueDeclarations,
4071 unsigned NumComponentLists, unsigned NumComponents)
4072 : OMPMappableExprListClause(
4073 OMPC_to, SourceLocation(), SourceLocation(), SourceLocation(),
4074 NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents) {}
4077 /// \brief Creates clause with a list of variables \a Vars.
4079 /// \param C AST context.
4080 /// \param StartLoc Starting location of the clause.
4081 /// \param EndLoc Ending location of the clause.
4082 /// \param Vars The original expression used in the clause.
4083 /// \param Declarations Declarations used in the clause.
4084 /// \param ComponentLists Component lists used in the clause.
4086 static OMPToClause *Create(const ASTContext &C, SourceLocation StartLoc,
4087 SourceLocation LParenLoc, SourceLocation EndLoc,
4088 ArrayRef<Expr *> Vars,
4089 ArrayRef<ValueDecl *> Declarations,
4090 MappableExprComponentListsRef ComponentLists);
4092 /// \brief Creates an empty clause with the place for \a NumVars variables.
4094 /// \param C AST context.
4095 /// \param NumVars Number of expressions listed in the clause.
4096 /// \param NumUniqueDeclarations Number of unique base declarations in this
4098 /// \param NumComponentLists Number of unique base declarations in this
4100 /// \param NumComponents Total number of expression components in the clause.
4102 static OMPToClause *CreateEmpty(const ASTContext &C, unsigned NumVars,
4103 unsigned NumUniqueDeclarations,
4104 unsigned NumComponentLists,
4105 unsigned NumComponents);
4107 static bool classof(const OMPClause *T) {
4108 return T->getClauseKind() == OMPC_to;
4111 child_range children() {
4112 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4113 reinterpret_cast<Stmt **>(varlist_end()));
4117 /// \brief This represents clause 'from' in the '#pragma omp ...'
4121 /// #pragma omp target update from(a,b)
4123 /// In this example directive '#pragma omp target update' has clause 'from'
4124 /// with the variables 'a' and 'b'.
4126 class OMPFromClause final
4127 : public OMPMappableExprListClause<OMPFromClause>,
4128 private llvm::TrailingObjects<
4129 OMPFromClause, Expr *, ValueDecl *, unsigned,
4130 OMPClauseMappableExprCommon::MappableComponent> {
4131 friend TrailingObjects;
4132 friend OMPVarListClause;
4133 friend OMPMappableExprListClause;
4134 friend class OMPClauseReader;
4136 /// Define the sizes of each trailing object array except the last one. This
4137 /// is required for TrailingObjects to work properly.
4138 size_t numTrailingObjects(OverloadToken<Expr *>) const {
4139 return varlist_size();
4141 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4142 return getUniqueDeclarationsNum();
4144 size_t numTrailingObjects(OverloadToken<unsigned>) const {
4145 return getUniqueDeclarationsNum() + getTotalComponentListNum();
4148 /// \brief Build clause with number of variables \a NumVars.
4150 /// \param StartLoc Starting location of the clause.
4151 /// \param EndLoc Ending location of the clause.
4152 /// \param NumVars Number of expressions listed in this clause.
4153 /// \param NumUniqueDeclarations Number of unique base declarations in this
4155 /// \param NumComponentLists Number of component lists in this clause.
4156 /// \param NumComponents Total number of expression components in the clause.
4158 explicit OMPFromClause(SourceLocation StartLoc, SourceLocation LParenLoc,
4159 SourceLocation EndLoc, unsigned NumVars,
4160 unsigned NumUniqueDeclarations,
4161 unsigned NumComponentLists, unsigned NumComponents)
4162 : OMPMappableExprListClause(OMPC_from, StartLoc, LParenLoc, EndLoc,
4163 NumVars, NumUniqueDeclarations,
4164 NumComponentLists, NumComponents) {}
4166 /// \brief Build an empty clause.
4168 /// \param NumVars Number of expressions listed in this clause.
4169 /// \param NumUniqueDeclarations Number of unique base declarations in this
4171 /// \param NumComponentLists Number of component lists in this clause.
4172 /// \param NumComponents Total number of expression components in the clause.
4174 explicit OMPFromClause(unsigned NumVars, unsigned NumUniqueDeclarations,
4175 unsigned NumComponentLists, unsigned NumComponents)
4176 : OMPMappableExprListClause(
4177 OMPC_from, SourceLocation(), SourceLocation(), SourceLocation(),
4178 NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents) {}
4181 /// \brief Creates clause with a list of variables \a Vars.
4183 /// \param C AST context.
4184 /// \param StartLoc Starting location of the clause.
4185 /// \param EndLoc Ending location of the clause.
4186 /// \param Vars The original expression used in the clause.
4187 /// \param Declarations Declarations used in the clause.
4188 /// \param ComponentLists Component lists used in the clause.
4190 static OMPFromClause *Create(const ASTContext &C, SourceLocation StartLoc,
4191 SourceLocation LParenLoc, SourceLocation EndLoc,
4192 ArrayRef<Expr *> Vars,
4193 ArrayRef<ValueDecl *> Declarations,
4194 MappableExprComponentListsRef ComponentLists);
4196 /// \brief Creates an empty clause with the place for \a NumVars variables.
4198 /// \param C AST context.
4199 /// \param NumVars Number of expressions listed in the clause.
4200 /// \param NumUniqueDeclarations Number of unique base declarations in this
4202 /// \param NumComponentLists Number of unique base declarations in this
4204 /// \param NumComponents Total number of expression components in the clause.
4206 static OMPFromClause *CreateEmpty(const ASTContext &C, unsigned NumVars,
4207 unsigned NumUniqueDeclarations,
4208 unsigned NumComponentLists,
4209 unsigned NumComponents);
4211 static bool classof(const OMPClause *T) {
4212 return T->getClauseKind() == OMPC_from;
4215 child_range children() {
4216 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4217 reinterpret_cast<Stmt **>(varlist_end()));
4221 /// This represents clause 'use_device_ptr' in the '#pragma omp ...'
4225 /// #pragma omp target data use_device_ptr(a,b)
4227 /// In this example directive '#pragma omp target data' has clause
4228 /// 'use_device_ptr' with the variables 'a' and 'b'.
4230 class OMPUseDevicePtrClause final
4231 : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
4232 private llvm::TrailingObjects<
4233 OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
4234 OMPClauseMappableExprCommon::MappableComponent> {
4235 friend TrailingObjects;
4236 friend OMPVarListClause;
4237 friend OMPMappableExprListClause;
4238 friend class OMPClauseReader;
4240 /// Define the sizes of each trailing object array except the last one. This
4241 /// is required for TrailingObjects to work properly.
4242 size_t numTrailingObjects(OverloadToken<Expr *>) const {
4243 return 3 * varlist_size();
4245 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4246 return getUniqueDeclarationsNum();
4248 size_t numTrailingObjects(OverloadToken<unsigned>) const {
4249 return getUniqueDeclarationsNum() + getTotalComponentListNum();
4252 /// Build clause with number of variables \a NumVars.
4254 /// \param StartLoc Starting location of the clause.
4255 /// \param EndLoc Ending location of the clause.
4256 /// \param NumVars Number of expressions listed in this clause.
4257 /// \param NumUniqueDeclarations Number of unique base declarations in this
4259 /// \param NumComponentLists Number of component lists in this clause.
4260 /// \param NumComponents Total number of expression components in the clause.
4262 explicit OMPUseDevicePtrClause(SourceLocation StartLoc,
4263 SourceLocation LParenLoc,
4264 SourceLocation EndLoc, unsigned NumVars,
4265 unsigned NumUniqueDeclarations,
4266 unsigned NumComponentLists,
4267 unsigned NumComponents)
4268 : OMPMappableExprListClause(OMPC_use_device_ptr, StartLoc, LParenLoc,
4269 EndLoc, NumVars, NumUniqueDeclarations,
4270 NumComponentLists, NumComponents) {}
4272 /// Build an empty clause.
4274 /// \param NumVars Number of expressions listed in this clause.
4275 /// \param NumUniqueDeclarations Number of unique base declarations in this
4277 /// \param NumComponentLists Number of component lists in this clause.
4278 /// \param NumComponents Total number of expression components in the clause.
4280 explicit OMPUseDevicePtrClause(unsigned NumVars,
4281 unsigned NumUniqueDeclarations,
4282 unsigned NumComponentLists,
4283 unsigned NumComponents)
4284 : OMPMappableExprListClause(OMPC_use_device_ptr, SourceLocation(),
4285 SourceLocation(), SourceLocation(), NumVars,
4286 NumUniqueDeclarations, NumComponentLists,
4289 /// Sets the list of references to private copies with initializers for new
4290 /// private variables.
4291 /// \param VL List of references.
4292 void setPrivateCopies(ArrayRef<Expr *> VL);
4294 /// Gets the list of references to private copies with initializers for new
4295 /// private variables.
4296 MutableArrayRef<Expr *> getPrivateCopies() {
4297 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
4299 ArrayRef<const Expr *> getPrivateCopies() const {
4300 return llvm::makeArrayRef(varlist_end(), varlist_size());
4303 /// Sets the list of references to initializer variables for new private
4305 /// \param VL List of references.
4306 void setInits(ArrayRef<Expr *> VL);
4308 /// Gets the list of references to initializer variables for new private
4310 MutableArrayRef<Expr *> getInits() {
4311 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
4313 ArrayRef<const Expr *> getInits() const {
4314 return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
4318 /// Creates clause with a list of variables \a Vars.
4320 /// \param C AST context.
4321 /// \param StartLoc Starting location of the clause.
4322 /// \param EndLoc Ending location of the clause.
4323 /// \param Vars The original expression used in the clause.
4324 /// \param PrivateVars Expressions referring to private copies.
4325 /// \param Inits Expressions referring to private copy initializers.
4326 /// \param Declarations Declarations used in the clause.
4327 /// \param ComponentLists Component lists used in the clause.
4329 static OMPUseDevicePtrClause *
4330 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4331 SourceLocation EndLoc, ArrayRef<Expr *> Vars,
4332 ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *> Inits,
4333 ArrayRef<ValueDecl *> Declarations,
4334 MappableExprComponentListsRef ComponentLists);
4336 /// Creates an empty clause with the place for \a NumVars variables.
4338 /// \param C AST context.
4339 /// \param NumVars Number of expressions listed in the clause.
4340 /// \param NumUniqueDeclarations Number of unique base declarations in this
4342 /// \param NumComponentLists Number of unique base declarations in this
4344 /// \param NumComponents Total number of expression components in the clause.
4346 static OMPUseDevicePtrClause *CreateEmpty(const ASTContext &C,
4348 unsigned NumUniqueDeclarations,
4349 unsigned NumComponentLists,
4350 unsigned NumComponents);
4352 typedef MutableArrayRef<Expr *>::iterator private_copies_iterator;
4353 typedef ArrayRef<const Expr *>::iterator private_copies_const_iterator;
4354 typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
4355 typedef llvm::iterator_range<private_copies_const_iterator>
4356 private_copies_const_range;
4358 private_copies_range private_copies() {
4359 return private_copies_range(getPrivateCopies().begin(),
4360 getPrivateCopies().end());
4362 private_copies_const_range private_copies() const {
4363 return private_copies_const_range(getPrivateCopies().begin(),
4364 getPrivateCopies().end());
4367 typedef MutableArrayRef<Expr *>::iterator inits_iterator;
4368 typedef ArrayRef<const Expr *>::iterator inits_const_iterator;
4369 typedef llvm::iterator_range<inits_iterator> inits_range;
4370 typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
4372 inits_range inits() {
4373 return inits_range(getInits().begin(), getInits().end());
4375 inits_const_range inits() const {
4376 return inits_const_range(getInits().begin(), getInits().end());
4379 child_range children() {
4380 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4381 reinterpret_cast<Stmt **>(varlist_end()));
4384 static bool classof(const OMPClause *T) {
4385 return T->getClauseKind() == OMPC_use_device_ptr;
4389 /// This represents clause 'is_device_ptr' in the '#pragma omp ...'
4393 /// #pragma omp target is_device_ptr(a,b)
4395 /// In this example directive '#pragma omp target' has clause
4396 /// 'is_device_ptr' with the variables 'a' and 'b'.
4398 class OMPIsDevicePtrClause final
4399 : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
4400 private llvm::TrailingObjects<
4401 OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
4402 OMPClauseMappableExprCommon::MappableComponent> {
4403 friend TrailingObjects;
4404 friend OMPVarListClause;
4405 friend OMPMappableExprListClause;
4406 friend class OMPClauseReader;
4408 /// Define the sizes of each trailing object array except the last one. This
4409 /// is required for TrailingObjects to work properly.
4410 size_t numTrailingObjects(OverloadToken<Expr *>) const {
4411 return varlist_size();
4413 size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4414 return getUniqueDeclarationsNum();
4416 size_t numTrailingObjects(OverloadToken<unsigned>) const {
4417 return getUniqueDeclarationsNum() + getTotalComponentListNum();
4419 /// Build clause with number of variables \a NumVars.
4421 /// \param StartLoc Starting location of the clause.
4422 /// \param EndLoc Ending location of the clause.
4423 /// \param NumVars Number of expressions listed in this clause.
4424 /// \param NumUniqueDeclarations Number of unique base declarations in this
4426 /// \param NumComponentLists Number of component lists in this clause.
4427 /// \param NumComponents Total number of expression components in the clause.
4429 explicit OMPIsDevicePtrClause(SourceLocation StartLoc,
4430 SourceLocation LParenLoc, SourceLocation EndLoc,
4432 unsigned NumUniqueDeclarations,
4433 unsigned NumComponentLists,
4434 unsigned NumComponents)
4435 : OMPMappableExprListClause(OMPC_is_device_ptr, StartLoc, LParenLoc,
4436 EndLoc, NumVars, NumUniqueDeclarations,
4437 NumComponentLists, NumComponents) {}
4439 /// Build an empty clause.
4441 /// \param NumVars Number of expressions listed in this clause.
4442 /// \param NumUniqueDeclarations Number of unique base declarations in this
4444 /// \param NumComponentLists Number of component lists in this clause.
4445 /// \param NumComponents Total number of expression components in the clause.
4447 explicit OMPIsDevicePtrClause(unsigned NumVars,
4448 unsigned NumUniqueDeclarations,
4449 unsigned NumComponentLists,
4450 unsigned NumComponents)
4451 : OMPMappableExprListClause(OMPC_is_device_ptr, SourceLocation(),
4452 SourceLocation(), SourceLocation(), NumVars,
4453 NumUniqueDeclarations, NumComponentLists,
4457 /// Creates clause with a list of variables \a Vars.
4459 /// \param C AST context.
4460 /// \param StartLoc Starting location of the clause.
4461 /// \param EndLoc Ending location of the clause.
4462 /// \param Vars The original expression used in the clause.
4463 /// \param Declarations Declarations used in the clause.
4464 /// \param ComponentLists Component lists used in the clause.
4466 static OMPIsDevicePtrClause *
4467 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
4468 SourceLocation EndLoc, ArrayRef<Expr *> Vars,
4469 ArrayRef<ValueDecl *> Declarations,
4470 MappableExprComponentListsRef ComponentLists);
4472 /// Creates an empty clause with the place for \a NumVars variables.
4474 /// \param C AST context.
4475 /// \param NumVars Number of expressions listed in the clause.
4476 /// \param NumUniqueDeclarations Number of unique base declarations in this
4478 /// \param NumComponentLists Number of unique base declarations in this
4480 /// \param NumComponents Total number of expression components in the clause.
4482 static OMPIsDevicePtrClause *CreateEmpty(const ASTContext &C,
4484 unsigned NumUniqueDeclarations,
4485 unsigned NumComponentLists,
4486 unsigned NumComponents);
4488 child_range children() {
4489 return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
4490 reinterpret_cast<Stmt **>(varlist_end()));
4493 static bool classof(const OMPClause *T) {
4494 return T->getClauseKind() == OMPC_is_device_ptr;
4497 } // end namespace clang
4499 #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H