Closed Bug 1497779 Opened 6 years ago Closed 6 years ago

clang-format is over-eager to break after '(' - Configure clang-format for Mozilla style of argument lists in function calls

Categories

(Developer Infrastructure :: Lint and Formatting, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: karlt, Unassigned)

References

(Blocks 1 open bug)

Details

Since clang-format has become available, I've started seeing function call argument styles that look like AlignAfterOpenBracket: AlwaysBreak. This is not Mozilla style (unless perhaps when there is no other option due to very long function names). Although not explicitly specified, the format I almost always saw previously was AlignAfterOpenBracket: Align. See the GetFlavorData() arguments, for example, at line 315 of https://phabricator.services.mozilla.com/D8074?id=22428#change-GEIhCAaWkyvA Expected: rv = dataProvider->GetFlavorData(this, aFlavor, getter_AddRefs(dataBytes), &len); Actual: rv = dataProvider->GetFlavorData( this, aFlavor, getter_AddRefs(dataBytes), &len); The actual is very different from line 398. Actual and tolerable: ​ mFormatConv->Convert(aFlavor, aData, aDataLen, data.GetFlavor().get(), getter_AddRefs(ConvertedData), &ConvertedLen); Expected: mFormatConv->Convert(aFlavor, aData, aDataLen, data.GetFlavor().get(), ​ getter_AddRefs(ConvertedData), &ConvertedLen); The expected formats above are what I get with BasedOnStyle: Mozilla at http://cf.monofraps.net/, so I don't know what is causing the actual formats.
I wouldn't consider this to be a bug, but more of the desired behavior. clang-format tries to fit all parameters onto a single line and if it fails than it brakes. The implementation was done here: https://reviews.llvm.org/D14104
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
The implementation just adds another option. Can you point me at the discussion that led to changing Mozilla's style, please?
Flags: needinfo?(bpostelnicu)
afaik, we didn't have a discussion on this and we didn't change this behavior with the Mozilla coding style in clang-format. So, I guess we are using the default option in clang-format :)
Flags: needinfo?(bpostelnicu)
My assumption was that bug 1188202 would use clang-format to "reformat everything to Mozilla style", in which case this bug would track one feature required in setting up clang-format to do that. https://bugzilla.mozilla.org/show_bug.cgi?id=1188202#c0 at least seems to support that interpretation. Are you implying that there has been a change in direction for bug 1188202 to instead reformat everything to clang-format's default style for BasedOnStyle: Mozilla, even though that is not Mozilla style?
Flags: needinfo?(sledru)
Yeah, I have been experimenting, I will share more information with the finding when ready!
Flags: needinfo?(sledru)
Thanks for taking a look. I assume we agree it is helpful to keep this open while still under investigation.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
I think other parts of the codebase use single-line-per-argument, so yeah, this bug probably requires some discussion to figure out what is Mozilla style... :)
Component: Source Code Analysis → Lint and Formatting
This will be wontfix based on the "update" in https://phabricator.services.mozilla.com/D12221?id=36525
Status: REOPENED → RESOLVED
Closed: 6 years ago6 years ago
Resolution: --- → WONTFIX
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.