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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 08:35:18 PST 2017


aaron.ballman 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]
----------------
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.


https://reviews.llvm.org/D40813





More information about the cfe-commits mailing list