Skip to content

Commit babdced

Browse files
authored
Replace GCC-specific attribute with [[nodiscard]] attribute (#6899)
1 parent 21607e0 commit babdced

20 files changed

+98
-157
lines changed

include/engine/guidance/collapse_turns.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef OSRM_ENGINE_GUIDANCE_COLLAPSE_HPP
22

33
#include "engine/guidance/route_step.hpp"
4-
#include "util/attributes.hpp"
54

65
#include <type_traits>
76
#include <vector>
@@ -12,16 +11,15 @@ namespace osrm::engine::guidance
1211
// Multiple possible reasons can result in unnecessary/confusing instructions
1312
// Collapsing such turns into a single turn instruction, we give a clearer
1413
// set of instructions that is not cluttered by unnecessary turns/name changes.
15-
OSRM_ATTR_WARN_UNUSED
16-
std::vector<RouteStep> collapseTurnInstructions(std::vector<RouteStep> steps);
14+
[[nodiscard]] std::vector<RouteStep> collapseTurnInstructions(std::vector<RouteStep> steps);
1715

1816
// Multiple possible reasons can result in unnecessary/confusing instructions
1917
// A prime example would be a segregated intersection. Turning around at this
2018
// intersection would result in two instructions to turn left.
2119
// Collapsing such turns into a single turn instruction, we give a clearer
2220
// set of instructions that is not cluttered by unnecessary turns/name changes.
23-
OSRM_ATTR_WARN_UNUSED
24-
std::vector<RouteStep> collapseSegregatedTurnInstructions(std::vector<RouteStep> steps);
21+
[[nodiscard]] std::vector<RouteStep>
22+
collapseSegregatedTurnInstructions(std::vector<RouteStep> steps);
2523

2624
// A combined turn is a set of two instructions that actually form a single turn, as far as we
2725
// perceive it. A u-turn consisting of two left turns is one such example. But there are also lots

include/engine/guidance/collapsing_utility.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "guidance/turn_instruction.hpp"
55
#include "engine/guidance/route_step.hpp"
6-
#include "util/attributes.hpp"
76
#include "util/bearing.hpp"
87
#include "util/guidance/name_announcements.hpp"
98

@@ -166,8 +165,7 @@ inline bool areSameSide(const RouteStep &lhs, const RouteStep &rhs)
166165
}
167166

