diff options
author | Paul Hoad <mydeveloperday@gmail.com> | 2019-03-23 14:37:58 +0000 |
---|---|---|
committer | Paul Hoad <mydeveloperday@gmail.com> | 2019-03-23 14:37:58 +0000 |
commit | c6deae452197631a4530a50df266cdf5063b601e (patch) | |
tree | f9815ece2ce465ca648961c316fc9436ba9cc35e /clang/lib/Format/Format.cpp | |
parent | a87ba1c59cb9f3381216cfe4e1a6a1e5425225ca (diff) | |
download | bcm5719-llvm-c6deae452197631a4530a50df266cdf5063b601e.tar.gz bcm5719-llvm-c6deae452197631a4530a50df266cdf5063b601e.zip |
Clang-format: add finer-grained options for putting all arguments on one line
Summary:
Add two new options,
AllowAllArgumentsOnNextLine and
AllowAllConstructorInitializersOnNextLine. These mirror the existing
AllowAllParametersOfDeclarationOnNextLine and allow me to support an
internal style guide where I work. I think this would be generally
useful, some have asked for it on stackoverflow:
https://stackoverflow.com/questions/30057534/clang-format-binpackarguments-not-working-as-expected
https://stackoverflow.com/questions/38635106/clang-format-how-to-prevent-all-function-arguments-on-next-line
Reviewers: djasper, krasimir, MyDeveloperDay
Reviewed By: MyDeveloperDay
Subscribers: jkorous, MyDeveloperDay, aol-nnov, lebedev.ri, uohcsemaj, cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D40988
Patch By: russellmcc (Russell McClellan)
llvm-svn: 356834
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 5fe118a7161..2d1adb58e4a 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -335,6 +335,10 @@ template <> struct MappingTraits<FormatStyle> { IO.mapOptional("AlignEscapedNewlines", Style.AlignEscapedNewlines); IO.mapOptional("AlignOperands", Style.AlignOperands); IO.mapOptional("AlignTrailingComments", Style.AlignTrailingComments); + IO.mapOptional("AllowAllArgumentsOnNextLine", + Style.AllowAllArgumentsOnNextLine); + IO.mapOptional("AllowAllConstructorInitializersOnNextLine", + Style.AllowAllConstructorInitializersOnNextLine); IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine", Style.AllowAllParametersOfDeclarationOnNextLine); IO.mapOptional("AllowShortBlocksOnASingleLine", @@ -351,6 +355,7 @@ template <> struct MappingTraits<FormatStyle> { Style.AlwaysBreakAfterDefinitionReturnType); IO.mapOptional("AlwaysBreakAfterReturnType", Style.AlwaysBreakAfterReturnType); + // If AlwaysBreakAfterDefinitionReturnType was specified but // AlwaysBreakAfterReturnType was not, initialize the latter from the // former for backwards compatibility. @@ -641,6 +646,8 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.AlignTrailingComments = true; LLVMStyle.AlignConsecutiveAssignments = false; LLVMStyle.AlignConsecutiveDeclarations = false; + LLVMStyle.AllowAllArgumentsOnNextLine = true; + LLVMStyle.AllowAllConstructorInitializersOnNextLine = true; LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true; LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All; LLVMStyle.AllowShortBlocksOnASingleLine = false; |