Changeset a35b458 in mainline for tools/checkers/clang.py


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/checkers/clang.py

    r3061bc1 ra35b458  
    4646def clang(root, job):
    4747        "Run Clang on a jobfile"
    48        
     48
    4949        inname = os.path.join(root, job)
    50        
     50
    5151        if (not os.path.isfile(inname)):
    5252                print("Unable to open %s" % inname)
    5353                print("Did you run \"make precheck\" on the source tree?")
    5454                return False
    55        
     55
    5656        inf = open(inname, "r")
    5757        records = inf.read().splitlines()
    5858        inf.close()
    59        
     59
    6060        for record in records:
    6161                arg = jobfile.parse_arg(record)
    6262                if (not arg):
    6363                        return False
    64                
     64
    6565                if (len(arg) < 6):
    6666                        print("Not enough jobfile record arguments")
    6767                        return False
    68                
     68
    6969                srcfname = arg[0]
    7070                tgtfname = arg[1]
     
    7373                base = arg[4]
    7474                options = arg[5].split()
    75                
     75
    7676                srcfqname = os.path.join(base, srcfname)
    7777                if (not os.path.isfile(srcfqname)):
    7878                        print("Source %s not found" % srcfqname)
    7979                        return False
    80                
     80
    8181                # Only C files are interesting for us
    8282                if (tool != "cc"):
    8383                        continue
    84                
     84
    8585                args = ['clang', '-Qunused-arguments', '--analyze',
    8686                        '-Xanalyzer', '-analyzer-opt-analyze-headers',
     
    8888                args.extend(options)
    8989                args.extend(['-o', tgtfname, srcfname])
    90                
     90
    9191                cwd = os.getcwd()
    9292                os.chdir(base)
    9393                retval = subprocess.Popen(args).wait()
    9494                os.chdir(cwd)
    95                
     95
    9696                if (retval != 0):
    9797                        return False
    98                
     98
    9999        return True
    100100
     
    103103                usage(sys.argv[0])
    104104                return
    105        
     105
    106106        rootdir = os.path.abspath(sys.argv[1])
    107107        config = os.path.join(rootdir, "HelenOS.config")
    108        
     108
    109109        if (not os.path.isfile(config)):
    110110                print("%s not found." % config)
    111111                print("Please specify the path to HelenOS build tree root as the first argument.")
    112112                return
    113        
     113
    114114        for job in jobs:
    115115                if (not clang(rootdir, job)):
     
    117117                        print("Failed job: %s" % job)
    118118                        return
    119        
     119
    120120        print
    121121        print("All jobs passed")
Note: See TracChangeset for help on using the changeset viewer.