Skip to content

Do not parse function parameters from continuations of multi-line expressions - #78221

Open
TheRealAlexxx wants to merge 1 commit into
WebKit:mainfrom
TheRealAlexxx:style-skip-continuation-function-detection
Open

TheRealAlexxx wants to merge 1 commit into
WebKit:mainfrom
TheRealAlexxx:style-skip-continuation-function-detection

Conversation

@TheRealAlexxx

@TheRealAlexxx TheRealAlexxx commented Oct 25, 2026 •

Copy link
Copy Markdown

Do not parse function parameters from continuations of multi-line expressions

check-webkit-style mistakes an argument of a multi-line call for a function declaration when the argument starts a line and looks like a declaration, such as std::max(CGRectGetMinX(contentViewFrame) - minX, 0) inside an Objective-C method. detect_functions treats the line as a function prototype ending at the statement's terminating ';', parameter_list then reads "minX" as a parameter name whose "type" contains CGRectGetMinX, and readability/parameter_name reports that the parameter name adds no information. This fires on real code, for example the CGRectMake calls in Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm from https://bugs.webkit.org/show_bug.cgi?id=270703.

Skip function detection for a line whose previous line ends with ',' or '('. Such a line continues a multi-line expression, such as an argument or initializer list, so it cannot start a function declaration or definition.

A new test covers an argument following a ',' and one directly following the '(' of a multi-line call, and confirms that genuine declarations are still checked.

PYTHONPATH=Tools/Scripts python3 -m unittest webkitpy.style.checkers.cpp_unittest
python3 Tools/Scripts/check-webkit-style Tools/Scripts/webkitpy/style/checkers/cpp.py Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

A single-line statement that is itself syntactically identical to a declaration (for example a discarded std::max call on its own line) can still be parsed as one. That ambiguity needs semantic information and is out of scope.
0c8f8c8

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-cmake-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 webkitpy ✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-cmake-debug
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
✅ 🧪 mac-cmake-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2   🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

…ressions

https://bugs.webkit.org/show_bug.cgi?id=270703

Reviewed by NOBODY (OOPS!).

check-webkit-style mistakes an argument of a multi-line call for a function declaration when the argument starts a line and looks like a declaration, such as std::max<CGFloat>(CGRectGetMinX(contentViewFrame) - minX, 0) inside an Objective-C method. detect_functions treats the line as a function prototype ending at the statement's terminating ';', parameter_list then reads "minX" as a parameter name whose "type" contains CGRectGetMinX, and readability/parameter_name reports that the parameter name adds no information. This fires on real code, for example the CGRectMake calls in Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm from https://bugs.webkit.org/show_bug.cgi?id=270703.

Skip function detection for a line whose previous line ends with ',' or '('. Such a line continues a multi-line expression, such as an argument or initializer list, so it cannot start a function declaration or definition.

A new test covers an argument following a ',' and one directly following the '(' of a multi-line call, and confirms that genuine declarations are still checked.

```
PYTHONPATH=Tools/Scripts python3 -m unittest webkitpy.style.checkers.cpp_unittest
python3 Tools/Scripts/check-webkit-style Tools/Scripts/webkitpy/style/checkers/cpp.py Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
```

A single-line statement that is itself syntactically identical to a declaration (for example a discarded std::max call on its own line) can still be parsed as one. That ambiguity needs semantic information and is out of scope.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants