aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/clint.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/clint.py b/src/clint.py
index 0cf89ad12f..80e4c4ac39 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -219,6 +219,7 @@ _ERROR_CATEGORIES = [
'whitespace/tab',
'whitespace/todo',
'whitespace/line_continuation',
+ 'whitespace/cast',
]
# The default state of the category filter. This is overrided by the --filter=
@@ -2513,6 +2514,15 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
'Must not indent preprocessor directives, use 1-space indent '
'after the hash')
+ cast_line = re.sub(r'^# *define +\w+\([^)]*\)', '', line)
+ match = Search(r'\((?:const )?(?:struct )?[a-zA-Z_]\w*(?: *\*(?:const)?)*\)'
+ r' +'
+ r'-?(?:\*+|&)?(?:\w+|\+\+|--|\()', cast_line)
+ if match and line[0] == ' ':
+ error(filename, linenum, 'whitespace/cast', 2,
+ 'Should leave no spaces after a cast: {!r}'.format(
+ match.group(0)))
+
def GetPreviousNonBlankLine(clean_lines, linenum):
"""Return the most recent non-blank line and its line number.