Skip to content

Commit 5c6e615

Browse files
DennisOSRMnyllet
andauthored
Upgrade clang-format from version 15 to 18 (#7359)
* Upgrade clang-format from version 15 to 19 * Change OSRM backend workflow to use Ubuntu 24.04 not 24.10 * Update clang-format version check in format.sh * Update clang-format version in workflow * Update clang-format version check from 19 to 18 * Fix formatting --------- Co-authored-by: martin nylin <martin.nylin@gmail.com>
1 parent fff162d commit 5c6e615

22 files changed

Lines changed: 108 additions & 127 deletions

.github/workflows/osrm-backend.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -94,33 +94,33 @@ jobs:
9494
token: ${{ secrets.GITHUB_TOKEN }}
9595

9696
format-taginfo-docs:
97-
runs-on: ubuntu-22.04
97+
runs-on: ubuntu-24.04
9898
steps:
99-
- uses: actions/checkout@v4
100-
- name: Use Node.js
101-
uses: actions/setup-node@v4
102-
with:
103-
node-version: 20
104-
- name: Enable Node.js cache
105-
uses: actions/cache@v4
106-
with:
107-
path: ~/.npm
108-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
109-
restore-keys: |
110-
${{ runner.os }}-node-
111-
- name: Prepare environment
112-
run: |
113-
npm ci --ignore-scripts
114-
clang-format-15 --version
115-
- name: Run checks
116-
run: |
117-
./scripts/check_taginfo.py taginfo.json profiles/car.lua
118-
# Check that code formatting is up to date
119-
./scripts/format.sh && ./scripts/error_on_dirty.sh "Run './scripts/format.sh' locally and commit the changes."
120-
node ./scripts/validate_changelog.js
121-
# Check that API documentation is up to date with JSDoc comments in node_osrm.cpp
122-
npm run docs && ./scripts/error_on_dirty.sh "Run 'npm run docs' locally and commit the changes."
123-
npm audit --production
99+
- uses: actions/checkout@v4
100+
- name: Use Node.js
101+
uses: actions/setup-node@v4
102+
with:
103+
node-version: 20
104+
- name: Enable Node.js cache
105+
uses: actions/cache@v4
106+
with:
107+
path: ~/.npm
108+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
109+
restore-keys: |
110+
${{ runner.os }}-node-
111+
- name: Prepare environment
112+
run: |
113+
npm ci --ignore-scripts
114+
clang-format-18 --version
115+
- name: Run checks
116+
run: |
117+
./scripts/check_taginfo.py taginfo.json profiles/car.lua
118+
# Check that code formatting is up to date
119+
./scripts/format.sh && ./scripts/error_on_dirty.sh "Run './scripts/format.sh' locally and commit the changes."
120+
node ./scripts/validate_changelog.js
121+
# Check that API documentation is up to date with JSDoc comments in node_osrm.cpp
122+
npm run docs && ./scripts/error_on_dirty.sh "Run 'npm run docs' locally and commit the changes."
123+
npm audit --production
124124
125125
docker-image-matrix:
126126
strategy:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- FIXED: Fix compilation with gcc >14 in release with LTO. [#7268](https://github.com/Project-OSRM/osrm-backend/issues/7268)
2222
- ADDED: Conditionally prefix custom CMake targets with `osrm_` when built as subproject, and add ALIAS targets for FetchContent compatibility [#7267](https://github.com/Project-OSRM/osrm-backend/issues/7267)
2323
- Misc:
24+
- CHANGED: Upgrade from clang-format-15 to clang-format-18 [#7249](https://github.com/Project-OSRM/osrm-backend/issues/7249)
2425
- ADDED: `--output` / `-o` option to osrm-extract for specifying custom output base path [#4930](https://github.com/Project-OSRM/osrm-backend/issues/4930)
2526
- ADDED: `--list-inputs` option to all OSRM tools to list required/optional input file extensions for deployment scripts [#2865](https://github.com/Project-OSRM/osrm-backend/issues/2865)
2627
- ADDED: `--max-header-size` to override the (automatically) configured maximum header size for osrm-routed [#7336](https://github.com/Project-OSRM/osrm-backend/pull/7336)

include/contractor/query_edge.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ struct QueryEdge
1515
struct EdgeData
1616
{
1717
explicit EdgeData()
18-
: turn_id(0), shortcut(false), weight{0}, duration(0), forward(false),
19-
backward(false), distance{0}
18+
: turn_id(0), shortcut(false), weight{0}, duration(0), forward(false), backward(false),
19+
distance{0}
2020
{
2121
}
2222

include/engine/api/base_api.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ class BaseAPI
6767
std::transform(candidates.begin(),
6868
candidates.end(),
6969
seg_hints.begin(),
70-
[this](const auto &phantom) {
71-
return SegmentHint{phantom, facade.GetCheckSum()};
72-
});
70+
[this](const auto &phantom)
71+
{ return SegmentHint{phantom, facade.GetCheckSum()}; });
7372

7473
return json::makeWaypoint(
7574
snapped_location,
@@ -135,9 +134,8 @@ class BaseAPI
135134
std::transform(candidates.begin(),
136135
candidates.end(),
137136
seg_hints.begin(),
138-
[this](const auto &phantom) {
139-
return SegmentHint{phantom, facade.GetCheckSum()};
140-
});
137+
[this](const auto &phantom)
138+
{ return SegmentHint{phantom, facade.GetCheckSum()}; });
141139
Hint hint{std::move(seg_hints)};
142140
hint_string = builder->CreateString(hint.ToBase64());
143141
}

include/engine/api/match_parameters.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ struct MatchParameters : public RouteParameters
7878
bool tidy_,
7979
const std::vector<std::size_t> &waypoints_,
8080
Args &&...args_)
81-
: RouteParameters{std::forward<Args>(args_)..., waypoints_}, timestamps{std::move(
82-
timestamps_)},
83-
gaps(gaps_), tidy(tidy_)
81+
: RouteParameters{std::forward<Args>(args_)..., waypoints_},
82+
timestamps{std::move(timestamps_)}, gaps(gaps_), tidy(tidy_)
8483
{
8584
}
8685

include/engine/api/route_parameters.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ struct RouteParameters : public BaseParameters
141141
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
142142
number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_},
143143
annotations_type{annotations_ ? AnnotationsType::All : AnnotationsType::None},
144-
geometries{geometries_}, overview{overview_},
145-
continue_straight{continue_straight_}, waypoints{std::move(waypoints_)}
144+
geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_},
145+
waypoints{std::move(waypoints_)}
146146
{
147147
}
148148

@@ -157,10 +157,10 @@ struct RouteParameters : public BaseParameters
157157
std::vector<std::size_t> waypoints_,
158158
Args &&...args_)
159159
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
160-
number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_ !=
161-
AnnotationsType::None},
162-
annotations_type{annotations_}, geometries{geometries_}, overview{overview_},
163-
continue_straight{continue_straight_}, waypoints{std::move(waypoints_)}
160+
number_of_alternatives{alternatives_ ? 1u : 0u},
161+
annotations{annotations_ != AnnotationsType::None}, annotations_type{annotations_},
162+
geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_},
163+
waypoints{std::move(waypoints_)}
164164
{
165165
}
166166

