Without this patch clangd silently process compiler instance prepare failure and only LSP errors "Invalid AST" could be found in logs.
E.g. the reason of the problem https://github.com/clangd/clangd/issues/734 is impossible to understand without verbose logs or with disabled background index.
This patch adds more information into logs to help understand the reason of such failures.
Logs without this patch:
E[...] Could not build a preamble for file test.cpp version 1
Logs with this patch:
E[...] Could not build a preamble for file test.cpp version 1: CreateTargetInfo() return null .. E[...] Failed to prepare a compiler instance: unknown target ABI 'lp64'
there's a bunch of logic that determines which diags we actually end up storing.
I'd suggest always calling take() and testing whether the result is empty, rather than using getNumErrors() which bypasses all our logic.
Luckily, we do (always?) end up storing the relevant diags here, assuming they're errors without a source location attached.
However I don't think we should hard-code that assumption here.