Re: [llvm-dev] how to access certain kinds of diagnostics from libclang API?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] how to access certain kinds of diagnostics from libclang API?

suyash singh via cfe-dev
Adding cfe-dev.

~Craig


On Sat, Feb 15, 2020 at 10:07 PM Andrew Kelley via llvm-dev <[hidden email]> wrote:
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 =
unit->stored_diag_begin(),
             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:
https://github.com/ziglang/zig/issues/4455
See specifically the discussion starting here
https://github.com/ziglang/zig/issues/3210#issuecomment-586085463 which
may point to a bug or flaw in libclang's API.

Thanks for the help,
Andrew

_______________________________________________
LLVM Developers mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev