<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">I reviewed this and the structure is again similar to the review for </span><br style="font-family:arial,sans-serif;font-size:13px"><h2 style="font-family:arial,sans-serif">
r212516 - [OPENMP] Parsing and sema analysis for 'omp parallel sections' directive.</h2><p style="font-family:arial,sans-serif;font-size:13px"><br></p><p style="font-family:arial,sans-serif;font-size:13px">It looks good. Thanks.</p>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 17, 2014 at 3:32 AM, Alexey Bataev <span dir="ltr"><<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: abataev<br>
Date: Thu Jul 17 02:32:53 2014<br>
New Revision: 213232<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=213232&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=213232&view=rev</a><br>
Log:<br>
[OPENMP] Initial parsing and sema analysis for 'final' clause.<br>
<br>
Added:<br>
cfe/trunk/test/OpenMP/task_final_messages.cpp (with props)<br>
Modified:<br>
cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h<br>
cfe/trunk/include/clang/AST/OpenMPClause.h<br>
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h<br>
cfe/trunk/include/clang/Basic/OpenMPKinds.def<br>
cfe/trunk/include/clang/Sema/Sema.h<br>
cfe/trunk/lib/AST/StmtPrinter.cpp<br>
cfe/trunk/lib/AST/StmtProfile.cpp<br>
cfe/trunk/lib/Basic/OpenMPKinds.cpp<br>
cfe/trunk/lib/Parse/ParseOpenMP.cpp<br>
cfe/trunk/lib/Sema/SemaOpenMP.cpp<br>
cfe/trunk/lib/Sema/TreeTransform.h<br>
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp<br>
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
cfe/trunk/test/OpenMP/task_ast_print.cpp<br>
cfe/trunk/tools/libclang/CIndex.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)<br>
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Thu Jul 17 02:32:53 2014<br>
@@ -2331,6 +2331,12 @@ bool RecursiveASTVisitor<Derived>::Visit<br>
}<br>
<br>
template <typename Derived><br>
+bool RecursiveASTVisitor<Derived>::VisitOMPFinalClause(OMPFinalClause *C) {<br>
+ TRY_TO(TraverseStmt(C->getCondition()));<br>
+ return true;<br>
+}<br>
+<br>
+template <typename Derived><br>
bool<br>
RecursiveASTVisitor<Derived>::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {<br>
TRY_TO(TraverseStmt(C->getNumThreads()));<br>
<br>
Modified: cfe/trunk/include/clang/AST/OpenMPClause.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)<br>
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Jul 17 02:32:53 2014<br>
@@ -196,6 +196,59 @@ public:<br>
StmtRange children() { return StmtRange(&Condition, &Condition + 1); }<br>
};<br>
<br>
+/// \brief This represents 'final' clause in the '#pragma omp ...' directive.<br>
+///<br>
+/// \code<br>
+/// #pragma omp task final(a > 5)<br>
+/// \endcode<br>
+/// In this example directive '#pragma omp task' has simple 'final'<br>
+/// clause with condition 'a > 5'.<br>
+///<br>
+class OMPFinalClause : public OMPClause {<br>
+ friend class OMPClauseReader;<br>
+ /// \brief Location of '('.<br>
+ SourceLocation LParenLoc;<br>
+ /// \brief Condition of the 'if' clause.<br>
+ Stmt *Condition;<br>
+<br>
+ /// \brief Set condition.<br>
+ ///<br>
+ void setCondition(Expr *Cond) { Condition = Cond; }<br>
+<br>
+public:<br>
+ /// \brief Build 'final' clause with condition \a Cond.<br>
+ ///<br>
+ /// \param StartLoc Starting location of the clause.<br>
+ /// \param LParenLoc Location of '('.<br>
+ /// \param Cond Condition of the clause.<br>
+ /// \param EndLoc Ending location of the clause.<br>
+ ///<br>
+ OMPFinalClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,<br>
+ SourceLocation EndLoc)<br>
+ : OMPClause(OMPC_final, StartLoc, EndLoc), LParenLoc(LParenLoc),<br>
+ Condition(Cond) {}<br>
+<br>
+ /// \brief Build an empty clause.<br>
+ ///<br>
+ OMPFinalClause()<br>
+ : OMPClause(OMPC_final, SourceLocation(), SourceLocation()),<br>
+ LParenLoc(SourceLocation()), Condition(nullptr) {}<br>
+<br>
+ /// \brief Sets the location of '('.<br>
+ void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }<br>
+ /// \brief Returns the location of '('.<br>
+ SourceLocation getLParenLoc() const { return LParenLoc; }<br>
+<br>
+ /// \brief Returns condition.<br>
+ Expr *getCondition() const { return cast_or_null<Expr>(Condition); }<br>
+<br>
+ static bool classof(const OMPClause *T) {<br>
+ return T->getClauseKind() == OMPC_final;<br>
+ }<br>
+<br>
+ StmtRange children() { return StmtRange(&Condition, &Condition + 1); }<br>
+};<br>
+<br>
/// \brief This represents 'num_threads' clause in the '#pragma omp ...'<br>
/// directive.<br>
///<br>
<br>
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)<br>
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Jul 17 02:32:53 2014<br>
@@ -2353,6 +2353,12 @@ bool RecursiveASTVisitor<Derived>::Visit<br>
}<br>
<br>
template <typename Derived><br>
+bool RecursiveASTVisitor<Derived>::VisitOMPFinalClause(OMPFinalClause *C) {<br>
+ TRY_TO(TraverseStmt(C->getCondition()));<br>
+ return true;<br>
+}<br>
+<br>
+template <typename Derived><br>
bool<br>
RecursiveASTVisitor<Derived>::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {<br>
TRY_TO(TraverseStmt(C->getNumThreads()));<br>
<br>
Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)<br>
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Thu Jul 17 02:32:53 2014<br>
@@ -69,6 +69,7 @@ OPENMP_DIRECTIVE_EXT(parallel_sections,<br>
<br>
// OpenMP clauses.<br>
OPENMP_CLAUSE(if, OMPIfClause)<br>
+OPENMP_CLAUSE(final, OMPFinalClause)<br>
OPENMP_CLAUSE(num_threads, OMPNumThreadsClause)<br>
OPENMP_CLAUSE(safelen, OMPSafelenClause)<br>
OPENMP_CLAUSE(collapse, OMPCollapseClause)<br>
@@ -175,6 +176,7 @@ OPENMP_PARALLEL_SECTIONS_CLAUSE(lastpriv<br>
<br>
// TODO more clauses allowed for OpenMP directive 'task'.<br>
OPENMP_TASK_CLAUSE(if)<br>
+OPENMP_TASK_CLAUSE(final)<br>
OPENMP_TASK_CLAUSE(default)<br>
OPENMP_TASK_CLAUSE(private)<br>
OPENMP_TASK_CLAUSE(firstprivate)<br>
<br>
Modified: cfe/trunk/include/clang/Sema/Sema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 17 02:32:53 2014<br>
@@ -7374,6 +7374,10 @@ public:<br>
OMPClause *ActOnOpenMPIfClause(Expr *Condition, SourceLocation StartLoc,<br>
SourceLocation LParenLoc,<br>
SourceLocation EndLoc);<br>
+ /// \brief Called on well-formed 'final' clause.<br>
+ OMPClause *ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc,<br>
+ SourceLocation LParenLoc,<br>
+ SourceLocation EndLoc);<br>
/// \brief Called on well-formed 'num_threads' clause.<br>
OMPClause *ActOnOpenMPNumThreadsClause(Expr *NumThreads,<br>
SourceLocation StartLoc,<br>
<br>
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)<br>
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Jul 17 02:32:53 2014<br>
@@ -603,6 +603,12 @@ void OMPClausePrinter::VisitOMPIfClause(<br>
OS << ")";<br>
}<br>
<br>
+void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) {<br>
+ OS << "final(";<br>
+ Node->getCondition()->printPretty(OS, nullptr, Policy, 0);<br>
+ OS << ")";<br>
+}<br>
+<br>
void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) {<br>
OS << "num_threads(";<br>
Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0);<br>
<br>
Modified: cfe/trunk/lib/AST/StmtProfile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)<br>
+++ cfe/trunk/lib/AST/StmtProfile.cpp Thu Jul 17 02:32:53 2014<br>
@@ -273,6 +273,11 @@ void OMPClauseProfiler::VisitOMPIfClause<br>
Profiler->VisitStmt(C->getCondition());<br>
}<br>
<br>
+void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {<br>
+ if (C->getCondition())<br>
+ Profiler->VisitStmt(C->getCondition());<br>
+}<br>
+<br>
void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {<br>
if (C->getNumThreads())<br>
Profiler->VisitStmt(C->getNumThreads());<br>
<br>
Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)<br>
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Thu Jul 17 02:32:53 2014<br>
@@ -88,6 +88,7 @@ unsigned clang::getOpenMPSimpleClauseTyp<br>
case OMPC_unknown:<br>
case OMPC_threadprivate:<br>
case OMPC_if:<br>
+ case OMPC_final:<br>
case OMPC_num_threads:<br>
case OMPC_safelen:<br>
case OMPC_collapse:<br>
@@ -143,6 +144,7 @@ const char *clang::getOpenMPSimpleClause<br>
case OMPC_unknown:<br>
case OMPC_threadprivate:<br>
case OMPC_if:<br>
+ case OMPC_final:<br>
case OMPC_num_threads:<br>
case OMPC_safelen:<br>
case OMPC_collapse:<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Thu Jul 17 02:32:53 2014<br>
@@ -286,11 +286,11 @@ bool Parser::ParseOpenMPSimpleVarList(Op<br>
/// \brief Parsing of OpenMP clauses.<br>
///<br>
/// clause:<br>
-/// if-clause | num_threads-clause | safelen-clause | default-clause |<br>
-/// private-clause | firstprivate-clause | shared-clause | linear-clause |<br>
-/// aligned-clause | collapse-clause | lastprivate-clause |<br>
-/// reduction-clause | proc_bind-clause | schedule-clause |<br>
-/// copyin-clause | copyprivate-clause<br>
+/// if-clause | final-clause | num_threads-clause | safelen-clause |<br>
+/// default-clause | private-clause | firstprivate-clause | shared-clause<br>
+/// | linear-clause | aligned-clause | collapse-clause |<br>
+/// lastprivate-clause | reduction-clause | proc_bind-clause |<br>
+/// schedule-clause | copyin-clause | copyprivate-clause<br>
///<br>
OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,<br>
OpenMPClauseKind CKind, bool FirstClause) {<br>
@@ -305,6 +305,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope<br>
<br>
switch (CKind) {<br>
case OMPC_if:<br>
+ case OMPC_final:<br>
case OMPC_num_threads:<br>
case OMPC_safelen:<br>
case OMPC_collapse:<br>
@@ -314,6 +315,9 @@ OMPClause *Parser::ParseOpenMPClause(Ope<br>
// OpenMP [2.8.1, simd construct, Restrictions]<br>
// Only one safelen clause can appear on a simd directive.<br>
// Only one collapse clause can appear on a simd directive.<br>
+ // OpenMP [2.11.1, task Construct, Restrictions]<br>
+ // At most one if clause can appear on the directive.<br>
+ // At most one final clause can appear on the directive.<br>
if (!FirstClause) {<br>
Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)<br>
<< getOpenMPClauseName(CKind);<br>
@@ -384,12 +388,15 @@ OMPClause *Parser::ParseOpenMPClause(Ope<br>
}<br>
<br>
/// \brief Parsing of OpenMP clauses with single expressions like 'if',<br>
-/// 'collapse', 'safelen', 'num_threads', 'simdlen', 'num_teams' or<br>
+/// 'final', 'collapse', 'safelen', 'num_threads', 'simdlen', 'num_teams' or<br>
/// 'thread_limit'.<br>
///<br>
/// if-clause:<br>
/// 'if' '(' expression ')'<br>
///<br>
+/// final-clause:<br>
+/// 'final' '(' expression ')'<br>
+///<br>
/// num_threads-clause:<br>
/// 'num_threads' '(' expression ')'<br>
///<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 17 02:32:53 2014<br>
@@ -1992,6 +1992,9 @@ OMPClause *Sema::ActOnOpenMPSingleExprCl<br>
case OMPC_if:<br>
Res = ActOnOpenMPIfClause(Expr, StartLoc, LParenLoc, EndLoc);<br>
break;<br>
+ case OMPC_final:<br>
+ Res = ActOnOpenMPFinalClause(Expr, StartLoc, LParenLoc, EndLoc);<br>
+ break;<br>
case OMPC_num_threads:<br>
Res = ActOnOpenMPNumThreadsClause(Expr, StartLoc, LParenLoc, EndLoc);<br>
break;<br>
@@ -2040,6 +2043,25 @@ OMPClause *Sema::ActOnOpenMPIfClause(Exp<br>
return new (Context) OMPIfClause(ValExpr, StartLoc, LParenLoc, EndLoc);<br>
}<br>
<br>
+OMPClause *Sema::ActOnOpenMPFinalClause(Expr *Condition,<br>
+ SourceLocation StartLoc,<br>
+ SourceLocation LParenLoc,<br>
+ SourceLocation EndLoc) {<br>
+ Expr *ValExpr = Condition;<br>
+ if (!Condition->isValueDependent() && !Condition->isTypeDependent() &&<br>
+ !Condition->isInstantiationDependent() &&<br>
+ !Condition->containsUnexpandedParameterPack()) {<br>
+ ExprResult Val = ActOnBooleanCondition(DSAStack->getCurScope(),<br>
+ Condition->getExprLoc(), Condition);<br>
+ if (Val.isInvalid())<br>
+ return nullptr;<br>
+<br>
+ ValExpr = Val.get();<br>
+ }<br>
+<br>
+ return new (Context) OMPFinalClause(ValExpr, StartLoc, LParenLoc, EndLoc);<br>
+}<br>
+<br>
ExprResult Sema::PerformOpenMPImplicitIntegerConversion(SourceLocation Loc,<br>
Expr *Op) {<br>
if (!Op)<br>
@@ -2180,6 +2202,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause<br>
LParenLoc, EndLoc);<br>
break;<br>
case OMPC_if:<br>
+ case OMPC_final:<br>
case OMPC_num_threads:<br>
case OMPC_safelen:<br>
case OMPC_collapse:<br>
@@ -2290,6 +2313,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWi<br>
LParenLoc, ArgumentLoc, CommaLoc, EndLoc);<br>
break;<br>
case OMPC_if:<br>
+ case OMPC_final:<br>
case OMPC_num_threads:<br>
case OMPC_safelen:<br>
case OMPC_collapse:<br>
@@ -2381,6 +2405,7 @@ OMPClause *Sema::ActOnOpenMPClause(OpenM<br>
Res = ActOnOpenMPNowaitClause(StartLoc, EndLoc);<br>
break;<br>
case OMPC_if:<br>
+ case OMPC_final:<br>
case OMPC_num_threads:<br>
case OMPC_safelen:<br>
case OMPC_collapse:<br>
@@ -2451,6 +2476,7 @@ OMPClause *Sema::ActOnOpenMPVarListClaus<br>
Res = ActOnOpenMPCopyprivateClause(VarList, StartLoc, LParenLoc, EndLoc);<br>
break;<br>
case OMPC_if:<br>
+ case OMPC_final:<br>
case OMPC_num_threads:<br>
case OMPC_safelen:<br>
case OMPC_collapse:<br>
<br>
Modified: cfe/trunk/lib/Sema/TreeTransform.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/TreeTransform.h (original)<br>
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Jul 17 02:32:53 2014<br>
@@ -1318,6 +1318,17 @@ public:<br>
LParenLoc, EndLoc);<br>
}<br>
<br>
+ /// \brief Build a new OpenMP 'final' clause.<br>
+ ///<br>
+ /// By default, performs semantic analysis to build the new OpenMP clause.<br>
+ /// Subclasses may override this routine to provide different behavior.<br>
+ OMPClause *RebuildOMPFinalClause(Expr *Condition, SourceLocation StartLoc,<br>
+ SourceLocation LParenLoc,<br>
+ SourceLocation EndLoc) {<br>
+ return getSema().ActOnOpenMPFinalClause(Condition, StartLoc, LParenLoc,<br>
+ EndLoc);<br>
+ }<br>
+<br>
/// \brief Build a new OpenMP 'num_threads' clause.<br>
///<br>
/// By default, performs semantic analysis to build the new OpenMP clause.<br>
@@ -6543,6 +6554,15 @@ OMPClause *TreeTransform<Derived>::Trans<br>
}<br>
<br>
template <typename Derived><br>
+OMPClause *TreeTransform<Derived>::TransformOMPFinalClause(OMPFinalClause *C) {<br>
+ ExprResult Cond = getDerived().TransformExpr(C->getCondition());<br>
+ if (Cond.isInvalid())<br>
+ return nullptr;<br>
+ return getDerived().RebuildOMPFinalClause(Cond.get(), C->getLocStart(),<br>
+ C->getLParenLoc(), C->getLocEnd());<br>
+}<br>
+<br>
+template <typename Derived><br>
OMPClause *<br>
TreeTransform<Derived>::TransformOMPNumThreadsClause(OMPNumThreadsClause *C) {<br>
ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Thu Jul 17 02:32:53 2014<br>
@@ -1682,6 +1682,9 @@ OMPClause *OMPClauseReader::readClause()<br>
case OMPC_if:<br>
C = new (Context) OMPIfClause();<br>
break;<br>
+ case OMPC_final:<br>
+ C = new (Context) OMPFinalClause();<br>
+ break;<br>
case OMPC_num_threads:<br>
C = new (Context) OMPNumThreadsClause();<br>
break;<br>
@@ -1745,6 +1748,11 @@ void OMPClauseReader::VisitOMPIfClause(O<br>
C->setCondition(Reader->Reader.ReadSubExpr());<br>
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));<br>
}<br>
+<br>
+void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) {<br>
+ C->setCondition(Reader->Reader.ReadSubExpr());<br>
+ C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));<br>
+}<br>
<br>
void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {<br>
C->setNumThreads(Reader->Reader.ReadSubExpr());<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Thu Jul 17 02:32:53 2014<br>
@@ -1687,6 +1687,11 @@ void OMPClauseWriter::VisitOMPIfClause(O<br>
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);<br>
}<br>
<br>
+void OMPClauseWriter::VisitOMPFinalClause(OMPFinalClause *C) {<br>
+ Writer->Writer.AddStmt(C->getCondition());<br>
+ Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);<br>
+}<br>
+<br>
void OMPClauseWriter::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {<br>
Writer->Writer.AddStmt(C->getNumThreads());<br>
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);<br>
<br>
Modified: cfe/trunk/test/OpenMP/task_ast_print.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_ast_print.cpp?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_ast_print.cpp?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/OpenMP/task_ast_print.cpp (original)<br>
+++ cfe/trunk/test/OpenMP/task_ast_print.cpp Thu Jul 17 02:32:53 2014<br>
@@ -35,7 +35,7 @@ T tmain(T argc, T *argv) {<br>
S<T> s;<br>
#pragma omp task<br>
a = 2;<br>
-#pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0)<br>
+#pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0) final(S<T>::TS > 0)<br>
foo();<br>
#pragma omp task if (C)<br>
foo();<br>
@@ -48,7 +48,7 @@ T tmain(T argc, T *argv) {<br>
// CHECK-NEXT: S<int> s;<br>
// CHECK-NEXT: #pragma omp task<br>
// CHECK-NEXT: a = 2;<br>
-// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0)<br>
+// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<int>::TS > 0)<br>
// CHECK-NEXT: foo()<br>
// CHECK-NEXT: #pragma omp task if(5)<br>
// CHECK-NEXT: foo()<br>
@@ -58,7 +58,7 @@ T tmain(T argc, T *argv) {<br>
// CHECK-NEXT: S<long> s;<br>
// CHECK-NEXT: #pragma omp task<br>
// CHECK-NEXT: a = 2;<br>
-// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0)<br>
+// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<long>::TS > 0)<br>
// CHECK-NEXT: foo()<br>
// CHECK-NEXT: #pragma omp task if(1)<br>
// CHECK-NEXT: foo()<br>
@@ -68,7 +68,7 @@ T tmain(T argc, T *argv) {<br>
// CHECK-NEXT: S<T> s;<br>
// CHECK-NEXT: #pragma omp task<br>
// CHECK-NEXT: a = 2;<br>
-// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0)<br>
+// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<T>::TS > 0)<br>
// CHECK-NEXT: foo()<br>
// CHECK-NEXT: #pragma omp task if(C)<br>
// CHECK-NEXT: foo()<br>
@@ -86,8 +86,8 @@ int main(int argc, char **argv) {<br>
// CHECK-NEXT: #pragma omp task<br>
a = 2;<br>
// CHECK-NEXT: a = 2;<br>
-#pragma omp task default(none), private(argc, b) firstprivate(argv) if (argc > 0)<br>
- // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) if(argc > 0)<br>
+#pragma omp task default(none), private(argc, b) firstprivate(argv) if (argc > 0) final(a > 0)<br>
+ // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) if(argc > 0) final(a > 0)<br>
foo();<br>
// CHECK-NEXT: foo();<br>
return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);<br>
<br>
Added: cfe/trunk/test/OpenMP/task_final_messages.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_final_messages.cpp?rev=213232&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_final_messages.cpp?rev=213232&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/OpenMP/task_final_messages.cpp (added)<br>
+++ cfe/trunk/test/OpenMP/task_final_messages.cpp Thu Jul 17 02:32:53 2014<br>
@@ -0,0 +1,46 @@<br>
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s<br>
+<br>
+void foo() {<br>
+}<br>
+<br>
+bool foobool(int argc) {<br>
+ return argc;<br>
+}<br>
+<br>
+struct S1; // expected-note {{declared here}}<br>
+<br>
+template <class T, class S> // expected-note {{declared here}}<br>
+int tmain(T argc, S **argv) {<br>
+ #pragma omp task final // expected-error {{expected '(' after 'final'}}<br>
+ #pragma omp task final ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ #pragma omp task final () // expected-error {{expected expression}}<br>
+ #pragma omp task final (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ #pragma omp task final (argc)) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}<br>
+ #pragma omp task final (argc > 0 ? argv[1] : argv[2])<br>
+ #pragma omp task final (foobool(argc)), final (true) // expected-error {{directive '#pragma omp task' cannot contain more than one 'final' clause}}<br>
+ #pragma omp task final (S) // expected-error {{'S' does not refer to a value}}<br>
+ #pragma omp task final (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ #pragma omp task final (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ #pragma omp task final(argc)<br>
+ foo();<br>
+<br>
+ return 0;<br>
+}<br>
+<br>
+int main(int argc, char **argv) {<br>
+ #pragma omp task final // expected-error {{expected '(' after 'final'}}<br>
+ #pragma omp task final ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ #pragma omp task final () // expected-error {{expected expression}}<br>
+ #pragma omp task final (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ #pragma omp task final (argc)) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}<br>
+ #pragma omp task final (argc > 0 ? argv[1] : argv[2])<br>
+ #pragma omp task final (foobool(argc)), final (true) // expected-error {{directive '#pragma omp task' cannot contain more than one 'final' clause}}<br>
+ #pragma omp task final (S1) // expected-error {{'S1' does not refer to a value}}<br>
+ #pragma omp task final (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ #pragma omp task final (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ #pragma omp task final (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ #pragma omp task final(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}<br>
+ foo();<br>
+<br>
+ return tmain(argc, argv);<br>
+}<br>
<br>
Propchange: cfe/trunk/test/OpenMP/task_final_messages.cpp<br>
------------------------------------------------------------------------------<br>
svn:eol-style = native<br>
<br>
Propchange: cfe/trunk/test/OpenMP/task_final_messages.cpp<br>
------------------------------------------------------------------------------<br>
svn:keywords = Author Date Id Rev URL<br>
<br>
Propchange: cfe/trunk/test/OpenMP/task_final_messages.cpp<br>
------------------------------------------------------------------------------<br>
svn:mime-type = text/plain<br>
<br>
Modified: cfe/trunk/tools/libclang/CIndex.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=213232&r1=213231&r2=213232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=213232&r1=213231&r2=213232&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/tools/libclang/CIndex.cpp (original)<br>
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Jul 17 02:32:53 2014<br>
@@ -1939,6 +1939,10 @@ void OMPClauseEnqueue::VisitOMPIfClause(<br>
Visitor->AddStmt(C->getCondition());<br>
}<br>
<br>
+void OMPClauseEnqueue::VisitOMPFinalClause(const OMPFinalClause *C) {<br>
+ Visitor->AddStmt(C->getCondition());<br>
+}<br>
+<br>
void OMPClauseEnqueue::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {<br>
Visitor->AddStmt(C->getNumThreads());<br>
}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>