@@ -9046,6 +9046,132 @@ class OMPXDynCGroupMemClause
90469046 Expr *getSize () const { return getStmtAs<Expr>(); }
90479047};
90489048
9049+ // / This represents the 'doacross' clause for the '#pragma omp ordered'
9050+ // / directive.
9051+ // /
9052+ // / \code
9053+ // / #pragma omp ordered doacross(sink: i-1, j-1)
9054+ // / \endcode
9055+ // / In this example directive '#pragma omp ordered' with clause 'doacross' with
9056+ // / a dependence-type 'sink' and loop-iteration vector expressions i-1 and j-1.
9057+ class OMPDoacrossClause final
9058+ : public OMPVarListClause<OMPDoacrossClause>,
9059+ private llvm::TrailingObjects<OMPDoacrossClause, Expr *> {
9060+ friend class OMPClauseReader ;
9061+ friend OMPVarListClause;
9062+ friend TrailingObjects;
9063+
9064+ // / Dependence type (sink or source).
9065+ OpenMPDoacrossClauseModifier DepType = OMPC_DOACROSS_unknown;
9066+
9067+ // / Dependence type location.
9068+ SourceLocation DepLoc;
9069+
9070+ // / Colon location.
9071+ SourceLocation ColonLoc;
9072+
9073+ // / Number of loops, associated with the doacross clause.
9074+ unsigned NumLoops = 0 ;
9075+
9076+ // / Build clause with number of expressions \a N.
9077+ // /
9078+ // / \param StartLoc Starting location of the clause.
9079+ // / \param LParenLoc Location of '('.
9080+ // / \param EndLoc Ending location of the clause.
9081+ // / \param N Number of expressions in the clause.
9082+ // / \param NumLoops Number of loops associated with the clause.
9083+ OMPDoacrossClause (SourceLocation StartLoc, SourceLocation LParenLoc,
9084+ SourceLocation EndLoc, unsigned N, unsigned NumLoops)
9085+ : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross, StartLoc,
9086+ LParenLoc, EndLoc, N),
9087+ NumLoops (NumLoops) {}
9088+
9089+ // / Build an empty clause.
9090+ // /
9091+ // / \param N Number of expressions in the clause.
9092+ // / \param NumLoops Number of loops associated with the clause.
9093+ explicit OMPDoacrossClause (unsigned N, unsigned NumLoops)
9094+ : OMPVarListClause<OMPDoacrossClause>(llvm::omp::OMPC_doacross,
9095+ SourceLocation (), SourceLocation(),
9096+ SourceLocation(), N),
9097+ NumLoops(NumLoops) {}
9098+
9099+ // / Set dependence type.
9100+ void setDependenceType (OpenMPDoacrossClauseModifier M) { DepType = M; }
9101+
9102+ // / Set dependence type location.
9103+ void setDependenceLoc (SourceLocation Loc) { DepLoc = Loc; }
9104+
9105+ // / Set colon location.
9106+ void setColonLoc (SourceLocation Loc) { ColonLoc = Loc; }
9107+
9108+ public:
9109+ // / Creates clause with a list of expressions \a VL.
9110+ // /
9111+ // / \param C AST context.
9112+ // / \param StartLoc Starting location of the clause.
9113+ // / \param LParenLoc Location of '('.
9114+ // / \param EndLoc Ending location of the clause.
9115+ // / \param DepType The dependence type.
9116+ // / \param DepLoc Location of the dependence type.
9117+ // / \param ColonLoc Location of ':'.
9118+ // / \param VL List of references to the expressions.
9119+ // / \param NumLoops Number of loops that associated with the clause.
9120+ static OMPDoacrossClause *
9121+ Create (const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
9122+ SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType,
9123+ SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
9124+ unsigned NumLoops);
9125+
9126+ // / Creates an empty clause with \a N expressions.
9127+ // /
9128+ // / \param C AST context.
9129+ // / \param N The number of expressions.
9130+ // / \param NumLoops Number of loops that is associated with this clause.
9131+ static OMPDoacrossClause *CreateEmpty (const ASTContext &C, unsigned N,
9132+ unsigned NumLoops);
9133+
9134+ // / Get dependence type.
9135+ OpenMPDoacrossClauseModifier getDependenceType () const { return DepType; }
9136+
9137+ // / Get dependence type location.
9138+ SourceLocation getDependenceLoc () const { return DepLoc; }
9139+
9140+ // / Get colon location.
9141+ SourceLocation getColonLoc () const { return ColonLoc; }
9142+
9143+ // / Get number of loops associated with the clause.
9144+ unsigned getNumLoops () const { return NumLoops; }
9145+
9146+ // / Set the loop data.
9147+ void setLoopData (unsigned NumLoop, Expr *Cnt);
9148+
9149+ // / Get the loop data.
9150+ Expr *getLoopData (unsigned NumLoop);
9151+ const Expr *getLoopData (unsigned NumLoop) const ;
9152+
9153+ child_range children () {
9154+ return child_range (reinterpret_cast <Stmt **>(varlist_begin ()),
9155+ reinterpret_cast <Stmt **>(varlist_end ()));
9156+ }
9157+
9158+ const_child_range children () const {
9159+ auto Children = const_cast <OMPDoacrossClause *>(this )->children ();
9160+ return const_child_range (Children.begin (), Children.end ());
9161+ }
9162+
9163+ child_range used_children () {
9164+ return child_range (child_iterator (), child_iterator ());
9165+ }
9166+ const_child_range used_children () const {
9167+ return const_child_range (const_child_iterator (), const_child_iterator ());
9168+ }
9169+
9170+ static bool classof (const OMPClause *T) {
9171+ return T->getClauseKind () == llvm::omp::OMPC_doacross;
9172+ }
9173+ };
9174+
90499175} // namespace clang
90509176
90519177#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
0 commit comments