This is an archive of the discontinued LLVM Phabricator instance.

Frontend: Simplify ownership model for clang's output streams.
ClosedPublic

Authored by pcc on Jun 20 2016, 3:16 PM.

Details

Summary

This changes the CompilerInstance::createOutputFile function to return
a std::unique_ptr<llvm::raw_ostream>, rather than an llvm::raw_ostream
implicitly owned by the CompilerInstance. This in most cases required that
I move ownership of the output stream to the relevant ASTConsumer.

The motivation for this change is to allow BackendConsumer to be a client
of interfaces such as D20268 which take ownership of the output stream.

Diff Detail

Event Timeline

pcc updated this revision to Diff 61312.Jun 20 2016, 3:16 PM
pcc retitled this revision from to Frontend: Simplify ownership model for clang's output streams..
pcc updated this object.
pcc added a reviewer: rsmith.
pcc added a subscriber: cfe-commits.
pcc updated this revision to Diff 61317.Jun 20 2016, 4:06 PM
  • Move EmitAssemblyHelper's pass managers into CreatePasses
rsmith accepted this revision.Jul 14 2016, 2:50 PM
rsmith edited edge metadata.

Yeah, I think this makes sense on balance, even though it does create a weird situation for the ASTPrinter case, where we don't really want to transfer ownership of the stream.

lib/CodeGen/CodeGenAction.cpp
705

I think return nullptr; would be clearer here.

lib/Frontend/CompilerInstance.cpp
599

Likewise.

This revision is now accepted and ready to land.Jul 14 2016, 2:50 PM
This revision was automatically updated to reflect the committed changes.