ABataev added inline comments.

================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4260-4273
@@ -4259,2 +4259,16 @@
 
+/// \brief look inside a Body stmt for a LF statement discarding any
+/// intervening CompoundStmt's
+template <typename LF>
+const static LF *hasEnclosingOpenMPDirective(const Stmt *Body) {
+  const CompoundStmt *S = nullptr;
+  // keep iterating until we find an LF or not a CompoundStmt or a nullptr
+  while ((S = dyn_cast_or_null<CompoundStmt>(Body)) &&
+         (!dyn_cast_or_null<LF>(Body)))
+      Body = S->body_front();
+
+  return (Body) ? dyn_cast_or_null<LF>(Body) :
+      nullptr;
+}
+
 /// \brief Emit the num_teams clause of an enclosed teams directive at the
----------------
I don't like this function at all. We need to add a template function. Each 
instantiation will produce a new function with almost the same body. MI prepfer 
to see another solution, like:
```
static const Stmt *ignoreCompoundStmts(const Stmt *Body) {
  while (auto *CS = dyn_cast_or_null<CompoundStmt>(Body))
    Body = CS->body_front();
  return Body;
}
...
if (auto *TeamsDir = 
dyn_cast<OMPTeamsDirective>(ignoreCompoundStmts(CS.getCapturedStmt()))) {
...
```



Repository:
  rL LLVM

http://reviews.llvm.org/D18474



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to