Index: test/clang-tidy/hicpp-exception-baseclass.cpp =================================================================== --- test/clang-tidy/hicpp-exception-baseclass.cpp +++ test/clang-tidy/hicpp-exception-baseclass.cpp @@ -10,39 +10,39 @@ void problematic() { try { - throw int(42); // Built in is not allowed + throw int(42); // CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception' } catch (int e) { } - throw int(42); // Bad + throw int(42); // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception' try { - throw non_derived_exception(); // Some class is not allowed + throw non_derived_exception(); // CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' // CHECK-MESSAGES: 9:1: note: type defined here } catch (non_derived_exception &e) { } - throw non_derived_exception(); // Bad + throw non_derived_exception(); // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' // CHECK-MESSAGES: 9:1: note: type defined here } void allowed_throws() { try { - throw std::exception(); // Ok + throw std::exception(); // Ok } catch (std::exception &e) { // Ok } throw std::exception(); try { - throw derived_exception(); // Ok + throw derived_exception(); // Ok } catch (derived_exception &e) { // Ok } throw derived_exception(); // Ok try { - throw deep_hierarchy(); // Ok, multiple levels of inheritance + throw deep_hierarchy(); // Ok, multiple levels of inheritance } catch (deep_hierarchy &e) { // Ok } throw deep_hierarchy(); // Ok @@ -75,14 +75,14 @@ class exotic_exception : public T {}; void generic_exceptions() { - THROW_EXCEPTION(int); // Bad + THROW_EXCEPTION(int); // CHECK MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception' - THROW_EXCEPTION(non_derived_exception); // Bad + THROW_EXCEPTION(non_derived_exception); // CHECK MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception' // CHECK MESSAGES: 9:1: note: type defined here - THROW_EXCEPTION(std::exception); // Ok + THROW_EXCEPTION(std::exception); // Ok THROW_EXCEPTION(derived_exception); // Ok - THROW_EXCEPTION(deep_hierarchy); // Ok + THROW_EXCEPTION(deep_hierarchy); // Ok THROW_BAD_EXCEPTION; // CHECK-MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception' @@ -90,24 +90,24 @@ THROW_GOOD_EXCEPTION; THROW_DERIVED_EXCEPTION; - throw generic_exception(); // Ok, + throw generic_exception(); // Ok, THROW_EXCEPTION(generic_exception); // Ok - throw bad_generic_exception(); // Bad, not derived + throw bad_generic_exception(); // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' - throw bad_generic_exception(); // Bad as well, since still not derived + throw bad_generic_exception(); // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' - THROW_EXCEPTION(bad_generic_exception); // Bad + THROW_EXCEPTION(bad_generic_exception); // CHECK MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' - THROW_EXCEPTION(bad_generic_exception); // Bad + THROW_EXCEPTION(bad_generic_exception); // CHECK MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception' - throw exotic_exception(); // Bad + throw exotic_exception(); // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception' - THROW_EXCEPTION(exotic_exception); // Bad + THROW_EXCEPTION(exotic_exception); // CHECK MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception' - throw exotic_exception(); // Ok + throw exotic_exception(); // Ok THROW_EXCEPTION(exotic_exception); // Ok } @@ -118,11 +118,11 @@ using UsingGood = deep_hierarchy; void typedefed() { - throw TypedefedBad(); // Bad + throw TypedefedBad(); // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'TypedefedBad' (aka 'int') is not derived from 'std::exception' throw TypedefedGood(); // Ok - throw UsingBad(); // Bad + throw UsingBad(); // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'UsingBad' (aka 'int') is not derived from 'std::exception' throw UsingGood(); // Ok }