[PATCH] D52552: [clang-tidy] Flag Classes Inheriting From Structs

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 26 10:26:20 PDT 2018


Eugene.Zelenko added inline comments.


================
Comment at: docs/ReleaseNotes.rst:109
 
+- New :doc:`misc-class-inherit-from-struct
+  <clang-tidy/checks/misc-class-inherit-from-struct>` check.
----------------
Please use alphabetical order for new checks list.


================
Comment at: docs/clang-tidy/checks/misc-class-inherit-from-struct.rst:6
+
+Finds instances of classes inheriting from structs. Structs are meant for 
+storing data and are often used to maintain C compatibility. Having a class
----------------
aaron.ballman wrote:
> I don't agree with the predicate here -- structs aren't just used for C compatibility (look at <type_traits> as an example). They're also useful when all members need to be public, which is exactly the situation you claim may be unintentional.
Please make first statement same as in Release Notes.


================
Comment at: docs/clang-tidy/checks/misc-class-inherit-from-struct.rst:15
+  struct A {};
+  class B: public A {}; //throws an error, members of A might be
+                        //unintentionally exposed
----------------
I think warning is more correct term then error for Clang-tidy diagnistics.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52552





More information about the cfe-commits mailing list