Skip to content

Bump clang-format from 17.0.6 to 20.1.0 #2046

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

Merged
merged 4 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 58 additions & 6 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
Expand All @@ -9,48 +8,83 @@ AlignConsecutiveAssignments:
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: true
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCaseArrows: false
AlignCaseColons: false
AlignConsecutiveTableGenBreakingDAGArgColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveTableGenCondOperatorColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveTableGenDefinitionColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseExpressionOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AllowShortNamespacesOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: All
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
- BSON_GNUC_WARN_UNUSED_RESULT
Expand Down Expand Up @@ -78,17 +112,22 @@ BraceWrapping:
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Never
BreakAfterJavaFieldAnnotations: false
BreakAfterReturnType: All
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Linux
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakBinaryOperations: Never
BreakConstructorInitializers: BeforeColon
BreakFunctionDefinitionParameters: false
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
BreakTemplateDeclarations: MultiLine
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
Expand Down Expand Up @@ -131,6 +170,7 @@ IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExportBlock: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
Expand All @@ -149,12 +189,16 @@ IntegerLiteralSeparator:
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
KeepEmptyLinesAtEOF: false
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: false
KeepFormFeed: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MainIncludeChar: AngleBracket
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
Expand All @@ -165,9 +209,11 @@ ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakBeforeMemberAccess: 150
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakScopeResolution: 500
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
Expand All @@ -177,14 +223,16 @@ PointerAlignment: Right
PPIndentWidth: -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: true
ReflowComments: Always
RemoveBracesLLVM: false
RemoveEmptyLinesInUnwrappedLines: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SkipMacroDefinitionBody: false
SortIncludes: Never
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
Expand All @@ -206,6 +254,7 @@ SpaceBeforeParensOptions:
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterPlacementOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
Expand All @@ -220,6 +269,7 @@ SpacesInLineCommentPrefix:
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
ExceptDoubleParentheses: false
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Expand All @@ -231,6 +281,7 @@ StatementAttributeLikeMacros:
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TableGenBreakInsideDAGArg: DontBreak
TabWidth: 3
UseTab: Never
VerilogBreakBetweenInstancePorts: true
Expand All @@ -240,4 +291,5 @@ WhitespaceSensitiveMacros:
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
WrapNamespaceBodyWithEmptyLines: Leave
...
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dev = [

format = [
# .evergreen/scripts/clang-format-all.sh
"clang-format~=17.0.6",
"clang-format~=20.1.0",
]

docs = [
Expand Down
1 change: 0 additions & 1 deletion src/libbson/src/bson/bson-decimal128.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* Copyright 2009-present MongoDB, Inc.
*
Expand Down
2 changes: 1 addition & 1 deletion src/libbson/src/bson/bson-iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bson_iter_init (bson_iter_t *iter, /* OUT */
iter->d4 = 0;
iter->next_off = 4;
iter->err_off = 0;
iter->value = (bson_value_t){0};
iter->value = (bson_value_t) {0};

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libbson/src/bson/bson-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ bson_json_opts_new (bson_json_mode_t mode, int32_t max_len)
bson_json_opts_t *opts;

opts = (bson_json_opts_t *) bson_malloc (sizeof *opts);
*opts = (bson_json_opts_t){
*opts = (bson_json_opts_t) {
.mode = mode,
.max_len = max_len,
.is_outermost_array = false,
Expand Down
8 changes: 1 addition & 7 deletions src/libbson/src/bson/bson-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,7 @@ BSON_ALIGNED_BEGIN (BSON_ALIGN_OF_PTR) typedef struct _bson_t {
* bson_t b = BSON_INITIALIZER;
* ]|
*/
#define BSON_INITIALIZER \
{ \
3, 5, \
{ \
5 \
} \
}
#define BSON_INITIALIZER {3, 5, {5}}


BSON_STATIC_ASSERT2 (bson_t, sizeof (bson_t) == 128);
Expand Down
18 changes: 9 additions & 9 deletions src/libbson/src/bson/bson-vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bson_vector_int8_view_init (bson_vector_int8_view_t *view_out, uint8_t *binary_d
if (bson_vector_binary_header_impl_init (&header, binary_data, binary_data_len) &&
bson_vector_int8_validate (header)) {
if (view_out) {
*view_out = (bson_vector_int8_view_t){
*view_out = (bson_vector_int8_view_t) {
.binary.data = binary_data, .binary.data_len = binary_data_len, .binary.header_copy = header};
}
return true;
Expand All @@ -103,7 +103,7 @@ bson_vector_int8_const_view_init (bson_vector_int8_const_view_t *view_out,
if (bson_vector_binary_header_impl_init (&header, binary_data, binary_data_len) &&
bson_vector_int8_validate (header)) {
if (view_out) {
*view_out = (bson_vector_int8_const_view_t){
*view_out = (bson_vector_int8_const_view_t) {
.binary.data = binary_data, .binary.data_len = binary_data_len, .binary.header_copy = header};
}
return true;
Expand All @@ -121,7 +121,7 @@ bson_vector_float32_view_init (bson_vector_float32_view_t *view_out, uint8_t *bi
if (bson_vector_binary_header_impl_init (&header, binary_data, binary_data_len) &&
bson_vector_float32_validate (header, binary_data_len)) {
if (view_out) {
*view_out = (bson_vector_float32_view_t){
*view_out = (bson_vector_float32_view_t) {
.binary.data = binary_data, .binary.data_len = binary_data_len, .binary.header_copy = header};
}
return true;
Expand All @@ -141,7 +141,7 @@ bson_vector_float32_const_view_init (bson_vector_float32_const_view_t *view_out,
if (bson_vector_binary_header_impl_init (&header, binary_data, binary_data_len) &&
bson_vector_float32_validate (header, binary_data_len)) {
if (view_out) {
*view_out = (bson_vector_float32_const_view_t){
*view_out = (bson_vector_float32_const_view_t) {
.binary.data = binary_data, .binary.data_len = binary_data_len, .binary.header_copy = header};
}
return true;
Expand All @@ -161,7 +161,7 @@ bson_vector_packed_bit_view_init (bson_vector_packed_bit_view_t *view_out,
if (bson_vector_binary_header_impl_init (&header, binary_data, binary_data_len) &&
bson_vector_packed_bit_validate (header, binary_data, binary_data_len)) {
if (view_out) {
*view_out = (bson_vector_packed_bit_view_t){
*view_out = (bson_vector_packed_bit_view_t) {
.binary.data = binary_data, .binary.data_len = binary_data_len, .binary.header_copy = header};
}
return true;
Expand All @@ -181,7 +181,7 @@ bson_vector_packed_bit_const_view_init (bson_vector_packed_bit_const_view_t *vie
if (bson_vector_binary_header_impl_init (&header, binary_data, binary_data_len) &&
bson_vector_packed_bit_validate (header, binary_data, binary_data_len)) {
if (view_out) {
*view_out = (bson_vector_packed_bit_const_view_t){
*view_out = (bson_vector_packed_bit_const_view_t) {
.binary.data = binary_data, .binary.data_len = binary_data_len, .binary.header_copy = header};
}
return true;
Expand Down Expand Up @@ -306,7 +306,7 @@ bson_append_vector_int8_uninit (
.bytes[1] = bson_vector_header_byte_1 (0)};
memcpy (binary, header.bytes, BSON_VECTOR_HEADER_LEN);
*view_out =
(bson_vector_int8_view_t){.binary.data = binary, .binary.data_len = length, .binary.header_copy = header};
(bson_vector_int8_view_t) {.binary.data = binary, .binary.data_len = length, .binary.header_copy = header};
return true;
} else {
return false;
Expand All @@ -331,7 +331,7 @@ bson_append_vector_float32_uninit (
.bytes[1] = bson_vector_header_byte_1 (0)};
memcpy (binary, header.bytes, BSON_VECTOR_HEADER_LEN);
*view_out =
(bson_vector_float32_view_t){.binary.data = binary, .binary.data_len = length, .binary.header_copy = header};
(bson_vector_float32_view_t) {.binary.data = binary, .binary.data_len = length, .binary.header_copy = header};
return true;
} else {
return false;
Expand Down Expand Up @@ -365,7 +365,7 @@ bson_append_vector_packed_bit_uninit (
// No reason to read-modify-write here, it's better to write the whole byte.
binary[length - 1u] = 0u;
}
*view_out = (bson_vector_packed_bit_view_t){
*view_out = (bson_vector_packed_bit_view_t) {
.binary.data = binary, .binary.data_len = length, .binary.header_copy = header};
return true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/libbson/src/bson/bson.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ BSON_STATIC_ASSERT2 (max_alloc_grow_fits_min_sizet, (uint64_t) BSON_MAX_SIZE * 2
mlib_diagnostic_pop (); \
goto append_failure; \
} else if ((_length) > 0) { \
*(_list).current++ = (_bson_append_bytes_arg){ \
*(_list).current++ = (_bson_append_bytes_arg) { \
.bytes = (const uint8_t *) (_bytes), \
.length = (_length), \
}; \
Expand Down
2 changes: 1 addition & 1 deletion src/libbson/src/bson/validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ _bson_validate_impl_v2 (const bson_t *bson, bson_validate_flags_t flags, size_t
BSON_ASSERT_PARAM (error);

// Clear the error
*error = (bson_error_t){0};
*error = (bson_error_t) {0};

// Initialize validation parameters
validation_params const params = {
Expand Down
1 change: 0 additions & 1 deletion src/libmongoc/examples/find_and_modify_with_opts/fam.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include <mongoc/mongoc.h>

/* EXAMPLE_FAM_BYPASS_BEGIN */
Expand Down
6 changes: 3 additions & 3 deletions src/libmongoc/src/mongoc/mcd-azure.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mcd_azure_access_token_try_init_from_json_str (mcd_azure_access_token *out,
}

// Zero the output
*out = (mcd_azure_access_token){0};
*out = (mcd_azure_access_token) {0};

// Parse the JSON data
bson_t bson;
Expand Down Expand Up @@ -112,7 +112,7 @@ mcd_azure_access_token_try_init_from_json_str (mcd_azure_access_token *out,
json);
} else {
// Set the output, duplicate each string
*out = (mcd_azure_access_token){
*out = (mcd_azure_access_token) {
.access_token = bson_strdup (access_token),
.resource = bson_strdup (resource),
.token_type = bson_strdup (token_type),
Expand Down Expand Up @@ -165,7 +165,7 @@ mcd_azure_access_token_from_imds (mcd_azure_access_token *const out,
bool okay = false;

// Clear the output
*out = (mcd_azure_access_token){0};
*out = (mcd_azure_access_token) {0};

mongoc_http_response_t resp;
_mongoc_http_response_init (&resp);
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/src/mongoc/mcd-nsinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mcd_nsinfo_append (mcd_nsinfo_t *self, const char *ns, bson_error_t *error)

// Add to hash table.
ns_to_index_t *entry = bson_malloc (sizeof (*entry));
*entry = (ns_to_index_t){.index = ns_index, .ns = bson_strdup (ns), .hh = {0}};
*entry = (ns_to_index_t) {.index = ns_index, .ns = bson_strdup (ns), .hh = {0}};

mlib_diagnostic_push ();
mlib_disable_constant_conditional_expression_warnings ();
Expand Down
Loading