how to access certain kinds of diagnostics from libclang API?

Here's an example diagnostic:

andy@ark ~/tmp> clang -c test.c -march=bogus
error: unknown target CPU 'bogus'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom,
      silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7,
      westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,
      core-avx2, broadwell, skylake, skylake-avx512, skx, cannonlake,
      icelake-client, icelake-server, knl, knm, k8, athlon64, athlon-fx,
      opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona,
      btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64

When using clang::ASTUnit::LoadFromCommandLine, both the clang::ASTUnit*
return value and the clang::ASTUnit* ErrAST out parameter are NULL. This
makes it impossible to access diagnostics with

    if (diags->hasErrorOccurred()) {
        clang::ASTUnit *unit = ast_unit ? ast_unit : err_unit.release();
        ZigList<Stage2ErrorMsg> errors = {};

        for (clang::ASTUnit::stored_diag_iterator it =
             it_end = unit->stored_diag_end(); it != it_end; ++it)

whereas for normal C compilation errors, this does work. Is there some
other way to access the diagnostics?

Here's a downstream issue report with more context:
See specifically the discussion starting here which
may point to a bug or flaw in libclang's API.

Thanks for the help,

Adding cfe-dev.