[cfe-dev] clang-tidy and static analysis for exception safety

Daniel Marjamäki via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 16 03:25:48 PDT 2017


As far as I see:

- a function calling only `noexcept` operations that does not throw can be marked noexcept

possible

- a function that has a `throw` statement not within a `try/catch` block can be marked noexcept(false)

Not possible

- a function calling a function that is not marked noexcept can not be marked noexcept
   but it could be noexecpt with deeper analysis on what exception could be thrown and what exceptions are handled

not possible



From: cfe-dev [mailto:cfe-dev-bounces at lists.llvm.org] On Behalf Of Jonas Toth via cfe-dev
Sent: Thursday, March 16, 2017 10:08 AM
To: via cfe-dev
Subject: [cfe-dev] clang-tidy and static analysis for exception safety

Hello everybody,

I want to implement an check for proper exception specification (noexcept correctness). In code review aaron.ballman pointed out that there is path sensitive analysis necessary. Since i have no experience and knowledge on that I would like to have some input from experienced programmers on that topic.

What should be possible with AST - Matching in clang-tidy:

- a function calling only `noexcept` operations that does not throw can be marked noexcept
- a function that has a `throw` statement not within a `try/catch` block can be marked noexcept(false)
- a function calling a function that is not marked noexcept can not be marked noexcept
   but it could be noexecpt with deeper analysis on what exception could be thrown and what exceptions are handled

Having logic for these cases would allow to automatically improve noexcept-correctness.
Maybe more importantly it would be possible to find destructors and deallocation functions that could throw but never should.

Is there already functionality for such analysis, is my model even correct and how hard would the analysis be?
I have no experience in CSA development but iam fairly interested in it and would like to learn if reasonably complicated.

All the best
Jonas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170316/cbff156a/attachment.html>


More information about the cfe-dev mailing list