diff options
author | Ben Gamari <ben@smart-cactus.org> | 2015-12-04 13:25:26 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-04 17:31:55 +0100 |
commit | 901cab10609dc9795e57163834512373530fc4a5 (patch) | |
tree | e327950c0dce4d0c5aac3e5d49d18fc343150f9b /.arc-linters | |
parent | 020375d1e723339a95b86d0d3b8a8214b1cc144a (diff) | |
download | haskell-901cab10609dc9795e57163834512373530fc4a5.tar.gz |
lint: Add linter to catch uses of ASSERT macro that Clang dislikes
In particular Clang rejects uses of CPP macros where the argument list
is separated by a space from the macro name. Warn when we see ASSERT
used in this way.
Diffstat (limited to '.arc-linters')
-rwxr-xr-x | .arc-linters/check-cpp.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.arc-linters/check-cpp.py b/.arc-linters/check-cpp.py new file mode 100755 index 0000000000..3794ca2cee --- /dev/null +++ b/.arc-linters/check-cpp.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +# A linter to warn for ASSERT macros which are separated from their argument +# list by a space, which Clang's CPP barfs on + +import sys +import logging +import os +import json +import re + + +def setup_logging(): + logger = logging.getLogger() + hdlr = logging.FileHandler('linter.log', 'w') + logger.addHandler(hdlr) + logger.setLevel(logging.DEBUG) + return logger + +logger = setup_logging() +#logger.debug(sys.argv) + +path = sys.argv[1] +warnings = [] +if os.path.isfile(path): + with open(path) as f: + for lineno, line in enumerate(f): + if re.search('ASSERT \(', line) is not None: + warning = { + 'severity': 'warning', + 'message': 'CPP macros should not have a space between the macro name and their argument list', + 'line': lineno+1, + } + warnings.append(warning) + +logger.debug(warnings) +print json.dumps(warnings) |