This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix documentation for AllowAllParametersOfDeclarationOnNextLine
ClosedPublic

Authored by LuMa on Sep 6 2017, 5:24 AM.

Details

Reviewers
krasimir
djasper
Summary

Current description of flag AllowAllParametersOfDeclarationOnNextLine in Clang-Format Style Options guide suggests that it is possible to format function declaration, which fits in a single line (what is not supported in current clang-format version). Also example is not reproducible and makes no sense.
I have added valid example and have stressed that flag applies only if declaration doesn't fit in a single line.

Diff Detail

Event Timeline

LuMa created this revision.Sep 6 2017, 5:24 AM
LuMa updated this revision to Diff 113995.Sep 6 2017, 6:08 AM
LuMa updated this revision to Diff 113998.Sep 6 2017, 6:15 AM
djasper edited edge metadata.Sep 6 2017, 6:30 AM

Note that these changes need to be made to the corresponding comments in include/clang/Format/Format.h and then this file is auto-generated with docs/tools/dump_format_style.py.

docs/ClangFormatStyleOptions.rst
276

Much better phrasing, thank you.

280

I think this sentence does not add value.

281

I think we should keep the example as short as it was previously (it is reproducible with a very short column limit), but you are right that the example was broken. So I suggest making this:

void myFunction(
    int a, int b, int c);

vs.

void myFunction(
    int a,
    int b,
    int c);
LuMa updated this revision to Diff 114151.Sep 7 2017, 4:45 AM

I moved changes to correct file.
When it comes to example, it doesn't seem to work with short function.

Example:

.clang-format:

ColumnLimit: 35
UseTab:          Never
BinPackParameters: false
AllowAllParametersOfDeclarationOnNextLine: true

For input:

void myFunction(int a, int b, int c);

output is:

void myFunction(int a,
                int b,
                int c);

although it should be:

void myFunction(
    int a, int b, int c);

I don't know if it's bug or expected behavior. Maybe it's result of other flags or penalties. But i think an example should work for default values, so i suggest using the longer one.

djasper accepted this revision.Sep 7 2017, 4:58 AM

Also run dump_format_style.py and keep the changed .rst file in this change.

Otherwise looks good.

This revision is now accepted and ready to land.Sep 7 2017, 4:58 AM
LuMa updated this revision to Diff 114161.Sep 7 2017, 5:28 AM
LuMa added a comment.Sep 7 2017, 5:34 AM

I cannot commit the patch myself.

djasper accepted this revision.Sep 7 2017, 6:47 AM

Submitted as r312721. Thank you.

LuMa closed this revision.Sep 8 2017, 2:20 AM

Thank you.