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

Stephen Kelly via cfe-dev cfe-dev at lists.llvm.org
Wed Oct 23 14:39:52 PDT 2019


On 21/10/2019 23:59, Alexander Lanin via cfe-dev wrote:
> 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/dependent
> -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 ?!

I suggest filing a bug in the tracker.

Thanks,

Stephen.




More information about the cfe-dev mailing list