[Docs][ORCv2] GetForCurrentProcess now returns an Expected<std::unique_ptr>. NFC
authorJon Roelofs <jonathan_roelofs@apple.com>
Tue, 5 Oct 2021 15:00:03 +0000 (08:00 -0700)
committerJon Roelofs <jonathan_roelofs@apple.com>
Fri, 10 Dec 2021 22:21:28 +0000 (14:21 -0800)
Differential Revision: https://reviews.llvm.org/D111158

llvm/docs/ORCv2.rst

index c5bc189..ec372f5 100644 (file)
@@ -730,8 +730,11 @@ For example, to load the whole interface of a runtime library:
     const DataLayout &DL = getDataLayout();
     auto &JD = ES.createJITDylib("main");
 
-    JD.addGenerator(DynamicLibrarySearchGenerator::Load("/path/to/lib"
-                                                        DL.getGlobalPrefix()));
+    if (auto DLSGOrErr = DynamicLibrarySearchGenerator::Load("/path/to/lib"
+                                                             DL.getGlobalPrefix()))
+      JD.addGenerator(std::move(*DLSGOrErr);
+    else
+      return DLSGOrErr.takeError();
 
     // IR added to JD can now link against all symbols exported by the library
     // at '/path/to/lib'.
@@ -753,10 +756,9 @@ Or, to expose an allowed set of symbols from the main process:
 
     // Use GetForCurrentProcess with a predicate function that checks the
     // allowed list.
-    JD.addGenerator(
-      DynamicLibrarySearchGenerator::GetForCurrentProcess(
-        DL.getGlobalPrefix(),
-        [&](const SymbolStringPtr &S) { return AllowList.count(S); }));
+    JD.addGenerator(cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
+          DL.getGlobalPrefix(),
+          [&](const SymbolStringPtr &S) { return AllowList.count(S); })));
 
     // IR added to JD can now link against any symbols exported by the process
     // and contained in the list.