diff --git a/.clang-tidy b/.clang-tidy index 229e2e69a..bf42711fb 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -13,6 +13,11 @@ Checks: > -bugprone-forward-declaration-namespace, -bugprone-sizeof-expression, -bugprone-throw-keyword-missing, + -bugprone-chained-comparison, + -bugprone-incorrect-enable-if, + -bugprone-switch-missing-default-case, + -bugprone-empty-catch, + -bugprone-unused-return-value, -clang-analyzer-*, -clang-diagnostic-deprecated-declarations, -clang-diagnostic-constant-conversion, @@ -49,11 +54,14 @@ Checks: > -misc-misplaced-const, -misc-definitions-in-headers, -misc-unused-parameters, + -misc-include-cleaner, modernize-concat-nested-namespaces, modernize-use-using, performance-*, -performance-noexcept-move-constructor, -performance-no-int-to-ptr, + -performance-enum-size, + -performance-avoid-endl, readability-*, -readability-avoid-const-params-in-decls, -readability-braces-around-statements, @@ -82,6 +90,10 @@ Checks: > -readability-make-member-function-const, -readability-redundant-string-init, -readability-non-const-parameter, + -readability-redundant-inline-specifier, + -readability-avoid-nested-conditional-operator, + -readability-avoid-return-with-void-value, + -readability-redundant-casting, -readability-static-accessed-through-instance WarningsAsErrors: '*' diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index cbf73e443..b3ae2f1cb 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -192,16 +192,16 @@ jobs: # CXXCOMPILER: clang++-15 # CUCUMBER_TIMEOUT: 60000 - # - name: clang-15-debug-clang-tidy - # continue-on-error: false - # node: 18 - # runs-on: ubuntu-22.04 - # BUILD_TOOLS: ON - # BUILD_TYPE: Debug - # CCOMPILER: clang-15 - # CXXCOMPILER: clang++-15 - # CUCUMBER_TIMEOUT: 60000 - # ENABLE_CLANG_TIDY: ON + # - name: clang-18-debug-clang-tidy + # continue-on-error: false + # node: 18 + # runs-on: ubuntu-24.04 + # BUILD_TOOLS: ON + # BUILD_TYPE: Debug + # CCOMPILER: clang-18 + # CXXCOMPILER: clang++-18 + # CUCUMBER_TIMEOUT: 60000 + # ENABLE_CLANG_TIDY: ON # - name: clang-14-release # continue-on-error: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a8c566d8..63323a56c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - ADDED: Add support for opposite approach request parameter. [#6842](https://github.com/Project-OSRM/osrm-backend/pull/6842) - ADDED: Add support for accessing edge flags in `process_segment` [#6658](https://github.com/Project-OSRM/osrm-backend/pull/6658) - Build: + - CHANGED: Upgrade clang-format to version 15. [#6919](https://github.com/Project-OSRM/osrm-backend/pull/6919) - CHANGED: Use Debian Bookworm as base Docker image [#6904](https://github.com/Project-OSRM/osrm-backend/pull/6904) - CHANGED: Upgrade CI actions to latest versions [#6893](https://github.com/Project-OSRM/osrm-backend/pull/6893) - CHANGED: Remove outdated warnings #6894 [#6894](https://github.com/Project-OSRM/osrm-backend/pull/6894) @@ -23,6 +24,7 @@ - NodeJS: - CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452) - Misc: + - FIXED: Fix performance-noexcept-swap clang-tidy warning. [#6931](https://github.com/Project-OSRM/osrm-backend/pull/6931) - CHANGED: Use custom struct instead of std::pair in QueryHeap. [#6921](https://github.com/Project-OSRM/osrm-backend/pull/6921) - CHANGED: Use std::string_view::starts_with instead of boost::starts_with. [#6918](https://github.com/Project-OSRM/osrm-backend/pull/6918) - CHANGED: Get rid of boost::math::constants::* and M_PI in favor of std::numbers. [#6916](https://github.com/Project-OSRM/osrm-backend/pull/6916) diff --git a/include/extractor/serialization.hpp b/include/extractor/serialization.hpp index 779989261..98ebc7713 100644 --- a/include/extractor/serialization.hpp +++ b/include/extractor/serialization.hpp @@ -215,7 +215,6 @@ inline void read(storage::tar::FileReader &reader, const std::string &name, detail::NameTableImpl &name_table) { - std::string buffer; util::serialization::read(reader, name, name_table.indexed_data); } } // namespace osrm::extractor::serialization diff --git a/include/storage/shared_memory.hpp b/include/storage/shared_memory.hpp index 76a385b88..3300728b9 100644 --- a/include/storage/shared_memory.hpp +++ b/include/storage/shared_memory.hpp @@ -61,7 +61,7 @@ class SharedMemory { shm = boost::interprocess::xsi_shared_memory(boost::interprocess::open_only, key); - util::Log(logDEBUG) << "opening " << (int)shm.get_shmid() << " from id " << (int)id; + util::Log(logDEBUG) << "opening " << shm.get_shmid() << " from id " << (int)id; region = boost::interprocess::mapped_region(shm, boost::interprocess::read_only); } diff --git a/include/util/deallocating_vector.hpp b/include/util/deallocating_vector.hpp index 9cb5641e3..f1cb0033d 100644 --- a/include/util/deallocating_vector.hpp +++ b/include/util/deallocating_vector.hpp @@ -166,7 +166,7 @@ class DeallocatingVectorIterator template class DeallocatingVector; -template void swap(DeallocatingVector &lhs, DeallocatingVector &rhs); +template void swap(DeallocatingVector &lhs, DeallocatingVector &rhs) noexcept; template class DeallocatingVector { @@ -221,9 +221,10 @@ template class DeallocatingVector ~DeallocatingVector() { clear(); } - friend void swap<>(DeallocatingVector &lhs, DeallocatingVector &rhs); + friend void swap<>(DeallocatingVector &lhs, + DeallocatingVector &rhs) noexcept; - void swap(DeallocatingVector &other) + void swap(DeallocatingVector &other) noexcept { std::swap(current_size, other.current_size); bucket_list.swap(other.bucket_list); @@ -342,7 +343,7 @@ template class DeallocatingVector } }; -template void swap(DeallocatingVector &lhs, DeallocatingVector &rhs) +template void swap(DeallocatingVector &lhs, DeallocatingVector &rhs) noexcept { lhs.swap(rhs); } diff --git a/include/util/permutation.hpp b/include/util/permutation.hpp index ae046b014..34520389a 100644 --- a/include/util/permutation.hpp +++ b/include/util/permutation.hpp @@ -10,9 +10,9 @@ namespace osrm::util namespace permutation_detail { -template static inline void swap(T &a, T &b) { std::swap(a, b); } +template static inline void swap(T &a, T &b) noexcept { std::swap(a, b); } -static inline void swap(std::vector::reference a, std::vector::reference b) +static inline void swap(std::vector::reference a, std::vector::reference b) noexcept { std::vector::swap(a, b); } diff --git a/scripts/ci/run_benchmarks.sh b/scripts/ci/run_benchmarks.sh index f1613d5e6..b0ec8bde9 100755 --- a/scripts/ci/run_benchmarks.sh +++ b/scripts/ci/run_benchmarks.sh @@ -1,6 +1,18 @@ #!/bin/bash set -eou pipefail +function measure_peak_ram_and_time { + COMMAND=$1 + OUTPUT_FILE=$2 + + OUTPUT=$(/usr/bin/time -f "%e %M" $COMMAND 2>&1 | tail -n 1) + + TIME=$(echo $OUTPUT | awk '{print $1}') + PEAK_RAM_KB=$(echo $OUTPUT | awk '{print $2}') + PEAK_RAM_MB=$(echo "scale=2; $PEAK_RAM_KB / 1024" | bc) + echo "Time: ${TIME}s Peak RAM: ${PEAK_RAM_MB}MB" > $OUTPUT_FILE +} + function run_benchmarks_for_folder { echo "Running benchmarks for $1" @@ -24,10 +36,11 @@ function run_benchmarks_for_folder { BINARIES_FOLDER="$FOLDER/build" cp ~/data.osm.pbf $FOLDER - $BINARIES_FOLDER/osrm-extract -p $FOLDER/profiles/car.lua $FOLDER/data.osm.pbf - $BINARIES_FOLDER/osrm-partition $FOLDER/data.osrm - $BINARIES_FOLDER/osrm-customize $FOLDER/data.osrm - $BINARIES_FOLDER/osrm-contract $FOLDER/data.osrm + + measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-extract -p $FOLDER/profiles/car.lua $FOLDER/data.osm.pbf" "$RESULTS_FOLDER/osrm_extract.bench" + measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-partition $FOLDER/data.osrm" "$RESULTS_FOLDER/osrm_partition.bench" + measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-customize $FOLDER/data.osrm" "$RESULTS_FOLDER/osrm_customize.bench" + measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-contract $FOLDER/data.osrm" "$RESULTS_FOLDER/osrm_contract.bench" for ALGORITHM in mld ch; do $BINARIES_FOLDER/osrm-routed --algorithm $ALGORITHM $FOLDER/data.osrm & diff --git a/third_party/sol2/include/sol/sol.hpp b/third_party/sol2/include/sol/sol.hpp index 8b0b7d36e..d7da763f7 100644 --- a/third_party/sol2/include/sol/sol.hpp +++ b/third_party/sol2/include/sol/sol.hpp @@ -19416,7 +19416,14 @@ namespace sol { namespace function_detail { } template - static int call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v) { + static int call(lua_State* L) +// see https://github.com/ThePhD/sol2/issues/1581#issuecomment-2103463524 +#if SOL_IS_ON(SOL_COMPILER_CLANG) + // apparent regression in clang 18 - llvm/llvm-project#91362 +#else + noexcept(std::is_nothrow_copy_assignable_v) +#endif + { int nr; if constexpr (no_trampoline) { nr = real_call(L); @@ -19456,7 +19463,14 @@ namespace sol { namespace function_detail { } template - static int call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v) { + static int call(lua_State* L) +// see https://github.com/ThePhD/sol2/issues/1581#issuecomment-2103463524 +#if SOL_IS_ON(SOL_COMPILER_CLANG) + // apparent regression in clang 18 - llvm/llvm-project#91362 +#else + noexcept(std::is_nothrow_copy_assignable_v) +#endif + { int nr; if constexpr (no_trampoline) { nr = real_call(L); diff --git a/unit_tests/library/route.cpp b/unit_tests/library/route.cpp index 8773db6b7..27ba55d55 100644 --- a/unit_tests/library/route.cpp +++ b/unit_tests/library/route.cpp @@ -239,7 +239,6 @@ void test_route_same_coordinates(bool use_json_only_api) BOOST_CHECK(((void)name, true)); // nothing can be said about mode, contains mode of transportation - const auto mode = std::get(step_object.values.at("mode")).value; BOOST_CHECK(!name.empty()); const auto &maneuver = diff --git a/unit_tests/partitioner/bisection_graph_view.cpp b/unit_tests/partitioner/bisection_graph_view.cpp index b98ac9fae..7ebe285bb 100644 --- a/unit_tests/partitioner/bisection_graph_view.cpp +++ b/unit_tests/partitioner/bisection_graph_view.cpp @@ -16,12 +16,15 @@ using namespace osrm::util; BOOST_AUTO_TEST_SUITE(graph_view) -static void shuffle(std::vector &grid_edges) +namespace +{ +void shuffle(std::vector &grid_edges) { std::random_device rd; std::mt19937 rng(rd()); std::shuffle(grid_edges.begin(), grid_edges.end(), rng); } +} // namespace BOOST_AUTO_TEST_CASE(separate_top_bottom) { diff --git a/unit_tests/util/static_rtree.cpp b/unit_tests/util/static_rtree.cpp index 2557a2df9..c1b9b373a 100644 --- a/unit_tests/util/static_rtree.cpp +++ b/unit_tests/util/static_rtree.cpp @@ -235,8 +235,6 @@ auto make_rtree(const boost::filesystem::path &path, FixtureT &fixture) template void construction_test(const std::string &path, FixtureT &fixture) { - std::string leaves_path; - std::string nodes_path; auto rtree = make_rtree(path, fixture); LinearSearchNN lsnn(fixture.coords, fixture.edges);