================
@@ -98,8 +98,11 @@ APINotesManager::loadAPINotes(FileEntryRef APINotesFile) {
// Load the binary form we just compiled.
auto Reader = APINotesReader::Create(std::move(CompiledBuffer),
SwiftVersion);
- assert(Reader && "Could not load the API notes we just generated?");
- return Reader;
+ if (!Reader) {
+ llvm::consumeError(Reader.takeError());
+ return nullptr;
+ }
+ return std::move(Reader.get());
----------------
mafeguimaraes wrote:
Hi @Xazax-hun,
I actually tried removing it, but it turns out the `std::move` is required here.
Since `Reader` is an `llvm::Expected<std::unique_ptr<APINotesReader>>`,
`Reader.get()` returns a reference to the underlying `unique_ptr`. Because we
are returning it by value from the function and `unique_ptr` cannot be copied,
we have to explicitly use `std::move()` to transfer ownership out of the
`Expected` wrapper.
I've kept the `std::move` in `APINotesManager.cpp`, but I removed the redundant
ones in `APINotesReader.cpp` as well as the stray semicolon you pointed out.
Pushed the updates! Thanks for the review!
https://github.com/llvm/llvm-project/pull/183812
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits