Author: Shilei Tian Date: 2022-04-15T11:41:26-04:00 New Revision: 52e6a27690ca8e5f07cc646716c3736475b7746b
URL: https://github.com/llvm/llvm-project/commit/52e6a27690ca8e5f07cc646716c3736475b7746b DIFF: https://github.com/llvm/llvm-project/commit/52e6a27690ca8e5f07cc646716c3736475b7746b.diff LOG: Clean up `OMPAtomicDirective::Create` Added: Modified: clang/include/clang/AST/StmtOpenMP.h clang/lib/AST/StmtOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h index 28b3567b36556..0aa318d84a93f 100644 --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -2889,6 +2889,27 @@ class OMPAtomicDirective : public OMPExecutableDirective { void setCond(Expr *C) { Data->getChildren()[DataPositionTy::POS_Cond] = C; } public: + struct Expressions { + /// 'x' part of the associated expression/statement. + Expr *X = nullptr; + /// 'v' part of the associated expression/statement. + Expr *V = nullptr; + /// 'expr' part of the associated expression/statement. + Expr *E = nullptr; + /// UE Helper expression of the form: + /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or + /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'. + Expr *UE = nullptr; + /// 'd' part of the associated expression/statement. + Expr *D = nullptr; + /// Conditional expression in `atomic compare` construct. + Expr *Cond = nullptr; + /// True if UE has the first form and false if the second. + bool IsXLHSInRHSPart; + /// True if original value of 'x' must be stored in 'v', not an updated one. + bool IsPostfixUpdate; + }; + /// Creates directive with a list of \a Clauses and 'x', 'v' and 'expr' /// parts of the atomic construct (see Section 2.12.6, atomic Construct, for /// detailed description of 'x', 'v' and 'expr'). @@ -2898,23 +2919,12 @@ class OMPAtomicDirective : public OMPExecutableDirective { /// \param EndLoc Ending Location of the directive. /// \param Clauses List of clauses. /// \param AssociatedStmt Statement, associated with the directive. - /// \param X 'x' part of the associated expression/statement. - /// \param V 'v' part of the associated expression/statement. - /// \param E 'expr' part of the associated expression/statement. - /// \param UE Helper expression of the form - /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or - /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'. - /// \param D 'd' part of the associated expression/statement. - /// \param Cond Conditional expression in `atomic compare` construct. - /// \param IsXLHSInRHSPart true if \a UE has the first form and false if the - /// second. - /// \param IsPostfixUpdate true if original value of 'x' must be stored in - /// 'v', not an updated one. - static OMPAtomicDirective * - Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, - ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V, - Expr *E, Expr *UE, Expr *D, Expr *Cond, bool IsXLHSInRHSPart, - bool IsPostfixUpdate); + /// \param Exprs Associated expressions or statements. + static OMPAtomicDirective *Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation EndLoc, + ArrayRef<OMPClause *> Clauses, + Stmt *AssociatedStmt, Expressions Exprs); /// Creates an empty directive with the place for \a NumClauses /// clauses. diff --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp index 84a4de00328a8..15e13da27dd84 100644 --- a/clang/lib/AST/StmtOpenMP.cpp +++ b/clang/lib/AST/StmtOpenMP.cpp @@ -866,19 +866,17 @@ OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C, OMPAtomicDirective * OMPAtomicDirective::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, - Stmt *AssociatedStmt, Expr *X, Expr *V, Expr *E, - Expr *UE, Expr *D, Expr *Cond, bool IsXLHSInRHSPart, - bool IsPostfixUpdate) { + Stmt *AssociatedStmt, Expressions Exprs) { auto *Dir = createDirective<OMPAtomicDirective>( C, Clauses, AssociatedStmt, /*NumChildren=*/6, StartLoc, EndLoc); - Dir->setX(X); - Dir->setV(V); - Dir->setExpr(E); - Dir->setUpdateExpr(UE); - Dir->setD(D); - Dir->setCond(Cond); - Dir->IsXLHSInRHSPart = IsXLHSInRHSPart; - Dir->IsPostfixUpdate = IsPostfixUpdate; + Dir->setX(Exprs.X); + Dir->setV(Exprs.V); + Dir->setExpr(Exprs.E); + Dir->setUpdateExpr(Exprs.UE); + Dir->setD(Exprs.D); + Dir->setCond(Exprs.Cond); + Dir->IsXLHSInRHSPart = Exprs.IsXLHSInRHSPart; + Dir->IsPostfixUpdate = Exprs.IsPostfixUpdate; return Dir; } diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 9757d0ebb18d8..9f3574e8d0e75 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -12505,9 +12505,9 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses, setFunctionHasBranchProtectedScope(); - return OMPAtomicDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt, - X, V, E, UE, D, CE, IsXLHSInRHSPart, - IsPostfixUpdate); + return OMPAtomicDirective::Create( + Context, StartLoc, EndLoc, Clauses, AStmt, + {X, V, E, UE, D, CE, IsXLHSInRHSPart, IsPostfixUpdate}); } StmtResult Sema::ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits