ReferenceDependenciesEmitter::emit in ReferenceDependencies.cpp writes the output directly to the specified path, instead of writing to a temporary file and then "atomically" renaming it into place. This can lead to truncated files if the compiler job is killed at exactly the wrong time.
Since ReferenceDependenciesEmitter::emit was implemented, a helper function was added to do exactly this kind of atomic rename: atomicallyWritingToFile in swift/Basic/FileSystem.h. This can replace the ReferenceDependenciesEmitter::openFile helper completely.
[split off from rdar://problem/25095498, which is mostly covered by SR-8706]