r317696 - [clang-refactor] Get rid of OccurrencesFinder in RenamingAction, NFC
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 8 06:53:08 PST 2017
Author: hokein
Date: Wed Nov 8 06:53:08 2017
New Revision: 317696
URL: http://llvm.org/viewvc/llvm-project?rev=317696&view=rev
Log:
[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
Modified:
cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
Modified: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp?rev=317696&r1=317695&r2=317696&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp Wed Nov 8 06:53:08 2017
@@ -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(RefactoringR
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.
More information about the cfe-commits
mailing list