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

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 26 07:54:13 PDT 2018


lebedev.ri added a comment.

Please upload patches with full context.
Please do follow coding style, clang-format your patches.

Would it make sense to not catch-all all the `class : struct`, but consider the explicitly specified inheritance visibility?



================
Comment at: clang-tidy/misc/ClassInheritFromStructCheck.cpp:21
+void ClassInheritFromStructCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(cxxRecordDecl(isClass(),unless(isImplicit()),isDerivedFrom(cxxRecordDecl(isStruct()))).bind("class"), this);
+}
----------------
Please linewrap to 80 chars.


================
Comment at: test/clang-tidy/misc-class-inherit-from-struct.cpp:13
+};
+
+class C
----------------
Missing cases:
* struct inheriting from struct
* Different inheritance visibility:
  * You only check the default visibility
  * What if class explicitly-`public`ly inherits from `struct`?
  * What if class explicitly-`private`ly inherits from `struct`?
  * What if class explicitly-`protected`ly inherits from `struct`?
  * Same for `struct` inheriting from struct?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52552





More information about the cfe-commits mailing list