Skip to content

run-clang-tidy-cached: surface fatal clang-tidy errors instead of caching empty output#10185

Merged
maliberty merged 1 commit intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:catch-tidy-error
Apr 19, 2026
Merged

run-clang-tidy-cached: surface fatal clang-tidy errors instead of caching empty output#10185
maliberty merged 1 commit intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:catch-tidy-error

Conversation

@openroad-ci
Copy link
Copy Markdown
Collaborator

Summary

Previously run-clang-tidy-cached.cc redirected clang-tidy's stderr to /dev/null and inferred findings solely from the captured stdout. When clang-tidy exited non-zero without emitting any check findings (bad config, missing compile DB, unknown check name, crash in a plugin), the runner cached an empty output file as if that translation unit was clean. Subsequent runs hit the cache and continued to show zero findings — effectively masking a broken configuration.

This change:

  • Redirects stderr into the per-file output (2>&1) so error text is preserved.
  • After each clang-tidy invocation, if the exit status is non-zero and the output contains no [check-name]-shaped finding, treat it as a fatal systemic failure.
  • Signals other worker threads via std::atomic<bool> fatal_stop to stop dequeuing new work.
  • Prints the captured output for the offending file and exits with failure rather than caching the empty result.

Type of Change

  • Bug fix

Impact

  • Broken clang-tidy configurations (missing compile_commands.json, invalid checks, plugin crashes, etc.) will now fail the run loudly with the underlying diagnostic, instead of silently producing a clean report and poisoning the cache.
  • No behavior change when clang-tidy is healthy: successful runs and runs with real findings take the same path as before.
  • No change to the on-disk cache format.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Related Issues

None.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements a mechanism to detect systemic clang-tidy failures by checking for non-zero exit codes without findings, preventing the caching of empty results. The review feedback points out that the regex for identifying check findings needs to include digits to correctly match many standard clang-tidy checks. Additionally, the fatal_lock mutex is identified as redundant because the atomic compare_exchange_strong operation on fatal_stop already ensures thread-safe access to the error information.

Comment thread etc/run-clang-tidy-cached.cc Outdated
Comment thread etc/run-clang-tidy-cached.cc Outdated
Comment thread etc/run-clang-tidy-cached.cc
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread etc/run-clang-tidy-cached.cc
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty
Copy link
Copy Markdown
Member

@codex review

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbbf29b3ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread etc/run-clang-tidy-cached.cc Outdated
…hing empty output

Previously, when clang-tidy exited non-zero without producing any check
findings (e.g. bad config, missing compile db, unknown check), stderr was
discarded via `2>/dev/null` and an empty output file was cached as if the
file had no findings. Subsequent runs would hit the cache and never notice.

Redirect stderr into the output, detect non-zero exits with no findings as
fatal, stop other worker threads via an atomic flag, and print the captured
output before aborting the run.

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty
Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Member

@maliberty maliberty left a comment

Choose a reason for hiding this comment

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

@hzeller FYI

@maliberty maliberty enabled auto-merge April 19, 2026 15:53
@maliberty maliberty merged commit 4de4328 into The-OpenROAD-Project:master Apr 19, 2026
15 of 16 checks passed
@maliberty maliberty deleted the catch-tidy-error branch April 19, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants