diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -2794,16 +2794,25 @@ : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic, SourceLocation(), SourceLocation()) {} + enum DataPositionTy : size_t { + POS_X = 0, + POS_V, + POS_E, + POS_UpdateExpr, + }; + /// Set 'x' part of the associated expression/statement. - void setX(Expr *X) { Data->getChildren()[0] = X; } + void setX(Expr *X) { Data->getChildren()[DataPositionTy::POS_X] = X; } /// Set helper expression of the form /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'. - void setUpdateExpr(Expr *UE) { Data->getChildren()[1] = UE; } + void setUpdateExpr(Expr *UE) { + Data->getChildren()[DataPositionTy::POS_UpdateExpr] = UE; + } /// Set 'v' part of the associated expression/statement. - void setV(Expr *V) { Data->getChildren()[2] = V; } + void setV(Expr *V) { Data->getChildren()[DataPositionTy::POS_V] = V; } /// Set 'expr' part of the associated expression/statement. - void setExpr(Expr *E) { Data->getChildren()[3] = E; } + void setExpr(Expr *E) { Data->getChildren()[DataPositionTy::POS_E] = E; } public: /// Creates directive with a list of \a Clauses and 'x', 'v' and 'expr' @@ -2840,16 +2849,22 @@ unsigned NumClauses, EmptyShell); /// Get 'x' part of the associated expression/statement. - Expr *getX() { return cast_or_null(Data->getChildren()[0]); } + Expr *getX() { + return cast_or_null(Data->getChildren()[DataPositionTy::POS_X]); + } const Expr *getX() const { - return cast_or_null(Data->getChildren()[0]); + return cast_or_null(Data->getChildren()[DataPositionTy::POS_X]); } /// Get helper expression of the form /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'. - Expr *getUpdateExpr() { return cast_or_null(Data->getChildren()[1]); } + Expr *getUpdateExpr() { + return cast_or_null( + Data->getChildren()[DataPositionTy::POS_UpdateExpr]); + } const Expr *getUpdateExpr() const { - return cast_or_null(Data->getChildren()[1]); + return cast_or_null( + Data->getChildren()[DataPositionTy::POS_UpdateExpr]); } /// Return true if helper update expression has form /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form @@ -2859,14 +2874,18 @@ /// 'x', false if 'v' must be updated to the new value of 'x'. bool isPostfixUpdate() const { return IsPostfixUpdate; } /// Get 'v' part of the associated expression/statement. - Expr *getV() { return cast_or_null(Data->getChildren()[2]); } + Expr *getV() { + return cast_or_null(Data->getChildren()[DataPositionTy::POS_V]); + } const Expr *getV() const { - return cast_or_null(Data->getChildren()[2]); + return cast_or_null(Data->getChildren()[DataPositionTy::POS_V]); } /// Get 'expr' part of the associated expression/statement. - Expr *getExpr() { return cast_or_null(Data->getChildren()[3]); } + Expr *getExpr() { + return cast_or_null(Data->getChildren()[DataPositionTy::POS_E]); + } const Expr *getExpr() const { - return cast_or_null(Data->getChildren()[3]); + return cast_or_null(Data->getChildren()[DataPositionTy::POS_E]); } static bool classof(const Stmt *T) {