<div dir="ltr">Ah, if the contents of example.c are simply:<div><br></div><div>main() {}<br></div><div><br></div><div>And then I run:</div><div><br></div><div>clang example.c<br><br>I get:<br><br><div>example.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]</div>
<div>main() {}</div><div>^~~~</div><div>1 warning generated.<br><br>So there are ranges, just not for as many diagnostic types as I would expect. Would patches to add more range information be welcome?</div><br></div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 22, 2014 at 3:26 PM, Michael Bolin <span dir="ltr"><<a href="mailto:bolinfest@gmail.com" target="_blank">bolinfest@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hmm, I just tried running `clang -fdiagnostics-print-source-range-info example.c` and I got:<br><br><div>
example.c:5:3: error: use of undeclared identifier 'retur'</div><div>   retur 0;</div><div>   ^</div>
<div>1 error generated.</div><br>So this has a caret identifying the source location, but there aren't any tildes showing the source range, as I would expect. From <a href="http://clang.llvm.org/diagnostics.html" target="_blank">http://clang.llvm.org/diagnostics.html</a>, I would expect most diagnostics to include a range.<div>

<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 22, 2014 at 3:19 PM, Michael Bolin <span dir="ltr"><<a href="mailto:bolinfest@gmail.com" target="_blank">bolinfest@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I am now calling clang_getDiagnosticNumRanges() from C and still get zero for the number of ranges. Here is my C code (main.c) that creates a CXTranslationUnit for a malformed file and dumps its diagnostics:<br>


<br><a href="https://gist.github.com/bolinfest/11196200" target="_blank">https://gist.github.com/bolinfest/11196200</a><br><div><br></div><div>Here is the malformed file, example.c, that I am using for testing:<br><br><a href="https://gist.github.com/bolinfest/11196225" target="_blank">https://gist.github.com/bolinfest/11196225</a><br>


<br>And here is the output when I run `./main.o example.c`:</div><div><br></div><div><a href="https://gist.github.com/bolinfest/11196241" target="_blank">https://gist.github.com/bolinfest/11196241</a><br><br>As you can see, I can get pretty much everything for the diagnostic (source location, category id, category name), but no source location. I would expect to get a source range associated that identifies the misspelled keyword. Any ideas? Are my expectations just wrong?</div>


<div><br></div><div>Thank you,</div><div>Michael</div><div><br></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 18, 2014 at 1:06 PM, Michael Bolin <span dir="ltr"><<a href="mailto:bolinfest@gmail.com" target="_blank">bolinfest@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I am using the Python wrapper for libclang (cindex.py), and none of my diagnostics have any SourceRanges associated with them. When I create the translation unit, I even make sure that -fprint-source-range-info and -fdiagnostics-print-source-range-info are passed as arguments (though I don't know if that is strictly necessary).<div>



<br></div><div>AFAICT, I believe that the Python calling and configuration code is correct:</div><div><br></div><div>  conf.lib.clang_getDiagnosticNumRanges(self.diag)</div><div><br></div><div><div>  ("clang_getDiagnosticNumRanges",</div>



<div>   [Diagnostic],</div><div>   c_uint),</div></div><div><br></div><div>Are there any suggestions on how to debug this besides writing against libclang directly in C to make sure everything is working there?</div><div>



<br></div><div>Thank you,</div><div>Michael</div><div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>