Delete the output streams coming from
CompilerInstance::createOutputFile() and friends once writes are
finished. Concretely, replacing OS->flush() with OS = nullptr in:
- PrecompiledPreambleAction::setEmittedPreamblePCH()
- ExtractAPIAction::EndSourceFileAction()
- cc1_main()'s support for -ftime-trace`
This fixes theoretical bugs related to proxy streams, which may have
cleanups to run in their destructor. E.g., buffer_ostream supports
pwrite() by holding all content in a buffer until destruction time.
This also protects against some logic bugs, triggering a null
dereference on a latter attempt to write to the stream.
No tests, since in practice these particular code paths don't seem to
ever use buffer_ostream; you need to be writing a binary file to a
pipe (such as stdout) to hit it; but I have some other patches in the
works that add some safety, crashing if the stream hasn't been
destructed by the time the CompilerInstance is told to keep the output
file.
Nit: OS.reset(nullptr); makes it more obvious this is a unique_ptr and not a raw pointer. Same for the other cases as well.