- /// deserialization of function bodies. If successful, this takes ownership
- /// of 'buffer. On error, this *does not* take ownership of Buffer.
- ErrorOr<Module *> getLazyBitcodeModule(MemoryBuffer *Buffer,
- LLVMContext &Context);
-
- /// getStreamedBitcodeModule - Read the header of the specified stream
- /// and prepare for lazy deserialization and streaming of function bodies.
- /// On error, this returns null, and fills in *ErrMsg with an error
- /// description if ErrMsg is non-null.
- Module *getStreamedBitcodeModule(const std::string &name,
- DataStreamer *streamer,
- LLVMContext &Context,
- std::string *ErrMsg = nullptr);
+ /// deserialization of function bodies. If ShouldLazyLoadMetadata is true,
+ /// lazily load metadata as well. If successful, this moves Buffer. On
+ /// error, this *does not* move Buffer.
+ ErrorOr<std::unique_ptr<Module>>
+ getLazyBitcodeModule(std::unique_ptr<MemoryBuffer> &&Buffer,
+ LLVMContext &Context,
+ DiagnosticHandlerFunction DiagnosticHandler = nullptr,
+ bool ShouldLazyLoadMetadata = false);
+
+ /// Read the header of the specified stream and prepare for lazy
+ /// deserialization and streaming of function bodies.
+ ErrorOr<std::unique_ptr<Module>> getStreamedBitcodeModule(
+ StringRef Name, std::unique_ptr<DataStreamer> Streamer,
+ LLVMContext &Context,
+ DiagnosticHandlerFunction DiagnosticHandler = nullptr);