Repository navigation
Do not parse function parameters from continuations of multi-line expressions - #78221
Open
TheRealAlexxx wants to merge 1 commit into
Open
TheRealAlexxx wants to merge 1 commit into
TheRealAlexxx wants to merge 1 commit into
Conversation
…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.
Collaborator
|
EWS run on current version of this PR (hash 0c8f8c8) Details |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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
🛠 playstation