[PATCH] [OPENMP] Codegen for 'lastprivate' clause in 'sections' directive.

Alexey Bataev a.bataev at hotmail.com
Sun Apr 26 21:18:19 PDT 2015


================
Comment at: lib/CodeGen/CGStmtOpenMP.cpp:1227
@@ -1202,1 +1226,3 @@
+      I(S.clauses(), LastprivateFilter);
+  bool HasLastprivates = I;
   auto &&CodeGen = [Stmt, &S, &HasFirstprivates](CodeGenFunction &CGF) {
----------------
rjmccall wrote:
> You construct iterators like this so often — and almost always with a single clause kind as the filter — that I think you should probably just add specific API for it on OMPExecutableDirective.  Something like
> 
>   template <Fn> filtered_clause_iterator<Fn> getFilteredClauses(Fn &&fn) const {
>     return filtered_clause_iterator<Fn>(clauses(), std::move(fn));
>   }
> 
>   struct ClauseKindFilter {
>     OpenMPClauseKind Kind;
>     bool operator()(const OMPClause *clause) const { return clause->getClauseKind() == Kind; }
>   };
>   filtered_clause_iterator<ClauseKindFilter> getClausesOfKind(OpenMPClauseKind kind) const {
>     return getFilteredClauses(ClauseKindFilter{ kind });
>   }
> 
> Also, the operator bool on filtered_clause_iterator should be explicit.
> 
> The upshot is that this entire block should turn into:
>   bool HasLastprivates = !S.getClausesOfKind(OMPC_lastprivate).empty();
John, I already thought about it. I will commit a fix for it later today.

http://reviews.llvm.org/D9240

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list