From bf9865fc78da180dfca153535e2dee932d023a20 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Wed, 28 May 2014 06:15:33 +0000 Subject: [PATCH] [OPENMP] Reformatting of parsing code for OpenMP constructs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209714 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseOpenMP.cpp | 81 ++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/lib/Parse/ParseOpenMP.cpp b/lib/Parse/ParseOpenMP.cpp index 5916098ab1..3a2a51e90d 100644 --- a/lib/Parse/ParseOpenMP.cpp +++ b/lib/Parse/ParseOpenMP.cpp @@ -36,9 +36,9 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() { SourceLocation Loc = ConsumeToken(); SmallVector Identifiers; - OpenMPDirectiveKind DKind = Tok.isAnnotation() ? - OMPD_unknown : - getOpenMPDirectiveKind(PP.getSpelling(Tok)); + OpenMPDirectiveKind DKind = Tok.isAnnotation() + ? OMPD_unknown + : getOpenMPDirectiveKind(PP.getSpelling(Tok)); switch (DKind) { case OMPD_threadprivate: @@ -48,13 +48,12 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() { // extra tokens. if (Tok.isNot(tok::annot_pragma_openmp_end)) { Diag(Tok, diag::warn_omp_extra_tokens_at_eol) - << getOpenMPDirectiveName(OMPD_threadprivate); + << getOpenMPDirectiveName(OMPD_threadprivate); SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch); } // Skip the last annot_pragma_openmp_end. ConsumeToken(); - return Actions.ActOnOpenMPThreadprivateDirective(Loc, - Identifiers); + return Actions.ActOnOpenMPThreadprivateDirective(Loc, Identifiers); } break; case OMPD_unknown: @@ -64,7 +63,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() { case OMPD_simd: case OMPD_task: Diag(Tok, diag::err_omp_unexpected_directive) - << getOpenMPDirectiveName(DKind); + << getOpenMPDirectiveName(DKind); break; } SkipUntil(tok::annot_pragma_openmp_end); @@ -86,13 +85,13 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() { SmallVector Identifiers; SmallVector Clauses; SmallVector, OMPC_unknown + 1> - FirstClauses(OMPC_unknown + 1); - const unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope | - Scope::OpenMPDirectiveScope; + FirstClauses(OMPC_unknown + 1); + const unsigned ScopeFlags = + Scope::FnScope | Scope::DeclScope | Scope::OpenMPDirectiveScope; SourceLocation Loc = ConsumeToken(), EndLoc; - OpenMPDirectiveKind DKind = Tok.isAnnotation() ? - OMPD_unknown : - getOpenMPDirectiveKind(PP.getSpelling(Tok)); + OpenMPDirectiveKind DKind = Tok.isAnnotation() + ? OMPD_unknown + : getOpenMPDirectiveKind(PP.getSpelling(Tok)); // Name of critical directive. DeclarationNameInfo DirName; StmtResult Directive = StmtError(); @@ -105,12 +104,11 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() { // extra tokens. if (Tok.isNot(tok::annot_pragma_openmp_end)) { Diag(Tok, diag::warn_omp_extra_tokens_at_eol) - << getOpenMPDirectiveName(OMPD_threadprivate); + << getOpenMPDirectiveName(OMPD_threadprivate); SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch); } DeclGroupPtrTy Res = - Actions.ActOnOpenMPThreadprivateDirective(Loc, - Identifiers); + Actions.ActOnOpenMPThreadprivateDirective(Loc, Identifiers); Directive = Actions.ActOnDeclStmt(Res, Loc, Tok.getLocation()); } SkipUntil(tok::annot_pragma_openmp_end); @@ -122,11 +120,11 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() { Actions.StartOpenMPDSABlock(DKind, DirName, Actions.getCurScope()); while (Tok.isNot(tok::annot_pragma_openmp_end)) { - OpenMPClauseKind CKind = Tok.isAnnotation() ? - OMPC_unknown : - getOpenMPClauseKind(PP.getSpelling(Tok)); - OMPClause *Clause = ParseOpenMPClause(DKind, CKind, - !FirstClauses[CKind].getInt()); + OpenMPClauseKind CKind = Tok.isAnnotation() + ? OMPC_unknown + : getOpenMPClauseKind(PP.getSpelling(Tok)); + OMPClause *Clause = + ParseOpenMPClause(DKind, CKind, !FirstClauses[CKind].getInt()); FirstClauses[CKind].setInt(true); if (Clause) { FirstClauses[CKind].setPointer(Clause); @@ -162,22 +160,21 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() { } } if (CreateDirective) - Directive = Actions.ActOnOpenMPExecutableDirective(DKind, Clauses, - AssociatedStmt.take(), - Loc, EndLoc); + Directive = Actions.ActOnOpenMPExecutableDirective( + DKind, Clauses, AssociatedStmt.take(), Loc, EndLoc); // Exit scope. Actions.EndOpenMPDSABlock(Directive.get()); OMPDirectiveScope.Exit(); - } break; + } case OMPD_unknown: Diag(Tok, diag::err_omp_unknown_directive); SkipUntil(tok::annot_pragma_openmp_end); break; case OMPD_task: Diag(Tok, diag::err_omp_unexpected_directive) - << getOpenMPDirectiveName(DKind); + << getOpenMPDirectiveName(DKind); SkipUntil(tok::annot_pragma_openmp_end); break; } @@ -231,8 +228,8 @@ bool Parser::ParseOpenMPSimpleVarList(OpenMPDirectiveKind Kind, << SourceRange(PrevTok.getLocation(), PrevTokLocation); } else { DeclarationNameInfo NameInfo = Actions.GetNameFromUnqualifiedId(Name); - ExprResult Res = Actions.ActOnOpenMPIdExpression(getCurScope(), SS, - NameInfo); + ExprResult Res = + Actions.ActOnOpenMPIdExpression(getCurScope(), SS, NameInfo); if (Res.isUsable()) VarList.push_back(Res.take()); } @@ -266,8 +263,8 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, bool ErrorFound = false; // Check if clause is allowed for the given directive. if (CKind != OMPC_unknown && !isAllowedClauseForDirective(DKind, CKind)) { - Diag(Tok, diag::err_omp_unexpected_clause) - << getOpenMPClauseName(CKind) << getOpenMPDirectiveName(DKind); + Diag(Tok, diag::err_omp_unexpected_clause) << getOpenMPClauseName(CKind) + << getOpenMPDirectiveName(DKind); ErrorFound = true; } @@ -283,8 +280,8 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, // Only one safelen clause can appear on a simd directive. // Only one collapse clause can appear on a simd directive. if (!FirstClause) { - Diag(Tok, diag::err_omp_more_one_clause) - << getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind); + Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind) + << getOpenMPClauseName(CKind); } Clause = ParseOpenMPSingleExprClause(CKind); @@ -297,8 +294,8 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, // OpenMP [2.5, parallel Construct, Restrictions] // At most one proc_bind clause can appear on the directive. if (!FirstClause) { - Diag(Tok, diag::err_omp_more_one_clause) - << getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind); + Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind) + << getOpenMPClauseName(CKind); } Clause = ParseOpenMPSimpleClause(CKind); @@ -312,12 +309,12 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, break; case OMPC_unknown: Diag(Tok, diag::warn_omp_extra_tokens_at_eol) - << getOpenMPDirectiveName(DKind); + << getOpenMPDirectiveName(DKind); SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch); break; case OMPC_threadprivate: - Diag(Tok, diag::err_omp_unexpected_clause) - << getOpenMPClauseName(CKind) << getOpenMPDirectiveName(DKind); + Diag(Tok, diag::err_omp_unexpected_clause) << getOpenMPClauseName(CKind) + << getOpenMPDirectiveName(DKind); SkipUntil(tok::comma, tok::annot_pragma_openmp_end, StopBeforeMatch); break; } @@ -357,9 +354,8 @@ OMPClause *Parser::ParseOpenMPSingleExprClause(OpenMPClauseKind Kind) { if (Val.isInvalid()) return nullptr; - return Actions.ActOnOpenMPSingleExprClause(Kind, Val.take(), Loc, - T.getOpenLocation(), - T.getCloseLocation()); + return Actions.ActOnOpenMPSingleExprClause( + Kind, Val.take(), Loc, T.getOpenLocation(), T.getCloseLocation()); } /// \brief Parsing of simple OpenMP clauses like 'default' or 'proc_bind'. @@ -379,9 +375,8 @@ OMPClause *Parser::ParseOpenMPSimpleClause(OpenMPClauseKind Kind) { getOpenMPClauseName(Kind))) return nullptr; - unsigned Type = - getOpenMPSimpleClauseType(Kind, - Tok.isAnnotation() ? "" : PP.getSpelling(Tok)); + unsigned Type = getOpenMPSimpleClauseType( + Kind, Tok.isAnnotation() ? "" : PP.getSpelling(Tok)); SourceLocation TypeLoc = Tok.getLocation(); if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) && Tok.isNot(tok::annot_pragma_openmp_end)) -- 2.40.0