Skip to content

Commit 424896b

Browse files
authored
Sort includes using clang-format (#129)
* Sort includes using clang-format * Update clang-format-check.yml to version 19 * Update clang-format-check.yml * Update unordered_map_and_set.hpp
1 parent 968e72d commit 424896b

Some content is hidden

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

51 files changed

+113
-88
lines changed

.clang-format

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,32 @@ BinPackParameters: false
88
AllowAllParametersOfDeclarationOnNextLine: true
99
AlignAfterOpenBracket: AlwaysBreak
1010
BreakBeforeBinaryOperators: NonAssignment
11-
SortIncludes: false
11+
SortIncludes: true
1212
CommentPragmas: '^@.+'
1313
BreakStringLiterals: false
1414
PackConstructorInitializers: CurrentLine
15+
# Regroup includes with a priority system
16+
IncludeBlocks: Regroup
17+
IncludeCategories:
18+
# by default, the main header of a cpp will get priority 0
19+
# regex here are sorted by search pattern, not by sort priority
20+
- Regex: "^<ipc\/[^/]*>" # this libraries
21+
Priority: 2 # internal library group
22+
SortPriority: 2
23+
CaseSensitive: true
24+
- Regex: "^<ipc\/.*\/.*>" # this libraries
25+
Priority: 2 # internal library group
26+
SortPriority: 3
27+
CaseSensitive: true
28+
- Regex: "^<(.*\\.h[px]*)|(Eigen\/.*)>"
29+
Priority: 4 # libraries (because they end in .h)
30+
SortPriority: 4
31+
CaseSensitive: false
32+
- Regex: "^<.*"
33+
Priority: 5 # system (without .h, because that is captured by the other group)
34+
SortPriority: 5
35+
CaseSensitive: false
36+
- Regex: ".*" # catch-all for internal files
37+
Priority: 1 # internal file group
38+
SortPriority: 1
39+
CaseSensitive: true

python/.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BasedOnStyle: InheritParentConfig
2+
SortIncludes: false

python/src/utils/eigen_ext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ void define_eigen_ext(py::module_& m)
99
{
1010
m.def(
1111
"project_to_pd",
12+
// clang-format off
1213
&project_to_pd<
1314
double, Eigen::Dynamic, Eigen::Dynamic,
1415
Eigen::ColMajor | Eigen::AutoAlign, Eigen::Dynamic, Eigen::Dynamic>,
16+
// clang-format on
1517
R"ipc_Qu8mg5v7(
1618
Matrix projection onto positive definite cone
1719
@@ -35,9 +37,11 @@ void define_eigen_ext(py::module_& m)
3537

3638
m.def(
3739
"project_to_psd",
40+
// clang-format off
3841
&project_to_psd<
3942
double, Eigen::Dynamic, Eigen::Dynamic,
4043
Eigen::ColMajor | Eigen::AutoAlign, Eigen::Dynamic, Eigen::Dynamic>,
44+
// clang-format on
4145
R"ipc_Qu8mg5v7(
4246
Matrix projection onto positive semi-definite cone
4347

src/ipc/broad_phase/aabb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "aabb.hpp"
22

3-
#include <tbb/parallel_for.h>
43
#include <tbb/blocked_range.h>
4+
#include <tbb/parallel_for.h>
55

66
#include <cfenv>
77

src/ipc/broad_phase/broad_phase.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
#include "broad_phase.hpp"
22

3+
#include <ipc/config.hpp>
34
#include <ipc/broad_phase/brute_force.hpp>
45
#include <ipc/broad_phase/bvh.hpp>
5-
#include <ipc/broad_phase/spatial_hash.hpp>
66
#include <ipc/broad_phase/hash_grid.hpp>
7+
#include <ipc/broad_phase/spatial_hash.hpp>
78
#include <ipc/broad_phase/sweep_and_prune.hpp>
89
#include <ipc/broad_phase/sweep_and_tiniest_queue.hpp>
910
#include <ipc/candidates/candidates.hpp>
1011

11-
#include <ipc/config.hpp>
12-
1312
namespace ipc {
1413

1514
void BroadPhase::build(

src/ipc/broad_phase/brute_force.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#include <ipc/utils/merge_thread_local.hpp>
44

5+
#include <tbb/blocked_range2d.h>
56
#include <tbb/enumerable_thread_specific.h>
67
#include <tbb/parallel_for.h>
7-
#include <tbb/blocked_range2d.h>
88

99
#include <algorithm> // std::min/max
1010

src/ipc/broad_phase/bvh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#include <ipc/utils/merge_thread_local.hpp>
44

5-
#include <tbb/parallel_for.h>
65
#include <tbb/blocked_range.h>
76
#include <tbb/enumerable_thread_specific.h>
7+
#include <tbb/parallel_for.h>
88

99
using namespace std::placeholders;
1010

src/ipc/broad_phase/hash_grid.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include "hash_grid.hpp"
22

33
#include <ipc/broad_phase/voxel_size_heuristic.hpp>
4-
#include <ipc/utils/merge_thread_local.hpp>
54
#include <ipc/utils/logger.hpp>
5+
#include <ipc/utils/merge_thread_local.hpp>
66

7-
#include <tbb/enumerable_thread_specific.h>
87
#include <tbb/blocked_range2d.h>
8+
#include <tbb/enumerable_thread_specific.h>
99
#include <tbb/parallel_for.h>
1010
#include <tbb/parallel_sort.h>
1111

src/ipc/broad_phase/spatial_hash.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// Originally created by Minchen Li.
33
#include "spatial_hash.hpp"
44

5-
#include <ipc/ccd/aabb.hpp>
5+
#include <ipc/config.hpp>
66
#include <ipc/broad_phase/voxel_size_heuristic.hpp>
7+
#include <ipc/ccd/aabb.hpp>
78
#include <ipc/utils/merge_thread_local.hpp>
89

9-
#include <ipc/config.hpp>
10-
1110
#include <tbb/enumerable_thread_specific.h>
1211
#include <tbb/parallel_for.h>
1312
#include <tbb/parallel_sort.h>

src/ipc/broad_phase/spatial_hash.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#pragma once
44

55
#include <ipc/broad_phase/broad_phase.hpp>
6-
#include <ipc/utils/unordered_map_and_set.hpp>
76
#include <ipc/utils/eigen_ext.hpp>
7+
#include <ipc/utils/unordered_map_and_set.hpp>
88

99
#include <vector>
1010

0 commit comments

Comments
 (0)