Skip to content

Commit 2bc52d9

Browse files
authored
Merge pull request #172 from IntelPython/change-pre-commit-clang-format
[MAINT] Change clang-format for pre-commit
2 parents 8704ec9 + f14e306 commit 2bc52d9

7 files changed

Lines changed: 228 additions & 175 deletions

File tree

.clang-format

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
BasedOnStyle: LLVM
2+
3+
AccessModifierOffset: -4
4+
5+
AlignConsecutiveMacros: true
6+
AlignConsecutiveBitFields: true
7+
AlignEscapedNewlines: Right
8+
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: Empty
11+
12+
AlwaysBreakTemplateDeclarations: Yes
13+
14+
BinPackParameters: false
15+
16+
BraceWrapping:
17+
AfterCaseLabel: true
18+
AfterClass: true
19+
AfterControlStatement: Never
20+
AfterEnum: true
21+
AfterFunction: true
22+
AfterNamespace: true
23+
AfterObjCDeclaration: false
24+
AfterStruct: true
25+
AfterUnion: true
26+
AfterExternBlock: true
27+
BeforeCatch: false
28+
BeforeElse: true
29+
BeforeLambdaBody: false
30+
BeforeWhile: false
31+
IndentBraces: false
32+
SplitEmptyFunction: true
33+
SplitEmptyRecord: true
34+
SplitEmptyNamespace: true
35+
BreakBeforeBraces: Custom
36+
37+
ColumnLimit: 80
38+
39+
IndentWidth: 4
40+
IndentWrappedFunctionNames: true

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55

66
# added more linters
77
3a3df3fae1574558973e3829368dc8a7b9c76ad9
8+
9+
# Move to clang-format-22
10+
85e977ffa438851fda6f9d2314810bca278998b1

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,5 @@ jobs:
3030
codespell
3131
pylint
3232
33-
- name: Set up clang-format
34-
run: |
35-
sudo apt-get install -y clang-format-18
36-
sudo unlink /usr/bin/clang-format
37-
sudo ln -s /usr/bin/clang-format-18 /usr/bin/clang-format
38-
clang-format --version
39-
4033
- name: Run pre-commit checks
4134
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ repos:
5151
- id: black
5252
exclude: "_vendored/conv_template.py"
5353

54-
- repo: https://github.com/pocc/pre-commit-hooks
55-
rev: v1.3.5
54+
- repo: https://github.com/pre-commit/mirrors-clang-format
55+
rev: v22.1.0
5656
hooks:
5757
- id: clang-format
5858
args: ["-i"]

mkl_umath/src/blocking_utils.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@
4242
static NPY_INLINE npy_intp npy_aligned_block_offset(const void *addr,
4343
const npy_uintp esize,
4444
const npy_uintp alignment,
45-
const npy_uintp nvals) {
46-
npy_uintp offset, peel;
45+
const npy_uintp nvals)
46+
{
47+
npy_uintp offset, peel;
4748

48-
offset = (npy_uintp)addr & (alignment - 1);
49-
peel = offset ? (alignment - offset) / esize : 0;
50-
peel = (peel <= nvals) ? peel : nvals;
51-
assert(peel <= NPY_MAX_INTP);
52-
return (npy_intp)peel;
49+
offset = (npy_uintp)addr & (alignment - 1);
50+
peel = offset ? (alignment - offset) / esize : 0;
51+
peel = (peel <= nvals) ? peel : nvals;
52+
assert(peel <= NPY_MAX_INTP);
53+
return (npy_intp)peel;
5354
}
5455

5556
/*
@@ -75,11 +76,12 @@ static NPY_INLINE npy_intp npy_aligned_block_offset(const void *addr,
7576
static NPY_INLINE npy_intp npy_blocked_end(const npy_uintp peel,
7677
const npy_uintp esize,
7778
const npy_uintp vsz,
78-
const npy_uintp nvals) {
79-
npy_uintp ndiff = nvals - peel;
80-
npy_uintp res = (ndiff - ndiff % (vsz / esize));
79+
const npy_uintp nvals)
80+
{
81+
npy_uintp ndiff = nvals - peel;
82+
npy_uintp res = (ndiff - ndiff % (vsz / esize));
8183

82-
assert(nvals >= peel);
83-
assert(res <= NPY_MAX_INTP);
84-
return (npy_intp)(res);
84+
assert(nvals >= peel);
85+
assert(res <= NPY_MAX_INTP);
86+
return (npy_intp)(res);
8587
}

0 commit comments

Comments
 (0)