168167
// do this after invalidating any steps to compress the step array again
169-
OSRM_ATTR_WARN_UNUSED
170-
inline std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> steps)
168+
[[nodiscard]] inline std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> steps)
171169
{
172170
// finally clean up the post-processed instructions.
173171
// Remove all invalid instructions from the set of instructions.

include/engine/guidance/lane_processing.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#ifndef OSRM_ENGINE_GUIDANCE_LANE_PROCESSING_HPP_
22
#define OSRM_ENGINE_GUIDANCE_LANE_PROCESSING_HPP_
33

4-
#include <vector>
5-
64
#include "engine/guidance/route_step.hpp"
7-
#include "util/attributes.hpp"
5+
6+
#include <vector>
87

98
namespace osrm::engine::guidance
109
{
@@ -14,9 +13,9 @@ namespace osrm::engine::guidance
1413
// we anticipate lane changes emitting only matching lanes early on.
1514
// the second parameter describes the duration that we feel two segments need to be apart to count
1615
// as separate maneuvers.
17-
OSRM_ATTR_WARN_UNUSED
18-
std::vector<RouteStep> anticipateLaneChange(std::vector<RouteStep> steps,
19-
const double min_distance_needed_for_lane_change = 200);
16+
[[nodiscard]] std::vector<RouteStep>
17+
anticipateLaneChange(std::vector<RouteStep> steps,
18+
const double min_distance_needed_for_lane_change = 200);
2019

2120
} // namespace osrm::engine::guidance
2221

include/engine/guidance/post_processing.hpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
#include "engine/guidance/leg_geometry.hpp"
66
#include "engine/guidance/route_step.hpp"
77
#include "engine/phantom_node.hpp"
8-
#include "util/attributes.hpp"
98

109
#include <vector>
1110

1211
namespace osrm::engine::guidance
1312
{
1413

1514
// passed as none-reference to modify in-place and move out again
16-
OSRM_ATTR_WARN_UNUSED
17-
std::vector<RouteStep> handleRoundabouts(std::vector<RouteStep> steps);
15+
[[nodiscard]] std::vector<RouteStep> handleRoundabouts(std::vector<RouteStep> steps);
1816

1917
// trim initial/final segment of very short length.
2018
// This function uses in/out parameter passing to modify both steps and geometry in place.
@@ -24,23 +22,21 @@ std::vector<RouteStep> handleRoundabouts(std::vector<RouteStep> steps);
2422
void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry);
2523

2624
// assign relative locations to depart/arrive instructions
27-
OSRM_ATTR_WARN_UNUSED
28-
std::vector<RouteStep> assignRelativeLocations(std::vector<RouteStep> steps,
29-
const LegGeometry &geometry,
30-
const PhantomNode &source_node,
31-
const PhantomNode &target_node);
25+
[[nodiscard]] std::vector<RouteStep> assignRelativeLocations(std::vector<RouteStep> steps,
26+
const LegGeometry &geometry,
27+
const PhantomNode &source_node,
28+
const PhantomNode &target_node);
3229

3330
// collapse suppressed instructions remaining into intersections array
34-
OSRM_ATTR_WARN_UNUSED
35-
std::vector<RouteStep> buildIntersections(std::vector<RouteStep> steps);
31+
[[nodiscard]] std::vector<RouteStep> buildIntersections(std::vector<RouteStep> steps);
3632

3733
// postProcess will break the connection between the leg geometry
3834
// for which a segment is supposed to represent exactly the coordinates
3935
// between routing maneuvers and the route steps itself.
4036
// If required, we can get both in sync again using this function.
4137
// Move in LegGeometry for modification in place.
42-
OSRM_ATTR_WARN_UNUSED
43-
LegGeometry resyncGeometry(LegGeometry leg_geometry, const std::vector<RouteStep> &steps);
38+
[[nodiscard]] LegGeometry resyncGeometry(LegGeometry leg_geometry,
39+
const std::vector<RouteStep> &steps);
4440

4541
/**
4642
* Apply maneuver override relations to the selected route.

include/engine/guidance/verbosity_reduction.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define OSRM_ENGINE_GUIDANCE_VERBOSITY_REDUCTION_HPP_
33

44
#include "engine/guidance/route_step.hpp"
5-
#include "util/attributes.hpp"
65

76
#include <vector>
87

@@ -13,8 +12,7 @@ namespace osrm::engine::guidance
1312
// to announce them. All these that are not collapsed into a single turn (think segregated
1413
// intersection) have to be checked for the length they are active in. If they are active for a
1514
// short distance only, we don't announce them
16-
OSRM_ATTR_WARN_UNUSED
17-
std::vector<RouteStep> suppressShortNameSegments(std::vector<RouteStep> steps);
15+
[[nodiscard]] std::vector<RouteStep> suppressShortNameSegments(std::vector<RouteStep> steps);
1816

1917
} // namespace osrm::engine::guidance
2018

include/extractor/intersection/coordinate_extractor.hpp

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#ifndef OSRM_EXTRACTOR_INTERSECTION_COORDINATE_EXTRACTOR_HPP_
22
#define OSRM_EXTRACTOR_INTERSECTION_COORDINATE_EXTRACTOR_HPP_
33

4-
#include <utility>
5-
#include <vector>
6-
74
#include "extractor/compressed_edge_container.hpp"
85
#include "extractor/query_node.hpp"
96

10-
#include "util/attributes.hpp"
117
#include "util/coordinate.hpp"
128
#include "util/node_based_graph.hpp"
139

10+
#include <utility>
11+
#include <vector>
12+
1413
namespace osrm::extractor::intersection
1514
{
1615

@@ -27,17 +26,16 @@ class CoordinateExtractor
2726
* Note: The segment between intersection and turn coordinate can be zero, if the OSM modelling
2827
* is unfortunate. See https://github.com/Project-OSRM/osrm-backend/issues/3470
2928
*/
30-
OSRM_ATTR_WARN_UNUSED
31-
util::Coordinate GetCoordinateAlongRoad(const NodeID intersection_node,
32-
const EdgeID turn_edge,
33-
const bool traversed_in_reverse,
34-
const NodeID to_node,
35-
const std::uint8_t number_of_in_lanes) const;
29+
[[nodiscard]] util::Coordinate
30+
GetCoordinateAlongRoad(const NodeID intersection_node,
31+
const EdgeID turn_edge,
32+
const bool traversed_in_reverse,
33+
const NodeID to_node,
34+
const std::uint8_t number_of_in_lanes) const;
3635

3736
// Given a set of precomputed coordinates, select the representative coordinate along the road
3837
// that best describes the turn
39-
OSRM_ATTR_WARN_UNUSED
40-
util::Coordinate
38+
[[nodiscard]] util::Coordinate
4139
ExtractRepresentativeCoordinate(const NodeID intersection_node,
4240
const EdgeID turn_edge,
4341
const bool traversed_in_reverse,
@@ -47,28 +45,26 @@ class CoordinateExtractor
4745

4846
// instead of finding only a single coordinate, we can also list all coordinates along a
4947
// road.
50-
OSRM_ATTR_WARN_UNUSED std::vector<util::Coordinate>
48+
[[nodiscard]] std::vector<util::Coordinate>
5149
GetCoordinatesAlongRoad(const NodeID intersection_node,
5250
const EdgeID turn_edge,
5351
const bool traversed_in_reverse,
5452
const NodeID to_node) const;
5553

5654
// wrapper in case of normal forward edges (traversed_in_reverse = false, to_node =
5755
// node_based_graph.GetTarget(turn_edge)
58-
OSRM_ATTR_WARN_UNUSED
59-
std::vector<util::Coordinate> GetForwardCoordinatesAlongRoad(const NodeID from,
60-
const EdgeID turn_edge) const;
56+
[[nodiscard]] std::vector<util::Coordinate>
57+
GetForwardCoordinatesAlongRoad(const NodeID from, const EdgeID turn_edge) const;
6158

6259
// a less precise way to compute coordinates along a route. Due to the heavy interaction of
6360
// graph traversal and turn instructions, we often don't care for high precision. We only want
6461
// to check for available connections in order, or find (with room for error) the straightmost
6562
// turn. This function will offer a bit more error potential but allow for much higher
6663
// performance
67-
OSRM_ATTR_WARN_UNUSED
68-
util::Coordinate GetCoordinateCloseToTurn(const NodeID from_node,
69-
const EdgeID turn_edge,
70-
const bool traversed_in_reverse,
71-
const NodeID to_node) const;
64+
[[nodiscard]] util::Coordinate GetCoordinateCloseToTurn(const NodeID from_node,
65+
const EdgeID turn_edge,
66+
const bool traversed_in_reverse,
67+
const NodeID to_node) const;
7268

7369
/* When extracting the coordinates, we first extract all coordinates. We don't care about most
7470
* of them, though.
@@ -90,22 +86,19 @@ class CoordinateExtractor
9086
* The optional length cache needs to store the accumulated distance up to the respective
9187
* coordinate index [0,d(0,1),...]
9288
*/
93-
OSRM_ATTR_WARN_UNUSED
94-
std::vector<util::Coordinate>
89+
[[nodiscard]] std::vector<util::Coordinate>
9590
TrimCoordinatesToLength(std::vector<util::Coordinate> coordinates,
9691
const double desired_length,
9792
const std::vector<double> &length_cache = {}) const;
9893

99-
OSRM_ATTR_WARN_UNUSED
100-
std::vector<double> PrepareLengthCache(const std::vector<util::Coordinate> &coordinates,
101-
const double limit) const;
94+
[[nodiscard]] std::vector<double>
95+
PrepareLengthCache(const std::vector<util::Coordinate> &coordinates, const double limit) const;
10296

10397
/* when looking at a set of coordinates, this function allows trimming the vector to a smaller,
10498
* only containing coordinates up to a given distance along the path. The last coordinate might
10599
* be interpolated
106100
*/
107-
OSRM_ATTR_WARN_UNUSED
108-
std::vector<util::Coordinate>
101+
[[nodiscard]] std::vector<util::Coordinate>
109102
TrimCoordinatesByLengthFront(std::vector<util::Coordinate> coordinates,
110103
const double desired_length) const;
111104

@@ -130,10 +123,9 @@ class CoordinateExtractor
130123
*
131124
* for fixpoint `b`, vector_base `d` and vector_head `e`
132125
*/
133-
OSRM_ATTR_WARN_UNUSED
134-
util::Coordinate GetCorrectedCoordinate(const util::Coordinate fixpoint,
135-
const util::Coordinate vector_base,
136-
const util::Coordinate vector_head) const;
126+
[[nodiscard]] util::Coordinate GetCorrectedCoordinate(const util::Coordinate fixpoint,
127+
const util::Coordinate vector_base,
128+
const util::Coordinate vector_head) const;
137129

138130
/* generate a uniform vector of coordinates in same range distances
139131
*
@@ -143,8 +135,7 @@ class CoordinateExtractor
143135
* Into:
144136
* x -- x -- x -- x -- x - x
145137
*/
146-
OSRM_ATTR_WARN_UNUSED
147-
std::vector<util::Coordinate>
138+
[[nodiscard]] std::vector<util::Coordinate>
148139
SampleCoordinates(const std::vector<util::Coordinate> &coordinates,
149140
const double length,
150141
const double rate) const;

include/guidance/motorway_handler.hpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "guidance/intersection_handler.hpp"
88
#include "guidance/is_through_street.hpp"
99

10-
#include "util/attributes.hpp"
1110
#include "util/node_based_graph.hpp"
1211

1312
#include <vector>
@@ -42,18 +41,14 @@ class MotorwayHandler final : public IntersectionHandler
4241
Intersection intersection) const override final;
4342

4443
private:
45-
OSRM_ATTR_WARN_UNUSED
46-
Intersection handleSliproads(const NodeID intersection_node_id,
47-
Intersection intersection) const;
44+
[[nodiscard]] Intersection handleSliproads(const NodeID intersection_node_id,
45+
Intersection intersection) const;
4846

49-
OSRM_ATTR_WARN_UNUSED
50-
Intersection fromMotorway(const EdgeID via_edge, Intersection intersection) const;
47+
[[nodiscard]] Intersection fromMotorway(const EdgeID via_edge, Intersection intersection) const;
5148

52-
OSRM_ATTR_WARN_UNUSED
53-
Intersection fromRamp(const EdgeID via_edge, Intersection intersection) const;
49+
[[nodiscard]] Intersection fromRamp(const EdgeID via_edge, Intersection intersection) const;
5450

55-
OSRM_ATTR_WARN_UNUSED
56-
Intersection fallback(Intersection intersection) const;
51+
[[nodiscard]] Intersection fallback(Intersection intersection) const;
5752
};
5853

