- SM.AddNewSourceBuffer(F, SMLoc());
-
- // If we are parsing into an existing module, do it.
- if (M)
- return LLParser(F, SM, Err, M).Run() ? 0 : M;
-
- // Otherwise create a new module.
- OwningPtr<Module> M2(new Module(F->getBufferIdentifier(), Context));
- if (LLParser(F, SM, Err, M2.get()).Run())
- return 0;
- return M2.take();
+ MemoryBuffer *Buf = F.get();
+ SM.AddNewSourceBuffer(F.release(), SMLoc());
+
+ std::unique_ptr<Module> M =
+ make_unique<Module>(Buf->getBufferIdentifier(), Context);
+ if (LLParser(Buf->getBuffer(), SM, Err, M.get()).Run())
+ return nullptr;
+ return std::move(M);