brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · d10556f Raw
65 lines · plain
1.. title:: clang-tidy - modernize-use-uncaught-exceptions2 3modernize-use-uncaught-exceptions4====================================5 6This check will warn on calls to ``std::uncaught_exception`` and replace them7with calls to ``std::uncaught_exceptions``, since ``std::uncaught_exception``8was deprecated in C++17.9 10Below are a few examples of what kind of occurrences will be found and what11they will be replaced with.12 13.. code-block:: c++14 15  #define MACRO1 std::uncaught_exception16  #define MACRO2 std::uncaught_exception17 18  int uncaught_exception() {19    return 0;20  }21 22  int main() {23    int res;24 25    res = uncaught_exception();26    // No warning, since it is not the deprecated function from namespace std27 28    res = MACRO2();29    // Warning, but will not be replaced30 31    res = std::uncaught_exception();32    // Warning and replaced33 34    using std::uncaught_exception;35    // Warning and replaced36 37    res = uncaught_exception();38    // Warning and replaced39  }40 41After applying the fixes the code will look like the following:42 43.. code-block:: c++44 45  #define MACRO1 std::uncaught_exception46  #define MACRO2 std::uncaught_exception47 48  int uncaught_exception() {49    return 0;50  }51 52  int main() {53    int res;54 55    res = uncaught_exception();56 57    res = MACRO2();58 59    res = std::uncaught_exceptions();60 61    using std::uncaught_exceptions;62 63    res = uncaught_exceptions();64  }65