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)
Wed, Dec 3, 11:45 AM
Unknown Object (File)
Mon, Dec 1, 11:48 AM
Unknown Object (File)
Thu, Nov 20, 8:06 PM
Unknown Object (File)
Thu, Nov 20, 7:53 PM
Unknown Object (File)
Thu, Nov 20, 7:53 PM
Unknown Object (File)
Thu, Nov 20, 7:44 PM
Unknown Object (File)
Nov 16 2025, 9:49 AM
Unknown Object (File)
Oct 18 2025, 11:32 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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.