diff options
author | Haojian Wu <hokein@google.com> | 2017-11-08 14:53:08 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2017-11-08 14:53:08 +0000 |
commit | f6c0678db7aa82294169c7b3e1a2713019ffa8f1 (patch) | |
tree | 09ab0ec815df6b39abc228bfd5f6c3ee386a5843 /clang/lib/Tooling/Refactoring | |
parent | 0a41be758c1ac705a176c3a0d08d8f1643829b75 (diff) | |
download | bcm5719-llvm-f6c0678db7aa82294169c7b3e1a2713019ffa8f1.tar.gz bcm5719-llvm-f6c0678db7aa82294169c7b3e1a2713019ffa8f1.zip |
[clang-refactor] Get rid of OccurrencesFinder in RenamingAction, NFC
Summary:
The OccurrencesFinder is only used in RenameOccurrences to find symbol
occurrences, there is no need to inherit RefactoringRule.
Replace it with a single utility function to avoid code misleading.
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D39796
llvm-svn: 317696
Diffstat (limited to 'clang/lib/Tooling/Refactoring')
-rw-r--r-- | clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp b/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp index e2d5d4c3d4c..c8ed9dd19a8 100644 --- a/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp +++ b/clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp @@ -43,22 +43,14 @@ namespace tooling { namespace { -class OccurrenceFinder final : public FindSymbolOccurrencesRefactoringRule { -public: - OccurrenceFinder(const NamedDecl *ND) : ND(ND) {} - - Expected<SymbolOccurrences> - findSymbolOccurrences(RefactoringRuleContext &Context) override { - std::vector<std::string> USRs = - getUSRsForDeclaration(ND, Context.getASTContext()); - std::string PrevName = ND->getNameAsString(); - return getOccurrencesOfUSRs( - USRs, PrevName, Context.getASTContext().getTranslationUnitDecl()); - } - -private: - const NamedDecl *ND; -}; +Expected<SymbolOccurrences> +findSymbolOccurrences(const NamedDecl *ND, RefactoringRuleContext &Context) { + std::vector<std::string> USRs = + getUSRsForDeclaration(ND, Context.getASTContext()); + std::string PrevName = ND->getNameAsString(); + return getOccurrencesOfUSRs(USRs, PrevName, + Context.getASTContext().getTranslationUnitDecl()); +} } // end anonymous namespace @@ -85,8 +77,7 @@ RenameOccurrences::initiate(RefactoringRuleContext &Context, Expected<AtomicChanges> RenameOccurrences::createSourceReplacements(RefactoringRuleContext &Context) { - Expected<SymbolOccurrences> Occurrences = - OccurrenceFinder(ND).findSymbolOccurrences(Context); + Expected<SymbolOccurrences> Occurrences = findSymbolOccurrences(ND, Context); if (!Occurrences) return Occurrences.takeError(); // FIXME: Verify that the new name is valid. |