Skip to content

[clang-format]: The new 19 breaks pointer type alignment in macros #104415

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

Closed
oerdnj opened this issue Aug 15, 2024 · 1 comment
Closed

[clang-format]: The new 19 breaks pointer type alignment in macros #104415

oerdnj opened this issue Aug 15, 2024 · 1 comment
Labels
clang-format duplicate Resolved as duplicate

Comments

@oerdnj
Copy link

oerdnj commented Aug 15, 2024

After upgrading from clang-format-18 to clang-format-19, the following has happened:

diff --git a/lib/dns/hmac_link.c b/lib/dns/hmac_link.c
index 4361fb73bf..8de785e804 100644
--- a/lib/dns/hmac_link.c
+++ b/lib/dns/hmac_link.c
@@ -53,22 +53,22 @@
 #define ISC_MD_sha512 ISC_MD_SHA512

 #define hmac_register_algorithm(alg)                                           \
-       static isc_result_t hmac##alg##_createctx(dst_key_t *key,              \
-                                                 dst_context_t *dctx) {       \
+       static isc_result_t hmac##alg##_createctx(dst_key_t * key,             \
+                                                 dst_context_t * dctx) {      \
                return (hmac_createctx(ISC_MD_##alg, key, dctx));              \
        }                                                                      \
-       static void hmac##alg##_destroyctx(dst_context_t *dctx) {              \
+       static void hmac##alg##_destroyctx(dst_context_t * dctx) {             \
                hmac_destroyctx(dctx);                                         \
        }                                                                      \
-       static isc_result_t hmac##alg##_adddata(dst_context_t *dctx,           \
+       static isc_result_t hmac##alg##_adddata(dst_context_t * dctx,          \
                                                const isc_region_t *data) {    \
                return (hmac_adddata(dctx, data));                             \
        }                                                                      \
-       static isc_result_t hmac##alg##_sign(dst_context_t *dctx,              \
-                                            isc_buffer_t *sig) {              \
+       static isc_result_t hmac##alg##_sign(dst_context_t * dctx,             \
+                                            isc_buffer_t * sig) {             \
                return (hmac_sign(dctx, sig));                                 \
        }                                                                      \
-       static isc_result_t hmac##alg##_verify(dst_context_t *dctx,            \
+       static isc_result_t hmac##alg##_verify(dst_context_t * dctx,           \
                                               const isc_region_t *sig) {      \
                return (hmac_verify(dctx, sig));                               \
        }                                                                      \

And the configuration we use for formatting C files is:

BasedOnStyle: LLVM
IndentWidth: 8
UseTab: Always
BreakBeforeBraces: Custom
BraceWrapping:
  AfterClass:      false
  AfterEnum:       false
  AfterStruct:     false
  AfterUnion:      false
  AfterControlStatement: MultiLine
  AfterFunction:   false # should also be MultiLine, but not yet supported
  AfterExternBlock: false
  BeforeElse:      false
  BeforeWhile:     false
  IndentBraces:    false
  SplitEmptyFunction: true
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AlwaysBreakAfterReturnType: All
Cpp11BracedListStyle: false
ColumnLimit: 80
AlignAfterOpenBracket: Align
AlignConsecutiveBitFields: true
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
AlignEscapedNewlines: Left
DerivePointerAlignment: false
PointerAlignment: Right
PointerBindsToType: false
IncludeBlocks: Regroup
IncludeCategories:
  - Regex:           '^<(urcu\.h|urcu/urcu-|urcu-)'
    Priority:        2
  - Regex:           '^<urcu/'
    Priority:        3
  - Regex:           '^<isc/'
    Priority:        5
  - Regex:           '^<(pk11|pkcs11)/'
    Priority:        10
  - Regex:           '^<dns/'
    Priority:        15
  - Regex:           '^<dst/'
    Priority:        20
  - Regex:           '^<isccc/'
    Priority:        25
  - Regex:           '^<isccfg/'
    Priority:        30
  - Regex:           '^<ns/'
    Priority:        35
  - Regex:           '^<irs/'
    Priority:        40
  - Regex:           '^<(dig|named|rndc|confgen|dlz)/'
    Priority:        50
  - Regex:           '^<dlz_'
    Priority:        55
  - Regex:           '^".*"'
    Priority:        99
  - Regex:           '^<tests/'
    Priority:        100
  - Regex:           '<openssl/'
    Priority:        4
  - Regex:           '<(mysql|protobuf-c)/'
    Priority:        4
  - Regex:           '.*'
    Priority:        0
IndentExternBlock: NoIndent
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
PenaltyBreakAssignment: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 80
PenaltyExcessCharacter: 100
Standard: Cpp11
ContinuationIndentWidth: 8
ForEachMacros: [ 'cds_lfs_for_each', 'cds_lfs_for_each_safe', 'cds_list_for_each_entry_safe', 'ISC_LIST_FOREACH', 'ISC_LIST_FOREACH_SAFE', 'ISC_LIST_FOREACH_REV', 'ISC_LIST_FOREACH_REV_SAFE' ]

It feels like PointerAlignment: Right is not applied, or the code is misunderstood for some reason here.

@owenca owenca added the duplicate Resolved as duplicate label Aug 15, 2024
@owenca
Copy link
Contributor

owenca commented Aug 15, 2024

Duplicate of #100304, fixed in 19 rc2.

@owenca owenca closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-format duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

2 participants