[llvm-commits] simple style checker

reed kotler rkotler at mips.com
Tue May 29 20:38:40 PDT 2012


On 05/29/2012 08:32 PM, David Blaikie wrote:
>
>
> On Tue, May 29, 2012 at 8:26 PM, reed kotler <rkotler at mips.com 
> <mailto:rkotler at mips.com>> wrote:
>
>     I made this simple python script to check for long lines and lines
>     with tabs.
>     If it will be useful, I will add more of the style rules to it.
>
>
> I can't speak for whether this is the sort of thing other people will 
> want added to the build, or the way it should be done, but if it is/if 
> you choose to use it yourself, it might be good to add "trailing 
> whitespace" as another thing to check for.
>
I was going to add trailing whitespace check tomorrow.

> [side note: to make such a check useful, we sort of would need to have 
> the codebase clean of violations to begin with (or the tool would have 
> to be smart enough to only flag based on revision control-reported 
> diffs) & some of the core developers are a bit averse to making such a 
> sweeping change as it would taint the revision history for "svn 
> blame"-like tasks (though I don't think this is actually true - since 
> both svn and git can annotate/blame with whitespace ignorance. Also, 
> one of the problems with making the codebase clean is that you can't 
> then keep it clean - until you have a tool like you've 
> written/provided here, so perhaps that'll provide extra motivation to 
> do a full clean]
both git and svn have apis for doing more. if it's useful i can expand 
there too.

Would be also cool to add to clang directly many things which require an 
AST in order to
properly do. Many visual rules that we have for continuation lines could 
be enforced for example
without the need for human beings to check those things.

Also, it would be possible to enforce global style conventions as well 
as to allow override of
them in c/c++ commants with a clang based tool.

I hate doing work that robots should do and lots of the style checking 
we do can be done by
robots.

>
>     Default is 80 character maximum lines and checking for tabs.
>
>     Usage: style_check.py arg1 arg2 ... argn [options]
>
>     Options:
>      -h, --help            show this help message and exit
>      --no-check-for-tabs   don't check for tabs
>      --no-check-line-length
>                            don't check line length
>      --max-line-length=MAXLINELENGTH
>                            specify maximum line length
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120529/1f0e5f9b/attachment.html>


More information about the llvm-commits mailing list