`misc`: update `.clang-format`
Makes the following changes to .clang-format to ensure consistent formatting in the codebase:
+ PointerAlignment: Left
+ QualifierAlignment: Custom
+ QualifierOrder: [static, inline, const, type]
+ ReferenceAlignment: Left
Thereby enforcing west const, pointer/reference alignment to the type, and a consistent qualifier order for all .cc/.h files.
As noted by https://clang.llvm.org/docs/ClangFormatStyleOptions.html#qualifieralignment, extra care should be taken when reviewing formatting performed with this option.
Backports Required
- [X] none - not a bug fix
- [ ] none - this is a backport
- [ ] none - issue does not exist in previous branches
- [ ] none - papercut/not impactful enough to backport
- [ ] v24.2.x
- [ ] v24.1.x
- [ ] v23.3.x
Release Notes
- none
Force push to:
- Correct improper syntax from
concept const auto&->const concept auto&insecurity/jwt.h
ducktape was retried in https://buildkite.com/redpanda/redpanda/builds/53606#0191944b-2084-47d1-af16-6f4cb6199042
ducktape was retried in https://buildkite.com/redpanda/redpanda/builds/54401#0191e724-5e61-477d-a6ae-5a1b71fc573a
ducktape was retried in https://buildkite.com/redpanda/redpanda/builds/54601#019200f2-5d95-46f2-9c88-0d7ec0e8e5a3
Moved to draft mode to prevent merging before Friday at @andijcr's request.
Do you have an example (or even an overview?) of how QualifierAlignment can spoil the code?
Do you have an example (or even an overview?) of how
QualifierAlignmentcan spoil the code?
apparently with concept
void foo(conceptable auto const&);
gets transformed to
void foo(conceptable const auto&);
and this doesn't compile. the correct transformation is
void foo(const conceptable auto&);
but i guess it's just a bug in the formatted. i don't know if there are valid cases where const position cal lead to valid but not correct code
a bug in the formatter
Ya, as I understand it, clang-format doesn't do a full parse, so distinguishing between lexically similar but semantically distinct expressions is pretty hard. Maybe that's not a bug; more of a fundamental limitation?
Do you have an example (or even an overview?) of how QualifierAlignment can spoil the code?
Unfortunately the clang-format docs aren't specific by what they mean by this, but the one compiler error I saw as a result of setting this property was as Andrea pointed out (the example with a conceptable const auto variable).
lgtm, approved in case we want to move forward with this instead of clang-format 18
we are going to move to clang-format-18
Unfortunately the clang-format docs aren't specific by what they mean by this, but the one compiler error I saw as a result of setting this property was as Andrea pointed out (the example with a conceptable const auto variable).
TBH I'd not use formatter settings that may convert buildable code into non-buildable
for the alignment changes where our clang-format settings currently has no preference and will keep the alignment unchanged, you could drip the changes into the tree over a series of PRs that kept review cost minimal.
i think that's only actually important for we are afraid that clang-format is making some kind of "incorrect" change?
new failures in https://buildkite.com/redpanda/redpanda/builds/54601#019200f2-5d95-46f2-9c88-0d7ec0e8e5a3:
"rptest.tests.usage_test.UsageTestCloudStorageMetrics.test_usage_manager_cloud_storage"
"rptest.tests.acls_test.AccessControlListTestUpgrade.test_describe_acls.use_tls=True.use_sasl=False.enable_authz=None.authn_method=none.client_auth=True"
"rptest.tests.acls_test.AccessControlListTestUpgrade.test_describe_acls.use_tls=True.use_sasl=False.enable_authz=None.authn_method=None.client_auth=True"
"rptest.tests.acls_test.AccessControlListTestUpgrade.test_describe_acls.use_tls=True.use_sasl=True.enable_authz=False.authn_method=none.client_auth=True"
"rptest.tests.acls_test.AccessControlListTestUpgrade.test_describe_acls.use_tls=True.use_sasl=True.enable_authz=None.authn_method=none.client_auth=True"
"rptest.tests.archival_test.ArchivalTest.test_write.cloud_storage_type_and_url_style=.CloudStorageType.ABS.2.virtual_host"
"rptest.tests.node_id_assignment_test.NodeIdAssignment.test_rejoin_after_decommission"
"rptest.tests.pandaproxy_test.PandaProxyMTLSTest.test_mtls"
new failures in https://buildkite.com/redpanda/redpanda/builds/54601#019200f2-5d92-46a4-983d-735710421faa:
"rptest.tests.cloud_storage_scrubber_test.CloudStorageScrubberTest.test_scrubber.cloud_storage_type=CloudStorageType.ABS"