<div dir="ltr"><div><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></div><div><br></div><div>I have verified that the form for the capture conforms to the OpenMP 4.0 specification.</div><div>It looks good.</div>
<div><br></div><div><div>If clause is capture:</div><div>v = x++;</div><div>v = x--;</div><div>v = ++x;</div><div>v = --x;</div><div>v = x binop= expr;</div><div>v = x = x binop expr;</div><div>v = x = expr binop x;</div>
<div>and where structured-block is a structured block with one of the following forms:</div><div>{v = x; x binop= expr;}</div><div>{x binop= expr; v = x;}</div><div>{v = x; x = x binop expr;}</div><div>{v = x; x = expr binop x;}</div>
<div>{x = x binop expr; v = x;}</div><div>{x = expr binop x; v = x;}</div><div>{v = x; x = expr;}</div><div>{v = x; x++;}</div><div>{v = x; ++x;}</div><div>{++x; v = x;}</div><div>{x++; v = x;}</div><div>{v = x; x--;}</div>
<div>{v = x; --x;}</div><div>{--x; v = x;}</div><div>{x--; v = x;}</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 24, 2014 at 2:46 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 24 01:46:57 2014<br>
New Revision: 213842<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=213842&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=213842&view=rev</a><br>
Log:<br>
[OPENMP] Initial parsing and sema analysis for clause 'capture' in 'atomic' directive.<br>
<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/DiagnosticSemaKinds.td<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/atomic_ast_print.cpp<br>
cfe/trunk/test/OpenMP/atomic_messages.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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)<br>
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Thu Jul 24 01:46:57 2014<br>
@@ -2436,6 +2436,11 @@ bool RecursiveASTVisitor<Derived>::Visit<br>
}<br>
<br>
template <typename Derived><br>
+bool RecursiveASTVisitor<Derived>::VisitOMPCaptureClause(OMPCaptureClause *) {<br>
+ return true;<br>
+}<br>
+<br>
+template <typename Derived><br>
template <typename T><br>
bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {<br>
for (auto *E : Node->varlists()) {<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)<br>
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Jul 24 01:46:57 2014<br>
@@ -857,6 +857,36 @@ public:<br>
StmtRange children() { return StmtRange(); }<br>
};<br>
<br>
+/// \brief This represents 'capture' clause in the '#pragma omp atomic'<br>
+/// directive.<br>
+///<br>
+/// \code<br>
+/// #pragma omp atomic capture<br>
+/// \endcode<br>
+/// In this example directive '#pragma omp atomic' has 'capture' clause.<br>
+///<br>
+class OMPCaptureClause : public OMPClause {<br>
+public:<br>
+ /// \brief Build 'capture' clause.<br>
+ ///<br>
+ /// \param StartLoc Starting location of the clause.<br>
+ /// \param EndLoc Ending location of the clause.<br>
+ ///<br>
+ OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc)<br>
+ : OMPClause(OMPC_capture, StartLoc, EndLoc) {}<br>
+<br>
+ /// \brief Build an empty clause.<br>
+ ///<br>
+ OMPCaptureClause()<br>
+ : OMPClause(OMPC_capture, SourceLocation(), SourceLocation()) {}<br>
+<br>
+ static bool classof(const OMPClause *T) {<br>
+ return T->getClauseKind() == OMPC_capture;<br>
+ }<br>
+<br>
+ StmtRange children() { return StmtRange(); }<br>
+};<br>
+<br>
/// \brief This represents clause 'private' in the '#pragma omp ...' directives.<br>
///<br>
/// \code<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)<br>
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Jul 24 01:46:57 2014<br>
@@ -2458,6 +2458,11 @@ bool RecursiveASTVisitor<Derived>::Visit<br>
}<br>
<br>
template <typename Derived><br>
+bool RecursiveASTVisitor<Derived>::VisitOMPCaptureClause(OMPCaptureClause *) {<br>
+ return true;<br>
+}<br>
+<br>
+template <typename Derived><br>
template <typename T><br>
bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {<br>
for (auto *E : Node->varlists()) {<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 24 01:46:57 2014<br>
@@ -7157,6 +7157,14 @@ def err_omp_atomic_write_not_expression_<br>
def err_omp_atomic_update_not_expression_statement : Error<<br>
"the statement for 'atomic%select{| update}0' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x',"<br>
" where x is an l-value expression with scalar type">;<br>
+def err_omp_atomic_capture_not_expression_statement : Error<<br>
+ "the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x',"<br>
+ " where x and v are both l-value expressions with scalar type">;<br>
+def err_omp_atomic_capture_not_compound_statement : Error<<br>
+ "the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}',"<br>
+ " '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}',"<br>
+ " '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}'"<br>
+ " where x is an l-value expression with scalar type">;<br>
def err_omp_atomic_several_clauses : Error<<br>
"directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause">;<br>
def note_omp_atomic_previous_clause : Note<<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)<br>
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Thu Jul 24 01:46:57 2014<br>
@@ -104,6 +104,7 @@ OPENMP_CLAUSE(flush, OMPFlushClause)<br>
OPENMP_CLAUSE(read, OMPReadClause)<br>
OPENMP_CLAUSE(write, OMPWriteClause)<br>
OPENMP_CLAUSE(update, OMPUpdateClause)<br>
+OPENMP_CLAUSE(capture, OMPCaptureClause)<br>
<br>
// Clauses allowed for OpenMP directive 'parallel'.<br>
OPENMP_PARALLEL_CLAUSE(if)<br>
@@ -205,6 +206,7 @@ OPENMP_TASK_CLAUSE(mergeable)<br>
OPENMP_ATOMIC_CLAUSE(read)<br>
OPENMP_ATOMIC_CLAUSE(write)<br>
OPENMP_ATOMIC_CLAUSE(update)<br>
+OPENMP_ATOMIC_CLAUSE(capture)<br>
<br>
#undef OPENMP_SCHEDULE_KIND<br>
#undef OPENMP_PROC_BIND_KIND<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 24 01:46:57 2014<br>
@@ -7491,6 +7491,9 @@ public:<br>
/// \brief Called on well-formed 'update' clause.<br>
OMPClause *ActOnOpenMPUpdateClause(SourceLocation StartLoc,<br>
SourceLocation EndLoc);<br>
+ /// \brief Called on well-formed 'capture' clause.<br>
+ OMPClause *ActOnOpenMPCaptureClause(SourceLocation StartLoc,<br>
+ SourceLocation EndLoc);<br>
<br>
OMPClause *<br>
ActOnOpenMPVarListClause(OpenMPClauseKind Kind, ArrayRef<Expr *> Vars,<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)<br>
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Jul 24 01:46:57 2014<br>
@@ -673,6 +673,10 @@ void OMPClausePrinter::VisitOMPUpdateCla<br>
OS << "update";<br>
}<br>
<br>
+void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {<br>
+ OS << "capture";<br>
+}<br>
+<br>
template<typename T><br>
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {<br>
for (typename T::varlist_iterator I = Node->varlist_begin(),<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)<br>
+++ cfe/trunk/lib/AST/StmtProfile.cpp Thu Jul 24 01:46:57 2014<br>
@@ -316,6 +316,8 @@ void OMPClauseProfiler::VisitOMPWriteCla<br>
<br>
void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}<br>
<br>
+void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}<br>
+<br>
template<typename T><br>
void OMPClauseProfiler::VisitOMPClauseList(T *Node) {<br>
for (auto *I : Node->varlists())<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)<br>
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Thu Jul 24 01:46:57 2014<br>
@@ -111,6 +111,7 @@ unsigned clang::getOpenMPSimpleClauseTyp<br>
case OMPC_read:<br>
case OMPC_write:<br>
case OMPC_update:<br>
+ case OMPC_capture:<br>
break;<br>
}<br>
llvm_unreachable("Invalid OpenMP simple clause kind");<br>
@@ -173,6 +174,7 @@ const char *clang::getOpenMPSimpleClause<br>
case OMPC_read:<br>
case OMPC_write:<br>
case OMPC_update:<br>
+ case OMPC_capture:<br>
break;<br>
}<br>
llvm_unreachable("Invalid OpenMP simple clause kind");<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Thu Jul 24 01:46:57 2014<br>
@@ -343,7 +343,7 @@ bool Parser::ParseOpenMPSimpleVarList(Op<br>
/// lastprivate-clause | reduction-clause | proc_bind-clause |<br>
/// schedule-clause | copyin-clause | copyprivate-clause | untied-clause |<br>
/// mergeable-clause | flush-clause | read-clause | write-clause |<br>
-/// update-clause<br>
+/// update-clause | capture-clause<br>
///<br>
OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,<br>
OpenMPClauseKind CKind, bool FirstClause) {<br>
@@ -412,6 +412,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope<br>
case OMPC_read:<br>
case OMPC_write:<br>
case OMPC_update:<br>
+ case OMPC_capture:<br>
// OpenMP [2.7.1, Restrictions, p. 9]<br>
// Only one ordered clause can appear on a loop directive.<br>
// OpenMP [2.7.1, Restrictions, C/C++, p. 4]<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 24 01:46:57 2014<br>
@@ -2392,7 +2392,8 @@ StmtResult Sema::ActOnOpenMPAtomicDirect<br>
SourceLocation AtomicKindLoc;<br>
for (auto *C : Clauses) {<br>
if (C->getClauseKind() == OMPC_read || C->getClauseKind() == OMPC_write ||<br>
- C->getClauseKind() == OMPC_update) {<br>
+ C->getClauseKind() == OMPC_update ||<br>
+ C->getClauseKind() == OMPC_capture) {<br>
if (AtomicKind != OMPC_unknown) {<br>
Diag(C->getLocStart(), diag::err_omp_atomic_several_clauses)<br>
<< SourceRange(C->getLocStart(), C->getLocEnd());<br>
@@ -2404,25 +2405,36 @@ StmtResult Sema::ActOnOpenMPAtomicDirect<br>
}<br>
}<br>
}<br>
+ auto Body = CS->getCapturedStmt();<br>
if (AtomicKind == OMPC_read) {<br>
- if (!isa<Expr>(CS->getCapturedStmt())) {<br>
- Diag(CS->getCapturedStmt()->getLocStart(),<br>
+ if (!isa<Expr>(Body)) {<br>
+ Diag(Body->getLocStart(),<br>
diag::err_omp_atomic_read_not_expression_statement);<br>
return StmtError();<br>
}<br>
} else if (AtomicKind == OMPC_write) {<br>
- if (!isa<Expr>(CS->getCapturedStmt())) {<br>
- Diag(CS->getCapturedStmt()->getLocStart(),<br>
+ if (!isa<Expr>(Body)) {<br>
+ Diag(Body->getLocStart(),<br>
diag::err_omp_atomic_write_not_expression_statement);<br>
return StmtError();<br>
}<br>
} else if (AtomicKind == OMPC_update || AtomicKind == OMPC_unknown) {<br>
- if (!isa<Expr>(CS->getCapturedStmt())) {<br>
- Diag(CS->getCapturedStmt()->getLocStart(),<br>
+ if (!isa<Expr>(Body)) {<br>
+ Diag(Body->getLocStart(),<br>
diag::err_omp_atomic_update_not_expression_statement)<br>
<< (AtomicKind == OMPC_update);<br>
return StmtError();<br>
}<br>
+ } else if (AtomicKind == OMPC_capture) {<br>
+ if (isa<Expr>(Body) && !isa<BinaryOperator>(Body)) {<br>
+ Diag(Body->getLocStart(),<br>
+ diag::err_omp_atomic_capture_not_expression_statement);<br>
+ return StmtError();<br>
+ } else if (!isa<Expr>(Body) && !isa<CompoundStmt>(Body)) {<br>
+ Diag(Body->getLocStart(),<br>
+ diag::err_omp_atomic_capture_not_compound_statement);<br>
+ return StmtError();<br>
+ }<br>
}<br>
<br>
getCurFunction()->setHasBranchProtectedScope();<br>
@@ -2472,6 +2484,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprCl<br>
case OMPC_read:<br>
case OMPC_write:<br>
case OMPC_update:<br>
+ case OMPC_capture:<br>
case OMPC_unknown:<br>
llvm_unreachable("Clause is not allowed.");<br>
}<br>
@@ -2677,6 +2690,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause<br>
case OMPC_read:<br>
case OMPC_write:<br>
case OMPC_update:<br>
+ case OMPC_capture:<br>
case OMPC_unknown:<br>
llvm_unreachable("Clause is not allowed.");<br>
}<br>
@@ -2795,6 +2809,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWi<br>
case OMPC_read:<br>
case OMPC_write:<br>
case OMPC_update:<br>
+ case OMPC_capture:<br>
case OMPC_unknown:<br>
llvm_unreachable("Clause is not allowed.");<br>
}<br>
@@ -2883,6 +2898,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenM<br>
case OMPC_update:<br>
Res = ActOnOpenMPUpdateClause(StartLoc, EndLoc);<br>
break;<br>
+ case OMPC_capture:<br>
+ Res = ActOnOpenMPCaptureClause(StartLoc, EndLoc);<br>
+ break;<br>
case OMPC_if:<br>
case OMPC_final:<br>
case OMPC_num_threads:<br>
@@ -2944,6 +2962,11 @@ OMPClause *Sema::ActOnOpenMPUpdateClause<br>
return new (Context) OMPUpdateClause(StartLoc, EndLoc);<br>
}<br>
<br>
+OMPClause *Sema::ActOnOpenMPCaptureClause(SourceLocation StartLoc,<br>
+ SourceLocation EndLoc) {<br>
+ return new (Context) OMPCaptureClause(StartLoc, EndLoc);<br>
+}<br>
+<br>
OMPClause *Sema::ActOnOpenMPVarListClause(<br>
OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,<br>
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,<br>
@@ -3000,6 +3023,7 @@ OMPClause *Sema::ActOnOpenMPVarListClaus<br>
case OMPC_read:<br>
case OMPC_write:<br>
case OMPC_update:<br>
+ case OMPC_capture:<br>
case OMPC_unknown:<br>
llvm_unreachable("Clause is not allowed.");<br>
}<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/TreeTransform.h (original)<br>
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Jul 24 01:46:57 2014<br>
@@ -6782,6 +6782,13 @@ TreeTransform<Derived>::TransformOMPUpda<br>
<br>
template <typename Derived><br>
OMPClause *<br>
+TreeTransform<Derived>::TransformOMPCaptureClause(OMPCaptureClause *C) {<br>
+ // No need to rebuild this clause, no template-dependent parameters.<br>
+ return C;<br>
+}<br>
+<br>
+template <typename Derived><br>
+OMPClause *<br>
TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {<br>
llvm::SmallVector<Expr *, 16> Vars;<br>
Vars.reserve(C->varlist_size());<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Thu Jul 24 01:46:57 2014<br>
@@ -1724,6 +1724,9 @@ OMPClause *OMPClauseReader::readClause()<br>
case OMPC_update:<br>
C = new (Context) OMPUpdateClause();<br>
break;<br>
+ case OMPC_capture:<br>
+ C = new (Context) OMPCaptureClause();<br>
+ break;<br>
case OMPC_private:<br>
C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);<br>
break;<br>
@@ -1824,6 +1827,8 @@ void OMPClauseReader::VisitOMPWriteClaus<br>
<br>
void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {}<br>
<br>
+void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}<br>
+<br>
void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {<br>
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));<br>
unsigned NumVars = C->varlist_size();<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Thu Jul 24 01:46:57 2014<br>
@@ -1741,6 +1741,8 @@ void OMPClauseWriter::VisitOMPWriteClaus<br>
<br>
void OMPClauseWriter::VisitOMPUpdateClause(OMPUpdateClause *) {}<br>
<br>
+void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}<br>
+<br>
void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {<br>
Record.push_back(C->varlist_size());<br>
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);<br>
<br>
Modified: cfe/trunk/test/OpenMP/atomic_ast_print.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_ast_print.cpp?rev=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_ast_print.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/OpenMP/atomic_ast_print.cpp (original)<br>
+++ cfe/trunk/test/OpenMP/atomic_ast_print.cpp Thu Jul 24 01:46:57 2014<br>
@@ -8,6 +8,7 @@<br>
<br>
template <class T><br>
T foo(T argc) {<br>
+ T b = T();<br>
T a = T();<br>
#pragma omp atomic<br>
a++;<br>
@@ -17,6 +18,13 @@ T foo(T argc) {<br>
a = argc + argc;<br>
#pragma omp atomic update<br>
a = a + argc;<br>
+#pragma omp atomic capture<br>
+ a = b++;<br>
+#pragma omp atomic capture<br>
+ {<br>
+ a = b;<br>
+ b++;<br>
+ }<br>
return T();<br>
}<br>
<br>
@@ -29,6 +37,13 @@ T foo(T argc) {<br>
// CHECK-NEXT: a = argc + argc;<br>
// CHECK-NEXT: #pragma omp atomic update<br>
// CHECK-NEXT: a = a + argc;<br>
+// CHECK-NEXT: #pragma omp atomic capture<br>
+// CHECK-NEXT: a = b++;<br>
+// CHECK-NEXT: #pragma omp atomic capture<br>
+// CHECK-NEXT: {<br>
+// CHECK-NEXT: a = b;<br>
+// CHECK-NEXT: b++;<br>
+// CHECK-NEXT: }<br>
// CHECK: T a = T();<br>
// CHECK-NEXT: #pragma omp atomic<br>
// CHECK-NEXT: a++;<br>
@@ -38,8 +53,16 @@ T foo(T argc) {<br>
// CHECK-NEXT: a = argc + argc;<br>
// CHECK-NEXT: #pragma omp atomic update<br>
// CHECK-NEXT: a = a + argc;<br>
+// CHECK-NEXT: #pragma omp atomic capture<br>
+// CHECK-NEXT: a = b++;<br>
+// CHECK-NEXT: #pragma omp atomic capture<br>
+// CHECK-NEXT: {<br>
+// CHECK-NEXT: a = b;<br>
+// CHECK-NEXT: b++;<br>
+// CHECK-NEXT: }<br>
<br>
int main(int argc, char **argv) {<br>
+ int b = 0;<br>
int a = 0;<br>
// CHECK: int a = 0;<br>
#pragma omp atomic<br>
@@ -50,6 +73,13 @@ int main(int argc, char **argv) {<br>
a = argc + argc;<br>
#pragma omp atomic update<br>
a = a + argc;<br>
+#pragma omp atomic capture<br>
+ a = b++;<br>
+#pragma omp atomic capture<br>
+ {<br>
+ a = b;<br>
+ b++;<br>
+ }<br>
// CHECK-NEXT: #pragma omp atomic<br>
// CHECK-NEXT: a++;<br>
// CHECK-NEXT: #pragma omp atomic read<br>
@@ -58,6 +88,13 @@ int main(int argc, char **argv) {<br>
// CHECK-NEXT: a = argc + argc;<br>
// CHECK-NEXT: #pragma omp atomic update<br>
// CHECK-NEXT: a = a + argc;<br>
+ // CHECK-NEXT: #pragma omp atomic capture<br>
+ // CHECK-NEXT: a = b++;<br>
+ // CHECK-NEXT: #pragma omp atomic capture<br>
+ // CHECK-NEXT: {<br>
+ // CHECK-NEXT: a = b;<br>
+ // CHECK-NEXT: b++;<br>
+ // CHECK-NEXT: }<br>
return foo(a);<br>
}<br>
<br>
<br>
Modified: cfe/trunk/test/OpenMP/atomic_messages.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_messages.cpp?rev=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_messages.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/OpenMP/atomic_messages.cpp (original)<br>
+++ cfe/trunk/test/OpenMP/atomic_messages.cpp Thu Jul 24 01:46:57 2014<br>
@@ -4,14 +4,14 @@ int foo() {<br>
L1:<br>
foo();<br>
#pragma omp atomic<br>
-// expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
{<br>
foo();<br>
goto L1; // expected-error {{use of undeclared label 'L1'}}<br>
}<br>
goto L2; // expected-error {{use of undeclared label 'L2'}}<br>
#pragma omp atomic<br>
-// expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
{<br>
foo();<br>
L2:<br>
@@ -26,7 +26,7 @@ T read() {<br>
T a, b = 0;<br>
// Test for atomic read<br>
#pragma omp atomic read<br>
-// expected-error@+1 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both l-value expressions with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both l-value expressions with scalar type}}<br>
;<br>
// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}<br>
#pragma omp atomic read read<br>
@@ -39,7 +39,7 @@ int read() {<br>
int a, b = 0;<br>
// Test for atomic read<br>
#pragma omp atomic read<br>
-// expected-error@+1 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both l-value expressions with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both l-value expressions with scalar type}}<br>
;<br>
// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}<br>
#pragma omp atomic read read<br>
@@ -53,7 +53,7 @@ T write() {<br>
T a, b = 0;<br>
// Test for atomic write<br>
#pragma omp atomic write<br>
-// expected-error@+1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}}<br>
;<br>
// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}<br>
#pragma omp atomic write write<br>
@@ -66,7 +66,7 @@ int write() {<br>
int a, b = 0;<br>
// Test for atomic write<br>
#pragma omp atomic write<br>
-// expected-error@+1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}}<br>
;<br>
// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}<br>
#pragma omp atomic write write<br>
@@ -80,14 +80,14 @@ T update() {<br>
T a, b = 0;<br>
// Test for atomic update<br>
#pragma omp atomic update<br>
-// expected-error@+1 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
;<br>
// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}<br>
#pragma omp atomic update update<br>
a += b;<br>
<br>
#pragma omp atomic<br>
-// expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
;<br>
<br>
return T();<br>
@@ -97,20 +97,53 @@ int update() {<br>
int a, b = 0;<br>
// Test for atomic update<br>
#pragma omp atomic update<br>
-// expected-error@+1 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
;<br>
// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}<br>
#pragma omp atomic update update<br>
a += b;<br>
<br>
#pragma omp atomic<br>
-// expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
+ // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}<br>
;<br>
<br>
return update<int>();<br>
}<br>
<br>
template <class T><br>
+T capture() {<br>
+ T a, b = 0;<br>
+// Test for atomic capture<br>
+#pragma omp atomic capture<br>
+ // expected-error@+1 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}<br>
+ ++a;<br>
+#pragma omp atomic capture<br>
+ // expected-error@+1 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}<br>
+ ;<br>
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}<br>
+#pragma omp atomic capture capture<br>
+ a = ++b;<br>
+<br>
+ return T();<br>
+}<br>
+<br>
+int capture() {<br>
+ int a, b = 0;<br>
+// Test for atomic capture<br>
+#pragma omp atomic capture<br>
+ // expected-error@+1 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}<br>
+ ++a;<br>
+#pragma omp atomic capture<br>
+ // expected-error@+1 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}<br>
+ ;<br>
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}<br>
+#pragma omp atomic capture capture<br>
+ a = ++b;<br>
+<br>
+ return capture<int>();<br>
+}<br>
+<br>
+template <class T><br>
T mixed() {<br>
T a, b = T();<br>
// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}<br>
@@ -125,6 +158,10 @@ T mixed() {<br>
// expected-note@+1 2 {{'update' clause used here}}<br>
#pragma omp atomic update read<br>
a += b;<br>
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}<br>
+// expected-note@+1 2 {{'capture' clause used here}}<br>
+#pragma omp atomic capture read<br>
+ a = ++b;<br>
return T();<br>
}<br>
<br>
@@ -142,7 +179,11 @@ int mixed() {<br>
// expected-note@+1 {{'write' clause used here}}<br>
#pragma omp atomic write update<br>
a = b;<br>
-// expected-note@+1 {{in instantiation of function template specialization 'mixed<int>' requested here}}<br>
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}<br>
+// expected-note@+1 {{'write' clause used here}}<br>
+#pragma omp atomic write capture<br>
+ a = b;<br>
+ // expected-note@+1 {{in instantiation of function template specialization 'mixed<int>' requested here}}<br>
return mixed<int>();<br>
}<br>
<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=213842&r1=213841&r2=213842&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=213842&r1=213841&r2=213842&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/tools/libclang/CIndex.cpp (original)<br>
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Jul 24 01:46:57 2014<br>
@@ -1987,6 +1987,8 @@ void OMPClauseEnqueue::VisitOMPWriteClau<br>
<br>
void OMPClauseEnqueue::VisitOMPUpdateClause(const OMPUpdateClause *) {}<br>
<br>
+void OMPClauseEnqueue::VisitOMPCaptureClause(const OMPCaptureClause *) {}<br>
+<br>
template<typename T><br>
void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {<br>
for (const auto *I : Node->varlists())<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>