[llvm-commits] update of patch for simple style checker

reed kotler rkotler at mips.com
Wed May 30 17:02:34 PDT 2012


I can update mine to address portability concerns.

I intend to add more including optional recursive search, checking 
headers, include file order, etc.

When I exhaust what's simple to do in python I'll move to a clang based 
plugin.
I know there is another project going on in Clang that is related to 
this but It's very ambitious
and I'd like to start with just being able to enforce all the llvm rules 
without having to read the
code looking for picky things.

I have some other llvm workflow related tools I'm contemplating.

On 05/30/2012 04:52 PM, Eric Christopher wrote:
> Here's the one I use, it's a bit more portable:
>
> #!/usr/bin/env python
>
> import sys, fileinput, subprocess
>
> err=0
> cols=80
>
> # Be careful to support Python 2.4, 2.6, and 3.x here!
> config_proc=subprocess.Popen([ "git", "config", "core.autocrlf" ],
>      stdout=subprocess.PIPE)
> result=config_proc.communicate()[0]
>
> true="true".encode('utf8')
> autocrlf=result.strip() == true if result is not None else False
>
> def report_err(s):
>      global err
>      print("%s:%d: %s" % (fileinput.filename(), fileinput.filelineno(), s))
>      err=1
>
> for line in fileinput.input(openhook=fileinput.hook_encoded("utf-8")):
>      if line.find('\t') != -1 and fileinput.filename().find("Makefile") == -1:
>          report_err("tab character")
>
>      if not autocrlf and line.find('\r') != -1:
>          report_err("CR character")
>
>      line_len = len(line)-2 if autocrlf else len(line)-1
>      if line_len>  cols:
>          report_err("line longer than %d chars" % cols)
>
>
> sys.exit(err)
>
> example: tidy.py *
> or
> find . -type f -print | xargs tidy.py
>
> -eric
>
> On May 30, 2012, at 4:40 PM, reed kotler<rkotler at mips.com>  wrote:
>
>> Added check for whitespace at the end of a line.
>>
>> File is new file for utils
>> ubuntu-rkotler:~/llvm_conventions>  python style_check.py --help
>> 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 [default 80]
>>   --no-check-whitespace-at-eol
>>                         don't check for whitespace at the end of a line
>>
>>
>>
>> <style_check_patch2.txt>_______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list