From f51d0729b010eefd231659e0ffb7f12ce9a9d3fc Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Mon, 17 Oct 2022 23:09:10 +0000 Subject: [PATCH 1/4] update clang-format Problem: .clang-format is out of sync with project style. This uses some newer options (clang 11) to get it a little closer. Originally proposed in flux-framework/flux-core#4694 --- .clang-format | 60 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/.clang-format b/.clang-format index 21f2150afcec..94e841ecba3e 100644 --- a/.clang-format +++ b/.clang-format @@ -1,13 +1,17 @@ BasedOnStyle : google SpaceBeforeParens : Always IndentWidth : 4 -BreakBeforeBraces : Linux +BreakBeforeBraces : Custom +BraceWrapping : + BeforeElse : true + AfterFunction : true UseTab: Never AllowShortIfStatementsOnASingleLine : false ConstructorInitializerAllOnOneLineOrOnePerLine : true AllowShortFunctionsOnASingleLine : false AllowShortLoopsOnASingleLine : false BinPackParameters : false +BinPackArguments : false AllowAllParametersOfDeclarationOnNextLine : false AlignTrailingComments : true ColumnLimit : 88 @@ -17,9 +21,59 @@ PenaltyBreakBeforeFirstCallParameter : 10000000 PenaltyReturnTypeOnItsOwnLine : 65000 PenaltyBreakString : 10 +# preserve formatting of arguments to pack/unpack functions +# found by running: rg --only-matching --no-filename --no-line-number '(flux|json)(_[^ ,()]+)?_(un)?pack' | sort -u +WhitespaceSensitiveMacros : +- flux_conf_unpack +- flux_event_pack +- flux_event_publish_pack +- flux_event_unpack +- flux_job_result_get_unpack +- flux_jobspec1_attr_pack +- flux_jobspec1_attr_unpack +- flux_jobspec_info_unpack +- flux_jobtap_event_post_pack +- flux_kvs_lookup_get_unpack +- flux_kvs_lookup_unpack +- flux_kvs_txn_pack +- flux_lookup_get_unpack +- flux_mrpc_pack +- flux_msg_pack +- flux_msg_unpack +- flux_plugin_arg_pack +- flux_plugin_arg_unpack +- flux_plugin_args_unpack +- flux_plugin_conf_unpack +- flux_request_unpack +- flux_respond_pack +- flux_rpc_get_unpack +- flux_rpc_pack +- flux_shell_getopt_unpack +- flux_shell_info_unpack +- flux_shell_jobspec_info_unpack +- flux_shell_rank_info_unpack +- flux_shell_rpc_pack +- flux_shell_setopt_pack +- flux_shell_setopt_unpack +- flux_shell_task_info_unpack +- json_pack +- json_unpack + +# treat foreach macros as for loops +ForEachMacros : +- json_array_foreach +- json_object_foreach + # These improve formatting results but require clang 3.6/7 or higher +SortIncludes : false BreakBeforeBinaryOperators : NonAssignment -AlignAfterOpenBracket: true -BinPackArguments : false +AlignAfterOpenBracket: Align AlignOperands : true BreakBeforeTernaryOperators : true +AllowAllParametersOfDeclarationOnNextLine : false +SpaceBeforeSquareBrackets: false +IndentPPDirectives: None + +# +# vi:tabstop=4 shiftwidth=4 expandtab ft=yaml +# From 0bf2a7a50fd961d635a9df02306e16898fb6b1b2 Mon Sep 17 00:00:00 2001 From: Jim Garlick Date: Thu, 14 Nov 2024 09:13:34 -0800 Subject: [PATCH 2/4] clang-format: limit columns to 80 chars Problem: the column limit of 88 chars is inconsistent with current project practices. Set the limit to 80 chars. --- .clang-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 94e841ecba3e..740525959962 100644 --- a/.clang-format +++ b/.clang-format @@ -14,7 +14,7 @@ BinPackParameters : false BinPackArguments : false AllowAllParametersOfDeclarationOnNextLine : false AlignTrailingComments : true -ColumnLimit : 88 +ColumnLimit : 80 # do not put all arguments on one line unless it's the same line as the call PenaltyBreakBeforeFirstCallParameter : 10000000 From 8db230fa111cdb41b562244ff796bbd3b6bcec28 Mon Sep 17 00:00:00 2001 From: Jim Garlick Date: Thu, 14 Nov 2024 09:32:47 -0800 Subject: [PATCH 3/4] clang-format: drop ancient clang version ref Problem: a comment about requiring clang-3.6 or clang-7 is probably no longer useful at this point as those releases are now old. Drop comment. --- .clang-format | 1 - 1 file changed, 1 deletion(-) diff --git a/.clang-format b/.clang-format index 740525959962..d7c35517b6a5 100644 --- a/.clang-format +++ b/.clang-format @@ -64,7 +64,6 @@ ForEachMacros : - json_array_foreach - json_object_foreach -# These improve formatting results but require clang 3.6/7 or higher SortIncludes : false BreakBeforeBinaryOperators : NonAssignment AlignAfterOpenBracket: Align From f5484bb1b931e18e5d5a6aab8deaecf9e8ba6a96 Mon Sep 17 00:00:00 2001 From: Jim Garlick Date: Thu, 14 Nov 2024 09:35:01 -0800 Subject: [PATCH 4/4] clang-format: add AlignConsecutiveMacros Problem: the current clang-format removes alignment of the values of consecutive macro assignments, which makes things less readable. clang-20 adds AlignConsecutiveMacros. Add it so we'll be ready. --- .clang-format | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.clang-format b/.clang-format index d7c35517b6a5..b8837ebb527b 100644 --- a/.clang-format +++ b/.clang-format @@ -73,6 +73,9 @@ AllowAllParametersOfDeclarationOnNextLine : false SpaceBeforeSquareBrackets: false IndentPPDirectives: None +# will appear in clang-20 +AlignConsecutiveMacros: true + # # vi:tabstop=4 shiftwidth=4 expandtab ft=yaml #