From 27929f1fd6e928ba536784e82ec67f7d474725c6 Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Wed, 10 Aug 2016 10:49:55 -0400 Subject: [PATCH] Allow space before C++11 attributes Modify rule checking for spaces before `[`s to ignore C++11 attributes, which usually should have spaces. This fixes an incorrect warning on code like: #define ABIEXPORT [[gnu::visibility("default")]] --- cpplint/cpplint.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpplint/cpplint.py b/cpplint/cpplint.py index f4b1113..e264152 100755 --- a/cpplint/cpplint.py +++ b/cpplint/cpplint.py @@ -3188,9 +3188,10 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): # get rid of comments and strings line = clean_lines.elided[linenum] - # You shouldn't have spaces before your brackets, except maybe after - # 'delete []' or 'return []() {};' - if Search(r'\w\s+\[', line) and not Search(r'(?:delete|return)\s+\[', line): + # You shouldn't have spaces before your brackets, except for C++11 attributes + # or maybe after 'delete []' or 'return []() {};' + if (Search(r'\w\s+\[(?!\[)', line) and + not Search(r'(?:delete|return)\s+\[', line)): error(filename, linenum, 'whitespace/braces', 5, 'Extra space before [')