This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Adding Fuchsia checker for virtual inheritance
ClosedPublic

Authored by juliehockett on Dec 4 2017, 4:24 PM.

Diff Detail

Event Timeline

juliehockett created this revision.Dec 4 2017, 4:24 PM
Eugene.Zelenko added inline comments.
test/clang-tidy/fuchsia-virtual-inheritance.cpp
43

void is redundant in C++. See modernize-redundant-void-arg.

aaron.ballman added inline comments.Dec 5 2017, 7:54 AM
clang-tidy/fuchsia/FuchsiaTidyModule.cpp
28–29

Formatting looks off here.

clang-tidy/fuchsia/VirtualInheritanceCheck.cpp
22

Elide spurious parens.

45

s/which/that

docs/clang-tidy/checks/fuchsia-virtual-inheritance.rst
13

Missing a semicolon on the class declaration.

juliehockett marked 5 inline comments as done.
aaron.ballman added inline comments.Dec 6 2017, 8:28 AM
test/clang-tidy/fuchsia-virtual-inheritance.cpp
31

I don't think that this should be diagnosed -- it will be confusing to the user to see this claimed as virtual inheritance when there's no virtual inheritance at this level.

35–37

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.

juliehockett marked an inline comment as done.

Updated matcher to only match direct virtual base classes.

juliehockett added inline comments.Dec 13 2017, 12:04 PM
test/clang-tidy/fuchsia-virtual-inheritance.cpp
35–37

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.

aaron.ballman added inline comments.Dec 14 2017, 8:35 AM
test/clang-tidy/fuchsia-virtual-inheritance.cpp
35–37

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.

Updating checker to only warn on declarations.

juliehockett marked 3 inline comments as done.Dec 14 2017, 2:52 PM
juliehockett added inline comments.
test/clang-tidy/fuchsia-virtual-inheritance.cpp
35–37

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.

aaron.ballman accepted this revision.Dec 14 2017, 5:11 PM

Aside from some documentation nits, LGTM!

docs/clang-tidy/checks/fuchsia-virtual-inheritance.rst
7

Comment is out of date.

15

Comment out of date

This revision is now accepted and ready to land.Dec 14 2017, 5:11 PM
This revision was automatically updated to reflect the committed changes.
juliehockett marked 4 inline comments as done.