[llvm-dev] how to access certain kinds of diagnostics from libclang API? (original) (raw)

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Sat Feb 15 23:11:05 PST 2020


Adding cfe-dev.

~Craig

On Sat, Feb 15, 2020 at 10:07 PM Andrew Kelley via llvm-dev < llvm-dev at lists.llvm.org> wrote:

Here's an example diagnostic:

andy at 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 = astunit ? astunit : errunit.release(); ZigList errors = {}; for (clang::ASTUnit::storeddiagiterator it = unit->storeddiagbegin(), itend = unit->storeddiagend(); it != itend; ++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 llvm-dev at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200215/62cbdc79/attachment.html>



More information about the llvm-dev mailing list