[PATCH] D40813: [clang-tidy] Adding Fuchsia checker for virtual inheritance

Julie Hockett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 14:52:59 PST 2017


juliehockett marked 3 inline comments as done.
juliehockett added inline comments.


================
Comment at: test/clang-tidy/fuchsia-virtual-inheritance.cpp:34-36
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: constructing a class that inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  D(int value) : A(value), B(), C() {}
+  // CHECK-MESSAGES: [[@LINE-3]]:33: warning: constructing a class that inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
----------------
aaron.ballman wrote:
> juliehockett wrote:
> > aaron.ballman wrote:
> > > I'm also not certain this should be diagnosed either. It's technically correct because it's calling the base class constructors here, but at the same time, it seems very low-value and likely to cause the user to do something really bad, like silence the warning by not calling the base class constructors.
> > I see what you mean, but where then would you draw the line between warning and not? We could warn for construction everywhere except in initialization lists, but that seems like it might open the door to trivially get around the check in ways that should be disallowed.
> Would it be sufficient to only flag at the point of inheritance, or do you have existing header files with class declarations using virtual inheritance and are worried about consumers inheriting from those?
> 
> e.g., flag declarations but not construction.
Makes sense -- we think the declaration is the important one to limit here. The check for constructed virtual objects can be moved to a different checker if it becomes necessary.


https://reviews.llvm.org/D40813





More information about the cfe-commits mailing list