[llvm] r263764 - [Support] Address some of dblaikie's feedback for r263749.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 17 16:43:33 PDT 2016


Author: lhames
Date: Thu Mar 17 18:43:33 2016
New Revision: 263764

URL: http://llvm.org/viewvc/llvm-project?rev=263764&view=rev
Log:
[Support] Address some of dblaikie's feedback for r263749.

Fixes some missing std::moves and take Expected<T> by rvalue reference in the
call operator.


Modified:
    llvm/trunk/include/llvm/Support/Error.h

Modified: llvm/trunk/include/llvm/Support/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Error.h?rev=263764&r1=263763&r2=263764&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Error.h (original)
+++ llvm/trunk/include/llvm/Support/Error.h Thu Mar 17 18:43:33 2016
@@ -752,17 +752,17 @@ public:
 
   /// Create an error on exit helper.
   ExitOnError(std::string Banner = "", int DefaultErrorExitCode = 1)
-    : Banner(Banner),
+    : Banner(std::move(Banner)),
       GetExitCode([=](const Error&) { return DefaultErrorExitCode; }) {}
 
   /// Set the banner string for any errors caught by operator().
   void setBanner(std::string Banner) {
-    this->Banner = Banner;
+    this->Banner = std::move(Banner);
   }
 
   /// Set the exit-code mapper function.
   void setExitCodeMapper(std::function<int(const Error&)> GetExitCode) {
-    this->GetExitCode = GetExitCode;
+    this->GetExitCode = std::move(GetExitCode);
   }
 
   /// Check Err. If it's in a failure state log the error(s) and exit.
@@ -773,7 +773,7 @@ public:
   /// Check E. If it's in a success state return the contained value. If it's
   /// in a failure state log the error(s) and exit.
   template <typename T>
-  T operator()(Expected<T> E) const {
+  T operator()(Expected<T> &&E) const {
     checkError(E.takeError());
     return std::move(*E);
   }




More information about the llvm-commits mailing list