Page MenuHomeFreeBSD

clang-format: Avoid breaking after the opening paren of function definitions
ClosedPublic

Authored by arichardson on Oct 27 2020, 4:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jul 5, 9:13 PM
Unknown Object (File)
Sat, Jul 4, 9:07 AM
Unknown Object (File)
Fri, Jul 3, 3:26 AM
Unknown Object (File)
Thu, Jul 2, 10:14 PM
Unknown Object (File)
Thu, Jul 2, 3:06 PM
Unknown Object (File)
Jun 17 2026, 4:12 AM
Unknown Object (File)
Jun 17 2026, 4:11 AM
Unknown Object (File)
Jun 15 2026, 2:38 PM
Subscribers

Details

Summary

This depends on https://reviews.llvm.org/D90246, but once that has landed
clang-format will no longer format code like this:

int
myfunction(
    int param1, int param2, int param2)
{
   ...
}

and instead create the following:

int
myfunction(int param1, int param2,
    int param2)
{
   ...
}

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34421
Build 31525: arc lint + arc unit

Event Timeline

arichardson created this revision.

LGTM. You could go ahead and commit the changes that work with current clang-format separately, if you're waiting on upstream for the AllowAllArgumentsOnNextLine.

Do you know if there is a mechanism to get the type and qualifiers on an independent line before the function name? That jumps out as a missing piece in both examples. Thanks!

This revision is now accepted and ready to land.Oct 27 2020, 4:56 PM
In D26978#601758, @cem wrote:

LGTM. You could go ahead and commit the changes that work with current clang-format separately, if you're waiting on upstream for the AllowAllArgumentsOnNextLine.

Do you know if there is a mechanism to get the type and qualifiers on an independent line before the function name? That jumps out as a missing piece in both examples. Thanks!

That was a bug in my commit description, AlwaysBreakAfterReturnType: TopLevelDefinitions will ensure that the return type is on a separate line.