This is an archive of the discontinued LLVM Phabricator instance.

[clang-rename] Merge rename-{ at | all } and optimise USRFindingAction.
ClosedPublic

Authored by omtcyfz on Sep 4 2016, 4:52 PM.

Details

Summary

Having both rename-at and rename-all both seems confusing and introduces unneeded difficulties. Allowing to use both -qualified-name and -offset at once while performing efficient renamings seems like a feature, too. Maintaining main function wrappers and custom help becomes redundant while CLI becomes less confusing.

This is basically D23651 done right.

This patch belongs to a sequence of patches needed for painless migration to clang-refactor, see D24192.

Diff Detail

Repository
rL LLVM

Event Timeline

omtcyfz updated this revision to Diff 70300.Sep 4 2016, 4:52 PM
omtcyfz retitled this revision from to [clang-rename] Merge rename-{ at | all } and optimise USRFindingAction..
omtcyfz updated this object.
omtcyfz added reviewers: alexfh, ioeric, vmiklos.
omtcyfz added subscribers: cfe-commits, Eugene.Zelenko.
vmiklos edited edge metadata.Sep 5 2016, 10:01 AM

Sure, I have no problems merging rename-all and rename-at, I added it as it looked like a good idea at that time.

alexfh requested changes to this revision.Sep 6 2016, 4:56 AM
alexfh edited edge metadata.
alexfh added inline comments.
clang-rename/USRFindingAction.cpp
49 ↗(On Diff #70300)

Why explicit?

140 ↗(On Diff #70300)

What's the reason to make the constructor explicit?

158 ↗(On Diff #70300)

Use conditional operator.

clang-rename/USRFindingAction.h
23 ↗(On Diff #70300)

No using declarations in headers, please. Also, since your code is in the clang namespace, you can include clang/Basic/LLVM.h that re-declares ArrayRef in namespace clang.

38 ↗(On Diff #70300)

Return ArrayRef.

39 ↗(On Diff #70300)

Same here.

This revision now requires changes to proceed.Sep 6 2016, 4:56 AM
omtcyfz updated this revision to Diff 70388.Sep 6 2016, 5:10 AM
omtcyfz edited edge metadata.
omtcyfz marked 6 inline comments as done.

Address comments.

omtcyfz added inline comments.Sep 6 2016, 5:18 AM
clang-rename/USRFindingAction.h
23 ↗(On Diff #70300)

Ah, I didn't think why this might be bad at first, but now I see.

alexfh requested changes to this revision.Sep 7 2016, 4:13 AM
alexfh edited edge metadata.
alexfh added inline comments.
clang-rename/USRFindingAction.cpp
158 ↗(On Diff #70388)

Merge this to the variable declaration.

169 ↗(On Diff #70388)

I'd better not use exit() in library code and try to find a way to signal the error to the caller (e.g. make the function return a bool so that HandleTranslationUnit doesn't do useless work, and use ASTContext::getDiagnostics() to report errors; or add a separate callback, if this doesn't work for some reason).

This revision now requires changes to proceed.Sep 7 2016, 4:13 AM
omtcyfz updated this revision to Diff 70673.Sep 8 2016, 3:29 AM
omtcyfz edited edge metadata.
omtcyfz marked 2 inline comments as done.

Address comments.

alexfh requested changes to this revision.Sep 8 2016, 5:24 AM
alexfh edited edge metadata.
alexfh added inline comments.
clang-rename/USRFindingAction.cpp
157 ↗(On Diff #70673)

Should we emit a diagnostic in this case as well?

171 ↗(On Diff #70673)

nit: no trailing period needed

173 ↗(On Diff #70673)

How about reporting diagnostics at this specific location?

clang-rename/USRFindingAction.h
40 ↗(On Diff #70673)

I'm not a native speaker, but to me has here reads as "possesses", not as a marker of past perfect tense. Maybe just errorOccurred()?

This revision now requires changes to proceed.Sep 8 2016, 5:24 AM
omtcyfz updated this revision to Diff 70687.Sep 8 2016, 6:03 AM
omtcyfz edited edge metadata.
omtcyfz marked 4 inline comments as done.

Address another round of comments.

Ping.

clang-rename/USRFindingAction.cpp
169 ↗(On Diff #70388)

Done.

omtcyfz updated this revision to Diff 71130.Sep 13 2016, 3:02 AM
omtcyfz edited edge metadata.

Remove redundant arguments passed to diagnostic.

alexfh accepted this revision.Sep 14 2016, 5:45 AM
alexfh edited edge metadata.

LG with a nit.

clang-rename/USRFindingAction.cpp
182 ↗(On Diff #70687)

No else after return.

This revision is now accepted and ready to land.Sep 14 2016, 5:45 AM
omtcyfz updated this revision to Diff 71334.Sep 14 2016, 6:03 AM
omtcyfz edited edge metadata.
omtcyfz marked an inline comment as done.

Nit.

This revision was automatically updated to reflect the committed changes.