Skip to content

Enable bugprone-empty-catch and eliminate empty catch handlers in core code#7396

Merged
DennisOSRM merged 2 commits intomasterfrom
copilot/fix-clang-tidy-warnings
Mar 4, 2026
Merged

Enable bugprone-empty-catch and eliminate empty catch handlers in core code#7396
DennisOSRM merged 2 commits intomasterfrom
copilot/fix-clang-tidy-warnings

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

This PR advances the clang-tidy-18 cleanup by re-enabling one previously disabled check (bugprone-empty-catch) and addressing its first-party findings with minimal behavioral impact. The scope is intentionally narrow: only the check enablement and directly affected catch blocks.

  • Clang-tidy configuration

    • Re-enabled bugprone-empty-catch in .clang-tidy.
  • Shared memory exception paths (src/storage/shared_memory.cpp)

    • Replaced empty catch (...) blocks in RegionExists with explicit return false;.
    • Added explicit return; in WaitForDetach catch blocks that intentionally swallow interprocess_exception.
  • Parameter parsing error path (src/server/api/parameters_parser.cpp)

    • In bad_numeric_cast handling, return std::nullopt directly from the catch block to make the intent explicit and avoid an empty catch body.
try
{
    // ...
}
catch (...)
{
    return false; // explicit fallback instead of empty catch
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix clang-tidy warnings</issue_title>
<issue_description>We updated to clang-tidy 18 in https://github.com/Project-OSRM/osrm-backend/pull/6919/files and disabled some of newly introduced warnings. This issue is to track progress on fixing them:

  • bugprone-chained-comparison
  • bugprone-incorrect-enable-if
  • bugprone-switch-missing-default-case
  • bugprone-empty-catch
  • bugprone-unused-return-value
  • misc-include-cleaner
  • performance-noexcept-swap
  • performance-enum-size
  • performance-avoid-endl
  • readability-redundant-inline-specifier
  • readability-avoid-nested-conditional-operator
  • readability-avoid-return-with-void-value
  • readability-redundant-casting

NOTE: some of them may be not actually very useful</issue_description>

<agent_instructions>create an individual pr for each of the disabled clang-tidy warnings, by enabling it and subsequently fixing the detected issues. Make sure the code is well formatted.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@SiarheiFedartsou https://github.com//pull/6934

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix clang-tidy warnings for code quality improvements Enable bugprone-empty-catch and eliminate empty catch handlers in core code Mar 3, 2026
@DennisOSRM DennisOSRM marked this pull request as ready for review March 3, 2026 21:29
@DennisOSRM DennisOSRM merged commit ff327c4 into master Mar 4, 2026
23 checks passed
@DennisOSRM DennisOSRM deleted the copilot/fix-clang-tidy-warnings branch March 4, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix clang-tidy warnings

2 participants