[cfe-dev] Getting diagnostic information from clang
popizdeh at gmail.com
Wed Jun 3 05:13:06 PDT 2015
On Wed, Jun 3, 2015 at 10:00 PM, Manuel Klimek <klimek at google.com> wrote:
> On Wed, Jun 3, 2015 at 1:47 PM Nathan Wilson <nwilson20 at gmail.com> wrote:
>> On Jun 3, 2015 4:23 AM, "Manuel Klimek" <klimek at google.com> wrote:
>> > On Tue, Jun 2, 2015 at 9:25 PM Nate Wilson <nwilson20 at gmail.com> wrote:
>> >> Hi,
>> >> Is there any way to get information about where a diagnostic came from
>> in clang, e.g. the source from which the Diagnostic was constructed? For
>> example, when I try to assign to a member which doesn't exist in my
>> class/struct, I get:
>> >> error: no member named 'foo' in 'Bar'
>> >> Is there anyway for clang to tell me where this Diagnostic came from?
>> > Do you mean where in the Clang source it was generated?
>> Yes I do, but i imagine it's not possible. Correct? Sorry for the
>> ambiguity. I'm asking about this because I'd like to see how clang
>> determined what I'm doing is wrong by looking at a backtrace (or
>> something). Not just in this case, but for something a little more
>> complicated in general as well which won't get put into the AST.
> Generally, you search for the diagnostic in the clang source code.
> Diagnostics are in so-called tablegen files. Those will define the
> diagnostic text and a constant that's used in the code. Once you have that
> constant, you look for that constant in the clang source code, which then
> shows you under which circumstances that diagnostic is emitted.
Or you put a breakpoint inside DiagnosticBuilder::Emit and run clang with a
file that produces the error under a debugger.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev