[Support] Address some of dblaikie's feedback for r263749.
authorLang Hames <lhames@gmail.com>
Thu, 17 Mar 2016 23:43:33 +0000 (23:43 +0000)
committerLang Hames <lhames@gmail.com>
Thu, 17 Mar 2016 23:43:33 +0000 (23:43 +0000)
Fixes some missing std::moves and take Expected<T> by rvalue reference in the
call operator.

llvm-svn: 263764

llvm/include/llvm/Support/Error.h

index 2e1699e..3c9bb9a 100644 (file)
@@ -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);
   }