carlo.bertolli added inline comments. ================ Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4257 @@ +4256,3 @@ +hasEnclosingTeams(const Stmt *TargetBody) { + if(auto *TeamsDir = dyn_cast<OMPTeamsDirective>(TargetBody)) return TeamsDir; + ---------------- sfantao wrote: > I think that this can be simplified to: > > ``` > while (auto *S = dyn_cast<CompoundStmt>(TargetBody)) > TargetBody = S->body_front(); > > return dyn_cast<CompoundStmt>(OMPTeamsDirective); > ``` > > I know that this is currently used only for teams, but I think it would be > nice to make this a templated function to look for other possible nests. I > suspect this will very useful for other cases like 'target teams parallel > distribute'. Thanks! I agree that having this as a template will help with combined directives. I will produce a new version of the patch with that support.
About your new loop: this would crash if S->body_front() is nullptr. This may happen if you have something like this: ``` #target { } ``` A solution may be ``` while (auto *S = dyn_cast_or_null<CompoundStmt>(TargetBody)) TargetBody = S->body_front(); return dyn_cast_or_null<CompoundStmt>(OMPTeamsDirective); ``` Thoughts? 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