[PATCH] D37060: [clang-tidy] Improve hicpp-exception-baseclass to handle generic code better

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 28 13:24:21 PDT 2017


lebedev.ri added a comment.

I did not test this yet, but looks better :)



================
Comment at: test/clang-tidy/hicpp-exception-baseclass.cpp:26
   }
   throw non_derived_exception(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
----------------
Could you please update the comments?
I find them misleading. What does this `bad` mean?
That this line is not handled correctly? Then please use `FIXME: wrong handling`
That this line is invalid? The `// CHECK-MESSAGES:` already states that...


================
Comment at: test/clang-tidy/hicpp-exception-baseclass.cpp:54-62
+// CHECK-MESSAGES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception<int>' is not derived from 'std::exception'
+// CHECK-MESSAGES: 71:1: note: type defined here
+// CHECK-MESSAGES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception<std::exception>' is not derived from 'std::exception'
+// CHECK-MESSAGES: 71:1: note: type defined here
+// CHECK-MESSAGES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception<non_derived_exception>' is not derived from 'std::exception'
+// CHECK-MESSAGES: 74:1: note: type defined here
+// CHECK-MESSAGES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
----------------
JonasToth wrote:
> these diagnostic come from the many instantiations of this function. 
> do you think, they should exist or rather not?
They definitively should exist.
But they also should ideally point to the origin of the `T`.


https://reviews.llvm.org/D37060





More information about the cfe-commits mailing list