Skip to content

Commit

Permalink
Style checker shouldn't complain about requires (MyConcept)
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=274324
rdar://128284081

Reviewed by Jonathan Bedard.

Right now the style checker will complain about an extra space before the
arguments to a function call when you do `requires (MyConcept)`. We should
treat spaces after `requires` the same way we treat spaces after other keywords.

* Tools/Scripts/webkitpy/style/checkers/cpp.py:
(check_spacing_for_function_call):
* Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py:
(WebKitStyleTest.test_spacing):

Canonical link: https://commits.webkit.org/278922@main
  • Loading branch information
kmiller68 committed May 17, 2024
1 parent a60827c commit 479314b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Tools/Scripts/webkitpy/style/checkers/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ def check_spacing_for_function_call(line, line_number, file_state, error):
# " (something)[something]"
# Note that we assume the contents of [] to be short enough that
# they'll never need to wrap.
if ( # Ignore control structures.
not search(r'\b(if|for|while|switch|return|new|delete)\b', function_call)
if ( # Ignore control structures / c++20 concept constraints.
not search(r'\b(if|for|while|switch|return|new|delete|requires)\b', function_call)
# Ignore lambda functions
and not regex_for_lambdas_and_blocks(function_call, line_number, file_state, error)
# Ignore pointers/references to functions.
Expand Down
11 changes: 11 additions & 0 deletions Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5000,6 +5000,17 @@ def test_spacing(self):
['Extra space after ( in function call [whitespace/parens] [4]',
'Extra space before ) [whitespace/parens] [2]'])

# Ignore concept constraints.
self.assert_multi_line_lint(
'template<typename T>\n'
'requires (MyConcept<T>)\n'
'int f(T a);',
'')

self.assert_multi_line_lint(
'int foo(int a, int b) requires (MyConcept<T>) { return a + b; }',
'')

# Ignore spacing inside four char code.
self.assert_multi_line_lint(
'CTFontTableTag os2Tag = \'OS/2\';',
Expand Down

0 comments on commit 479314b

Please sign in to comment.