@@ -1250,32 +1250,59 @@ class OpenACCCreateClause final
12501250 SourceLocation EndLoc);
12511251};
12521252
1253+ // A structure to stand in for the recipe on a reduction. RecipeDecl is the
1254+ // 'main' declaration used for initializaiton, which is fixed.
1255+ struct OpenACCReductionRecipe {
1256+ VarDecl *RecipeDecl;
1257+ // TODO: OpenACC: this should eventually have the operations here too.
1258+ };
1259+
12531260class OpenACCReductionClause final
12541261 : public OpenACCClauseWithVarList,
1255- private llvm::TrailingObjects<OpenACCReductionClause, Expr *> {
1262+ private llvm::TrailingObjects<OpenACCReductionClause, Expr *,
1263+ OpenACCReductionRecipe> {
12561264 friend TrailingObjects;
12571265 OpenACCReductionOperator Op;
12581266
12591267 OpenACCReductionClause (SourceLocation BeginLoc, SourceLocation LParenLoc,
12601268 OpenACCReductionOperator Operator,
1261- ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1269+ ArrayRef<Expr *> VarList,
1270+ ArrayRef<OpenACCReductionRecipe> Recipes,
1271+ SourceLocation EndLoc)
12621272 : OpenACCClauseWithVarList(OpenACCClauseKind::Reduction, BeginLoc,
12631273 LParenLoc, EndLoc),
12641274 Op (Operator) {
1265- setExprs (getTrailingObjects (VarList.size ()), VarList);
1275+ assert (VarList.size () == Recipes.size ());
1276+ setExprs (getTrailingObjects<Expr *>(VarList.size ()), VarList);
1277+ llvm::uninitialized_copy (Recipes, getTrailingObjects<
1278+ OpenACCReductionRecipe > ());
12661279 }
12671280
12681281public:
12691282 static bool classof (const OpenACCClause *C) {
12701283 return C->getClauseKind () == OpenACCClauseKind::Reduction;
12711284 }
12721285
1286+ ArrayRef<OpenACCReductionRecipe> getRecipes () {
1287+ return ArrayRef<OpenACCReductionRecipe>{
1288+ getTrailingObjects<OpenACCReductionRecipe>(), getExprs ().size ()};
1289+ }
1290+
1291+ ArrayRef<OpenACCReductionRecipe> getRecipes () const {
1292+ return ArrayRef<OpenACCReductionRecipe>{
1293+ getTrailingObjects<OpenACCReductionRecipe>(), getExprs ().size ()};
1294+ }
1295+
12731296 static OpenACCReductionClause *
12741297 Create (const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
12751298 OpenACCReductionOperator Operator, ArrayRef<Expr *> VarList,
1276- SourceLocation EndLoc);
1299+ ArrayRef<OpenACCReductionRecipe> Recipes, SourceLocation EndLoc);
12771300
12781301 OpenACCReductionOperator getReductionOp () const { return Op; }
1302+
1303+ size_t numTrailingObjects (OverloadToken<Expr *>) const {
1304+ return getExprs ().size ();
1305+ }
12791306};
12801307
12811308class OpenACCLinkClause final
0 commit comments