Diagnostics: Simplify provider registeration and make it safer

Waqar Ahmed requested to merge work/diag-rework into master

Instead of manual register/unregister calls, rely on RAII. A provider gets registered on construction and unregistered on destruction.

On unregistering, clear the diagnostics from the provider getting destroyed to avoid stale pointers in diagnostics.

Also, ensure destructing is fast by clearing everything manually before disabling plugins.

This fixes a crash after the build plugin merge.

Merge request reports