include/engine/api/trip_parameters.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ struct TripParameters : public RouteParameters
6060
DestinationType destination_,
6161
bool roundtrip_,
6262
Args &&...args_)
63-
: RouteParameters{std::forward<Args>(args_)...}, source{source_},
64-
destination{destination_}, roundtrip{roundtrip_}
63+
: RouteParameters{std::forward<Args>(args_)...}, source{source_}, destination{destination_},
64+
roundtrip{roundtrip_}
6565
{
6666
}
6767

include/engine/phantom_node.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,15 @@ namespace osrm::engine
4444
struct PhantomNode
4545
{
4646
PhantomNode()
47-
: forward_segment_id{SPECIAL_SEGMENTID, false}, reverse_segment_id{SPECIAL_SEGMENTID,
48-
false},
49-
forward_weight(INVALID_EDGE_WEIGHT),
47+
: forward_segment_id{SPECIAL_SEGMENTID, false},
48+
reverse_segment_id{SPECIAL_SEGMENTID, false}, forward_weight(INVALID_EDGE_WEIGHT),
5049
reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset{0}, reverse_weight_offset{0},
5150
forward_distance(INVALID_EDGE_DISTANCE), reverse_distance(INVALID_EDGE_DISTANCE),
5251
forward_distance_offset{0}, reverse_distance_offset{0},
5352
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
5453
forward_duration_offset{0}, reverse_duration_offset{0},
55-
component({INVALID_COMPONENTID, 0}),
56-
fwd_segment_position(0), is_valid_forward_source{false}, is_valid_forward_target{false},
54+
component({INVALID_COMPONENTID, 0}), fwd_segment_position(0),
55+
is_valid_forward_source{false}, is_valid_forward_target{false},
5756
is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0)
5857

5958
{

include/engine/routing_algorithms/routing_base_mld.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
313313
const auto &cell =
314314
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
315315
auto destination = cell.GetDestinationNodes().begin();
316-
auto distance = [&cell, node = heapNode.node ]() -> auto
316+
auto distance = [&cell, node = heapNode.node]() -> auto
317317
{
318318
if constexpr (IS_MAP_MATCHING)
319319
{
@@ -325,8 +325,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
325325
boost::ignore_unused(cell, node);
326326
return 0;
327327
}
328-
}
329-
();
328+
}();
330329
for (auto shortcut_weight : cell.GetOutWeight(heapNode.node))
331330
{
332331
BOOST_ASSERT(destination != cell.GetDestinationNodes().end());
@@ -361,7 +360,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
361360
const auto &cell =
362361
cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
363362
auto source = cell.GetSourceNodes().begin();
364-
auto distance = [&cell, node = heapNode.node ]() -> auto
363+
auto distance = [&cell, node = heapNode.node]() -> auto
365364
{
366365
if constexpr (IS_MAP_MATCHING)
367366
{
@@ -373,8 +372,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
373372
boost::ignore_unused(cell, node);
374373
return 0;
375374
}
376-
}
377-
();
375+
}();
378376
for (auto shortcut_weight : cell.GetInWeight(heapNode.node))
379377
{
380378
BOOST_ASSERT(source != cell.GetSourceNodes().end());

include/extractor/edge_based_node_segment.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ namespace osrm::extractor
1818
struct EdgeBasedNodeSegment
1919
{
2020
EdgeBasedNodeSegment()
21-
: forward_segment_id{SPECIAL_SEGMENTID, false}, reverse_segment_id{SPECIAL_SEGMENTID,
22-
false},
23-
u(SPECIAL_NODEID), v(SPECIAL_NODEID),
21+
: forward_segment_id{SPECIAL_SEGMENTID, false},
22+
reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), v(SPECIAL_NODEID),
2423
fwd_segment_position(std::numeric_limits<unsigned short>::max() >>
2524
1), // >> 1 because we've only got 15 bits
2625
is_startpoint(false)

0 commit comments

Comments
 (0)