This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Support function and overloaded operator SpacesInParensOption
Needs ReviewPublic

Authored by gedare on Jul 26 2023, 12:57 PM.



This change separates function calls, declarations, definitions, and
overloaded operators from SpacesInParensOptions.Other to allow control
over each independently.

Fixes Github Issue #55428.

Depends on D155529

Event Timeline

gedare created this revision.Jul 26 2023, 12:57 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptJul 26 2023, 12:57 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
gedare requested review of this revision.Jul 26 2023, 12:57 PM
gedare edited the summary of this revision. (Show Details)Jul 26 2023, 12:58 PM

You need some tests to show that the new options really apply like intended.

gedare updated this revision to Diff 544544.Jul 26 2023, 3:55 PM

Add tests and correct function call detection.


Why change this?


Should here be a space?

gedare added inline comments.Aug 1 2023, 10:43 AM

The original test is incomplete/ambiguous. It's either a declaration missing a semicolon, or it's the start of a definition. I made it a definition.


That's controlled by space in empty parens.

owenpan added inline comments.Nov 9 2023, 4:23 PM

Consider wrapping this in a function or lambda. Not sure if it would simply the logic with the parens being handled separately:

if ( {
} else if ( {

No else after return.


Then can you also add a declaration?

gedare updated this revision to Diff 558245.Tue, Dec 19, 6:15 PM

Fix for review comments, refactor logic to lambdas

gedare updated this revision to Diff 558246.Tue, Dec 19, 6:26 PM

add missing test case for function prototype

gedare marked 3 inline comments as done.Tue, Dec 19, 6:28 PM