-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove deprecated Clang-Format style options and setting BreakAfterReturnType to ExceptShortType #5034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Pull request was converted to draft
drebelsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some general notes
| SplitEmptyRecord: true | ||
| SplitEmptyNamespace: true | ||
| BreakAfterJavaFieldAnnotations: false | ||
| BreakAfterReturnType: ExceptShortType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there not fewer changes with BreakAfterReturnType: AllDefinitions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought ExceptShortType was more readable than AllDefinitions. Though AllDefinitions is closer to what we had before. I will leave it for the team to decide on which one they prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would vote for never breaking after the function return type. I don't think it adds any readability, but it definitely does make search for the functions harder. I sometimes search for something like int foo and the line break makes this impossible to do without involving regexes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a None option which sounds like would never break but its marked as deprecated in https://releases.llvm.org/20.1.0/tools/clang/docs/ClangFormatStyleOptions.html
We should do a team poll to vote on the available options: Automatic, ExceptShortType, All, TopLevel, AllDefinitions, TopLevelDefinitions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a difference between ExceptShortType and Automatic,
==========
BreakAfterReturnType: ExceptShortType
==========
void Peer::maybeExecuteInBackground(
std::string const& jobName, std::function<void(std::shared_ptr<Peer>)> f)
{
==========
BreakAfterReturnType: Automatic
==========
void
Peer::maybeExecuteInBackground(std::string const& jobName,
std::function<void(std::shared_ptr<Peer>)> f)
{
| ObjCBlockIndentWidth: 2 | ||
| ObjCSpaceAfterProperty: false | ||
| ObjCSpaceBeforeProtocolList: true | ||
| PackConstructorInitializers: NextLine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe CurrentLine corresponds to what we already have
ConstructorInitializerAllOnOneLineOrOnePerLine (
Boolean) clang-format 3.7 ¶
This option is deprecated. SeeCurrentLineofPackConstructorInitializers
PCIS_CurrentLine(in configuration:CurrentLine) Put all constructor initializers on the current line if they fit. Otherwise, put each one on its own line.
PCIS_NextLine(in configuration:NextLine) Same asPCIS_CurrentLineexcept that if all constructor initializers do not fit on the current line, try to fit them on the next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NextLine seemed a bit more readable but we can check with team's preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a difference between NextLine and CurrentLine,
==========
PackConstructorInitializers: NextLine
==========
CatchupConfiguration::CatchupConfiguration(LedgerNumHashPair ledgerHashPair,
uint32_t count, Mode mode)
: mCount{count}, mLedgerHashPair{ledgerHashPair}, mMode{mode}
{
}
==========
PackConstructorInitializers: CurrentLine
==========
CatchupConfiguration::CatchupConfiguration(LedgerNumHashPair ledgerHashPair,
uint32_t count, Mode mode)
: mCount{count}
, mLedgerHashPair{ledgerHashPair}
, mMode{mode}
{
}
c71b552 to
4dfbdb8
Compare
4dfbdb8 to
afcf477
Compare
what
Remove deprecated clang-format20 style options and improve readability.
One more change here is to set
BreakAfterReturnType: ExceptShortTypewhich puts the return type in the same line as the definition with break after return type based on PenaltyReturnTypeOnItsOwnLine setting.Example:why
NOTE: Counter proposal in #5061