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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 05:45:41 PDT 2017


aaron.ballman added inline comments.


================
Comment at: clang-tidy/hicpp/ExceptionBaseclassCheck.cpp:41
+                                              "'std::exception'")
+      << BadThrow->getSubExpr()->getType() << BadThrow->getSourceRange();
 
----------------
Can you add a test that uses a rethrow? e.g.,
```
try {
  throw 12; // Diagnose this
} catch (...) {
  throw; // Does not diagnose this
}
```


================
Comment at: test/clang-tidy/hicpp-exception-baseclass.cpp:9
+class deep_hierarchy : public derived_exception {};
 class non_derived_exception {};
 
----------------
Can you add a test that uses multiple inheritance? e.g.,
```
class terrible_idea : public non_derived_exception, public derived_exception {};
```
Also, is private inheritance also acceptable, or does it need to be public inheritance? I kind of get the impression it needs to be public, because the goal appears to be that you should always be able to catch a `std::exception` instance, and you can't do that if it's privately inherited. That should have a test as well.


https://reviews.llvm.org/D37060





More information about the cfe-commits mailing list