74 lines · plain
1.. title:: clang-tidy - bugprone-exception-escape2 3bugprone-exception-escape4=========================5 6Finds functions which may throw an exception directly or indirectly, but they7should not. The functions which should not throw exceptions are the following:8 9* Destructors10* Move constructors11* Move assignment operators12* The ``main()`` functions13* ``swap()`` functions14* ``iter_swap()`` functions15* ``iter_move()`` functions16* Functions marked with ``throw()`` or ``noexcept``17* Other functions given as option18 19A destructor throwing an exception may result in undefined behavior, resource20leaks or unexpected termination of the program. Throwing move constructor or21move assignment also may result in undefined behavior or resource leak. The22``swap()`` operations expected to be non throwing most of the cases and they23are 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 for29functions like ``swap()``, ``main()``, move constructors, move assignment30operators and destructors, it is a clear indication of the developer's31intention and should be respected.32 33WARNING! This check may be expensive on large source files.34 35Options36-------37 38.. option:: CheckDestructors39 40 When `true`, destructors are analyzed to not throw exceptions.41 Default value is `true`.42 43.. option:: CheckMoveMemberFunctions44 45 When `true`, move constructors and move assignment operators are analyzed46 to not throw exceptions. Default value is `true`.47 48.. option:: CheckMain49 50 When `true`, the ``main()`` function is analyzed to not throw exceptions.51 Default value is `true`.52 53.. option:: CheckNothrowFunctions54 55 When `true`, functions marked with ``noexcept`` or ``throw()`` exception56 specifications are analyzed to not throw exceptions. Default value is `true`.57 58.. option:: CheckedSwapFunctions59 60 Comma-separated list of swap function names which should not throw exceptions.61 Default value is `swap,iter_swap,iter_move`.62 63.. option:: FunctionsThatShouldNotThrow64 65 Comma separated list containing function names which should not throw. An66 example value for this parameter can be ``WinMain`` which adds function67 ``WinMain()`` in the Windows API to the list of the functions which should68 not throw. Default value is an empty string.69 70.. option:: IgnoredExceptions71 72 Comma separated list containing type names which are not counted as thrown73 exceptions in the check. Default value is an empty string.74