@@ -7252,6 +7252,107 @@ class OMPUsesAllocatorsClause final
72527252 }
72537253};
72547254
7255+ // / This represents clause 'affinity' in the '#pragma omp task'-based
7256+ // / directives.
7257+ // /
7258+ // / \code
7259+ // / #pragma omp task affinity(iterator(i = 0:n) : ([3][n])a, b[:n], c[i])
7260+ // / \endcode
7261+ // / In this example directive '#pragma omp task' has clause 'affinity' with the
7262+ // / affinity modifer 'iterator(i = 0:n)' and locator items '([3][n])a', 'b[:n]'
7263+ // / and 'c[i]'.
7264+ class OMPAffinityClause final
7265+ : public OMPVarListClause<OMPAffinityClause>,
7266+ private llvm::TrailingObjects<OMPAffinityClause, Expr *> {
7267+ friend class OMPClauseReader ;
7268+ friend OMPVarListClause;
7269+ friend TrailingObjects;
7270+
7271+ // / Location of ':' symbol.
7272+ SourceLocation ColonLoc;
7273+
7274+ // / Build clause.
7275+ // /
7276+ // / \param StartLoc Starting location of the clause.
7277+ // / \param LParenLoc Location of '('.
7278+ // / \param ColonLoc Location of ':'.
7279+ // / \param EndLoc Ending location of the clause.
7280+ // / \param N Number of locators asssociated with the clause.
7281+ OMPAffinityClause (SourceLocation StartLoc, SourceLocation LParenLoc,
7282+ SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N)
7283+ : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, StartLoc,
7284+ LParenLoc, EndLoc, N) {}
7285+
7286+ // / Build an empty clause.
7287+ // / \param N Number of locators asssociated with the clause.
7288+ // /
7289+ explicit OMPAffinityClause (unsigned N)
7290+ : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity,
7291+ SourceLocation (), SourceLocation(),
7292+ SourceLocation(), N) {}
7293+
7294+ // / Sets the affinity modifier for the clause, if any.
7295+ void setModifier (Expr *E) {
7296+ getTrailingObjects<Expr *>()[varlist_size ()] = E;
7297+ }
7298+
7299+ // / Sets the location of ':' symbol.
7300+ void setColonLoc (SourceLocation Loc) { ColonLoc = Loc; }
7301+
7302+ public:
7303+ // / Creates clause with a modifier a list of locator items.
7304+ // /
7305+ // / \param C AST context.
7306+ // / \param StartLoc Starting location of the clause.
7307+ // / \param LParenLoc Location of '('.
7308+ // / \param ColonLoc Location of ':'.
7309+ // / \param EndLoc Ending location of the clause.
7310+ // / \param Locators List of locator items.
7311+ static OMPAffinityClause *Create (const ASTContext &C, SourceLocation StartLoc,
7312+ SourceLocation LParenLoc,
7313+ SourceLocation ColonLoc,
7314+ SourceLocation EndLoc, Expr *Modifier,
7315+ ArrayRef<Expr *> Locators);
7316+
7317+ // / Creates an empty clause with the place for \p N locator items.
7318+ // /
7319+ // / \param C AST context.
7320+ // / \param N The number of locator items.
7321+ static OMPAffinityClause *CreateEmpty (const ASTContext &C, unsigned N);
7322+
7323+ // / Gets affinity modifier.
7324+ Expr *getModifier () { return getTrailingObjects<Expr *>()[varlist_size ()]; }
7325+ Expr *getModifier () const {
7326+ return getTrailingObjects<Expr *>()[varlist_size ()];
7327+ }
7328+
7329+ // / Gets the location of ':' symbol.
7330+ SourceLocation getColonLoc () const { return ColonLoc; }
7331+
7332+ // Iterators
7333+ child_range children () {
7334+ int Offset = getModifier () ? 1 : 0 ;
7335+ return child_range (reinterpret_cast <Stmt **>(varlist_begin ()),
7336+ reinterpret_cast <Stmt **>(varlist_end () + Offset));
7337+ }
7338+
7339+ const_child_range children () const {
7340+ auto Children = const_cast <OMPAffinityClause *>(this )->children ();
7341+ return const_child_range (Children.begin (), Children.end ());
7342+ }
7343+
7344+ child_range used_children () {
7345+ return child_range (child_iterator (), child_iterator ());
7346+ }
7347+ const_child_range used_children () const {
7348+ return const_child_range (const_child_iterator (), const_child_iterator ());
7349+ }
7350+
7351+ static bool classof (const OMPClause *T) {
7352+ return T->getClauseKind () == llvm::omp::OMPC_affinity;
7353+ }
7354+ };
7355+
72557356// / This class implements a simple visitor for OMPClause
72567357// / subclasses.
72577358template <class ImplClass , template <typename > class Ptr , typename RetTy>
0 commit comments