[PATCH] D59466: [clang-tidy] openmp-exception-escape - a new check

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 22 11:02:05 PDT 2019


lebedev.ri added inline comments.


================
Comment at: docs/clang-tidy/checks/openmp-exception-escape.rst:10-11
+As per the OpenMP specification, structured block is an executable statement,
+possibly compound, with a single entry at the top and a single exit at the
+bottom. Which means, ``throw`` may not be used to to 'exit' out of the
+structured block. If an exception is not caught in the same structured block
----------------
aaron.ballman wrote:
> lebedev.ri wrote:
> > aaron.ballman wrote:
> > > Does this mean setjmp/longjmp out of the block is also a dangerous activity? What about gotos?
> > From D59214:
> > 
> > https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf, page 3:
> > ```
> > structured block
> > 
> > For C/C++, an executable statement, possibly compound, with a single entry at the
> > top and a single exit at the bottom, or an OpenMP construct.
> > 
> > COMMENT: See Section 2.1 on page 38 for restrictions on structured
> > blocks.
> > ```
> > ```
> > 2.1 Directive Format
> > 
> > Some executable directives include a structured block. A structured block:
> > • may contain infinite loops where the point of exit is never reached;
> > • may halt due to an IEEE exception;
> > • may contain calls to exit(), _Exit(), quick_exit(), abort() or functions with a
> > _Noreturn specifier (in C) or a noreturn attribute (in C/C++);
> > • may be an expression statement, iteration statement, selection statement, or try block, provided
> > that the corresponding compound statement obtained by enclosing it in { and } would be a
> > structured block; and
> > 
> > Restrictions
> > Restrictions to structured blocks are as follows:
> > • Entry to a structured block must not be the result of a branch.
> > • The point of exit cannot be a branch out of the structured block.
> > C / C++
> > • The point of entry to a structured block must not be a call to setjmp().
> > • longjmp() and throw() must not violate the entry/exit criteria.
> > ```
> > 
> > So yeah, `setjmp`/`longjmp` are also suspects.
> > Maybe not so much `goto` though https://godbolt.org/z/GZMugf https://godbolt.org/z/WUYcYD
> > 
> This might be another future thing for the patch to handle. May be worth adding some FIXME comments to the code detailing the extensions we want to see.
I think those might be two new checks, though i don't really expect to look into that.
I have added FIXME here though.
Also, [[ https://clang.llvm.org/extra/clang-tidy/checks/cert-err52-cpp.html | `cert-err52-cpp` ]] check already exists.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59466/new/

https://reviews.llvm.org/D59466





More information about the cfe-commits mailing list