[cfe-dev] Ranges for diagnostics

Milian Wolff mail at milianw.de
Fri Jan 24 06:26:22 PST 2014


Hey there,

integrating clang into KDevelop we noticed that some diagnostics are lacking 
ranges which are in our opinion useful to have. Take this example:

~~~~~~~
class foobar {};
class foobar {};

void foo(double);
void foo(float);

int main()
{
  foo(0);

  "123" + 1;
  return 0;
}
~~~~~~~

If you compile this with clang++ you'll get:

~~~~~~~
test.cpp:2:7: error: redefinition of 'foobar'
class foobar {};
      ^
test.cpp:1:7: note: previous definition is here
class foobar {};
      ^
test.cpp:9:3: error: call to 'foo' is ambiguous
  foo(0);
  ^~~
test.cpp:4:6: note: candidate function
void foo(double);
     ^
test.cpp:5:6: note: candidate function
void foo(float);
     ^
test.cpp:11:9: warning: expression result unused [-Wunused-value]
  "123" + 1;
  ~~~~~ ^ ~
1 warning and 2 errors generated.
~~~~~~~

Is there a reason why some diagnostics only have a cursor pointing to the 
beginning of a token, while others are underlined properly?

For the child diagnostics pointing to the candidate function it's fine to only 
get a cursor. But for the redefinition of 'foobar' I'd expect a range. Similar 
for diagnostics related to not-found #include statements.

Would patches be accepted to add ranges to these diagnostics? Where would I 
have to look in the codebase?

Thanks
-- 
Milian Wolff
mail at milianw.de
http://milianw.de



More information about the cfe-dev mailing list