[RFC/PATCH] Fix-it hints

Manuel López-Ibáñez lopezibanez@gmail.com
Sat Sep 27 16:20:00 GMT 2014


On 25 September 2014 11:34, Dodji Seketeli <dodji@redhat.com> wrote:
>> When the caret line is disabled with -fno-diagnostics-show-caret, the
>> fix-it hint is printed as:
>>
>> gcc/testsuite/g++.dg/template/crash83.C:5:21: error: an explicit
>> specialization must be preceded by 'template <>'
>> gcc/testsuite/g++.dg/template/crash83.C:5:21: fixit: template<>
>>
>> The latter form may allow an IDE (such as emacs) to automatically
>> apply the fix.
>
> Nice.  Is the "fixit:" prefix used by other compilers too?  Or are there
> variations from compiler to compiler?

Clang seems to do:

fix-it:"t.cpp":{7:25-7:29}:"Gamma"

http://clang.llvm.org/docs/UsersManual.html#cmdoption-fdiagnostics-parseable-fixits

where the location is a half-open range (insertions are marked as
{7:25-7:25}). However, this is not the standard GNU format for ranges,
and last time I tried to update that (to support multiple ranges) RMS
was not in favour of adding the Clang flavour. Quoting the filename
also does not seem to be what GNU mandates. No idea why they use {}
around the location range and not sure if they support just 7:25,
which seems nicer.

Also, I don't know who are the consumers of Clang's format that GCC
will be interested in supporting.

No idea about other compilers that support fix-it hints.

Comments?


>
>> Currently, fix-it hints are limited to insertions at one single
>> location, whereas Clang allows insertions, deletions, and replacements
>> at arbitrary location ranges.
>
> Do you have example of each of these kinds of fix-it hints? (deletions,
> replacement at location ranges).  I think it'd be nice to have an idea
> of what needs to be done, even if we are not doing it "in extenso" right
> now.

I think in the case of deletions, they just underline the text to be deleted:

typename3.C:3:7: warning: duplicate 'const' declaration specifier
[-Wduplicate-decl-specifier]
const const long long long int x;
      ^~~~~~
fix-it:"typename3.C":{3:7-3:13}:""

In the case of replacements, there does not seem to be any visible
difference with an insertion:

typename3.C:4:33: note: change this ',' to a ';' to call 'f'
const const long long long int x,
                                ^
                                ;
fix-it:"typename3.C":{4:33-4:34}:";"

Cheers,

Manuel.



More information about the Gcc-patches mailing list