Make diagnostics API safer to use

I received a crash report in DiagnosticManager that was caused by a
nullptr diagnostic having been added. The API allows passing in a null
unique_ptr, but all the methods are written assuming that all pointers
a dereferencable. This patch makes it impossible to add a null
diagnostic.

rdar://107633615

Differential Revision: https://reviews.llvm.org/D148823

GitOrigin-RevId: 737820e6d6e2df50f2ddf522a0db9ffb794ff749
2 files changed