mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
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 (cherry picked from commit 26470f9ccb354ff2f6d098f831271a1833701b28 from https://github.com/google/styleguide) Bug: 1287491 Change-Id: Ib61a75853e19316b1bacf8dc56528f94c17e30a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3389431 Reviewed-by: Anthony Polito <apolito@google.com> Commit-Queue: Victor Boivie <boivie@google.com>
This commit is contained in:
6
cpplint.py
vendored
6
cpplint.py
vendored
@@ -3162,10 +3162,10 @@ 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 []() {};', or in the case of c++ attributes
|
||||
# like 'class [[clang::lto_visibility_public]] MyClass'.
|
||||
# 'delete []', 'return []() {};', 'auto [abc, ...] = ...;' or in the case of
|
||||
# c++ attributes like 'class [[clang::lto_visibility_public]] MyClass'.
|
||||
if (Search(r'\w\s+\[', line)
|
||||
and not Search(r'(?:delete|return)\s+\[', line)
|
||||
and not Search(r'(?:auto&?|delete|return)\s+\[', line)
|
||||
and not Search(r'\s+\[\[', line)):
|
||||
error(filename, linenum, 'whitespace/braces', 5,
|
||||
'Extra space before [')
|
||||
|
||||
Reference in New Issue
Block a user