botan icon indicating copy to clipboard operation
botan copied to clipboard

Add clang-format 17 formatting rules for attributes and inline assembly

Open KaganCanSit opened this issue 1 month ago • 2 comments

Hi,

This PR adds two new clang-format 17 options to the .clang-format configuration, as specified in #4049.

I initially prepared all the requested changes from #4049 in this branch. However, considering the broad impact across the codebase, I believe it would be better for you to handle those changes directly, as you have a better understanding of the project's current state and appropriate timing.

Therefore, this PR focuses solely on adding the two new clang-format 17 flags and applying the necessary formatting adjustments.

Changes:

  • Added BreakAfterAttributes: Always
  • Added BreakBeforeInlineAsmColon: OnlyMultiLine

Command used:

python3 src/scripts/dev_tools/run_clang_format.py --clang-format=clang-format-17 --src-dir=src

Clang-format version:

Debian clang-format version 17.0.6 (22+b2)

Note: Currently, BreakBeforeInlineAsmColon = OnlyMultiLine has no effect on any files in the codebase.

I believe this approach minimizes the review scope while still making incremental progress on the formatting improvements outlined in #4049.

Best regards.

KaganCanSit avatar Nov 22 '25 13:11 KaganCanSit

Coverage Status

coverage: 90.629% (+0.002%) from 90.627% when pulling 9ea34d5a55785b0839c5cf166e6935ea73c32b6e on KaganCanSit:add-clang-format-17-attributes into f8eb340027de2d81cdb35982ca55760e6d315c45 on randombit:master.

coveralls avatar Nov 22 '25 14:11 coveralls

Hmm, the static analysis failed because I shifted the suppression lines for clang-tidy. I can make adjustments to those lines. But I'm not sure what you'd prefer revert this or continue. So I'm looking forward to hearing from you.

Why same functions have a third line? Interesting. I expected it to be more like two lines.

[[nodiscard]]
detail::SessionHandle operator[](size_t i) const noexcept {

Problem is tpm2_util.h and stl_util.h files.

// NOLINTNEXTLINE(*-explicit-conversions) FIXME

KaganCanSit avatar Nov 22 '25 14:11 KaganCanSit