aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Light <allight@google.com>2019-11-19 09:52:07 -0800
committerMark Mentovai <mark@chromium.org>2019-11-19 12:52:07 -0500
commit26470f9ccb354ff2f6d098f831271a1833701b28 (patch)
tree9ce0170937b12deb22d70cd8684dc9e96ebda6a7
parent83a9e8d7ca3d47239cb0a7bf532de791e6df3ba6 (diff)
downloadgoogle-styleguide-26470f9ccb354ff2f6d098f831271a1833701b28.tar.gz
Add support for c++17 tuple destructuring (#487)
C++17 adds support for tuple destructuring. This allow one to write code such as: ``` std::pair<int, int> span = getSpan(); auto [start, end] = span; // Use start as span.first and end as span.second ``` This makes cpplint recognize and allow a space before the '[' in this situation. This is a purposeful divergence from the internal version where the entire whitespace/braces category was removed. It was decided to leave the checks in since this is sometimes used without other formatting tools. Test: manual
-rwxr-xr-xcpplint/cpplint.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/cpplint/cpplint.py b/cpplint/cpplint.py
index 65baa6c..6c839b4 100755
--- a/cpplint/cpplint.py
+++ b/cpplint/cpplint.py
@@ -3283,8 +3283,8 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
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):
+ # 'delete []', 'return []() {};', or 'auto [abc, ...] = ...;'.
+ if Search(r'\w\s+\[', line) and not Search(r'(?:auto&?|delete|return)\s+\[', line):
error(filename, linenum, 'whitespace/braces', 5,
'Extra space before [')