[cfe-dev] Any known issues with clang_getDiagnosticNumRanges() in libclang?

Michael Bolin bolinfest at gmail.com
Tue Apr 22 15:26:34 PDT 2014


Hmm, I just tried running `clang -fdiagnostics-print-source-range-info
example.c` and I got:

example.c:5:3: error: use of undeclared identifier 'retur'
   retur 0;
   ^
1 error generated.

So this has a caret identifying the source location, but there aren't any
tildes showing the source range, as I would expect. From
http://clang.llvm.org/diagnostics.html, I would expect most diagnostics to
include a range.



On Tue, Apr 22, 2014 at 3:19 PM, Michael Bolin <bolinfest at gmail.com> wrote:

> 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:
>
> https://gist.github.com/bolinfest/11196200
>
> Here is the malformed file, example.c, that I am using for testing:
>
> https://gist.github.com/bolinfest/11196225
>
> And here is the output when I run `./main.o example.c`:
>
> https://gist.github.com/bolinfest/11196241
>
> 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?
>
> Thank you,
> Michael
>
>
>
> On Fri, Apr 18, 2014 at 1:06 PM, Michael Bolin <bolinfest at gmail.com>wrote:
>
>> 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).
>>
>> AFAICT, I believe that the Python calling and configuration code is
>> correct:
>>
>>   conf.lib.clang_getDiagnosticNumRanges(self.diag)
>>
>>   ("clang_getDiagnosticNumRanges",
>>    [Diagnostic],
>>    c_uint),
>>
>> Are there any suggestions on how to debug this besides writing against
>> libclang directly in C to make sure everything is working there?
>>
>> Thank you,
>> Michael
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140422/7b79d3ad/attachment.html>


More information about the cfe-dev mailing list