[cfe-dev] Using clang-tidy to fix compiler errors

Alexander Lanin via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 26 03:54:51 PDT 2019


Done, thanks.
https://bugs.llvm.org/show_bug.cgi?id=43816


-----Ursprüngliche Nachricht-----
Von: Jonas Toth <development at jonas-toth.eu> 
Gesendet: Donnerstag, 24. Oktober 2019 20:13
An: Alexander Lanin <alex at lanin.de>; cfe-dev at lists.llvm.org
Betreff: Re: [cfe-dev] Using clang-tidy to fix compiler errors

Hi Alexander,

clang-tidy runs the frontend first, so if the frontend detects errors it will report them as well.

There is a feature in the frontend itself that tries to fix bugs, e.g.
s"foo.method()"/"foo->method()" fixits can be emitted.

I think that is closer to what you want and might be a better place to request that feature.

Best Regards
Jonas

Am 22.10.19 um 00:59 schrieb Alexander Lanin via cfe-dev:
> Hello,
>
> clang-tidy can not only be used to improve code, but also to make it 
> work in the first place.
>
> Taking an example from
> https://github.com/llvm-mirror/clang/blob/master/test/SemaTemplate/dep
> endent
> -template-recover.cpp
>
>     template<typename T, typename U, int N>
>     struct X {
>       void f(T* t) {
>         t->f0<U>(); // expected-error{{use 'template' keyword to treat 'f0'
> as a dependent template name}}
>       }
>     };
>
> Clang-tidy is capable of fixing that error.
> However it's not possible to fix it without running any other checks?!
> e.g. this works fine: clang-tidy --checks="*" test.cpp -fix-errors but 
> it performs all sorts of other changes.
>
> The best approach seems to be to pick some checker that doesn't find 
> anything in order to fix only errors ?!
>
> Thanks,
> Alexander Lanin
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list