This is an archive of the discontinued LLVM Phabricator instance.

[clang-rename] add support for overridden functions
ClosedPublic

Authored by omtcyfz on Jul 15 2016, 5:53 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

omtcyfz updated this revision to Diff 64133.Jul 15 2016, 5:53 AM
omtcyfz retitled this revision from to [clang-rename] add support for overridden functions.
omtcyfz updated this object.
omtcyfz added reviewers: bkramer, alexfh, klimek.
omtcyfz added a subscriber: cfe-commits.
Prazek added a project: Restricted Project.Jul 16 2016, 9:28 AM
Prazek added a subscriber: Prazek.

haven't found anything else

clang-rename/USRFindingAction.cpp
62 ↗(On Diff #64133)

const auto &OverridenMethod

omtcyfz updated this revision to Diff 64228.Jul 16 2016, 9:58 AM
omtcyfz marked an inline comment as done.
omtcyfz added inline comments.
clang-rename/USRFindingAction.cpp
62 ↗(On Diff #64133)

Fixed; thanks!

klimek added inline comments.Jul 18 2016, 12:34 AM
clang-rename/USRFindingAction.cpp
12 ↗(On Diff #64228)

... at <offset>, as well as all relevant USRs.

60 ↗(On Diff #64228)

I'd use early exit here:
if (!D->isVirtual) return true;
...

62 ↗(On Diff #64228)

This is n^3, right? (for each virtual method we run over all overrides, searching through all USRs)
a) would be cool if we could use matchers for this, as they automatically memoize; if we don't want to do that, we might want to memoize ourselves
b) sorting USRs and using binary_search should be a cheap speed-up

144 ↗(On Diff #64228)

Having all side-effects in the constructor is really unexpected to me. I'd add a Find() method.

omtcyfz updated this revision to Diff 64285.Jul 18 2016, 2:01 AM
omtcyfz marked an inline comment as done.

replaced RecursiveASTVisitor with ASTMatcher

omtcyfz marked an inline comment as done.Jul 18 2016, 2:03 AM
omtcyfz added inline comments.
clang-rename/USRFindingAction.cpp
48 ↗(On Diff #64285)

Thanks for the feedback!
a) done
b) using std::set instead and pushing into std::vector afterwards. I thing it's simple and efficient, too.

omtcyfz marked an inline comment as done.Jul 18 2016, 2:35 AM
klimek added inline comments.Jul 18 2016, 3:12 AM
clang-rename/USRFindingAction.cpp
45 ↗(On Diff #64285)

Still pondering whether 'relevant' is a good name here...

72 ↗(On Diff #64285)

That way, the matchers don't actually get us too much - I'd hoped we already had an hasOverriddenMethod matcher (apparently we don't). It might make sense to implement one.
Then we can implement a matchesUSR matcher, too (which takes a set of USRs), and all those lookups would be cached automatically.
Fine to add a FIXME for this patch though.

86 ↗(On Diff #64285)

Perhaps call this addUSRsFromOverrideSets or something? addRelevantUSRs doesn't really tell me anything about what it does, and it's currently pretty specific.

omtcyfz updated this revision to Diff 64293.Jul 18 2016, 3:36 AM
omtcyfz marked 3 inline comments as done.

Addressed Manuel's comments.

klimek accepted this revision.Jul 19 2016, 12:32 AM
klimek edited edge metadata.

lg

This revision is now accepted and ready to land.Jul 19 2016, 12:32 AM
This revision was automatically updated to reflect the committed changes.