5954
} // namespace osrm::guidance

include/guidance/parsing_toolkit.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include <boost/algorithm/string.hpp>
88
#include <boost/tokenizer.hpp>
99

10-
#include "util/attributes.hpp"
11-
1210
namespace osrm::extractor::guidance
1311
{
1412

@@ -21,8 +19,7 @@ namespace osrm::extractor::guidance
2119
// will be corrected to left|throught, since the final lane is not drivable.
2220
// This is in contrast to a situation with lanes:psv:forward=0 (or not set) where left|through|
2321
// represents left|through|through
24-
OSRM_ATTR_WARN_UNUSED
25-
inline std::string
22+
[[nodiscard]] inline std::string
2623
trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t count_right)
2724
{
2825
if (count_left)
@@ -68,8 +65,8 @@ trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t co
6865
// turn:lanes=left|through|through|right
6966
// vehicle:lanes=yes|yes|no|yes
7067
// bicycle:lanes=yes|no|designated|yes
71-
OSRM_ATTR_WARN_UNUSED
72-
inline std::string applyAccessTokens(std::string lane_string, const std::string &access_tokens)
68+
[[nodiscard]] inline std::string applyAccessTokens(std::string lane_string,
69+
const std::string &access_tokens)
7370
{
7471
using tokenizer = boost::tokenizer<boost::char_separator<char>>;
7572
boost::char_separator<char> sep("|", "", boost::keep_empty_tokens);

include/guidance/turn_analysis.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "guidance/turn_classification.hpp"
1818
#include "guidance/turn_handler.hpp"
1919

20-
#include "util/attributes.hpp"
2120
#include "util/node_based_graph.hpp"
2221

2322
#include <cstdint>
@@ -47,13 +46,11 @@ class TurnAnalysis
4746

4847
/* Full Analysis Process for a single node/edge combination. Use with caution, as the process is
4948
* relatively expensive */
50-
OSRM_ATTR_WARN_UNUSED
51-
Intersection operator()(const NodeID node_prior_to_intersection,
52-
const EdgeID entering_via_edge) const;
49+
[[nodiscard]] Intersection operator()(const NodeID node_prior_to_intersection,
50+
const EdgeID entering_via_edge) const;
5351

5452
// Select turn types based on the intersection shape
55-
OSRM_ATTR_WARN_UNUSED
56-
Intersection
53+
[[nodiscard]] Intersection
5754
AssignTurnTypes(const NodeID from_node,
5855
const EdgeID via_eid,
5956
const extractor::intersection::IntersectionView &intersection) const;

0 commit comments

Comments
 (0)