From 57f7c157ed22c71529146cb027872664b4bc89aa Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Wed, 31 Aug 2022 23:39:47 +0200 Subject: [PATCH] Update CI to use clang-tidy 14 (#6353) --- .clang-tidy | 2 ++ .github/workflows/osrm-backend.yml | 6 +++--- include/engine/api/table_api.hpp | 2 ++ include/engine/datafacade/algorithm_datafacade.hpp | 4 ++++ include/engine/routing_algorithms.hpp | 2 ++ include/extractor/raster_source.hpp | 2 +- include/partitioner/partition_graph.hpp | 10 +++++----- include/storage/view_factory.hpp | 3 --- include/util/dist_table_wrapper.hpp | 2 +- include/util/filtered_graph.hpp | 4 ++-- src/engine/datafacade/mmap_memory_allocator.cpp | 2 +- src/engine/guidance/post_processing.cpp | 2 -- src/extractor/intersection/coordinate_extractor.cpp | 2 -- src/guidance/intersection_handler.cpp | 2 -- src/guidance/motorway_handler.cpp | 1 - src/guidance/roundabout_handler.cpp | 2 -- .../segregated_intersection_classification.cpp | 2 -- src/guidance/sliproad_handler.cpp | 1 - src/guidance/turn_analysis.cpp | 2 -- src/guidance/turn_handler.cpp | 1 - src/partitioner/partitioner.cpp | 3 --- src/server/connection.cpp | 2 +- 22 files changed, 24 insertions(+), 35 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index dbaf8536fe1..1c87f870275 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -12,6 +12,7 @@ Checks: > -bugprone-unhandled-self-assignment, -bugprone-forward-declaration-namespace, -bugprone-sizeof-expression, + -bugprone-throw-keyword-missing, -clang-analyzer-*, -clang-diagnostic-deprecated-declarations, -clang-diagnostic-constant-conversion, @@ -64,6 +65,7 @@ Checks: > -readability-else-after-return, -readability-inconsistent-declaration-parameter-name, -readability-isolate-declaration, + -readability-identifier-length, -readability-redundant-declaration, -readability-uppercase-literal-suffix, -readability-named-parameter, diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index 3bb854e0900..5264bfaff69 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -145,11 +145,11 @@ jobs: - name: clang-11.0-debug-clang-tidy continue-on-error: false node: 12 - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 BUILD_TOOLS: ON BUILD_TYPE: Debug - CCOMPILER: clang-11 - CXXCOMPILER: clang++-11 + CCOMPILER: clang-14 + CXXCOMPILER: clang++-14 CUCUMBER_TIMEOUT: 60000 ENABLE_CLANG_TIDY: ON diff --git a/include/engine/api/table_api.hpp b/include/engine/api/table_api.hpp index c7a9dba837d..cf6bac1db4b 100644 --- a/include/engine/api/table_api.hpp +++ b/include/engine/api/table_api.hpp @@ -32,6 +32,8 @@ namespace api class TableAPI final : public BaseAPI { public: + virtual ~TableAPI() = default; + struct TableCellRef { TableCellRef(const std::size_t &row, const std::size_t &column) : row{row}, column{column} diff --git a/include/engine/datafacade/algorithm_datafacade.hpp b/include/engine/datafacade/algorithm_datafacade.hpp index 4ccbf5af308..c9337f079c8 100644 --- a/include/engine/datafacade/algorithm_datafacade.hpp +++ b/include/engine/datafacade/algorithm_datafacade.hpp @@ -31,6 +31,8 @@ template <> class AlgorithmDataFacade using EdgeData = contractor::QueryEdge::EdgeData; using EdgeRange = util::filtered_range>; + virtual ~AlgorithmDataFacade() = default; + // search graph access virtual unsigned GetNumberOfNodes() const = 0; @@ -66,6 +68,8 @@ template <> class AlgorithmDataFacade using EdgeData = customizer::EdgeBasedGraphEdgeData; using EdgeRange = util::range; + virtual ~AlgorithmDataFacade() = default; + // search graph access virtual unsigned GetNumberOfNodes() const = 0; diff --git a/include/engine/routing_algorithms.hpp b/include/engine/routing_algorithms.hpp index 6f41b0be334..f3610bbb2a0 100644 --- a/include/engine/routing_algorithms.hpp +++ b/include/engine/routing_algorithms.hpp @@ -19,6 +19,8 @@ namespace engine class RoutingAlgorithmsInterface { public: + virtual ~RoutingAlgorithmsInterface() = default; + virtual InternalManyRoutesResult AlternativePathSearch(const PhantomEndpointCandidates &endpoint_candidates, unsigned number_of_alternatives) const = 0; diff --git a/include/extractor/raster_source.hpp b/include/extractor/raster_source.hpp index e910892520c..aa6e2c97b39 100644 --- a/include/extractor/raster_source.hpp +++ b/include/extractor/raster_source.hpp @@ -58,7 +58,7 @@ class RasterGrid for (unsigned int y = 0; y < ydim; y++) { // read one line from file. - file_reader.ReadLine(&buffer[0], xdim * 11); + file_reader.ReadLine(buffer.data(), xdim * 11); boost::algorithm::trim(buffer); std::vector result; diff --git a/include/partitioner/partition_graph.hpp b/include/partitioner/partition_graph.hpp index 3b2d60e96f3..21c3556c1a7 100644 --- a/include/partitioner/partition_graph.hpp +++ b/include/partitioner/partition_graph.hpp @@ -125,13 +125,13 @@ template class RemappableGraph NodeID GetID(const NodeT &node) const { - BOOST_ASSERT(&node >= &nodes[0] && &node <= &nodes.back()); - return (&node - &nodes[0]); + BOOST_ASSERT(&node >= nodes.data() && &node <= &nodes.back()); + return (&node - nodes.data()); } EdgeID GetID(const EdgeT &edge) const { - BOOST_ASSERT(&edge >= &edges[0] && &edge <= &edges.back()); - return (&edge - &edges[0]); + BOOST_ASSERT(&edge >= edges.data() && &edge <= &edges.back()); + return (&edge - edges.data()); } NodeIterator Begin() { return nodes.begin(); } @@ -142,7 +142,7 @@ template class RemappableGraph // removes the edges from the graph that return true for the filter, returns new end template auto RemoveEdges(NodeT &node, FilterT filter) { - BOOST_ASSERT(&node >= &nodes[0] && &node <= &nodes.back()); + BOOST_ASSERT(&node >= nodes.data() && &node <= &nodes.back()); // required since we are not on std++17 yet, otherwise we are missing an argument_type const auto negate_filter = [&](const EdgeT &edge) { return !filter(edge); }; const auto center = std::stable_partition(BeginEdges(node), EndEdges(node), negate_filter); diff --git a/include/storage/view_factory.hpp b/include/storage/view_factory.hpp index 41ebf4283f1..bbc490ce39f 100644 --- a/include/storage/view_factory.hpp +++ b/include/storage/view_factory.hpp @@ -36,9 +36,6 @@ #include "util/vector_view.hpp" #include "util/filtered_graph.hpp" -#include "util/packed_vector.hpp" -#include "util/vector_view.hpp" - namespace osrm { namespace storage diff --git a/include/util/dist_table_wrapper.hpp b/include/util/dist_table_wrapper.hpp index 8344a317817..8d67747e87d 100644 --- a/include/util/dist_table_wrapper.hpp +++ b/include/util/dist_table_wrapper.hpp @@ -25,7 +25,7 @@ template class DistTableWrapper DistTableWrapper(std::vector table, std::size_t number_of_nodes) : table_(std::move(table)), number_of_nodes_(number_of_nodes) { - BOOST_ASSERT_MSG(table.size() == 0, "table is empty"); + BOOST_ASSERT_MSG(!table_.empty(), "table is empty"); BOOST_ASSERT_MSG(number_of_nodes_ * number_of_nodes_ <= table_.size(), "number_of_nodes_ is invalid"); } diff --git a/include/util/filtered_graph.hpp b/include/util/filtered_graph.hpp index 3efdf7b9bd4..55c2d047e19 100644 --- a/include/util/filtered_graph.hpp +++ b/include/util/filtered_graph.hpp @@ -126,8 +126,8 @@ class FilteredGraphImpl, Ownership> FilteredGraphImpl() = default; - FilteredGraphImpl(Graph graph, Vector edge_filter_) - : graph(std::move(graph)), edge_filter(std::move(edge_filter_)) + FilteredGraphImpl(Graph graph_, Vector edge_filter_) + : graph(std::move(graph_)), edge_filter(std::move(edge_filter_)) { BOOST_ASSERT(edge_filter.empty() || edge_filter.size() == graph.GetNumberOfEdges()); } diff --git a/src/engine/datafacade/mmap_memory_allocator.cpp b/src/engine/datafacade/mmap_memory_allocator.cpp index 38038656ca2..765b05d3127 100644 --- a/src/engine/datafacade/mmap_memory_allocator.cpp +++ b/src/engine/datafacade/mmap_memory_allocator.cpp @@ -39,7 +39,7 @@ MMapMemoryAllocator::MMapMemoryAllocator(const storage::StorageConfig &config) // prior to C++17 (which we're not using), those return a `const char *`, // which isn't compatible with the `char *` that AllocatedRegion expects // for it's memory_ptr - allocated_regions.push_back({&(rtree_filename[0]), std::move(fake_layout)}); + allocated_regions.push_back({rtree_filename.data(), std::move(fake_layout)}); } auto files = storage.GetStaticFiles(); diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index ac73e75b762..8b18bcae27e 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -15,8 +15,6 @@ #include #include -#include "engine/guidance/collapsing_utility.hpp" - #include #include #include diff --git a/src/extractor/intersection/coordinate_extractor.cpp b/src/extractor/intersection/coordinate_extractor.cpp index 18199a79d56..ea99613fc85 100644 --- a/src/extractor/intersection/coordinate_extractor.cpp +++ b/src/extractor/intersection/coordinate_extractor.cpp @@ -11,8 +11,6 @@ #include "util/bearing.hpp" #include "util/coordinate_calculation.hpp" -using osrm::util::angularDeviation; - namespace osrm { namespace extractor diff --git a/src/guidance/intersection_handler.cpp b/src/guidance/intersection_handler.cpp index c2142bacca7..80993fb8905 100644 --- a/src/guidance/intersection_handler.cpp +++ b/src/guidance/intersection_handler.cpp @@ -7,13 +7,11 @@ #include "util/log.hpp" #include "util/bearing.hpp" -#include "util/coordinate_calculation.hpp" #include #include using EdgeData = osrm::util::NodeBasedDynamicGraph::EdgeData; -using osrm::guidance::getTurnDirection; using osrm::util::angularDeviation; namespace osrm diff --git a/src/guidance/motorway_handler.cpp b/src/guidance/motorway_handler.cpp index 4094a0d6a0e..8fc0e4b2a31 100644 --- a/src/guidance/motorway_handler.cpp +++ b/src/guidance/motorway_handler.cpp @@ -11,7 +11,6 @@ #include -using osrm::guidance::getTurnDirection; using osrm::util::angularDeviation; namespace osrm diff --git a/src/guidance/roundabout_handler.cpp b/src/guidance/roundabout_handler.cpp index 8e9f9f0b426..13501fbfbbf 100644 --- a/src/guidance/roundabout_handler.cpp +++ b/src/guidance/roundabout_handler.cpp @@ -15,8 +15,6 @@ #include -using osrm::guidance::getTurnDirection; - namespace osrm { namespace guidance diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index e0d60381c72..b87d19a350f 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -6,8 +6,6 @@ #include "util/coordinate_calculation.hpp" #include -using osrm::guidance::getTurnDirection; - namespace osrm { namespace guidance diff --git a/src/guidance/sliproad_handler.cpp b/src/guidance/sliproad_handler.cpp index 569cb640502..acc3009785c 100644 --- a/src/guidance/sliproad_handler.cpp +++ b/src/guidance/sliproad_handler.cpp @@ -12,7 +12,6 @@ #include -using osrm::guidance::getTurnDirection; using osrm::util::angularDeviation; namespace osrm diff --git a/src/guidance/turn_analysis.cpp b/src/guidance/turn_analysis.cpp index 0c7463bfe72..57f68ec2bad 100644 --- a/src/guidance/turn_analysis.cpp +++ b/src/guidance/turn_analysis.cpp @@ -10,8 +10,6 @@ #include #include -using osrm::guidance::getTurnDirection; - namespace osrm { namespace guidance diff --git a/src/guidance/turn_handler.cpp b/src/guidance/turn_handler.cpp index 35ee3b13904..f7b28132dac 100644 --- a/src/guidance/turn_handler.cpp +++ b/src/guidance/turn_handler.cpp @@ -11,7 +11,6 @@ #include #include -using osrm::guidance::getTurnDirection; using osrm::util::angularDeviation; namespace diff --git a/src/partitioner/partitioner.cpp b/src/partitioner/partitioner.cpp index 63a1a7fc26f..bb37d52c50e 100644 --- a/src/partitioner/partitioner.cpp +++ b/src/partitioner/partitioner.cpp @@ -29,9 +29,6 @@ #include #include -#include "util/geojson_debug_logger.hpp" -#include "util/geojson_debug_policies.hpp" -#include "util/json_container.hpp" #include "util/timing_util.hpp" namespace osrm diff --git a/src/server/connection.cpp b/src/server/connection.cpp index a9800ed8306..4a01129d15e 100644 --- a/src/server/connection.cpp +++ b/src/server/connection.cpp @@ -239,7 +239,7 @@ std::vector Connection::compress_buffers(const std::vector &uncompre boost::iostreams::filtering_ostream gzip_stream; gzip_stream.push(boost::iostreams::gzip_compressor(compression_parameters)); gzip_stream.push(boost::iostreams::back_inserter(compressed_data)); - gzip_stream.write(&uncompressed_data[0], uncompressed_data.size()); + gzip_stream.write(uncompressed_data.data(), uncompressed_data.size()); boost::iostreams::close(gzip_stream); return compressed_data;