[cfe-dev] [RFC][clang-tidy] indentation readability check

Daniel Marjamäki via cfe-dev cfe-dev at lists.llvm.org
Fri Jan 29 09:58:12 PST 2016


Hello!

> To my mind this functionality belongs in clang-format rather than clang-tidy.

Yes I should have clarified this.

This check will not complement / undo clang-format. Imho you can use both clang-format and this check, this check will be just redundant then.

It's easy to think that everybody uses a formatter, for instance clang-format, because it's so much better than formatting the code manually.

I work as a contractor and have been to a few companies. I have not seen a company yet that uses a formatting tool, they rather update formatting manually. I have tried to suggest using clang-format or some other such tool.. but there is hard resistance against it.

Best regards,
Daniel Marjamäki
..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile:                 +46 (0)709 12 42 62
E-mail:                 Daniel.Marjamaki at evidente.se

www.evidente.se

________________________________________
Från: jonathanbcoe at gmail.com [jonathanbcoe at gmail.com] för Jonathan Coe [jbcoe at me.com]
Skickat: den 29 januari 2016 15:41
Till: Daniel Marjamäki
Ämne: Re: [cfe-dev] [RFC][clang-tidy] indentation readability check

To my mind this functionality belongs in clang-format rather than clang-tidy.

What would the check do that clang-format would not undo?

regards,

Jon

On 29 January 2016 at 12:03, Daniel Marjamäki <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> wrote:

Hello!

I am working on a new indentation check for clang-tidy.

The idea is to write a generic check that will work no matter if you prefer spaces or tabs or where you like to put { etc. It will just check for some common idioms.

Currently it is designed to warn if there is negative indentation below a if:

    void warn1(int x)
    {
          if (x==0)
       {          // CHECK-MESSAGES: :[[@LINE]]:4: warning: unexpected negative indentation below if [readability-indentation]
        }
    }

I am testing this experimental check right now on various projects. So far it has found 129 warnings in 354 debian projects. I've looked at a few warnings and think it looks good overall. I saw no project that consistently use negative indentations below if.

My work-in-progress code can be seen in the attached patches.

I also have seen that there was related work before to create a Windent flag:
https://llvm.org/bugs/show_bug.cgi?id=18938

Best regards,
Daniel Marjamäki

..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile:                 +46 (0)709 12 42 62<tel:%2B46%20%280%29709%2012%2042%2062>
E-mail:                 Daniel.Marjamaki at evidente.se<mailto:Daniel.Marjamaki at evidente.se>

www.evidente.se<http://www.evidente.se>
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list