@@ -158,6 +158,68 @@ class OMPThreadPrivateDecl final : public OMPDeclarativeDirective<Decl> {
158158 static bool classofKind (Kind K) { return K == OMPThreadPrivate; }
159159};
160160
161+ // / This represents '#pragma omp groupprivate ...' directive.
162+ // / For example, in the following, both 'a' and 'A::b' are groupprivate:
163+ // /
164+ // / \code
165+ // / int a;
166+ // / #pragma omp groupprivate(a)
167+ // / struct A {
168+ // / static int b;
169+ // / #pragma omp groupprivate(b)
170+ // / };
171+ // / \endcode
172+ // /
173+ class OMPGroupPrivateDecl final : public OMPDeclarativeDirective<Decl> {
174+ friend class OMPDeclarativeDirective <Decl>;
175+
176+ LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION ();
177+
178+ OMPGroupPrivateDecl (DeclContext *DC = nullptr ,
179+ SourceLocation L = SourceLocation())
180+ : OMPDeclarativeDirective<Decl>(OMPGroupPrivate, DC, L) {}
181+
182+ ArrayRef<const Expr *> getVars () const {
183+ auto **Storage = reinterpret_cast <Expr **>(Data->getChildren ().data ());
184+ return {Storage, Data->getNumChildren ()};
185+ }
186+
187+ MutableArrayRef<Expr *> getVars () {
188+ auto **Storage = reinterpret_cast <Expr **>(Data->getChildren ().data ());
189+ return {Storage, Data->getNumChildren ()};
190+ }
191+
192+ void setVars (ArrayRef<Expr *> VL);
193+
194+ public:
195+ static OMPGroupPrivateDecl *Create (ASTContext &C, DeclContext *DC,
196+ SourceLocation L, ArrayRef<Expr *> VL);
197+ static OMPGroupPrivateDecl *CreateDeserialized (ASTContext &C, GlobalDeclID ID,
198+ unsigned N);
199+
200+ typedef MutableArrayRef<Expr *>::iterator varlist_iterator;
201+ typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
202+ typedef llvm::iterator_range<varlist_iterator> varlist_range;
203+ typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
204+
205+ unsigned varlist_size () const { return Data->getNumChildren (); }
206+ bool varlist_empty () const { return Data->getChildren ().empty (); }
207+
208+ varlist_range varlist () {
209+ return varlist_range (varlist_begin (), varlist_end ());
210+ }
211+ varlist_const_range varlist () const {
212+ return varlist_const_range (varlist_begin (), varlist_end ());
213+ }
214+ varlist_iterator varlist_begin () { return getVars ().begin (); }
215+ varlist_iterator varlist_end () { return getVars ().end (); }
216+ varlist_const_iterator varlist_begin () const { return getVars ().begin (); }
217+ varlist_const_iterator varlist_end () const { return getVars ().end (); }
218+
219+ static bool classof (const Decl *D) { return classofKind (D->getKind ()); }
220+ static bool classofKind (Kind K) { return K == OMPGroupPrivate; }
221+ };
222+
161223enum class OMPDeclareReductionInitKind {
162224 Call, // Initialized by function call.
163225 Direct, // omp_priv(<expr>)
0 commit comments