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

Daniel Marjamäki via cfe-dev cfe-dev at lists.llvm.org
Fri Jan 29 04:03:55 PST 2016


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
E-mail:                 Daniel.Marjamaki at evidente.se

www.evidente.se
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 160129-indentation-clang.diff
Type: text/x-patch
Size: 3718 bytes
Desc: 160129-indentation-clang.diff
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160129/0221e7f2/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 160129-indentation-extra.diff
Type: text/x-patch
Size: 6601 bytes
Desc: 160129-indentation-extra.diff
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160129/0221e7f2/attachment-0001.bin>


More information about the cfe-dev mailing list