| 1 |
.. title:: clang-tidy - bugprone-exception-escape |
| 2 |
|
| 3 |
bugprone-exception-escape |
| 4 |
========================= |
| 5 |
|
| 6 |
Finds functions which may throw an exception directly or indirectly, but they |
| 7 |
should not. The functions which should not throw exceptions are the following: |
| 8 |
|
| 9 |
* Destructors |
| 10 |
* Move constructors |
| 11 |
* Move assignment operators |
| 12 |
* The ``main()`` functions |
| 13 |
* ``swap()`` functions |
| 14 |
* Functions marked with ``throw()`` or ``noexcept`` |
| 15 |
* Other functions given as option |
| 16 |
|
| 17 |
A destructor throwing an exception may result in undefined behavior, resource |
| 18 |
leaks or unexpected termination of the program. Throwing move constructor or |
| 19 |
move assignment also may result in undefined behavior or resource leak. The |
| 20 |
``swap()`` operations expected to be non throwing most of the cases and they |
| 21 |
are always possible to implement in a non throwing way. Non throwing ``swap()`` |
| 22 |
operations are also used to create move operations. A throwing ``main()`` |
| 23 |
function also results in unexpected termination. |
| 24 |
|
| 25 |
WARNING! This check may be expensive on large source files. |
| 26 |
|
| 27 |
Options |
| 28 |
------- |
| 29 |
|
| 30 |
.. option:: FunctionsThatShouldNotThrow |
| 31 |
|
| 32 |
Comma separated list containing function names which should not throw. An |
| 33 |
example value for this parameter can be ``WinMain`` which adds function |
| 34 |
``WinMain()`` in the Windows API to the list of the functions which should |
| 35 |
not throw. Default value is an empty string. |
| 36 |
|
| 37 |
.. option:: IgnoredExceptions |
| 38 |
|
| 39 |
Comma separated list containing type names which are not counted as thrown |
| 40 |
exceptions in the check. Default value is an empty string. |