Page MenuHomePhabricator

modernize-use-default supports copy constructor and copy-assignment operator.
ClosedPublic

Authored by angelgarcia on Oct 28 2015, 4:19 AM.

Diff Detail

Event Timeline

angelgarcia retitled this revision from to modernize-use-default supports copy constructor and copy-assignment operator..
angelgarcia updated this object.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: alexfh, cfe-commits.

Small tweak.

klimek edited edge metadata.Oct 28 2015, 4:40 AM

Generally, I feel like a lot of the code would be written better as ast matchers (by adding new matchers if necessary). You can use tooling::ast_matchers::matches if you want to do a match inside a callback.

clang-tidy/modernize/UseDefaultCheck.cpp
278–279

FIXME: Put into ASTMatchers.h (or just do that :)

OK, thanks! I will try to refactor some of the parts into AST matchers
then. It will probably take some time, though.

angelgarcia edited edge metadata.

Refactor most of the code to use AST matchers.

Note that now this change requires D14152 to be applied first.

klimek added inline comments.Oct 28 2015, 9:24 AM
clang-tidy/modernize/UseDefaultCheck.cpp
83–91

This looks like something we'd want to matcherify, too.

152–153

In which cases can this be false? (I assume if not all are copied?)

In which cases can this be false? (I assume if not all are copied?)

This can be false is there is we do anything else than initializing the
bases and members. So the previous code is there to ensure that we do that
and this is here to ensure that we *only* do that.

In which cases can this be false? (I assume if not all are copied?)

This can be false is there is we do anything else than initializing the
bases and members. So the previous code is there to ensure that we do that
and this is here to ensure that we *only* do that.

How can we do more inside an initializer list?

You can initialize an indirect base if it's virtual.

You can initialize an indirect base if it's virtual.

Cool, those cases would be useful to have as comment, for example:
Make sure there are no additional initializations going on (for example, of indirect bases)
and that all fields and direct bases have been initialized.

alexfh added inline comments.Oct 28 2015, 5:13 PM
test/clang-tidy/modernize-use-default.cpp
159

Can we choose a different name for it, that does not resemble a digit?

167

Please add a test with a function try block. Something along the lines of:

struct A {};
struct B : public A {
  B() try : A() {} catch(...) {}
};

Put more logic into the matchers.

Btw, do you know how can I get the exception specification of a function?

angelgarcia marked an inline comment as done.

Remove debugging code.

klimek accepted this revision.Nov 1 2015, 9:44 AM
klimek edited edge metadata.

lg

This revision is now accepted and ready to land.Nov 1 2015, 9:44 AM
angelgarcia closed this revision.Nov 2 2015, 2:36 AM