@@ -878,23 +878,46 @@ class OpenACCPrivateClause final
878878
879879class OpenACCFirstPrivateClause final
880880 : public OpenACCClauseWithVarList,
881- private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *> {
881+ private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *,
882+ VarDecl *> {
882883 friend TrailingObjects;
883884
884885 OpenACCFirstPrivateClause (SourceLocation BeginLoc, SourceLocation LParenLoc,
885- ArrayRef<Expr *> VarList, SourceLocation EndLoc)
886+ ArrayRef<Expr *> VarList,
887+ ArrayRef<VarDecl *> InitRecipes,
888+ SourceLocation EndLoc)
886889 : OpenACCClauseWithVarList(OpenACCClauseKind::FirstPrivate, BeginLoc,
887890 LParenLoc, EndLoc) {
888- setExprs (getTrailingObjects (VarList.size ()), VarList);
891+ assert (VarList.size () == InitRecipes.size ());
892+ setExprs (getTrailingObjects<Expr *>(VarList.size ()), VarList);
893+ llvm::uninitialized_copy (InitRecipes, getTrailingObjects<VarDecl *>());
889894 }
890895
891896public:
892897 static bool classof (const OpenACCClause *C) {
893898 return C->getClauseKind () == OpenACCClauseKind::FirstPrivate;
894899 }
900+
901+ // Gets a list of 'made up' `VarDecl` objects that can be used by codegen to
902+ // ensure that we properly initialize each of these variables.
903+ ArrayRef<VarDecl *> getInitRecipes () {
904+ return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(),
905+ getExprs ().size ()};
906+ }
907+
908+ ArrayRef<VarDecl *> getInitRecipes () const {
909+ return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(),
910+ getExprs ().size ()};
911+ }
912+
895913 static OpenACCFirstPrivateClause *
896914 Create (const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
897- ArrayRef<Expr *> VarList, SourceLocation EndLoc);
915+ ArrayRef<Expr *> VarList, ArrayRef<VarDecl *> InitRecipes,
916+ SourceLocation EndLoc);
917+
918+ size_t numTrailingObjects (OverloadToken<Expr *>) const {
919+ return getExprs ().size ();
920+ }
898921};
899922
900923class OpenACCDevicePtrClause final
0 commit comments