<div dir="ltr">Adding cfe-dev.<div><br clear="all"><div><div dir="ltr" data-smartmail="gmail_signature">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Feb 15, 2020 at 10:07 PM Andrew Kelley via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Here's an example diagnostic:<br>
<br>
andy@ark ~/tmp> clang -c test.c -march=bogus<br>
error: unknown target CPU 'bogus'<br>
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom,<br>
silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7,<br>
westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,<br>
core-avx2, broadwell, skylake, skylake-avx512, skx, cannonlake,<br>
icelake-client, icelake-server, knl, knm, k8, athlon64, athlon-fx,<br>
opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona,<br>
btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64<br>
<br>
<br>
When using clang::ASTUnit::LoadFromCommandLine, both the clang::ASTUnit*<br>
return value and the clang::ASTUnit* ErrAST out parameter are NULL. This<br>
makes it impossible to access diagnostics with<br>
<br>
if (diags->hasErrorOccurred()) {<br>
clang::ASTUnit *unit = ast_unit ? ast_unit : err_unit.release();<br>
ZigList<Stage2ErrorMsg> errors = {};<br>
<br>
for (clang::ASTUnit::stored_diag_iterator it =<br>
unit->stored_diag_begin(),<br>
it_end = unit->stored_diag_end(); it != it_end; ++it)<br>
<br>
<br>
whereas for normal C compilation errors, this does work. Is there some<br>
other way to access the diagnostics?<br>
<br>
Here's a downstream issue report with more context:<br>
<a href="https://github.com/ziglang/zig/issues/4455" rel="noreferrer" target="_blank">https://github.com/ziglang/zig/issues/4455</a><br>
See specifically the discussion starting here<br>
<a href="https://github.com/ziglang/zig/issues/3210#issuecomment-586085463" rel="noreferrer" target="_blank">https://github.com/ziglang/zig/issues/3210#issuecomment-586085463</a> which<br>
may point to a bug or flaw in libclang's API.<br>
<br>
Thanks for the help,<br>
Andrew<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>