Clang Project

clang_source_code/include/clang/AST/OpenMPClause.h
1//===- OpenMPClause.h - Classes for OpenMP clauses --------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// This file defines OpenMP AST classes for clauses.
11/// There are clauses for executable directives, clauses for declarative
12/// directives and clauses which can be used in both kinds of directives.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_CLANG_AST_OPENMPCLAUSE_H
17#define LLVM_CLANG_AST_OPENMPCLAUSE_H
18
19#include "clang/AST/Decl.h"
20#include "clang/AST/DeclarationName.h"
21#include "clang/AST/Expr.h"
22#include "clang/AST/NestedNameSpecifier.h"
23#include "clang/AST/Stmt.h"
24#include "clang/AST/StmtIterator.h"
25#include "clang/Basic/LLVM.h"
26#include "clang/Basic/OpenMPKinds.h"
27#include "clang/Basic/SourceLocation.h"
28#include "llvm/ADT/ArrayRef.h"
29#include "llvm/ADT/MapVector.h"
30#include "llvm/ADT/SmallVector.h"
31#include "llvm/ADT/iterator.h"
32#include "llvm/ADT/iterator_range.h"
33#include "llvm/Support/Casting.h"
34#include "llvm/Support/Compiler.h"
35#include "llvm/Support/TrailingObjects.h"
36#include <cassert>
37#include <cstddef>
38#include <iterator>
39#include <utility>
40
41namespace clang {
42
43class ASTContext;
44
45//===----------------------------------------------------------------------===//
46// AST classes for clauses.
47//===----------------------------------------------------------------------===//
48
49/// This is a basic class for representing single OpenMP clause.
50class OMPClause {
51  /// Starting location of the clause (the clause keyword).
52  SourceLocation StartLoc;
53
54  /// Ending location of the clause.
55  SourceLocation EndLoc;
56
57  /// Kind of the clause.
58  OpenMPClauseKind Kind;
59
60protected:
61  OMPClause(OpenMPClauseKind KSourceLocation StartLocSourceLocation EndLoc)
62      : StartLoc(StartLoc), EndLoc(EndLoc), Kind(K) {}
63
64public:
65  /// Returns the starting location of the clause.
66  SourceLocation getBeginLoc() const { return StartLoc; }
67
68  /// Returns the ending location of the clause.
69  SourceLocation getEndLoc() const { return EndLoc; }
70
71  /// Sets the starting location of the clause.
72  void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
73
74  /// Sets the ending location of the clause.
75  void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
76
77  /// Returns kind of OpenMP clause (private, shared, reduction, etc.).
78  OpenMPClauseKind getClauseKind() const { return Kind; }
79
80  bool isImplicit() const { return StartLoc.isInvalid(); }
81
82  using child_iterator = StmtIterator;
83  using const_child_iterator = ConstStmtIterator;
84  using child_range = llvm::iterator_range<child_iterator>;
85  using const_child_range = llvm::iterator_range<const_child_iterator>;
86
87  child_range children();
88  const_child_range children() const {
89    auto Children = const_cast<OMPClause *>(this)->children();
90    return const_child_range(Children.begin(), Children.end());
91  }
92
93  static bool classof(const OMPClause *) { return true; }
94};
95
96/// Class that handles pre-initialization statement for some clauses, like
97/// 'shedule', 'firstprivate' etc.
98class OMPClauseWithPreInit {
99  friend class OMPClauseReader;
100
101  /// Pre-initialization statement for the clause.
102  Stmt *PreInit = nullptr;
103
104  /// Region that captures the associated stmt.
105  OpenMPDirectiveKind CaptureRegion = OMPD_unknown;
106
107protected:
108  OMPClauseWithPreInit(const OMPClause *This) {
109     (0) . __assert_fail ("get(This) && \"get is not tuned for pre-init.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 109, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(get(This) && "get is not tuned for pre-init.");
110  }
111
112  /// Set pre-initialization statement for the clause.
113  void setPreInitStmt(Stmt *SOpenMPDirectiveKind ThisRegion = OMPD_unknown) {
114    PreInit = S;
115    CaptureRegion = ThisRegion;
116  }
117
118public:
119  /// Get pre-initialization statement for the clause.
120  const Stmt *getPreInitStmt() const { return PreInit; }
121
122  /// Get pre-initialization statement for the clause.
123  Stmt *getPreInitStmt() { return PreInit; }
124
125  /// Get capture region for the stmt in the clause.
126  OpenMPDirectiveKind getCaptureRegion() const { return CaptureRegion; }
127
128  static OMPClauseWithPreInit *get(OMPClause *C);
129  static const OMPClauseWithPreInit *get(const OMPClause *C);
130};
131
132/// Class that handles post-update expression for some clauses, like
133/// 'lastprivate', 'reduction' etc.
134class OMPClauseWithPostUpdate : public OMPClauseWithPreInit {
135  friend class OMPClauseReader;
136
137  /// Post-update expression for the clause.
138  Expr *PostUpdate = nullptr;
139
140protected:
141  OMPClauseWithPostUpdate(const OMPClause *This) : OMPClauseWithPreInit(This) {
142     (0) . __assert_fail ("get(This) && \"get is not tuned for post-update.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 142, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(get(This) && "get is not tuned for post-update.");
143  }
144
145  /// Set pre-initialization statement for the clause.
146  void setPostUpdateExpr(Expr *S) { PostUpdate = S; }
147
148public:
149  /// Get post-update expression for the clause.
150  const Expr *getPostUpdateExpr() const { return PostUpdate; }
151
152  /// Get post-update expression for the clause.
153  Expr *getPostUpdateExpr() { return PostUpdate; }
154
155  static OMPClauseWithPostUpdate *get(OMPClause *C);
156  static const OMPClauseWithPostUpdate *get(const OMPClause *C);
157};
158
159/// This structure contains most locations needed for by an OMPVarListClause.
160struct OMPVarListLocTy {
161  /// Starting location of the clause (the clause keyword).
162  SourceLocation StartLoc;
163  /// Location of '('.
164  SourceLocation LParenLoc;
165  /// Ending location of the clause.
166  SourceLocation EndLoc;
167  OMPVarListLocTy() = default;
168  OMPVarListLocTy(SourceLocation StartLocSourceLocation LParenLoc,
169                  SourceLocation EndLoc)
170      : StartLoc(StartLoc), LParenLoc(LParenLoc), EndLoc(EndLoc) {}
171};
172
173/// This represents clauses with the list of variables like 'private',
174/// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
175/// '#pragma omp ...' directives.
176template <class T> class OMPVarListClause : public OMPClause {
177  friend class OMPClauseReader;
178
179  /// Location of '('.
180  SourceLocation LParenLoc;
181
182  /// Number of variables in the list.
183  unsigned NumVars;
184
185protected:
186  /// Build a clause with \a N variables
187  ///
188  /// \param K Kind of the clause.
189  /// \param StartLoc Starting location of the clause (the clause keyword).
190  /// \param LParenLoc Location of '('.
191  /// \param EndLoc Ending location of the clause.
192  /// \param N Number of the variables in the clause.
193  OMPVarListClause(OpenMPClauseKind KSourceLocation StartLoc,
194                   SourceLocation LParenLocSourceLocation EndLocunsigned N)
195      : OMPClause(KStartLocEndLoc), LParenLoc(LParenLoc), NumVars(N) {}
196
197  /// Fetches list of variables associated with this clause.
198  MutableArrayRef<Expr *> getVarRefs() {
199    return MutableArrayRef<Expr *>(
200        static_cast<T *>(this)->template getTrailingObjects<Expr *>(), NumVars);
201  }
202
203  /// Sets the list of variables for this clause.
204  void setVarRefs(ArrayRef<Expr *> VL) {
205     (0) . __assert_fail ("VL.size() == NumVars && \"Number of variables is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 206, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(VL.size() == NumVars &&
206 (0) . __assert_fail ("VL.size() == NumVars && \"Number of variables is not the same as the preallocated buffer\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 206, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Number of variables is not the same as the preallocated buffer");
207    std::copy(VL.begin(), VL.end(),
208              static_cast<T *>(this)->template getTrailingObjects<Expr *>());
209  }
210
211public:
212  using varlist_iterator = MutableArrayRef<Expr *>::iterator;
213  using varlist_const_iterator = ArrayRef<const Expr *>::iterator;
214  using varlist_range = llvm::iterator_range<varlist_iterator>;
215  using varlist_const_range = llvm::iterator_range<varlist_const_iterator>;
216
217  unsigned varlist_size() const { return NumVars; }
218  bool varlist_empty() const { return NumVars == 0; }
219
220  varlist_range varlists() {
221    return varlist_range(varlist_begin(), varlist_end());
222  }
223  varlist_const_range varlists() const {
224    return varlist_const_range(varlist_begin(), varlist_end());
225  }
226
227  varlist_iterator varlist_begin() { return getVarRefs().begin(); }
228  varlist_iterator varlist_end() { return getVarRefs().end(); }
229  varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
230  varlist_const_iterator varlist_end() const { return getVarRefs().end(); }
231
232  /// Sets the location of '('.
233  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
234
235  /// Returns the location of '('.
236  SourceLocation getLParenLoc() const { return LParenLoc; }
237
238  /// Fetches list of all variables in the clause.
239  ArrayRef<const Expr *> getVarRefs() const {
240    return llvm::makeArrayRef(
241        static_cast<const T *>(this)->template getTrailingObjects<Expr *>(),
242        NumVars);
243  }
244};
245
246/// This represents 'allocator' clause in the '#pragma omp ...'
247/// directive.
248///
249/// \code
250/// #pragma omp allocate(a) allocator(omp_default_mem_alloc)
251/// \endcode
252/// In this example directive '#pragma omp allocate' has simple 'allocator'
253/// clause with the allocator 'omp_default_mem_alloc'.
254class OMPAllocatorClause : public OMPClause {
255  friend class OMPClauseReader;
256
257  /// Location of '('.
258  SourceLocation LParenLoc;
259
260  /// Expression with the allocator.
261  Stmt *Allocator = nullptr;
262
263  /// Set allocator.
264  void setAllocator(Expr *A) { Allocator = A; }
265
266public:
267  /// Build 'allocator' clause with the given allocator.
268  ///
269  /// \param A Allocator.
270  /// \param StartLoc Starting location of the clause.
271  /// \param LParenLoc Location of '('.
272  /// \param EndLoc Ending location of the clause.
273  OMPAllocatorClause(Expr *ASourceLocation StartLocSourceLocation LParenLoc,
274                     SourceLocation EndLoc)
275      : OMPClause(OMPC_allocatorStartLocEndLoc), LParenLoc(LParenLoc),
276        Allocator(A) {}
277
278  /// Build an empty clause.
279  OMPAllocatorClause()
280      : OMPClause(OMPC_allocatorSourceLocation(), SourceLocation()) {}
281
282  /// Sets the location of '('.
283  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
284
285  /// Returns the location of '('.
286  SourceLocation getLParenLoc() const { return LParenLoc; }
287
288  /// Returns allocator.
289  Expr *getAllocator() const { return cast_or_null<Expr>(Allocator); }
290
291  child_range children() { return child_range(&Allocator, &Allocator + 1); }
292
293  static bool classof(const OMPClause *T) {
294    return T->getClauseKind() == OMPC_allocator;
295  }
296};
297
298/// This represents clause 'allocate' in the '#pragma omp ...' directives.
299///
300/// \code
301/// #pragma omp parallel private(a) allocate(omp_default_mem_alloc :a)
302/// \endcode
303/// In this example directive '#pragma omp parallel' has clause 'private'
304/// and clause 'allocate' for the variable 'a'.
305class OMPAllocateClause final
306    : public OMPVarListClause<OMPAllocateClause>,
307      private llvm::TrailingObjects<OMPAllocateClause, Expr *> {
308  friend class OMPClauseReader;
309  friend OMPVarListClause;
310  friend TrailingObjects;
311
312  /// Allocator specified in the clause, or 'nullptr' if the default one is
313  /// used.
314  Expr *Allocator = nullptr;
315  /// Position of the ':' delimiter in the clause;
316  SourceLocation ColonLoc;
317
318  /// Build clause with number of variables \a N.
319  ///
320  /// \param StartLoc Starting location of the clause.
321  /// \param LParenLoc Location of '('.
322  /// \param Allocator Allocator expression.
323  /// \param ColonLoc Location of ':' delimiter.
324  /// \param EndLoc Ending location of the clause.
325  /// \param N Number of the variables in the clause.
326  OMPAllocateClause(SourceLocation StartLocSourceLocation LParenLoc,
327                    Expr *AllocatorSourceLocation ColonLoc,
328                    SourceLocation EndLocunsigned N)
329      : OMPVarListClause<OMPAllocateClause>(OMPC_allocate, StartLoc, LParenLoc,
330                                            EndLoc, N),
331        Allocator(Allocator), ColonLoc(ColonLoc) {}
332
333  /// Build an empty clause.
334  ///
335  /// \param N Number of variables.
336  explicit OMPAllocateClause(unsigned N)
337      : OMPVarListClause<OMPAllocateClause>(OMPC_allocate, SourceLocation(),
338                                            SourceLocation(), SourceLocation(),
339                                            N) {}
340
341  /// Sets location of ':' symbol in clause.
342  void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
343
344  void setAllocator(Expr *A) { Allocator = A; }
345
346public:
347  /// Creates clause with a list of variables \a VL.
348  ///
349  /// \param C AST context.
350  /// \param StartLoc Starting location of the clause.
351  /// \param LParenLoc Location of '('.
352  /// \param Allocator Allocator expression.
353  /// \param ColonLoc Location of ':' delimiter.
354  /// \param EndLoc Ending location of the clause.
355  /// \param VL List of references to the variables.
356  static OMPAllocateClause *Create(const ASTContext &CSourceLocation StartLoc,
357                                   SourceLocation LParenLocExpr *Allocator,
358                                   SourceLocation ColonLoc,
359                                   SourceLocation EndLocArrayRef<Expr *> VL);
360
361  /// Returns the allocator expression or nullptr, if no allocator is specified.
362  Expr *getAllocator() const { return Allocator; }
363
364  /// Returns the location of the ':' delimiter.
365  SourceLocation getColonLoc() const { return ColonLoc; }
366
367  /// Creates an empty clause with the place for \a N variables.
368  ///
369  /// \param C AST context.
370  /// \param N The number of variables.
371  static OMPAllocateClause *CreateEmpty(const ASTContext &Cunsigned N);
372
373  child_range children() {
374    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
375                       reinterpret_cast<Stmt **>(varlist_end()));
376  }
377
378  static bool classof(const OMPClause *T) {
379    return T->getClauseKind() == OMPC_allocate;
380  }
381};
382
383/// This represents 'if' clause in the '#pragma omp ...' directive.
384///
385/// \code
386/// #pragma omp parallel if(parallel:a > 5)
387/// \endcode
388/// In this example directive '#pragma omp parallel' has simple 'if' clause with
389/// condition 'a > 5' and directive name modifier 'parallel'.
390class OMPIfClause : public OMPClausepublic OMPClauseWithPreInit {
391  friend class OMPClauseReader;
392
393  /// Location of '('.
394  SourceLocation LParenLoc;
395
396  /// Condition of the 'if' clause.
397  Stmt *Condition = nullptr;
398
399  /// Location of ':' (if any).
400  SourceLocation ColonLoc;
401
402  /// Directive name modifier for the clause.
403  OpenMPDirectiveKind NameModifier = OMPD_unknown;
404
405  /// Name modifier location.
406  SourceLocation NameModifierLoc;
407
408  /// Set condition.
409  void setCondition(Expr *Cond) { Condition = Cond; }
410
411  /// Set directive name modifier for the clause.
412  void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; }
413
414  /// Set location of directive name modifier for the clause.
415  void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; }
416
417  /// Set location of ':'.
418  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
419
420public:
421  /// Build 'if' clause with condition \a Cond.
422  ///
423  /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause.
424  /// \param Cond Condition of the clause.
425  /// \param HelperCond Helper condition for the clause.
426  /// \param CaptureRegion Innermost OpenMP region where expressions in this
427  /// clause must be captured.
428  /// \param StartLoc Starting location of the clause.
429  /// \param LParenLoc Location of '('.
430  /// \param NameModifierLoc Location of directive name modifier.
431  /// \param ColonLoc [OpenMP 4.1] Location of ':'.
432  /// \param EndLoc Ending location of the clause.
433  OMPIfClause(OpenMPDirectiveKind NameModifierExpr *CondStmt *HelperCond,
434              OpenMPDirectiveKind CaptureRegionSourceLocation StartLoc,
435              SourceLocation LParenLocSourceLocation NameModifierLoc,
436              SourceLocation ColonLocSourceLocation EndLoc)
437      : OMPClause(OMPC_ifStartLocEndLoc), OMPClauseWithPreInit(this),
438        LParenLoc(LParenLoc), Condition(Cond), ColonLoc(ColonLoc),
439        NameModifier(NameModifier), NameModifierLoc(NameModifierLoc) {
440    setPreInitStmt(HelperCondCaptureRegion);
441  }
442
443  /// Build an empty clause.
444  OMPIfClause()
445      : OMPClause(OMPC_ifSourceLocation(), SourceLocation()),
446        OMPClauseWithPreInit(this) {}
447
448  /// Sets the location of '('.
449  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
450
451  /// Returns the location of '('.
452  SourceLocation getLParenLoc() const { return LParenLoc; }
453
454  /// Return the location of ':'.
455  SourceLocation getColonLoc() const { return ColonLoc; }
456
457  /// Returns condition.
458  Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
459
460  /// Return directive name modifier associated with the clause.
461  OpenMPDirectiveKind getNameModifier() const { return NameModifier; }
462
463  /// Return the location of directive name modifier.
464  SourceLocation getNameModifierLoc() const { return NameModifierLoc; }
465
466  child_range children() { return child_range(&Condition, &Condition + 1); }
467
468  static bool classof(const OMPClause *T) {
469    return T->getClauseKind() == OMPC_if;
470  }
471};
472
473/// This represents 'final' clause in the '#pragma omp ...' directive.
474///
475/// \code
476/// #pragma omp task final(a > 5)
477/// \endcode
478/// In this example directive '#pragma omp task' has simple 'final'
479/// clause with condition 'a > 5'.
480class OMPFinalClause : public OMPClause {
481  friend class OMPClauseReader;
482
483  /// Location of '('.
484  SourceLocation LParenLoc;
485
486  /// Condition of the 'if' clause.
487  Stmt *Condition = nullptr;
488
489  /// Set condition.
490  void setCondition(Expr *Cond) { Condition = Cond; }
491
492public:
493  /// Build 'final' clause with condition \a Cond.
494  ///
495  /// \param StartLoc Starting location of the clause.
496  /// \param LParenLoc Location of '('.
497  /// \param Cond Condition of the clause.
498  /// \param EndLoc Ending location of the clause.
499  OMPFinalClause(Expr *CondSourceLocation StartLocSourceLocation LParenLoc,
500                 SourceLocation EndLoc)
501      : OMPClause(OMPC_finalStartLocEndLoc), LParenLoc(LParenLoc),
502        Condition(Cond) {}
503
504  /// Build an empty clause.
505  OMPFinalClause()
506      : OMPClause(OMPC_finalSourceLocation(), SourceLocation()) {}
507
508  /// Sets the location of '('.
509  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
510
511  /// Returns the location of '('.
512  SourceLocation getLParenLoc() const { return LParenLoc; }
513
514  /// Returns condition.
515  Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
516
517  child_range children() { return child_range(&Condition, &Condition + 1); }
518
519  static bool classof(const OMPClause *T) {
520    return T->getClauseKind() == OMPC_final;
521  }
522};
523
524/// This represents 'num_threads' clause in the '#pragma omp ...'
525/// directive.
526///
527/// \code
528/// #pragma omp parallel num_threads(6)
529/// \endcode
530/// In this example directive '#pragma omp parallel' has simple 'num_threads'
531/// clause with number of threads '6'.
532class OMPNumThreadsClause : public OMPClausepublic OMPClauseWithPreInit {
533  friend class OMPClauseReader;
534
535  /// Location of '('.
536  SourceLocation LParenLoc;
537
538  /// Condition of the 'num_threads' clause.
539  Stmt *NumThreads = nullptr;
540
541  /// Set condition.
542  void setNumThreads(Expr *NThreads) { NumThreads = NThreads; }
543
544public:
545  /// Build 'num_threads' clause with condition \a NumThreads.
546  ///
547  /// \param NumThreads Number of threads for the construct.
548  /// \param HelperNumThreads Helper Number of threads for the construct.
549  /// \param CaptureRegion Innermost OpenMP region where expressions in this
550  /// clause must be captured.
551  /// \param StartLoc Starting location of the clause.
552  /// \param LParenLoc Location of '('.
553  /// \param EndLoc Ending location of the clause.
554  OMPNumThreadsClause(Expr *NumThreadsStmt *HelperNumThreads,
555                      OpenMPDirectiveKind CaptureRegion,
556                      SourceLocation StartLocSourceLocation LParenLoc,
557                      SourceLocation EndLoc)
558      : OMPClause(OMPC_num_threadsStartLocEndLoc),
559        OMPClauseWithPreInit(this), LParenLoc(LParenLoc),
560        NumThreads(NumThreads) {
561    setPreInitStmt(HelperNumThreadsCaptureRegion);
562  }
563
564  /// Build an empty clause.
565  OMPNumThreadsClause()
566      : OMPClause(OMPC_num_threadsSourceLocation(), SourceLocation()),
567        OMPClauseWithPreInit(this) {}
568
569  /// Sets the location of '('.
570  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
571
572  /// Returns the location of '('.
573  SourceLocation getLParenLoc() const { return LParenLoc; }
574
575  /// Returns number of threads.
576  Expr *getNumThreads() const { return cast_or_null<Expr>(NumThreads); }
577
578  child_range children() { return child_range(&NumThreads, &NumThreads + 1); }
579
580  static bool classof(const OMPClause *T) {
581    return T->getClauseKind() == OMPC_num_threads;
582  }
583};
584
585/// This represents 'safelen' clause in the '#pragma omp ...'
586/// directive.
587///
588/// \code
589/// #pragma omp simd safelen(4)
590/// \endcode
591/// In this example directive '#pragma omp simd' has clause 'safelen'
592/// with single expression '4'.
593/// If the safelen clause is used then no two iterations executed
594/// concurrently with SIMD instructions can have a greater distance
595/// in the logical iteration space than its value. The parameter of
596/// the safelen clause must be a constant positive integer expression.
597class OMPSafelenClause : public OMPClause {
598  friend class OMPClauseReader;
599
600  /// Location of '('.
601  SourceLocation LParenLoc;
602
603  /// Safe iteration space distance.
604  Stmt *Safelen = nullptr;
605
606  /// Set safelen.
607  void setSafelen(Expr *Len) { Safelen = Len; }
608
609public:
610  /// Build 'safelen' clause.
611  ///
612  /// \param Len Expression associated with this clause.
613  /// \param StartLoc Starting location of the clause.
614  /// \param EndLoc Ending location of the clause.
615  OMPSafelenClause(Expr *LenSourceLocation StartLocSourceLocation LParenLoc,
616                   SourceLocation EndLoc)
617      : OMPClause(OMPC_safelenStartLocEndLoc), LParenLoc(LParenLoc),
618        Safelen(Len) {}
619
620  /// Build an empty clause.
621  explicit OMPSafelenClause()
622      : OMPClause(OMPC_safelenSourceLocation(), SourceLocation()) {}
623
624  /// Sets the location of '('.
625  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
626
627  /// Returns the location of '('.
628  SourceLocation getLParenLoc() const { return LParenLoc; }
629
630  /// Return safe iteration space distance.
631  Expr *getSafelen() const { return cast_or_null<Expr>(Safelen); }
632
633  child_range children() { return child_range(&Safelen, &Safelen + 1); }
634
635  static bool classof(const OMPClause *T) {
636    return T->getClauseKind() == OMPC_safelen;
637  }
638};
639
640/// This represents 'simdlen' clause in the '#pragma omp ...'
641/// directive.
642///
643/// \code
644/// #pragma omp simd simdlen(4)
645/// \endcode
646/// In this example directive '#pragma omp simd' has clause 'simdlen'
647/// with single expression '4'.
648/// If the 'simdlen' clause is used then it specifies the preferred number of
649/// iterations to be executed concurrently. The parameter of the 'simdlen'
650/// clause must be a constant positive integer expression.
651class OMPSimdlenClause : public OMPClause {
652  friend class OMPClauseReader;
653
654  /// Location of '('.
655  SourceLocation LParenLoc;
656
657  /// Safe iteration space distance.
658  Stmt *Simdlen = nullptr;
659
660  /// Set simdlen.
661  void setSimdlen(Expr *Len) { Simdlen = Len; }
662
663public:
664  /// Build 'simdlen' clause.
665  ///
666  /// \param Len Expression associated with this clause.
667  /// \param StartLoc Starting location of the clause.
668  /// \param EndLoc Ending location of the clause.
669  OMPSimdlenClause(Expr *LenSourceLocation StartLocSourceLocation LParenLoc,
670                   SourceLocation EndLoc)
671      : OMPClause(OMPC_simdlenStartLocEndLoc), LParenLoc(LParenLoc),
672        Simdlen(Len) {}
673
674  /// Build an empty clause.
675  explicit OMPSimdlenClause()
676      : OMPClause(OMPC_simdlenSourceLocation(), SourceLocation()) {}
677
678  /// Sets the location of '('.
679  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
680
681  /// Returns the location of '('.
682  SourceLocation getLParenLoc() const { return LParenLoc; }
683
684  /// Return safe iteration space distance.
685  Expr *getSimdlen() const { return cast_or_null<Expr>(Simdlen); }
686
687  child_range children() { return child_range(&Simdlen, &Simdlen + 1); }
688
689  static bool classof(const OMPClause *T) {
690    return T->getClauseKind() == OMPC_simdlen;
691  }
692};
693
694/// This represents 'collapse' clause in the '#pragma omp ...'
695/// directive.
696///
697/// \code
698/// #pragma omp simd collapse(3)
699/// \endcode
700/// In this example directive '#pragma omp simd' has clause 'collapse'
701/// with single expression '3'.
702/// The parameter must be a constant positive integer expression, it specifies
703/// the number of nested loops that should be collapsed into a single iteration
704/// space.
705class OMPCollapseClause : public OMPClause {
706  friend class OMPClauseReader;
707
708  /// Location of '('.
709  SourceLocation LParenLoc;
710
711  /// Number of for-loops.
712  Stmt *NumForLoops = nullptr;
713
714  /// Set the number of associated for-loops.
715  void setNumForLoops(Expr *Num) { NumForLoops = Num; }
716
717public:
718  /// Build 'collapse' clause.
719  ///
720  /// \param Num Expression associated with this clause.
721  /// \param StartLoc Starting location of the clause.
722  /// \param LParenLoc Location of '('.
723  /// \param EndLoc Ending location of the clause.
724  OMPCollapseClause(Expr *NumSourceLocation StartLoc,
725                    SourceLocation LParenLocSourceLocation EndLoc)
726      : OMPClause(OMPC_collapseStartLocEndLoc), LParenLoc(LParenLoc),
727        NumForLoops(Num) {}
728
729  /// Build an empty clause.
730  explicit OMPCollapseClause()
731      : OMPClause(OMPC_collapseSourceLocation(), SourceLocation()) {}
732
733  /// Sets the location of '('.
734  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
735
736  /// Returns the location of '('.
737  SourceLocation getLParenLoc() const { return LParenLoc; }
738
739  /// Return the number of associated for-loops.
740  Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
741
742  child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
743
744  static bool classof(const OMPClause *T) {
745    return T->getClauseKind() == OMPC_collapse;
746  }
747};
748
749/// This represents 'default' clause in the '#pragma omp ...' directive.
750///
751/// \code
752/// #pragma omp parallel default(shared)
753/// \endcode
754/// In this example directive '#pragma omp parallel' has simple 'default'
755/// clause with kind 'shared'.
756class OMPDefaultClause : public OMPClause {
757  friend class OMPClauseReader;
758
759  /// Location of '('.
760  SourceLocation LParenLoc;
761
762  /// A kind of the 'default' clause.
763  OpenMPDefaultClauseKind Kind = OMPC_DEFAULT_unknown;
764
765  /// Start location of the kind in source code.
766  SourceLocation KindKwLoc;
767
768  /// Set kind of the clauses.
769  ///
770  /// \param K Argument of clause.
771  void setDefaultKind(OpenMPDefaultClauseKind K) { Kind = K; }
772
773  /// Set argument location.
774  ///
775  /// \param KLoc Argument location.
776  void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
777
778public:
779  /// Build 'default' clause with argument \a A ('none' or 'shared').
780  ///
781  /// \param A Argument of the clause ('none' or 'shared').
782  /// \param ALoc Starting location of the argument.
783  /// \param StartLoc Starting location of the clause.
784  /// \param LParenLoc Location of '('.
785  /// \param EndLoc Ending location of the clause.
786  OMPDefaultClause(OpenMPDefaultClauseKind ASourceLocation ALoc,
787                   SourceLocation StartLocSourceLocation LParenLoc,
788                   SourceLocation EndLoc)
789      : OMPClause(OMPC_defaultStartLocEndLoc), LParenLoc(LParenLoc),
790        Kind(A), KindKwLoc(ALoc) {}
791
792  /// Build an empty clause.
793  OMPDefaultClause()
794      : OMPClause(OMPC_defaultSourceLocation(), SourceLocation()) {}
795
796  /// Sets the location of '('.
797  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
798
799  /// Returns the location of '('.
800  SourceLocation getLParenLoc() const { return LParenLoc; }
801
802  /// Returns kind of the clause.
803  OpenMPDefaultClauseKind getDefaultKind() const { return Kind; }
804
805  /// Returns location of clause kind.
806  SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; }
807
808  child_range children() {
809    return child_range(child_iterator(), child_iterator());
810  }
811
812  static bool classof(const OMPClause *T) {
813    return T->getClauseKind() == OMPC_default;
814  }
815};
816
817/// This represents 'proc_bind' clause in the '#pragma omp ...'
818/// directive.
819///
820/// \code
821/// #pragma omp parallel proc_bind(master)
822/// \endcode
823/// In this example directive '#pragma omp parallel' has simple 'proc_bind'
824/// clause with kind 'master'.
825class OMPProcBindClause : public OMPClause {
826  friend class OMPClauseReader;
827
828  /// Location of '('.
829  SourceLocation LParenLoc;
830
831  /// A kind of the 'proc_bind' clause.
832  OpenMPProcBindClauseKind Kind = OMPC_PROC_BIND_unknown;
833
834  /// Start location of the kind in source code.
835  SourceLocation KindKwLoc;
836
837  /// Set kind of the clause.
838  ///
839  /// \param K Kind of clause.
840  void setProcBindKind(OpenMPProcBindClauseKind K) { Kind = K; }
841
842  /// Set clause kind location.
843  ///
844  /// \param KLoc Kind location.
845  void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; }
846
847public:
848  /// Build 'proc_bind' clause with argument \a A ('master', 'close' or
849  ///        'spread').
850  ///
851  /// \param A Argument of the clause ('master', 'close' or 'spread').
852  /// \param ALoc Starting location of the argument.
853  /// \param StartLoc Starting location of the clause.
854  /// \param LParenLoc Location of '('.
855  /// \param EndLoc Ending location of the clause.
856  OMPProcBindClause(OpenMPProcBindClauseKind ASourceLocation ALoc,
857                    SourceLocation StartLocSourceLocation LParenLoc,
858                    SourceLocation EndLoc)
859      : OMPClause(OMPC_proc_bindStartLocEndLoc), LParenLoc(LParenLoc),
860        Kind(A), KindKwLoc(ALoc) {}
861
862  /// Build an empty clause.
863  OMPProcBindClause()
864      : OMPClause(OMPC_proc_bindSourceLocation(), SourceLocation()) {}
865
866  /// Sets the location of '('.
867  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
868
869  /// Returns the location of '('.
870  SourceLocation getLParenLoc() const { return LParenLoc; }
871
872  /// Returns kind of the clause.
873  OpenMPProcBindClauseKind getProcBindKind() const { return Kind; }
874
875  /// Returns location of clause kind.
876  SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }
877
878  child_range children() {
879    return child_range(child_iterator(), child_iterator());
880  }
881
882  static bool classof(const OMPClause *T) {
883    return T->getClauseKind() == OMPC_proc_bind;
884  }
885};
886
887/// This represents 'unified_address' clause in the '#pragma omp requires'
888/// directive.
889///
890/// \code
891/// #pragma omp requires unified_address
892/// \endcode
893/// In this example directive '#pragma omp requires' has 'unified_address'
894/// clause.
895class OMPUnifiedAddressClause final : public OMPClause {
896public:
897  friend class OMPClauseReader;
898  /// Build 'unified_address' clause.
899  ///
900  /// \param StartLoc Starting location of the clause.
901  /// \param EndLoc Ending location of the clause.
902  OMPUnifiedAddressClause(SourceLocation StartLocSourceLocation EndLoc)
903      : OMPClause(OMPC_unified_addressStartLocEndLoc) {}
904
905  /// Build an empty clause.
906  OMPUnifiedAddressClause()
907      : OMPClause(OMPC_unified_addressSourceLocation(), SourceLocation()) {}
908
909  child_range children() {
910    return child_range(child_iterator(), child_iterator());
911  }
912
913  static bool classof(const OMPClause *T) {
914    return T->getClauseKind() == OMPC_unified_address;
915  }
916};
917
918/// This represents 'unified_shared_memory' clause in the '#pragma omp requires'
919/// directive.
920///
921/// \code
922/// #pragma omp requires unified_shared_memory
923/// \endcode
924/// In this example directive '#pragma omp requires' has 'unified_shared_memory'
925/// clause.
926class OMPUnifiedSharedMemoryClause final : public OMPClause {
927public:
928  friend class OMPClauseReader;
929  /// Build 'unified_shared_memory' clause.
930  ///
931  /// \param StartLoc Starting location of the clause.
932  /// \param EndLoc Ending location of the clause.
933  OMPUnifiedSharedMemoryClause(SourceLocation StartLocSourceLocation EndLoc)
934      : OMPClause(OMPC_unified_shared_memoryStartLocEndLoc) {}
935
936  /// Build an empty clause.
937  OMPUnifiedSharedMemoryClause()
938      : OMPClause(OMPC_unified_shared_memorySourceLocation(), SourceLocation()) {}
939
940  child_range children() {
941    return child_range(child_iterator(), child_iterator());
942  }
943
944  static bool classof(const OMPClause *T) {
945    return T->getClauseKind() == OMPC_unified_shared_memory;
946  }
947};
948
949/// This represents 'reverse_offload' clause in the '#pragma omp requires'
950/// directive.
951///
952/// \code
953/// #pragma omp requires reverse_offload
954/// \endcode
955/// In this example directive '#pragma omp requires' has 'reverse_offload'
956/// clause.
957class OMPReverseOffloadClause final : public OMPClause {
958public:
959  friend class OMPClauseReader;
960  /// Build 'reverse_offload' clause.
961  ///
962  /// \param StartLoc Starting location of the clause.
963  /// \param EndLoc Ending location of the clause.
964  OMPReverseOffloadClause(SourceLocation StartLocSourceLocation EndLoc)
965      : OMPClause(OMPC_reverse_offloadStartLocEndLoc) {}
966
967  /// Build an empty clause.
968  OMPReverseOffloadClause()
969      : OMPClause(OMPC_reverse_offloadSourceLocation(), SourceLocation()) {}
970
971  child_range children() {
972    return child_range(child_iterator(), child_iterator());
973  }
974
975  static bool classof(const OMPClause *T) {
976    return T->getClauseKind() == OMPC_reverse_offload;
977  }
978};
979
980/// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
981/// directive.
982///
983/// \code
984/// #pragma omp requires dynamic_allocators
985/// \endcode
986/// In this example directive '#pragma omp requires' has 'dynamic_allocators'
987/// clause.
988class OMPDynamicAllocatorsClause final : public OMPClause {
989public:
990  friend class OMPClauseReader;
991  /// Build 'dynamic_allocators' clause.
992  ///
993  /// \param StartLoc Starting location of the clause.
994  /// \param EndLoc Ending location of the clause.
995  OMPDynamicAllocatorsClause(SourceLocation StartLocSourceLocation EndLoc)
996      : OMPClause(OMPC_dynamic_allocatorsStartLocEndLoc) {}
997
998  /// Build an empty clause.
999  OMPDynamicAllocatorsClause()
1000      : OMPClause(OMPC_dynamic_allocatorsSourceLocation(), SourceLocation()) {
1001  }
1002
1003  child_range children() {
1004    return child_range(child_iterator(), child_iterator());
1005  }
1006
1007  static bool classof(const OMPClause *T) {
1008    return T->getClauseKind() == OMPC_dynamic_allocators;
1009  }
1010};
1011
1012/// This represents 'atomic_default_mem_order' clause in the '#pragma omp
1013/// requires'  directive.
1014///
1015/// \code
1016/// #pragma omp requires atomic_default_mem_order(seq_cst)
1017/// \endcode
1018/// In this example directive '#pragma omp requires' has simple
1019/// atomic_default_mem_order' clause with kind 'seq_cst'.
1020class OMPAtomicDefaultMemOrderClause final : public OMPClause {
1021  friend class OMPClauseReader;
1022
1023  /// Location of '('
1024  SourceLocation LParenLoc;
1025
1026  /// A kind of the 'atomic_default_mem_order' clause.
1027  OpenMPAtomicDefaultMemOrderClauseKind Kind =
1028      OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown;
1029
1030  /// Start location of the kind in source code.
1031  SourceLocation KindKwLoc;
1032
1033  /// Set kind of the clause.
1034  ///
1035  /// \param K Kind of clause.
1036  void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) {
1037    Kind = K;
1038  }
1039
1040  /// Set clause kind location.
1041  ///
1042  /// \param KLoc Kind location.
1043  void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) {
1044    KindKwLoc = KLoc;
1045  }
1046
1047public:
1048  /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst',
1049  /// 'acq_rel' or 'relaxed').
1050  ///
1051  /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed').
1052  /// \param ALoc Starting location of the argument.
1053  /// \param StartLoc Starting location of the clause.
1054  /// \param LParenLoc Location of '('.
1055  /// \param EndLoc Ending location of the clause.
1056  OMPAtomicDefaultMemOrderClause(OpenMPAtomicDefaultMemOrderClauseKind A,
1057                                 SourceLocation ALocSourceLocation StartLoc,
1058                                 SourceLocation LParenLoc,
1059                                 SourceLocation EndLoc)
1060      : OMPClause(OMPC_atomic_default_mem_orderStartLocEndLoc),
1061        LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
1062
1063  /// Build an empty clause.
1064  OMPAtomicDefaultMemOrderClause()
1065      : OMPClause(OMPC_atomic_default_mem_orderSourceLocation(),
1066                  SourceLocation()) {}
1067
1068  /// Sets the location of '('.
1069  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1070
1071  /// Returns the locaiton of '('.
1072  SourceLocation getLParenLoc() const { return LParenLoc; }
1073
1074  /// Returns kind of the clause.
1075  OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const {
1076    return Kind;
1077  }
1078
1079  /// Returns location of clause kind.
1080  SourceLocation getAtomicDefaultMemOrderKindKwLoc() const { return KindKwLoc; }
1081
1082  child_range children() {
1083    return child_range(child_iterator(), child_iterator());
1084  }
1085
1086  static bool classof(const OMPClause *T) {
1087    return T->getClauseKind() == OMPC_atomic_default_mem_order;
1088  }
1089};
1090
1091/// This represents 'schedule' clause in the '#pragma omp ...' directive.
1092///
1093/// \code
1094/// #pragma omp for schedule(static, 3)
1095/// \endcode
1096/// In this example directive '#pragma omp for' has 'schedule' clause with
1097/// arguments 'static' and '3'.
1098class OMPScheduleClause : public OMPClausepublic OMPClauseWithPreInit {
1099  friend class OMPClauseReader;
1100
1101  /// Location of '('.
1102  SourceLocation LParenLoc;
1103
1104  /// A kind of the 'schedule' clause.
1105  OpenMPScheduleClauseKind Kind = OMPC_SCHEDULE_unknown;
1106
1107  /// Modifiers for 'schedule' clause.
1108  enum {FIRSTSECONDNUM_MODIFIERS};
1109  OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
1110
1111  /// Locations of modifiers.
1112  SourceLocation ModifiersLoc[NUM_MODIFIERS];
1113
1114  /// Start location of the schedule ind in source code.
1115  SourceLocation KindLoc;
1116
1117  /// Location of ',' (if any).
1118  SourceLocation CommaLoc;
1119
1120  /// Chunk size.
1121  Expr *ChunkSize = nullptr;
1122
1123  /// Set schedule kind.
1124  ///
1125  /// \param K Schedule kind.
1126  void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
1127
1128  /// Set the first schedule modifier.
1129  ///
1130  /// \param M Schedule modifier.
1131  void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
1132    Modifiers[FIRST] = M;
1133  }
1134
1135  /// Set the second schedule modifier.
1136  ///
1137  /// \param M Schedule modifier.
1138  void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
1139    Modifiers[SECOND] = M;
1140  }
1141
1142  /// Set location of the first schedule modifier.
1143  void setFirstScheduleModifierLoc(SourceLocation Loc) {
1144    ModifiersLoc[FIRST] = Loc;
1145  }
1146
1147  /// Set location of the second schedule modifier.
1148  void setSecondScheduleModifierLoc(SourceLocation Loc) {
1149    ModifiersLoc[SECOND] = Loc;
1150  }
1151
1152  /// Set schedule modifier location.
1153  ///
1154  /// \param M Schedule modifier location.
1155  void setScheduleModifer(OpenMPScheduleClauseModifier M) {
1156    if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
1157      Modifiers[FIRST] = M;
1158    else {
1159      assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
1160      Modifiers[SECOND] = M;
1161    }
1162  }
1163
1164  /// Sets the location of '('.
1165  ///
1166  /// \param Loc Location of '('.
1167  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1168
1169  /// Set schedule kind start location.
1170  ///
1171  /// \param KLoc Schedule kind location.
1172  void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
1173
1174  /// Set location of ','.
1175  ///
1176  /// \param Loc Location of ','.
1177  void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
1178
1179  /// Set chunk size.
1180  ///
1181  /// \param E Chunk size.
1182  void setChunkSize(Expr *E) { ChunkSize = E; }
1183
1184public:
1185  /// Build 'schedule' clause with schedule kind \a Kind and chunk size
1186  /// expression \a ChunkSize.
1187  ///
1188  /// \param StartLoc Starting location of the clause.
1189  /// \param LParenLoc Location of '('.
1190  /// \param KLoc Starting location of the argument.
1191  /// \param CommaLoc Location of ','.
1192  /// \param EndLoc Ending location of the clause.
1193  /// \param Kind Schedule kind.
1194  /// \param ChunkSize Chunk size.
1195  /// \param HelperChunkSize Helper chunk size for combined directives.
1196  /// \param M1 The first modifier applied to 'schedule' clause.
1197  /// \param M1Loc Location of the first modifier
1198  /// \param M2 The second modifier applied to 'schedule' clause.
1199  /// \param M2Loc Location of the second modifier
1200  OMPScheduleClause(SourceLocation StartLocSourceLocation LParenLoc,
1201                    SourceLocation KLocSourceLocation CommaLoc,
1202                    SourceLocation EndLocOpenMPScheduleClauseKind Kind,
1203                    Expr *ChunkSizeStmt *HelperChunkSize,
1204                    OpenMPScheduleClauseModifier M1SourceLocation M1Loc,
1205                    OpenMPScheduleClauseModifier M2SourceLocation M2Loc)
1206      : OMPClause(OMPC_scheduleStartLocEndLoc), OMPClauseWithPreInit(this),
1207        LParenLoc(LParenLoc), Kind(Kind), KindLoc(KLoc), CommaLoc(CommaLoc),
1208        ChunkSize(ChunkSize) {
1209    setPreInitStmt(HelperChunkSize);
1210    Modifiers[FIRST] = M1;
1211    Modifiers[SECOND] = M2;
1212    ModifiersLoc[FIRST] = M1Loc;
1213    ModifiersLoc[SECOND] = M2Loc;
1214  }
1215
1216  /// Build an empty clause.
1217  explicit OMPScheduleClause()
1218      : OMPClause(OMPC_scheduleSourceLocation(), SourceLocation()),
1219        OMPClauseWithPreInit(this) {
1220    Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown;
1221    Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown;
1222  }
1223
1224  /// Get kind of the clause.
1225  OpenMPScheduleClauseKind getScheduleKind() const { return Kind; }
1226
1227  /// Get the first modifier of the clause.
1228  OpenMPScheduleClauseModifier getFirstScheduleModifier() const {
1229    return Modifiers[FIRST];
1230  }
1231
1232  /// Get the second modifier of the clause.
1233  OpenMPScheduleClauseModifier getSecondScheduleModifier() const {
1234    return Modifiers[SECOND];
1235  }
1236
1237  /// Get location of '('.
1238  SourceLocation getLParenLoc() { return LParenLoc; }
1239
1240  /// Get kind location.
1241  SourceLocation getScheduleKindLoc() { return KindLoc; }
1242
1243  /// Get the first modifier location.
1244  SourceLocation getFirstScheduleModifierLoc() const {
1245    return ModifiersLoc[FIRST];
1246  }
1247
1248  /// Get the second modifier location.
1249  SourceLocation getSecondScheduleModifierLoc() const {
1250    return ModifiersLoc[SECOND];
1251  }
1252
1253  /// Get location of ','.
1254  SourceLocation getCommaLoc() { return CommaLoc; }
1255
1256  /// Get chunk size.
1257  Expr *getChunkSize() { return ChunkSize; }
1258
1259  /// Get chunk size.
1260  const Expr *getChunkSize() const { return ChunkSize; }
1261
1262  child_range children() {
1263    return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
1264                       reinterpret_cast<Stmt **>(&ChunkSize) + 1);
1265  }
1266
1267  static bool classof(const OMPClause *T) {
1268    return T->getClauseKind() == OMPC_schedule;
1269  }
1270};
1271
1272/// This represents 'ordered' clause in the '#pragma omp ...' directive.
1273///
1274/// \code
1275/// #pragma omp for ordered (2)
1276/// \endcode
1277/// In this example directive '#pragma omp for' has 'ordered' clause with
1278/// parameter 2.
1279class OMPOrderedClause final
1280    : public OMPClause,
1281      private llvm::TrailingObjects<OMPOrderedClause, Expr *> {
1282  friend class OMPClauseReader;
1283  friend TrailingObjects;
1284
1285  /// Location of '('.
1286  SourceLocation LParenLoc;
1287
1288  /// Number of for-loops.
1289  Stmt *NumForLoops = nullptr;
1290
1291  /// Real number of loops.
1292  unsigned NumberOfLoops = 0;
1293
1294  /// Build 'ordered' clause.
1295  ///
1296  /// \param Num Expression, possibly associated with this clause.
1297  /// \param NumLoops Number of loops, associated with this clause.
1298  /// \param StartLoc Starting location of the clause.
1299  /// \param LParenLoc Location of '('.
1300  /// \param EndLoc Ending location of the clause.
1301  OMPOrderedClause(Expr *Numunsigned NumLoopsSourceLocation StartLoc,
1302                   SourceLocation LParenLocSourceLocation EndLoc)
1303      : OMPClause(OMPC_orderedStartLocEndLoc), LParenLoc(LParenLoc),
1304        NumForLoops(Num), NumberOfLoops(NumLoops) {}
1305
1306  /// Build an empty clause.
1307  explicit OMPOrderedClause(unsigned NumLoops)
1308      : OMPClause(OMPC_orderedSourceLocation(), SourceLocation()),
1309        NumberOfLoops(NumLoops) {}
1310
1311  /// Set the number of associated for-loops.
1312  void setNumForLoops(Expr *Num) { NumForLoops = Num; }
1313
1314public:
1315  /// Build 'ordered' clause.
1316  ///
1317  /// \param Num Expression, possibly associated with this clause.
1318  /// \param NumLoops Number of loops, associated with this clause.
1319  /// \param StartLoc Starting location of the clause.
1320  /// \param LParenLoc Location of '('.
1321  /// \param EndLoc Ending location of the clause.
1322  static OMPOrderedClause *Create(const ASTContext &CExpr *Num,
1323                                  unsigned NumLoopsSourceLocation StartLoc,
1324                                  SourceLocation LParenLoc,
1325                                  SourceLocation EndLoc);
1326
1327  /// Build an empty clause.
1328  static OMPOrderedClauseCreateEmpty(const ASTContext &Cunsigned NumLoops);
1329
1330  /// Sets the location of '('.
1331  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1332
1333  /// Returns the location of '('.
1334  SourceLocation getLParenLoc() const { return LParenLoc; }
1335
1336  /// Return the number of associated for-loops.
1337  Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); }
1338
1339  /// Set number of iterations for the specified loop.
1340  void setLoopNumIterations(unsigned NumLoopExpr *NumIterations);
1341  /// Get number of iterations for all the loops.
1342  ArrayRef<Expr *> getLoopNumIterations() const;
1343
1344  /// Set loop counter for the specified loop.
1345  void setLoopCounter(unsigned NumLoopExpr *Counter);
1346  /// Get loops counter for the specified loop.
1347  Expr *getLoopCounter(unsigned NumLoop);
1348  const Expr *getLoopCounter(unsigned NumLoopconst;
1349
1350  child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); }
1351
1352  static bool classof(const OMPClause *T) {
1353    return T->getClauseKind() == OMPC_ordered;
1354  }
1355};
1356
1357/// This represents 'nowait' clause in the '#pragma omp ...' directive.
1358///
1359/// \code
1360/// #pragma omp for nowait
1361/// \endcode
1362/// In this example directive '#pragma omp for' has 'nowait' clause.
1363class OMPNowaitClause : public OMPClause {
1364public:
1365  /// Build 'nowait' clause.
1366  ///
1367  /// \param StartLoc Starting location of the clause.
1368  /// \param EndLoc Ending location of the clause.
1369  OMPNowaitClause(SourceLocation StartLocSourceLocation EndLoc)
1370      : OMPClause(OMPC_nowaitStartLocEndLoc) {}
1371
1372  /// Build an empty clause.
1373  OMPNowaitClause()
1374      : OMPClause(OMPC_nowaitSourceLocation(), SourceLocation()) {}
1375
1376  child_range children() {
1377    return child_range(child_iterator(), child_iterator());
1378  }
1379
1380  static bool classof(const OMPClause *T) {
1381    return T->getClauseKind() == OMPC_nowait;
1382  }
1383};
1384
1385/// This represents 'untied' clause in the '#pragma omp ...' directive.
1386///
1387/// \code
1388/// #pragma omp task untied
1389/// \endcode
1390/// In this example directive '#pragma omp task' has 'untied' clause.
1391class OMPUntiedClause : public OMPClause {
1392public:
1393  /// Build 'untied' clause.
1394  ///
1395  /// \param StartLoc Starting location of the clause.
1396  /// \param EndLoc Ending location of the clause.
1397  OMPUntiedClause(SourceLocation StartLocSourceLocation EndLoc)
1398      : OMPClause(OMPC_untiedStartLocEndLoc) {}
1399
1400  /// Build an empty clause.
1401  OMPUntiedClause()
1402      : OMPClause(OMPC_untiedSourceLocation(), SourceLocation()) {}
1403
1404  child_range children() {
1405    return child_range(child_iterator(), child_iterator());
1406  }
1407
1408  static bool classof(const OMPClause *T) {
1409    return T->getClauseKind() == OMPC_untied;
1410  }
1411};
1412
1413/// This represents 'mergeable' clause in the '#pragma omp ...'
1414/// directive.
1415///
1416/// \code
1417/// #pragma omp task mergeable
1418/// \endcode
1419/// In this example directive '#pragma omp task' has 'mergeable' clause.
1420class OMPMergeableClause : public OMPClause {
1421public:
1422  /// Build 'mergeable' clause.
1423  ///
1424  /// \param StartLoc Starting location of the clause.
1425  /// \param EndLoc Ending location of the clause.
1426  OMPMergeableClause(SourceLocation StartLocSourceLocation EndLoc)
1427      : OMPClause(OMPC_mergeableStartLocEndLoc) {}
1428
1429  /// Build an empty clause.
1430  OMPMergeableClause()
1431      : OMPClause(OMPC_mergeableSourceLocation(), SourceLocation()) {}
1432
1433  child_range children() {
1434    return child_range(child_iterator(), child_iterator());
1435  }
1436
1437  static bool classof(const OMPClause *T) {
1438    return T->getClauseKind() == OMPC_mergeable;
1439  }
1440};
1441
1442/// This represents 'read' clause in the '#pragma omp atomic' directive.
1443///
1444/// \code
1445/// #pragma omp atomic read
1446/// \endcode
1447/// In this example directive '#pragma omp atomic' has 'read' clause.
1448class OMPReadClause : public OMPClause {
1449public:
1450  /// Build 'read' clause.
1451  ///
1452  /// \param StartLoc Starting location of the clause.
1453  /// \param EndLoc Ending location of the clause.
1454  OMPReadClause(SourceLocation StartLocSourceLocation EndLoc)
1455      : OMPClause(OMPC_readStartLocEndLoc) {}
1456
1457  /// Build an empty clause.
1458  OMPReadClause() : OMPClause(OMPC_readSourceLocation(), SourceLocation()) {}
1459
1460  child_range children() {
1461    return child_range(child_iterator(), child_iterator());
1462  }
1463
1464  static bool classof(const OMPClause *T) {
1465    return T->getClauseKind() == OMPC_read;
1466  }
1467};
1468
1469/// This represents 'write' clause in the '#pragma omp atomic' directive.
1470///
1471/// \code
1472/// #pragma omp atomic write
1473/// \endcode
1474/// In this example directive '#pragma omp atomic' has 'write' clause.
1475class OMPWriteClause : public OMPClause {
1476public:
1477  /// Build 'write' clause.
1478  ///
1479  /// \param StartLoc Starting location of the clause.
1480  /// \param EndLoc Ending location of the clause.
1481  OMPWriteClause(SourceLocation StartLocSourceLocation EndLoc)
1482      : OMPClause(OMPC_writeStartLocEndLoc) {}
1483
1484  /// Build an empty clause.
1485  OMPWriteClause()
1486      : OMPClause(OMPC_writeSourceLocation(), SourceLocation()) {}
1487
1488  child_range children() {
1489    return child_range(child_iterator(), child_iterator());
1490  }
1491
1492  static bool classof(const OMPClause *T) {
1493    return T->getClauseKind() == OMPC_write;
1494  }
1495};
1496
1497/// This represents 'update' clause in the '#pragma omp atomic'
1498/// directive.
1499///
1500/// \code
1501/// #pragma omp atomic update
1502/// \endcode
1503/// In this example directive '#pragma omp atomic' has 'update' clause.
1504class OMPUpdateClause : public OMPClause {
1505public:
1506  /// Build 'update' clause.
1507  ///
1508  /// \param StartLoc Starting location of the clause.
1509  /// \param EndLoc Ending location of the clause.
1510  OMPUpdateClause(SourceLocation StartLocSourceLocation EndLoc)
1511      : OMPClause(OMPC_updateStartLocEndLoc) {}
1512
1513  /// Build an empty clause.
1514  OMPUpdateClause()
1515      : OMPClause(OMPC_updateSourceLocation(), SourceLocation()) {}
1516
1517  child_range children() {
1518    return child_range(child_iterator(), child_iterator());
1519  }
1520
1521  static bool classof(const OMPClause *T) {
1522    return T->getClauseKind() == OMPC_update;
1523  }
1524};
1525
1526/// This represents 'capture' clause in the '#pragma omp atomic'
1527/// directive.
1528///
1529/// \code
1530/// #pragma omp atomic capture
1531/// \endcode
1532/// In this example directive '#pragma omp atomic' has 'capture' clause.
1533class OMPCaptureClause : public OMPClause {
1534public:
1535  /// Build 'capture' clause.
1536  ///
1537  /// \param StartLoc Starting location of the clause.
1538  /// \param EndLoc Ending location of the clause.
1539  OMPCaptureClause(SourceLocation StartLocSourceLocation EndLoc)
1540      : OMPClause(OMPC_captureStartLocEndLoc) {}
1541
1542  /// Build an empty clause.
1543  OMPCaptureClause()
1544      : OMPClause(OMPC_captureSourceLocation(), SourceLocation()) {}
1545
1546  child_range children() {
1547    return child_range(child_iterator(), child_iterator());
1548  }
1549
1550  static bool classof(const OMPClause *T) {
1551    return T->getClauseKind() == OMPC_capture;
1552  }
1553};
1554
1555/// This represents 'seq_cst' clause in the '#pragma omp atomic'
1556/// directive.
1557///
1558/// \code
1559/// #pragma omp atomic seq_cst
1560/// \endcode
1561/// In this example directive '#pragma omp atomic' has 'seq_cst' clause.
1562class OMPSeqCstClause : public OMPClause {
1563public:
1564  /// Build 'seq_cst' clause.
1565  ///
1566  /// \param StartLoc Starting location of the clause.
1567  /// \param EndLoc Ending location of the clause.
1568  OMPSeqCstClause(SourceLocation StartLocSourceLocation EndLoc)
1569      : OMPClause(OMPC_seq_cstStartLocEndLoc) {}
1570
1571  /// Build an empty clause.
1572  OMPSeqCstClause()
1573      : OMPClause(OMPC_seq_cstSourceLocation(), SourceLocation()) {}
1574
1575  child_range children() {
1576    return child_range(child_iterator(), child_iterator());
1577  }
1578
1579  static bool classof(const OMPClause *T) {
1580    return T->getClauseKind() == OMPC_seq_cst;
1581  }
1582};
1583
1584/// This represents clause 'private' in the '#pragma omp ...' directives.
1585///
1586/// \code
1587/// #pragma omp parallel private(a,b)
1588/// \endcode
1589/// In this example directive '#pragma omp parallel' has clause 'private'
1590/// with the variables 'a' and 'b'.
1591class OMPPrivateClause final
1592    : public OMPVarListClause<OMPPrivateClause>,
1593      private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
1594  friend class OMPClauseReader;
1595  friend OMPVarListClause;
1596  friend TrailingObjects;
1597
1598  /// Build clause with number of variables \a N.
1599  ///
1600  /// \param StartLoc Starting location of the clause.
1601  /// \param LParenLoc Location of '('.
1602  /// \param EndLoc Ending location of the clause.
1603  /// \param N Number of the variables in the clause.
1604  OMPPrivateClause(SourceLocation StartLocSourceLocation LParenLoc,
1605                   SourceLocation EndLocunsigned N)
1606      : OMPVarListClause<OMPPrivateClause>(OMPC_private, StartLoc, LParenLoc,
1607                                           EndLoc, N) {}
1608
1609  /// Build an empty clause.
1610  ///
1611  /// \param N Number of variables.
1612  explicit OMPPrivateClause(unsigned N)
1613      : OMPVarListClause<OMPPrivateClause>(OMPC_private, SourceLocation(),
1614                                           SourceLocation(), SourceLocation(),
1615                                           N) {}
1616
1617  /// Sets the list of references to private copies with initializers for
1618  /// new private variables.
1619  /// \param VL List of references.
1620  void setPrivateCopies(ArrayRef<Expr *> VL);
1621
1622  /// Gets the list of references to private copies with initializers for
1623  /// new private variables.
1624  MutableArrayRef<Expr *> getPrivateCopies() {
1625    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1626  }
1627  ArrayRef<const Expr *> getPrivateCopies() const {
1628    return llvm::makeArrayRef(varlist_end(), varlist_size());
1629  }
1630
1631public:
1632  /// Creates clause with a list of variables \a VL.
1633  ///
1634  /// \param C AST context.
1635  /// \param StartLoc Starting location of the clause.
1636  /// \param LParenLoc Location of '('.
1637  /// \param EndLoc Ending location of the clause.
1638  /// \param VL List of references to the variables.
1639  /// \param PrivateVL List of references to private copies with initializers.
1640  static OMPPrivateClause *Create(const ASTContext &CSourceLocation StartLoc,
1641                                  SourceLocation LParenLoc,
1642                                  SourceLocation EndLocArrayRef<Expr *> VL,
1643                                  ArrayRef<Expr *> PrivateVL);
1644
1645  /// Creates an empty clause with the place for \a N variables.
1646  ///
1647  /// \param C AST context.
1648  /// \param N The number of variables.
1649  static OMPPrivateClause *CreateEmpty(const ASTContext &Cunsigned N);
1650
1651  using private_copies_iterator = MutableArrayRef<Expr *>::iterator;
1652  using private_copies_const_iterator = ArrayRef<const Expr *>::iterator;
1653  using private_copies_range = llvm::iterator_range<private_copies_iterator>;
1654  using private_copies_const_range =
1655      llvm::iterator_range<private_copies_const_iterator>;
1656
1657  private_copies_range private_copies() {
1658    return private_copies_range(getPrivateCopies().begin(),
1659                                getPrivateCopies().end());
1660  }
1661
1662  private_copies_const_range private_copies() const {
1663    return private_copies_const_range(getPrivateCopies().begin(),
1664                                      getPrivateCopies().end());
1665  }
1666
1667  child_range children() {
1668    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1669                       reinterpret_cast<Stmt **>(varlist_end()));
1670  }
1671
1672  static bool classof(const OMPClause *T) {
1673    return T->getClauseKind() == OMPC_private;
1674  }
1675};
1676
1677/// This represents clause 'firstprivate' in the '#pragma omp ...'
1678/// directives.
1679///
1680/// \code
1681/// #pragma omp parallel firstprivate(a,b)
1682/// \endcode
1683/// In this example directive '#pragma omp parallel' has clause 'firstprivate'
1684/// with the variables 'a' and 'b'.
1685class OMPFirstprivateClause final
1686    : public OMPVarListClause<OMPFirstprivateClause>,
1687      public OMPClauseWithPreInit,
1688      private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
1689  friend class OMPClauseReader;
1690  friend OMPVarListClause;
1691  friend TrailingObjects;
1692
1693  /// Build clause with number of variables \a N.
1694  ///
1695  /// \param StartLoc Starting location of the clause.
1696  /// \param LParenLoc Location of '('.
1697  /// \param EndLoc Ending location of the clause.
1698  /// \param N Number of the variables in the clause.
1699  OMPFirstprivateClause(SourceLocation StartLocSourceLocation LParenLoc,
1700                        SourceLocation EndLocunsigned N)
1701      : OMPVarListClause<OMPFirstprivateClause>(OMPC_firstprivate, StartLoc,
1702                                                LParenLoc, EndLoc, N),
1703        OMPClauseWithPreInit(this) {}
1704
1705  /// Build an empty clause.
1706  ///
1707  /// \param N Number of variables.
1708  explicit OMPFirstprivateClause(unsigned N)
1709      : OMPVarListClause<OMPFirstprivateClause>(
1710            OMPC_firstprivate, SourceLocation(), SourceLocation(),
1711            SourceLocation(), N),
1712        OMPClauseWithPreInit(this) {}
1713
1714  /// Sets the list of references to private copies with initializers for
1715  /// new private variables.
1716  /// \param VL List of references.
1717  void setPrivateCopies(ArrayRef<Expr *> VL);
1718
1719  /// Gets the list of references to private copies with initializers for
1720  /// new private variables.
1721  MutableArrayRef<Expr *> getPrivateCopies() {
1722    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1723  }
1724  ArrayRef<const Expr *> getPrivateCopies() const {
1725    return llvm::makeArrayRef(varlist_end(), varlist_size());
1726  }
1727
1728  /// Sets the list of references to initializer variables for new
1729  /// private variables.
1730  /// \param VL List of references.
1731  void setInits(ArrayRef<Expr *> VL);
1732
1733  /// Gets the list of references to initializer variables for new
1734  /// private variables.
1735  MutableArrayRef<Expr *> getInits() {
1736    return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1737  }
1738  ArrayRef<const Expr *> getInits() const {
1739    return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1740  }
1741
1742public:
1743  /// Creates clause with a list of variables \a VL.
1744  ///
1745  /// \param C AST context.
1746  /// \param StartLoc Starting location of the clause.
1747  /// \param LParenLoc Location of '('.
1748  /// \param EndLoc Ending location of the clause.
1749  /// \param VL List of references to the original variables.
1750  /// \param PrivateVL List of references to private copies with initializers.
1751  /// \param InitVL List of references to auto generated variables used for
1752  /// initialization of a single array element. Used if firstprivate variable is
1753  /// of array type.
1754  /// \param PreInit Statement that must be executed before entering the OpenMP
1755  /// region with this clause.
1756  static OMPFirstprivateClause *
1757  Create(const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
1758         SourceLocation EndLocArrayRef<Expr *> VLArrayRef<Expr *> PrivateVL,
1759         ArrayRef<Expr *> InitVLStmt *PreInit);
1760
1761  /// Creates an empty clause with the place for \a N variables.
1762  ///
1763  /// \param C AST context.
1764  /// \param N The number of variables.
1765  static OMPFirstprivateClause *CreateEmpty(const ASTContext &Cunsigned N);
1766
1767  using private_copies_iterator = MutableArrayRef<Expr *>::iterator;
1768  using private_copies_const_iterator = ArrayRef<const Expr *>::iterator;
1769  using private_copies_range = llvm::iterator_range<private_copies_iterator>;
1770  using private_copies_const_range =
1771      llvm::iterator_range<private_copies_const_iterator>;
1772
1773  private_copies_range private_copies() {
1774    return private_copies_range(getPrivateCopies().begin(),
1775                                getPrivateCopies().end());
1776  }
1777  private_copies_const_range private_copies() const {
1778    return private_copies_const_range(getPrivateCopies().begin(),
1779                                      getPrivateCopies().end());
1780  }
1781
1782  using inits_iterator = MutableArrayRef<Expr *>::iterator;
1783  using inits_const_iterator = ArrayRef<const Expr *>::iterator;
1784  using inits_range = llvm::iterator_range<inits_iterator>;
1785  using inits_const_range = llvm::iterator_range<inits_const_iterator>;
1786
1787  inits_range inits() {
1788    return inits_range(getInits().begin(), getInits().end());
1789  }
1790  inits_const_range inits() const {
1791    return inits_const_range(getInits().begin(), getInits().end());
1792  }
1793
1794  child_range children() {
1795    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1796                       reinterpret_cast<Stmt **>(varlist_end()));
1797  }
1798
1799  static bool classof(const OMPClause *T) {
1800    return T->getClauseKind() == OMPC_firstprivate;
1801  }
1802};
1803
1804/// This represents clause 'lastprivate' in the '#pragma omp ...'
1805/// directives.
1806///
1807/// \code
1808/// #pragma omp simd lastprivate(a,b)
1809/// \endcode
1810/// In this example directive '#pragma omp simd' has clause 'lastprivate'
1811/// with the variables 'a' and 'b'.
1812class OMPLastprivateClause final
1813    : public OMPVarListClause<OMPLastprivateClause>,
1814      public OMPClauseWithPostUpdate,
1815      private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
1816  // There are 4 additional tail-allocated arrays at the end of the class:
1817  // 1. Contains list of pseudo variables with the default initialization for
1818  // each non-firstprivate variables. Used in codegen for initialization of
1819  // lastprivate copies.
1820  // 2. List of helper expressions for proper generation of assignment operation
1821  // required for lastprivate clause. This list represents private variables
1822  // (for arrays, single array element).
1823  // 3. List of helper expressions for proper generation of assignment operation
1824  // required for lastprivate clause. This list represents original variables
1825  // (for arrays, single array element).
1826  // 4. List of helper expressions that represents assignment operation:
1827  // \code
1828  // DstExprs = SrcExprs;
1829  // \endcode
1830  // Required for proper codegen of final assignment performed by the
1831  // lastprivate clause.
1832  friend class OMPClauseReader;
1833  friend OMPVarListClause;
1834  friend TrailingObjects;
1835
1836  /// Build clause with number of variables \a N.
1837  ///
1838  /// \param StartLoc Starting location of the clause.
1839  /// \param LParenLoc Location of '('.
1840  /// \param EndLoc Ending location of the clause.
1841  /// \param N Number of the variables in the clause.
1842  OMPLastprivateClause(SourceLocation StartLocSourceLocation LParenLoc,
1843                       SourceLocation EndLocunsigned N)
1844      : OMPVarListClause<OMPLastprivateClause>(OMPC_lastprivate, StartLoc,
1845                                               LParenLoc, EndLoc, N),
1846        OMPClauseWithPostUpdate(this) {}
1847
1848  /// Build an empty clause.
1849  ///
1850  /// \param N Number of variables.
1851  explicit OMPLastprivateClause(unsigned N)
1852      : OMPVarListClause<OMPLastprivateClause>(
1853            OMPC_lastprivate, SourceLocation(), SourceLocation(),
1854            SourceLocation(), N),
1855        OMPClauseWithPostUpdate(this) {}
1856
1857  /// Get the list of helper expressions for initialization of private
1858  /// copies for lastprivate variables.
1859  MutableArrayRef<Expr *> getPrivateCopies() {
1860    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
1861  }
1862  ArrayRef<const Expr *> getPrivateCopies() const {
1863    return llvm::makeArrayRef(varlist_end(), varlist_size());
1864  }
1865
1866  /// Set list of helper expressions, required for proper codegen of the
1867  /// clause. These expressions represent private variables (for arrays, single
1868  /// array element) in the final assignment statement performed by the
1869  /// lastprivate clause.
1870  void setSourceExprs(ArrayRef<Expr *> SrcExprs);
1871
1872  /// Get the list of helper source expressions.
1873  MutableArrayRef<Expr *> getSourceExprs() {
1874    return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
1875  }
1876  ArrayRef<const Expr *> getSourceExprs() const {
1877    return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
1878  }
1879
1880  /// Set list of helper expressions, required for proper codegen of the
1881  /// clause. These expressions represent original variables (for arrays, single
1882  /// array element) in the final assignment statement performed by the
1883  /// lastprivate clause.
1884  void setDestinationExprs(ArrayRef<Expr *> DstExprs);
1885
1886  /// Get the list of helper destination expressions.
1887  MutableArrayRef<Expr *> getDestinationExprs() {
1888    return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
1889  }
1890  ArrayRef<const Expr *> getDestinationExprs() const {
1891    return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
1892  }
1893
1894  /// Set list of helper assignment expressions, required for proper
1895  /// codegen of the clause. These expressions are assignment expressions that
1896  /// assign private copy of the variable to original variable.
1897  void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
1898
1899  /// Get the list of helper assignment expressions.
1900  MutableArrayRef<Expr *> getAssignmentOps() {
1901    return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
1902  }
1903  ArrayRef<const Expr *> getAssignmentOps() const {
1904    return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
1905  }
1906
1907public:
1908  /// Creates clause with a list of variables \a VL.
1909  ///
1910  /// \param C AST context.
1911  /// \param StartLoc Starting location of the clause.
1912  /// \param LParenLoc Location of '('.
1913  /// \param EndLoc Ending location of the clause.
1914  /// \param VL List of references to the variables.
1915  /// \param SrcExprs List of helper expressions for proper generation of
1916  /// assignment operation required for lastprivate clause. This list represents
1917  /// private variables (for arrays, single array element).
1918  /// \param DstExprs List of helper expressions for proper generation of
1919  /// assignment operation required for lastprivate clause. This list represents
1920  /// original variables (for arrays, single array element).
1921  /// \param AssignmentOps List of helper expressions that represents assignment
1922  /// operation:
1923  /// \code
1924  /// DstExprs = SrcExprs;
1925  /// \endcode
1926  /// Required for proper codegen of final assignment performed by the
1927  /// lastprivate clause.
1928  /// \param PreInit Statement that must be executed before entering the OpenMP
1929  /// region with this clause.
1930  /// \param PostUpdate Expression that must be executed after exit from the
1931  /// OpenMP region with this clause.
1932  static OMPLastprivateClause *
1933  Create(const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
1934         SourceLocation EndLocArrayRef<Expr *> VLArrayRef<Expr *> SrcExprs,
1935         ArrayRef<Expr *> DstExprsArrayRef<Expr *> AssignmentOps,
1936         Stmt *PreInitExpr *PostUpdate);
1937
1938  /// Creates an empty clause with the place for \a N variables.
1939  ///
1940  /// \param C AST context.
1941  /// \param N The number of variables.
1942  static OMPLastprivateClause *CreateEmpty(const ASTContext &Cunsigned N);
1943
1944  using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
1945  using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
1946  using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
1947  using helper_expr_const_range =
1948      llvm::iterator_range<helper_expr_const_iterator>;
1949
1950  /// Set list of helper expressions, required for generation of private
1951  /// copies of original lastprivate variables.
1952  void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
1953
1954  helper_expr_const_range private_copies() const {
1955    return helper_expr_const_range(getPrivateCopies().begin(),
1956                                   getPrivateCopies().end());
1957  }
1958
1959  helper_expr_range private_copies() {
1960    return helper_expr_range(getPrivateCopies().begin(),
1961                             getPrivateCopies().end());
1962  }
1963
1964  helper_expr_const_range source_exprs() const {
1965    return helper_expr_const_range(getSourceExprs().begin(),
1966                                   getSourceExprs().end());
1967  }
1968
1969  helper_expr_range source_exprs() {
1970    return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
1971  }
1972
1973  helper_expr_const_range destination_exprs() const {
1974    return helper_expr_const_range(getDestinationExprs().begin(),
1975                                   getDestinationExprs().end());
1976  }
1977
1978  helper_expr_range destination_exprs() {
1979    return helper_expr_range(getDestinationExprs().begin(),
1980                             getDestinationExprs().end());
1981  }
1982
1983  helper_expr_const_range assignment_ops() const {
1984    return helper_expr_const_range(getAssignmentOps().begin(),
1985                                   getAssignmentOps().end());
1986  }
1987
1988  helper_expr_range assignment_ops() {
1989    return helper_expr_range(getAssignmentOps().begin(),
1990                             getAssignmentOps().end());
1991  }
1992
1993  child_range children() {
1994    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
1995                       reinterpret_cast<Stmt **>(varlist_end()));
1996  }
1997
1998  static bool classof(const OMPClause *T) {
1999    return T->getClauseKind() == OMPC_lastprivate;
2000  }
2001};
2002
2003/// This represents clause 'shared' in the '#pragma omp ...' directives.
2004///
2005/// \code
2006/// #pragma omp parallel shared(a,b)
2007/// \endcode
2008/// In this example directive '#pragma omp parallel' has clause 'shared'
2009/// with the variables 'a' and 'b'.
2010class OMPSharedClause final
2011    : public OMPVarListClause<OMPSharedClause>,
2012      private llvm::TrailingObjects<OMPSharedClause, Expr *> {
2013  friend OMPVarListClause;
2014  friend TrailingObjects;
2015
2016  /// Build clause with number of variables \a N.
2017  ///
2018  /// \param StartLoc Starting location of the clause.
2019  /// \param LParenLoc Location of '('.
2020  /// \param EndLoc Ending location of the clause.
2021  /// \param N Number of the variables in the clause.
2022  OMPSharedClause(SourceLocation StartLocSourceLocation LParenLoc,
2023                  SourceLocation EndLocunsigned N)
2024      : OMPVarListClause<OMPSharedClause>(OMPC_shared, StartLoc, LParenLoc,
2025                                          EndLoc, N) {}
2026
2027  /// Build an empty clause.
2028  ///
2029  /// \param N Number of variables.
2030  explicit OMPSharedClause(unsigned N)
2031      : OMPVarListClause<OMPSharedClause>(OMPC_shared, SourceLocation(),
2032                                          SourceLocation(), SourceLocation(),
2033                                          N) {}
2034
2035public:
2036  /// Creates clause with a list of variables \a VL.
2037  ///
2038  /// \param C AST context.
2039  /// \param StartLoc Starting location of the clause.
2040  /// \param LParenLoc Location of '('.
2041  /// \param EndLoc Ending location of the clause.
2042  /// \param VL List of references to the variables.
2043  static OMPSharedClause *Create(const ASTContext &CSourceLocation StartLoc,
2044                                 SourceLocation LParenLoc,
2045                                 SourceLocation EndLocArrayRef<Expr *> VL);
2046
2047  /// Creates an empty clause with \a N variables.
2048  ///
2049  /// \param C AST context.
2050  /// \param N The number of variables.
2051  static OMPSharedClause *CreateEmpty(const ASTContext &Cunsigned N);
2052
2053  child_range children() {
2054    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2055                       reinterpret_cast<Stmt **>(varlist_end()));
2056  }
2057
2058  static bool classof(const OMPClause *T) {
2059    return T->getClauseKind() == OMPC_shared;
2060  }
2061};
2062
2063/// This represents clause 'reduction' in the '#pragma omp ...'
2064/// directives.
2065///
2066/// \code
2067/// #pragma omp parallel reduction(+:a,b)
2068/// \endcode
2069/// In this example directive '#pragma omp parallel' has clause 'reduction'
2070/// with operator '+' and the variables 'a' and 'b'.
2071class OMPReductionClause final
2072    : public OMPVarListClause<OMPReductionClause>,
2073      public OMPClauseWithPostUpdate,
2074      private llvm::TrailingObjects<OMPReductionClause, Expr *> {
2075  friend class OMPClauseReader;
2076  friend OMPVarListClause;
2077  friend TrailingObjects;
2078
2079  /// Location of ':'.
2080  SourceLocation ColonLoc;
2081
2082  /// Nested name specifier for C++.
2083  NestedNameSpecifierLoc QualifierLoc;
2084
2085  /// Name of custom operator.
2086  DeclarationNameInfo NameInfo;
2087
2088  /// Build clause with number of variables \a N.
2089  ///
2090  /// \param StartLoc Starting location of the clause.
2091  /// \param LParenLoc Location of '('.
2092  /// \param EndLoc Ending location of the clause.
2093  /// \param ColonLoc Location of ':'.
2094  /// \param N Number of the variables in the clause.
2095  /// \param QualifierLoc The nested-name qualifier with location information
2096  /// \param NameInfo The full name info for reduction identifier.
2097  OMPReductionClause(SourceLocation StartLocSourceLocation LParenLoc,
2098                     SourceLocation ColonLocSourceLocation EndLocunsigned N,
2099                     NestedNameSpecifierLoc QualifierLoc,
2100                     const DeclarationNameInfo &NameInfo)
2101      : OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
2102                                             LParenLoc, EndLoc, N),
2103        OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
2104        QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
2105
2106  /// Build an empty clause.
2107  ///
2108  /// \param N Number of variables.
2109  explicit OMPReductionClause(unsigned N)
2110      : OMPVarListClause<OMPReductionClause>(OMPC_reduction, SourceLocation(),
2111                                             SourceLocation(), SourceLocation(),
2112                                             N),
2113        OMPClauseWithPostUpdate(this) {}
2114
2115  /// Sets location of ':' symbol in clause.
2116  void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
2117
2118  /// Sets the name info for specified reduction identifier.
2119  void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
2120
2121  /// Sets the nested name specifier.
2122  void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
2123
2124  /// Set list of helper expressions, required for proper codegen of the
2125  /// clause. These expressions represent private copy of the reduction
2126  /// variable.
2127  void setPrivates(ArrayRef<Expr *> Privates);
2128
2129  /// Get the list of helper privates.
2130  MutableArrayRef<Expr *> getPrivates() {
2131    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2132  }
2133  ArrayRef<const Expr *> getPrivates() const {
2134    return llvm::makeArrayRef(varlist_end(), varlist_size());
2135  }
2136
2137  /// Set list of helper expressions, required for proper codegen of the
2138  /// clause. These expressions represent LHS expression in the final
2139  /// reduction expression performed by the reduction clause.
2140  void setLHSExprs(ArrayRef<Expr *> LHSExprs);
2141
2142  /// Get the list of helper LHS expressions.
2143  MutableArrayRef<Expr *> getLHSExprs() {
2144    return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
2145  }
2146  ArrayRef<const Expr *> getLHSExprs() const {
2147    return llvm::makeArrayRef(getPrivates().end(), varlist_size());
2148  }
2149
2150  /// Set list of helper expressions, required for proper codegen of the
2151  /// clause. These expressions represent RHS expression in the final
2152  /// reduction expression performed by the reduction clause.
2153  /// Also, variables in these expressions are used for proper initialization of
2154  /// reduction copies.
2155  void setRHSExprs(ArrayRef<Expr *> RHSExprs);
2156
2157  /// Get the list of helper destination expressions.
2158  MutableArrayRef<Expr *> getRHSExprs() {
2159    return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
2160  }
2161  ArrayRef<const Expr *> getRHSExprs() const {
2162    return llvm::makeArrayRef(getLHSExprs().end(), varlist_size());
2163  }
2164
2165  /// Set list of helper reduction expressions, required for proper
2166  /// codegen of the clause. These expressions are binary expressions or
2167  /// operator/custom reduction call that calculates new value from source
2168  /// helper expressions to destination helper expressions.
2169  void setReductionOps(ArrayRef<Expr *> ReductionOps);
2170
2171  /// Get the list of helper reduction expressions.
2172  MutableArrayRef<Expr *> getReductionOps() {
2173    return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
2174  }
2175  ArrayRef<const Expr *> getReductionOps() const {
2176    return llvm::makeArrayRef(getRHSExprs().end(), varlist_size());
2177  }
2178
2179public:
2180  /// Creates clause with a list of variables \a VL.
2181  ///
2182  /// \param StartLoc Starting location of the clause.
2183  /// \param LParenLoc Location of '('.
2184  /// \param ColonLoc Location of ':'.
2185  /// \param EndLoc Ending location of the clause.
2186  /// \param VL The variables in the clause.
2187  /// \param QualifierLoc The nested-name qualifier with location information
2188  /// \param NameInfo The full name info for reduction identifier.
2189  /// \param Privates List of helper expressions for proper generation of
2190  /// private copies.
2191  /// \param LHSExprs List of helper expressions for proper generation of
2192  /// assignment operation required for copyprivate clause. This list represents
2193  /// LHSs of the reduction expressions.
2194  /// \param RHSExprs List of helper expressions for proper generation of
2195  /// assignment operation required for copyprivate clause. This list represents
2196  /// RHSs of the reduction expressions.
2197  /// Also, variables in these expressions are used for proper initialization of
2198  /// reduction copies.
2199  /// \param ReductionOps List of helper expressions that represents reduction
2200  /// expressions:
2201  /// \code
2202  /// LHSExprs binop RHSExprs;
2203  /// operator binop(LHSExpr, RHSExpr);
2204  /// <CutomReduction>(LHSExpr, RHSExpr);
2205  /// \endcode
2206  /// Required for proper codegen of final reduction operation performed by the
2207  /// reduction clause.
2208  /// \param PreInit Statement that must be executed before entering the OpenMP
2209  /// region with this clause.
2210  /// \param PostUpdate Expression that must be executed after exit from the
2211  /// OpenMP region with this clause.
2212  static OMPReductionClause *
2213  Create(const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
2214         SourceLocation ColonLocSourceLocation EndLocArrayRef<Expr *> VL,
2215         NestedNameSpecifierLoc QualifierLoc,
2216         const DeclarationNameInfo &NameInfoArrayRef<Expr *> Privates,
2217         ArrayRef<Expr *> LHSExprsArrayRef<Expr *> RHSExprs,
2218         ArrayRef<Expr *> ReductionOpsStmt *PreInitExpr *PostUpdate);
2219
2220  /// Creates an empty clause with the place for \a N variables.
2221  ///
2222  /// \param C AST context.
2223  /// \param N The number of variables.
2224  static OMPReductionClause *CreateEmpty(const ASTContext &Cunsigned N);
2225
2226  /// Gets location of ':' symbol in clause.
2227  SourceLocation getColonLoc() const { return ColonLoc; }
2228
2229  /// Gets the name info for specified reduction identifier.
2230  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
2231
2232  /// Gets the nested name specifier.
2233  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2234
2235  using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
2236  using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
2237  using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
2238  using helper_expr_const_range =
2239      llvm::iterator_range<helper_expr_const_iterator>;
2240
2241  helper_expr_const_range privates() const {
2242    return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
2243  }
2244
2245  helper_expr_range privates() {
2246    return helper_expr_range(getPrivates().begin(), getPrivates().end());
2247  }
2248
2249  helper_expr_const_range lhs_exprs() const {
2250    return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
2251  }
2252
2253  helper_expr_range lhs_exprs() {
2254    return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
2255  }
2256
2257  helper_expr_const_range rhs_exprs() const {
2258    return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
2259  }
2260
2261  helper_expr_range rhs_exprs() {
2262    return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
2263  }
2264
2265  helper_expr_const_range reduction_ops() const {
2266    return helper_expr_const_range(getReductionOps().begin(),
2267                                   getReductionOps().end());
2268  }
2269
2270  helper_expr_range reduction_ops() {
2271    return helper_expr_range(getReductionOps().begin(),
2272                             getReductionOps().end());
2273  }
2274
2275  child_range children() {
2276    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2277                       reinterpret_cast<Stmt **>(varlist_end()));
2278  }
2279
2280  static bool classof(const OMPClause *T) {
2281    return T->getClauseKind() == OMPC_reduction;
2282  }
2283};
2284
2285/// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
2286/// directives.
2287///
2288/// \code
2289/// #pragma omp taskgroup task_reduction(+:a,b)
2290/// \endcode
2291/// In this example directive '#pragma omp taskgroup' has clause
2292/// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
2293class OMPTaskReductionClause final
2294    : public OMPVarListClause<OMPTaskReductionClause>,
2295      public OMPClauseWithPostUpdate,
2296      private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> {
2297  friend class OMPClauseReader;
2298  friend OMPVarListClause;
2299  friend TrailingObjects;
2300
2301  /// Location of ':'.
2302  SourceLocation ColonLoc;
2303
2304  /// Nested name specifier for C++.
2305  NestedNameSpecifierLoc QualifierLoc;
2306
2307  /// Name of custom operator.
2308  DeclarationNameInfo NameInfo;
2309
2310  /// Build clause with number of variables \a N.
2311  ///
2312  /// \param StartLoc Starting location of the clause.
2313  /// \param LParenLoc Location of '('.
2314  /// \param EndLoc Ending location of the clause.
2315  /// \param ColonLoc Location of ':'.
2316  /// \param N Number of the variables in the clause.
2317  /// \param QualifierLoc The nested-name qualifier with location information
2318  /// \param NameInfo The full name info for reduction identifier.
2319  OMPTaskReductionClause(SourceLocation StartLocSourceLocation LParenLoc,
2320                         SourceLocation ColonLocSourceLocation EndLoc,
2321                         unsigned NNestedNameSpecifierLoc QualifierLoc,
2322                         const DeclarationNameInfo &NameInfo)
2323      : OMPVarListClause<OMPTaskReductionClause>(OMPC_task_reduction, StartLoc,
2324                                                 LParenLoc, EndLoc, N),
2325        OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
2326        QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
2327
2328  /// Build an empty clause.
2329  ///
2330  /// \param N Number of variables.
2331  explicit OMPTaskReductionClause(unsigned N)
2332      : OMPVarListClause<OMPTaskReductionClause>(
2333            OMPC_task_reduction, SourceLocation(), SourceLocation(),
2334            SourceLocation(), N),
2335        OMPClauseWithPostUpdate(this) {}
2336
2337  /// Sets location of ':' symbol in clause.
2338  void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
2339
2340  /// Sets the name info for specified reduction identifier.
2341  void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
2342
2343  /// Sets the nested name specifier.
2344  void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
2345
2346  /// Set list of helper expressions, required for proper codegen of the clause.
2347  /// These expressions represent private copy of the reduction variable.
2348  void setPrivates(ArrayRef<Expr *> Privates);
2349
2350  /// Get the list of helper privates.
2351  MutableArrayRef<Expr *> getPrivates() {
2352    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2353  }
2354  ArrayRef<const Expr *> getPrivates() const {
2355    return llvm::makeArrayRef(varlist_end(), varlist_size());
2356  }
2357
2358  /// Set list of helper expressions, required for proper codegen of the clause.
2359  /// These expressions represent LHS expression in the final reduction
2360  /// expression performed by the reduction clause.
2361  void setLHSExprs(ArrayRef<Expr *> LHSExprs);
2362
2363  /// Get the list of helper LHS expressions.
2364  MutableArrayRef<Expr *> getLHSExprs() {
2365    return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
2366  }
2367  ArrayRef<const Expr *> getLHSExprs() const {
2368    return llvm::makeArrayRef(getPrivates().end(), varlist_size());
2369  }
2370
2371  /// Set list of helper expressions, required for proper codegen of the clause.
2372  /// These expressions represent RHS expression in the final reduction
2373  /// expression performed by the reduction clause. Also, variables in these
2374  /// expressions are used for proper initialization of reduction copies.
2375  void setRHSExprs(ArrayRef<Expr *> RHSExprs);
2376
2377  ///  Get the list of helper destination expressions.
2378  MutableArrayRef<Expr *> getRHSExprs() {
2379    return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
2380  }
2381  ArrayRef<const Expr *> getRHSExprs() const {
2382    return llvm::makeArrayRef(getLHSExprs().end(), varlist_size());
2383  }
2384
2385  /// Set list of helper reduction expressions, required for proper
2386  /// codegen of the clause. These expressions are binary expressions or
2387  /// operator/custom reduction call that calculates new value from source
2388  /// helper expressions to destination helper expressions.
2389  void setReductionOps(ArrayRef<Expr *> ReductionOps);
2390
2391  ///  Get the list of helper reduction expressions.
2392  MutableArrayRef<Expr *> getReductionOps() {
2393    return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
2394  }
2395  ArrayRef<const Expr *> getReductionOps() const {
2396    return llvm::makeArrayRef(getRHSExprs().end(), varlist_size());
2397  }
2398
2399public:
2400  /// Creates clause with a list of variables \a VL.
2401  ///
2402  /// \param StartLoc Starting location of the clause.
2403  /// \param LParenLoc Location of '('.
2404  /// \param ColonLoc Location of ':'.
2405  /// \param EndLoc Ending location of the clause.
2406  /// \param VL The variables in the clause.
2407  /// \param QualifierLoc The nested-name qualifier with location information
2408  /// \param NameInfo The full name info for reduction identifier.
2409  /// \param Privates List of helper expressions for proper generation of
2410  /// private copies.
2411  /// \param LHSExprs List of helper expressions for proper generation of
2412  /// assignment operation required for copyprivate clause. This list represents
2413  /// LHSs of the reduction expressions.
2414  /// \param RHSExprs List of helper expressions for proper generation of
2415  /// assignment operation required for copyprivate clause. This list represents
2416  /// RHSs of the reduction expressions.
2417  /// Also, variables in these expressions are used for proper initialization of
2418  /// reduction copies.
2419  /// \param ReductionOps List of helper expressions that represents reduction
2420  /// expressions:
2421  /// \code
2422  /// LHSExprs binop RHSExprs;
2423  /// operator binop(LHSExpr, RHSExpr);
2424  /// <CutomReduction>(LHSExpr, RHSExpr);
2425  /// \endcode
2426  /// Required for proper codegen of final reduction operation performed by the
2427  /// reduction clause.
2428  /// \param PreInit Statement that must be executed before entering the OpenMP
2429  /// region with this clause.
2430  /// \param PostUpdate Expression that must be executed after exit from the
2431  /// OpenMP region with this clause.
2432  static OMPTaskReductionClause *
2433  Create(const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
2434         SourceLocation ColonLocSourceLocation EndLocArrayRef<Expr *> VL,
2435         NestedNameSpecifierLoc QualifierLoc,
2436         const DeclarationNameInfo &NameInfoArrayRef<Expr *> Privates,
2437         ArrayRef<Expr *> LHSExprsArrayRef<Expr *> RHSExprs,
2438         ArrayRef<Expr *> ReductionOpsStmt *PreInitExpr *PostUpdate);
2439
2440  /// Creates an empty clause with the place for \a N variables.
2441  ///
2442  /// \param C AST context.
2443  /// \param N The number of variables.
2444  static OMPTaskReductionClause *CreateEmpty(const ASTContext &Cunsigned N);
2445
2446  /// Gets location of ':' symbol in clause.
2447  SourceLocation getColonLoc() const { return ColonLoc; }
2448
2449  /// Gets the name info for specified reduction identifier.
2450  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
2451
2452  /// Gets the nested name specifier.
2453  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2454
2455  using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
2456  using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
2457  using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
2458  using helper_expr_const_range =
2459      llvm::iterator_range<helper_expr_const_iterator>;
2460
2461  helper_expr_const_range privates() const {
2462    return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
2463  }
2464
2465  helper_expr_range privates() {
2466    return helper_expr_range(getPrivates().begin(), getPrivates().end());
2467  }
2468
2469  helper_expr_const_range lhs_exprs() const {
2470    return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
2471  }
2472
2473  helper_expr_range lhs_exprs() {
2474    return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
2475  }
2476
2477  helper_expr_const_range rhs_exprs() const {
2478    return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
2479  }
2480
2481  helper_expr_range rhs_exprs() {
2482    return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
2483  }
2484
2485  helper_expr_const_range reduction_ops() const {
2486    return helper_expr_const_range(getReductionOps().begin(),
2487                                   getReductionOps().end());
2488  }
2489
2490  helper_expr_range reduction_ops() {
2491    return helper_expr_range(getReductionOps().begin(),
2492                             getReductionOps().end());
2493  }
2494
2495  child_range children() {
2496    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2497                       reinterpret_cast<Stmt **>(varlist_end()));
2498  }
2499
2500  static bool classof(const OMPClause *T) {
2501    return T->getClauseKind() == OMPC_task_reduction;
2502  }
2503};
2504
2505/// This represents clause 'in_reduction' in the '#pragma omp task' directives.
2506///
2507/// \code
2508/// #pragma omp task in_reduction(+:a,b)
2509/// \endcode
2510/// In this example directive '#pragma omp task' has clause 'in_reduction' with
2511/// operator '+' and the variables 'a' and 'b'.
2512class OMPInReductionClause final
2513    : public OMPVarListClause<OMPInReductionClause>,
2514      public OMPClauseWithPostUpdate,
2515      private llvm::TrailingObjects<OMPInReductionClause, Expr *> {
2516  friend class OMPClauseReader;
2517  friend OMPVarListClause;
2518  friend TrailingObjects;
2519
2520  /// Location of ':'.
2521  SourceLocation ColonLoc;
2522
2523  /// Nested name specifier for C++.
2524  NestedNameSpecifierLoc QualifierLoc;
2525
2526  /// Name of custom operator.
2527  DeclarationNameInfo NameInfo;
2528
2529  /// Build clause with number of variables \a N.
2530  ///
2531  /// \param StartLoc Starting location of the clause.
2532  /// \param LParenLoc Location of '('.
2533  /// \param EndLoc Ending location of the clause.
2534  /// \param ColonLoc Location of ':'.
2535  /// \param N Number of the variables in the clause.
2536  /// \param QualifierLoc The nested-name qualifier with location information
2537  /// \param NameInfo The full name info for reduction identifier.
2538  OMPInReductionClause(SourceLocation StartLocSourceLocation LParenLoc,
2539                       SourceLocation ColonLocSourceLocation EndLoc,
2540                       unsigned NNestedNameSpecifierLoc QualifierLoc,
2541                       const DeclarationNameInfo &NameInfo)
2542      : OMPVarListClause<OMPInReductionClause>(OMPC_in_reduction, StartLoc,
2543                                               LParenLoc, EndLoc, N),
2544        OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
2545        QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
2546
2547  /// Build an empty clause.
2548  ///
2549  /// \param N Number of variables.
2550  explicit OMPInReductionClause(unsigned N)
2551      : OMPVarListClause<OMPInReductionClause>(
2552            OMPC_in_reduction, SourceLocation(), SourceLocation(),
2553            SourceLocation(), N),
2554        OMPClauseWithPostUpdate(this) {}
2555
2556  /// Sets location of ':' symbol in clause.
2557  void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
2558
2559  /// Sets the name info for specified reduction identifier.
2560  void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
2561
2562  /// Sets the nested name specifier.
2563  void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
2564
2565  /// Set list of helper expressions, required for proper codegen of the clause.
2566  /// These expressions represent private copy of the reduction variable.
2567  void setPrivates(ArrayRef<Expr *> Privates);
2568
2569  /// Get the list of helper privates.
2570  MutableArrayRef<Expr *> getPrivates() {
2571    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2572  }
2573  ArrayRef<const Expr *> getPrivates() const {
2574    return llvm::makeArrayRef(varlist_end(), varlist_size());
2575  }
2576
2577  /// Set list of helper expressions, required for proper codegen of the clause.
2578  /// These expressions represent LHS expression in the final reduction
2579  /// expression performed by the reduction clause.
2580  void setLHSExprs(ArrayRef<Expr *> LHSExprs);
2581
2582  /// Get the list of helper LHS expressions.
2583  MutableArrayRef<Expr *> getLHSExprs() {
2584    return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
2585  }
2586  ArrayRef<const Expr *> getLHSExprs() const {
2587    return llvm::makeArrayRef(getPrivates().end(), varlist_size());
2588  }
2589
2590  /// Set list of helper expressions, required for proper codegen of the clause.
2591  /// These expressions represent RHS expression in the final reduction
2592  /// expression performed by the reduction clause. Also, variables in these
2593  /// expressions are used for proper initialization of reduction copies.
2594  void setRHSExprs(ArrayRef<Expr *> RHSExprs);
2595
2596  ///  Get the list of helper destination expressions.
2597  MutableArrayRef<Expr *> getRHSExprs() {
2598    return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size());
2599  }
2600  ArrayRef<const Expr *> getRHSExprs() const {
2601    return llvm::makeArrayRef(getLHSExprs().end(), varlist_size());
2602  }
2603
2604  /// Set list of helper reduction expressions, required for proper
2605  /// codegen of the clause. These expressions are binary expressions or
2606  /// operator/custom reduction call that calculates new value from source
2607  /// helper expressions to destination helper expressions.
2608  void setReductionOps(ArrayRef<Expr *> ReductionOps);
2609
2610  ///  Get the list of helper reduction expressions.
2611  MutableArrayRef<Expr *> getReductionOps() {
2612    return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size());
2613  }
2614  ArrayRef<const Expr *> getReductionOps() const {
2615    return llvm::makeArrayRef(getRHSExprs().end(), varlist_size());
2616  }
2617
2618  /// Set list of helper reduction taskgroup descriptors.
2619  void setTaskgroupDescriptors(ArrayRef<Expr *> ReductionOps);
2620
2621  ///  Get the list of helper reduction taskgroup descriptors.
2622  MutableArrayRef<Expr *> getTaskgroupDescriptors() {
2623    return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size());
2624  }
2625  ArrayRef<const Expr *> getTaskgroupDescriptors() const {
2626    return llvm::makeArrayRef(getReductionOps().end(), varlist_size());
2627  }
2628
2629public:
2630  /// Creates clause with a list of variables \a VL.
2631  ///
2632  /// \param StartLoc Starting location of the clause.
2633  /// \param LParenLoc Location of '('.
2634  /// \param ColonLoc Location of ':'.
2635  /// \param EndLoc Ending location of the clause.
2636  /// \param VL The variables in the clause.
2637  /// \param QualifierLoc The nested-name qualifier with location information
2638  /// \param NameInfo The full name info for reduction identifier.
2639  /// \param Privates List of helper expressions for proper generation of
2640  /// private copies.
2641  /// \param LHSExprs List of helper expressions for proper generation of
2642  /// assignment operation required for copyprivate clause. This list represents
2643  /// LHSs of the reduction expressions.
2644  /// \param RHSExprs List of helper expressions for proper generation of
2645  /// assignment operation required for copyprivate clause. This list represents
2646  /// RHSs of the reduction expressions.
2647  /// Also, variables in these expressions are used for proper initialization of
2648  /// reduction copies.
2649  /// \param ReductionOps List of helper expressions that represents reduction
2650  /// expressions:
2651  /// \code
2652  /// LHSExprs binop RHSExprs;
2653  /// operator binop(LHSExpr, RHSExpr);
2654  /// <CutomReduction>(LHSExpr, RHSExpr);
2655  /// \endcode
2656  /// Required for proper codegen of final reduction operation performed by the
2657  /// reduction clause.
2658  /// \param TaskgroupDescriptors List of helper taskgroup descriptors for
2659  /// corresponding items in parent taskgroup task_reduction clause.
2660  /// \param PreInit Statement that must be executed before entering the OpenMP
2661  /// region with this clause.
2662  /// \param PostUpdate Expression that must be executed after exit from the
2663  /// OpenMP region with this clause.
2664  static OMPInReductionClause *
2665  Create(const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
2666         SourceLocation ColonLocSourceLocation EndLocArrayRef<Expr *> VL,
2667         NestedNameSpecifierLoc QualifierLoc,
2668         const DeclarationNameInfo &NameInfoArrayRef<Expr *> Privates,
2669         ArrayRef<Expr *> LHSExprsArrayRef<Expr *> RHSExprs,
2670         ArrayRef<Expr *> ReductionOpsArrayRef<Expr *> TaskgroupDescriptors,
2671         Stmt *PreInitExpr *PostUpdate);
2672
2673  /// Creates an empty clause with the place for \a N variables.
2674  ///
2675  /// \param C AST context.
2676  /// \param N The number of variables.
2677  static OMPInReductionClause *CreateEmpty(const ASTContext &Cunsigned N);
2678
2679  /// Gets location of ':' symbol in clause.
2680  SourceLocation getColonLoc() const { return ColonLoc; }
2681
2682  /// Gets the name info for specified reduction identifier.
2683  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
2684
2685  /// Gets the nested name specifier.
2686  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2687
2688  using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
2689  using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
2690  using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
2691  using helper_expr_const_range =
2692      llvm::iterator_range<helper_expr_const_iterator>;
2693
2694  helper_expr_const_range privates() const {
2695    return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
2696  }
2697
2698  helper_expr_range privates() {
2699    return helper_expr_range(getPrivates().begin(), getPrivates().end());
2700  }
2701
2702  helper_expr_const_range lhs_exprs() const {
2703    return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
2704  }
2705
2706  helper_expr_range lhs_exprs() {
2707    return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
2708  }
2709
2710  helper_expr_const_range rhs_exprs() const {
2711    return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
2712  }
2713
2714  helper_expr_range rhs_exprs() {
2715    return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
2716  }
2717
2718  helper_expr_const_range reduction_ops() const {
2719    return helper_expr_const_range(getReductionOps().begin(),
2720                                   getReductionOps().end());
2721  }
2722
2723  helper_expr_range reduction_ops() {
2724    return helper_expr_range(getReductionOps().begin(),
2725                             getReductionOps().end());
2726  }
2727
2728  helper_expr_const_range taskgroup_descriptors() const {
2729    return helper_expr_const_range(getTaskgroupDescriptors().begin(),
2730                                   getTaskgroupDescriptors().end());
2731  }
2732
2733  helper_expr_range taskgroup_descriptors() {
2734    return helper_expr_range(getTaskgroupDescriptors().begin(),
2735                             getTaskgroupDescriptors().end());
2736  }
2737
2738  child_range children() {
2739    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2740                       reinterpret_cast<Stmt **>(varlist_end()));
2741  }
2742
2743  static bool classof(const OMPClause *T) {
2744    return T->getClauseKind() == OMPC_in_reduction;
2745  }
2746};
2747
2748/// This represents clause 'linear' in the '#pragma omp ...'
2749/// directives.
2750///
2751/// \code
2752/// #pragma omp simd linear(a,b : 2)
2753/// \endcode
2754/// In this example directive '#pragma omp simd' has clause 'linear'
2755/// with variables 'a', 'b' and linear step '2'.
2756class OMPLinearClause final
2757    : public OMPVarListClause<OMPLinearClause>,
2758      public OMPClauseWithPostUpdate,
2759      private llvm::TrailingObjects<OMPLinearClause, Expr *> {
2760  friend class OMPClauseReader;
2761  friend OMPVarListClause;
2762  friend TrailingObjects;
2763
2764  /// Modifier of 'linear' clause.
2765  OpenMPLinearClauseKind Modifier = OMPC_LINEAR_val;
2766
2767  /// Location of linear modifier if any.
2768  SourceLocation ModifierLoc;
2769
2770  /// Location of ':'.
2771  SourceLocation ColonLoc;
2772
2773  /// Sets the linear step for clause.
2774  void setStep(Expr *Step) { *(getFinals().end()) = Step; }
2775
2776  /// Sets the expression to calculate linear step for clause.
2777  void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; }
2778
2779  /// Build 'linear' clause with given number of variables \a NumVars.
2780  ///
2781  /// \param StartLoc Starting location of the clause.
2782  /// \param LParenLoc Location of '('.
2783  /// \param ColonLoc Location of ':'.
2784  /// \param EndLoc Ending location of the clause.
2785  /// \param NumVars Number of variables.
2786  OMPLinearClause(SourceLocation StartLocSourceLocation LParenLoc,
2787                  OpenMPLinearClauseKind ModifierSourceLocation ModifierLoc,
2788                  SourceLocation ColonLocSourceLocation EndLoc,
2789                  unsigned NumVars)
2790      : OMPVarListClause<OMPLinearClause>(OMPC_linear, StartLoc, LParenLoc,
2791                                          EndLoc, NumVars),
2792        OMPClauseWithPostUpdate(this), Modifier(Modifier),
2793        ModifierLoc(ModifierLoc), ColonLoc(ColonLoc) {}
2794
2795  /// Build an empty clause.
2796  ///
2797  /// \param NumVars Number of variables.
2798  explicit OMPLinearClause(unsigned NumVars)
2799      : OMPVarListClause<OMPLinearClause>(OMPC_linear, SourceLocation(),
2800                                          SourceLocation(), SourceLocation(),
2801                                          NumVars),
2802        OMPClauseWithPostUpdate(this) {}
2803
2804  /// Gets the list of initial values for linear variables.
2805  ///
2806  /// There are NumVars expressions with initial values allocated after the
2807  /// varlist, they are followed by NumVars update expressions (used to update
2808  /// the linear variable's value on current iteration) and they are followed by
2809  /// NumVars final expressions (used to calculate the linear variable's
2810  /// value after the loop body). After these lists, there are 2 helper
2811  /// expressions - linear step and a helper to calculate it before the
2812  /// loop body (used when the linear step is not constant):
2813  ///
2814  /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[];
2815  /// Finals[]; Step; CalcStep; }
2816  MutableArrayRef<Expr *> getPrivates() {
2817    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
2818  }
2819  ArrayRef<const Expr *> getPrivates() const {
2820    return llvm::makeArrayRef(varlist_end(), varlist_size());
2821  }
2822
2823  MutableArrayRef<Expr *> getInits() {
2824    return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size());
2825  }
2826  ArrayRef<const Expr *> getInits() const {
2827    return llvm::makeArrayRef(getPrivates().end(), varlist_size());
2828  }
2829
2830  /// Sets the list of update expressions for linear variables.
2831  MutableArrayRef<Expr *> getUpdates() {
2832    return MutableArrayRef<Expr *>(getInits().end(), varlist_size());
2833  }
2834  ArrayRef<const Expr *> getUpdates() const {
2835    return llvm::makeArrayRef(getInits().end(), varlist_size());
2836  }
2837
2838  /// Sets the list of final update expressions for linear variables.
2839  MutableArrayRef<Expr *> getFinals() {
2840    return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size());
2841  }
2842  ArrayRef<const Expr *> getFinals() const {
2843    return llvm::makeArrayRef(getUpdates().end(), varlist_size());
2844  }
2845
2846  /// Sets the list of the copies of original linear variables.
2847  /// \param PL List of expressions.
2848  void setPrivates(ArrayRef<Expr *> PL);
2849
2850  /// Sets the list of the initial values for linear variables.
2851  /// \param IL List of expressions.
2852  void setInits(ArrayRef<Expr *> IL);
2853
2854public:
2855  /// Creates clause with a list of variables \a VL and a linear step
2856  /// \a Step.
2857  ///
2858  /// \param C AST Context.
2859  /// \param StartLoc Starting location of the clause.
2860  /// \param LParenLoc Location of '('.
2861  /// \param Modifier Modifier of 'linear' clause.
2862  /// \param ModifierLoc Modifier location.
2863  /// \param ColonLoc Location of ':'.
2864  /// \param EndLoc Ending location of the clause.
2865  /// \param VL List of references to the variables.
2866  /// \param PL List of private copies of original variables.
2867  /// \param IL List of initial values for the variables.
2868  /// \param Step Linear step.
2869  /// \param CalcStep Calculation of the linear step.
2870  /// \param PreInit Statement that must be executed before entering the OpenMP
2871  /// region with this clause.
2872  /// \param PostUpdate Expression that must be executed after exit from the
2873  /// OpenMP region with this clause.
2874  static OMPLinearClause *
2875  Create(const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
2876         OpenMPLinearClauseKind ModifierSourceLocation ModifierLoc,
2877         SourceLocation ColonLocSourceLocation EndLocArrayRef<Expr *> VL,
2878         ArrayRef<Expr *> PLArrayRef<Expr *> ILExpr *StepExpr *CalcStep,
2879         Stmt *PreInitExpr *PostUpdate);
2880
2881  /// Creates an empty clause with the place for \a NumVars variables.
2882  ///
2883  /// \param C AST context.
2884  /// \param NumVars Number of variables.
2885  static OMPLinearClause *CreateEmpty(const ASTContext &Cunsigned NumVars);
2886
2887  /// Set modifier.
2888  void setModifier(OpenMPLinearClauseKind Kind) { Modifier = Kind; }
2889
2890  /// Return modifier.
2891  OpenMPLinearClauseKind getModifier() const { return Modifier; }
2892
2893  /// Set modifier location.
2894  void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
2895
2896  /// Return modifier location.
2897  SourceLocation getModifierLoc() const { return ModifierLoc; }
2898
2899  /// Sets the location of ':'.
2900  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
2901
2902  /// Returns the location of ':'.
2903  SourceLocation getColonLoc() const { return ColonLoc; }
2904
2905  /// Returns linear step.
2906  Expr *getStep() { return *(getFinals().end()); }
2907
2908  /// Returns linear step.
2909  const Expr *getStep() const { return *(getFinals().end()); }
2910
2911  /// Returns expression to calculate linear step.
2912  Expr *getCalcStep() { return *(getFinals().end() + 1); }
2913
2914  /// Returns expression to calculate linear step.
2915  const Expr *getCalcStep() const { return *(getFinals().end() + 1); }
2916
2917  /// Sets the list of update expressions for linear variables.
2918  /// \param UL List of expressions.
2919  void setUpdates(ArrayRef<Expr *> UL);
2920
2921  /// Sets the list of final update expressions for linear variables.
2922  /// \param FL List of expressions.
2923  void setFinals(ArrayRef<Expr *> FL);
2924
2925  using privates_iterator = MutableArrayRef<Expr *>::iterator;
2926  using privates_const_iterator = ArrayRef<const Expr *>::iterator;
2927  using privates_range = llvm::iterator_range<privates_iterator>;
2928  using privates_const_range = llvm::iterator_range<privates_const_iterator>;
2929
2930  privates_range privates() {
2931    return privates_range(getPrivates().begin(), getPrivates().end());
2932  }
2933
2934  privates_const_range privates() const {
2935    return privates_const_range(getPrivates().begin(), getPrivates().end());
2936  }
2937
2938  using inits_iterator = MutableArrayRef<Expr *>::iterator;
2939  using inits_const_iterator = ArrayRef<const Expr *>::iterator;
2940  using inits_range = llvm::iterator_range<inits_iterator>;
2941  using inits_const_range = llvm::iterator_range<inits_const_iterator>;
2942
2943  inits_range inits() {
2944    return inits_range(getInits().begin(), getInits().end());
2945  }
2946
2947  inits_const_range inits() const {
2948    return inits_const_range(getInits().begin(), getInits().end());
2949  }
2950
2951  using updates_iterator = MutableArrayRef<Expr *>::iterator;
2952  using updates_const_iterator = ArrayRef<const Expr *>::iterator;
2953  using updates_range = llvm::iterator_range<updates_iterator>;
2954  using updates_const_range = llvm::iterator_range<updates_const_iterator>;
2955
2956  updates_range updates() {
2957    return updates_range(getUpdates().begin(), getUpdates().end());
2958  }
2959
2960  updates_const_range updates() const {
2961    return updates_const_range(getUpdates().begin(), getUpdates().end());
2962  }
2963
2964  using finals_iterator = MutableArrayRef<Expr *>::iterator;
2965  using finals_const_iterator = ArrayRef<const Expr *>::iterator;
2966  using finals_range = llvm::iterator_range<finals_iterator>;
2967  using finals_const_range = llvm::iterator_range<finals_const_iterator>;
2968
2969  finals_range finals() {
2970    return finals_range(getFinals().begin(), getFinals().end());
2971  }
2972
2973  finals_const_range finals() const {
2974    return finals_const_range(getFinals().begin(), getFinals().end());
2975  }
2976
2977  child_range children() {
2978    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
2979                       reinterpret_cast<Stmt **>(varlist_end()));
2980  }
2981
2982  static bool classof(const OMPClause *T) {
2983    return T->getClauseKind() == OMPC_linear;
2984  }
2985};
2986
2987/// This represents clause 'aligned' in the '#pragma omp ...'
2988/// directives.
2989///
2990/// \code
2991/// #pragma omp simd aligned(a,b : 8)
2992/// \endcode
2993/// In this example directive '#pragma omp simd' has clause 'aligned'
2994/// with variables 'a', 'b' and alignment '8'.
2995class OMPAlignedClause final
2996    : public OMPVarListClause<OMPAlignedClause>,
2997      private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
2998  friend class OMPClauseReader;
2999  friend OMPVarListClause;
3000  friend TrailingObjects;
3001
3002  /// Location of ':'.
3003  SourceLocation ColonLoc;
3004
3005  /// Sets the alignment for clause.
3006  void setAlignment(Expr *A) { *varlist_end() = A; }
3007
3008  /// Build 'aligned' clause with given number of variables \a NumVars.
3009  ///
3010  /// \param StartLoc Starting location of the clause.
3011  /// \param LParenLoc Location of '('.
3012  /// \param ColonLoc Location of ':'.
3013  /// \param EndLoc Ending location of the clause.
3014  /// \param NumVars Number of variables.
3015  OMPAlignedClause(SourceLocation StartLocSourceLocation LParenLoc,
3016                   SourceLocation ColonLocSourceLocation EndLoc,
3017                   unsigned NumVars)
3018      : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, StartLoc, LParenLoc,
3019                                           EndLoc, NumVars),
3020        ColonLoc(ColonLoc) {}
3021
3022  /// Build an empty clause.
3023  ///
3024  /// \param NumVars Number of variables.
3025  explicit OMPAlignedClause(unsigned NumVars)
3026      : OMPVarListClause<OMPAlignedClause>(OMPC_aligned, SourceLocation(),
3027                                           SourceLocation(), SourceLocation(),
3028                                           NumVars) {}
3029
3030public:
3031  /// Creates clause with a list of variables \a VL and alignment \a A.
3032  ///
3033  /// \param C AST Context.
3034  /// \param StartLoc Starting location of the clause.
3035  /// \param LParenLoc Location of '('.
3036  /// \param ColonLoc Location of ':'.
3037  /// \param EndLoc Ending location of the clause.
3038  /// \param VL List of references to the variables.
3039  /// \param A Alignment.
3040  static OMPAlignedClause *Create(const ASTContext &CSourceLocation StartLoc,
3041                                  SourceLocation LParenLoc,
3042                                  SourceLocation ColonLoc,
3043                                  SourceLocation EndLocArrayRef<Expr *> VL,
3044                                  Expr *A);
3045
3046  /// Creates an empty clause with the place for \a NumVars variables.
3047  ///
3048  /// \param C AST context.
3049  /// \param NumVars Number of variables.
3050  static OMPAlignedClause *CreateEmpty(const ASTContext &Cunsigned NumVars);
3051
3052  /// Sets the location of ':'.
3053  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3054
3055  /// Returns the location of ':'.
3056  SourceLocation getColonLoc() const { return ColonLoc; }
3057
3058  /// Returns alignment.
3059  Expr *getAlignment() { return *varlist_end(); }
3060
3061  /// Returns alignment.
3062  const Expr *getAlignment() const { return *varlist_end(); }
3063
3064  child_range children() {
3065    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3066                       reinterpret_cast<Stmt **>(varlist_end()));
3067  }
3068
3069  static bool classof(const OMPClause *T) {
3070    return T->getClauseKind() == OMPC_aligned;
3071  }
3072};
3073
3074/// This represents clause 'copyin' in the '#pragma omp ...' directives.
3075///
3076/// \code
3077/// #pragma omp parallel copyin(a,b)
3078/// \endcode
3079/// In this example directive '#pragma omp parallel' has clause 'copyin'
3080/// with the variables 'a' and 'b'.
3081class OMPCopyinClause final
3082    : public OMPVarListClause<OMPCopyinClause>,
3083      private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
3084  // Class has 3 additional tail allocated arrays:
3085  // 1. List of helper expressions for proper generation of assignment operation
3086  // required for copyin clause. This list represents sources.
3087  // 2. List of helper expressions for proper generation of assignment operation
3088  // required for copyin clause. This list represents destinations.
3089  // 3. List of helper expressions that represents assignment operation:
3090  // \code
3091  // DstExprs = SrcExprs;
3092  // \endcode
3093  // Required for proper codegen of propagation of master's thread values of
3094  // threadprivate variables to local instances of that variables in other
3095  // implicit threads.
3096
3097  friend class OMPClauseReader;
3098  friend OMPVarListClause;
3099  friend TrailingObjects;
3100
3101  /// Build clause with number of variables \a N.
3102  ///
3103  /// \param StartLoc Starting location of the clause.
3104  /// \param LParenLoc Location of '('.
3105  /// \param EndLoc Ending location of the clause.
3106  /// \param N Number of the variables in the clause.
3107  OMPCopyinClause(SourceLocation StartLocSourceLocation LParenLoc,
3108                  SourceLocation EndLocunsigned N)
3109      : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, StartLoc, LParenLoc,
3110                                          EndLoc, N) {}
3111
3112  /// Build an empty clause.
3113  ///
3114  /// \param N Number of variables.
3115  explicit OMPCopyinClause(unsigned N)
3116      : OMPVarListClause<OMPCopyinClause>(OMPC_copyin, SourceLocation(),
3117                                          SourceLocation(), SourceLocation(),
3118                                          N) {}
3119
3120  /// Set list of helper expressions, required for proper codegen of the
3121  /// clause. These expressions represent source expression in the final
3122  /// assignment statement performed by the copyin clause.
3123  void setSourceExprs(ArrayRef<Expr *> SrcExprs);
3124
3125  /// Get the list of helper source expressions.
3126  MutableArrayRef<Expr *> getSourceExprs() {
3127    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3128  }
3129  ArrayRef<const Expr *> getSourceExprs() const {
3130    return llvm::makeArrayRef(varlist_end(), varlist_size());
3131  }
3132
3133  /// Set list of helper expressions, required for proper codegen of the
3134  /// clause. These expressions represent destination expression in the final
3135  /// assignment statement performed by the copyin clause.
3136  void setDestinationExprs(ArrayRef<Expr *> DstExprs);
3137
3138  /// Get the list of helper destination expressions.
3139  MutableArrayRef<Expr *> getDestinationExprs() {
3140    return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
3141  }
3142  ArrayRef<const Expr *> getDestinationExprs() const {
3143    return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
3144  }
3145
3146  /// Set list of helper assignment expressions, required for proper
3147  /// codegen of the clause. These expressions are assignment expressions that
3148  /// assign source helper expressions to destination helper expressions
3149  /// correspondingly.
3150  void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
3151
3152  /// Get the list of helper assignment expressions.
3153  MutableArrayRef<Expr *> getAssignmentOps() {
3154    return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
3155  }
3156  ArrayRef<const Expr *> getAssignmentOps() const {
3157    return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
3158  }
3159
3160public:
3161  /// Creates clause with a list of variables \a VL.
3162  ///
3163  /// \param C AST context.
3164  /// \param StartLoc Starting location of the clause.
3165  /// \param LParenLoc Location of '('.
3166  /// \param EndLoc Ending location of the clause.
3167  /// \param VL List of references to the variables.
3168  /// \param SrcExprs List of helper expressions for proper generation of
3169  /// assignment operation required for copyin clause. This list represents
3170  /// sources.
3171  /// \param DstExprs List of helper expressions for proper generation of
3172  /// assignment operation required for copyin clause. This list represents
3173  /// destinations.
3174  /// \param AssignmentOps List of helper expressions that represents assignment
3175  /// operation:
3176  /// \code
3177  /// DstExprs = SrcExprs;
3178  /// \endcode
3179  /// Required for proper codegen of propagation of master's thread values of
3180  /// threadprivate variables to local instances of that variables in other
3181  /// implicit threads.
3182  static OMPCopyinClause *
3183  Create(const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
3184         SourceLocation EndLocArrayRef<Expr *> VLArrayRef<Expr *> SrcExprs,
3185         ArrayRef<Expr *> DstExprsArrayRef<Expr *> AssignmentOps);
3186
3187  /// Creates an empty clause with \a N variables.
3188  ///
3189  /// \param C AST context.
3190  /// \param N The number of variables.
3191  static OMPCopyinClause *CreateEmpty(const ASTContext &Cunsigned N);
3192
3193  using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
3194  using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
3195  using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3196  using helper_expr_const_range =
3197      llvm::iterator_range<helper_expr_const_iterator>;
3198
3199  helper_expr_const_range source_exprs() const {
3200    return helper_expr_const_range(getSourceExprs().begin(),
3201                                   getSourceExprs().end());
3202  }
3203
3204  helper_expr_range source_exprs() {
3205    return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
3206  }
3207
3208  helper_expr_const_range destination_exprs() const {
3209    return helper_expr_const_range(getDestinationExprs().begin(),
3210                                   getDestinationExprs().end());
3211  }
3212
3213  helper_expr_range destination_exprs() {
3214    return helper_expr_range(getDestinationExprs().begin(),
3215                             getDestinationExprs().end());
3216  }
3217
3218  helper_expr_const_range assignment_ops() const {
3219    return helper_expr_const_range(getAssignmentOps().begin(),
3220                                   getAssignmentOps().end());
3221  }
3222
3223  helper_expr_range assignment_ops() {
3224    return helper_expr_range(getAssignmentOps().begin(),
3225                             getAssignmentOps().end());
3226  }
3227
3228  child_range children() {
3229    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3230                       reinterpret_cast<Stmt **>(varlist_end()));
3231  }
3232
3233  static bool classof(const OMPClause *T) {
3234    return T->getClauseKind() == OMPC_copyin;
3235  }
3236};
3237
3238/// This represents clause 'copyprivate' in the '#pragma omp ...'
3239/// directives.
3240///
3241/// \code
3242/// #pragma omp single copyprivate(a,b)
3243/// \endcode
3244/// In this example directive '#pragma omp single' has clause 'copyprivate'
3245/// with the variables 'a' and 'b'.
3246class OMPCopyprivateClause final
3247    : public OMPVarListClause<OMPCopyprivateClause>,
3248      private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
3249  friend class OMPClauseReader;
3250  friend OMPVarListClause;
3251  friend TrailingObjects;
3252
3253  /// Build clause with number of variables \a N.
3254  ///
3255  /// \param StartLoc Starting location of the clause.
3256  /// \param LParenLoc Location of '('.
3257  /// \param EndLoc Ending location of the clause.
3258  /// \param N Number of the variables in the clause.
3259  OMPCopyprivateClause(SourceLocation StartLocSourceLocation LParenLoc,
3260                       SourceLocation EndLocunsigned N)
3261      : OMPVarListClause<OMPCopyprivateClause>(OMPC_copyprivate, StartLoc,
3262                                               LParenLoc, EndLoc, N) {}
3263
3264  /// Build an empty clause.
3265  ///
3266  /// \param N Number of variables.
3267  explicit OMPCopyprivateClause(unsigned N)
3268      : OMPVarListClause<OMPCopyprivateClause>(
3269            OMPC_copyprivate, SourceLocation(), SourceLocation(),
3270            SourceLocation(), N) {}
3271
3272  /// Set list of helper expressions, required for proper codegen of the
3273  /// clause. These expressions represent source expression in the final
3274  /// assignment statement performed by the copyprivate clause.
3275  void setSourceExprs(ArrayRef<Expr *> SrcExprs);
3276
3277  /// Get the list of helper source expressions.
3278  MutableArrayRef<Expr *> getSourceExprs() {
3279    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
3280  }
3281  ArrayRef<const Expr *> getSourceExprs() const {
3282    return llvm::makeArrayRef(varlist_end(), varlist_size());
3283  }
3284
3285  /// Set list of helper expressions, required for proper codegen of the
3286  /// clause. These expressions represent destination expression in the final
3287  /// assignment statement performed by the copyprivate clause.
3288  void setDestinationExprs(ArrayRef<Expr *> DstExprs);
3289
3290  /// Get the list of helper destination expressions.
3291  MutableArrayRef<Expr *> getDestinationExprs() {
3292    return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size());
3293  }
3294  ArrayRef<const Expr *> getDestinationExprs() const {
3295    return llvm::makeArrayRef(getSourceExprs().end(), varlist_size());
3296  }
3297
3298  /// Set list of helper assignment expressions, required for proper
3299  /// codegen of the clause. These expressions are assignment expressions that
3300  /// assign source helper expressions to destination helper expressions
3301  /// correspondingly.
3302  void setAssignmentOps(ArrayRef<Expr *> AssignmentOps);
3303
3304  /// Get the list of helper assignment expressions.
3305  MutableArrayRef<Expr *> getAssignmentOps() {
3306    return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size());
3307  }
3308  ArrayRef<const Expr *> getAssignmentOps() const {
3309    return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
3310  }
3311
3312public:
3313  /// Creates clause with a list of variables \a VL.
3314  ///
3315  /// \param C AST context.
3316  /// \param StartLoc Starting location of the clause.
3317  /// \param LParenLoc Location of '('.
3318  /// \param EndLoc Ending location of the clause.
3319  /// \param VL List of references to the variables.
3320  /// \param SrcExprs List of helper expressions for proper generation of
3321  /// assignment operation required for copyprivate clause. This list represents
3322  /// sources.
3323  /// \param DstExprs List of helper expressions for proper generation of
3324  /// assignment operation required for copyprivate clause. This list represents
3325  /// destinations.
3326  /// \param AssignmentOps List of helper expressions that represents assignment
3327  /// operation:
3328  /// \code
3329  /// DstExprs = SrcExprs;
3330  /// \endcode
3331  /// Required for proper codegen of final assignment performed by the
3332  /// copyprivate clause.
3333  static OMPCopyprivateClause *
3334  Create(const ASTContext &CSourceLocation StartLocSourceLocation LParenLoc,
3335         SourceLocation EndLocArrayRef<Expr *> VLArrayRef<Expr *> SrcExprs,
3336         ArrayRef<Expr *> DstExprsArrayRef<Expr *> AssignmentOps);
3337
3338  /// Creates an empty clause with \a N variables.
3339  ///
3340  /// \param C AST context.
3341  /// \param N The number of variables.
3342  static OMPCopyprivateClause *CreateEmpty(const ASTContext &Cunsigned N);
3343
3344  using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
3345  using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
3346  using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
3347  using helper_expr_const_range =
3348      llvm::iterator_range<helper_expr_const_iterator>;
3349
3350  helper_expr_const_range source_exprs() const {
3351    return helper_expr_const_range(getSourceExprs().begin(),
3352                                   getSourceExprs().end());
3353  }
3354
3355  helper_expr_range source_exprs() {
3356    return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
3357  }
3358
3359  helper_expr_const_range destination_exprs() const {
3360    return helper_expr_const_range(getDestinationExprs().begin(),
3361                                   getDestinationExprs().end());
3362  }
3363
3364  helper_expr_range destination_exprs() {
3365    return helper_expr_range(getDestinationExprs().begin(),
3366                             getDestinationExprs().end());
3367  }
3368
3369  helper_expr_const_range assignment_ops() const {
3370    return helper_expr_const_range(getAssignmentOps().begin(),
3371                                   getAssignmentOps().end());
3372  }
3373
3374  helper_expr_range assignment_ops() {
3375    return helper_expr_range(getAssignmentOps().begin(),
3376                             getAssignmentOps().end());
3377  }
3378
3379  child_range children() {
3380    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3381                       reinterpret_cast<Stmt **>(varlist_end()));
3382  }
3383
3384  static bool classof(const OMPClause *T) {
3385    return T->getClauseKind() == OMPC_copyprivate;
3386  }
3387};
3388
3389/// This represents implicit clause 'flush' for the '#pragma omp flush'
3390/// directive.
3391/// This clause does not exist by itself, it can be only as a part of 'omp
3392/// flush' directive. This clause is introduced to keep the original structure
3393/// of \a OMPExecutableDirective class and its derivatives and to use the
3394/// existing infrastructure of clauses with the list of variables.
3395///
3396/// \code
3397/// #pragma omp flush(a,b)
3398/// \endcode
3399/// In this example directive '#pragma omp flush' has implicit clause 'flush'
3400/// with the variables 'a' and 'b'.
3401class OMPFlushClause final
3402    : public OMPVarListClause<OMPFlushClause>,
3403      private llvm::TrailingObjects<OMPFlushClause, Expr *> {
3404  friend OMPVarListClause;
3405  friend TrailingObjects;
3406
3407  /// Build clause with number of variables \a N.
3408  ///
3409  /// \param StartLoc Starting location of the clause.
3410  /// \param LParenLoc Location of '('.
3411  /// \param EndLoc Ending location of the clause.
3412  /// \param N Number of the variables in the clause.
3413  OMPFlushClause(SourceLocation StartLocSourceLocation LParenLoc,
3414                 SourceLocation EndLocunsigned N)
3415      : OMPVarListClause<OMPFlushClause>(OMPC_flush, StartLoc, LParenLoc,
3416                                         EndLoc, N) {}
3417
3418  /// Build an empty clause.
3419  ///
3420  /// \param N Number of variables.
3421  explicit OMPFlushClause(unsigned N)
3422      : OMPVarListClause<OMPFlushClause>(OMPC_flush, SourceLocation(),
3423                                         SourceLocation(), SourceLocation(),
3424                                         N) {}
3425
3426public:
3427  /// Creates clause with a list of variables \a VL.
3428  ///
3429  /// \param C AST context.
3430  /// \param StartLoc Starting location of the clause.
3431  /// \param LParenLoc Location of '('.
3432  /// \param EndLoc Ending location of the clause.
3433  /// \param VL List of references to the variables.
3434  static OMPFlushClause *Create(const ASTContext &CSourceLocation StartLoc,
3435                                SourceLocation LParenLocSourceLocation EndLoc,
3436                                ArrayRef<Expr *> VL);
3437
3438  /// Creates an empty clause with \a N variables.
3439  ///
3440  /// \param C AST context.
3441  /// \param N The number of variables.
3442  static OMPFlushClause *CreateEmpty(const ASTContext &Cunsigned N);
3443
3444  child_range children() {
3445    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3446                       reinterpret_cast<Stmt **>(varlist_end()));
3447  }
3448
3449  static bool classof(const OMPClause *T) {
3450    return T->getClauseKind() == OMPC_flush;
3451  }
3452};
3453
3454/// This represents implicit clause 'depend' for the '#pragma omp task'
3455/// directive.
3456///
3457/// \code
3458/// #pragma omp task depend(in:a,b)
3459/// \endcode
3460/// In this example directive '#pragma omp task' with clause 'depend' with the
3461/// variables 'a' and 'b' with dependency 'in'.
3462class OMPDependClause final
3463    : public OMPVarListClause<OMPDependClause>,
3464      private llvm::TrailingObjects<OMPDependClause, Expr *> {
3465  friend class OMPClauseReader;
3466  friend OMPVarListClause;
3467  friend TrailingObjects;
3468
3469  /// Dependency type (one of in, out, inout).
3470  OpenMPDependClauseKind DepKind = OMPC_DEPEND_unknown;
3471
3472  /// Dependency type location.
3473  SourceLocation DepLoc;
3474
3475  /// Colon location.
3476  SourceLocation ColonLoc;
3477
3478  /// Number of loops, associated with the depend clause.
3479  unsigned NumLoops = 0;
3480
3481  /// Build clause with number of variables \a N.
3482  ///
3483  /// \param StartLoc Starting location of the clause.
3484  /// \param LParenLoc Location of '('.
3485  /// \param EndLoc Ending location of the clause.
3486  /// \param N Number of the variables in the clause.
3487  /// \param NumLoops Number of loops that is associated with this depend
3488  /// clause.
3489  OMPDependClause(SourceLocation StartLocSourceLocation LParenLoc,
3490                  SourceLocation EndLocunsigned Nunsigned NumLoops)
3491      : OMPVarListClause<OMPDependClause>(OMPC_depend, StartLoc, LParenLoc,
3492                                          EndLoc, N), NumLoops(NumLoops) {}
3493
3494  /// Build an empty clause.
3495  ///
3496  /// \param N Number of variables.
3497  /// \param NumLoops Number of loops that is associated with this depend
3498  /// clause.
3499  explicit OMPDependClause(unsigned Nunsigned NumLoops)
3500      : OMPVarListClause<OMPDependClause>(OMPC_depend, SourceLocation(),
3501                                          SourceLocation(), SourceLocation(),
3502                                          N),
3503        NumLoops(NumLoops) {}
3504
3505  /// Set dependency kind.
3506  void setDependencyKind(OpenMPDependClauseKind K) { DepKind = K; }
3507
3508  /// Set dependency kind and its location.
3509  void setDependencyLoc(SourceLocation Loc) { DepLoc = Loc; }
3510
3511  /// Set colon location.
3512  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
3513
3514public:
3515  /// Creates clause with a list of variables \a VL.
3516  ///
3517  /// \param C AST context.
3518  /// \param StartLoc Starting location of the clause.
3519  /// \param LParenLoc Location of '('.
3520  /// \param EndLoc Ending location of the clause.
3521  /// \param DepKind Dependency type.
3522  /// \param DepLoc Location of the dependency type.
3523  /// \param ColonLoc Colon location.
3524  /// \param VL List of references to the variables.
3525  /// \param NumLoops Number of loops that is associated with this depend
3526  /// clause.
3527  static OMPDependClause *Create(const ASTContext &CSourceLocation StartLoc,
3528                                 SourceLocation LParenLoc,
3529                                 SourceLocation EndLoc,
3530                                 OpenMPDependClauseKind DepKind,
3531                                 SourceLocation DepLocSourceLocation ColonLoc,
3532                                 ArrayRef<Expr *> VLunsigned NumLoops);
3533
3534  /// Creates an empty clause with \a N variables.
3535  ///
3536  /// \param C AST context.
3537  /// \param N The number of variables.
3538  /// \param NumLoops Number of loops that is associated with this depend
3539  /// clause.
3540  static OMPDependClause *CreateEmpty(const ASTContext &Cunsigned N,
3541                                      unsigned NumLoops);
3542
3543  /// Get dependency type.
3544  OpenMPDependClauseKind getDependencyKind() const { return DepKind; }
3545
3546  /// Get dependency type location.
3547  SourceLocation getDependencyLoc() const { return DepLoc; }
3548
3549  /// Get colon location.
3550  SourceLocation getColonLoc() const { return ColonLoc; }
3551
3552  /// Get number of loops associated with the clause.
3553  unsigned getNumLoops() const { return NumLoops; }
3554
3555  /// Set the loop data for the depend clauses with 'sink|source' kind of
3556  /// dependency.
3557  void setLoopData(unsigned NumLoopExpr *Cnt);
3558
3559  /// Get the loop data.
3560  Expr *getLoopData(unsigned NumLoop);
3561  const Expr *getLoopData(unsigned NumLoopconst;
3562
3563  child_range children() {
3564    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
3565                       reinterpret_cast<Stmt **>(varlist_end()));
3566  }
3567
3568  static bool classof(const OMPClause *T) {
3569    return T->getClauseKind() == OMPC_depend;
3570  }
3571};
3572
3573/// This represents 'device' clause in the '#pragma omp ...'
3574/// directive.
3575///
3576/// \code
3577/// #pragma omp target device(a)
3578/// \endcode
3579/// In this example directive '#pragma omp target' has clause 'device'
3580/// with single expression 'a'.
3581class OMPDeviceClause : public OMPClausepublic OMPClauseWithPreInit {
3582  friend class OMPClauseReader;
3583
3584  /// Location of '('.
3585  SourceLocation LParenLoc;
3586
3587  /// Device number.
3588  Stmt *Device = nullptr;
3589
3590  /// Set the device number.
3591  ///
3592  /// \param E Device number.
3593  void setDevice(Expr *E) { Device = E; }
3594
3595public:
3596  /// Build 'device' clause.
3597  ///
3598  /// \param E Expression associated with this clause.
3599  /// \param CaptureRegion Innermost OpenMP region where expressions in this
3600  /// clause must be captured.
3601  /// \param StartLoc Starting location of the clause.
3602  /// \param LParenLoc Location of '('.
3603  /// \param EndLoc Ending location of the clause.
3604  OMPDeviceClause(Expr *EStmt *HelperEOpenMPDirectiveKind CaptureRegion,
3605                  SourceLocation StartLocSourceLocation LParenLoc,
3606                  SourceLocation EndLoc)
3607      : OMPClause(OMPC_deviceStartLocEndLoc), OMPClauseWithPreInit(this),
3608        LParenLoc(LParenLoc), Device(E) {
3609    setPreInitStmt(HelperECaptureRegion);
3610  }
3611
3612  /// Build an empty clause.
3613  OMPDeviceClause()
3614      : OMPClause(OMPC_deviceSourceLocation(), SourceLocation()),
3615        OMPClauseWithPreInit(this) {}
3616
3617  /// Sets the location of '('.
3618  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
3619
3620  /// Returns the location of '('.
3621  SourceLocation getLParenLoc() const { return LParenLoc; }
3622
3623  /// Return device number.
3624  Expr *getDevice() { return cast<Expr>(Device); }
3625
3626  /// Return device number.
3627  Expr *getDevice() const { return cast<Expr>(Device); }
3628
3629  child_range children() { return child_range(&Device, &Device + 1); }
3630
3631  static bool classof(const OMPClause *T) {
3632    return T->getClauseKind() == OMPC_device;
3633  }
3634};
3635
3636/// This represents 'threads' clause in the '#pragma omp ...' directive.
3637///
3638/// \code
3639/// #pragma omp ordered threads
3640/// \endcode
3641/// In this example directive '#pragma omp ordered' has simple 'threads' clause.
3642class OMPThreadsClause : public OMPClause {
3643public:
3644  /// Build 'threads' clause.
3645  ///
3646  /// \param StartLoc Starting location of the clause.
3647  /// \param EndLoc Ending location of the clause.
3648  OMPThreadsClause(SourceLocation StartLocSourceLocation EndLoc)
3649      : OMPClause(OMPC_threadsStartLocEndLoc) {}
3650
3651  /// Build an empty clause.
3652  OMPThreadsClause()
3653      : OMPClause(OMPC_threadsSourceLocation(), SourceLocation()) {}
3654
3655  child_range children() {
3656    return child_range(child_iterator(), child_iterator());
3657  }
3658
3659  static bool classof(const OMPClause *T) {
3660    return T->getClauseKind() == OMPC_threads;
3661  }
3662};
3663
3664/// This represents 'simd' clause in the '#pragma omp ...' directive.
3665///
3666/// \code
3667/// #pragma omp ordered simd
3668/// \endcode
3669/// In this example directive '#pragma omp ordered' has simple 'simd' clause.
3670class OMPSIMDClause : public OMPClause {
3671public:
3672  /// Build 'simd' clause.
3673  ///
3674  /// \param StartLoc Starting location of the clause.
3675  /// \param EndLoc Ending location of the clause.
3676  OMPSIMDClause(SourceLocation StartLocSourceLocation EndLoc)
3677      : OMPClause(OMPC_simdStartLocEndLoc) {}
3678
3679  /// Build an empty clause.
3680  OMPSIMDClause() : OMPClause(OMPC_simdSourceLocation(), SourceLocation()) {}
3681
3682  child_range children() {
3683    return child_range(child_iterator(), child_iterator());
3684  }
3685
3686  static bool classof(const OMPClause *T) {
3687    return T->getClauseKind() == OMPC_simd;
3688  }
3689};
3690
3691/// Struct that defines common infrastructure to handle mappable
3692/// expressions used in OpenMP clauses.
3693class OMPClauseMappableExprCommon {
3694public:
3695  /// Class that represents a component of a mappable expression. E.g.
3696  /// for an expression S.a, the first component is a declaration reference
3697  /// expression associated with 'S' and the second is a member expression
3698  /// associated with the field declaration 'a'. If the expression is an array
3699  /// subscript it may not have any associated declaration. In that case the
3700  /// associated declaration is set to nullptr.
3701  class MappableComponent {
3702    /// Expression associated with the component.
3703    Expr *AssociatedExpression = nullptr;
3704
3705    /// Declaration associated with the declaration. If the component does
3706    /// not have a declaration (e.g. array subscripts or section), this is set
3707    /// to nullptr.
3708    ValueDecl *AssociatedDeclaration = nullptr;
3709
3710  public:
3711    explicit MappableComponent() = default;
3712    explicit MappableComponent(Expr *AssociatedExpression,
3713                               ValueDecl *AssociatedDeclaration)
3714        : AssociatedExpression(AssociatedExpression),
3715          AssociatedDeclaration(
3716              AssociatedDeclaration
3717                  ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl())
3718                  : nullptr) {}
3719
3720    Expr *getAssociatedExpression() const { return AssociatedExpression; }
3721
3722    ValueDecl *getAssociatedDeclaration() const {
3723      return AssociatedDeclaration;
3724    }
3725  };
3726
3727  // List of components of an expression. This first one is the whole
3728  // expression and the last one is the base expression.
3729  using MappableExprComponentList = SmallVector<MappableComponent8>;
3730  using MappableExprComponentListRef = ArrayRef<MappableComponent>;
3731
3732  // List of all component lists associated to the same base declaration.
3733  // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
3734  // their component list but the same base declaration 'S'.
3735  using MappableExprComponentLists = SmallVector<MappableExprComponentList8>;
3736  using MappableExprComponentListsRef = ArrayRef<MappableExprComponentList>;
3737
3738protected:
3739  // Return the total number of elements in a list of component lists.
3740  static unsigned
3741  getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists);
3742
3743  // Return the total number of elements in a list of declarations. All
3744  // declarations are expected to be canonical.
3745  static unsigned
3746  getUniqueDeclarationsTotalNumber(ArrayRef<const ValueDecl *> Declarations);
3747};
3748
3749/// This structure contains all sizes needed for by an
3750/// OMPMappableExprListClause.
3751struct OMPMappableExprListSizeTy {
3752  /// Number of expressions listed.
3753  unsigned NumVars;
3754  /// Number of unique base declarations.
3755  unsigned NumUniqueDeclarations;
3756  /// Number of component lists.
3757  unsigned NumComponentLists;
3758  /// Total number of expression components.
3759  unsigned NumComponents;
3760  OMPMappableExprListSizeTy() = default;
3761  OMPMappableExprListSizeTy(unsigned NumVarsunsigned NumUniqueDeclarations,
3762                            unsigned NumComponentListsunsigned NumComponents)
3763      : NumVars(NumVars), NumUniqueDeclarations(NumUniqueDeclarations),
3764        NumComponentLists(NumComponentLists), NumComponents(NumComponents) {}
3765};
3766
3767/// This represents clauses with a list of expressions that are mappable.
3768/// Examples of these clauses are 'map' in
3769/// '#pragma omp target [enter|exit] [data]...' directives, and  'to' and 'from
3770/// in '#pragma omp target update...' directives.
3771template <class T>
3772class OMPMappableExprListClause : public OMPVarListClause<T>,
3773                                  public OMPClauseMappableExprCommon {
3774  friend class OMPClauseReader;
3775
3776  /// Number of unique declarations in this clause.
3777  unsigned NumUniqueDeclarations;
3778
3779  /// Number of component lists in this clause.
3780  unsigned NumComponentLists;
3781
3782  /// Total number of components in this clause.
3783  unsigned NumComponents;
3784
3785  /// C++ nested name specifier for the associated user-defined mapper.
3786  NestedNameSpecifierLoc MapperQualifierLoc;
3787
3788  /// The associated user-defined mapper identifier information.
3789  DeclarationNameInfo MapperIdInfo;
3790
3791protected:
3792  /// Build a clause for \a NumUniqueDeclarations declarations, \a
3793  /// NumComponentLists total component lists, and \a NumComponents total
3794  /// components.
3795  ///
3796  /// \param K Kind of the clause.
3797  /// \param Locs Locations needed to build a mappable clause. It includes 1)
3798  /// StartLoc: starting location of the clause (the clause keyword); 2)
3799  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
3800  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
3801  /// NumVars: number of expressions listed in this clause; 2)
3802  /// NumUniqueDeclarations: number of unique base declarations in this clause;
3803  /// 3) NumComponentLists: number of component lists in this clause; and 4)
3804  /// NumComponents: total number of expression components in the clause.
3805  /// \param MapperQualifierLocPtr C++ nested name specifier for the associated
3806  /// user-defined mapper.
3807  /// \param MapperIdInfoPtr The identifier of associated user-defined mapper.
3808  OMPMappableExprListClause(
3809      OpenMPClauseKind Kconst OMPVarListLocTy &Locs,
3810      const OMPMappableExprListSizeTy &Sizes,
3811      NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr,
3812      DeclarationNameInfo *MapperIdInfoPtr = nullptr)
3813      : OMPVarListClause<T>(KLocs.StartLocLocs.LParenLocLocs.EndLoc,
3814                            Sizes.NumVars),
3815        NumUniqueDeclarations(Sizes.NumUniqueDeclarations),
3816        NumComponentLists(Sizes.NumComponentLists),
3817        NumComponents(Sizes.NumComponents) {
3818    if (MapperQualifierLocPtr)
3819      MapperQualifierLoc = *MapperQualifierLocPtr;
3820    if (MapperIdInfoPtr)
3821      MapperIdInfo = *MapperIdInfoPtr;
3822  }
3823
3824  /// Get the unique declarations that are in the trailing objects of the
3825  /// class.
3826  MutableArrayRef<ValueDecl *> getUniqueDeclsRef() {
3827    return MutableArrayRef<ValueDecl *>(
3828        static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(),
3829        NumUniqueDeclarations);
3830  }
3831
3832  /// Get the unique declarations that are in the trailing objects of the
3833  /// class.
3834  ArrayRef<ValueDecl *> getUniqueDeclsRef() const {
3835    return ArrayRef<ValueDecl *>(
3836        static_cast<const T *>(this)
3837            ->template getTrailingObjects<ValueDecl *>(),
3838        NumUniqueDeclarations);
3839  }
3840
3841  /// Set the unique declarations that are in the trailing objects of the
3842  /// class.
3843  void setUniqueDecls(ArrayRef<ValueDecl *> UDs) {
3844     (0) . __assert_fail ("UDs.size() == NumUniqueDeclarations && \"Unexpected amount of unique declarations.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3845, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(UDs.size() == NumUniqueDeclarations &&
3845 (0) . __assert_fail ("UDs.size() == NumUniqueDeclarations && \"Unexpected amount of unique declarations.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3845, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected amount of unique declarations.");
3846    std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin());
3847  }
3848
3849  /// Get the number of lists per declaration that are in the trailing
3850  /// objects of the class.
3851  MutableArrayRef<unsignedgetDeclNumListsRef() {
3852    return MutableArrayRef<unsigned>(
3853        static_cast<T *>(this)->template getTrailingObjects<unsigned>(),
3854        NumUniqueDeclarations);
3855  }
3856
3857  /// Get the number of lists per declaration that are in the trailing
3858  /// objects of the class.
3859  ArrayRef<unsignedgetDeclNumListsRef() const {
3860    return ArrayRef<unsigned>(
3861        static_cast<const T *>(this)->template getTrailingObjects<unsigned>(),
3862        NumUniqueDeclarations);
3863  }
3864
3865  /// Set the number of lists per declaration that are in the trailing
3866  /// objects of the class.
3867  void setDeclNumLists(ArrayRef<unsignedDNLs) {
3868     (0) . __assert_fail ("DNLs.size() == NumUniqueDeclarations && \"Unexpected amount of list numbers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3869, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(DNLs.size() == NumUniqueDeclarations &&
3869 (0) . __assert_fail ("DNLs.size() == NumUniqueDeclarations && \"Unexpected amount of list numbers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3869, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected amount of list numbers.");
3870    std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin());
3871  }
3872
3873  /// Get the cumulative component lists sizes that are in the trailing
3874  /// objects of the class. They are appended after the number of lists.
3875  MutableArrayRef<unsignedgetComponentListSizesRef() {
3876    return MutableArrayRef<unsigned>(
3877        static_cast<T *>(this)->template getTrailingObjects<unsigned>() +
3878            NumUniqueDeclarations,
3879        NumComponentLists);
3880  }
3881
3882  /// Get the cumulative component lists sizes that are in the trailing
3883  /// objects of the class. They are appended after the number of lists.
3884  ArrayRef<unsignedgetComponentListSizesRef() const {
3885    return ArrayRef<unsigned>(
3886        static_cast<const T *>(this)->template getTrailingObjects<unsigned>() +
3887            NumUniqueDeclarations,
3888        NumComponentLists);
3889  }
3890
3891  /// Set the cumulative component lists sizes that are in the trailing
3892  /// objects of the class.
3893  void setComponentListSizes(ArrayRef<unsignedCLSs) {
3894     (0) . __assert_fail ("CLSs.size() == NumComponentLists && \"Unexpected amount of component lists.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3895, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(CLSs.size() == NumComponentLists &&
3895 (0) . __assert_fail ("CLSs.size() == NumComponentLists && \"Unexpected amount of component lists.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3895, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected amount of component lists.");
3896    std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin());
3897  }
3898
3899  /// Get the components that are in the trailing objects of the class.
3900  MutableArrayRef<MappableComponentgetComponentsRef() {
3901    return MutableArrayRef<MappableComponent>(
3902        static_cast<T *>(this)
3903            ->template getTrailingObjects<MappableComponent>(),
3904        NumComponents);
3905  }
3906
3907  /// Get the components that are in the trailing objects of the class.
3908  ArrayRef<MappableComponentgetComponentsRef() const {
3909    return ArrayRef<MappableComponent>(
3910        static_cast<const T *>(this)
3911            ->template getTrailingObjects<MappableComponent>(),
3912        NumComponents);
3913  }
3914
3915  /// Set the components that are in the trailing objects of the class.
3916  /// This requires the list sizes so that it can also fill the original
3917  /// expressions, which are the first component of each list.
3918  void setComponents(ArrayRef<MappableComponentComponents,
3919                     ArrayRef<unsignedCLSs) {
3920     (0) . __assert_fail ("Components.size() == NumComponents && \"Unexpected amount of component lists.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3921, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Components.size() == NumComponents &&
3921 (0) . __assert_fail ("Components.size() == NumComponents && \"Unexpected amount of component lists.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3921, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected amount of component lists.");
3922     (0) . __assert_fail ("CLSs.size() == NumComponentLists && \"Unexpected amount of list sizes.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3923, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(CLSs.size() == NumComponentLists &&
3923 (0) . __assert_fail ("CLSs.size() == NumComponentLists && \"Unexpected amount of list sizes.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3923, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected amount of list sizes.");
3924    std::copy(Components.begin(), Components.end(), getComponentsRef().begin());
3925  }
3926
3927  /// Fill the clause information from the list of declarations and
3928  /// associated component lists.
3929  void setClauseInfo(ArrayRef<ValueDecl *> Declarations,
3930                     MappableExprComponentListsRef ComponentLists) {
3931    // Perform some checks to make sure the data sizes are consistent with the
3932    // information available when the clause was created.
3933     (0) . __assert_fail ("getUniqueDeclarationsTotalNumber(Declarations) == NumUniqueDeclarations && \"Unexpected number of mappable expression info entries!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3935, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getUniqueDeclarationsTotalNumber(Declarations) ==
3934 (0) . __assert_fail ("getUniqueDeclarationsTotalNumber(Declarations) == NumUniqueDeclarations && \"Unexpected number of mappable expression info entries!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3935, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">               NumUniqueDeclarations &&
3935 (0) . __assert_fail ("getUniqueDeclarationsTotalNumber(Declarations) == NumUniqueDeclarations && \"Unexpected number of mappable expression info entries!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3935, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected number of mappable expression info entries!");
3936     (0) . __assert_fail ("getComponentsTotalNumber(ComponentLists) == NumComponents && \"Unexpected total number of components!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3937, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getComponentsTotalNumber(ComponentLists) == NumComponents &&
3937 (0) . __assert_fail ("getComponentsTotalNumber(ComponentLists) == NumComponents && \"Unexpected total number of components!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3937, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected total number of components!");
3938     (0) . __assert_fail ("Declarations.size() == ComponentLists.size() && \"Declaration and component lists size is not consistent!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3939, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Declarations.size() == ComponentLists.size() &&
3939 (0) . __assert_fail ("Declarations.size() == ComponentLists.size() && \"Declaration and component lists size is not consistent!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3939, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Declaration and component lists size is not consistent!");
3940     (0) . __assert_fail ("Declarations.size() == NumComponentLists && \"Unexpected declaration and component lists size!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3941, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Declarations.size() == NumComponentLists &&
3941 (0) . __assert_fail ("Declarations.size() == NumComponentLists && \"Unexpected declaration and component lists size!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3941, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected declaration and component lists size!");
3942
3943    // Organize the components by declaration and retrieve the original
3944    // expression. Original expressions are always the first component of the
3945    // mappable component list.
3946    llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>>
3947        ComponentListMap;
3948    {
3949      auto CI = ComponentLists.begin();
3950      for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE;
3951           ++DI, ++CI) {
3952         (0) . __assert_fail ("!CI->empty() && \"Invalid component list!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 3952, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!CI->empty() && "Invalid component list!");
3953        ComponentListMap[*DI].push_back(*CI);
3954      }
3955    }
3956
3957    // Iterators of the target storage.
3958    auto UniqueDeclarations = getUniqueDeclsRef();
3959    auto UDI = UniqueDeclarations.begin();
3960
3961    auto DeclNumLists = getDeclNumListsRef();
3962    auto DNLI = DeclNumLists.begin();
3963
3964    auto ComponentListSizes = getComponentListSizesRef();
3965    auto CLSI = ComponentListSizes.begin();
3966
3967    auto Components = getComponentsRef();
3968    auto CI = Components.begin();
3969
3970    // Variable to compute the accumulation of the number of components.
3971    unsigned PrevSize = 0u;
3972
3973    // Scan all the declarations and associated component lists.
3974    for (auto &M : ComponentListMap) {
3975      // The declaration.
3976      auto *D = M.first;
3977      // The component lists.
3978      auto CL = M.second;
3979
3980      // Initialize the entry.
3981      *UDI = D;
3982      ++UDI;
3983
3984      *DNLI = CL.size();
3985      ++DNLI;
3986
3987      // Obtain the cumulative sizes and concatenate all the components in the
3988      // reserved storage.
3989      for (auto C : CL) {
3990        // Accumulate with the previous size.
3991        PrevSize += C.size();
3992
3993        // Save the size.
3994        *CLSI = PrevSize;
3995        ++CLSI;
3996
3997        // Append components after the current components iterator.
3998        CI = std::copy(C.begin(), C.end(), CI);
3999      }
4000    }
4001  }
4002
4003  /// Set the nested name specifier of associated user-defined mapper.
4004  void setMapperQualifierLoc(NestedNameSpecifierLoc NNSL) {
4005    MapperQualifierLoc = NNSL;
4006  }
4007
4008  /// Set the name of associated user-defined mapper.
4009  void setMapperIdInfo(DeclarationNameInfo MapperId) {
4010    MapperIdInfo = MapperId;
4011  }
4012
4013  /// Get the user-defined mapper references that are in the trailing objects of
4014  /// the class.
4015  MutableArrayRef<Expr *> getUDMapperRefs() {
4016    return llvm::makeMutableArrayRef<Expr *>(
4017        static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
4018            OMPVarListClause<T>::varlist_size(),
4019        OMPVarListClause<T>::varlist_size());
4020  }
4021
4022  /// Get the user-defined mappers references that are in the trailing objects
4023  /// of the class.
4024  ArrayRef<Expr *> getUDMapperRefs() const {
4025    return llvm::makeArrayRef<Expr *>(
4026        static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
4027            OMPVarListClause<T>::varlist_size(),
4028        OMPVarListClause<T>::varlist_size());
4029  }
4030
4031  /// Set the user-defined mappers that are in the trailing objects of the
4032  /// class.
4033  void setUDMapperRefs(ArrayRef<Expr *> DMDs) {
4034     (0) . __assert_fail ("DMDs.size() == OMPVarListClause..varlist_size() && \"Unexpected number of user-defined mappers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4035, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(DMDs.size() == OMPVarListClause<T>::varlist_size() &&
4035 (0) . __assert_fail ("DMDs.size() == OMPVarListClause..varlist_size() && \"Unexpected number of user-defined mappers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4035, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected number of user-defined mappers.");
4036    std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin());
4037  }
4038
4039public:
4040  /// Return the number of unique base declarations in this clause.
4041  unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; }
4042
4043  /// Return the number of lists derived from the clause expressions.
4044  unsigned getTotalComponentListNum() const { return NumComponentLists; }
4045
4046  /// Return the total number of components in all lists derived from the
4047  /// clause.
4048  unsigned getTotalComponentsNum() const { return NumComponents; }
4049
4050  /// Gets the nested name specifier for associated user-defined mapper.
4051  NestedNameSpecifierLoc getMapperQualifierLoc() const {
4052    return MapperQualifierLoc;
4053  }
4054
4055  /// Gets the name info for associated user-defined mapper.
4056  const DeclarationNameInfo &getMapperIdInfo() const { return MapperIdInfo; }
4057
4058  /// Iterator that browse the components by lists. It also allows
4059  /// browsing components of a single declaration.
4060  class const_component_lists_iterator
4061      : public llvm::iterator_adaptor_base<
4062            const_component_lists_iterator,
4063            MappableExprComponentListRef::const_iterator,
4064            std::forward_iterator_tag, MappableComponent, ptrdiff_t,
4065            MappableComponent, MappableComponent> {
4066    // The declaration the iterator currently refers to.
4067    ArrayRef<ValueDecl *>::iterator DeclCur;
4068
4069    // The list number associated with the current declaration.
4070    ArrayRef<unsigned>::iterator NumListsCur;
4071
4072    // Remaining lists for the current declaration.
4073    unsigned RemainingLists = 0;
4074
4075    // The cumulative size of the previous list, or zero if there is no previous
4076    // list.
4077    unsigned PrevListSize = 0;
4078
4079    // The cumulative sizes of the current list - it will delimit the remaining
4080    // range of interest.
4081    ArrayRef<unsigned>::const_iterator ListSizeCur;
4082    ArrayRef<unsigned>::const_iterator ListSizeEnd;
4083
4084    // Iterator to the end of the components storage.
4085    MappableExprComponentListRef::const_iterator End;
4086
4087  public:
4088    /// Construct an iterator that scans all lists.
4089    explicit const_component_lists_iterator(
4090        ArrayRef<ValueDecl *> UniqueDeclsArrayRef<unsignedDeclsListNum,
4091        ArrayRef<unsignedCumulativeListSizes,
4092        MappableExprComponentListRef Components)
4093        : const_component_lists_iterator::iterator_adaptor_base(
4094              Components.begin()),
4095          DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()),
4096          ListSizeCur(CumulativeListSizes.begin()),
4097          ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) {
4098       (0) . __assert_fail ("UniqueDecls.size() == DeclsListNum.size() && \"Inconsistent number of declarations and list sizes!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4099, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(UniqueDecls.size() == DeclsListNum.size() &&
4099 (0) . __assert_fail ("UniqueDecls.size() == DeclsListNum.size() && \"Inconsistent number of declarations and list sizes!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4099, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">             "Inconsistent number of declarations and list sizes!");
4100      if (!DeclsListNum.empty())
4101        RemainingLists = *NumListsCur;
4102    }
4103
4104    /// Construct an iterator that scan lists for a given declaration \a
4105    /// Declaration.
4106    explicit const_component_lists_iterator(
4107        const ValueDecl *DeclarationArrayRef<ValueDecl *> UniqueDecls,
4108        ArrayRef<unsignedDeclsListNumArrayRef<unsignedCumulativeListSizes,
4109        MappableExprComponentListRef Components)
4110        : const_component_lists_iterator(UniqueDecls, DeclsListNum,
4111                                         CumulativeListSizes, Components) {
4112      // Look for the desired declaration. While we are looking for it, we
4113      // update the state so that we know the component where a given list
4114      // starts.
4115      for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) {
4116        if (*DeclCur == Declaration)
4117          break;
4118
4119         (0) . __assert_fail ("*NumListsCur > 0 && \"No lists associated with declaration??\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4119, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(*NumListsCur > 0 && "No lists associated with declaration??");
4120
4121        // Skip the lists associated with the current declaration, but save the
4122        // last list size that was skipped.
4123        std::advance(ListSizeCur, *NumListsCur - 1);
4124        PrevListSize = *ListSizeCur;
4125        ++ListSizeCur;
4126      }
4127
4128      // If we didn't find any declaration, advance the iterator to after the
4129      // last component and set remaining lists to zero.
4130      if (ListSizeCur == CumulativeListSizes.end()) {
4131        this->I = End;
4132        RemainingLists = 0u;
4133        return;
4134      }
4135
4136      // Set the remaining lists with the total number of lists of the current
4137      // declaration.
4138      RemainingLists = *NumListsCur;
4139
4140      // Adjust the list size end iterator to the end of the relevant range.
4141      ListSizeEnd = ListSizeCur;
4142      std::advance(ListSizeEnd, RemainingLists);
4143
4144      // Given that the list sizes are cumulative, the index of the component
4145      // that start the list is the size of the previous list.
4146      std::advance(this->I, PrevListSize);
4147    }
4148
4149    // Return the array with the current list. The sizes are cumulative, so the
4150    // array size is the difference between the current size and previous one.
4151    std::pair<const ValueDecl *, MappableExprComponentListRef>
4152    operator*() const {
4153       (0) . __assert_fail ("ListSizeCur != ListSizeEnd && \"Invalid iterator!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4153, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(ListSizeCur != ListSizeEnd && "Invalid iterator!");
4154      return std::make_pair(
4155          *DeclCur,
4156          MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize));
4157    }
4158    std::pair<const ValueDecl *, MappableExprComponentListRef>
4159    operator->() const {
4160      return **this;
4161    }
4162
4163    // Skip the components of the current list.
4164    const_component_lists_iterator &operator++() {
4165       (0) . __assert_fail ("ListSizeCur != ListSizeEnd && RemainingLists && \"Invalid iterator!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4166, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(ListSizeCur != ListSizeEnd && RemainingLists &&
4166 (0) . __assert_fail ("ListSizeCur != ListSizeEnd && RemainingLists && \"Invalid iterator!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4166, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">             "Invalid iterator!");
4167
4168      // If we don't have more lists just skip all the components. Otherwise,
4169      // advance the iterator by the number of components in the current list.
4170      if (std::next(ListSizeCur) == ListSizeEnd) {
4171        this->I = End;
4172        RemainingLists = 0;
4173      } else {
4174        std::advance(this->I, *ListSizeCur - PrevListSize);
4175        PrevListSize = *ListSizeCur;
4176
4177        // We are done with a declaration, move to the next one.
4178        if (!(--RemainingLists)) {
4179          ++DeclCur;
4180          ++NumListsCur;
4181          RemainingLists = *NumListsCur;
4182           (0) . __assert_fail ("RemainingLists && \"No lists in the following declaration??\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4182, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(RemainingLists && "No lists in the following declaration??");
4183        }
4184      }
4185
4186      ++ListSizeCur;
4187      return *this;
4188    }
4189  };
4190
4191  using const_component_lists_range =
4192      llvm::iterator_range<const_component_lists_iterator>;
4193
4194  /// Iterators for all component lists.
4195  const_component_lists_iterator component_lists_begin() const {
4196    return const_component_lists_iterator(
4197        getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(),
4198        getComponentsRef());
4199  }
4200  const_component_lists_iterator component_lists_end() const {
4201    return const_component_lists_iterator(
4202        ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(),
4203        MappableExprComponentListRef(getComponentsRef().end(),
4204                                     getComponentsRef().end()));
4205  }
4206  const_component_lists_range component_lists() const {
4207    return {component_lists_begin(), component_lists_end()};
4208  }
4209
4210  /// Iterators for component lists associated with the provided
4211  /// declaration.
4212  const_component_lists_iterator
4213  decl_component_lists_begin(const ValueDecl *VDconst {
4214    return const_component_lists_iterator(
4215        VD, getUniqueDeclsRef(), getDeclNumListsRef(),
4216        getComponentListSizesRef(), getComponentsRef());
4217  }
4218  const_component_lists_iterator decl_component_lists_end() const {
4219    return component_lists_end();
4220  }
4221  const_component_lists_range decl_component_lists(const ValueDecl *VD) const {
4222    return {decl_component_lists_begin(VD), decl_component_lists_end()};
4223  }
4224
4225  /// Iterators to access all the declarations, number of lists, list sizes, and
4226  /// components.
4227  using const_all_decls_iterator = ArrayRef<ValueDecl *>::iterator;
4228  using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>;
4229
4230  const_all_decls_range all_decls() const {
4231    auto A = getUniqueDeclsRef();
4232    return const_all_decls_range(A.begin(), A.end());
4233  }
4234
4235  using const_all_num_lists_iterator = ArrayRef<unsigned>::iterator;
4236  using const_all_num_lists_range =
4237      llvm::iterator_range<const_all_num_lists_iterator>;
4238
4239  const_all_num_lists_range all_num_lists() const {
4240    auto A = getDeclNumListsRef();
4241    return const_all_num_lists_range(A.begin(), A.end());
4242  }
4243
4244  using const_all_lists_sizes_iterator = ArrayRef<unsigned>::iterator;
4245  using const_all_lists_sizes_range =
4246      llvm::iterator_range<const_all_lists_sizes_iterator>;
4247
4248  const_all_lists_sizes_range all_lists_sizes() const {
4249    auto A = getComponentListSizesRef();
4250    return const_all_lists_sizes_range(A.begin(), A.end());
4251  }
4252
4253  using const_all_components_iterator = ArrayRef<MappableComponent>::iterator;
4254  using const_all_components_range =
4255      llvm::iterator_range<const_all_components_iterator>;
4256
4257  const_all_components_range all_components() const {
4258    auto A = getComponentsRef();
4259    return const_all_components_range(A.begin(), A.end());
4260  }
4261
4262  using mapperlist_iterator = MutableArrayRef<Expr *>::iterator;
4263  using mapperlist_const_iterator = ArrayRef<const Expr *>::iterator;
4264  using mapperlist_range = llvm::iterator_range<mapperlist_iterator>;
4265  using mapperlist_const_range =
4266      llvm::iterator_range<mapperlist_const_iterator>;
4267
4268  mapperlist_iterator mapperlist_begin() { return getUDMapperRefs().begin(); }
4269  mapperlist_iterator mapperlist_end() { return getUDMapperRefs().end(); }
4270  mapperlist_const_iterator mapperlist_begin() const {
4271    return getUDMapperRefs().begin();
4272  }
4273  mapperlist_const_iterator mapperlist_end() const {
4274    return getUDMapperRefs().end();
4275  }
4276  mapperlist_range mapperlists() {
4277    return mapperlist_range(mapperlist_begin(), mapperlist_end());
4278  }
4279  mapperlist_const_range mapperlists() const {
4280    return mapperlist_const_range(mapperlist_begin(), mapperlist_end());
4281  }
4282};
4283
4284/// This represents clause 'map' in the '#pragma omp ...'
4285/// directives.
4286///
4287/// \code
4288/// #pragma omp target map(a,b)
4289/// \endcode
4290/// In this example directive '#pragma omp target' has clause 'map'
4291/// with the variables 'a' and 'b'.
4292class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
4293                           private llvm::TrailingObjects<
4294                               OMPMapClause, Expr *, ValueDecl *, unsigned,
4295                               OMPClauseMappableExprCommon::MappableComponent> {
4296  friend class OMPClauseReader;
4297  friend OMPMappableExprListClause;
4298  friend OMPVarListClause;
4299  friend TrailingObjects;
4300
4301  /// Define the sizes of each trailing object array except the last one. This
4302  /// is required for TrailingObjects to work properly.
4303  size_t numTrailingObjects(OverloadToken<Expr *>) const {
4304    // There are varlist_size() of expressions, and varlist_size() of
4305    // user-defined mappers.
4306    return 2 * varlist_size();
4307  }
4308  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
4309    return getUniqueDeclarationsNum();
4310  }
4311  size_t numTrailingObjects(OverloadToken<unsigned>) const {
4312    return getUniqueDeclarationsNum() + getTotalComponentListNum();
4313  }
4314
4315public:
4316  /// Number of allowed map-type-modifiers.
4317  static constexpr unsigned NumberOfModifiers =
4318      OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1;
4319
4320private:
4321  /// Map-type-modifiers for the 'map' clause.
4322  OpenMPMapModifierKind MapTypeModifiers[NumberOfModifiers] = {
4323      OMPC_MAP_MODIFIER_unknownOMPC_MAP_MODIFIER_unknown,
4324      OMPC_MAP_MODIFIER_unknown};
4325
4326  /// Location of map-type-modifiers for the 'map' clause.
4327  SourceLocation MapTypeModifiersLoc[NumberOfModifiers];
4328
4329  /// Map type for the 'map' clause.
4330  OpenMPMapClauseKind MapType = OMPC_MAP_unknown;
4331
4332  /// Is this an implicit map type or not.
4333  bool MapTypeIsImplicit = false;
4334
4335  /// Location of the map type.
4336  SourceLocation MapLoc;
4337
4338  /// Colon location.
4339  SourceLocation ColonLoc;
4340
4341  /// Build a clause for \a NumVars listed expressions, \a
4342  /// NumUniqueDeclarations declarations, \a NumComponentLists total component
4343  /// lists, and \a NumComponents total expression components.
4344  ///
4345  /// \param MapModifiers Map-type-modifiers.
4346  /// \param MapModifiersLoc Locations of map-type-modifiers.
4347  /// \param MapperQualifierLoc C++ nested name specifier for the associated
4348  /// user-defined mapper.
4349  /// \param MapperIdInfo The identifier of associated user-defined mapper.
4350  /// \param MapType Map type.
4351  /// \param MapTypeIsImplicit Map type is inferred implicitly.
4352  /// \param MapLoc Location of the map type.
4353  /// \param Locs Locations needed to build a mappable clause. It includes 1)
4354  /// StartLoc: starting location of the clause (the clause keyword); 2)
4355  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
4356  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
4357  /// NumVars: number of expressions listed in this clause; 2)
4358  /// NumUniqueDeclarations: number of unique base declarations in this clause;
4359  /// 3) NumComponentLists: number of component lists in this clause; and 4)
4360  /// NumComponents: total number of expression components in the clause.
4361  explicit OMPMapClause(ArrayRef<OpenMPMapModifierKindMapModifiers,
4362                        ArrayRef<SourceLocationMapModifiersLoc,
4363                        NestedNameSpecifierLoc MapperQualifierLoc,
4364                        DeclarationNameInfo MapperIdInfo,
4365                        OpenMPMapClauseKind MapTypebool MapTypeIsImplicit,
4366                        SourceLocation MapLocconst OMPVarListLocTy &Locs,
4367                        const OMPMappableExprListSizeTy &Sizes)
4368      : OMPMappableExprListClause(OMPC_map, Locs, Sizes, &MapperQualifierLoc,
4369                                  &MapperIdInfo),
4370        MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {
4371     (0) . __assert_fail ("llvm..array_lengthof(MapTypeModifiers) == MapModifiers.size() && \"Unexpected number of map type modifiers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4372, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(llvm::array_lengthof(MapTypeModifiers) == MapModifiers.size() &&
4372 (0) . __assert_fail ("llvm..array_lengthof(MapTypeModifiers) == MapModifiers.size() && \"Unexpected number of map type modifiers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4372, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected number of map type modifiers.");
4373    llvm::copy(MapModifiers, std::begin(MapTypeModifiers));
4374
4375     (0) . __assert_fail ("llvm..array_lengthof(MapTypeModifiersLoc) == MapModifiersLoc.size() && \"Unexpected number of map type modifier locations.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4377, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(llvm::array_lengthof(MapTypeModifiersLoc) ==
4376 (0) . __assert_fail ("llvm..array_lengthof(MapTypeModifiersLoc) == MapModifiersLoc.size() && \"Unexpected number of map type modifier locations.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4377, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">               MapModifiersLoc.size() &&
4377 (0) . __assert_fail ("llvm..array_lengthof(MapTypeModifiersLoc) == MapModifiersLoc.size() && \"Unexpected number of map type modifier locations.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4377, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected number of map type modifier locations.");
4378    llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc));
4379  }
4380
4381  /// Build an empty clause.
4382  ///
4383  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
4384  /// NumVars: number of expressions listed in this clause; 2)
4385  /// NumUniqueDeclarations: number of unique base declarations in this clause;
4386  /// 3) NumComponentLists: number of component lists in this clause; and 4)
4387  /// NumComponents: total number of expression components in the clause.
4388  explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes)
4389      : OMPMappableExprListClause(OMPC_map, OMPVarListLocTy(), Sizes) {}
4390
4391  /// Set map-type-modifier for the clause.
4392  ///
4393  /// \param I index for map-type-modifier.
4394  /// \param T map-type-modifier for the clause.
4395  void setMapTypeModifier(unsigned IOpenMPMapModifierKind T) {
4396     (0) . __assert_fail ("I < NumberOfModifiers && \"Unexpected index to store map type modifier, exceeds array size.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4397, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < NumberOfModifiers &&
4397 (0) . __assert_fail ("I < NumberOfModifiers && \"Unexpected index to store map type modifier, exceeds array size.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4397, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Unexpected index to store map type modifier, exceeds array size.");
4398    MapTypeModifiers[I] = T;
4399  }
4400
4401  /// Set location for the map-type-modifier.
4402  ///
4403  /// \param I index for map-type-modifier location.
4404  /// \param TLoc map-type-modifier location.
4405  void setMapTypeModifierLoc(unsigned ISourceLocation TLoc) {
4406     (0) . __assert_fail ("I < NumberOfModifiers && \"Index to store map type modifier location exceeds array size.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4407, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < NumberOfModifiers &&
4407 (0) . __assert_fail ("I < NumberOfModifiers && \"Index to store map type modifier location exceeds array size.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4407, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Index to store map type modifier location exceeds array size.");
4408    MapTypeModifiersLoc[I] = TLoc;
4409  }
4410
4411  /// Set type for the clause.
4412  ///
4413  /// \param T Type for the clause.
4414  void setMapType(OpenMPMapClauseKind T) { MapType = T; }
4415
4416  /// Set type location.
4417  ///
4418  /// \param TLoc Type location.
4419  void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; }
4420
4421  /// Set colon location.
4422  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }
4423
4424public:
4425  /// Creates clause with a list of variables \a VL.
4426  ///
4427  /// \param C AST context.
4428  /// \param Locs Locations needed to build a mappable clause. It includes 1)
4429  /// StartLoc: starting location of the clause (the clause keyword); 2)
4430  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
4431  /// \param Vars The original expression used in the clause.
4432  /// \param Declarations Declarations used in the clause.
4433  /// \param ComponentLists Component lists used in the clause.
4434  /// \param UDMapperRefs References to user-defined mappers associated with
4435  /// expressions used in the clause.
4436  /// \param MapModifiers Map-type-modifiers.
4437  /// \param MapModifiersLoc Location of map-type-modifiers.
4438  /// \param UDMQualifierLoc C++ nested name specifier for the associated
4439  /// user-defined mapper.
4440  /// \param MapperId The identifier of associated user-defined mapper.
4441  /// \param Type Map type.
4442  /// \param TypeIsImplicit Map type is inferred implicitly.
4443  /// \param TypeLoc Location of the map type.
4444  static OMPMapClause *
4445  Create(const ASTContext &Cconst OMPVarListLocTy &Locs,
4446         ArrayRef<Expr *> VarsArrayRef<ValueDecl *> Declarations,
4447         MappableExprComponentListsRef ComponentLists,
4448         ArrayRef<Expr *> UDMapperRefs,
4449         ArrayRef<OpenMPMapModifierKindMapModifiers,
4450         ArrayRef<SourceLocationMapModifiersLoc,
4451         NestedNameSpecifierLoc UDMQualifierLocDeclarationNameInfo MapperId,
4452         OpenMPMapClauseKind Typebool TypeIsImplicitSourceLocation TypeLoc);
4453
4454  /// Creates an empty clause with the place for \a NumVars original
4455  /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists
4456  /// lists, and \a NumComponents expression components.
4457  ///
4458  /// \param C AST context.
4459  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
4460  /// NumVars: number of expressions listed in this clause; 2)
4461  /// NumUniqueDeclarations: number of unique base declarations in this clause;
4462  /// 3) NumComponentLists: number of component lists in this clause; and 4)
4463  /// NumComponents: total number of expression components in the clause.
4464  static OMPMapClause *CreateEmpty(const ASTContext &C,
4465                                   const OMPMappableExprListSizeTy &Sizes);
4466
4467  /// Fetches mapping kind for the clause.
4468  OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
4469
4470  /// Is this an implicit map type?
4471  /// We have to capture 'IsMapTypeImplicit' from the parser for more
4472  /// informative error messages.  It helps distinguish map(r) from
4473  /// map(tofrom: r), which is important to print more helpful error
4474  /// messages for some target directives.
4475  bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; }
4476
4477  /// Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
4478  ///
4479  /// \param Cnt index for map-type-modifier.
4480  OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY {
4481     (0) . __assert_fail ("Cnt < NumberOfModifiers && \"Requested modifier exceeds the total number of modifiers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4482, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Cnt < NumberOfModifiers &&
4482 (0) . __assert_fail ("Cnt < NumberOfModifiers && \"Requested modifier exceeds the total number of modifiers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4482, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Requested modifier exceeds the total number of modifiers.");
4483    return MapTypeModifiers[Cnt];
4484  }
4485
4486  /// Fetches the map-type-modifier location at 'Cnt' index of array of
4487  /// modifiers' locations.
4488  ///
4489  /// \param Cnt index for map-type-modifier location.
4490  SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY {
4491     (0) . __assert_fail ("Cnt < NumberOfModifiers && \"Requested modifier location exceeds total number of modifiers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4492, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Cnt < NumberOfModifiers &&
4492 (0) . __assert_fail ("Cnt < NumberOfModifiers && \"Requested modifier location exceeds total number of modifiers.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/OpenMPClause.h", 4492, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Requested modifier location exceeds total number of modifiers.");
4493    return MapTypeModifiersLoc[Cnt];
4494  }
4495
4496  /// Fetches ArrayRef of map-type-modifiers.
4497  ArrayRef<OpenMPMapModifierKind> getMapTypeModifiers() const LLVM_READONLY {
4498    return llvm::makeArrayRef(MapTypeModifiers);
4499  }
4500
4501  /// Fetches ArrayRef of location of map-type-modifiers.
4502  ArrayRef<SourceLocation> getMapTypeModifiersLoc() const LLVM_READONLY {
4503    return llvm::makeArrayRef(MapTypeModifiersLoc);
4504  }
4505
4506  /// Fetches location of clause mapping kind.
4507  SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; }
4508
4509  /// Get colon location.
4510  SourceLocation getColonLoc() const { return ColonLoc; }
4511
4512  child_range children() {
4513    return child_range(
4514        reinterpret_cast<Stmt **>(varlist_begin()),
4515        reinterpret_cast<Stmt **>(varlist_end()));
4516  }
4517
4518  static bool classof(const OMPClause *T) {
4519    return T->getClauseKind() == OMPC_map;
4520  }
4521};
4522
4523/// This represents 'num_teams' clause in the '#pragma omp ...'
4524/// directive.
4525///
4526/// \code
4527/// #pragma omp teams num_teams(n)
4528/// \endcode
4529/// In this example directive '#pragma omp teams' has clause 'num_teams'
4530/// with single expression 'n'.
4531class OMPNumTeamsClause : public OMPClausepublic OMPClauseWithPreInit {
4532  friend class OMPClauseReader;
4533
4534  /// Location of '('.
4535  SourceLocation LParenLoc;
4536
4537  /// NumTeams number.
4538  Stmt *NumTeams = nullptr;
4539
4540  /// Set the NumTeams number.
4541  ///
4542  /// \param E NumTeams number.
4543  void setNumTeams(Expr *E) { NumTeams = E; }
4544
4545public:
4546  /// Build 'num_teams' clause.
4547  ///
4548  /// \param E Expression associated with this clause.
4549  /// \param HelperE Helper Expression associated with this clause.
4550  /// \param CaptureRegion Innermost OpenMP region where expressions in this
4551  /// clause must be captured.
4552  /// \param StartLoc Starting location of the clause.
4553  /// \param LParenLoc Location of '('.
4554  /// \param EndLoc Ending location of the clause.
4555  OMPNumTeamsClause(Expr *EStmt *HelperEOpenMPDirectiveKind CaptureRegion,
4556                    SourceLocation StartLocSourceLocation LParenLoc,
4557                    SourceLocation EndLoc)
4558      : OMPClause(OMPC_num_teamsStartLocEndLoc), OMPClauseWithPreInit(this),
4559        LParenLoc(LParenLoc), NumTeams(E) {
4560    setPreInitStmt(HelperECaptureRegion);
4561  }
4562
4563  /// Build an empty clause.
4564  OMPNumTeamsClause()
4565      : OMPClause(OMPC_num_teamsSourceLocation(), SourceLocation()),
4566        OMPClauseWithPreInit(this) {}
4567
4568  /// Sets the location of '('.
4569  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4570
4571  /// Returns the location of '('.
4572  SourceLocation getLParenLoc() const { return LParenLoc; }
4573
4574  /// Return NumTeams number.
4575  Expr *getNumTeams() { return cast<Expr>(NumTeams); }
4576
4577  /// Return NumTeams number.
4578  Expr *getNumTeams() const { return cast<Expr>(NumTeams); }
4579
4580  child_range children() { return child_range(&NumTeams, &NumTeams + 1); }
4581
4582  static bool classof(const OMPClause *T) {
4583    return T->getClauseKind() == OMPC_num_teams;
4584  }
4585};
4586
4587/// This represents 'thread_limit' clause in the '#pragma omp ...'
4588/// directive.
4589///
4590/// \code
4591/// #pragma omp teams thread_limit(n)
4592/// \endcode
4593/// In this example directive '#pragma omp teams' has clause 'thread_limit'
4594/// with single expression 'n'.
4595class OMPThreadLimitClause : public OMPClausepublic OMPClauseWithPreInit {
4596  friend class OMPClauseReader;
4597
4598  /// Location of '('.
4599  SourceLocation LParenLoc;
4600
4601  /// ThreadLimit number.
4602  Stmt *ThreadLimit = nullptr;
4603
4604  /// Set the ThreadLimit number.
4605  ///
4606  /// \param E ThreadLimit number.
4607  void setThreadLimit(Expr *E) { ThreadLimit = E; }
4608
4609public:
4610  /// Build 'thread_limit' clause.
4611  ///
4612  /// \param E Expression associated with this clause.
4613  /// \param HelperE Helper Expression associated with this clause.
4614  /// \param CaptureRegion Innermost OpenMP region where expressions in this
4615  /// clause must be captured.
4616  /// \param StartLoc Starting location of the clause.
4617  /// \param LParenLoc Location of '('.
4618  /// \param EndLoc Ending location of the clause.
4619  OMPThreadLimitClause(Expr *EStmt *HelperE,
4620                       OpenMPDirectiveKind CaptureRegion,
4621                       SourceLocation StartLocSourceLocation LParenLoc,
4622                       SourceLocation EndLoc)
4623      : OMPClause(OMPC_thread_limitStartLocEndLoc),
4624        OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadLimit(E) {
4625    setPreInitStmt(HelperECaptureRegion);
4626  }
4627
4628  /// Build an empty clause.
4629  OMPThreadLimitClause()
4630      : OMPClause(OMPC_thread_limitSourceLocation(), SourceLocation()),
4631        OMPClauseWithPreInit(this) {}
4632
4633  /// Sets the location of '('.
4634  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4635
4636  /// Returns the location of '('.
4637  SourceLocation getLParenLoc() const { return LParenLoc; }
4638
4639  /// Return ThreadLimit number.
4640  Expr *getThreadLimit() { return cast<Expr>(ThreadLimit); }
4641
4642  /// Return ThreadLimit number.
4643  Expr *getThreadLimit() const { return cast<Expr>(ThreadLimit); }
4644
4645  child_range children() { return child_range(&ThreadLimit, &ThreadLimit + 1); }
4646
4647  static bool classof(const OMPClause *T) {
4648    return T->getClauseKind() == OMPC_thread_limit;
4649  }
4650};
4651
4652/// This represents 'priority' clause in the '#pragma omp ...'
4653/// directive.
4654///
4655/// \code
4656/// #pragma omp task priority(n)
4657/// \endcode
4658/// In this example directive '#pragma omp teams' has clause 'priority' with
4659/// single expression 'n'.
4660class OMPPriorityClause : public OMPClause {
4661  friend class OMPClauseReader;
4662
4663  /// Location of '('.
4664  SourceLocation LParenLoc;
4665
4666  /// Priority number.
4667  Stmt *Priority = nullptr;
4668
4669  /// Set the Priority number.
4670  ///
4671  /// \param E Priority number.
4672  void setPriority(Expr *E) { Priority = E; }
4673
4674public:
4675  /// Build 'priority' clause.
4676  ///
4677  /// \param E Expression associated with this clause.
4678  /// \param StartLoc Starting location of the clause.
4679  /// \param LParenLoc Location of '('.
4680  /// \param EndLoc Ending location of the clause.
4681  OMPPriorityClause(Expr *ESourceLocation StartLocSourceLocation LParenLoc,
4682                    SourceLocation EndLoc)
4683      : OMPClause(OMPC_priorityStartLocEndLoc), LParenLoc(LParenLoc),
4684        Priority(E) {}
4685
4686  /// Build an empty clause.
4687  OMPPriorityClause()
4688      : OMPClause(OMPC_prioritySourceLocation(), SourceLocation()) {}
4689
4690  /// Sets the location of '('.
4691  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4692
4693  /// Returns the location of '('.
4694  SourceLocation getLParenLoc() const { return LParenLoc; }
4695
4696  /// Return Priority number.
4697  Expr *getPriority() { return cast<Expr>(Priority); }
4698
4699  /// Return Priority number.
4700  Expr *getPriority() const { return cast<Expr>(Priority); }
4701
4702  child_range children() { return child_range(&Priority, &Priority + 1); }
4703
4704  static bool classof(const OMPClause *T) {
4705    return T->getClauseKind() == OMPC_priority;
4706  }
4707};
4708
4709/// This represents 'grainsize' clause in the '#pragma omp ...'
4710/// directive.
4711///
4712/// \code
4713/// #pragma omp taskloop grainsize(4)
4714/// \endcode
4715/// In this example directive '#pragma omp taskloop' has clause 'grainsize'
4716/// with single expression '4'.
4717class OMPGrainsizeClause : public OMPClause {
4718  friend class OMPClauseReader;
4719
4720  /// Location of '('.
4721  SourceLocation LParenLoc;
4722
4723  /// Safe iteration space distance.
4724  Stmt *Grainsize = nullptr;
4725
4726  /// Set safelen.
4727  void setGrainsize(Expr *Size) { Grainsize = Size; }
4728
4729public:
4730  /// Build 'grainsize' clause.
4731  ///
4732  /// \param Size Expression associated with this clause.
4733  /// \param StartLoc Starting location of the clause.
4734  /// \param EndLoc Ending location of the clause.
4735  OMPGrainsizeClause(Expr *SizeSourceLocation StartLoc,
4736                     SourceLocation LParenLocSourceLocation EndLoc)
4737      : OMPClause(OMPC_grainsizeStartLocEndLoc), LParenLoc(LParenLoc),
4738        Grainsize(Size) {}
4739
4740  /// Build an empty clause.
4741  explicit OMPGrainsizeClause()
4742      : OMPClause(OMPC_grainsizeSourceLocation(), SourceLocation()) {}
4743
4744  /// Sets the location of '('.
4745  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4746
4747  /// Returns the location of '('.
4748  SourceLocation getLParenLoc() const { return LParenLoc; }
4749
4750  /// Return safe iteration space distance.
4751  Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); }
4752
4753  child_range children() { return child_range(&Grainsize, &Grainsize + 1); }
4754
4755  static bool classof(const OMPClause *T) {
4756    return T->getClauseKind() == OMPC_grainsize;
4757  }
4758};
4759
4760/// This represents 'nogroup' clause in the '#pragma omp ...' directive.
4761///
4762/// \code
4763/// #pragma omp taskloop nogroup
4764/// \endcode
4765/// In this example directive '#pragma omp taskloop' has 'nogroup' clause.
4766class OMPNogroupClause : public OMPClause {
4767public:
4768  /// Build 'nogroup' clause.
4769  ///
4770  /// \param StartLoc Starting location of the clause.
4771  /// \param EndLoc Ending location of the clause.
4772  OMPNogroupClause(SourceLocation StartLocSourceLocation EndLoc)
4773      : OMPClause(OMPC_nogroupStartLocEndLoc) {}
4774
4775  /// Build an empty clause.
4776  OMPNogroupClause()
4777      : OMPClause(OMPC_nogroupSourceLocation(), SourceLocation()) {}
4778
4779  child_range children() {
4780    return child_range(child_iterator(), child_iterator());
4781  }
4782
4783  static bool classof(const OMPClause *T) {
4784    return T->getClauseKind() == OMPC_nogroup;
4785  }
4786};
4787
4788/// This represents 'num_tasks' clause in the '#pragma omp ...'
4789/// directive.
4790///
4791/// \code
4792/// #pragma omp taskloop num_tasks(4)
4793/// \endcode
4794/// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
4795/// with single expression '4'.
4796class OMPNumTasksClause : public OMPClause {
4797  friend class OMPClauseReader;
4798
4799  /// Location of '('.
4800  SourceLocation LParenLoc;
4801
4802  /// Safe iteration space distance.
4803  Stmt *NumTasks = nullptr;
4804
4805  /// Set safelen.
4806  void setNumTasks(Expr *Size) { NumTasks = Size; }
4807
4808public:
4809  /// Build 'num_tasks' clause.
4810  ///
4811  /// \param Size Expression associated with this clause.
4812  /// \param StartLoc Starting location of the clause.
4813  /// \param EndLoc Ending location of the clause.
4814  OMPNumTasksClause(Expr *SizeSourceLocation StartLoc,
4815                    SourceLocation LParenLocSourceLocation EndLoc)
4816      : OMPClause(OMPC_num_tasksStartLocEndLoc), LParenLoc(LParenLoc),
4817        NumTasks(Size) {}
4818
4819  /// Build an empty clause.
4820  explicit OMPNumTasksClause()
4821      : OMPClause(OMPC_num_tasksSourceLocation(), SourceLocation()) {}
4822
4823  /// Sets the location of '('.
4824  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4825
4826  /// Returns the location of '('.
4827  SourceLocation getLParenLoc() const { return LParenLoc; }
4828
4829  /// Return safe iteration space distance.
4830  Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
4831
4832  child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
4833
4834  static bool classof(const OMPClause *T) {
4835    return T->getClauseKind() == OMPC_num_tasks;
4836  }
4837};
4838
4839/// This represents 'hint' clause in the '#pragma omp ...' directive.
4840///
4841/// \code
4842/// #pragma omp critical (name) hint(6)
4843/// \endcode
4844/// In this example directive '#pragma omp critical' has name 'name' and clause
4845/// 'hint' with argument '6'.
4846class OMPHintClause : public OMPClause {
4847  friend class OMPClauseReader;
4848
4849  /// Location of '('.
4850  SourceLocation LParenLoc;
4851
4852  /// Hint expression of the 'hint' clause.
4853  Stmt *Hint = nullptr;
4854
4855  /// Set hint expression.
4856  void setHint(Expr *H) { Hint = H; }
4857
4858public:
4859  /// Build 'hint' clause with expression \a Hint.
4860  ///
4861  /// \param Hint Hint expression.
4862  /// \param StartLoc Starting location of the clause.
4863  /// \param LParenLoc Location of '('.
4864  /// \param EndLoc Ending location of the clause.
4865  OMPHintClause(Expr *HintSourceLocation StartLocSourceLocation LParenLoc,
4866                SourceLocation EndLoc)
4867      : OMPClause(OMPC_hintStartLocEndLoc), LParenLoc(LParenLoc),
4868        Hint(Hint) {}
4869
4870  /// Build an empty clause.
4871  OMPHintClause() : OMPClause(OMPC_hintSourceLocation(), SourceLocation()) {}
4872
4873  /// Sets the location of '('.
4874  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4875
4876  /// Returns the location of '('.
4877  SourceLocation getLParenLoc() const { return LParenLoc; }
4878
4879  /// Returns number of threads.
4880  Expr *getHint() const { return cast_or_null<Expr>(Hint); }
4881
4882  child_range children() { return child_range(&Hint, &Hint + 1); }
4883
4884  static bool classof(const OMPClause *T) {
4885    return T->getClauseKind() == OMPC_hint;
4886  }
4887};
4888
4889/// This represents 'dist_schedule' clause in the '#pragma omp ...'
4890/// directive.
4891///
4892/// \code
4893/// #pragma omp distribute dist_schedule(static, 3)
4894/// \endcode
4895/// In this example directive '#pragma omp distribute' has 'dist_schedule'
4896/// clause with arguments 'static' and '3'.
4897class OMPDistScheduleClause : public OMPClausepublic OMPClauseWithPreInit {
4898  friend class OMPClauseReader;
4899
4900  /// Location of '('.
4901  SourceLocation LParenLoc;
4902
4903  /// A kind of the 'schedule' clause.
4904  OpenMPDistScheduleClauseKind Kind = OMPC_DIST_SCHEDULE_unknown;
4905
4906  /// Start location of the schedule kind in source code.
4907  SourceLocation KindLoc;
4908
4909  /// Location of ',' (if any).
4910  SourceLocation CommaLoc;
4911
4912  /// Chunk size.
4913  Expr *ChunkSize = nullptr;
4914
4915  /// Set schedule kind.
4916  ///
4917  /// \param K Schedule kind.
4918  void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; }
4919
4920  /// Sets the location of '('.
4921  ///
4922  /// \param Loc Location of '('.
4923  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
4924
4925  /// Set schedule kind start location.
4926  ///
4927  /// \param KLoc Schedule kind location.
4928  void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
4929
4930  /// Set location of ','.
4931  ///
4932  /// \param Loc Location of ','.
4933  void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; }
4934
4935  /// Set chunk size.
4936  ///
4937  /// \param E Chunk size.
4938  void setChunkSize(Expr *E) { ChunkSize = E; }
4939
4940public:
4941  /// Build 'dist_schedule' clause with schedule kind \a Kind and chunk
4942  /// size expression \a ChunkSize.
4943  ///
4944  /// \param StartLoc Starting location of the clause.
4945  /// \param LParenLoc Location of '('.
4946  /// \param KLoc Starting location of the argument.
4947  /// \param CommaLoc Location of ','.
4948  /// \param EndLoc Ending location of the clause.
4949  /// \param Kind DistSchedule kind.
4950  /// \param ChunkSize Chunk size.
4951  /// \param HelperChunkSize Helper chunk size for combined directives.
4952  OMPDistScheduleClause(SourceLocation StartLocSourceLocation LParenLoc,
4953                        SourceLocation KLocSourceLocation CommaLoc,
4954                        SourceLocation EndLoc,
4955                        OpenMPDistScheduleClauseKind KindExpr *ChunkSize,
4956                        Stmt *HelperChunkSize)
4957      : OMPClause(OMPC_dist_scheduleStartLocEndLoc),
4958        OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind),
4959        KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) {
4960    setPreInitStmt(HelperChunkSize);
4961  }
4962
4963  /// Build an empty clause.
4964  explicit OMPDistScheduleClause()
4965      : OMPClause(OMPC_dist_scheduleSourceLocation(), SourceLocation()),
4966        OMPClauseWithPreInit(this) {}
4967
4968  /// Get kind of the clause.
4969  OpenMPDistScheduleClauseKind getDistScheduleKind() const { return Kind; }
4970
4971  /// Get location of '('.
4972  SourceLocation getLParenLoc() { return LParenLoc; }
4973
4974  /// Get kind location.
4975  SourceLocation getDistScheduleKindLoc() { return KindLoc; }
4976
4977  /// Get location of ','.
4978  SourceLocation getCommaLoc() { return CommaLoc; }
4979
4980  /// Get chunk size.
4981  Expr *getChunkSize() { return ChunkSize; }
4982
4983  /// Get chunk size.
4984  const Expr *getChunkSize() const { return ChunkSize; }
4985
4986  child_range children() {
4987    return child_range(reinterpret_cast<Stmt **>(&ChunkSize),
4988                       reinterpret_cast<Stmt **>(&ChunkSize) + 1);
4989  }
4990
4991  static bool classof(const OMPClause *T) {
4992    return T->getClauseKind() == OMPC_dist_schedule;
4993  }
4994};
4995
4996/// This represents 'defaultmap' clause in the '#pragma omp ...' directive.
4997///
4998/// \code
4999/// #pragma omp target defaultmap(tofrom: scalar)
5000/// \endcode
5001/// In this example directive '#pragma omp target' has 'defaultmap' clause of kind
5002/// 'scalar' with modifier 'tofrom'.
5003class OMPDefaultmapClause : public OMPClause {
5004  friend class OMPClauseReader;
5005
5006  /// Location of '('.
5007  SourceLocation LParenLoc;
5008
5009  /// Modifiers for 'defaultmap' clause.
5010  OpenMPDefaultmapClauseModifier Modifier = OMPC_DEFAULTMAP_MODIFIER_unknown;
5011
5012  /// Locations of modifiers.
5013  SourceLocation ModifierLoc;
5014
5015  /// A kind of the 'defaultmap' clause.
5016  OpenMPDefaultmapClauseKind Kind = OMPC_DEFAULTMAP_unknown;
5017
5018  /// Start location of the defaultmap kind in source code.
5019  SourceLocation KindLoc;
5020
5021  /// Set defaultmap kind.
5022  ///
5023  /// \param K Defaultmap kind.
5024  void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; }
5025
5026  /// Set the defaultmap modifier.
5027  ///
5028  /// \param M Defaultmap modifier.
5029  void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) {
5030    Modifier = M;
5031  }
5032
5033  /// Set location of the defaultmap modifier.
5034  void setDefaultmapModifierLoc(SourceLocation Loc) {
5035    ModifierLoc = Loc;
5036  }
5037
5038  /// Sets the location of '('.
5039  ///
5040  /// \param Loc Location of '('.
5041  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
5042
5043  /// Set defaultmap kind start location.
5044  ///
5045  /// \param KLoc Defaultmap kind location.
5046  void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
5047
5048public:
5049  /// Build 'defaultmap' clause with defaultmap kind \a Kind
5050  ///
5051  /// \param StartLoc Starting location of the clause.
5052  /// \param LParenLoc Location of '('.
5053  /// \param KLoc Starting location of the argument.
5054  /// \param EndLoc Ending location of the clause.
5055  /// \param Kind Defaultmap kind.
5056  /// \param M The modifier applied to 'defaultmap' clause.
5057  /// \param MLoc Location of the modifier
5058  OMPDefaultmapClause(SourceLocation StartLocSourceLocation LParenLoc,
5059                      SourceLocation MLocSourceLocation KLoc,
5060                      SourceLocation EndLocOpenMPDefaultmapClauseKind Kind,
5061                      OpenMPDefaultmapClauseModifier M)
5062      : OMPClause(OMPC_defaultmapStartLocEndLoc), LParenLoc(LParenLoc),
5063        Modifier(M), ModifierLoc(MLoc), Kind(Kind), KindLoc(KLoc) {}
5064
5065  /// Build an empty clause.
5066  explicit OMPDefaultmapClause()
5067      : OMPClause(OMPC_defaultmapSourceLocation(), SourceLocation()) {}
5068
5069  /// Get kind of the clause.
5070  OpenMPDefaultmapClauseKind getDefaultmapKind() const { return Kind; }
5071
5072  /// Get the modifier of the clause.
5073  OpenMPDefaultmapClauseModifier getDefaultmapModifier() const {
5074    return Modifier;
5075  }
5076
5077  /// Get location of '('.
5078  SourceLocation getLParenLoc() { return LParenLoc; }
5079
5080  /// Get kind location.
5081  SourceLocation getDefaultmapKindLoc() { return KindLoc; }
5082
5083  /// Get the modifier location.
5084  SourceLocation getDefaultmapModifierLoc() const {
5085    return ModifierLoc;
5086  }
5087
5088  child_range children() {
5089    return child_range(child_iterator(), child_iterator());
5090  }
5091
5092  static bool classof(const OMPClause *T) {
5093    return T->getClauseKind() == OMPC_defaultmap;
5094  }
5095};
5096
5097/// This represents clause 'to' in the '#pragma omp ...'
5098/// directives.
5099///
5100/// \code
5101/// #pragma omp target update to(a,b)
5102/// \endcode
5103/// In this example directive '#pragma omp target update' has clause 'to'
5104/// with the variables 'a' and 'b'.
5105class OMPToClause final : public OMPMappableExprListClause<OMPToClause>,
5106                          private llvm::TrailingObjects<
5107                              OMPToClause, Expr *, ValueDecl *, unsigned,
5108                              OMPClauseMappableExprCommon::MappableComponent> {
5109  friend class OMPClauseReader;
5110  friend OMPMappableExprListClause;
5111  friend OMPVarListClause;
5112  friend TrailingObjects;
5113
5114  /// Build clause with number of variables \a NumVars.
5115  ///
5116  /// \param MapperQualifierLoc C++ nested name specifier for the associated
5117  /// user-defined mapper.
5118  /// \param MapperIdInfo The identifier of associated user-defined mapper.
5119  /// \param Locs Locations needed to build a mappable clause. It includes 1)
5120  /// StartLoc: starting location of the clause (the clause keyword); 2)
5121  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5122  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5123  /// NumVars: number of expressions listed in this clause; 2)
5124  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5125  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5126  /// NumComponents: total number of expression components in the clause.
5127  explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc,
5128                       DeclarationNameInfo MapperIdInfo,
5129                       const OMPVarListLocTy &Locs,
5130                       const OMPMappableExprListSizeTy &Sizes)
5131      : OMPMappableExprListClause(OMPC_to, Locs, Sizes, &MapperQualifierLoc,
5132                                  &MapperIdInfo) {}
5133
5134  /// Build an empty clause.
5135  ///
5136  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5137  /// NumVars: number of expressions listed in this clause; 2)
5138  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5139  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5140  /// NumComponents: total number of expression components in the clause.
5141  explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes)
5142      : OMPMappableExprListClause(OMPC_to, OMPVarListLocTy(), Sizes) {}
5143
5144  /// Define the sizes of each trailing object array except the last one. This
5145  /// is required for TrailingObjects to work properly.
5146  size_t numTrailingObjects(OverloadToken<Expr *>) const {
5147    // There are varlist_size() of expressions, and varlist_size() of
5148    // user-defined mappers.
5149    return 2 * varlist_size();
5150  }
5151  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
5152    return getUniqueDeclarationsNum();
5153  }
5154  size_t numTrailingObjects(OverloadToken<unsigned>) const {
5155    return getUniqueDeclarationsNum() + getTotalComponentListNum();
5156  }
5157
5158public:
5159  /// Creates clause with a list of variables \a Vars.
5160  ///
5161  /// \param C AST context.
5162  /// \param Locs Locations needed to build a mappable clause. It includes 1)
5163  /// StartLoc: starting location of the clause (the clause keyword); 2)
5164  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5165  /// \param Vars The original expression used in the clause.
5166  /// \param Declarations Declarations used in the clause.
5167  /// \param ComponentLists Component lists used in the clause.
5168  /// \param UDMapperRefs References to user-defined mappers associated with
5169  /// expressions used in the clause.
5170  /// \param UDMQualifierLoc C++ nested name specifier for the associated
5171  /// user-defined mapper.
5172  /// \param MapperId The identifier of associated user-defined mapper.
5173  static OMPToClause *Create(const ASTContext &Cconst OMPVarListLocTy &Locs,
5174                             ArrayRef<Expr *> Vars,
5175                             ArrayRef<ValueDecl *> Declarations,
5176                             MappableExprComponentListsRef ComponentLists,
5177                             ArrayRef<Expr *> UDMapperRefs,
5178                             NestedNameSpecifierLoc UDMQualifierLoc,
5179                             DeclarationNameInfo MapperId);
5180
5181  /// Creates an empty clause with the place for \a NumVars variables.
5182  ///
5183  /// \param C AST context.
5184  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5185  /// NumVars: number of expressions listed in this clause; 2)
5186  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5187  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5188  /// NumComponents: total number of expression components in the clause.
5189  static OMPToClause *CreateEmpty(const ASTContext &C,
5190                                  const OMPMappableExprListSizeTy &Sizes);
5191
5192  child_range children() {
5193    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5194                       reinterpret_cast<Stmt **>(varlist_end()));
5195  }
5196
5197  static bool classof(const OMPClause *T) {
5198    return T->getClauseKind() == OMPC_to;
5199  }
5200};
5201
5202/// This represents clause 'from' in the '#pragma omp ...'
5203/// directives.
5204///
5205/// \code
5206/// #pragma omp target update from(a,b)
5207/// \endcode
5208/// In this example directive '#pragma omp target update' has clause 'from'
5209/// with the variables 'a' and 'b'.
5210class OMPFromClause final
5211    : public OMPMappableExprListClause<OMPFromClause>,
5212      private llvm::TrailingObjects<
5213          OMPFromClause, Expr *, ValueDecl *, unsigned,
5214          OMPClauseMappableExprCommon::MappableComponent> {
5215  friend class OMPClauseReader;
5216  friend OMPMappableExprListClause;
5217  friend OMPVarListClause;
5218  friend TrailingObjects;
5219
5220  /// Build clause with number of variables \a NumVars.
5221  ///
5222  /// \param MapperQualifierLoc C++ nested name specifier for the associated
5223  /// user-defined mapper.
5224  /// \param MapperIdInfo The identifier of associated user-defined mapper.
5225  /// \param Locs Locations needed to build a mappable clause. It includes 1)
5226  /// StartLoc: starting location of the clause (the clause keyword); 2)
5227  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5228  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5229  /// NumVars: number of expressions listed in this clause; 2)
5230  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5231  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5232  /// NumComponents: total number of expression components in the clause.
5233  explicit OMPFromClause(NestedNameSpecifierLoc MapperQualifierLoc,
5234                         DeclarationNameInfo MapperIdInfo,
5235                         const OMPVarListLocTy &Locs,
5236                         const OMPMappableExprListSizeTy &Sizes)
5237      : OMPMappableExprListClause(OMPC_from, Locs, Sizes, &MapperQualifierLoc,
5238                                  &MapperIdInfo) {}
5239
5240  /// Build an empty clause.
5241  ///
5242  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5243  /// NumVars: number of expressions listed in this clause; 2)
5244  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5245  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5246  /// NumComponents: total number of expression components in the clause.
5247  explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes)
5248      : OMPMappableExprListClause(OMPC_from, OMPVarListLocTy(), Sizes) {}
5249
5250  /// Define the sizes of each trailing object array except the last one. This
5251  /// is required for TrailingObjects to work properly.
5252  size_t numTrailingObjects(OverloadToken<Expr *>) const {
5253    // There are varlist_size() of expressions, and varlist_size() of
5254    // user-defined mappers.
5255    return 2 * varlist_size();
5256  }
5257  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
5258    return getUniqueDeclarationsNum();
5259  }
5260  size_t numTrailingObjects(OverloadToken<unsigned>) const {
5261    return getUniqueDeclarationsNum() + getTotalComponentListNum();
5262  }
5263
5264public:
5265  /// Creates clause with a list of variables \a Vars.
5266  ///
5267  /// \param C AST context.
5268  /// \param Locs Locations needed to build a mappable clause. It includes 1)
5269  /// StartLoc: starting location of the clause (the clause keyword); 2)
5270  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5271  /// \param Vars The original expression used in the clause.
5272  /// \param Declarations Declarations used in the clause.
5273  /// \param ComponentLists Component lists used in the clause.
5274  /// \param UDMapperRefs References to user-defined mappers associated with
5275  /// expressions used in the clause.
5276  /// \param UDMQualifierLoc C++ nested name specifier for the associated
5277  /// user-defined mapper.
5278  /// \param MapperId The identifier of associated user-defined mapper.
5279  static OMPFromClause *Create(const ASTContext &Cconst OMPVarListLocTy &Locs,
5280                               ArrayRef<Expr *> Vars,
5281                               ArrayRef<ValueDecl *> Declarations,
5282                               MappableExprComponentListsRef ComponentLists,
5283                               ArrayRef<Expr *> UDMapperRefs,
5284                               NestedNameSpecifierLoc UDMQualifierLoc,
5285                               DeclarationNameInfo MapperId);
5286
5287  /// Creates an empty clause with the place for \a NumVars variables.
5288  ///
5289  /// \param C AST context.
5290  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5291  /// NumVars: number of expressions listed in this clause; 2)
5292  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5293  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5294  /// NumComponents: total number of expression components in the clause.
5295  static OMPFromClause *CreateEmpty(const ASTContext &C,
5296                                    const OMPMappableExprListSizeTy &Sizes);
5297
5298  child_range children() {
5299    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5300                       reinterpret_cast<Stmt **>(varlist_end()));
5301  }
5302
5303  static bool classof(const OMPClause *T) {
5304    return T->getClauseKind() == OMPC_from;
5305  }
5306};
5307
5308/// This represents clause 'use_device_ptr' in the '#pragma omp ...'
5309/// directives.
5310///
5311/// \code
5312/// #pragma omp target data use_device_ptr(a,b)
5313/// \endcode
5314/// In this example directive '#pragma omp target data' has clause
5315/// 'use_device_ptr' with the variables 'a' and 'b'.
5316class OMPUseDevicePtrClause final
5317    : public OMPMappableExprListClause<OMPUseDevicePtrClause>,
5318      private llvm::TrailingObjects<
5319          OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
5320          OMPClauseMappableExprCommon::MappableComponent> {
5321  friend class OMPClauseReader;
5322  friend OMPMappableExprListClause;
5323  friend OMPVarListClause;
5324  friend TrailingObjects;
5325
5326  /// Build clause with number of variables \a NumVars.
5327  ///
5328  /// \param Locs Locations needed to build a mappable clause. It includes 1)
5329  /// StartLoc: starting location of the clause (the clause keyword); 2)
5330  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5331  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5332  /// NumVars: number of expressions listed in this clause; 2)
5333  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5334  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5335  /// NumComponents: total number of expression components in the clause.
5336  explicit OMPUseDevicePtrClause(const OMPVarListLocTy &Locs,
5337                                 const OMPMappableExprListSizeTy &Sizes)
5338      : OMPMappableExprListClause(OMPC_use_device_ptr, Locs, Sizes) {}
5339
5340  /// Build an empty clause.
5341  ///
5342  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5343  /// NumVars: number of expressions listed in this clause; 2)
5344  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5345  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5346  /// NumComponents: total number of expression components in the clause.
5347  explicit OMPUseDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
5348      : OMPMappableExprListClause(OMPC_use_device_ptr, OMPVarListLocTy(),
5349                                  Sizes) {}
5350
5351  /// Define the sizes of each trailing object array except the last one. This
5352  /// is required for TrailingObjects to work properly.
5353  size_t numTrailingObjects(OverloadToken<Expr *>) const {
5354    return 3 * varlist_size();
5355  }
5356  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
5357    return getUniqueDeclarationsNum();
5358  }
5359  size_t numTrailingObjects(OverloadToken<unsigned>) const {
5360    return getUniqueDeclarationsNum() + getTotalComponentListNum();
5361  }
5362
5363  /// Sets the list of references to private copies with initializers for new
5364  /// private variables.
5365  /// \param VL List of references.
5366  void setPrivateCopies(ArrayRef<Expr *> VL);
5367
5368  /// Gets the list of references to private copies with initializers for new
5369  /// private variables.
5370  MutableArrayRef<Expr *> getPrivateCopies() {
5371    return MutableArrayRef<Expr *>(varlist_end(), varlist_size());
5372  }
5373  ArrayRef<const Expr *> getPrivateCopies() const {
5374    return llvm::makeArrayRef(varlist_end(), varlist_size());
5375  }
5376
5377  /// Sets the list of references to initializer variables for new private
5378  /// variables.
5379  /// \param VL List of references.
5380  void setInits(ArrayRef<Expr *> VL);
5381
5382  /// Gets the list of references to initializer variables for new private
5383  /// variables.
5384  MutableArrayRef<Expr *> getInits() {
5385    return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size());
5386  }
5387  ArrayRef<const Expr *> getInits() const {
5388    return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size());
5389  }
5390
5391public:
5392  /// Creates clause with a list of variables \a Vars.
5393  ///
5394  /// \param C AST context.
5395  /// \param Locs Locations needed to build a mappable clause. It includes 1)
5396  /// StartLoc: starting location of the clause (the clause keyword); 2)
5397  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5398  /// \param Vars The original expression used in the clause.
5399  /// \param PrivateVars Expressions referring to private copies.
5400  /// \param Inits Expressions referring to private copy initializers.
5401  /// \param Declarations Declarations used in the clause.
5402  /// \param ComponentLists Component lists used in the clause.
5403  static OMPUseDevicePtrClause *
5404  Create(const ASTContext &Cconst OMPVarListLocTy &Locs,
5405         ArrayRef<Expr *> VarsArrayRef<Expr *> PrivateVars,
5406         ArrayRef<Expr *> InitsArrayRef<ValueDecl *> Declarations,
5407         MappableExprComponentListsRef ComponentLists);
5408
5409  /// Creates an empty clause with the place for \a NumVars variables.
5410  ///
5411  /// \param C AST context.
5412  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5413  /// NumVars: number of expressions listed in this clause; 2)
5414  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5415  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5416  /// NumComponents: total number of expression components in the clause.
5417  static OMPUseDevicePtrClause *
5418  CreateEmpty(const ASTContext &Cconst OMPMappableExprListSizeTy &Sizes);
5419
5420  using private_copies_iterator = MutableArrayRef<Expr *>::iterator;
5421  using private_copies_const_iterator = ArrayRef<const Expr *>::iterator;
5422  using private_copies_range = llvm::iterator_range<private_copies_iterator>;
5423  using private_copies_const_range =
5424      llvm::iterator_range<private_copies_const_iterator>;
5425
5426  private_copies_range private_copies() {
5427    return private_copies_range(getPrivateCopies().begin(),
5428                                getPrivateCopies().end());
5429  }
5430
5431  private_copies_const_range private_copies() const {
5432    return private_copies_const_range(getPrivateCopies().begin(),
5433                                      getPrivateCopies().end());
5434  }
5435
5436  using inits_iterator = MutableArrayRef<Expr *>::iterator;
5437  using inits_const_iterator = ArrayRef<const Expr *>::iterator;
5438  using inits_range = llvm::iterator_range<inits_iterator>;
5439  using inits_const_range = llvm::iterator_range<inits_const_iterator>;
5440
5441  inits_range inits() {
5442    return inits_range(getInits().begin(), getInits().end());
5443  }
5444
5445  inits_const_range inits() const {
5446    return inits_const_range(getInits().begin(), getInits().end());
5447  }
5448
5449  child_range children() {
5450    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5451                       reinterpret_cast<Stmt **>(varlist_end()));
5452  }
5453
5454  static bool classof(const OMPClause *T) {
5455    return T->getClauseKind() == OMPC_use_device_ptr;
5456  }
5457};
5458
5459/// This represents clause 'is_device_ptr' in the '#pragma omp ...'
5460/// directives.
5461///
5462/// \code
5463/// #pragma omp target is_device_ptr(a,b)
5464/// \endcode
5465/// In this example directive '#pragma omp target' has clause
5466/// 'is_device_ptr' with the variables 'a' and 'b'.
5467class OMPIsDevicePtrClause final
5468    : public OMPMappableExprListClause<OMPIsDevicePtrClause>,
5469      private llvm::TrailingObjects<
5470          OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
5471          OMPClauseMappableExprCommon::MappableComponent> {
5472  friend class OMPClauseReader;
5473  friend OMPMappableExprListClause;
5474  friend OMPVarListClause;
5475  friend TrailingObjects;
5476
5477  /// Build clause with number of variables \a NumVars.
5478  ///
5479  /// \param Locs Locations needed to build a mappable clause. It includes 1)
5480  /// StartLoc: starting location of the clause (the clause keyword); 2)
5481  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5482  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5483  /// NumVars: number of expressions listed in this clause; 2)
5484  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5485  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5486  /// NumComponents: total number of expression components in the clause.
5487  explicit OMPIsDevicePtrClause(const OMPVarListLocTy &Locs,
5488                                const OMPMappableExprListSizeTy &Sizes)
5489      : OMPMappableExprListClause(OMPC_is_device_ptr, Locs, Sizes) {}
5490
5491  /// Build an empty clause.
5492  ///
5493  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5494  /// NumVars: number of expressions listed in this clause; 2)
5495  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5496  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5497  /// NumComponents: total number of expression components in the clause.
5498  explicit OMPIsDevicePtrClause(const OMPMappableExprListSizeTy &Sizes)
5499      : OMPMappableExprListClause(OMPC_is_device_ptr, OMPVarListLocTy(),
5500                                  Sizes) {}
5501
5502  /// Define the sizes of each trailing object array except the last one. This
5503  /// is required for TrailingObjects to work properly.
5504  size_t numTrailingObjects(OverloadToken<Expr *>) const {
5505    return varlist_size();
5506  }
5507  size_t numTrailingObjects(OverloadToken<ValueDecl *>) const {
5508    return getUniqueDeclarationsNum();
5509  }
5510  size_t numTrailingObjects(OverloadToken<unsigned>) const {
5511    return getUniqueDeclarationsNum() + getTotalComponentListNum();
5512  }
5513
5514public:
5515  /// Creates clause with a list of variables \a Vars.
5516  ///
5517  /// \param C AST context.
5518  /// \param Locs Locations needed to build a mappable clause. It includes 1)
5519  /// StartLoc: starting location of the clause (the clause keyword); 2)
5520  /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
5521  /// \param Vars The original expression used in the clause.
5522  /// \param Declarations Declarations used in the clause.
5523  /// \param ComponentLists Component lists used in the clause.
5524  static OMPIsDevicePtrClause *
5525  Create(const ASTContext &Cconst OMPVarListLocTy &Locs,
5526         ArrayRef<Expr *> VarsArrayRef<ValueDecl *> Declarations,
5527         MappableExprComponentListsRef ComponentLists);
5528
5529  /// Creates an empty clause with the place for \a NumVars variables.
5530  ///
5531  /// \param C AST context.
5532  /// \param Sizes All required sizes to build a mappable clause. It includes 1)
5533  /// NumVars: number of expressions listed in this clause; 2)
5534  /// NumUniqueDeclarations: number of unique base declarations in this clause;
5535  /// 3) NumComponentLists: number of component lists in this clause; and 4)
5536  /// NumComponents: total number of expression components in the clause.
5537  static OMPIsDevicePtrClause *
5538  CreateEmpty(const ASTContext &Cconst OMPMappableExprListSizeTy &Sizes);
5539
5540  child_range children() {
5541    return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
5542                       reinterpret_cast<Stmt **>(varlist_end()));
5543  }
5544
5545  static bool classof(const OMPClause *T) {
5546    return T->getClauseKind() == OMPC_is_device_ptr;
5547  }
5548};
5549
5550/// This class implements a simple visitor for OMPClause
5551/// subclasses.
5552template<class ImplClass, template <typenameclass Ptr, typename RetTy>
5553class OMPClauseVisitorBase {
5554public:
5555#define PTR(CLASS) typename Ptr<CLASS>::type
5556#define DISPATCH(CLASS) \
5557  return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S))
5558
5559#define OPENMP_CLAUSE(Name, Class)                              \
5560  RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
5561#include "clang/Basic/OpenMPKinds.def"
5562
5563  RetTy Visit(PTR(OMPClause) S) {
5564    // Top switch clause: visit each OMPClause.
5565    switch (S->getClauseKind()) {
5566    default: llvm_unreachable("Unknown clause kind!");
5567#define OPENMP_CLAUSE(Name, Class)                              \
5568    case OMPC_ ## Name : return Visit ## Class(static_cast<PTR(Class)>(S));
5569#include "clang/Basic/OpenMPKinds.def"
5570    }
5571  }
5572  // Base case, ignore it. :)
5573  RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); }
5574#undef PTR
5575#undef DISPATCH
5576};
5577
5578template <typename T>
5579using const_ptr = typename std::add_pointer<typename std::add_const<T>::type>;
5580
5581template<class ImplClass, typename RetTy = void>
5582class OMPClauseVisitor :
5583      public OMPClauseVisitorBase <ImplClass, std::add_pointer, RetTy> {};
5584template<class ImplClass, typename RetTy = void>
5585class ConstOMPClauseVisitor :
5586      public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {};
5587
5588class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
5589  raw_ostream &OS;
5590  const PrintingPolicy &Policy;
5591
5592  /// Process clauses with list of variables.
5593  template <typename T> void VisitOMPClauseList(T *Nodechar StartSym);
5594
5595public:
5596  OMPClausePrinter(raw_ostream &OSconst PrintingPolicy &Policy)
5597      : OS(OS), Policy(Policy) {}
5598
5599#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S);
5600#include "clang/Basic/OpenMPKinds.def"
5601};
5602
5603// namespace clang
5604
5605#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
5606
clang::OMPClause::StartLoc
clang::OMPClause::EndLoc
clang::OMPClause::Kind
clang::OMPClause::getBeginLoc
clang::OMPClause::getEndLoc
clang::OMPClause::setLocStart
clang::OMPClause::setLocEnd
clang::OMPClause::getClauseKind
clang::OMPClause::isImplicit
clang::OMPClause::children
clang::OMPClause::children
clang::OMPClause::classof
clang::OMPClauseWithPreInit::PreInit
clang::OMPClauseWithPreInit::CaptureRegion
clang::OMPClauseWithPreInit::setPreInitStmt
clang::OMPClauseWithPreInit::getPreInitStmt
clang::OMPClauseWithPreInit::getPreInitStmt
clang::OMPClauseWithPreInit::getCaptureRegion
clang::OMPClauseWithPreInit::get
clang::OMPClauseWithPreInit::get
clang::OMPClauseWithPostUpdate::PostUpdate
clang::OMPClauseWithPostUpdate::setPostUpdateExpr
clang::OMPClauseWithPostUpdate::getPostUpdateExpr
clang::OMPClauseWithPostUpdate::getPostUpdateExpr
clang::OMPClauseWithPostUpdate::get
clang::OMPClauseWithPostUpdate::get
clang::OMPVarListLocTy::StartLoc
clang::OMPVarListLocTy::LParenLoc
clang::OMPVarListLocTy::EndLoc
clang::OMPVarListClause::LParenLoc
clang::OMPVarListClause::NumVars
clang::OMPVarListClause::getVarRefs
clang::OMPVarListClause::setVarRefs
clang::OMPVarListClause::varlist_size
clang::OMPVarListClause::varlist_empty
clang::OMPVarListClause::varlists
clang::OMPVarListClause::varlists
clang::OMPVarListClause::varlist_begin
clang::OMPVarListClause::varlist_end
clang::OMPVarListClause::varlist_begin
clang::OMPVarListClause::varlist_end
clang::OMPVarListClause::setLParenLoc
clang::OMPVarListClause::getLParenLoc
clang::OMPVarListClause::getVarRefs
clang::OMPAllocatorClause::LParenLoc
clang::OMPAllocatorClause::Allocator
clang::OMPAllocatorClause::setAllocator
clang::OMPAllocatorClause::setLParenLoc
clang::OMPAllocatorClause::getLParenLoc
clang::OMPAllocatorClause::getAllocator
clang::OMPAllocatorClause::children
clang::OMPAllocatorClause::classof
clang::OMPAllocateClause::Allocator
clang::OMPAllocateClause::ColonLoc
clang::OMPAllocateClause::setColonLoc
clang::OMPAllocateClause::setAllocator
clang::OMPAllocateClause::Create
clang::OMPAllocateClause::getAllocator
clang::OMPAllocateClause::getColonLoc
clang::OMPAllocateClause::CreateEmpty
clang::OMPAllocateClause::children
clang::OMPAllocateClause::classof
clang::OMPIfClause::LParenLoc
clang::OMPIfClause::Condition
clang::OMPIfClause::ColonLoc
clang::OMPIfClause::NameModifier
clang::OMPIfClause::NameModifierLoc
clang::OMPIfClause::setCondition
clang::OMPIfClause::setNameModifier
clang::OMPIfClause::setNameModifierLoc
clang::OMPIfClause::setColonLoc
clang::OMPIfClause::setLParenLoc
clang::OMPIfClause::getLParenLoc
clang::OMPIfClause::getColonLoc
clang::OMPIfClause::getCondition
clang::OMPIfClause::getNameModifier
clang::OMPIfClause::getNameModifierLoc
clang::OMPIfClause::children
clang::OMPIfClause::classof
clang::OMPFinalClause::LParenLoc
clang::OMPFinalClause::Condition
clang::OMPFinalClause::setCondition
clang::OMPFinalClause::setLParenLoc
clang::OMPFinalClause::getLParenLoc
clang::OMPFinalClause::getCondition
clang::OMPFinalClause::children
clang::OMPFinalClause::classof
clang::OMPNumThreadsClause::LParenLoc
clang::OMPNumThreadsClause::NumThreads
clang::OMPNumThreadsClause::setNumThreads
clang::OMPNumThreadsClause::setLParenLoc
clang::OMPNumThreadsClause::getLParenLoc
clang::OMPNumThreadsClause::getNumThreads
clang::OMPNumThreadsClause::children
clang::OMPNumThreadsClause::classof
clang::OMPSafelenClause::LParenLoc
clang::OMPSafelenClause::Safelen
clang::OMPSafelenClause::setSafelen
clang::OMPSafelenClause::setLParenLoc
clang::OMPSafelenClause::getLParenLoc
clang::OMPSafelenClause::getSafelen
clang::OMPSafelenClause::children
clang::OMPSafelenClause::classof
clang::OMPSimdlenClause::LParenLoc
clang::OMPSimdlenClause::Simdlen
clang::OMPSimdlenClause::setSimdlen
clang::OMPSimdlenClause::setLParenLoc
clang::OMPSimdlenClause::getLParenLoc
clang::OMPSimdlenClause::getSimdlen
clang::OMPSimdlenClause::children
clang::OMPSimdlenClause::classof
clang::OMPCollapseClause::LParenLoc
clang::OMPCollapseClause::NumForLoops
clang::OMPCollapseClause::setNumForLoops
clang::OMPCollapseClause::setLParenLoc
clang::OMPCollapseClause::getLParenLoc
clang::OMPCollapseClause::getNumForLoops
clang::OMPCollapseClause::children
clang::OMPCollapseClause::classof
clang::OMPDefaultClause::LParenLoc
clang::OMPDefaultClause::Kind
clang::OMPDefaultClause::KindKwLoc
clang::OMPDefaultClause::setDefaultKind
clang::OMPDefaultClause::setDefaultKindKwLoc
clang::OMPDefaultClause::setLParenLoc
clang::OMPDefaultClause::getLParenLoc
clang::OMPDefaultClause::getDefaultKind
clang::OMPDefaultClause::getDefaultKindKwLoc
clang::OMPDefaultClause::children
clang::OMPDefaultClause::classof
clang::OMPProcBindClause::LParenLoc
clang::OMPProcBindClause::Kind
clang::OMPProcBindClause::KindKwLoc
clang::OMPProcBindClause::setProcBindKind
clang::OMPProcBindClause::setProcBindKindKwLoc
clang::OMPProcBindClause::setLParenLoc
clang::OMPProcBindClause::getLParenLoc
clang::OMPProcBindClause::getProcBindKind
clang::OMPProcBindClause::getProcBindKindKwLoc
clang::OMPProcBindClause::children
clang::OMPProcBindClause::classof
clang::OMPUnifiedAddressClause::children
clang::OMPUnifiedAddressClause::classof
clang::OMPUnifiedSharedMemoryClause::children
clang::OMPUnifiedSharedMemoryClause::classof
clang::OMPReverseOffloadClause::children
clang::OMPReverseOffloadClause::classof
clang::OMPDynamicAllocatorsClause::children
clang::OMPDynamicAllocatorsClause::classof
clang::OMPAtomicDefaultMemOrderClause::LParenLoc
clang::OMPAtomicDefaultMemOrderClause::Kind
clang::OMPAtomicDefaultMemOrderClause::KindKwLoc
clang::OMPAtomicDefaultMemOrderClause::setAtomicDefaultMemOrderKind
clang::OMPAtomicDefaultMemOrderClause::setAtomicDefaultMemOrderKindKwLoc
clang::OMPAtomicDefaultMemOrderClause::setLParenLoc
clang::OMPAtomicDefaultMemOrderClause::getLParenLoc
clang::OMPAtomicDefaultMemOrderClause::getAtomicDefaultMemOrderKind
clang::OMPAtomicDefaultMemOrderClause::getAtomicDefaultMemOrderKindKwLoc
clang::OMPAtomicDefaultMemOrderClause::children
clang::OMPAtomicDefaultMemOrderClause::classof
clang::OMPScheduleClause::LParenLoc
clang::OMPScheduleClause::Kind
clang::OMPScheduleClause::Modifiers
clang::OMPScheduleClause::ModifiersLoc
clang::OMPScheduleClause::KindLoc
clang::OMPScheduleClause::CommaLoc
clang::OMPScheduleClause::ChunkSize
clang::OMPScheduleClause::setScheduleKind
clang::OMPScheduleClause::setFirstScheduleModifier
clang::OMPScheduleClause::setSecondScheduleModifier
clang::OMPScheduleClause::setFirstScheduleModifierLoc
clang::OMPScheduleClause::setSecondScheduleModifierLoc
clang::OMPScheduleClause::setScheduleModifer
clang::OMPScheduleClause::setLParenLoc
clang::OMPScheduleClause::setScheduleKindLoc
clang::OMPScheduleClause::setCommaLoc
clang::OMPScheduleClause::setChunkSize
clang::OMPScheduleClause::getScheduleKind
clang::OMPScheduleClause::getFirstScheduleModifier
clang::OMPScheduleClause::getSecondScheduleModifier
clang::OMPScheduleClause::getLParenLoc
clang::OMPScheduleClause::getScheduleKindLoc
clang::OMPScheduleClause::getFirstScheduleModifierLoc
clang::OMPScheduleClause::getSecondScheduleModifierLoc
clang::OMPScheduleClause::getCommaLoc
clang::OMPScheduleClause::getChunkSize
clang::OMPScheduleClause::getChunkSize
clang::OMPScheduleClause::children
clang::OMPScheduleClause::classof
clang::OMPOrderedClause::LParenLoc
clang::OMPOrderedClause::NumForLoops
clang::OMPOrderedClause::NumberOfLoops
clang::OMPOrderedClause::setNumForLoops
clang::OMPOrderedClause::Create
clang::OMPOrderedClause::CreateEmpty
clang::OMPOrderedClause::setLParenLoc
clang::OMPOrderedClause::getLParenLoc
clang::OMPOrderedClause::getNumForLoops
clang::OMPOrderedClause::setLoopNumIterations
clang::OMPOrderedClause::getLoopNumIterations
clang::OMPOrderedClause::setLoopCounter
clang::OMPOrderedClause::getLoopCounter
clang::OMPOrderedClause::getLoopCounter
clang::OMPOrderedClause::children
clang::OMPOrderedClause::classof
clang::OMPNowaitClause::children
clang::OMPNowaitClause::classof
clang::OMPUntiedClause::children
clang::OMPUntiedClause::classof
clang::OMPMergeableClause::children
clang::OMPMergeableClause::classof
clang::OMPReadClause::children
clang::OMPReadClause::classof
clang::OMPWriteClause::children
clang::OMPWriteClause::classof
clang::OMPUpdateClause::children
clang::OMPUpdateClause::classof
clang::OMPCaptureClause::children
clang::OMPCaptureClause::classof
clang::OMPSeqCstClause::children
clang::OMPSeqCstClause::classof
clang::OMPPrivateClause::setPrivateCopies
clang::OMPPrivateClause::getPrivateCopies
clang::OMPPrivateClause::getPrivateCopies
clang::OMPPrivateClause::Create
clang::OMPPrivateClause::CreateEmpty
clang::OMPPrivateClause::private_copies
clang::OMPPrivateClause::private_copies
clang::OMPPrivateClause::children
clang::OMPPrivateClause::classof
clang::OMPFirstprivateClause::setPrivateCopies
clang::OMPFirstprivateClause::getPrivateCopies
clang::OMPFirstprivateClause::getPrivateCopies
clang::OMPFirstprivateClause::setInits
clang::OMPFirstprivateClause::getInits
clang::OMPFirstprivateClause::getInits
clang::OMPFirstprivateClause::Create
clang::OMPFirstprivateClause::CreateEmpty
clang::OMPFirstprivateClause::private_copies
clang::OMPFirstprivateClause::private_copies
clang::OMPFirstprivateClause::inits
clang::OMPFirstprivateClause::inits
clang::OMPFirstprivateClause::children
clang::OMPFirstprivateClause::classof
clang::OMPLastprivateClause::getPrivateCopies
clang::OMPLastprivateClause::getPrivateCopies
clang::OMPLastprivateClause::setSourceExprs
clang::OMPLastprivateClause::getSourceExprs
clang::OMPLastprivateClause::getSourceExprs
clang::OMPLastprivateClause::setDestinationExprs
clang::OMPLastprivateClause::getDestinationExprs
clang::OMPLastprivateClause::getDestinationExprs
clang::OMPLastprivateClause::setAssignmentOps
clang::OMPLastprivateClause::getAssignmentOps
clang::OMPLastprivateClause::getAssignmentOps
clang::OMPLastprivateClause::Create
clang::OMPLastprivateClause::CreateEmpty
clang::OMPLastprivateClause::setPrivateCopies
clang::OMPLastprivateClause::private_copies
clang::OMPLastprivateClause::private_copies
clang::OMPLastprivateClause::source_exprs
clang::OMPLastprivateClause::source_exprs
clang::OMPLastprivateClause::destination_exprs
clang::OMPLastprivateClause::destination_exprs
clang::OMPLastprivateClause::assignment_ops
clang::OMPLastprivateClause::assignment_ops
clang::OMPLastprivateClause::children
clang::OMPLastprivateClause::classof
clang::OMPSharedClause::Create
clang::OMPSharedClause::CreateEmpty
clang::OMPSharedClause::children
clang::OMPSharedClause::classof
clang::OMPReductionClause::ColonLoc
clang::OMPReductionClause::QualifierLoc
clang::OMPReductionClause::NameInfo
clang::OMPReductionClause::setColonLoc
clang::OMPReductionClause::setNameInfo
clang::OMPReductionClause::setQualifierLoc
clang::OMPReductionClause::setPrivates
clang::OMPReductionClause::getPrivates
clang::OMPReductionClause::getPrivates
clang::OMPReductionClause::setLHSExprs
clang::OMPReductionClause::getLHSExprs
clang::OMPReductionClause::getLHSExprs
clang::OMPReductionClause::setRHSExprs
clang::OMPReductionClause::getRHSExprs
clang::OMPReductionClause::getRHSExprs
clang::OMPReductionClause::setReductionOps
clang::OMPReductionClause::getReductionOps
clang::OMPReductionClause::getReductionOps
clang::OMPReductionClause::Create
clang::OMPReductionClause::CreateEmpty
clang::OMPReductionClause::getColonLoc
clang::OMPReductionClause::getNameInfo
clang::OMPReductionClause::getQualifierLoc
clang::OMPReductionClause::privates
clang::OMPReductionClause::privates
clang::OMPReductionClause::lhs_exprs
clang::OMPReductionClause::lhs_exprs
clang::OMPReductionClause::rhs_exprs
clang::OMPReductionClause::rhs_exprs
clang::OMPReductionClause::reduction_ops
clang::OMPReductionClause::reduction_ops
clang::OMPReductionClause::children
clang::OMPReductionClause::classof
clang::OMPTaskReductionClause::ColonLoc
clang::OMPTaskReductionClause::QualifierLoc
clang::OMPTaskReductionClause::NameInfo
clang::OMPTaskReductionClause::setColonLoc
clang::OMPTaskReductionClause::setNameInfo
clang::OMPTaskReductionClause::setQualifierLoc
clang::OMPTaskReductionClause::setPrivates
clang::OMPTaskReductionClause::getPrivates
clang::OMPTaskReductionClause::getPrivates
clang::OMPTaskReductionClause::setLHSExprs
clang::OMPTaskReductionClause::getLHSExprs
clang::OMPTaskReductionClause::getLHSExprs
clang::OMPTaskReductionClause::setRHSExprs
clang::OMPTaskReductionClause::getRHSExprs
clang::OMPTaskReductionClause::getRHSExprs
clang::OMPTaskReductionClause::setReductionOps
clang::OMPTaskReductionClause::getReductionOps
clang::OMPTaskReductionClause::getReductionOps
clang::OMPTaskReductionClause::Create
clang::OMPTaskReductionClause::CreateEmpty
clang::OMPTaskReductionClause::getColonLoc
clang::OMPTaskReductionClause::getNameInfo
clang::OMPTaskReductionClause::getQualifierLoc
clang::OMPTaskReductionClause::privates
clang::OMPTaskReductionClause::privates
clang::OMPTaskReductionClause::lhs_exprs
clang::OMPTaskReductionClause::lhs_exprs
clang::OMPTaskReductionClause::rhs_exprs
clang::OMPTaskReductionClause::rhs_exprs
clang::OMPTaskReductionClause::reduction_ops
clang::OMPTaskReductionClause::reduction_ops
clang::OMPTaskReductionClause::children
clang::OMPTaskReductionClause::classof
clang::OMPInReductionClause::ColonLoc
clang::OMPInReductionClause::QualifierLoc
clang::OMPInReductionClause::NameInfo
clang::OMPInReductionClause::setColonLoc
clang::OMPInReductionClause::setNameInfo
clang::OMPInReductionClause::setQualifierLoc
clang::OMPInReductionClause::setPrivates
clang::OMPInReductionClause::getPrivates
clang::OMPInReductionClause::getPrivates
clang::OMPInReductionClause::setLHSExprs
clang::OMPInReductionClause::getLHSExprs
clang::OMPInReductionClause::getLHSExprs
clang::OMPInReductionClause::setRHSExprs
clang::OMPInReductionClause::getRHSExprs
clang::OMPInReductionClause::getRHSExprs
clang::OMPInReductionClause::setReductionOps
clang::OMPInReductionClause::getReductionOps
clang::OMPInReductionClause::getReductionOps
clang::OMPInReductionClause::setTaskgroupDescriptors
clang::OMPInReductionClause::getTaskgroupDescriptors
clang::OMPInReductionClause::getTaskgroupDescriptors
clang::OMPInReductionClause::Create
clang::OMPInReductionClause::CreateEmpty
clang::OMPInReductionClause::getColonLoc
clang::OMPInReductionClause::getNameInfo
clang::OMPInReductionClause::getQualifierLoc
clang::OMPInReductionClause::privates
clang::OMPInReductionClause::privates
clang::OMPInReductionClause::lhs_exprs
clang::OMPInReductionClause::lhs_exprs
clang::OMPInReductionClause::rhs_exprs
clang::OMPInReductionClause::rhs_exprs
clang::OMPInReductionClause::reduction_ops
clang::OMPInReductionClause::reduction_ops
clang::OMPInReductionClause::taskgroup_descriptors
clang::OMPInReductionClause::taskgroup_descriptors
clang::OMPInReductionClause::children
clang::OMPInReductionClause::classof
clang::OMPLinearClause::Modifier
clang::OMPLinearClause::ModifierLoc
clang::OMPLinearClause::ColonLoc
clang::OMPLinearClause::setStep
clang::OMPLinearClause::setCalcStep
clang::OMPLinearClause::getPrivates
clang::OMPLinearClause::getPrivates
clang::OMPLinearClause::getInits
clang::OMPLinearClause::getInits
clang::OMPLinearClause::getUpdates
clang::OMPLinearClause::getUpdates
clang::OMPLinearClause::getFinals
clang::OMPLinearClause::getFinals
clang::OMPLinearClause::setPrivates
clang::OMPLinearClause::setInits
clang::OMPLinearClause::Create
clang::OMPLinearClause::CreateEmpty
clang::OMPLinearClause::setModifier
clang::OMPLinearClause::getModifier
clang::OMPLinearClause::setModifierLoc
clang::OMPLinearClause::getModifierLoc
clang::OMPLinearClause::setColonLoc
clang::OMPLinearClause::getColonLoc
clang::OMPLinearClause::getStep
clang::OMPLinearClause::getStep
clang::OMPLinearClause::getCalcStep
clang::OMPLinearClause::getCalcStep
clang::OMPLinearClause::setUpdates
clang::OMPLinearClause::setFinals
clang::OMPLinearClause::privates
clang::OMPLinearClause::privates
clang::OMPLinearClause::inits
clang::OMPLinearClause::inits
clang::OMPLinearClause::updates
clang::OMPLinearClause::updates
clang::OMPLinearClause::finals
clang::OMPLinearClause::finals
clang::OMPLinearClause::children
clang::OMPLinearClause::classof
clang::OMPAlignedClause::ColonLoc
clang::OMPAlignedClause::setAlignment
clang::OMPAlignedClause::Create
clang::OMPAlignedClause::CreateEmpty
clang::OMPAlignedClause::setColonLoc
clang::OMPAlignedClause::getColonLoc
clang::OMPAlignedClause::getAlignment
clang::OMPAlignedClause::getAlignment
clang::OMPAlignedClause::children
clang::OMPAlignedClause::classof
clang::OMPCopyinClause::setSourceExprs
clang::OMPCopyinClause::getSourceExprs
clang::OMPCopyinClause::getSourceExprs
clang::OMPCopyinClause::setDestinationExprs
clang::OMPCopyinClause::getDestinationExprs
clang::OMPCopyinClause::getDestinationExprs
clang::OMPCopyinClause::setAssignmentOps
clang::OMPCopyinClause::getAssignmentOps
clang::OMPCopyinClause::getAssignmentOps
clang::OMPCopyinClause::Create
clang::OMPCopyinClause::CreateEmpty
clang::OMPCopyinClause::source_exprs
clang::OMPCopyinClause::source_exprs
clang::OMPCopyinClause::destination_exprs
clang::OMPCopyinClause::destination_exprs
clang::OMPCopyinClause::assignment_ops
clang::OMPCopyinClause::assignment_ops
clang::OMPCopyinClause::children
clang::OMPCopyinClause::classof
clang::OMPCopyprivateClause::setSourceExprs
clang::OMPCopyprivateClause::getSourceExprs
clang::OMPCopyprivateClause::getSourceExprs
clang::OMPCopyprivateClause::setDestinationExprs
clang::OMPCopyprivateClause::getDestinationExprs
clang::OMPCopyprivateClause::getDestinationExprs
clang::OMPCopyprivateClause::setAssignmentOps
clang::OMPCopyprivateClause::getAssignmentOps
clang::OMPCopyprivateClause::getAssignmentOps
clang::OMPCopyprivateClause::Create
clang::OMPCopyprivateClause::CreateEmpty
clang::OMPCopyprivateClause::source_exprs
clang::OMPCopyprivateClause::source_exprs
clang::OMPCopyprivateClause::destination_exprs
clang::OMPCopyprivateClause::destination_exprs
clang::OMPCopyprivateClause::assignment_ops
clang::OMPCopyprivateClause::assignment_ops
clang::OMPCopyprivateClause::children
clang::OMPCopyprivateClause::classof
clang::OMPFlushClause::Create
clang::OMPFlushClause::CreateEmpty
clang::OMPFlushClause::children
clang::OMPFlushClause::classof
clang::OMPDependClause::DepKind
clang::OMPDependClause::DepLoc
clang::OMPDependClause::ColonLoc
clang::OMPDependClause::NumLoops
clang::OMPDependClause::setDependencyKind
clang::OMPDependClause::setDependencyLoc
clang::OMPDependClause::setColonLoc
clang::OMPDependClause::Create
clang::OMPDependClause::CreateEmpty
clang::OMPDependClause::getDependencyKind
clang::OMPDependClause::getDependencyLoc
clang::OMPDependClause::getColonLoc
clang::OMPDependClause::getNumLoops
clang::OMPDependClause::setLoopData
clang::OMPDependClause::getLoopData
clang::OMPDependClause::getLoopData
clang::OMPDependClause::children
clang::OMPDependClause::classof
clang::OMPDeviceClause::LParenLoc
clang::OMPDeviceClause::Device
clang::OMPDeviceClause::setDevice
clang::OMPDeviceClause::setLParenLoc
clang::OMPDeviceClause::getLParenLoc
clang::OMPDeviceClause::getDevice
clang::OMPDeviceClause::getDevice
clang::OMPDeviceClause::children
clang::OMPDeviceClause::classof
clang::OMPThreadsClause::children
clang::OMPThreadsClause::classof
clang::OMPSIMDClause::children
clang::OMPSIMDClause::classof
clang::OMPClauseMappableExprCommon::MappableComponent
clang::OMPClauseMappableExprCommon::MappableComponent::AssociatedExpression
clang::OMPClauseMappableExprCommon::MappableComponent::AssociatedDeclaration
clang::OMPClauseMappableExprCommon::MappableComponent::getAssociatedExpression
clang::OMPClauseMappableExprCommon::MappableComponent::getAssociatedDeclaration
clang::OMPClauseMappableExprCommon::getComponentsTotalNumber
clang::OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber
clang::OMPMappableExprListSizeTy::NumVars
clang::OMPMappableExprListSizeTy::NumUniqueDeclarations
clang::OMPMappableExprListSizeTy::NumComponentLists
clang::OMPMappableExprListSizeTy::NumComponents
clang::OMPMappableExprListClause::NumUniqueDeclarations
clang::OMPMappableExprListClause::NumComponentLists
clang::OMPMappableExprListClause::NumComponents
clang::OMPMappableExprListClause::MapperQualifierLoc
clang::OMPMappableExprListClause::MapperIdInfo
clang::OMPMappableExprListClause::getUniqueDeclsRef
clang::OMPMappableExprListClause::getUniqueDeclsRef
clang::OMPMappableExprListClause::setUniqueDecls
clang::OMPMappableExprListClause::getDeclNumListsRef
clang::OMPMappableExprListClause::getDeclNumListsRef
clang::OMPMappableExprListClause::setDeclNumLists
clang::OMPMappableExprListClause::getComponentListSizesRef
clang::OMPMappableExprListClause::getComponentListSizesRef
clang::OMPMappableExprListClause::setComponentListSizes
clang::OMPMappableExprListClause::getComponentsRef
clang::OMPMappableExprListClause::getComponentsRef
clang::OMPMappableExprListClause::setComponents
clang::OMPMappableExprListClause::setClauseInfo
clang::OMPMappableExprListClause::setMapperQualifierLoc
clang::OMPMappableExprListClause::setMapperIdInfo
clang::OMPMappableExprListClause::getUDMapperRefs
clang::OMPMappableExprListClause::getUDMapperRefs
clang::OMPMappableExprListClause::setUDMapperRefs
clang::OMPMappableExprListClause::getUniqueDeclarationsNum
clang::OMPMappableExprListClause::getTotalComponentListNum
clang::OMPMappableExprListClause::getTotalComponentsNum
clang::OMPMappableExprListClause::getMapperQualifierLoc
clang::OMPMappableExprListClause::getMapperIdInfo
clang::OMPMappableExprListClause::const_component_lists_iterator
clang::OMPMappableExprListClause::const_component_lists_iterator::DeclCur
clang::OMPMappableExprListClause::const_component_lists_iterator::NumListsCur
clang::OMPMappableExprListClause::const_component_lists_iterator::RemainingLists
clang::OMPMappableExprListClause::const_component_lists_iterator::PrevListSize
clang::OMPMappableExprListClause::const_component_lists_iterator::ListSizeCur
clang::OMPMappableExprListClause::const_component_lists_iterator::ListSizeEnd
clang::OMPMappableExprListClause::const_component_lists_iterator::End
clang::OMPMappableExprListClause::component_lists_begin
clang::OMPMappableExprListClause::component_lists_end
clang::OMPMappableExprListClause::component_lists
clang::OMPMappableExprListClause::decl_component_lists_begin
clang::OMPMappableExprListClause::decl_component_lists_end
clang::OMPMappableExprListClause::decl_component_lists
clang::OMPMappableExprListClause::all_decls
clang::OMPMappableExprListClause::all_num_lists
clang::OMPMappableExprListClause::all_lists_sizes
clang::OMPMappableExprListClause::all_components
clang::OMPMappableExprListClause::mapperlist_begin
clang::OMPMappableExprListClause::mapperlist_end
clang::OMPMappableExprListClause::mapperlist_begin
clang::OMPMappableExprListClause::mapperlist_end
clang::OMPMappableExprListClause::mapperlists
clang::OMPMappableExprListClause::mapperlists
clang::OMPMapClause::numTrailingObjects
clang::OMPMapClause::NumberOfModifiers
clang::OMPMapClause::MapTypeModifiers
clang::OMPMapClause::MapTypeModifiersLoc
clang::OMPMapClause::MapType
clang::OMPMapClause::MapTypeIsImplicit
clang::OMPMapClause::MapLoc
clang::OMPMapClause::ColonLoc
clang::OMPMapClause::setMapTypeModifier
clang::OMPMapClause::setMapTypeModifierLoc
clang::OMPMapClause::setMapType
clang::OMPMapClause::setMapLoc
clang::OMPMapClause::setColonLoc
clang::OMPMapClause::Create
clang::OMPMapClause::CreateEmpty
clang::OMPMapClause::getMapType
clang::OMPNumTeamsClause::LParenLoc
clang::OMPNumTeamsClause::NumTeams
clang::OMPNumTeamsClause::setNumTeams
clang::OMPNumTeamsClause::setLParenLoc
clang::OMPNumTeamsClause::getLParenLoc
clang::OMPNumTeamsClause::getNumTeams
clang::OMPNumTeamsClause::getNumTeams
clang::OMPNumTeamsClause::children
clang::OMPNumTeamsClause::classof
clang::OMPThreadLimitClause::LParenLoc
clang::OMPThreadLimitClause::ThreadLimit
clang::OMPThreadLimitClause::setThreadLimit
clang::OMPThreadLimitClause::setLParenLoc
clang::OMPThreadLimitClause::getLParenLoc
clang::OMPThreadLimitClause::getThreadLimit
clang::OMPThreadLimitClause::getThreadLimit
clang::OMPThreadLimitClause::children
clang::OMPThreadLimitClause::classof
clang::OMPPriorityClause::LParenLoc
clang::OMPPriorityClause::Priority
clang::OMPPriorityClause::setPriority
clang::OMPPriorityClause::setLParenLoc
clang::OMPPriorityClause::getLParenLoc
clang::OMPPriorityClause::getPriority
clang::OMPPriorityClause::getPriority
clang::OMPPriorityClause::children
clang::OMPPriorityClause::classof
clang::OMPGrainsizeClause::LParenLoc
clang::OMPGrainsizeClause::Grainsize
clang::OMPGrainsizeClause::setGrainsize
clang::OMPGrainsizeClause::setLParenLoc
clang::OMPGrainsizeClause::getLParenLoc
clang::OMPGrainsizeClause::getGrainsize
clang::OMPGrainsizeClause::children
clang::OMPGrainsizeClause::classof
clang::OMPNogroupClause::children
clang::OMPNogroupClause::classof
clang::OMPNumTasksClause::LParenLoc
clang::OMPNumTasksClause::NumTasks
clang::OMPNumTasksClause::setNumTasks
clang::OMPNumTasksClause::setLParenLoc
clang::OMPNumTasksClause::getLParenLoc
clang::OMPNumTasksClause::getNumTasks
clang::OMPNumTasksClause::children
clang::OMPNumTasksClause::classof
clang::OMPHintClause::LParenLoc
clang::OMPHintClause::Hint
clang::OMPHintClause::setHint
clang::OMPHintClause::setLParenLoc
clang::OMPHintClause::getLParenLoc
clang::OMPHintClause::getHint
clang::OMPHintClause::children
clang::OMPHintClause::classof
clang::OMPDistScheduleClause::LParenLoc
clang::OMPDistScheduleClause::Kind
clang::OMPDistScheduleClause::KindLoc
clang::OMPDistScheduleClause::CommaLoc
clang::OMPDistScheduleClause::ChunkSize
clang::OMPDistScheduleClause::setDistScheduleKind
clang::OMPDistScheduleClause::setLParenLoc
clang::OMPDistScheduleClause::setDistScheduleKindLoc
clang::OMPDistScheduleClause::setCommaLoc
clang::OMPDistScheduleClause::setChunkSize
clang::OMPDistScheduleClause::getDistScheduleKind
clang::OMPDistScheduleClause::getLParenLoc
clang::OMPDistScheduleClause::getDistScheduleKindLoc
clang::OMPDistScheduleClause::getCommaLoc
clang::OMPDistScheduleClause::getChunkSize
clang::OMPDistScheduleClause::getChunkSize
clang::OMPDistScheduleClause::children
clang::OMPDistScheduleClause::classof
clang::OMPDefaultmapClause::LParenLoc
clang::OMPDefaultmapClause::Modifier
clang::OMPDefaultmapClause::ModifierLoc
clang::OMPDefaultmapClause::Kind
clang::OMPDefaultmapClause::KindLoc
clang::OMPDefaultmapClause::setDefaultmapKind
clang::OMPDefaultmapClause::setDefaultmapModifier
clang::OMPDefaultmapClause::setDefaultmapModifierLoc
clang::OMPDefaultmapClause::setLParenLoc
clang::OMPDefaultmapClause::setDefaultmapKindLoc
clang::OMPDefaultmapClause::getDefaultmapKind
clang::OMPDefaultmapClause::getDefaultmapModifier
clang::OMPDefaultmapClause::getLParenLoc
clang::OMPDefaultmapClause::getDefaultmapKindLoc
clang::OMPDefaultmapClause::getDefaultmapModifierLoc
clang::OMPDefaultmapClause::children
clang::OMPDefaultmapClause::classof
clang::OMPToClause::numTrailingObjects
clang::OMPToClause::Create
clang::OMPToClause::CreateEmpty
clang::OMPToClause::children
clang::OMPToClause::classof
clang::OMPFromClause::numTrailingObjects
clang::OMPFromClause::Create
clang::OMPFromClause::CreateEmpty
clang::OMPFromClause::children
clang::OMPFromClause::classof
clang::OMPUseDevicePtrClause::numTrailingObjects
clang::OMPUseDevicePtrClause::setPrivateCopies
clang::OMPUseDevicePtrClause::getPrivateCopies
clang::OMPUseDevicePtrClause::getPrivateCopies
clang::OMPUseDevicePtrClause::setInits
clang::OMPUseDevicePtrClause::getInits
clang::OMPUseDevicePtrClause::getInits
clang::OMPUseDevicePtrClause::Create
clang::OMPUseDevicePtrClause::CreateEmpty
clang::OMPUseDevicePtrClause::private_copies
clang::OMPUseDevicePtrClause::private_copies
clang::OMPUseDevicePtrClause::inits
clang::OMPUseDevicePtrClause::inits
clang::OMPUseDevicePtrClause::children
clang::OMPUseDevicePtrClause::classof
clang::OMPIsDevicePtrClause::numTrailingObjects
clang::OMPIsDevicePtrClause::Create
clang::OMPIsDevicePtrClause::CreateEmpty
clang::OMPIsDevicePtrClause::children
clang::OMPIsDevicePtrClause::classof
clang::OMPClauseVisitorBase::Visit
clang::OMPClauseVisitorBase::VisitOMPClause
clang::OMPClausePrinter::OS
clang::OMPClausePrinter::Policy
clang::OMPClausePrinter::VisitOMPClauseList