<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 24, 2014 at 10:12 AM, Milian Wolff <span dir="ltr"><<a href="mailto:mail@milianw.de" target="_blank">mail@milianw.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Friday 24 January 2014 08:25:26 David Blaikie wrote:<br>
> On Fri, Jan 24, 2014 at 6:26 AM, Milian Wolff <<a href="mailto:mail@milianw.de">mail@milianw.de</a>> wrote:<br>
> > Hey there,<br>
> ><br>
> > integrating clang into KDevelop we noticed that some diagnostics are<br>
> > lacking<br>
> > ranges which are in our opinion useful to have. Take this example:<br>
> ><br>
> > ~~~~~~~<br>
> > class foobar {};<br>
> > class foobar {};<br>
> ><br>
> > void foo(double);<br>
> > void foo(float);<br>
> ><br>
> > int main()<br>
> > {<br>
> ><br>
> >   foo(0);<br>
> ><br>
> >   "123" + 1;<br>
> >   return 0;<br>
> ><br>
> > }<br>
> > ~~~~~~~<br>
> ><br>
> > If you compile this with clang++ you'll get:<br>
> ><br>
> > ~~~~~~~<br>
> > test.cpp:2:7: error: redefinition of 'foobar'<br>
> > class foobar {};<br>
> ><br>
> >       ^<br>
> ><br>
> > test.cpp:1:7: note: previous definition is here<br>
> > class foobar {};<br>
> ><br>
> >       ^<br>
> ><br>
> > test.cpp:9:3: error: call to 'foo' is ambiguous<br>
> ><br>
> >   foo(0);<br>
> >   ^~~<br>
> ><br>
> > test.cpp:4:6: note: candidate function<br>
> > void foo(double);<br>
> ><br>
> >      ^<br>
> ><br>
> > test.cpp:5:6: note: candidate function<br>
> > void foo(float);<br>
> ><br>
> >      ^<br>
> ><br>
> > test.cpp:11:9: warning: expression result unused [-Wunused-value]<br>
> ><br>
> >   "123" + 1;<br>
> >   ~~~~~ ^ ~<br>
> ><br>
> > 1 warning and 2 errors generated.<br>
> > ~~~~~~~<br>
> ><br>
> > Is there a reason why some diagnostics only have a cursor pointing to the<br>
> > beginning of a token, while others are underlined properly?<br>
><br>
> This isn't a question of "properly" or not - you'll notice that the things<br>
> underlined could actually, in other contexts, be more than one token (eg:<br>
> (1 + 2) + "foo" the LHS is (1 + 2) is underlined, and in "foo(0)" it's<br>
> possible that 'foo' could be a more complex expression involving a fully<br>
> qualified function name, decltype, etc). I suppose arguably the 'foobar'<br>
> example could involve a fully qualified (nested) name too.<br>
<br>
</div></div>Right, properly is the wrong word.<br>
<br>
To rephrase: I propose to add ranges to "top-level" diagnostics. In the<br>
example above, that would mean adding a range to the "redifinition of<br>
'foobar'.<br>
<div class="im"><br>
> > For the child diagnostics pointing to the candidate function it's fine to<br>
> > only<br>
> > get a cursor. But for the redefinition of 'foobar' I'd expect a range.<br>
> > Similar<br>
> > for diagnostics related to not-found #include statements.<br>
> ><br>
> > Would patches be accepted to add ranges to these diagnostics? Where would<br>
> > I<br>
> > have to look in the codebase?<br>
><br>
> If we decide that's the right direction (that all diagnostic locations<br>
> should highlight the entire token, rather than just use a caret to point to<br>
> the start) we should probably just fix the diagnostic printer, rather than<br>
> fixing every diagnostic call site.<br>
<br>
</div>Me as a consumer of the clang-c API also need to have that information. Thus<br>
we'll need to store the ranges into the diagnostics anyways - no? The printers<br>
should then just work™.<br>
<br>
Or how would you implement this purely on the diagnostic printer side? How do<br>
you get the token at a cursor position with the C-API? We tried<br>
clang_Cursor_getSpellingNameRange but didn't get good results.<br></blockquote><div><br></div><div>I haven't used the C API, but if there's a limitation there that you can't get the range of a token - we should just fix that.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
Thanks<br>
--<br>
Milian Wolff<br>
<a href="mailto:mail@milianw.de">mail@milianw.de</a><br>
<a href="http://milianw.de" target="_blank">http://milianw.de</a><br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div></div>