[PATCH] D39796: [clang-refactor] Get rid of OccurrencesFinder in RenamingAction, NFC

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 8 06:53:56 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL317696: [clang-refactor] Get rid of OccurrencesFinder in RenamingAction, NFC (authored by hokein).

Repository:
  rL LLVM

https://reviews.llvm.org/D39796

Files:
  cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp


Index: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
===================================================================
--- cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -43,22 +43,14 @@
 
 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 @@
 
 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39796.122088.patch
Type: text/x-patch
Size: 1680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171108/a3300740/attachment.bin>


More information about the cfe-commits mailing list