brintos

brintos / llvm-project-archived public Read only

0
0
Text · 768 B · 9bbc7fc Raw
30 lines · plain
1.. title:: clang-tidy - hicpp-exception-baseclass2 3hicpp-exception-baseclass4=========================5 6Ensure that every value that in a ``throw`` expression is an instance of7``std::exception``.8 9This enforces `rule 15.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-standard-exception-handling>`_10of the High Integrity C++ Coding Standard.11 12.. code-block:: c++13 14  class custom_exception {};15 16  void throwing() noexcept(false) {17    // Problematic throw expressions.18    throw int(42);19    throw custom_exception();20  }21 22  class mathematical_error : public std::exception {};23 24  void throwing2() noexcept(false) {25    // These kind of throws are ok.26    throw mathematical_error();27    throw std::runtime_error();28    throw std::exception();29  }30