This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] BreakBeforeBinaryOperations and AlignAfterOpenBracket conflict, bug 30304
ClosedPublic

Authored by daphnediane on Sep 17 2016, 8:22 PM.

Details

Reviewers
djasper
Summary

Fix for the formatting options combination of BreakBeforeBinaryOperators: All, AlignAfterOpenBracket: AlwaysBreak not handling long templates correctly. This patch allows a break after an opening left parenthesis, TemplateOpener, or bracket when both options are enabled.

Diff Detail

Event Timeline

daphnediane retitled this revision from to [clang-format] BreakBeforeBinaryOperations and AlignAfterOpenBracket conflict, bug 30304.
daphnediane updated this object.
daphnediane added a reviewer: djasper.
daphnediane added a subscriber: cfe-commits.
djasper edited edge metadata.Sep 17 2016, 10:48 PM

I think, this is the wrong fix. Instead, a

|| (Left.is(TT_TemplateOpener) && !Right.is(TT_TemplateCloser))

should be added to the last return statement of this function.

Also, could you please add a test in unittests/Format/FormatTest.cpp.

I think, this is the wrong fix. Instead, a

|| (Left.is(TT_TemplateOpener) && !Right.is(TT_TemplateCloser))

should be added to the last return statement of this function.

Also, could you please add a test in unittests/Format/FormatTest.cpp.

Trying that on my code after I finish rebasing and rebuilding, will also look into adding test to FormatTest.

daphnediane edited edge metadata.

Adds test case, changes to suggested fix allowing break after template opener that is not immediately followed by template closer.

djasper accepted this revision.Sep 18 2016, 10:59 PM
djasper edited edge metadata.

Looks good. Thank you!

This revision is now accepted and ready to land.Sep 18 2016, 10:59 PM

Looks good. Thank you!

Thanks. Are there additional steps I need to get it commited or do I just wait for a commiter to notice?

Looks like patch was not committed.

ping.

FYI I have found some additional similar cases when AlignConsecutiveDeclarations is also true, that I'll see if I can document/test case etc. at some point.

ping. I've been using this for a long time and still seems to apply to cleanly and works, though the line numbers have shifted a little since I generated the previous diff.

djasper closed this revision.Feb 6 2017, 3:07 AM

Submitted as r294179. Sorry I missed this before.