Skip to content

clang-tidy: resolve bugprone-exception-escape#491

Merged
knoepfel merged 5 commits intomainfrom
maintenance/clang-tidy/bugprone-exception-escape
Apr 8, 2026
Merged

clang-tidy: resolve bugprone-exception-escape#491
knoepfel merged 5 commits intomainfrom
maintenance/clang-tidy/bugprone-exception-escape

Conversation

@greenc-FNAL
Copy link
Copy Markdown
Contributor

@greenc-FNAL greenc-FNAL commented Apr 7, 2026

clang-tidy flags main() functions that can propagate uncaught exceptions as bugprone-exception-escape. This addresses those warnings across the app and two test executables.

Changes

  • phlex/app/phlex.cpp — Suppresses the warning with NOLINTNEXTLINE(bugprone-exception-escape) rather than wrapping main in a function-try-block. The existing inner try/catch blocks (around bpo command-line parsing and phlex::experimental::run()) already handle the relevant throw sites; an outer catch would only duplicate handling inconsistently.

    // NOLINTNEXTLINE(bugprone-exception-escape) -- primary application entry point; exceptions
    // from potentially-throwing calls should be handled internally, not propagated from main
    int main(int argc, char* argv[])
    {
      ...
      try {
        phlex::experimental::run(configurations, max_concurrency);
      } catch (std::exception const& e) { ... }
        catch (...) { ... }
    }
  • test/memory-checks/many_events.cpp and test/form/form_root_schema_read_test.cpp — Wraps main() in a function-try-block catching std::exception const& and ..., printing to std::cerr and returning non-zero on unhandled exceptions.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Wraps main() bodies in function-try-blocks to prevent exceptions from escaping main, addressing clang-tidy’s bugprone-exception-escape warnings in the app and a couple of test executables.

Changes:

  • Convert main() definitions to function-try-blocks with catch (std::exception const&) and catch (...).
  • Emit error messages to std::cerr and return non-zero on uncaught exceptions.
  • Add <iostream> include where needed for new std::cerr usage.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/memory-checks/many_events.cpp Adds top-level exception handling in main() and prints failures to stderr.
test/form/form_root_schema_read_test.cpp Adds top-level exception handling in main() for schema evolution test executable.
phlex/app/phlex.cpp Adds a top-level function-try-block around the CLI/application entry point to prevent exception escape.

Comment thread test/memory-checks/many_events.cpp Outdated
Comment thread phlex/app/phlex.cpp Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main     #491      +/-   ##
==========================================
+ Coverage   85.49%   85.52%   +0.02%     
==========================================
  Files         142      142              
  Lines        3586     3586              
  Branches      615      615              
==========================================
+ Hits         3066     3067       +1     
  Misses        311      311              
+ Partials      209      208       -1     
Flag Coverage Δ
unittests 85.52% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
phlex/app/phlex.cpp 66.66% <ø> (ø)

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1e67db...135e530. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI changed the title Resolve bugprone-exception-escape clang-tidy issues Resolve bugprone-exception-escape clang-tidy warnings Apr 8, 2026
@greenc-FNAL greenc-FNAL changed the title Resolve bugprone-exception-escape clang-tidy warnings clang-tidy: resolve bugprone-exception-escape Apr 8, 2026
@greenc-FNAL greenc-FNAL force-pushed the maintenance/clang-tidy/bugprone-exception-escape branch from 54d4d66 to 135e530 Compare April 8, 2026 14:32
@knoepfel knoepfel merged commit 7a54982 into main Apr 8, 2026
36 checks passed
@knoepfel knoepfel deleted the maintenance/clang-tidy/bugprone-exception-escape branch April 8, 2026 15:13
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.

4 participants