Skip to content

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Dec 2, 2025

This is a tricky bit with no standard solution.

clang-format suggests: `} break;`. curl uses a break in
a separate line either in or out of the block. In this case
the outer solution triggered checksrc.
I formatted this manually.
@vszakats
Copy link
Member Author

vszakats commented Dec 2, 2025

.clang-tidy:

# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
BreakBeforeBraces: Stroustrup
ColumnLimit: 79
SortIncludes:
  Enabled: false
SpaceAroundPointerQualifiers: Before
SpaceBeforeParens: Never
BracedInitializerIndentWidth: 2
ContinuationIndentWidth: 2
# Ignored for /* */ comments unfortunately
SpacesBeforeTrailingComments: 2
AlignEscapedNewlines: LeftWithLastLine
AllowShortFunctionsOnASingleLine: false
# llvm 22: no longer supports False
#Cpp11BracedListStyle: False
# llvm 22:
Cpp11BracedListStyle: Block
# default. Could also be OnePerLine, neither matches current curl practices
BinPackParameters: BinPack
AlignConsecutiveMacros: AcrossComments
IndentGotoLabels: False
# llvm 22: https://github.com/llvm/llvm-project/commit/7dd2f1cc10902e632c0c78c75a30432a53eb59dc
IndentPPDirectives: Leave
AlignTrailingComments:
  Kind: Leave
BitFieldColonSpacing: None

It's not 100% and there are likely settings I missed.

@bagder
Copy link
Member

bagder commented Dec 2, 2025

Not sure it is relevant anymore but we once tried working on a complete clang format setup for curl over here: https://github.com/curl/curl/wiki/clang-format-style

@vszakats
Copy link
Member Author

vszakats commented Dec 2, 2025

Nice, I'll check!

I keep a list of cases it doesn't handle well, or which some seemed
like a regression compared to manual (e.g. line flowing/splitting).
It has issues with inline comments. Some things aren't consistent
enough in the codebase (PP line splits, spacing), and some
other things are sometimes nicely adjusted, but strictly speaking
not according to curl rules. There are also some bugs in clang-format.
Some I could not let go easily, but we probably could or should.
It's still a little bit in flux. Overall, it gets things right in most cases,
though fully automating would need swallowing the minor regressions,
and/or adding exceptions here and there.

@vszakats vszakats closed this in c3b030b Dec 3, 2025
@vszakats vszakats deleted the lrf3 branch December 3, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants