Skip to content

Commit 6b9f786

Browse files
authored
Upgrade to clang-format 19 (#8543)
1 parent a9f82db commit 6b9f786

31 files changed

+729
-681
lines changed

.clang-format

+11-20
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,39 @@
11
---
22
AccessModifierOffset: -4
33
AlignEscapedNewlines: Left
4-
AlignTrailingComments: true
4+
AlignTrailingComments:
5+
Kind: Always
6+
OverEmptyLines: 0
57
AllowAllParametersOfDeclarationOnNextLine: true
68
AllowShortBlocksOnASingleLine: Empty
79
AllowShortFunctionsOnASingleLine: None
810
AllowShortIfStatementsOnASingleLine: Always
911
AllowShortLoopsOnASingleLine: false
1012
AlwaysBreakBeforeMultilineStrings: false
11-
AlwaysBreakTemplateDeclarations: Yes
1213
BinPackParameters: true
14+
BreakAfterReturnType: Automatic
1315
BreakBeforeBinaryOperators: None
1416
BreakBeforeBraces: Attach
1517
BreakBeforeTernaryOperators: false
16-
BreakConstructorInitializersBeforeComma: false
18+
BreakConstructorInitializers: BeforeColon
19+
BreakTemplateDeclarations: Yes
1720
ColumnLimit: 0
18-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
1921
ConstructorInitializerIndentWidth: 4
2022
ContinuationIndentWidth: 4
21-
Cpp11BracedListStyle: true
22-
DerivePointerAlignment: false
23-
ExperimentalAutoDetectBinPacking: false
2423
IndentCaseLabels: false
25-
IndentWrappedFunctionNames: false
2624
IndentWidth: 4
25+
IndentWrappedFunctionNames: false
2726
MaxEmptyLinesToKeep: 1
2827
NamespaceIndentation: None
29-
ObjCSpaceBeforeProtocolList: true
30-
PenaltyBreakBeforeFirstCallParameter: 19
31-
PenaltyBreakComment: 60
32-
PenaltyBreakFirstLessLess: 120
33-
PenaltyBreakString: 1000
34-
PenaltyExcessCharacter: 1000000
35-
PenaltyReturnTypeOnItsOwnLine: 60
28+
PackConstructorInitializers: BinPack
3629
PointerAlignment: Right
37-
SpaceBeforeParens: ControlStatements
3830
SpaceAfterCStyleCast: false
3931
SpaceAfterTemplateKeyword: false
4032
SpaceBeforeAssignmentOperators: true
41-
SpaceInEmptyParentheses: false
33+
SpaceBeforeParens: ControlStatements
4234
SpacesBeforeTrailingComments: 2
43-
SpacesInAngles: false
44-
SpacesInCStyleCastParentheses: false
45-
SpacesInParentheses: false
35+
SpacesInAngles: Never
36+
SpacesInParens: Never
4637
Standard: c++17
4738
TabWidth: 8
4839
UseTab: Never

.github/workflows/presubmit.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ permissions:
1616
jobs:
1717
check_clang_format:
1818
name: Check clang-format
19-
runs-on: ubuntu-20.04
19+
runs-on: macos-14
2020
steps:
2121
- uses: actions/checkout@v3
22-
- uses: DoozyX/[email protected]
23-
with:
24-
source: '.'
25-
extensions: 'h,c,cpp'
26-
clangFormatVersion: 17
22+
- name: Install clang-format
23+
run: brew install llvm@19
24+
- name: Check clang-format
25+
run: ./run-clang-format.sh -c
26+
env:
27+
CLANG_FORMAT_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@19
2728
check_clang_tidy:
2829
name: Check clang-tidy
2930
runs-on: macos-14

apps/HelloAndroidCamera2/jni/LockedSurface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// Round x up to a multiple of mask.
77
// E.g., ALIGN(x, 16) means round x up to the nearest multiple of 16.
8-
#define ALIGN(x, mask) (((x) + (mask)-1) & ~((mask)-1))
8+
#define ALIGN(x, mask) (((x) + (mask) - 1) & ~((mask) - 1))
99

1010
LockedSurface *LockedSurface::lock(JNIEnv *env, jobject surface) {
1111
LockedSurface *output = new LockedSurface;

apps/HelloWasm/core.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ void mainloop(void *arg) {
7676
"Frame rate: %2.0f fps",
7777
ctx->smoothed_runtime, ctx->smoothed_blit_time, ctx->smoothed_fps);
7878
// Run some javascript inline to update the web-page
79-
EM_ASM({
80-
document.getElementById(UTF8ToString($0)).innerHTML = UTF8ToString($1);
81-
},
82-
"runtime", buf);
79+
EM_ASM({ document.getElementById(UTF8ToString($0)).innerHTML = UTF8ToString($1); }, "runtime", buf);
8380

8481
// Read the threads slider from the UI
8582
int threads = EM_ASM_INT({

apps/blur/test.cpp

+48-48
Original file line numberDiff line numberDiff line change
@@ -70,61 +70,61 @@ Buffer<uint16_t, 2> blur_fast(Buffer<uint16_t, 2> in) {
7070
}
7171
}
7272
#elif __ARM_NEON
73-
uint16x4_t one_third = vdup_n_u16(21846);
73+
uint16x4_t one_third = vdup_n_u16(21846);
7474
#pragma omp parallel for
75-
for (int yTile = 0; yTile < out.height(); yTile += 32) {
76-
uint16x8_t tmp[(128 / 8) * (32 + 2)];
77-
for (int xTile = 0; xTile < out.width(); xTile += 128) {
78-
uint16_t *tmpPtr = (uint16_t *)tmp;
79-
for (int y = 0; y < 32 + 2; y++) {
80-
const uint16_t *inPtr = &(in(xTile, yTile + y));
81-
for (int x = 0; x < 128; x += 8) {
82-
uint16x8_t a = vld1q_u16(inPtr);
83-
uint16x8_t b = vld1q_u16(inPtr + 1);
84-
uint16x8_t c = vld1q_u16(inPtr + 2);
85-
uint16x8_t sum = vaddq_u16(vaddq_u16(a, b), c);
86-
uint16x4_t sumlo = vget_low_u16(sum);
87-
uint16x4_t sumhi = vget_high_u16(sum);
88-
uint16x4_t avglo = vshrn_n_u32(vmull_u16(sumlo, one_third), 16);
89-
uint16x4_t avghi = vshrn_n_u32(vmull_u16(sumhi, one_third), 16);
90-
uint16x8_t avg = vcombine_u16(avglo, avghi);
91-
vst1q_u16(tmpPtr, avg);
92-
tmpPtr += 8;
93-
inPtr += 8;
94-
}
75+
for (int yTile = 0; yTile < out.height(); yTile += 32) {
76+
uint16x8_t tmp[(128 / 8) * (32 + 2)];
77+
for (int xTile = 0; xTile < out.width(); xTile += 128) {
78+
uint16_t *tmpPtr = (uint16_t *)tmp;
79+
for (int y = 0; y < 32 + 2; y++) {
80+
const uint16_t *inPtr = &(in(xTile, yTile + y));
81+
for (int x = 0; x < 128; x += 8) {
82+
uint16x8_t a = vld1q_u16(inPtr);
83+
uint16x8_t b = vld1q_u16(inPtr + 1);
84+
uint16x8_t c = vld1q_u16(inPtr + 2);
85+
uint16x8_t sum = vaddq_u16(vaddq_u16(a, b), c);
86+
uint16x4_t sumlo = vget_low_u16(sum);
87+
uint16x4_t sumhi = vget_high_u16(sum);
88+
uint16x4_t avglo = vshrn_n_u32(vmull_u16(sumlo, one_third), 16);
89+
uint16x4_t avghi = vshrn_n_u32(vmull_u16(sumhi, one_third), 16);
90+
uint16x8_t avg = vcombine_u16(avglo, avghi);
91+
vst1q_u16(tmpPtr, avg);
92+
tmpPtr += 8;
93+
inPtr += 8;
9594
}
96-
tmpPtr = (uint16_t *)tmp;
97-
for (int y = 0; y < 32; y++) {
98-
uint16_t *outPtr = &(out(xTile, yTile + y));
99-
for (int x = 0; x < 128; x += 8) {
100-
uint16x8_t a = vld1q_u16(tmpPtr + (2 * 128));
101-
uint16x8_t b = vld1q_u16(tmpPtr + 128);
102-
uint16x8_t c = vld1q_u16(tmpPtr);
103-
uint16x8_t sum = vaddq_u16(vaddq_u16(a, b), c);
104-
uint16x4_t sumlo = vget_low_u16(sum);
105-
uint16x4_t sumhi = vget_high_u16(sum);
106-
uint16x4_t avglo = vshrn_n_u32(vmull_u16(sumlo, one_third), 16);
107-
uint16x4_t avghi = vshrn_n_u32(vmull_u16(sumhi, one_third), 16);
108-
uint16x8_t avg = vcombine_u16(avglo, avghi);
109-
vst1q_u16(outPtr, avg);
110-
tmpPtr += 8;
111-
outPtr += 8;
112-
}
95+
}
96+
tmpPtr = (uint16_t *)tmp;
97+
for (int y = 0; y < 32; y++) {
98+
uint16_t *outPtr = &(out(xTile, yTile + y));
99+
for (int x = 0; x < 128; x += 8) {
100+
uint16x8_t a = vld1q_u16(tmpPtr + (2 * 128));
101+
uint16x8_t b = vld1q_u16(tmpPtr + 128);
102+
uint16x8_t c = vld1q_u16(tmpPtr);
103+
uint16x8_t sum = vaddq_u16(vaddq_u16(a, b), c);
104+
uint16x4_t sumlo = vget_low_u16(sum);
105+
uint16x4_t sumhi = vget_high_u16(sum);
106+
uint16x4_t avglo = vshrn_n_u32(vmull_u16(sumlo, one_third), 16);
107+
uint16x4_t avghi = vshrn_n_u32(vmull_u16(sumhi, one_third), 16);
108+
uint16x8_t avg = vcombine_u16(avglo, avghi);
109+
vst1q_u16(outPtr, avg);
110+
tmpPtr += 8;
111+
outPtr += 8;
113112
}
114113
}
115114
}
115+
}
116116
#else
117-
// No intrinsics enabled, do a naive thing.
118-
for (int y = 0; y < out.height(); y++) {
119-
for (int x = 0; x < out.width(); x++) {
120-
int tmp[3] = {
121-
(in(x, y) + in(x + 1, y) + in(x + 2, y)) / 3,
122-
(in(x, y + 1) + in(x + 1, y + 1) + in(x + 2, y + 1)) / 3,
123-
(in(x, y + 2) + in(x + 1, y + 2) + in(x + 2, y + 2)) / 3,
124-
};
125-
out(x, y) = (tmp[0] + tmp[1] + tmp[2]) / 3;
126-
}
117+
// No intrinsics enabled, do a naive thing.
118+
for (int y = 0; y < out.height(); y++) {
119+
for (int x = 0; x < out.width(); x++) {
120+
int tmp[3] = {
121+
(in(x, y) + in(x + 1, y) + in(x + 2, y)) / 3,
122+
(in(x, y + 1) + in(x + 1, y + 1) + in(x + 2, y + 1)) / 3,
123+
(in(x, y + 2) + in(x + 1, y + 2) + in(x + 2, y + 2)) / 3,
124+
};
125+
out(x, y) = (tmp[0] + tmp[1] + tmp[2]) / 3;
127126
}
127+
}
128128
#endif
129129
});
130130

apps/hexagon_dma/process_raw_linear_interleaved_basic.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ typedef struct {
4242
#define _SCHEDULE_STR(s) #s
4343
#define _SCHEDULE_NAME(data, direction, schedule) pipeline_##data##_##direction##_##schedule
4444
#define _SCHEDULE_PAIR(data, direction, schedule) \
45-
{ _SCHEDULE_STR(scheduled - pipeline(data, direction, schedule)), _SCHEDULE_NAME(data, direction, schedule) }
45+
{_SCHEDULE_STR(scheduled - pipeline(data, direction, schedule)), _SCHEDULE_NAME(data, direction, schedule)}
4646
#define _SCHEDULE_DUMMY_PAIR \
47-
{ NULL, NULL }
47+
{NULL, NULL}
4848
#define SCHEDULE_FUNCTION_RW(schedule) _SCHEDULE_PAIR(raw_linear_interleaved, rw, schedule)
4949

5050
#ifdef SCHEDULE_ALL

apps/hexagon_dma/process_yuv_linear_basic.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ typedef struct {
5555
#define _SCHEDULE_STR(s) #s
5656
#define _SCHEDULE_NAME(data, direction, schedule) pipeline_##data##_##direction##_##schedule
5757
#define _SCHEDULE_PAIR(data, direction, schedule) \
58-
{ _SCHEDULE_STR(scheduled - pipeline(data, direction, schedule)), _SCHEDULE_NAME(data, direction, schedule) }
58+
{_SCHEDULE_STR(scheduled - pipeline(data, direction, schedule)), _SCHEDULE_NAME(data, direction, schedule)}
5959
#define _SCHEDULE_DUMMY_PAIR \
60-
{ NULL, NULL }
60+
{NULL, NULL}
6161
#define SCHEDULE_FUNCTION_RW(type, schedule) _SCHEDULE_PAIR(type##_linear, rw, schedule)
6262

6363
#ifdef SCHEDULE_ALL

apps/resnet_50/Resnet50Generator.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,35 @@ class Resnet50Generator : public Halide::Generator<Resnet50Generator> {
3131
Input<Buffer<float, 3>> input{"input"};
3232
/** parameter values for scaling layers **/
3333
Input<Buffer<float, 1>> conv1_gamma{"conv1_gamma"};
34-
Input<Buffer<float, 1>[4]> br1_gamma { "br1_gamma" };
35-
Input<Buffer<float, 1>[16]> br2a_gamma { "br2a_gamma" };
36-
Input<Buffer<float, 1>[16]> br2b_gamma { "br2b_gamma" };
37-
Input<Buffer<float, 1>[16]> br2c_gamma { "br2c_gamma" };
34+
Input<Buffer<float, 1>[4]> br1_gamma{"br1_gamma"};
35+
Input<Buffer<float, 1>[16]> br2a_gamma{"br2a_gamma"};
36+
Input<Buffer<float, 1>[16]> br2b_gamma{"br2b_gamma"};
37+
Input<Buffer<float, 1>[16]> br2c_gamma{"br2c_gamma"};
3838

3939
Input<Buffer<float, 1>> conv1_beta{"conv1_beta"};
40-
Input<Buffer<float, 1>[4]> br1_beta { "br1_beta" };
41-
Input<Buffer<float, 1>[16]> br2a_beta { "br2a_beta" };
42-
Input<Buffer<float, 1>[16]> br2b_beta { "br2b_beta" };
43-
Input<Buffer<float, 1>[16]> br2c_beta { "br2c_beta" };
40+
Input<Buffer<float, 1>[4]> br1_beta{"br1_beta"};
41+
Input<Buffer<float, 1>[16]> br2a_beta{"br2a_beta"};
42+
Input<Buffer<float, 1>[16]> br2b_beta{"br2b_beta"};
43+
Input<Buffer<float, 1>[16]> br2c_beta{"br2c_beta"};
4444

4545
Input<Buffer<float, 1>> conv1_mu{"conv1_mu"};
46-
Input<Buffer<float, 1>[4]> br1_mu { "br1_mu" };
47-
Input<Buffer<float, 1>[16]> br2a_mu { "br2a_mu" };
48-
Input<Buffer<float, 1>[16]> br2b_mu { "br2b_mu" };
49-
Input<Buffer<float, 1>[16]> br2c_mu { "br2c_mu" };
46+
Input<Buffer<float, 1>[4]> br1_mu{"br1_mu"};
47+
Input<Buffer<float, 1>[16]> br2a_mu{"br2a_mu"};
48+
Input<Buffer<float, 1>[16]> br2b_mu{"br2b_mu"};
49+
Input<Buffer<float, 1>[16]> br2c_mu{"br2c_mu"};
5050

5151
Input<Buffer<float, 1>> conv1_sig{"conv1_sig"};
52-
Input<Buffer<float, 1>[4]> br1_sig { "br1_sig" };
53-
Input<Buffer<float, 1>[16]> br2a_sig { "br2a_sig" };
54-
Input<Buffer<float, 1>[16]> br2b_sig { "br2b_sig" };
55-
Input<Buffer<float, 1>[16]> br2c_sig { "br2c_sig" };
52+
Input<Buffer<float, 1>[4]> br1_sig{"br1_sig"};
53+
Input<Buffer<float, 1>[16]> br2a_sig{"br2a_sig"};
54+
Input<Buffer<float, 1>[16]> br2b_sig{"br2b_sig"};
55+
Input<Buffer<float, 1>[16]> br2c_sig{"br2c_sig"};
5656

5757
/** weights and biases for convolutions **/
5858
Input<Buffer<float, 4>> conv1_weights{"conv1_weights"};
59-
Input<Buffer<float, 4>[4]> br1_conv_weights { "br1_conv_weights" };
60-
Input<Buffer<float, 4>[16]> br2a_conv_weights { "br2a_conv_weights" };
61-
Input<Buffer<float, 4>[16]> br2b_conv_weights { "br2b_conv_weights" };
62-
Input<Buffer<float, 4>[16]> br2c_conv_weights { "br2c_conv_weights" };
59+
Input<Buffer<float, 4>[4]> br1_conv_weights{"br1_conv_weights"};
60+
Input<Buffer<float, 4>[16]> br2a_conv_weights{"br2a_conv_weights"};
61+
Input<Buffer<float, 4>[16]> br2b_conv_weights{"br2b_conv_weights"};
62+
Input<Buffer<float, 4>[16]> br2c_conv_weights{"br2c_conv_weights"};
6363

6464
Input<Buffer<float, 2>> fc1000_weights{"fc1000_weights"};
6565
Input<Buffer<float, 1>> fc1000_bias{"fc1000_bias"};

0 commit comments

Comments
 (0)