alexshap created this revision.
alexshap added reviewers: djasper, klimek, ioeric.
alexshap added a subscriber: cfe-commits.
alexshap set the repository for this revision to rL LLVM.
alexshap changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".
Herald added a subscriber: klimek.

This diff adds std::move to avoid copying of the Replacement NewR in the method 
Replacements::add.

The class Replacement has a move constructor:
clang-query> set output print
clang-query> match cxxConstructorDecl(ofClass(hasName("Replacement")), 
isMoveConstructor(), isDefinition()).bind("id")
Match #1:
Binding for "id":
inline Replacement(clang::tooling::Replacement &&) noexcept : 
FilePath(static_cast<clang::tooling::Replacement &&>().FilePath), 
ReplacementRange(static_cast<clang::tooling::Replacement 
&&>().ReplacementRange), 
ReplacementText(static_cast<clang::tooling::Replacement &&>().ReplacementText) {
} 

Test plan: make -j8 check-all

Repository:
  rL LLVM

https://reviews.llvm.org/D25049

Files:
  lib/Tooling/Core/Replacement.cpp

Index: lib/Tooling/Core/Replacement.cpp
===================================================================
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -245,7 +245,7 @@
           R.getFilePath(), R.getOffset(), 0,
           (R.getReplacementText() + I->getReplacementText()).str());
       Replaces.erase(I);
-      Replaces.insert(NewR);
+      Replaces.insert(std::move(NewR));
       return llvm::Error::success();
     }
     // Insertion `R` is adjacent to a non-insertion replacement `I`, so they


Index: lib/Tooling/Core/Replacement.cpp
===================================================================
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -245,7 +245,7 @@
           R.getFilePath(), R.getOffset(), 0,
           (R.getReplacementText() + I->getReplacementText()).str());
       Replaces.erase(I);
-      Replaces.insert(NewR);
+      Replaces.insert(std::move(NewR));
       return llvm::Error::success();
     }
     // Insertion `R` is adjacent to a non-insertion replacement `I`, so they
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to