Commit 901cab10 authored by Ben Gamari's avatar Ben Gamari 🐢
Browse files

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.
parent 020375d1
#!/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')
return logger
logger = setup_logging()
path = sys.argv[1]
warnings = []
if os.path.isfile(path):
with open(path) as f:
for lineno, line in enumerate(f):
if'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,
print json.dumps(warnings)
......@@ -56,6 +56,11 @@
"check-binaries": {
"type": "external-json",
"external-json.script": "python .arc-linters/"
"bad-assert-clang-cpp": {
"type": "external-json",
"include": ["(\\.(l?hs|x|y\\.pp)(\\.in)?$)"],
"external-json.script": "python .arc-linters/"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment