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

Alexander Lanin via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 21 15:59:35 PDT 2019


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 ?!

Thanks,
Alexander Lanin





More information about the cfe-dev mailing list