[ORC] Return bootstrap map values via reference argument.
authorLang Hames <lhames@gmail.com>
Wed, 5 Apr 2023 01:07:44 +0000 (18:07 -0700)
committerLang Hames <lhames@gmail.com>
Wed, 5 Apr 2023 02:11:48 +0000 (19:11 -0700)
This simplifies checking of the result (it's just an Error, rather than an
optional<Expected<T>>), and allows T to be deduced rather than requiring that
it be specified.

llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h

index 49ae55b..a16a3b9 100644 (file)
@@ -227,18 +227,22 @@ public:
   ///
   ///
   template <typename T, typename SPSTagT>
-  std::optional<Expected<T>> getBootstrapMapValue(StringRef Key) const {
+  Error getBootstrapMapValue(StringRef Key, std::optional<T> &Val) const {
+    Val = std::nullopt;
+
     auto I = BootstrapMap.find(Key);
     if (I == BootstrapMap.end())
-      return std::nullopt;
+      return Error::success();
 
-    T Val;
+    T Tmp;
     shared::SPSInputBuffer IB(I->second.data(), I->second.size());
-    if (!shared::SPSArgList<SPSTagT>::deserialize(IB, Val))
+    if (!shared::SPSArgList<SPSTagT>::deserialize(IB, Tmp))
       return make_error<StringError>("Could not deserialize value for key " +
                                          Key,
                                      inconvertibleErrorCode());
-    return Val;
+
+    Val = std::move(Tmp);
+    return Error::success();
   }
 
   /// Returns the bootstrap symbol map.