Skip to content

Commit efd9e8e

Browse files
authored
Reformat entire codebase (except Tolk) with clang-format 21
2 parents 431aa80 + 1abeaef commit efd9e8e

File tree

986 files changed

+11532
-13090
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

986 files changed

+11532
-13090
lines changed

.clang-format

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ DisableFormat: false
4949
ExperimentalAutoDetectBinPacking: false
5050
FixNamespaceComments: true
5151
# ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
52+
IncludeBlocks: Regroup
53+
IncludeCategories:
54+
- Regex: '>$'
55+
Priority: -3
56+
- Regex: '.h>$'
57+
Priority: -2
58+
- Regex: '^\".*/.*\"$'
59+
Priority: -1
60+
- Regex: '^\"[^/]*\"$'
61+
Priority: 0
5262
IndentCaseLabels: true
5363
IndentWidth: 2
5464
IndentWrappedFunctionNames: false
@@ -70,7 +80,7 @@ PenaltyExcessCharacter: 1000000
7080
PenaltyReturnTypeOnItsOwnLine: 200
7181
PointerAlignment: Left
7282
ReflowComments: false # true
73-
SortIncludes: false # disabled, because we need case insensitive sort
83+
SortIncludes: true
7484
SpaceAfterCStyleCast: false
7585
SpaceAfterTemplateKeyword: true
7686
SpaceBeforeAssignmentOperators: true

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ third_party/** linguist-vendored
3434
*.a binary
3535
*.jar binary
3636
*.tlo binary
37+
38+
*.h merge=clang-format-driver
39+
*.cpp merge=clang-format-driver
40+
*.hpp merge=clang-format-driver

.github/workflows/build-ton-linux-x86-64-werror.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Ubuntu TON -Werror build (shared, x86-64)
1+
name: Lint
22

33
on: [push, pull_request, workflow_dispatch, workflow_call]
44

55
jobs:
6-
build:
6+
lint:
77
runs-on: ubuntu-24.04
88

99
steps:
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
wget https://apt.llvm.org/llvm.sh
2929
chmod +x llvm.sh
30-
sudo ./llvm.sh 21 clang
30+
sudo ./llvm.sh 21 all
3131
3232
# TODO: Preserve ccache cache between runs once we get rid of warning suppression mappings.
3333

@@ -41,3 +41,9 @@ jobs:
4141
-DTON_USE_LLD=On \
4242
-DTON_WERROR_BUILD=On
4343
ninja -C build
44+
45+
- name: Check C++ formatting
46+
run: |
47+
# TODO: Run clang-format only on changed files.
48+
clang-format-21 -i $(git ls-files '*.h' '*.hpp' '*.cpp' ':!^example/android/third_party' ':!^tolk/')
49+
git diff --exit-code

adnl/adnl-address-list.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
1717
Copyright 2017-2020 Telegram Systems LLP
1818
*/
19-
#include "adnl-address-list.hpp"
20-
#include "adnl-peer-table.h"
2119
#include "auto/tl/ton_api.hpp"
22-
#include "td/utils/overloaded.h"
23-
#include "td/net/UdpServer.h"
2420
#include "keys/encryptor.h"
21+
#include "td/net/UdpServer.h"
22+
#include "td/utils/overloaded.h"
23+
24+
#include "adnl-address-list.hpp"
25+
#include "adnl-peer-table.h"
2526

2627
namespace ton {
2728

adnl/adnl-address-list.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
*/
1919
#pragma once
2020

21-
#include "adnl-network-manager.h"
2221
#include "crypto/common/refcnt.hpp"
2322

23+
#include "adnl-network-manager.h"
24+
2425
namespace ton {
2526

2627
namespace adnl {

adnl/adnl-address-list.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
#pragma once
2020

21-
#include "adnl-node-id.hpp"
2221
#include "adnl-address-list.h"
22+
#include "adnl-node-id.hpp"
2323

2424
namespace ton {
2525

adnl/adnl-channel.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
1717
Copyright 2017-2020 Telegram Systems LLP
1818
*/
19+
#include "crypto/Ed25519.h"
20+
#include "td/utils/crypto.h"
21+
1922
#include "adnl-channel.hpp"
20-
#include "adnl-peer.h"
2123
#include "adnl-peer-table.h"
22-
23-
#include "td/utils/crypto.h"
24-
#include "crypto/Ed25519.h"
24+
#include "adnl-peer.h"
2525

2626
namespace ton {
2727

adnl/adnl-channel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#pragma once
2020

2121
#include "adnl-local-id.h"
22-
#include "adnl-peer.h"
23-
#include "adnl-peer-table.h"
2422
#include "adnl-network-manager.h"
23+
#include "adnl-peer-table.h"
24+
#include "adnl-peer.h"
2525

2626
namespace ton {
2727

adnl/adnl-channel.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
*/
1919
#pragma once
2020

21-
#include "adnl-channel.h"
2221
#include "keys/encryptor.h"
2322

23+
#include "adnl-channel.h"
24+
2425
namespace ton {
2526

2627
namespace adnl {

adnl/adnl-db.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
1717
Copyright 2017-2020 Telegram Systems LLP
1818
*/
19-
#include "adnl-db.hpp"
2019
#include "td/db/RocksDb.h"
2120

21+
#include "adnl-db.hpp"
22+
2223
namespace ton {
2324

2425
namespace adnl {

0 commit comments

Comments
 (0)