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(); }
61 ConstStmtRange children() const {
62 return const_cast<OMPClause *>(this)->children();
64 static bool classof(const OMPClause *) { return true; }
67 /// \brief This represents clauses with the list of variables like 'private',
68 /// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
69 /// '#pragma omp ...' directives.
70 template <class T> class OMPVarListClause : public OMPClause {
71 friend class OMPClauseReader;
72 /// \brief Location of '('.
73 SourceLocation LParenLoc;
74 /// \brief Number of variables in the list.
78 /// \brief Fetches list of variables associated with this clause.
79 MutableArrayRef<Expr *> getVarRefs() {
80 return MutableArrayRef<Expr *>(
81 reinterpret_cast<Expr **>(
82 reinterpret_cast<char *>(this) +
83 llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<Expr *>())),
87 /// \brief Sets the list of variables for this clause.
88 void setVarRefs(ArrayRef<Expr *> VL) {
89 assert(VL.size() == NumVars &&
90 "Number of variables is not the same as the preallocated buffer");
93 reinterpret_cast<Expr **>(
94 reinterpret_cast<char *>(this) +
95 llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<Expr *>())));
98 /// \brief Build a clause with \a N variables
100 /// \param K Kind of the clause.
101 /// \param StartLoc Starting location of the clause (the clause keyword).
102 /// \param LParenLoc Location of '('.
103 /// \param EndLoc Ending location of the clause.
104 /// \param N Number of the variables in the clause.
106 OMPVarListClause(OpenMPClauseKind K, SourceLocation StartLoc,
107 SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
108 : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {}
111 typedef MutableArrayRef<Expr *>::iterator varlist_iterator;
112 typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
113 typedef llvm::iterator_range<varlist_iterator> varlist_range;
114 typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
116 unsigned varlist_size() const { return NumVars; }
117 bool varlist_empty() const { return NumVars == 0; }
119 varlist_range varlists() {
120 return varlist_range(varlist_begin(), varlist_end());
122 varlist_const_range varlists() const {
123 return varlist_const_range(varlist_begin(), varlist_end());
126 varlist_iterator varlist_begin() { return getVarRefs().begin(); }
127 varlist_iterator varlist_end() { return getVarRefs().end(); }
128 varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
129 varlist_const_iterator varlist_end() const { return getVarRefs().end(); }
131 /// \brief Sets the location of '('.
132 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
133 /// \brief Returns the location of '('.
134 SourceLocation getLParenLoc() const { return LParenLoc; }
136 /// \brief Fetches list of all variables in the clause.
137 ArrayRef<const Expr *> getVarRefs() const {
138 return llvm::makeArrayRef(
139 reinterpret_cast<const Expr *const *>(
140 reinterpret_cast<const char *>(this) +
141 llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<const Expr *>())),
146 /// \brief This represents 'if' clause in the '#pragma omp ...' directive.
149 /// #pragma omp parallel if(a > 5)
151 /// In this example directive '#pragma omp parallel' has simple 'if'
152 /// clause with condition 'a > 5'.
154 class OMPIfClause : public OMPClause {
155 friend class OMPClauseReader;
156 /// \brief Location of '('.
157 SourceLocation LParenLoc;
158 /// \brief Condition of the 'if' clause.
161 /// \brief Set condition.
163 void setCondition(Expr *Cond) { Condition = Cond; }
166 /// \brief Build 'if' clause with condition \a Cond.
168 /// \param StartLoc Starting location of the clause.
169 /// \param LParenLoc Location of '('.
170 /// \param Cond Condition of the clause.
171 /// \param EndLoc Ending location of the clause.
173 OMPIfClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,
174 SourceLocation EndLoc)
175 : OMPClause(OMPC_if, StartLoc, EndLoc), LParenLoc(LParenLoc),
178 /// \brief Build an empty clause.
181 : OMPClause(OMPC_if, SourceLocation(), SourceLocation()),
182 LParenLoc(SourceLocation()), Condition(nullptr) {}
184 /// \brief Sets the location of '('.
185 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
186 /// \brief Returns the location of '('.
187 SourceLocation getLParenLoc() const { return LParenLoc; }
189 /// \brief Returns condition.
190 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
192 static bool classof(const OMPClause *T) {
193 return T->getClauseKind() == OMPC_if;
196 StmtRange children() { return StmtRange(&Condition, &Condition + 1); }
199 /// \brief This represents 'final' clause in the '#pragma omp ...' directive.
202 /// #pragma omp task final(a > 5)
204 /// In this example directive '#pragma omp task' has simple 'final'
205 /// clause with condition 'a > 5'.
207 class OMPFinalClause : public OMPClause {
208 friend class OMPClauseReader;
209 /// \brief Location of '('.
210 SourceLocation LParenLoc;
211 /// \brief Condition of the 'if' clause.
214 /// \brief Set condition.
216 void setCondition(Expr *Cond) { Condition = Cond; }
219 /// \brief Build 'final' clause with condition \a Cond.
221 /// \param StartLoc Starting location of the clause.
222 /// \param LParenLoc Location of '('.
223 /// \param Cond Condition of the clause.
224 /// \param EndLoc Ending location of the clause.
226 OMPFinalClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,
227 SourceLocation EndLoc)
228 : OMPClause(OMPC_final, StartLoc, EndLoc), LParenLoc(LParenLoc),
231 /// \brief Build an empty clause.
234 : OMPClause(OMPC_final, SourceLocation(), SourceLocation()),
235 LParenLoc(SourceLocation()), Condition(nullptr) {}
237 /// \brief Sets the location of '('.
238 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
239 /// \brief Returns the location of '('.
240 SourceLocation getLParenLoc() const { return LParenLoc; }
242 /// \brief Returns condition.
243 Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
245 static bool classof(const OMPClause *T) {
246 return T->getClauseKind() == OMPC_final;
249 StmtRange children() { return StmtRange(&Condition, &Condition + 1); }
252 /// \brief This represents 'num_threads' clause in the '#pragma omp ...'
256 /// #pragma omp parallel num_threads(6)
258 /// In this example directive '#pragma omp parallel' has simple 'num_threads'
259 /// clause with number of threads '6'.
261 class OMPNumThreadsClause : public OMPClause {
262 friend class OMPClauseReader;
263 /// \brief Location of '('.
264 SourceLocation LParenLoc;
265 /// \brief Condition of the 'num_threads' clause.
268 /// \brief Set condition.
270 void setNumThreads(Expr *NThreads) { NumThreads = NThreads; }
273 /// \brief Build 'num_threads' clause with condition \a NumThreads.
275 /// \param NumThreads Number of threads for the construct.
276 /// \param StartLoc Starting location of the clause.
277 /// \param LParenLoc Location of '('.
278 /// \param EndLoc Ending location of the clause.
280 OMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc,
281 SourceLocation LParenLoc, SourceLocation EndLoc)
282 : OMPClause(OMPC_num_threads, StartLoc, EndLoc), LParenLoc(LParenLoc),
283 NumThreads(NumThreads) {}
285 /// \brief Build an empty clause.
287 OMPNumThreadsClause()
288 : OMPClause(OMPC_num_threads, SourceLocation(), SourceLocation()),
289 LParenLoc(SourceLocation()), NumThreads(nullptr) {}
291 /// \brief Sets the location of '('.
292 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
293 /// \brief Returns the location of '('.
294 SourceLocation getLParenLoc() const { return LParenLoc; }
296 /// \brief Returns number of threads.
297 Expr *getNumThreads() const { return cast_or_null<Expr>(NumThreads); }
299 static bool classof(const OMPClause *T) {
300 return T->getClauseKind() == OMPC_num_threads;
303 StmtRange children() { return StmtRange(&NumThreads, &NumThreads + 1); }
306 /// \brief This represents 'safelen' clause in the '#pragma omp ...'
310 /// #pragma omp simd safelen(4)
312 /// In this example directive '#pragma omp simd' has clause 'safelen'
313 /// with single expression '4'.
314 /// If the safelen clause is used then no two iterations executed
315 /// concurrently with SIMD instructions can have a greater distance
316 /// in the logical iteration space than its value. The parameter of
317 /// the safelen clause must be a constant positive integer expression.
319 class OMPSafelenClause : public OMPClause {
320 friend class OMPClauseReader;
321 /// \brief Location of '('.
322 SourceLocation LParenLoc;
323 /// \brief Safe iteration space distance.
326 /// \brief Set safelen.
327 void setSafelen(Expr *Len) { Safelen = Len; }
330 /// \brief Build 'safelen' clause.
332 /// \param Len Expression associated with this clause.
333 /// \param StartLoc Starting location of the clause.
334 /// \param EndLoc Ending location of the clause.
336 OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc,
337 SourceLocation EndLoc)
338 : OMPClause(OMPC_safelen, StartLoc, EndLoc), LParenLoc(LParenLoc),
341 /// \brief Build an empty clause.
343 explicit OMPSafelenClause()
344 : OMPClause(OMPC_safelen, SourceLocation(), SourceLocation()),
345 LParenLoc(SourceLocation()), Safelen(nullptr) {}
347 /// \brief Sets the location of '('.
348 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
349 /// \brief Returns the location of '('.
350 SourceLocation getLParenLoc() const { return LParenLoc; }
352 /// \brief Return safe iteration space distance.
353 Expr *getSafelen() const { return cast_or_null<Expr>(Safelen); }
355 static bool classof(const OMPClause *T) {
356 return T->getClauseKind() == OMPC_safelen;
359 StmtRange children() { return StmtRange(&Safelen, &Safelen + 1); }
362 /// \brief This represents 'collapse' clause in the '#pragma omp ...'
366 /// #pragma omp simd collapse(3)
368 /// In this example directive '#pragma omp simd' has clause 'collapse'
369 /// with single expression '3'.
370 /// The parameter must be a constant positive integer expression, it specifies
371 /// the number of nested loops that should be collapsed into a single iteration
374 class OMPCollapseClause : public OMPClause {
375 friend class OMPClauseReader;
376 /// \brief Location of '('.
377 SourceLocation LParenLoc;
378 /// \brief Number of for-loops.
381 /// \brief Set the number of associated for-loops.
382 void setNumForLoops(Expr *Num) { NumForLoops = Num; }
385 /// \brief Build 'collapse' clause.
387 /// \param Num Expression associated with this clause.
388 /// \param StartLoc Starting location of the clause.
389 /// \param LParenLoc Location of '('.
390 /// \param EndLoc Ending location of the clause.
392 OMPCollapseClause(Expr *Num, SourceLocation StartLoc,
393 SourceLocation LParenLoc, SourceLocation EndLoc)
394 : OMPClause(OMPC_collapse, StartLoc, EndLoc), LParenLoc(LParenLoc),
397 /// \brief Build an empty clause.
399 explicit OMPCollapseClause()
400 : OMPClause(OMPC_collapse, SourceLocation(), SourceLocation()),
401 LParenLoc(SourceLocation()), NumForLoops(nullptr) {}
403 /// \brief Sets the location of '('.
404 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
405 /// \brief Returns the location of '('.
406 SourceLocation getLParenLoc() const { return LParenLoc; }
408 /// \brief Return the number of associated for-loops.
409 Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
411 static bool classof(const OMPClause *T) {
412 return T->getClauseKind() == OMPC_collapse;
415 StmtRange children() { return StmtRange(&NumForLoops, &NumForLoops + 1); }
418 /// \brief This represents 'default' clause in the '#pragma omp ...' directive.
421 /// #pragma omp parallel default(shared)
423 /// In this example directive '#pragma omp parallel' has simple 'default'
424 /// clause with kind 'shared'.
426 class OMPDefaultClause : public OMPClause {
427 friend class OMPClauseReader;
428 /// \brief Location of '('.
429 SourceLocation LParenLoc;
430 /// \brief A kind of the 'default' clause.
431 OpenMPDefaultClauseKind Kind;
432 /// \brief Start location of the kind in source code.
433 SourceLocation KindKwLoc;
435 /// \brief Set kind of the clauses.
437 /// \param K Argument of clause.
439 void setDefaultKind(OpenMPDefaultClauseKind K) { Kind = K; }
441 /// \brief Set argument location.
443 /// \param KLoc Argument location.
445 void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
448 /// \brief Build 'default' clause with argument \a A ('none' or 'shared').
450 /// \param A Argument of the clause ('none' or 'shared').
451 /// \param ALoc Starting location of the argument.
452 /// \param StartLoc Starting location of the clause.
453 /// \param LParenLoc Location of '('.
454 /// \param EndLoc Ending location of the clause.
456 OMPDefaultClause(OpenMPDefaultClauseKind A, SourceLocation ALoc,
457 SourceLocation StartLoc, SourceLocation LParenLoc,
458 SourceLocation EndLoc)
459 : OMPClause(OMPC_default, StartLoc, EndLoc), LParenLoc(LParenLoc),
460 Kind(A), KindKwLoc(ALoc) {}
462 /// \brief Build an empty clause.
465 : OMPClause(OMPC_default, SourceLocation(), SourceLocation()),
466 LParenLoc(SourceLocation()), Kind(OMPC_DEFAULT_unknown),
467 KindKwLoc(SourceLocation()) {}
469 /// \brief Sets the location of '('.
470 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
471 /// \brief Returns the location of '('.
472 SourceLocation getLParenLoc() const { return LParenLoc; }
474 /// \brief Returns kind of the clause.
475 OpenMPDefaultClauseKind getDefaultKind() const { return Kind; }
477 /// \brief Returns location of clause kind.
478 SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
480 static bool classof(const OMPClause *T) {
481 return T->getClauseKind() == OMPC_default;
484 StmtRange children() { return StmtRange(); }
487 /// \brief This represents 'proc_bind' clause in the '#pragma omp ...'
491 /// #pragma omp parallel proc_bind(master)
493 /// In this example directive '#pragma omp parallel' has simple 'proc_bind'
494 /// clause with kind 'master'.
496 class OMPProcBindClause : public OMPClause {
497 friend class OMPClauseReader;
498 /// \brief Location of '('.
499 SourceLocation LParenLoc;
500 /// \brief A kind of the 'proc_bind' clause.
501 OpenMPProcBindClauseKind Kind;
502 /// \brief Start location of the kind in source code.
503 SourceLocation KindKwLoc;
505 /// \brief Set kind of the clause.
507 /// \param K Kind of clause.
509 void setProcBindKind(OpenMPProcBindClauseKind K) { Kind = K; }
511 /// \brief Set clause kind location.
513 /// \param KLoc Kind location.
515 void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
518 /// \brief Build 'proc_bind' clause with argument \a A ('master', 'close' or
521 /// \param A Argument of the clause ('master', 'close' or 'spread').
522 /// \param ALoc Starting location of the argument.
523 /// \param StartLoc Starting location of the clause.
524 /// \param LParenLoc Location of '('.
525 /// \param EndLoc Ending location of the clause.
527 OMPProcBindClause(OpenMPProcBindClauseKind A, SourceLocation ALoc,
528 SourceLocation StartLoc, SourceLocation LParenLoc,
529 SourceLocation EndLoc)
530 : OMPClause(OMPC_proc_bind, StartLoc, EndLoc), LParenLoc(LParenLoc),
531 Kind(A), KindKwLoc(ALoc) {}
533 /// \brief Build an empty clause.
536 : OMPClause(OMPC_proc_bind, SourceLocation(), SourceLocation()),
537 LParenLoc(SourceLocation()), Kind(OMPC_PROC_BIND_unknown),
538 KindKwLoc(SourceLocation()) {}
540 /// \brief Sets the location of '('.
541 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
542 /// \brief Returns the location of '('.
543 SourceLocation getLParenLoc() const { return LParenLoc; }
545 /// \brief Returns kind of the clause.
546 OpenMPProcBindClauseKind getProcBindKind() const { return Kind; }
548 /// \brief Returns location of clause kind.
549 SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
551 static bool classof(const OMPClause *T) {
552 return T->getClauseKind() == OMPC_proc_bind;
555 StmtRange children() { return StmtRange(); }
558 /// \brief This represents 'schedule' clause in the '#pragma omp ...' directive.
561 /// #pragma omp for schedule(static, 3)
563 /// In this example directive '#pragma omp for' has 'schedule' clause with
564 /// arguments 'static' and '3'.
566 class OMPScheduleClause : public OMPClause {
567 friend class OMPClauseReader;
568 /// \brief Location of '('.
569 SourceLocation LParenLoc;
570 /// \brief A kind of the 'schedule' clause.
571 OpenMPScheduleClauseKind Kind;
572 /// \brief Start location of the schedule ind in source code.
573 SourceLocation KindLoc;
574 /// \brief Location of ',' (if any).
575 SourceLocation CommaLoc;
576 /// \brief Chunk size.
579 /// \brief Set schedule kind.
581 /// \param K Schedule kind.
583 void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
584 /// \brief Sets the location of '('.
586 /// \param Loc Location of '('.
588 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
589 /// \brief Set schedule kind start location.
591 /// \param KLoc Schedule kind location.
593 void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
594 /// \brief Set location of ','.
596 /// \param Loc Location of ','.
598 void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
599 /// \brief Set chunk size.
601 /// \param E Chunk size.
603 void setChunkSize(Expr *E) { ChunkSize = E; }
606 /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size
607 /// expression \a ChunkSize.
609 /// \param StartLoc Starting location of the clause.
610 /// \param LParenLoc Location of '('.
611 /// \param KLoc Starting location of the argument.
612 /// \param CommaLoc Location of ','.
613 /// \param EndLoc Ending location of the clause.
614 /// \param Kind Schedule kind.
615 /// \param ChunkSize Chunk size.
617 OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
618 SourceLocation KLoc, SourceLocation CommaLoc,
619 SourceLocation EndLoc, OpenMPScheduleClauseKind Kind,
621 : OMPClause(OMPC_schedule, StartLoc, EndLoc), LParenLoc(LParenLoc),
622 Kind(Kind), KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {}
624 /// \brief Build an empty clause.
626 explicit OMPScheduleClause()
627 : OMPClause(OMPC_schedule, SourceLocation(), SourceLocation()),
628 Kind(OMPC_SCHEDULE_unknown), ChunkSize(nullptr) {}
630 /// \brief Get kind of the clause.
632 OpenMPScheduleClauseKind getScheduleKind() const { return Kind; }
633 /// \brief Get location of '('.
635 SourceLocation getLParenLoc() { return LParenLoc; }
636 /// \brief Get kind location.
638 SourceLocation getScheduleKindLoc() { return KindLoc; }
639 /// \brief Get location of ','.
641 SourceLocation getCommaLoc() { return CommaLoc; }
642 /// \brief Get chunk size.
644 Expr *getChunkSize() { return dyn_cast_or_null<Expr>(ChunkSize); }
645 /// \brief Get chunk size.
647 Expr *getChunkSize() const { return dyn_cast_or_null<Expr>(ChunkSize); }
649 static bool classof(const OMPClause *T) {
650 return T->getClauseKind() == OMPC_schedule;
653 StmtRange children() { return StmtRange(&ChunkSize, &ChunkSize + 1); }
656 /// \brief This represents 'ordered' clause in the '#pragma omp ...' directive.
659 /// #pragma omp for ordered
661 /// In this example directive '#pragma omp for' has 'ordered' clause.
663 class OMPOrderedClause : public OMPClause {
665 /// \brief Build 'ordered' clause.
667 /// \param StartLoc Starting location of the clause.
668 /// \param EndLoc Ending location of the clause.
670 OMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc)
671 : OMPClause(OMPC_ordered, StartLoc, EndLoc) {}
673 /// \brief Build an empty clause.
676 : OMPClause(OMPC_ordered, SourceLocation(), SourceLocation()) {}
678 static bool classof(const OMPClause *T) {
679 return T->getClauseKind() == OMPC_ordered;
682 StmtRange children() { return StmtRange(); }
685 /// \brief This represents 'nowait' clause in the '#pragma omp ...' directive.
688 /// #pragma omp for nowait
690 /// In this example directive '#pragma omp for' has 'nowait' clause.
692 class OMPNowaitClause : public OMPClause {
694 /// \brief Build 'nowait' clause.
696 /// \param StartLoc Starting location of the clause.
697 /// \param EndLoc Ending location of the clause.
699 OMPNowaitClause(SourceLocation StartLoc, SourceLocation EndLoc)
700 : OMPClause(OMPC_nowait, StartLoc, EndLoc) {}
702 /// \brief Build an empty clause.
705 : OMPClause(OMPC_nowait, SourceLocation(), SourceLocation()) {}
707 static bool classof(const OMPClause *T) {
708 return T->getClauseKind() == OMPC_nowait;
711 StmtRange children() { return StmtRange(); }
714 /// \brief This represents 'untied' clause in the '#pragma omp ...' directive.
717 /// #pragma omp task untied
719 /// In this example directive '#pragma omp task' has 'untied' clause.
721 class OMPUntiedClause : public OMPClause {
723 /// \brief Build 'untied' clause.
725 /// \param StartLoc Starting location of the clause.
726 /// \param EndLoc Ending location of the clause.
728 OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
729 : OMPClause(OMPC_untied, StartLoc, EndLoc) {}
731 /// \brief Build an empty clause.
734 : OMPClause(OMPC_untied, SourceLocation(), SourceLocation()) {}
736 static bool classof(const OMPClause *T) {
737 return T->getClauseKind() == OMPC_untied;
740 StmtRange children() { return StmtRange(); }
743 /// \brief This represents 'mergeable' clause in the '#pragma omp ...'
747 /// #pragma omp task mergeable
749 /// In this example directive '#pragma omp task' has 'mergeable' clause.
751 class OMPMergeableClause : public OMPClause {
753 /// \brief Build 'mergeable' clause.
755 /// \param StartLoc Starting location of the clause.
756 /// \param EndLoc Ending location of the clause.
758 OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc)
759 : OMPClause(OMPC_mergeable, StartLoc, EndLoc) {}
761 /// \brief Build an empty clause.
764 : OMPClause(OMPC_mergeable, SourceLocation(), SourceLocation()) {}
766 static bool classof(const OMPClause *T) {
767 return T->getClauseKind() == OMPC_mergeable;
770 StmtRange children() { return StmtRange(); }
773 /// \brief This represents 'read' clause in the '#pragma omp atomic' directive.
776 /// #pragma omp atomic read
778 /// In this example directive '#pragma omp atomic' has 'read' clause.
780 class OMPReadClause : public OMPClause {
782 /// \brief Build 'read' clause.
784 /// \param StartLoc Starting location of the clause.
785 /// \param EndLoc Ending location of the clause.
787 OMPReadClause(SourceLocation StartLoc, SourceLocation EndLoc)
788 : OMPClause(OMPC_read, StartLoc, EndLoc) {}
790 /// \brief Build an empty clause.
792 OMPReadClause() : OMPClause(OMPC_read, SourceLocation(), SourceLocation()) {}
794 static bool classof(const OMPClause *T) {
795 return T->getClauseKind() == OMPC_read;
798 StmtRange children() { return StmtRange(); }
801 /// \brief This represents 'write' clause in the '#pragma omp atomic' directive.
804 /// #pragma omp atomic write
806 /// In this example directive '#pragma omp atomic' has 'write' clause.
808 class OMPWriteClause : public OMPClause {
810 /// \brief Build 'write' clause.
812 /// \param StartLoc Starting location of the clause.
813 /// \param EndLoc Ending location of the clause.
815 OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc)
816 : OMPClause(OMPC_write, StartLoc, EndLoc) {}
818 /// \brief Build an empty clause.
821 : OMPClause(OMPC_write, SourceLocation(), SourceLocation()) {}
823 static bool classof(const OMPClause *T) {
824 return T->getClauseKind() == OMPC_write;
827 StmtRange children() { return StmtRange(); }
830 /// \brief This represents 'update' clause in the '#pragma omp atomic'
834 /// #pragma omp atomic update
836 /// In this example directive '#pragma omp atomic' has 'update' clause.
838 class OMPUpdateClause : public OMPClause {
840 /// \brief Build 'update' clause.
842 /// \param StartLoc Starting location of the clause.
843 /// \param EndLoc Ending location of the clause.
845 OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc)
846 : OMPClause(OMPC_update, StartLoc, EndLoc) {}
848 /// \brief Build an empty clause.
851 : OMPClause(OMPC_update, SourceLocation(), SourceLocation()) {}
853 static bool classof(const OMPClause *T) {
854 return T->getClauseKind() == OMPC_update;
857 StmtRange children() { return StmtRange(); }
860 /// \brief This represents 'capture' clause in the '#pragma omp atomic'
864 /// #pragma omp atomic capture
866 /// In this example directive '#pragma omp atomic' has 'capture' clause.
868 class OMPCaptureClause : public OMPClause {
870 /// \brief Build 'capture' clause.
872 /// \param StartLoc Starting location of the clause.
873 /// \param EndLoc Ending location of the clause.
875 OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc)
876 : OMPClause(OMPC_capture, StartLoc, EndLoc) {}
878 /// \brief Build an empty clause.
881 : OMPClause(OMPC_capture, SourceLocation(), SourceLocation()) {}
883 static bool classof(const OMPClause *T) {
884 return T->getClauseKind() == OMPC_capture;
887 StmtRange children() { return StmtRange(); }
890 /// \brief This represents 'seq_cst' clause in the '#pragma omp atomic'
894 /// #pragma omp atomic seq_cst
896 /// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
898 class OMPSeqCstClause : public OMPClause {
900 /// \brief Build 'seq_cst' clause.
902 /// \param StartLoc Starting location of the clause.
903 /// \param EndLoc Ending location of the clause.
905 OMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc)
906 : OMPClause(OMPC_seq_cst, StartLoc, EndLoc) {}
908 /// \brief Build an empty clause.
911 : OMPClause(OMPC_seq_cst, SourceLocation(), SourceLocation()) {}
913 static bool classof(const OMPClause *T) {
914 return T->getClauseKind() == OMPC_seq_cst;
917 StmtRange children() { return StmtRange(); }
920 /// \brief This represents clause 'private' in the '#pragma omp ...' directives.
923 /// #pragma omp parallel private(a,b)
925 /// In this example directive '#pragma omp parallel' has clause 'private'
926 /// with the variables 'a' and 'b'.
928 class OMPPrivateClause : public OMPVarListClause<OMPPrivateClause> {
929 friend class OMPClauseReader;
930 /// \brief Build clause with number of variables \a N.
932 /// \param StartLoc Starting location of the clause.
933 /// \param LParenLoc Location of '('.
934 /// \param EndLoc Ending location of the clause.
935 /// \param N Number of the variables in the clause.
937 OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
938 SourceLocation EndLoc, unsigned N)
939 : OMPVarListClause<OMPPrivateClause>(OMPC_private, StartLoc, LParenLoc,
942 /// \brief Build an empty clause.
944 /// \param N Number of variables.
946 explicit OMPPrivateClause(unsigned N)
947 : OMPVarListClause<OMPPrivateClause>(OMPC_private, SourceLocation(),
948 SourceLocation(), SourceLocation(),
951 /// \brief Sets the list of references to private copies with initializers for
952 /// new private variables.
953 /// \param VL List of references.
954 void setPrivateCopies(ArrayRef<Expr *> VL);
956 /// \brief Gets the list of references to private copies with initializers for
957 /// new private variables.
958 MutableArrayRef<Expr *> getPrivateCopies() {
959 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
961 ArrayRef<const Expr *> getPrivateCopies() const {
962 return llvm::makeArrayRef(varlist_end(), varlist_size());
966 /// \brief Creates clause with a list of variables \a VL.
968 /// \param C AST context.
969 /// \param StartLoc Starting location of the clause.
970 /// \param LParenLoc Location of '('.
971 /// \param EndLoc Ending location of the clause.
972 /// \param VL List of references to the variables.
973 /// \param PrivateVL List of references to private copies with initializers.
975 static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc,
976 SourceLocation LParenLoc,
977 SourceLocation EndLoc, ArrayRef<Expr *> VL,
978 ArrayRef<Expr *> PrivateVL);
979 /// \brief Creates an empty clause with the place for \a N variables.
981 /// \param C AST context.
982 /// \param N The number of variables.
984 static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N);
986 typedef MutableArrayRef<Expr *>::iterator private_copies_iterator;
987 typedef ArrayRef<const Expr *>::iterator private_copies_const_iterator;
988 typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
989 typedef llvm::iterator_range<private_copies_const_iterator>
990 private_copies_const_range;
992 private_copies_range private_copies() {
993 return private_copies_range(getPrivateCopies().begin(),
994 getPrivateCopies().end());
996 private_copies_const_range private_copies() const {
997 return private_copies_const_range(getPrivateCopies().begin(),
998 getPrivateCopies().end());
1001 StmtRange children() {
1002 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1003 reinterpret_cast<Stmt **>(varlist_end()));
1006 static bool classof(const OMPClause *T) {
1007 return T->getClauseKind() == OMPC_private;
1011 /// \brief This represents clause 'firstprivate' in the '#pragma omp ...'
1015 /// #pragma omp parallel firstprivate(a,b)
1017 /// In this example directive '#pragma omp parallel' has clause 'firstprivate'
1018 /// with the variables 'a' and 'b'.
1020 class OMPFirstprivateClause : public OMPVarListClause<OMPFirstprivateClause> {
1021 friend class OMPClauseReader;
1023 /// \brief Build clause with number of variables \a N.
1025 /// \param StartLoc Starting location of the clause.
1026 /// \param LParenLoc Location of '('.
1027 /// \param EndLoc Ending location of the clause.
1028 /// \param N Number of the variables in the clause.
1030 OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1031 SourceLocation EndLoc, unsigned N)
1032 : OMPVarListClause<OMPFirstprivateClause>(OMPC_firstprivate, StartLoc,
1033 LParenLoc, EndLoc, N) {}
1035 /// \brief Build an empty clause.
1037 /// \param N Number of variables.
1039 explicit OMPFirstprivateClause(unsigned N)
1040 : OMPVarListClause<OMPFirstprivateClause>(
1041 OMPC_firstprivate, SourceLocation(), SourceLocation(),
1042 SourceLocation(), N) {}
1043 /// \brief Sets the list of references to private copies with initializers for
1044 /// new private variables.
1045 /// \param VL List of references.
1046 void setPrivateCopies(ArrayRef<Expr *> VL);
1048 /// \brief Gets the list of references to private copies with initializers for
1049 /// new private variables.
1050 MutableArrayRef<Expr *> getPrivateCopies() {
1051 return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1053 ArrayRef<const Expr *> getPrivateCopies() const {
1054 return llvm::makeArrayRef(varlist_end(), varlist_size());
1057 /// \brief Sets the list of references to initializer variables for new
1058 /// private variables.
1059 /// \param VL List of references.
1060 void setInits(ArrayRef<Expr *> VL);
1062 /// \brief Gets the list of references to initializer variables for new
1063 /// private variables.
1064 MutableArrayRef<Expr *> getInits() {
1065 return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1067 ArrayRef<const Expr *> getInits() const {
1068 return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1072 /// \brief Creates clause with a list of variables \a VL.
1074 /// \param C AST context.
1075 /// \param StartLoc Starting location of the clause.
1076 /// \param LParenLoc Location of '('.
1077 /// \param EndLoc Ending location of the clause.
1078 /// \param VL List of references to the original variables.
1079 /// \param PrivateVL List of references to private copies with initializers.
1080 /// \param InitVL List of references to auto generated variables used for
1081 /// initialization of a single array element. Used if firstprivate variable is
1084 static OMPFirstprivateClause *
1085 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1086 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
1087 ArrayRef<Expr *> InitVL);
1088 /// \brief Creates an empty clause with the place for \a N variables.
1090 /// \param C AST context.
1091 /// \param N The number of variables.
1093 static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1095 typedef MutableArrayRef<Expr *>::iterator private_copies_iterator;
1096 typedef ArrayRef<const Expr *>::iterator private_copies_const_iterator;
1097 typedef llvm::iterator_range<private_copies_iterator> private_copies_range;
1098 typedef llvm::iterator_range<private_copies_const_iterator>
1099 private_copies_const_range;
1101 private_copies_range private_copies() {
1102 return private_copies_range(getPrivateCopies().begin(),
1103 getPrivateCopies().end());
1105 private_copies_const_range private_copies() const {
1106 return private_copies_const_range(getPrivateCopies().begin(),
1107 getPrivateCopies().end());
1110 typedef MutableArrayRef<Expr *>::iterator inits_iterator;
1111 typedef ArrayRef<const Expr *>::iterator inits_const_iterator;
1112 typedef llvm::iterator_range<inits_iterator> inits_range;
1113 typedef llvm::iterator_range<inits_const_iterator> inits_const_range;
1115 inits_range inits() {
1116 return inits_range(getInits().begin(), getInits().end());
1118 inits_const_range inits() const {
1119 return inits_const_range(getInits().begin(), getInits().end());
1122 StmtRange children() {
1123 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1124 reinterpret_cast<Stmt **>(varlist_end()));
1127 static bool classof(const OMPClause *T) {
1128 return T->getClauseKind() == OMPC_firstprivate;
1132 /// \brief This represents clause 'lastprivate' in the '#pragma omp ...'
1136 /// #pragma omp simd lastprivate(a,b)
1138 /// In this example directive '#pragma omp simd' has clause 'lastprivate'
1139 /// with the variables 'a' and 'b'.
1141 class OMPLastprivateClause : public OMPVarListClause<OMPLastprivateClause> {
1142 /// \brief Build clause with number of variables \a N.
1144 /// \param StartLoc Starting location of the clause.
1145 /// \param LParenLoc Location of '('.
1146 /// \param EndLoc Ending location of the clause.
1147 /// \param N Number of the variables in the clause.
1149 OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1150 SourceLocation EndLoc, unsigned N)
1151 : OMPVarListClause<OMPLastprivateClause>(OMPC_lastprivate, StartLoc,
1152 LParenLoc, EndLoc, N) {}
1154 /// \brief Build an empty clause.
1156 /// \param N Number of variables.
1158 explicit OMPLastprivateClause(unsigned N)
1159 : OMPVarListClause<OMPLastprivateClause>(
1160 OMPC_lastprivate, SourceLocation(), SourceLocation(),
1161 SourceLocation(), N) {}
1164 /// \brief Creates clause with a list of variables \a VL.
1166 /// \param C AST context.
1167 /// \param StartLoc Starting location of the clause.
1168 /// \param LParenLoc Location of '('.
1169 /// \param EndLoc Ending location of the clause.
1170 /// \param VL List of references to the variables.
1172 static OMPLastprivateClause *
1173 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1174 SourceLocation EndLoc, ArrayRef<Expr *> VL);
1175 /// \brief Creates an empty clause with the place for \a N variables.
1177 /// \param C AST context.
1178 /// \param N The number of variables.
1180 static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1182 StmtRange children() {
1183 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1184 reinterpret_cast<Stmt **>(varlist_end()));
1187 static bool classof(const OMPClause *T) {
1188 return T->getClauseKind() == OMPC_lastprivate;
1192 /// \brief This represents clause 'shared' in the '#pragma omp ...' directives.
1195 /// #pragma omp parallel shared(a,b)
1197 /// In this example directive '#pragma omp parallel' has clause 'shared'
1198 /// with the variables 'a' and 'b'.
1200 class OMPSharedClause : public OMPVarListClause<OMPSharedClause> {
1201 /// \brief Build clause with number of variables \a N.
1203 /// \param StartLoc Starting location of the clause.
1204 /// \param LParenLoc Location of '('.
1205 /// \param EndLoc Ending location of the clause.
1206 /// \param N Number of the variables in the clause.
1208 OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1209 SourceLocation EndLoc, unsigned N)
1210 : OMPVarListClause<OMPSharedClause>(OMPC_shared, StartLoc, LParenLoc,
1213 /// \brief Build an empty clause.
1215 /// \param N Number of variables.
1217 explicit OMPSharedClause(unsigned N)
1218 : OMPVarListClause<OMPSharedClause>(OMPC_shared, SourceLocation(),
1219 SourceLocation(), SourceLocation(),
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.
1231 static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc,
1232 SourceLocation LParenLoc,
1233 SourceLocation EndLoc, ArrayRef<Expr *> VL);
1234 /// \brief Creates an empty clause with \a N variables.
1236 /// \param C AST context.
1237 /// \param N The number of variables.
1239 static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N);
1241 StmtRange children() {
1242 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1243 reinterpret_cast<Stmt **>(varlist_end()));
1246 static bool classof(const OMPClause *T) {
1247 return T->getClauseKind() == OMPC_shared;
1251 /// \brief This represents clause 'reduction' in the '#pragma omp ...'
1255 /// #pragma omp parallel reduction(+:a,b)
1257 /// In this example directive '#pragma omp parallel' has clause 'reduction'
1258 /// with operator '+' and the variables 'a' and 'b'.
1260 class OMPReductionClause : public OMPVarListClause<OMPReductionClause> {
1261 friend class OMPClauseReader;
1262 /// \brief Location of ':'.
1263 SourceLocation ColonLoc;
1264 /// \brief Nested name specifier for C++.
1265 NestedNameSpecifierLoc QualifierLoc;
1266 /// \brief Name of custom operator.
1267 DeclarationNameInfo NameInfo;
1269 /// \brief Build clause with number of variables \a N.
1271 /// \param StartLoc Starting location of the clause.
1272 /// \param LParenLoc Location of '('.
1273 /// \param EndLoc Ending location of the clause.
1274 /// \param ColonLoc Location of ':'.
1275 /// \param N Number of the variables in the clause.
1276 /// \param QualifierLoc The nested-name qualifier with location information
1277 /// \param NameInfo The full name info for reduction identifier.
1279 OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1280 SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N,
1281 NestedNameSpecifierLoc QualifierLoc,
1282 const DeclarationNameInfo &NameInfo)
1283 : OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
1284 LParenLoc, EndLoc, N),
1285 ColonLoc(ColonLoc), QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
1287 /// \brief Build an empty clause.
1289 /// \param N Number of variables.
1291 explicit OMPReductionClause(unsigned N)
1292 : OMPVarListClause<OMPReductionClause>(OMPC_reduction, SourceLocation(),
1293 SourceLocation(), SourceLocation(),
1295 ColonLoc(), QualifierLoc(), NameInfo() {}
1297 /// \brief Sets location of ':' symbol in clause.
1298 void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
1299 /// \brief Sets the name info for specified reduction identifier.
1300 void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
1301 /// \brief Sets the nested name specifier.
1302 void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
1305 /// \brief Creates clause with a list of variables \a VL.
1307 /// \param StartLoc Starting location of the clause.
1308 /// \param LParenLoc Location of '('.
1309 /// \param ColonLoc Location of ':'.
1310 /// \param EndLoc Ending location of the clause.
1311 /// \param VL The variables in the clause.
1312 /// \param QualifierLoc The nested-name qualifier with location information
1313 /// \param NameInfo The full name info for reduction identifier.
1315 static OMPReductionClause *
1316 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1317 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
1318 NestedNameSpecifierLoc QualifierLoc,
1319 const DeclarationNameInfo &NameInfo);
1320 /// \brief Creates an empty clause with the place for \a N variables.
1322 /// \param C AST context.
1323 /// \param N The number of variables.
1325 static OMPReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
1327 /// \brief Gets location of ':' symbol in clause.
1328 SourceLocation getColonLoc() const { return ColonLoc; }
1329 /// \brief Gets the name info for specified reduction identifier.
1330 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
1331 /// \brief Gets the nested name specifier.
1332 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
1334 StmtRange children() {
1335 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1336 reinterpret_cast<Stmt **>(varlist_end()));
1339 static bool classof(const OMPClause *T) {
1340 return T->getClauseKind() == OMPC_reduction;
1344 /// \brief This represents clause 'linear' in the '#pragma omp ...'
1348 /// #pragma omp simd linear(a,b : 2)
1350 /// In this example directive '#pragma omp simd' has clause 'linear'
1351 /// with variables 'a', 'b' and linear step '2'.
1353 class OMPLinearClause : public OMPVarListClause<OMPLinearClause> {
1354 friend class OMPClauseReader;
1355 /// \brief Location of ':'.
1356 SourceLocation ColonLoc;
1358 /// \brief Sets the linear step for clause.
1359 void setStep(Expr *Step) { *varlist_end() = Step; }
1361 /// \brief Build 'linear' clause with given number of variables \a NumVars.
1363 /// \param StartLoc Starting location of the clause.
1364 /// \param LParenLoc Location of '('.
1365 /// \param ColonLoc Location of ':'.
1366 /// \param EndLoc Ending location of the clause.
1367 /// \param NumVars Number of variables.
1369 OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1370 SourceLocation ColonLoc, SourceLocation EndLoc,
1372 : OMPVarListClause<OMPLinearClause>(OMPC_linear, StartLoc, LParenLoc,
1374 ColonLoc(ColonLoc) {}
1376 /// \brief Build an empty clause.
1378 /// \param NumVars Number of variables.
1380 explicit OMPLinearClause(unsigned NumVars)
1381 : OMPVarListClause<OMPLinearClause>(OMPC_linear, SourceLocation(),
1382 SourceLocation(), SourceLocation(),
1384 ColonLoc(SourceLocation()) {}
1387 /// \brief Creates clause with a list of variables \a VL and a linear step
1390 /// \param C AST Context.
1391 /// \param StartLoc Starting location of the clause.
1392 /// \param LParenLoc Location of '('.
1393 /// \param ColonLoc Location of ':'.
1394 /// \param EndLoc Ending location of the clause.
1395 /// \param VL List of references to the variables.
1396 /// \param Step Linear step.
1397 static OMPLinearClause *Create(const ASTContext &C, SourceLocation StartLoc,
1398 SourceLocation LParenLoc,
1399 SourceLocation ColonLoc, SourceLocation EndLoc,
1400 ArrayRef<Expr *> VL, Expr *Step);
1402 /// \brief Creates an empty clause with the place for \a NumVars variables.
1404 /// \param C AST context.
1405 /// \param NumVars Number of variables.
1407 static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
1409 /// \brief Sets the location of ':'.
1410 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
1411 /// \brief Returns the location of '('.
1412 SourceLocation getColonLoc() const { return ColonLoc; }
1414 /// \brief Returns linear step.
1415 Expr *getStep() { return *varlist_end(); }
1416 /// \brief Returns linear step.
1417 const Expr *getStep() const { return *varlist_end(); }
1419 StmtRange children() {
1420 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1421 reinterpret_cast<Stmt **>(varlist_end() + 1));
1424 static bool classof(const OMPClause *T) {
1425 return T->getClauseKind() == OMPC_linear;
1429 /// \brief This represents clause 'aligned' in the '#pragma omp ...'
1433 /// #pragma omp simd aligned(a,b : 8)
1435 /// In this example directive '#pragma omp simd' has clause 'aligned'
1436 /// with variables 'a', 'b' and alignment '8'.
1438 class OMPAlignedClause : public OMPVarListClause<OMPAlignedClause> {
1439 friend class OMPClauseReader;
1440 /// \brief Location of ':'.
1441 SourceLocation ColonLoc;
1443 /// \brief Sets the alignment for clause.
1444 void setAlignment(Expr *A) { *varlist_end() = A; }
1446 /// \brief Build 'aligned' clause with given number of variables \a NumVars.
1448 /// \param StartLoc Starting location of the clause.
1449 /// \param LParenLoc Location of '('.
1450 /// \param ColonLoc Location of ':'.
1451 /// \param EndLoc Ending location of the clause.
1452 /// \param NumVars Number of variables.
1454 OMPAlignedClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1455 SourceLocation ColonLoc, SourceLocation EndLoc,
1457 : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, StartLoc, LParenLoc,
1459 ColonLoc(ColonLoc) {}
1461 /// \brief Build an empty clause.
1463 /// \param NumVars Number of variables.
1465 explicit OMPAlignedClause(unsigned NumVars)
1466 : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, SourceLocation(),
1467 SourceLocation(), SourceLocation(),
1469 ColonLoc(SourceLocation()) {}
1472 /// \brief Creates clause with a list of variables \a VL and alignment \a A.
1474 /// \param C AST Context.
1475 /// \param StartLoc Starting location of the clause.
1476 /// \param LParenLoc Location of '('.
1477 /// \param ColonLoc Location of ':'.
1478 /// \param EndLoc Ending location of the clause.
1479 /// \param VL List of references to the variables.
1480 /// \param A Alignment.
1481 static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc,
1482 SourceLocation LParenLoc,
1483 SourceLocation ColonLoc,
1484 SourceLocation EndLoc, ArrayRef<Expr *> VL,
1487 /// \brief Creates an empty clause with the place for \a NumVars variables.
1489 /// \param C AST context.
1490 /// \param NumVars Number of variables.
1492 static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars);
1494 /// \brief Sets the location of ':'.
1495 void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
1496 /// \brief Returns the location of ':'.
1497 SourceLocation getColonLoc() const { return ColonLoc; }
1499 /// \brief Returns alignment.
1500 Expr *getAlignment() { return *varlist_end(); }
1501 /// \brief Returns alignment.
1502 const Expr *getAlignment() const { return *varlist_end(); }
1504 StmtRange children() {
1505 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1506 reinterpret_cast<Stmt **>(varlist_end() + 1));
1509 static bool classof(const OMPClause *T) {
1510 return T->getClauseKind() == OMPC_aligned;
1514 /// \brief This represents clause 'copyin' in the '#pragma omp ...' directives.
1517 /// #pragma omp parallel copyin(a,b)
1519 /// In this example directive '#pragma omp parallel' has clause 'copyin'
1520 /// with the variables 'a' and 'b'.
1522 class OMPCopyinClause : public OMPVarListClause<OMPCopyinClause> {
1523 /// \brief Build clause with number of variables \a N.
1525 /// \param StartLoc Starting location of the clause.
1526 /// \param LParenLoc Location of '('.
1527 /// \param EndLoc Ending location of the clause.
1528 /// \param N Number of the variables in the clause.
1530 OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1531 SourceLocation EndLoc, unsigned N)
1532 : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, StartLoc, LParenLoc,
1535 /// \brief Build an empty clause.
1537 /// \param N Number of variables.
1539 explicit OMPCopyinClause(unsigned N)
1540 : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, SourceLocation(),
1541 SourceLocation(), SourceLocation(),
1545 /// \brief Creates clause with a list of variables \a VL.
1547 /// \param C AST context.
1548 /// \param StartLoc Starting location of the clause.
1549 /// \param LParenLoc Location of '('.
1550 /// \param EndLoc Ending location of the clause.
1551 /// \param VL List of references to the variables.
1553 static OMPCopyinClause *Create(const ASTContext &C, SourceLocation StartLoc,
1554 SourceLocation LParenLoc,
1555 SourceLocation EndLoc, ArrayRef<Expr *> VL);
1556 /// \brief Creates an empty clause with \a N variables.
1558 /// \param C AST context.
1559 /// \param N The number of variables.
1561 static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N);
1563 StmtRange children() {
1564 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1565 reinterpret_cast<Stmt **>(varlist_end()));
1568 static bool classof(const OMPClause *T) {
1569 return T->getClauseKind() == OMPC_copyin;
1573 /// \brief This represents clause 'copyprivate' in the '#pragma omp ...'
1577 /// #pragma omp single copyprivate(a,b)
1579 /// In this example directive '#pragma omp single' has clause 'copyprivate'
1580 /// with the variables 'a' and 'b'.
1582 class OMPCopyprivateClause : public OMPVarListClause<OMPCopyprivateClause> {
1583 /// \brief Build clause with number of variables \a N.
1585 /// \param StartLoc Starting location of the clause.
1586 /// \param LParenLoc Location of '('.
1587 /// \param EndLoc Ending location of the clause.
1588 /// \param N Number of the variables in the clause.
1590 OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1591 SourceLocation EndLoc, unsigned N)
1592 : OMPVarListClause<OMPCopyprivateClause>(OMPC_copyprivate, StartLoc,
1593 LParenLoc, EndLoc, N) {}
1595 /// \brief Build an empty clause.
1597 /// \param N Number of variables.
1599 explicit OMPCopyprivateClause(unsigned N)
1600 : OMPVarListClause<OMPCopyprivateClause>(
1601 OMPC_copyprivate, SourceLocation(), SourceLocation(),
1602 SourceLocation(), N) {}
1605 /// \brief Creates clause with a list of variables \a VL.
1607 /// \param C AST context.
1608 /// \param StartLoc Starting location of the clause.
1609 /// \param LParenLoc Location of '('.
1610 /// \param EndLoc Ending location of the clause.
1611 /// \param VL List of references to the variables.
1613 static OMPCopyprivateClause *
1614 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1615 SourceLocation EndLoc, ArrayRef<Expr *> VL);
1616 /// \brief Creates an empty clause with \a N variables.
1618 /// \param C AST context.
1619 /// \param N The number of variables.
1621 static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N);
1623 StmtRange children() {
1624 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1625 reinterpret_cast<Stmt **>(varlist_end()));
1628 static bool classof(const OMPClause *T) {
1629 return T->getClauseKind() == OMPC_copyprivate;
1633 /// \brief This represents implicit clause 'flush' for the '#pragma omp flush'
1635 /// This clause does not exist by itself, it can be only as a part of 'omp
1636 /// flush' directive. This clause is introduced to keep the original structure
1637 /// of \a OMPExecutableDirective class and its derivatives and to use the
1638 /// existing infrastructure of clauses with the list of variables.
1641 /// #pragma omp flush(a,b)
1643 /// In this example directive '#pragma omp flush' has implicit clause 'flush'
1644 /// with the variables 'a' and 'b'.
1646 class OMPFlushClause : public OMPVarListClause<OMPFlushClause> {
1647 /// \brief Build clause with number of variables \a N.
1649 /// \param StartLoc Starting location of the clause.
1650 /// \param LParenLoc Location of '('.
1651 /// \param EndLoc Ending location of the clause.
1652 /// \param N Number of the variables in the clause.
1654 OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc,
1655 SourceLocation EndLoc, unsigned N)
1656 : OMPVarListClause<OMPFlushClause>(OMPC_flush, StartLoc, LParenLoc,
1659 /// \brief Build an empty clause.
1661 /// \param N Number of variables.
1663 explicit OMPFlushClause(unsigned N)
1664 : OMPVarListClause<OMPFlushClause>(OMPC_flush, SourceLocation(),
1665 SourceLocation(), SourceLocation(),
1669 /// \brief Creates clause with a list of variables \a VL.
1671 /// \param C AST context.
1672 /// \param StartLoc Starting location of the clause.
1673 /// \param LParenLoc Location of '('.
1674 /// \param EndLoc Ending location of the clause.
1675 /// \param VL List of references to the variables.
1677 static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc,
1678 SourceLocation LParenLoc, SourceLocation EndLoc,
1679 ArrayRef<Expr *> VL);
1680 /// \brief Creates an empty clause with \a N variables.
1682 /// \param C AST context.
1683 /// \param N The number of variables.
1685 static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N);
1687 StmtRange children() {
1688 return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()),
1689 reinterpret_cast<Stmt **>(varlist_end()));
1692 static bool classof(const OMPClause *T) {
1693 return T->getClauseKind() == OMPC_flush;
1697 } // end namespace clang