This is an archive of the discontinued LLVM Phabricator instance.

[clang-move] Abstract a ClassMather for matching class declarations.
ClosedPublic

Authored by hokein on Nov 10 2016, 11:20 AM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

hokein updated this revision to Diff 77517.Nov 10 2016, 11:20 AM
hokein retitled this revision from to [clang-move] Abstract a ClassMather for matching class declarations..
hokein updated this object.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.
ioeric added inline comments.Nov 10 2016, 11:26 AM
clang-move/ClangMove.cpp
144 ↗(On Diff #77517)

It'd be more readable if you pull each case below into a helper function.

403 ↗(On Diff #77517)

push_back and then use back() would save you a variable.

424 ↗(On Diff #77517)

I'd first move push_back to the top, and then use MatchCallbacksHolder.back().

clang-move/ClangMove.h
104 ↗(On Diff #77517)

Simply MatchCallbacks would be a better name IMO.

hokein updated this revision to Diff 77521.Nov 10 2016, 11:38 AM
hokein marked 3 inline comments as done.

Address comments.

clang-move/ClangMove.cpp
144 ↗(On Diff #77517)

hmm, I'd prefer current way. Because I don't see significant advantage by pulling each case into a helper function, since the code for each condition is used only once.

ioeric added inline comments.Nov 10 2016, 11:52 AM
clang-move/ClangMove.cpp
139 ↗(On Diff #77521)

Why is this called a Matcher?

144 ↗(On Diff #77517)

Generally, we prefer short functions to long functions.

hokein updated this revision to Diff 77788.Nov 14 2016, 3:57 AM
hokein marked 2 inline comments as done.

Split to small functions.

clang-move/ClangMove.cpp
139 ↗(On Diff #77521)

Rename it to a better name "Match".

ioeric accepted this revision.Nov 14 2016, 4:57 AM
ioeric edited edge metadata.

Lg with a few comments.

(There are two empty comments that can't be deleted due to a phabricator bugs...)

clang-move/ClangMove.cpp
151 ↗(On Diff #77788)

Not sure why you don't do type check in run(...). The following structure looks a bit weird.

if (...) {
  ...
  return true;
}
return false;
414 ↗(On Diff #77788)

Maybe put all addMatchers that bind this before those that bind to ClassDeclarationMatch.

407 ↗(On Diff #77521)

.

455 ↗(On Diff #77521)

-

This revision is now accepted and ready to land.Nov 14 2016, 4:57 AM
hokein updated this revision to Diff 77803.Nov 14 2016, 6:21 AM
hokein marked 2 inline comments as done.
hokein edited edge metadata.

Address remaining comments.

This revision was automatically updated to reflect the committed changes.