<html><body><p>Hi<br><br>I checked that the patch modified as suggested by Jonas passes all tests including clang under address sanitizer.<br><br>Commit again at rev255498.<br><br>Please, let me know if this still breaks something and I will revert and investigate.<br><br>Apologies for the previous error!<br><br>-- Carlo<br><br><img width="16" height="16" src="cid:3__=8FBBF588DFC2762F8f9e8a93df938690918c8FB@" border="0" alt="Inactive hide details for NAKAMURA Takumi ---12/10/2015 08:48:08 PM---From: NAKAMURA Takumi <geek4civic@gmail.com> To: Hans Wen"><font color="#424282">NAKAMURA Takumi ---12/10/2015 08:48:08 PM---From: NAKAMURA Takumi <geek4civic@gmail.com> To: Hans Wennborg <hans@chromium.org>, Carlo Bertolli/Watson/IBM@IBMUS</font><br><br><font size="2" color="#5F5F5F">From:        </font><font size="2">NAKAMURA Takumi <geek4civic@gmail.com></font><br><font size="2" color="#5F5F5F">To:        </font><font size="2">Hans Wennborg <hans@chromium.org>, Carlo Bertolli/Watson/IBM@IBMUS</font><br><font size="2" color="#5F5F5F">Cc:        </font><font size="2">cfe-commits <cfe-commits@lists.llvm.org></font><br><font size="2" color="#5F5F5F">Date:        </font><font size="2">12/10/2015 08:48 PM</font><br><font size="2" color="#5F5F5F">Subject:        </font><font size="2">Re: r255001 - Add parse and sema for OpenMP distribute directive and all its clauses excluding dist_schedule.</font><br><hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br><br><br><font size="4">Reverted in r255094.</font><br><br><font size="4">I suspect, in StmtOpenMP.h, "*std::next(begin_iter, n) = Expr" would be always safe.</font><br><br><font size="4">On Wed, Dec 9, 2015 at 7:19 AM Hans Wennborg via cfe-commits <</font><a href="mailto:cfe-commits@lists.llvm.org"><u><font size="4" color="#0000FF">cfe-commits@lists.llvm.org</font></u></a><font size="4">> wrote:</font><ul><font size="4">It fails on Windows too. I was using a 32-bit build on Windows with -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON.</font><br><br><font size="4">If you need more time for fixing this, please consider reverting it in the meantime.</font><br><br><font size="4">Thanks,</font><br><font size="4">Hans</font><br><br><br><font size="4">On Tue, Dec 8, 2015 at 12:58 PM, Carlo Bertolli via cfe-commits <</font><a href="mailto:cfe-commits@lists.llvm.org" target="_blank"><u><font size="4" color="#0000FF">cfe-commits@lists.llvm.org</font></u></a><font size="4">> wrote:</font><br><font size="4">Hi<br><br>I was unable to replicate the errors. This is what I tried:<br><br>- Run check-clang on ppc64le linux ubuntu 14.04, debug mode, llvm and clang compiled with clang 3.7.<br><br>- Run check-clang on x86-64 linux, debug and release modes, llvm and clang compiled with both clang 3.7 and gcc 4.8.2<br><br>I am using cmake+ninja,<br><br>Can you please advise on how to replicate the errors that you see, including platform, flags, etc?<br><br>Many thanks!<br><br>-- Carlo<br><br></font><font size="4" color="#424282">Alexey Samsonov ---12/08/2015 12:36:39 PM---ASan bootstrap provides an error report as well: </font><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-" target="_blank"><u><font size="4" color="#0000FF">http://lab.llvm.org:8011/builders/sanitizer-x86_64-</font></u></a><font size="4"><br></font><font color="#5F5F5F"><br>From: </font>Alexey Samsonov <<a href="mailto:vonosmas@gmail.com" target="_blank"><u><font color="#0000FF">vonosmas@gmail.com</font></u></a>><font color="#5F5F5F"><br>To: </font>NAKAMURA Takumi <<a href="mailto:geek4civic@gmail.com" target="_blank"><u><font color="#0000FF">geek4civic@gmail.com</font></u></a>><font color="#5F5F5F"><br>Cc: </font>Carlo Bertolli/Watson/IBM@IBMUS, cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank"><u><font color="#0000FF">cfe-commits@lists.llvm.org</font></u></a>><font color="#5F5F5F"><br>Date: </font>12/08/2015 12:36 PM<font color="#5F5F5F"><br>Subject: </font>Re: r255001 - Add parse and sema for OpenMP distribute directive and all its clauses excluding dist_schedule.<br><hr width="100%" size="2" align="left" noshade><br><font size="4"><br><br></font><font size="5"><br>ASan bootstrap provides an error report as well:</font><font size="4"><br></font><u><font size="4" color="#0000FF"><br></font></u><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/8407/steps/check-clang%20asan/logs/stdio" target="_blank"><u><font size="5" color="#0000FF">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/8407/steps/check-clang%20asan/logs/stdio</font></u></a><font size="5"><br>Please investigate or revert.</font><font size="4"><br></font><font size="5"><br>On Tue, Dec 8, 2015 at 6:06 AM, NAKAMURA Takumi via cfe-commits <</font><a href="mailto:cfe-commits@lists.llvm.org" target="_blank"><u><font size="5" color="#0000FF">cfe-commits@lists.llvm.org</font></u></a><font size="5">> wrote:</font><ul><ul><font size="5">It crashes on i686-clang. See </font><a href="http://bb.pgr.jp/builders/clang-3stage-i686-linux/builds/4055" target="_blank"><u><font size="5" color="#0000FF">http://bb.pgr.jp/builders/clang-3stage-i686-linux/builds/4055</font></u></a><font size="5"><br>Investigating.</font><font size="4"><br></font><font size="5"><br>#6  0xf7ea482f in operator delete(void*) () from /usr/lib32/libstdc++.so.6<br>#7  0x0bef8cce in llvm::DenseMap<clang::VarDecl*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<clang::VarDecl*>, llvm::detail::DenseSetPair<clang::VarDecl*> >::~DenseMap (this=0xf2419d8)<br>    at llvm/include/llvm/ADT/DenseMap.h:575<br>#8  0x0bef8c86 in llvm::DenseSet<clang::VarDecl*, llvm::DenseMapInfo<clang::VarDecl*> >::~DenseSet (this=0xf2419d8)<br>    at llvm/include/llvm/ADT/DenseSet.h:39<br>#9  0x0cf988a4 in (anonymous namespace)::DSAStackTy::SharingMapTy::~SharingMapTy (this=0xf2412c0)<br>    at clang/lib/Sema/SemaOpenMP.cpp:95<br>#10 0x0cf9e24b in llvm::SmallVectorTemplateBase<(anonymous namespace)::DSAStackTy::SharingMapTy, false>::pop_back (this=0xf23fca0)<br>    at llvm/include/llvm/ADT/SmallVector.h:245<br>#11 0x0cf68ed2 in (anonymous namespace)::DSAStackTy::pop (this=0xf23fca0)<br>    at clang/lib/Sema/SemaOpenMP.cpp:163<br>#12 0x0cf68a50 in clang::Sema::EndOpenMPDSABlock (this=0xf23e188,<br>    CurDirective=0xf2901a0)<br>    at clang/lib/Sema/SemaOpenMP.cpp:957<br>#13 0x0c603bf0 in clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective (<br>    this=0xf25d3c0, StandAloneAllowed=false)<br>    at clang/lib/Parse/ParseOpenMP.cpp:314<br>#14 0x0c61c641 in clang::Parser::ParseStatementOrDeclarationAfterAttributes (<br>    this=0xf25d3c0, Stmts=..., OnlyStatement=true, TrailingElseLoc=0x0,<br>    Attrs=...)<br>    at clang/lib/Parse/ParseStmt.cpp:349<br>#15 0x0c61b1e9 in clang::Parser::ParseStatementOrDeclaration (this=0xf25d3c0,<br>    Stmts=..., OnlyStatement=true, TrailingElseLoc=0x0)<br>    at clang/lib/Parse/ParseStmt.cpp:106<br>#16 0x0c61b064 in clang::Parser::ParseStatement (this=0xf25d3c0,<br>    TrailingElseLoc=0x0)<br>    at clang/lib/Parse/ParseStmt.cpp:42<br>#17 0x0c6039ff in clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective (<br>    this=0xf25d3c0, StandAloneAllowed=false)<br>    at clang/lib/Parse/ParseOpenMP.cpp:305<br>#18 0x0c61c641 in clang::Parser::ParseStatementOrDeclarationAfterAttributes (<br>    this=0xf25d3c0, Stmts=..., OnlyStatement=true, TrailingElseLoc=0x0,<br>    Attrs=...)<br>    at clang/lib/Parse/ParseStmt.cpp:349<br>#19 0x0c61b1e9 in clang::Parser::ParseStatementOrDeclaration (this=0xf25d3c0,<br>    Stmts=..., OnlyStatement=true, TrailingElseLoc=0x0)<br>    at clang/lib/Parse/ParseStmt.cpp:106<br>#20 0x0c61b064 in clang::Parser::ParseStatement (this=0xf25d3c0,<br>    TrailingElseLoc=0x0)<br>    at clang/lib/Parse/ParseStmt.cpp:42<br>#21 0x0c6039ff in clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective (<br>    this=0xf25d3c0, StandAloneAllowed=true)<br>    at clang/lib/Parse/ParseOpenMP.cpp:305<br>#22 0x0c61c641 in clang::Parser::ParseStatementOrDeclarationAfterAttributes (<br>    this=0xf25d3c0, Stmts=..., OnlyStatement=false, TrailingElseLoc=0x0,<br>    Attrs=...)<br>    at clang/lib/Parse/ParseStmt.cpp:349<br>#23 0x0c61b1e9 in clang::Parser::ParseStatementOrDeclaration (this=0xf25d3c0,<br>    Stmts=..., OnlyStatement=false, TrailingElseLoc=0x0)<br>    at clang/lib/Parse/ParseStmt.cpp:106<br>#24 0x0c625955 in clang::Parser::ParseCompoundStatementBody (this=0xf25d3c0,<br>    isStmtExpr=false)<br>    at clang/lib/Parse/ParseStmt.cpp:968<br>#25 0x0c62692d in clang::Parser::ParseFunctionStatementBody (this=0xf25d3c0,<br>    Decl=0xf27a948, BodyScope=...)<br>    at clang/lib/Parse/ParseStmt.cpp:1914<br>#26 0x0c53f639 in clang::Parser::ParseFunctionDefinition (this=0xf25d3c0,<br>    D=..., TemplateInfo=..., LateParsedAttrs=0xffffb630)<br>    at clang/lib/Parse/Parser.cpp:1147<br>#27 0x0c56c1ca in clang::Parser::ParseDeclGroup (this=0xf25d3c0, DS=...,<br>    Context=0, DeclEnd=0x0, FRI=0x0)<br>    at clang/lib/Parse/ParseDecl.cpp:1757<br>#28 0x0c53e13b in clang::Parser::ParseDeclOrFunctionDefInternal (<br>    this=0xf25d3c0, attrs=..., DS=..., AS=clang::AS_none)<br>    at clang/lib/Parse/Parser.cpp:927<br>#29 0x0c53d527 in clang::Parser::ParseDeclarationOrFunctionDefinition (<br>    this=0xf25d3c0, attrs=..., DS=0x0, AS=clang::AS_none)<br>    at clang/lib/Parse/Parser.cpp:943<br>#30 0x0c53c9c4 in clang::Parser::ParseExternalDeclaration (this=0xf25d3c0,<br>    attrs=..., DS=0x0)<br>    at clang/lib/Parse/Parser.cpp:801<br>#31 0x0c53b4af in clang::Parser::ParseTopLevelDecl (this=0xf25d3c0, Result=...)<br>    at clang/lib/Parse/Parser.cpp:593<br>#32 0x0c535b0d in clang::ParseAST (S=..., PrintStats=false,<br>    SkipFunctionBodies=false)<br>    at clang/lib/Parse/ParseAST.cpp:161<br>#33 0x0b3bec76 in clang::ASTFrontendAction::ExecuteAction (this=0xf200980)<br>    at clang/lib/Frontend/FrontendAction.cpp:538<br>#34 0x0b3be581 in clang::FrontendAction::Execute (this=0xf200980)<br>    at clang/lib/Frontend/FrontendAction.cpp:439<br>#35 0x0b355071 in clang::CompilerInstance::ExecuteAction (this=0xf1ff128,<br>    Act=...)<br>    at clang/lib/Frontend/CompilerInstance.cpp:841<br>#36 0x0b52d118 in clang::ExecuteCompilerInvocation (Clang=0xf1ff128)<br>    at clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:222<br>#37 0x086e8734 in cc1_main (Argv=...,<br>    Argv0=0xffffd7c0 "/home/tnakamura/llvm/2-32/bin/clang",<br>    MainAddr=0x86d7820 <GetExecutablePath(char const*, bool)>)<br>    at clang/tools/driver/cc1_main.cpp:116<br>#38 0x086d9823 in ExecuteCC1Tool (argv=..., Tool=...)<br>    at clang/tools/driver/driver.cpp:301<br>#39 0x086d8316 in main (argc_=8, argv_=0xffffd684)<br>    at clang/tools/driver/driver.cpp:366</font><font size="4"><br><br></font><font size="5"><br>On Tue, Dec 8, 2015 at 1:24 PM Carlo Bertolli via cfe-commits <</font><a href="mailto:cfe-commits@lists.llvm.org" target="_blank"><u><font size="5" color="#0000FF">cfe-commits@lists.llvm.org</font></u></a><font size="5">> wrote:<br>Author: cbertol<br>Date: Mon Dec  7 22:21:03 2015<br>New Revision: 255001<br><br>URL: </font><a href="http://llvm.org/viewvc/llvm-project?rev=255001&view=rev" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project?rev=255001&view=rev</font></u></a><font size="5"><br>Log:<br>Add parse and sema for OpenMP distribute directive and all its clauses excluding dist_schedule.<br><br>Added:<br>    cfe/trunk/test/OpenMP/distribute_ast_print.cpp<br>    cfe/trunk/test/OpenMP/distribute_collapse_messages.cpp<br>    cfe/trunk/test/OpenMP/distribute_firstprivate_messages.cpp<br>    cfe/trunk/test/OpenMP/distribute_private_messages.cpp<br>Modified:<br>    cfe/trunk/include/clang-c/Index.h<br>    cfe/trunk/include/clang/AST/RecursiveASTVisitor.h<br>    cfe/trunk/include/clang/AST/StmtOpenMP.h<br>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>    cfe/trunk/include/clang/Basic/OpenMPKinds.def<br>    cfe/trunk/include/clang/Basic/OpenMPKinds.h<br>    cfe/trunk/include/clang/Basic/StmtNodes.td<br>    cfe/trunk/include/clang/Sema/Sema.h<br>    cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>    cfe/trunk/lib/AST/StmtOpenMP.cpp<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/CodeGen/CGStmt.cpp<br>    cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp<br>    cfe/trunk/lib/CodeGen/CodeGenFunction.h<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/lib/StaticAnalyzer/Core/ExprEngine.cpp<br>    cfe/trunk/test/OpenMP/nesting_of_regions.cpp<br>    cfe/trunk/tools/libclang/CIndex.cpp<br>    cfe/trunk/tools/libclang/CXCursor.cpp<br><br>Modified: cfe/trunk/include/clang-c/Index.h<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/include/clang-c/Index.h (original)<br>+++ cfe/trunk/include/clang-c/Index.h Mon Dec  7 22:21:03 2015<br>@@ -2264,7 +2264,11 @@ enum CXCursorKind {<br>    */<br>   CXCursor_OMPTaskLoopSimdDirective      = 259,<br><br>-  CXCursor_LastStmt                      = CXCursor_OMPTaskLoopSimdDirective,<br>+   /** \brief OpenMP distribute directive.<br>+   */<br>+  CXCursor_OMPDistributeDirective        = 260,<br>+<br>+  CXCursor_LastStmt                      = CXCursor_OMPDistributeDirective,<br><br>   /**<br>    * \brief Cursor that represents the translation unit itself.<br><br>Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)<br>+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Dec  7 22:21:03 2015<br>@@ -2439,6 +2439,9 @@ DEF_TRAVERSE_STMT(OMPTaskLoopDirective,<br> DEF_TRAVERSE_STMT(OMPTaskLoopSimdDirective,<br>                   { TRY_TO(TraverseOMPExecutableDirective(S)); })<br><br>+DEF_TRAVERSE_STMT(OMPDistributeDirective,<br>+                  { TRY_TO(TraverseOMPExecutableDirective(S)); })<br>+<br> // OpenMP clauses.<br> template <typename Derived><br> bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {<br><br>Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)<br>+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Mon Dec  7 22:21:03 2015<br>@@ -424,43 +424,50 @@ protected:<br>   void setInc(Expr *Inc) { *std::next(child_begin(), IncOffset) = Inc; }<br>   void setIsLastIterVariable(Expr *IL) {<br>     assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||<br>-            isOpenMPTaskLoopDirective(getDirectiveKind())) &&<br>+            isOpenMPTaskLoopDirective(getDirectiveKind()) ||<br>+            isOpenMPDistributeDirective(getDirectiveKind())) &&<br>            "expected worksharing loop directive");<br>     *std::next(child_begin(), IsLastIterVariableOffset) = IL;<br>   }<br>   void setLowerBoundVariable(Expr *LB) {<br>     assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||<br>-            isOpenMPTaskLoopDirective(getDirectiveKind())) &&<br>+            isOpenMPTaskLoopDirective(getDirectiveKind()) ||<br>+            isOpenMPDistributeDirective(getDirectiveKind())) &&<br>            "expected worksharing loop directive");<br>     *std::next(child_begin(), LowerBoundVariableOffset) = LB;<br>   }<br>   void setUpperBoundVariable(Expr *UB) {<br>     assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||<br>-            isOpenMPTaskLoopDirective(getDirectiveKind())) &&<br>+            isOpenMPTaskLoopDirective(getDirectiveKind()) ||<br>+            isOpenMPDistributeDirective(getDirectiveKind())) &&<br>            "expected worksharing loop directive");<br>     *std::next(child_begin(), UpperBoundVariableOffset) = UB;<br>   }<br>   void setStrideVariable(Expr *ST) {<br>     assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||<br>-            isOpenMPTaskLoopDirective(getDirectiveKind())) &&<br>+            isOpenMPTaskLoopDirective(getDirectiveKind()) ||<br>+            isOpenMPDistributeDirective(getDirectiveKind())) &&<br>            "expected worksharing loop directive");<br>     *std::next(child_begin(), StrideVariableOffset) = ST;<br>   }<br>   void setEnsureUpperBound(Expr *EUB) {<br>     assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||<br>-            isOpenMPTaskLoopDirective(getDirectiveKind())) &&<br>+            isOpenMPTaskLoopDirective(getDirectiveKind()) ||<br>+            isOpenMPDistributeDirective(getDirectiveKind())) &&<br>            "expected worksharing loop directive");<br>     *std::next(child_begin(), EnsureUpperBoundOffset) = EUB;<br>   }<br>   void setNextLowerBound(Expr *NLB) {<br>     assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||<br>-            isOpenMPTaskLoopDirective(getDirectiveKind())) &&<br>+            isOpenMPTaskLoopDirective(getDirectiveKind()) ||<br>+            isOpenMPDistributeDirective(getDirectiveKind())) &&<br>            "expected worksharing loop directive");<br>     *std::next(child_begin(), NextLowerBoundOffset) = NLB;<br>   }<br>   void setNextUpperBound(Expr *NUB) {<br>     assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||<br>-            isOpenMPTaskLoopDirective(getDirectiveKind())) &&<br>+            isOpenMPTaskLoopDirective(getDirectiveKind()) ||<br>+            isOpenMPDistributeDirective(getDirectiveKind())) &&<br>            "expected worksharing loop directive");<br>     *std::next(child_begin(), NextUpperBoundOffset) = NUB;<br>   }<br>@@ -683,7 +690,8 @@ public:<br>            T->getStmtClass() == OMPParallelForDirectiveClass ||<br>            T->getStmtClass() == OMPParallelForSimdDirectiveClass ||<br>            T->getStmtClass() == OMPTaskLoopDirectiveClass ||<br>-           T->getStmtClass() == OMPTaskLoopSimdDirectiveClass;<br>+           T->getStmtClass() == OMPTaskLoopSimdDirectiveClass ||<br>+           T->getStmtClass() == OMPDistributeDirectiveClass;<br>   }<br> };<br><br>@@ -2333,6 +2341,73 @@ public:<br>   }<br> };<br><br>+/// \brief This represents '#pragma omp distribute' directive.<br>+///<br>+/// \code<br>+/// #pragma omp distribute private(a,b)<br>+/// \endcode<br>+/// In this example directive '#pragma omp distribute' has clauses 'private'<br>+/// with the variables 'a' and 'b'<br>+///<br>+class OMPDistributeDirective : public OMPLoopDirective {<br>+  friend class ASTStmtReader;<br>+<br>+  /// \brief Build directive with the given start and end location.<br>+  ///<br>+  /// \param StartLoc Starting location of the directive kind.<br>+  /// \param EndLoc Ending location of the directive.<br>+  /// \param CollapsedNum Number of collapsed nested loops.<br>+  /// \param NumClauses Number of clauses.<br>+  ///<br>+  OMPDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc,<br>+                         unsigned CollapsedNum, unsigned NumClauses)<br>+      : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,<br>+                         StartLoc, EndLoc, CollapsedNum, NumClauses)<br>+        {}<br>+<br>+  /// \brief Build an empty directive.<br>+  ///<br>+  /// \param CollapsedNum Number of collapsed nested loops.<br>+  /// \param NumClauses Number of clauses.<br>+  ///<br>+  explicit OMPDistributeDirective(unsigned CollapsedNum, unsigned NumClauses)<br>+      : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,<br>+                         SourceLocation(), SourceLocation(), CollapsedNum,<br>+                         NumClauses)<br>+        {}<br>+<br>+public:<br>+  /// \brief Creates directive with a list of \a Clauses.<br>+  ///<br>+  /// \param C AST context.<br>+  /// \param StartLoc Starting location of the directive kind.<br>+  /// \param EndLoc Ending Location of the directive.<br>+  /// \param CollapsedNum Number of collapsed loops.<br>+  /// \param Clauses List of clauses.<br>+  /// \param AssociatedStmt Statement, associated with the directive.<br>+  /// \param Exprs Helper expressions for CodeGen.<br>+    ///<br>+  static OMPDistributeDirective *<br>+  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,<br>+         unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,<br>+         Stmt *AssociatedStmt, const HelperExprs &Exprs);<br>+<br>+  /// \brief Creates an empty directive with the place<br>+  /// for \a NumClauses clauses.<br>+  ///<br>+  /// \param C AST context.<br>+  /// \param CollapsedNum Number of collapsed nested loops.<br>+  /// \param NumClauses Number of clauses.<br>+  ///<br>+  static OMPDistributeDirective *CreateEmpty(const ASTContext &C,<br>+                                             unsigned NumClauses,<br>+                                             unsigned CollapsedNum, EmptyShell);<br>+<br>+  static bool classof(const Stmt *T) {<br>+    return T->getStmtClass() == OMPDistributeDirectiveClass;<br>+  }<br>+};<br>+<br> } // end namespace clang<br><br> #endif<br><br>Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Dec  7 22:21:03 2015<br>@@ -7801,7 +7801,8 @@ def err_omp_prohibited_region : Error<<br>   "region cannot be%select{| closely}0 nested inside '%1' region"<br>   "%select{|; perhaps you forget to enclose 'omp %3' directive into a parallel region?|"<br>   "; perhaps you forget to enclose 'omp %3' directive into a for or a parallel for region with 'ordered' clause?|"<br>-  "; perhaps you forget to enclose 'omp %3' directive into a target region?}2">;<br>+  "; perhaps you forget to enclose 'omp %3' directive into a target region?|"<br>+  "; perhaps you forget to enclose 'omp %3' directive into a teams region?}2">;<br> def err_omp_prohibited_region_simd : Error<<br>   "OpenMP constructs may not be nested inside a simd region">;<br> def err_omp_prohibited_region_atomic : Error<<br>@@ -7920,6 +7921,12 @@ def err_omp_wrong_ordered_loop_count : E<br>   "the parameter of the 'ordered' clause must be greater than or equal to the parameter of the 'collapse' clause">;<br> def note_collapse_loop_count : Note<<br>   "parameter of the 'collapse' clause">;<br>+def err_omp_firstprivate_distribute_private_teams : Error<<br>+  "private variable in '#pragma omp teams' cannot be firstprivate in '#pragma omp distribute'">;<br>+def err_omp_firstprivate_and_lastprivate_in_distribute : Error<<br>+  "lastprivate variable cannot be firstprivate in '#pragma omp distribute'">;<br>+def err_omp_firstprivate_distribute_in_teams_reduction : Error<<br>+  "reduction variable in '#pragma omp teams' cannot be firstprivate in '#pragma omp distribute'">;<br> } // end of OpenMP category<br><br> let CategoryName = "Related Result Type Issue" in {<br><br>Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)<br>+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Mon Dec  7 22:21:03 2015<br>@@ -75,6 +75,9 @@<br> #ifndef OPENMP_TASKLOOP_SIMD_CLAUSE<br> #  define OPENMP_TASKLOOP_SIMD_CLAUSE(Name)<br> #endif<br>+#ifndef OPENMP_DISTRIBUTE_CLAUSE<br>+#define OPENMP_DISTRIBUTE_CLAUSE(Name)<br>+#endif<br> #ifndef OPENMP_DEFAULT_KIND<br> #  define OPENMP_DEFAULT_KIND(Name)<br> #endif<br>@@ -123,6 +126,7 @@ OPENMP_DIRECTIVE_EXT(for_simd, "for simd<br> OPENMP_DIRECTIVE_EXT(cancellation_point, "cancellation point")<br> OPENMP_DIRECTIVE(taskloop)<br> OPENMP_DIRECTIVE_EXT(taskloop_simd, "taskloop simd")<br>+OPENMP_DIRECTIVE(distribute)<br><br> // OpenMP clauses.<br> OPENMP_CLAUSE(if, OMPIfClause)<br>@@ -388,6 +392,12 @@ OPENMP_TASKLOOP_SIMD_CLAUSE(simdlen)<br> OPENMP_TASKLOOP_SIMD_CLAUSE(grainsize)<br> OPENMP_TASKLOOP_SIMD_CLAUSE(nogroup)<br><br>+// Clauses allowed for OpenMP directive 'distribute'<br>+OPENMP_DISTRIBUTE_CLAUSE(private)<br>+OPENMP_DISTRIBUTE_CLAUSE(firstprivate)<br>+OPENMP_DISTRIBUTE_CLAUSE(lastprivate)<br>+OPENMP_DISTRIBUTE_CLAUSE(collapse)<br>+<br> #undef OPENMP_TASKLOOP_SIMD_CLAUSE<br> #undef OPENMP_TASKLOOP_CLAUSE<br> #undef OPENMP_LINEAR_KIND<br>@@ -415,3 +425,4 @@ OPENMP_TASKLOOP_SIMD_CLAUSE(nogroup)<br> #undef OPENMP_FOR_CLAUSE<br> #undef OPENMP_FOR_SIMD_CLAUSE<br> #undef OPENMP_MAP_KIND<br>+#undef OPENMP_DISTRIBUTE_CLAUSE<br><br>Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)<br>+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Mon Dec  7 22:21:03 2015<br>@@ -141,6 +141,13 @@ bool isOpenMPTeamsDirective(OpenMPDirect<br> /// otherwise - false.<br> bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind);<br><br>+/// \brief Checks if the specified directive is a distribute directive.<br>+/// \param DKind Specified directive.<br>+/// \return true - the directive is a distribute-directive like 'omp<br>+/// distribute',<br>+/// otherwise - false.<br>+bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind);<br>+<br> /// \brief Checks if the specified clause is one of private clauses like<br> /// 'private', 'firstprivate', 'reduction' etc..<br> /// \param Kind Clause kind.<br><br>Modified: cfe/trunk/include/clang/Basic/StmtNodes.td<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/include/clang/Basic/StmtNodes.td (original)<br>+++ cfe/trunk/include/clang/Basic/StmtNodes.td Mon Dec  7 22:21:03 2015<br>@@ -221,4 +221,4 @@ def OMPCancellationPointDirective : DStm<br> def OMPCancelDirective : DStmt<OMPExecutableDirective>;<br> def OMPTaskLoopDirective : DStmt<OMPLoopDirective>;<br> def OMPTaskLoopSimdDirective : DStmt<OMPLoopDirective>;<br>-<br>+def OMPDistributeDirective : DStmt<OMPLoopDirective>;<br><br>Modified: cfe/trunk/include/clang/Sema/Sema.h<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>+++ cfe/trunk/include/clang/Sema/Sema.h Mon Dec  7 22:21:03 2015<br>@@ -7961,6 +7961,12 @@ public:<br>       ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,<br>       SourceLocation EndLoc,<br>       llvm::DenseMap<VarDecl *, Expr *> &VarsWithImplicitDSA);<br>+  /// \brief Called on well-formed '\#pragma omp distribute' after parsing<br>+  /// of the associated statement.<br>+  StmtResult ActOnOpenMPDistributeDirective(<br>+      ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,<br>+      SourceLocation EndLoc,<br>+      llvm::DenseMap<VarDecl *, Expr *> &VarsWithImplicitDSA);<br><br>   OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,<br>                                          Expr *Expr,<br><br>Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)<br>+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Mon Dec  7 22:21:03 2015<br>@@ -1449,6 +1449,7 @@ namespace clang {<br>       STMT_OMP_CANCEL_DIRECTIVE,<br>       STMT_OMP_TASKLOOP_DIRECTIVE,<br>       STMT_OMP_TASKLOOP_SIMD_DIRECTIVE,<br>+      STMT_OMP_DISTRIBUTE_DIRECTIVE,<br>       EXPR_OMP_ARRAY_SECTION,<br><br>       // ARC<br><br>Modified: cfe/trunk/lib/AST/StmtOpenMP.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtOpenMP.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtOpenMP.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/AST/StmtOpenMP.cpp (original)<br>+++ cfe/trunk/lib/AST/StmtOpenMP.cpp Mon Dec  7 22:21:03 2015<br>@@ -832,3 +832,48 @@ OMPTaskLoopSimdDirective::CreateEmpty(co<br>   return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses);<br> }<br><br>+OMPDistributeDirective *OMPDistributeDirective::Create(<br>+    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,<br>+    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,<br>+    const HelperExprs &Exprs) {<br>+  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPDistributeDirective),<br>+                                           llvm::alignOf<OMPClause *>());<br>+  void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +<br>+                         sizeof(Stmt *) *<br>+                             numLoopChildren(CollapsedNum, OMPD_distribute));<br>+  OMPDistributeDirective *Dir = new (Mem)<br>+      OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());<br>+  Dir->setClauses(Clauses);<br>+  Dir->setAssociatedStmt(AssociatedStmt);<br>+  Dir->setIterationVariable(Exprs.IterationVarRef);<br>+  Dir->setLastIteration(Exprs.LastIteration);<br>+  Dir->setCalcLastIteration(Exprs.CalcLastIteration);<br>+  Dir->setPreCond(Exprs.PreCond);<br>+  Dir->setCond(Exprs.Cond);<br>+  Dir->setInit(Exprs.Init);<br>+  Dir->setInc(Exprs.Inc);<br>+  Dir->setIsLastIterVariable(Exprs.IL);<br>+  Dir->setLowerBoundVariable(Exprs.LB);<br>+  Dir->setUpperBoundVariable(Exprs.UB);<br>+  Dir->setStrideVariable(Exprs.ST);<br>+  Dir->setEnsureUpperBound(Exprs.EUB);<br>+  Dir->setNextLowerBound(Exprs.NLB);<br>+  Dir->setNextUpperBound(Exprs.NUB);<br>+  Dir->setCounters(Exprs.Counters);<br>+  Dir->setPrivateCounters(Exprs.PrivateCounters);<br>+  Dir->setInits(Exprs.Inits);<br>+  Dir->setUpdates(Exprs.Updates);<br>+  Dir->setFinals(Exprs.Finals);<br>+  return Dir;<br>+}<br>+<br>+OMPDistributeDirective *<br>+OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,<br>+                                    unsigned CollapsedNum, EmptyShell) {<br>+  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPDistributeDirective),<br>+                                           llvm::alignOf<OMPClause *>());<br>+  void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +<br>+                         sizeof(Stmt *) *<br>+                             numLoopChildren(CollapsedNum, OMPD_distribute));<br>+  return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);<br>+}<br><br>Modified: cfe/trunk/lib/AST/StmtPrinter.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)<br>+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Dec  7 22:21:03 2015<br>@@ -1057,6 +1057,11 @@ void StmtPrinter::VisitOMPTaskLoopSimdDi<br>   PrintOMPExecutableDirective(Node);<br> }<br><br>+void StmtPrinter::VisitOMPDistributeDirective(OMPDistributeDirective *Node) {<br>+  Indent() << "#pragma omp distribute ";<br>+  PrintOMPExecutableDirective(Node);<br>+}<br>+<br> //===----------------------------------------------------------------------===//<br> //  Expr printing methods.<br> //===----------------------------------------------------------------------===//<br><br>Modified: cfe/trunk/lib/AST/StmtProfile.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/AST/StmtProfile.cpp (original)<br>+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Dec  7 22:21:03 2015<br>@@ -599,6 +599,11 @@ void StmtProfiler::VisitOMPTaskLoopSimdD<br>   VisitOMPLoopDirective(S);<br> }<br><br>+void StmtProfiler::VisitOMPDistributeDirective(<br>+    const OMPDistributeDirective *S) {<br>+  VisitOMPLoopDirective(S);<br>+}<br>+<br> void StmtProfiler::VisitExpr(const Expr *S) {<br>   VisitStmt(S);<br> }<br><br>Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)<br>+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Mon Dec  7 22:21:03 2015<br>@@ -436,6 +436,16 @@ bool clang::isAllowedClauseForDirective(<br>       break;<br>     }<br>     break;<br>+  case OMPD_distribute:<br>+    switch (CKind) {<br>+#define OPENMP_DISTRIBUTE_CLAUSE(Name)                                         \<br>+  case OMPC_##Name:                                                            \<br>+    return true;<br>+#include "clang/Basic/OpenMPKinds.def"<br>+    default:<br>+      break;<br>+    }<br>+    break;<br>   case OMPD_unknown:<br>   case OMPD_threadprivate:<br>   case OMPD_section:<br>@@ -455,7 +465,8 @@ bool clang::isOpenMPLoopDirective(OpenMP<br>   return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||<br>          DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||<br>          DKind == OMPD_taskloop ||<br>-         DKind == OMPD_taskloop_simd; // TODO add next directives.<br>+         DKind == OMPD_taskloop_simd ||<br>+         DKind == OMPD_distribute; // TODO add next directives.<br> }<br><br> bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {<br>@@ -490,6 +501,10 @@ bool clang::isOpenMPSimdDirective(OpenMP<br>          DKind == OMPD_taskloop_simd; // TODO add next directives.<br> }<br><br>+bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) {<br>+  return Kind == OMPD_distribute; // TODO add next directives.<br>+}<br>+<br> bool clang::isOpenMPPrivate(OpenMPClauseKind Kind) {<br>   return Kind == OMPC_private || Kind == OMPC_firstprivate ||<br>          Kind == OMPC_lastprivate || Kind == OMPC_linear ||<br><br>Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)<br>+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Mon Dec  7 22:21:03 2015<br>@@ -262,6 +262,9 @@ void CodeGenFunction::EmitStmt(const Stm<br>   case Stmt::OMPTaskLoopSimdDirectiveClass:</font><br><font size="5">     EmitOMPTaskLoopSimdDirective(cast<OMPTaskLoopSimdDirective>(*S));<br>     break;<br>+case Stmt::OMPDistributeDirectiveClass:<br>+    EmitOMPDistributeDirective(cast<OMPDistributeDirective>(*S));<br>+       break;<br>   }<br> }<br><br><br>Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)<br>+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Dec  7 22:21:03 2015<br>@@ -2045,6 +2045,11 @@ void CodeGenFunction::EmitOMPFlushDirect<br>   }(), S.getLocStart());<br> }<br><br>+void CodeGenFunction::EmitOMPDistributeDirective(<br>+    const OMPDistributeDirective &S) {<br>+  llvm_unreachable("CodeGen for 'omp distribute' is not supported yet.");<br>+}<br>+<br> static llvm::Function *emitOutlinedOrderedFunction(CodeGenModule &CGM,<br>                                                    const CapturedStmt *S) {<br>   CodeGenFunction CGF(CGM, /*suppressNewContext=*/true);<br><br>Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)<br>+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Dec  7 22:21:03 2015<br>@@ -2339,6 +2339,7 @@ public:<br>   void EmitOMPCancelDirective(const OMPCancelDirective &S);<br>   void EmitOMPTaskLoopDirective(const OMPTaskLoopDirective &S);<br>   void EmitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &S);<br>+  void EmitOMPDistributeDirective(const OMPDistributeDirective &S);<br><br>   /// \brief Emit inner loop of the worksharing/simd construct.<br>   ///<br><br>Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=255001&r1=255000&am
p;r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)<br>+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Mon Dec  7 22:21:03 2015<br>@@ -140,6 +140,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpen<br>   case OMPD_target_data:<br>   case OMPD_taskloop:<br>   case OMPD_taskloop_simd:<br>+  case OMPD_distribute:<br>     Diag(Tok, diag::err_omp_unexpected_directive)<br>         << getOpenMPDirectiveName(DKind);<br>     break;<br>@@ -160,7 +161,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpen<br> ///         'parallel for' | 'parallel sections' | 'task' | 'taskyi eld' |<br> ///         'barrier' | 'taskwait' | 'flush' | 'ordered' | 'atomic' |<br> ///         'for simd' | 'parallel for simd' | 'target' | 'target data' |<br>-///         'taskgroup' | 'teams' | 'taskloop' | 'taskloop simd' {clause}<br>+///         'taskgroup' | 'teams' | 'taskloop' | 'taskloop simd' {clause} |<br>+///         'distribute'<br> ///         annot_pragma_openmp_end<br> ///<br> StmtResult<br>@@ -237,7 +239,8 @@ Parser::ParseOpenMPDeclarativeOrExecutab<br>   case OMPD_taskgroup:<br>   case OMPD_target_data:<br>   case OMPD_taskloop:<br>-  case OMPD_taskloop_simd: {<br>+  case OMPD_taskloop_simd:<br>+  case OMPD_distribute: {<br>     ConsumeToken();<br>     // Parse directive name of the 'critical' directive if any.<br>     if (DKind == OMPD_critical) {<br><br>Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)<br>+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Dec  7 22:21:03 2015<br>@@ -1568,6 +1568,14 @@ void Sema::ActOnOpenMPRegionStart(OpenMP<br>                              Params);<br>     break;<br>   }<br>+  case OMPD_distribute: {<br>+    Sema::CapturedParamNameType Params[] = {<br>+        std::make_pair(StringRef(), QualType()) // __context with shared vars<br>+    };<br>+    ActOnCapturedRegionStart(DSAStack->getConstructLoc(), CurScope, CR_OpenMP,<br>+                             Params);<br>+    break;<br>+  }<br>   case OMPD_threadprivate:<br>   case OMPD_taskyield:<br>   case OMPD_barrier:<br>@@ -1652,6 +1660,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | parallel         | cancel          | !                                  |<br>   // | parallel         | taskloop        | *                                  |<br>   // | parallel         | taskloop simd   | *                                  |<br>+  // | parallel         | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | for              | parallel        | *                                  |<br>   // | for              | for             | +                                  |<br>@@ -1680,6 +1689,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | for              | cancel          | !                                  |<br>   // | for              | taskloop        | *                                  |<br>   // | for              | taskloop simd   | *                                  |<br>+  // | for              | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | master           | parallel        | *                                  |<br>   // | master           | for             | +                                  |<br>@@ -1708,6 +1718,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | master           | cancel          |                                    |<br>   // | master           | taskloop        | *                                  |<br>   // | master           | taskloop simd   | *                                  |<br>+  // | master           | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | critical         | parallel        | *                                  |<br>   // | critical         | for             | +                                  |<br>@@ -1735,6 +1746,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | critical         | cancel          |                                    |<br>   // | critical         | taskloop        | *                                  |<br>   // | critical         | taskloop simd   | *                                  |<br>+  // | critical         | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | simd             | parallel        |                                    |<br>   // | simd             | for             |                                    |<br>@@ -1763,6 +1775,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | simd             | cancel          |                                    |<br>   // | simd             | taskloop        |                                    |<br>   // | simd             | taskloop simd   |                                    |<br>+  // | simd             | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | for simd         | parallel        |                                    |<br>   // | for simd         | for             |                                    |<br>@@ -1791,6 +1804,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | for simd         | cancel          |                                    |<br>   // | for simd         | taskloop        |                                    |<br>   // | for simd         | taskloop simd   |                                    |<br>+  // | for simd         | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | parallel for simd| parallel        |                                    |<br>   // | parallel for simd| for             |                                    |<br>@@ -1819,6 +1833,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | parallel for simd| cancel          |                                    |<br>   // | parallel for simd| taskloop        |                                    |<br>   // | parallel for simd| taskloop simd   |                                    |<br>+  // | parallel for simd| distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | sections         | parallel        | *                                  |<br>   // | sections         | for             | +                                  |<br>@@ -1847,6 +1862,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | sections         | cancel          | !                                  |<br>   // | sections         | taskloop        | *                                  |<br>   // | sections         | taskloop simd   | *                                  |<br>+  // | sections         | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | section          | parallel        | *                                  |<br>   // | section          | for             | +                                  |<br>@@ -1875,6 +1891,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | section          | cancel          | !                                  |<br>   // | section          | taskloop        | *                                  |<br>   // | section          | taskloop simd   | *                                  |<br>+  // | section          | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | single           | parallel        | *                                  |<br>   // | single           | for             | +                                  |<br>@@ -1903,6 +1920,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | single           | cancel          |                                    |<br>   // | single           | taskloop        | *                                  |<br>   // | single           | taskloop simd   | *                                  |<br>+  // | single           | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | parallel for     | parallel        | *                                  |<br>   // | parallel for     | for             | +                                  |<br>@@ -1931,6 +1949,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | parallel for     | cancel          | !                                  |<br>   // | parallel for     | taskloop        | *                                  |<br>   // | parallel for     | taskloop simd   | *                                  |<br>+  // | parallel for     | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | parallel sections| parallel        | *                                  |<br>   // | parallel sections| for             | +                                  |<br>@@ -1959,6 +1978,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | parallel sections| cancel          | !                                  |<br>   // | parallel sections| taskloop        | *                                  |<br>   // | parallel sections| taskloop simd   | *                                  |<br>+  // | parallel sections| distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | task             | parallel        | *                                  |<br>   // | task             | for             | +                                  |<br>@@ -1987,6 +2007,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | task             | cancel          | !                                  |<br>   // | task             | taskloop        | *                                  |<br>   // | task             | taskloop simd   | *                                  |<br>+  // | task             | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | ordered          | parallel        | *                                  |<br>   // | ordered          | for             | +                                  |<br>@@ -2015,6 +2036,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | ordered          | cancel          |                                    |<br>   // | ordered          | taskloop        | *                                  |<br>   // | ordered          | taskloop simd   | *                                  |<br>+  // | ordered          | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | atomic           | parallel        |                                    |<br>   // | atomic           | for             |                                    |<br>@@ -2043,6 +2065,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | atomic           | cancel          |                                    |<br>   // | atomic           | taskloop        |                                    |<br>   // | atomic           | taskloop simd   |                                    |<br>+  // | atomic           | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | target           | parallel        | *                                  |<br>   // | target           | for             | *                                  |<br>@@ -2071,6 +2094,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | target           | cancel          |                                    |<br>   // | target           | taskloop        | *                                  |<br>   // | target           | taskloop simd   | *                                  |<br>+  // | target           | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | teams            | parallel        | *                                  |<br>   // | teams            | for             | +                                  |<br>@@ -2099,6 +2123,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // | teams            | cancel          |                                    |<br>   // | teams            | taskloop        | +                                  |<br>   // | teams            | taskloop simd   | +                                  |<br>+  // | teams            | distribute      | !                                  |<br>   // +------------------+-----------------+------------------------------------+<br>   // | taskloop         | parallel        | *                                  |<br>   // | taskloop         | for             | +                                  |<br>@@ -2126,6 +2151,7 @@ static bool CheckNestingOfRegions(Sema &<br>   // |                  | point           |                                    |<br>   // | taskloop         | cancel          |                                    |<br>   // | taskloop         | taskloop        | *                                  |<br>+  // | taskloop         | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   // | taskloop simd    | parallel        |                                    |<br>   // | taskloop simd    | for             |                                    |<br>@@ -2154,6 +2180,36 @@ static bool CheckNestingOfRegions(Sema &<br>   // | taskloop simd    | cancel          |                                    |<br>   // | taskloop simd    | taskloop        |                                    |<br>   // | taskloop simd    | taskloop simd   |                                    |<br>+  // | taskloop simd    | distribute      |                                    |<br>+  // +------------------+-----------------+------------------------------------+<br>+  // | distribute       | parallel        | *                                  |<br>+  // | distribute       | for             | *                                  |<br>+  // | distribute       | for simd        | *                                  |<br>+  // | distribute       | master          | *                                  |<br>+  // | distribute       | critical        | *                                  |<br>+  // | distribute       | simd            | *                                  |<br>+  // | distribute       | sections        | *                                  |<br>+  // | distribute       | section         | *                                  |<br>+  // | distribute       | single          | *                                  |<br>+  // | distribute       | parallel for    | *                                  |<br>+  // | distribute       |parallel for simd| *                                  |<br>+  // | distribute       |parallel sections| *                                  |<br>+  // | distribute       | task            | *                                  |<br>+  // | distribute       | taskyield       | *                                  |<br>+  // | distribute       | barrier         | *                                  |<br>+  // | distribute       | taskwait        | *                                  |<br>+  // | distribute       | taskgroup       | *                                  |<br>+  // | distribute       | flush           | *                                  |<br>+  // | distribute       | ordered         | +                                  |<br>+  // | distribute       | atomic          | *                                  |<br>+  // | distribute       | target          |                                    |<br>+  // | distribute       | teams           |                                    |<br>+  // | distribute       | cancellation    | +                                  |<br>+  // |                  | point           |                                    |<br>+  // | distribute       | cancel          | +                                  |<br>+  // | distribute       | taskloop        | *                                  |<br>+  // | distribute       | taskloop simd   | *                                  |<br>+  // | distribute       | distribute      |                                    |<br>   // +------------------+-----------------+------------------------------------+<br>   if (Stack->getCurScope()) {<br>     auto ParentRegion = Stack->getParentDirective();<br>@@ -2163,7 +2219,8 @@ static bool CheckNestingOfRegions(Sema &<br>       NoRecommend,<br>       ShouldBeInParallelRegion,<br>     ShouldBeInOrderedRegion,<br>-      ShouldBeInTargetRegion<br>+      ShouldBeInTargetRegion,<br>+      ShouldBeInTeamsRegion<br>     } Recommend = NoRecommend;<br>     if (isOpenMPSimdDirective(ParentRegion) && CurrentRegion != OMPD_ordered) {<br>       // OpenMP [2.16, Nesting of Regions]<br>@@ -2303,10 +2360,17 @@ static bool CheckNestingOfRegions(Sema &<br>       // distribute, parallel, parallel sections, parallel workshare, and the<br>       // parallel loop and parallel loop SIMD constructs are the only OpenMP<br>       // constructs that can be closely nested in the teams region.<br>-      // TODO: add distribute directive.<br>-      NestingProhibited = !isOpenMPParallelDirective(CurrentRegion);<br>+      NestingProhibited = !isOpenMPParallelDirective(CurrentRegion) &&<br>+                          !isOpenMPDistributeDirective(CurrentRegion);<br>       Recommend = ShouldBeInParallelRegion;<br>     }<br>+    if (!NestingProhibited && isOpenMPDistributeDirective(CurrentRegion)) {<br>+      // OpenMP 4.5 [2.17 Nesting of Regions]<br>+      // The region associated with the distribute construct must be strictly<br>+      // nested inside a teams region<br>+      NestingProhibited = !isOpenMPTeamsDirective(ParentRegion);<br>+      Recommend = ShouldBeInTeamsRegion;<br>+    }<br>     if (NestingProhibited) {<br>       SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)<br>           << CloseNesting << getOpenMPDirectiveName(ParentRegion) << Recommend<br>@@ -2574,6 +2638,10 @@ StmtResult Sema::ActOnOpenMPExecutableDi<br>                                            EndLoc, VarsWithInheritedDSA);<br>     AllowedNameModifiers.push_back(OMPD_taskloop);<br>     break;<br>+  case OMPD_distribute:<br>+    Res = ActOnOpenMPDistributeDirective(ClausesWithImplicit, AStmt, StartLoc,<br>+                                         EndLoc, VarsWithInheritedDSA);<br>+    break;<br>   case OMPD_threadprivate:<br>     llvm_unreachable("OpenMP Directive is not allowed");<br>   case OMPD_unknown:<br>@@ -3402,7 +3470,8 @@ static bool CheckOpenMPIterationSpace(<br>           : OMPC_private;<br>   if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&<br>         DVar.CKind != OMPC_threadprivate && DVar.CKind != PredeterminedCKind) ||<br>-       ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop) &&<br>+       ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||<br>+        isOpenMPDistributeDirective(DKind)) &&<br>         !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&<br>         DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate &&<br>         DVar.CKind != OMPC_threadprivate)) &&<br>@@ -3441,7 +3510,8 @@ static bool CheckOpenMPIterationSpace(<br>   ResultIterSpace.PreCond = ISC.BuildPreCond(DSA.getCurScope(), For->getCond());<br>   ResultIterSpace.NumIterations = ISC.BuildNumIterations(<br>       DSA.getCurScope(), (isOpenMPWorksharingDirective(DKind) ||<br>-                          isOpenMPTaskLoopDirective(DKind)));<br>+                          isOpenMPTaskLoopDirective(DKind) ||<br>+                          isOpenMPDistributeDirective(DKind)));<br>   ResultIterSpace.CounterVar = ISC.BuildCounterVar();<br>   ResultIterSpace.PrivateCounterVar = ISC.BuildPrivateCounterVar();<br>   ResultIterSpace.CounterInit = ISC.BuildCounterInit();<br>@@ -3749,7 +3819,8 @@ CheckOpenMPLoop(OpenMPDirectiveKind DKin<br>   QualType VType = LastIteration.get()->getType();<br>   // Build variables passed into runtime, nesessary for worksharing directives.<br>   ExprResult LB, UB, IL, ST, EUB;<br>-  if (isOpenMPWorksharingDirective(DKind) || isOpenMPTaskLoopDirective(DKind)) {<br>+  if (isOpenMPWorksharingDirective(DKind) || isOpenMPTaskLoopDirective(DKind) ||<br>+      isOpenMPDistributeDirective(DKind)) {<br>     // Lower bound variable, initialized with zero.<br>     VarDecl *LBDecl = buildVarDecl(SemaRef, InitLoc, VType, ".</font><a href="http://omp.lb/" target="_blank"><u><font size="5" color="#0000FF">omp.lb</font></u></a><font size="5">");<br>     LB = buildDeclRefExpr(SemaRef, LBDecl, VType, InitLoc);<br>@@ -3798,7 +3869,8 @@ CheckOpenMPLoop(OpenMPDirectiveKind DKin<br>     VarDecl *IVDecl = buildVarDecl(SemaRef, InitLoc, VType, ".omp.iv");<br>     IV = buildDeclRefExpr(SemaRef, IVDecl, VType, InitLoc);<br>     Expr *RHS = (isOpenMPWorksharingDirective(DKind) ||<br>-                 isOpenMPTaskLoopDirective(DKind))<br>+                 isOpenMPTaskLoopDirective(DKind) ||<br>+                 isOpenMPDistributeDirective(DKind))<br>                     ? LB.get()<br>                     : SemaRef.ActOnIntegerConstant(SourceLocation(), 0).get();<br>     Init = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, IV.get(), RHS);<br>@@ -3808,7 +3880,8 @@ CheckOpenMPLoop(OpenMPDirectiveKind DKin<br>   // Loop condition (IV < NumIterations) or (IV <= UB) for worksharing loops.<br>   SourceLocation CondLoc;<br>   ExprResult Cond =<br>-      (isOpenMPWorksharingDirective(DKind) || isOpenMPTaskLoopDirective(DKind))<br>+      (isOpenMPWorksharingDirective(DKind) ||<br>+       isOpenMPTaskLoopDirective(DKind) || isOpenMPDistributeDirective(DKind))<br>           ? SemaRef.BuildBinOp(CurScope, CondLoc, BO_LE, IV.get(), UB.get())<br>           : SemaRef.BuildBinOp(CurScope, CondLoc, BO_LT, IV.get(),<br>                                NumIterations.get());<br>@@ -3828,7 +3901,8 @@ CheckOpenMPLoop(OpenMPDirectiveKind DKin<br>   // Increments for worksharing loops (LB = LB + ST; UB = UB + ST).<br>   // Used for directives with static scheduling.<br>   ExprResult NextLB, NextUB;<br>-  if (isOpenMPWorksharingDirective(DKind) || isOpenMPTaskLoopDirective(DKind)) {<br>+  if (isOpenMPWorksharingDirective(DKind) || isOpenMPTaskLoopDirective(DKind) ||<br>+      isOpenMPDistributeDirective(DKind)) {<br>     // LB + ST<br>     NextLB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Add, LB.get(), ST.get());<br>     if (!NextLB.isUsable())<br>@@ -5345,6 +5419,32 @@ StmtResult Sema::ActOnOpenMPTaskLoopSimd<br>                                           NestedLoopCount, Clauses, AStmt, B);<br> }<br><br>+StmtResult Sema::ActOnOpenMPDistributeDirective(<br>+    ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,<br>+    SourceLocation EndLoc,<br>+    llvm::DenseMap<VarDecl *, Expr *> &VarsWithImplicitDSA) {<br>+  if (!AStmt)<br>+    return StmtError();<br>+<br>+  assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");<br>+  OMPLoopDirective::HelperExprs B;<br>+  // In presence of clause 'collapse' with number of loops, it will<br>+  // define the nested loops number.<br>+  unsigned NestedLoopCount =<br>+      CheckOpenMPLoop(OMPD_distribute, getCollapseNumberExpr(Clauses),<br>+                      nullptr /*ordered not a clause on distribute*/, AStmt,<br>+                      *this, *DSAStack, VarsWithImplicitDSA, B);<br>+  if (NestedLoopCount == 0)<br>+    return StmtError();<br>+<br>+  assert((CurContext->isDependentContext() || B.builtAll()) &&<br>+         "omp for loop exprs were not built");<br>+<br>+  getCurFunction()->setHasBranchProtectedScope();<br>+  return OMPDistributeDirective::Create(Context, StartLoc, EndLoc,<br>+                                        NestedLoopCount, Clauses, AStmt, B);<br>+}<br>+<br> OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,<br>                                              SourceLocation StartLoc,<br>                                              SourceLocation LParenLoc,<br>@@ -6381,6 +6481,49 @@ OMPClause *Sema::ActOnOpenMPFirstprivate<br>           continue;<br>         }<br>       }<br>+<br>+      // OpenMP 4.5 [2.15.3.4, Restrictions, p.3]<br>+      // A list item that is private within a teams region must not appear in a<br>+      // firstprivate clause on a distribute construct if any of the distribute<br>+      // regions arising from the distribute construct ever bind to any of the<br>+      // teams regions arising from the teams construct.<br>+      // OpenMP 4.5 [2.15.3.4, Restrictions, p.3]<br>+      // A list item that appears in a reduction clause of a teams construct<br>+      // must not appear in a firstprivate clause on a distribute construct if<br>+      // any of the distribute regions arising from the distribute construct<br>+      // ever bind to any of the teams regions arising from the teams construct.<br>+      // OpenMP 4.5 [2.10.8, Distribute Construct, p.3]<br>+      // A list item may appear in a firstprivate or lastprivate clause but not<br>+      // both.<br>+      if (CurrDir == OMPD_distribute) {<br>+        DVar = DSAStack->hasInnermostDSA(VD, MatchesAnyClause(OMPC_private),<br>+                                         [](OpenMPDirectiveKind K) -> bool {<br>+                                           return isOpenMPTeamsDirective(K);<br>+                                         },<br>+                                         false);<br>+        if (DVar.CKind == OMPC_private && isOpenMPTeamsDirective(DVar.DKind)) {<br>+          Diag(ELoc, diag::err_omp_firstprivate_distribute_private_teams);<br>+          ReportOriginalDSA(*this, DSAStack, VD, DVar);<br>+          continue;<br>+        }<br>+        DVar = DSAStack->hasInnermostDSA(VD, MatchesAnyClause(OMPC_reduction),<br>+                                         [](OpenMPDirectiveKind K) -> bool {<br>+                                           return isOpenMPTeamsDirective(K);<br>+                                         },<br>+                                         false);<br>+        if (DVar.CKind == OMPC_reduction &&<br>+            isOpenMPTeamsDirective(DVar.DKind)) {<br>+          Diag(ELoc, diag::err_omp_firstprivate_distribute_in_teams_reduction);<br>+          ReportOriginalDSA(*this, DSAStack, VD, DVar);<br>+          continue;<br>+        }<br>+        DVar = DSAStack->getTopDSA(VD, false);<br>+        if (DVar.CKind == OMPC_lastprivate) {<br>+          Diag(ELoc, diag::err_omp_firstprivate_and_lastprivate_in_distribute);<br>+          ReportOriginalDSA(*this, DSAStack, VD, DVar);<br>+          continue;<br>+        }<br>+      }<br>     }<br><br>     // Variably modified types are not supported for tasks.<br>@@ -6577,6 +6720,18 @@ OMPClause *Sema::ActOnOpenMPLastprivateC<br>     if (AssignmentOp.isInvalid())<br>       continue;<br><br>+    // OpenMP 4.5 [2.10.8, Distribute Construct, p.3]<br>+    // A list item may appear in a firstprivate or lastprivate clause but not<br>+    // both.<br>+    if (CurrDir == OMPD_distribute) {<br>+      DSAStackTy::DSAVarData DVar = DSAStack->getTopDSA(VD, false);<br>+      if (DVar.CKind == OMPC_firstprivate) {<br>+        Diag(ELoc, diag::err_omp_firstprivate_and_lastprivate_in_distribute);<br>+        ReportOriginalDSA(*this, DSAStack, VD, DVar);<br>+        continue;<br>+      }<br>+    }<br>+<br>     if (TopDVar.CKind != OMPC_firstprivate)<br>       DSAStack->addDSA(VD, DE, OMPC_lastprivate);<br>     Vars.push_back(DE);<br><br>Modified: cfe/trunk/lib/Sema/TreeTransform.h<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/Sema/TreeTransform.h (original)<br>+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Dec  7 22:21:03 2015<br>@@ -7386,6 +7386,17 @@ StmtResult TreeTransform<Derived>::Trans<br>   return Res;<br> }<br><br>+template <typename Derived><br>+StmtResult TreeTransform<Derived>::TransformOMPDistributeDirective(<br>+    OMPDistributeDirective *D) {<br>+  DeclarationNameInfo DirName;<br>+  getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute, DirName, nullptr,<br>+                                             D->getLocStart());<br>+  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);<br>+  getDerived().getSema().EndOpenMPDSABlock(Res.get());<br>+  return Res;<br>+}<br>+<br> //===----------------------------------------------------------------------===//<br> // OpenMP clause transformation<br> //===----------------------------------------------------------------------===//<br><br>Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)<br>+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Mon Dec  7 22:21:03 2015<br>@@ -2441,6 +2441,10 @@ void ASTStmtReader::VisitOMPTaskLoopSimd<br>   VisitOMPLoopDirective(D);<br> }<br><br>+void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {<br>+  VisitOMPLoopDirective(D);<br>+}<br>+<br> //===----------------------------------------------------------------------===//<br> // ASTReader Implementation<br> //===----------------------------------------------------------------------===//<br>@@ -3079,6 +3083,14 @@ Stmt *ASTReader::ReadStmtFromStream(Modu<br>       break;<br>     }<br><br>+    case STMT_OMP_DISTRIBUTE_DIRECTIVE: {<br>+      unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];<br>+      unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];<br>+      S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,<br>+                                              Empty);<br>+      break;<br>+    }<br>+<br>     case EXPR_CXX_OPERATOR_CALL:<br>       S = new (Context) CXXOperatorCallExpr(Context, Empty);<br>       break;<br><br>Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)<br>+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Mon Dec  7 22:21:03 2015<br>@@ -2261,6 +2261,11 @@ void ASTStmtWriter::VisitOMPTaskLoopSimd<br>   Code = serialization::STMT_OMP_TASKLOOP_SIMD_DIRECTIVE;<br> }<br><br>+void ASTStmtWriter::VisitOMPDistributeDirective(OMPDistributeDirective *D) {<br>+  VisitOMPLoopDirective(D);<br>+  Code = serialization::STMT_OMP_DISTRIBUTE_DIRECTIVE;<br>+}<br>+<br> //===----------------------------------------------------------------------===//<br> // ASTWriter Implementation<br> //===----------------------------------------------------------------------===//<br><br>Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp<br>URL: </font><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=255001&r1=255000&r2=255001&view=diff" target="_blank"><u><font size="5" color="#0000FF">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=255001&r1=255000&r2=255001&view=diff</font></u></a><font size="5"><br>==============================================================================<br>--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)<br>+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Dec  7 22:21:03 2015<br>@@ -831,6 +831,7 @@ void ExprEngine::Visit(const Stmt *S, Ex<br>     case Stmt::OMPCancelDirectiveClass:<br>     case Stmt::OMPTaskLoopDirectiveClass:<br>     case Stmt::OMPTaskLoopSimdDirectiveClass:<br>+    case Stmt::OMPDist<br><br>_______________________________________________<br>cfe-commits mailing list</font><u><font size="4" color="#0000FF"><br></font></u><a href="mailto:cfe-commits@lists.llvm.org" target="_blank"><u><font size="5" color="#0000FF">cfe-commits@lists.llvm.org</font></u></a><u><font size="4" color="#0000FF"><br></font></u><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank"><u><font size="5" color="#0000FF">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</font></u></a></ul></ul><font size="4"><br><br></font><font size="5"><br>-- <br>Alexey Samsonov</font><u><font size="4" color="#0000FF"><br></font></u><a href="mailto:vonosmas@gmail.com" target="_blank"><u><font size="5" color="#0000FF">vonosmas@gmail.com</font></u></a><font size="4"><br><br></font><br><font size="4"><br>_______________________________________________<br>cfe-commits mailing list</font><u><font size="4" color="#0000FF"><br></font></u><a href="mailto:cfe-commits@lists.llvm.org" target="_blank"><u><font size="4" color="#0000FF">cfe-commits@lists.llvm.org</font></u></a><u><font size="4" color="#0000FF"><br></font></u><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank"><u><font size="4" color="#0000FF">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</font></u></a><font size="4"><br></font><br><br><font size="4">_______________________________________________<br>cfe-commits mailing list</font><u><font size="4" color="#0000FF"><br></font></u><a href="mailto:cfe-commits@lists.llvm.org" target="_blank"><u><font size="4" color="#0000FF">cfe-commits@lists.llvm.org</font></u></a><u><font size="4" color="#0000FF"><br></font></u><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank"><u><font size="4" color="#0000FF">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</font></u></a><u><font size="4" color="#0000FF">[attachment "graycol.gif" deleted by Carlo Bertolli/Watson/IBM] </font></u><br><br></ul><BR>
</body></html>