[CachedDiagnostics] Optimize in case no diagnostics is emitted
When no diagnostics is emitted from the compilation, just use an empty
object as cached diagnostics. That is an optimization for storage to
avoid emitting some supporting file to recreate source manager when not
needed, also save a bit time from emitting YAML file.
rdar://128426132