[PATCH] D98947: [Orc] Fix copy elision warning in RPCUtils

Stefan Gränitz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 19 08:01:21 PDT 2021


sgraenitz updated this revision to Diff 331881.
sgraenitz added a comment.

Make returnError() static (oops). Rename RTraits -> AltRetTraits. Turn some autos into concrete typenames to aid readability.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98947/new/

https://reviews.llvm.org/D98947

Files:
  llvm/include/llvm/ExecutionEngine/Orc/Shared/RPCUtils.h


Index: llvm/include/llvm/ExecutionEngine/Orc/Shared/RPCUtils.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/Orc/Shared/RPCUtils.h
+++ llvm/include/llvm/ExecutionEngine/Orc/Shared/RPCUtils.h
@@ -243,6 +243,8 @@
   static void consumeAbandoned(ErrorReturnType RetOrErr) {
     consumeError(RetOrErr.takeError());
   }
+
+  static ErrorReturnType returnError(Error Err) { return std::move(Err); }
 };
 
 // ResultTraits specialization for void functions.
@@ -275,6 +277,8 @@
   static void consumeAbandoned(ErrorReturnType Err) {
     consumeError(std::move(Err));
   }
+
+  static ErrorReturnType returnError(Error Err) { return Err; }
 };
 
 // ResultTraits<Error> is equivalent to ResultTraits<void>. This allows
@@ -1494,36 +1498,34 @@
   typename detail::ResultTraits<AltRetT>::ErrorReturnType
   callB(const ArgTs &...Args) {
     bool ReceivedResponse = false;
-    using ResultType = typename detail::ResultTraits<AltRetT>::ErrorReturnType;
-    auto Result = detail::ResultTraits<AltRetT>::createBlankErrorReturnValue();
+    using AltRetTraits = detail::ResultTraits<AltRetT>;
+    using ResultType = typename AltRetTraits::ErrorReturnType;
+    ResultType Result = AltRetTraits::createBlankErrorReturnValue();
 
     // We have to 'Check' result (which we know is in a success state at this
     // point) so that it can be overwritten in the async handler.
     (void)!!Result;
 
-    if (auto Err = this->template appendCallAsync<Func>(
+    if (Error Err = this->template appendCallAsync<Func>(
             [&](ResultType R) {
               Result = std::move(R);
               ReceivedResponse = true;
               return Error::success();
             },
             Args...)) {
-      detail::ResultTraits<typename Func::ReturnType>::consumeAbandoned(
-          std::move(Result));
-      return std::move(Err);
+      AltRetTraits::consumeAbandoned(std::move(Result));
+      return AltRetTraits::returnError(std::move(Err));
     }
 
-    if (auto Err = this->C.send()) {
-      detail::ResultTraits<typename Func::ReturnType>::consumeAbandoned(
-          std::move(Result));
-      return std::move(Err);
+    if (Error Err = this->C.send()) {
+      AltRetTraits::consumeAbandoned(std::move(Result));
+      return AltRetTraits::returnError(std::move(Err));
     }
 
     while (!ReceivedResponse) {
-      if (auto Err = this->handleOne()) {
-        detail::ResultTraits<typename Func::ReturnType>::consumeAbandoned(
-            std::move(Result));
-        return std::move(Err);
+      if (Error Err = this->handleOne()) {
+        AltRetTraits::consumeAbandoned(std::move(Result));
+        return AltRetTraits::returnError(std::move(Err));
       }
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98947.331881.patch
Type: text/x-patch
Size: 2752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210319/9c5843e0/attachment.bin>


More information about the llvm-commits mailing list