[PATCH] D33061: [tooling] RefactoringCallbacks code cleanup

Alexander Shaposhnikov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 10 13:14:37 PDT 2017


alexshap created this revision.
alexshap created this object with visibility "All Users".

1. Add missing "explicit" for single argument constructors
2. Add missing std::move in ReplaceNodeWithTemplate constructor

and switch to pass-by-value idiom

Test plan:
make check-clang


Repository:
  rL LLVM

https://reviews.llvm.org/D33061

Files:
  include/clang/Tooling/RefactoringCallbacks.h
  lib/Tooling/RefactoringCallbacks.cpp


Index: lib/Tooling/RefactoringCallbacks.cpp
===================================================================
--- lib/Tooling/RefactoringCallbacks.cpp
+++ lib/Tooling/RefactoringCallbacks.cpp
@@ -38,7 +38,7 @@
 
 class RefactoringASTConsumer : public ASTConsumer {
 public:
-  RefactoringASTConsumer(ASTMatchRefactorer &Refactoring)
+  explicit RefactoringASTConsumer(ASTMatchRefactorer &Refactoring)
       : Refactoring(Refactoring) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
@@ -153,8 +153,8 @@
 }
 
 ReplaceNodeWithTemplate::ReplaceNodeWithTemplate(
-    llvm::StringRef FromId, std::vector<TemplateElement> &&Template)
-    : FromId(FromId), Template(Template) {}
+    llvm::StringRef FromId, std::vector<TemplateElement> Template)
+    : FromId(FromId), Template(std::move(Template)) {}
 
 llvm::Expected<std::unique_ptr<ReplaceNodeWithTemplate>>
 ReplaceNodeWithTemplate::create(StringRef FromId, StringRef ToTemplate) {
@@ -193,7 +193,7 @@
     }
   }
   return std::unique_ptr<ReplaceNodeWithTemplate>(
-      new ReplaceNodeWithTemplate(FromId, std::move(ParsedTemplate)));
+       new ReplaceNodeWithTemplate(FromId, std::move(ParsedTemplate)));
 }
 
 void ReplaceNodeWithTemplate::run(
Index: include/clang/Tooling/RefactoringCallbacks.h
===================================================================
--- include/clang/Tooling/RefactoringCallbacks.h
+++ include/clang/Tooling/RefactoringCallbacks.h
@@ -53,7 +53,8 @@
 /// Runs AST matchers and stores the \c tooling::Replacements in a map.
 class ASTMatchRefactorer {
 public:
-  ASTMatchRefactorer(std::map<std::string, Replacements> &FileToReplaces);
+  explicit ASTMatchRefactorer(
+    std::map<std::string, Replacements> &FileToReplaces);
 
   template <typename T>
   void addMatcher(const T &Matcher, RefactoringCallback *Callback) {
@@ -103,7 +104,7 @@
     std::string Value;
   };
   ReplaceNodeWithTemplate(llvm::StringRef FromId,
-                          std::vector<TemplateElement> &&Template);
+                          std::vector<TemplateElement> Template);
   std::string FromId;
   std::vector<TemplateElement> Template;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33061.98509.patch
Type: text/x-patch
Size: 2140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170510/db593a5d/attachment.bin>


More information about the cfe-commits mailing list