From 64d33f1d46ec8307de3ceeaebd90944792ddf8f8 Mon Sep 17 00:00:00 2001 From: Alexander Musman Date: Wed, 4 Jun 2014 07:53:32 +0000 Subject: [PATCH] [OPENMP] Small comment and reformatting fixes. Fix post-commit review comments by Carlo Bertolli for commit r209660 - OMP collapse clause. Re-formatted TransformOMP* functions in TreeTransform.h with clang-format. llvm-svn: 210169 --- clang/include/clang/Sema/Sema.h | 3 +- clang/lib/Sema/SemaOpenMP.cpp | 13 ++-- clang/lib/Sema/TreeTransform.h | 134 ++++++++++++++++++---------------------- 3 files changed, 70 insertions(+), 80 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 7b1be83..39bb156 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -7326,7 +7326,8 @@ public: SourceLocation LParenLoc, SourceLocation EndLoc); /// \brief Called on well-formed 'collapse' clause. - OMPClause *ActOnOpenMPCollapseClause(Expr *Num, SourceLocation StartLoc, + OMPClause *ActOnOpenMPCollapseClause(Expr *NumForLoops, + SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 32b956b..db90657 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1486,18 +1486,21 @@ OMPClause *Sema::ActOnOpenMPSafelenClause(Expr *Len, SourceLocation StartLoc, OMPSafelenClause(Safelen.get(), StartLoc, LParenLoc, EndLoc); } -OMPClause *Sema::ActOnOpenMPCollapseClause(Expr *Num, SourceLocation StartLoc, +OMPClause *Sema::ActOnOpenMPCollapseClause(Expr *NumForLoops, + SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) { + // OpenMP [2.7.1, loop construct, Description] // OpenMP [2.8.1, simd construct, Description] + // OpenMP [2.9.6, distribute construct, Description] // The parameter of the collapse clause must be a constant // positive integer expression. - ExprResult NumForLoops = - VerifyPositiveIntegerConstantInClause(Num, OMPC_collapse); - if (NumForLoops.isInvalid()) + ExprResult NumForLoopsResult = + VerifyPositiveIntegerConstantInClause(NumForLoops, OMPC_collapse); + if (NumForLoopsResult.isInvalid()) return nullptr; return new (Context) - OMPCollapseClause(NumForLoops.get(), StartLoc, LParenLoc, EndLoc); + OMPCollapseClause(NumForLoopsResult.get(), StartLoc, LParenLoc, EndLoc); } OMPClause *Sema::ActOnOpenMPSimpleClause( diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 6b6ebad..29c9163 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1301,7 +1301,7 @@ public: /// \brief Build a new OpenMP 'if' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPIfClause(Expr *Condition, SourceLocation StartLoc, @@ -1313,7 +1313,7 @@ public: /// \brief Build a new OpenMP 'num_threads' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc, @@ -1325,7 +1325,7 @@ public: /// \brief Build a new OpenMP 'safelen' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -1335,7 +1335,7 @@ public: /// \brief Build a new OpenMP 'collapse' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -1346,7 +1346,7 @@ public: /// \brief Build a new OpenMP 'default' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPDefaultClause(OpenMPDefaultClauseKind Kind, SourceLocation KindKwLoc, @@ -1359,7 +1359,7 @@ public: /// \brief Build a new OpenMP 'proc_bind' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPProcBindClause(OpenMPProcBindClauseKind Kind, SourceLocation KindKwLoc, @@ -1372,7 +1372,7 @@ public: /// \brief Build a new OpenMP 'private' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPPrivateClause(ArrayRef VarList, SourceLocation StartLoc, @@ -1384,7 +1384,7 @@ public: /// \brief Build a new OpenMP 'firstprivate' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPFirstprivateClause(ArrayRef VarList, SourceLocation StartLoc, @@ -1396,7 +1396,7 @@ public: /// \brief Build a new OpenMP 'shared' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPSharedClause(ArrayRef VarList, SourceLocation StartLoc, @@ -1408,7 +1408,7 @@ public: /// \brief Build a new OpenMP 'linear' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPLinearClause(ArrayRef VarList, Expr *Step, SourceLocation StartLoc, @@ -1421,7 +1421,7 @@ public: /// \brief Build a new OpenMP 'aligned' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPAlignedClause(ArrayRef VarList, Expr *Alignment, SourceLocation StartLoc, @@ -1434,7 +1434,7 @@ public: /// \brief Build a new OpenMP 'copyin' clause. /// - /// By default, performs semantic analysis to build the new statement. + /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. OMPClause *RebuildOMPCopyinClause(ArrayRef VarList, SourceLocation StartLoc, @@ -6294,10 +6294,12 @@ StmtResult TreeTransform::TransformSEHHandler(Stmt *Handler) { return getDerived().TransformSEHExceptStmt(cast(Handler)); } -template -StmtResult -TreeTransform::TransformOMPExecutableDirective( - OMPExecutableDirective *D) { +//===----------------------------------------------------------------------===// +// OpenMP directive transformation +//===----------------------------------------------------------------------===// +template +StmtResult TreeTransform::TransformOMPExecutableDirective( + OMPExecutableDirective *D) { // Transform the clauses llvm::SmallVector TClauses; @@ -6311,8 +6313,7 @@ TreeTransform::TransformOMPExecutableDirective( return StmtError(); } TClauses.push_back(Clause); - } - else { + } else { TClauses.push_back(nullptr); } } @@ -6320,19 +6321,17 @@ TreeTransform::TransformOMPExecutableDirective( return StmtError(); } StmtResult AssociatedStmt = - getDerived().TransformStmt(D->getAssociatedStmt()); + getDerived().TransformStmt(D->getAssociatedStmt()); if (AssociatedStmt.isInvalid()) { return StmtError(); } - return getDerived().RebuildOMPExecutableDirective(D->getDirectiveKind(), - TClauses, - AssociatedStmt.get(), - D->getLocStart(), - D->getLocEnd()); + return getDerived().RebuildOMPExecutableDirective( + D->getDirectiveKind(), TClauses, AssociatedStmt.get(), D->getLocStart(), + D->getLocEnd()); } -template +template StmtResult TreeTransform::TransformOMPParallelDirective(OMPParallelDirective *D) { DeclarationNameInfo DirName; @@ -6342,7 +6341,7 @@ TreeTransform::TransformOMPParallelDirective(OMPParallelDirective *D) { return Res; } -template +template StmtResult TreeTransform::TransformOMPSimdDirective(OMPSimdDirective *D) { DeclarationNameInfo DirName; @@ -6352,9 +6351,11 @@ TreeTransform::TransformOMPSimdDirective(OMPSimdDirective *D) { return Res; } -template -OMPClause * -TreeTransform::TransformOMPIfClause(OMPIfClause *C) { +//===----------------------------------------------------------------------===// +// OpenMP clause transformation +//===----------------------------------------------------------------------===// +template +OMPClause *TreeTransform::TransformOMPIfClause(OMPIfClause *C) { ExprResult Cond = getDerived().TransformExpr(C->getCondition()); if (Cond.isInvalid()) return nullptr; @@ -6362,16 +6363,14 @@ TreeTransform::TransformOMPIfClause(OMPIfClause *C) { C->getLParenLoc(), C->getLocEnd()); } -template +template OMPClause * TreeTransform::TransformOMPNumThreadsClause(OMPNumThreadsClause *C) { ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads()); if (NumThreads.isInvalid()) return nullptr; - return getDerived().RebuildOMPNumThreadsClause(NumThreads.get(), - C->getLocStart(), - C->getLParenLoc(), - C->getLocEnd()); + return getDerived().RebuildOMPNumThreadsClause( + NumThreads.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); } template @@ -6394,27 +6393,23 @@ TreeTransform::TransformOMPCollapseClause(OMPCollapseClause *C) { E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); } -template +template OMPClause * TreeTransform::TransformOMPDefaultClause(OMPDefaultClause *C) { - return getDerived().RebuildOMPDefaultClause(C->getDefaultKind(), - C->getDefaultKindKwLoc(), - C->getLocStart(), - C->getLParenLoc(), - C->getLocEnd()); + return getDerived().RebuildOMPDefaultClause( + C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getLocStart(), + C->getLParenLoc(), C->getLocEnd()); } -template +template OMPClause * TreeTransform::TransformOMPProcBindClause(OMPProcBindClause *C) { - return getDerived().RebuildOMPProcBindClause(C->getProcBindKind(), - C->getProcBindKindKwLoc(), - C->getLocStart(), - C->getLParenLoc(), - C->getLocEnd()); + return getDerived().RebuildOMPProcBindClause( + C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getLocStart(), + C->getLParenLoc(), C->getLocEnd()); } -template +template OMPClause * TreeTransform::TransformOMPPrivateClause(OMPPrivateClause *C) { llvm::SmallVector Vars; @@ -6425,16 +6420,13 @@ TreeTransform::TransformOMPPrivateClause(OMPPrivateClause *C) { return nullptr; Vars.push_back(EVar.get()); } - return getDerived().RebuildOMPPrivateClause(Vars, - C->getLocStart(), - C->getLParenLoc(), - C->getLocEnd()); + return getDerived().RebuildOMPPrivateClause( + Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); } -template -OMPClause * -TreeTransform::TransformOMPFirstprivateClause( - OMPFirstprivateClause *C) { +template +OMPClause *TreeTransform::TransformOMPFirstprivateClause( + OMPFirstprivateClause *C) { llvm::SmallVector Vars; Vars.reserve(C->varlist_size()); for (auto *VE : C->varlists()) { @@ -6443,13 +6435,11 @@ TreeTransform::TransformOMPFirstprivateClause( return nullptr; Vars.push_back(EVar.get()); } - return getDerived().RebuildOMPFirstprivateClause(Vars, - C->getLocStart(), - C->getLParenLoc(), - C->getLocEnd()); + return getDerived().RebuildOMPFirstprivateClause( + Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); } -template +template OMPClause * TreeTransform::TransformOMPSharedClause(OMPSharedClause *C) { llvm::SmallVector Vars; @@ -6460,13 +6450,11 @@ TreeTransform::TransformOMPSharedClause(OMPSharedClause *C) { return nullptr; Vars.push_back(EVar.get()); } - return getDerived().RebuildOMPSharedClause(Vars, - C->getLocStart(), - C->getLParenLoc(), - C->getLocEnd()); + return getDerived().RebuildOMPSharedClause(Vars, C->getLocStart(), + C->getLParenLoc(), C->getLocEnd()); } -template +template OMPClause * TreeTransform::TransformOMPLinearClause(OMPLinearClause *C) { llvm::SmallVector Vars; @@ -6480,12 +6468,12 @@ TreeTransform::TransformOMPLinearClause(OMPLinearClause *C) { ExprResult Step = getDerived().TransformExpr(C->getStep()); if (Step.isInvalid()) return nullptr; - return getDerived().RebuildOMPLinearClause( - Vars, Step.get(), C->getLocStart(), C->getLParenLoc(), C->getColonLoc(), - C->getLocEnd()); + return getDerived().RebuildOMPLinearClause(Vars, Step.get(), C->getLocStart(), + C->getLParenLoc(), + C->getColonLoc(), C->getLocEnd()); } -template +template OMPClause * TreeTransform::TransformOMPAlignedClause(OMPAlignedClause *C) { llvm::SmallVector Vars; @@ -6504,7 +6492,7 @@ TreeTransform::TransformOMPAlignedClause(OMPAlignedClause *C) { C->getColonLoc(), C->getLocEnd()); } -template +template OMPClause * TreeTransform::TransformOMPCopyinClause(OMPCopyinClause *C) { llvm::SmallVector Vars; @@ -6515,10 +6503,8 @@ TreeTransform::TransformOMPCopyinClause(OMPCopyinClause *C) { return nullptr; Vars.push_back(EVar.get()); } - return getDerived().RebuildOMPCopyinClause(Vars, - C->getLocStart(), - C->getLParenLoc(), - C->getLocEnd()); + return getDerived().RebuildOMPCopyinClause(Vars, C->getLocStart(), + C->getLParenLoc(), C->getLocEnd()); } //===----------------------------------------------------------------------===// -- 2.7.4