Warn on unused return values in guidance code, resolves #2686.
https://github.com/Project-OSRM/osrm-backend/pull/2685/files fixes an issue where we did elongate(fstStep, sndStep); instead of newStep = elongate(fstStep, sndStep); we didn't get any warnings. The only way to trigger a warning here is to use ```cpp __attribute__((warn_unused_result)) ``` This changeset does exactly that: for the new guidance code prone to these kind of issue we add such an attribute to the declaration.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/restriction_map.hpp"
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
@@ -46,6 +47,7 @@ class IntersectionGenerator
|
||||
// node reached
|
||||
// from `from_node` via `via_eid`
|
||||
// The resulting candidates have to be analysed for their actual instructions later on.
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection getConnectedRoads(const NodeID from_node, const EdgeID via_eid) const;
|
||||
|
||||
// Merge segregated roads to omit invalid turns in favor of treating segregated roads as
|
||||
@@ -59,6 +61,7 @@ class IntersectionGenerator
|
||||
//
|
||||
// The treatment results in a straight turn angle of 180º rather than a turn angle of approx
|
||||
// 160
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection mergeSegregatedRoads(Intersection intersection) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "extractor/guidance/intersection_handler.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
|
||||
@@ -40,11 +41,17 @@ class MotorwayHandler : public IntersectionHandler
|
||||
Intersection intersection) const override final;
|
||||
|
||||
private:
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection handleSliproads(const NodeID intersection_node_id,
|
||||
Intersection intersection) const;
|
||||
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection fromMotorway(const EdgeID via_edge, Intersection intersection) const;
|
||||
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection fromRamp(const EdgeID via_edge, Intersection intersection) const;
|
||||
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection fallback(Intersection intersection) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef OSRM_GUIDANCE_TOOLKIT_HPP_
|
||||
#define OSRM_GUIDANCE_TOOLKIT_HPP_
|
||||
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/bearing.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
@@ -262,6 +263,7 @@ inline bool requiresNameAnnounced(const std::string &from,
|
||||
// To simplify handling of Left/Right hand turns, we can mirror turns and write an intersection
|
||||
// handler only for one side. The mirror function turns a left-hand turn in a equivalent right-hand
|
||||
// turn and vice versa.
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
inline ConnectedRoad mirror(ConnectedRoad road)
|
||||
{
|
||||
const constexpr DirectionModifier::Enum mirrored_modifiers[] = {DirectionModifier::UTurn,
|
||||
@@ -311,6 +313,7 @@ inline bool hasRoundaboutType(const TurnInstruction instruction)
|
||||
// will be corrected to left|throught, since the final lane is not drivable.
|
||||
// This is in contrast to a situation with lanes:psv:forward=0 (or not set) where left|through|
|
||||
// represents left|through|through
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
inline std::string
|
||||
trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t count_right)
|
||||
{
|
||||
@@ -357,6 +360,7 @@ trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t co
|
||||
// turn:lanes=left|through|through|right
|
||||
// vehicle:lanes=yes|yes|no|yes
|
||||
// bicycle:lanes=yes|no|designated|yes
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
inline std::string applyAccessTokens(std::string lane_string, const std::string &access_tokens)
|
||||
{
|
||||
typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "extractor/guidance/intersection_handler.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
|
||||
@@ -46,15 +47,19 @@ class TurnHandler : public IntersectionHandler
|
||||
const ConnectedRoad &road,
|
||||
const ConnectedRoad &other) const;
|
||||
// Dead end.
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection handleOneWayTurn(Intersection intersection) const;
|
||||
|
||||
// Mode Changes, new names...
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection handleTwoWayTurn(const EdgeID via_edge, Intersection intersection) const;
|
||||
|
||||
// Forks, T intersections and similar
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection handleThreeWayTurn(const EdgeID via_edge, Intersection intersection) const;
|
||||
|
||||
// Handling of turns larger then degree three
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection handleComplexTurn(const EdgeID via_edge, Intersection intersection) const;
|
||||
|
||||
void
|
||||
@@ -64,9 +69,12 @@ class TurnHandler : public IntersectionHandler
|
||||
std::pair<std::size_t, std::size_t> findFork(const EdgeID via_edge,
|
||||
const Intersection &intersection) const;
|
||||
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection assignLeftTurns(const EdgeID via_edge,
|
||||
Intersection intersection,
|
||||
const std::size_t starting_at) const;
|
||||
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection assignRightTurns(const EdgeID via_edge,
|
||||
Intersection intersection,
|
||||
const std::size_t up_to) const;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/guidance/turn_lane_data.hpp"
|
||||
#include "util/attributes.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -13,6 +14,7 @@ namespace guidance
|
||||
namespace lanes
|
||||
{
|
||||
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
LaneDataVector handleNoneValueAtSimpleTurn(LaneDataVector lane_data,
|
||||
const Intersection &intersection);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_DATA_HPP_
|
||||
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -26,6 +27,7 @@ struct TurnLaneData
|
||||
typedef std::vector<TurnLaneData> LaneDataVector;
|
||||
|
||||
// convertes a string given in the OSM format into a TurnLaneData vector
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
LaneDataVector laneDataFromDescription(const TurnLaneDescription &turn_lane_description);
|
||||
|
||||
// Locate A Tag in a lane data vector (if multiple tags are set, the first one found is returned)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/guidance/turn_lanes.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
@@ -41,6 +42,7 @@ class TurnLaneHandler
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const TurnAnalysis &turn_analysis);
|
||||
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection assignTurnLanes(const NodeID at,
|
||||
const EdgeID via_edge,
|
||||
Intersection intersection,
|
||||
@@ -60,17 +62,20 @@ class TurnLaneHandler
|
||||
const Intersection &intersection) const;
|
||||
|
||||
// in case of a simple intersection, assign the lane entries
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection simpleMatchTuplesToTurns(Intersection intersection,
|
||||
const LaneDataVector &lane_data,
|
||||
const LaneDescriptionID lane_string_id,
|
||||
LaneDataIdMap &id_map) const;
|
||||
|
||||
// partition lane data into lane data relevant at current turn and at next turn
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
std::pair<TurnLaneHandler::LaneDataVector, TurnLaneHandler::LaneDataVector> partitionLaneData(
|
||||
const NodeID at, LaneDataVector turn_lane_data, const Intersection &intersection) const;
|
||||
|
||||
// if the current intersections turn string is empty, we check whether there is an incoming
|
||||
// intersection whose turns might be related to this current intersection
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection handleTurnAtPreviousIntersection(const NodeID at,
|
||||
const EdgeID via_edge,
|
||||
Intersection intersection,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_lane_data.hpp"
|
||||
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/guidance/turn_lanes.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
|
||||
@@ -37,6 +38,7 @@ findBestMatchForReverse(const TurnLaneType::Mask &leftmost_tag, const Intersecti
|
||||
bool canMatchTrivially(const Intersection &intersection, const LaneDataVector &lane_data);
|
||||
|
||||
// perform a trivial match on the turn lanes
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection triviallyMatchLanesToTurns(Intersection intersection,
|
||||
const LaneDataVector &lane_data,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
|
||||
Reference in New Issue
Block a user