@@ -405,6 +405,73 @@ class OMPRequiresDecl final
405405 static bool classof (const Decl *D) { return classofKind (D->getKind ()); }
406406 static bool classofKind (Kind K) { return K == OMPRequires; }
407407};
408+
409+ // / This represents '#pragma omp allocate ...' directive.
410+ // / For example, in the following, the default allocator is used for both 'a'
411+ // / and 'A::b':
412+ // /
413+ // / \code
414+ // / int a;
415+ // / #pragma omp allocate(a)
416+ // / struct A {
417+ // / static int b;
418+ // / #pragma omp allocate(b)
419+ // / };
420+ // / \endcode
421+ // /
422+ class OMPAllocateDecl final
423+ : public Decl,
424+ private llvm::TrailingObjects<OMPAllocateDecl, Expr *> {
425+ friend class ASTDeclReader ;
426+ friend TrailingObjects;
427+
428+ // / Number of variable within the allocate directive.
429+ unsigned NumVars = 0 ;
430+
431+ virtual void anchor ();
432+
433+ OMPAllocateDecl (Kind DK, DeclContext *DC, SourceLocation L)
434+ : Decl(DK, DC, L) {}
435+
436+ ArrayRef<const Expr *> getVars () const {
437+ return llvm::makeArrayRef (getTrailingObjects<Expr *>(), NumVars);
438+ }
439+
440+ MutableArrayRef<Expr *> getVars () {
441+ return MutableArrayRef<Expr *>(getTrailingObjects<Expr *>(), NumVars);
442+ }
443+
444+ void setVars (ArrayRef<Expr *> VL);
445+
446+ public:
447+ static OMPAllocateDecl *Create (ASTContext &C, DeclContext *DC,
448+ SourceLocation L, ArrayRef<Expr *> VL);
449+ static OMPAllocateDecl *CreateDeserialized (ASTContext &C, unsigned ID,
450+ unsigned N);
451+
452+ typedef MutableArrayRef<Expr *>::iterator varlist_iterator;
453+ typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
454+ typedef llvm::iterator_range<varlist_iterator> varlist_range;
455+ typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
456+
457+ unsigned varlist_size () const { return NumVars; }
458+ bool varlist_empty () const { return NumVars == 0 ; }
459+
460+ varlist_range varlists () {
461+ return varlist_range (varlist_begin (), varlist_end ());
462+ }
463+ varlist_const_range varlists () const {
464+ return varlist_const_range (varlist_begin (), varlist_end ());
465+ }
466+ varlist_iterator varlist_begin () { return getVars ().begin (); }
467+ varlist_iterator varlist_end () { return getVars ().end (); }
468+ varlist_const_iterator varlist_begin () const { return getVars ().begin (); }
469+ varlist_const_iterator varlist_end () const { return getVars ().end (); }
470+
471+ static bool classof (const Decl *D) { return classofKind (D->getKind ()); }
472+ static bool classofKind (Kind K) { return K == OMPAllocate; }
473+ };
474+
408475} // end namespace clang
409476
410477#endif
0 commit comments