1.. title:: clang-tidy - bugprone-exception-escape 2 3bugprone-exception-escape 4========================= 5 6Finds functions which may throw an exception directly or indirectly, but they 7should 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* ``iter_swap()`` functions 15* ``iter_move()`` functions 16* Functions marked with ``throw()`` or ``noexcept`` 17* Other functions given as option 18 19A destructor throwing an exception may result in undefined behavior, resource 20leaks or unexpected termination of the program. Throwing move constructor or 21move assignment also may result in undefined behavior or resource leak. The 22``swap()`` operations expected to be non throwing most of the cases and they 23are always possible to implement in a non throwing way. Non throwing ``swap()`` 24operations are also used to create move operations. A throwing ``main()`` 25function also results in unexpected termination. 26 27Functions declared explicitly with ``noexcept(false)`` or ``throw(exception)`` 28will be excluded from the analysis, as even though it is not recommended for 29functions like ``swap()``, ``main()``, move constructors, move assignment operators 30and destructors, it is a clear indication of the developer's intention and 31should be respected. 32 33WARNING! This check may be expensive on large source files. 34 35Options 36------- 37 38.. option:: FunctionsThatShouldNotThrow 39 40 Comma separated list containing function names which should not throw. An 41 example value for this parameter can be ``WinMain`` which adds function 42 ``WinMain()`` in the Windows API to the list of the functions which should 43 not throw. Default value is an empty string. 44 45.. option:: IgnoredExceptions 46 47 Comma separated list containing type names which are not counted as thrown 48 exceptions in the check. Default value is an empty string. 49