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
F132205942: D26978.id78823.diff
Tue, Oct 14, 6:56 PM
F132205940: D26978.id78842.diff
Tue, Oct 14, 6:56 PM
F132205939: D26978.id.diff
Tue, Oct 14, 6:56 PM
Unknown Object (File)
Tue, Oct 14, 7:45 AM
Unknown Object (File)
Tue, Oct 7, 8:49 AM
Unknown Object (File)
Sun, Oct 5, 9:46 AM
Unknown Object (File)
Sun, Sep 21, 2:56 AM
Unknown Object (File)
Sep 9 2025, 7:23 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.