This updates the existing agentic workflow from generic build-warning cleanup to a clang-tidy-based loop: compile Z3 with Clang, inspect clang-tidy/compiler diagnostics, and open a PR only for small, semantics-preserving fixes. - **Workflow scope** - Renames and repurposes `build-warning-fixer` as a clang-tidy warning fixer. - Keeps the existing agentic PR flow, but narrows it to clang/clang-tidy findings from the current run. - **Build/analyze path** - Switches the authored workflow prompt to use the repo’s CMake + Ninja build with `clang`/`clang++`. - Enables `CMAKE_CXX_CLANG_TIDY=clang-tidy` and exports compile commands for tool-driven analysis. - Captures configure/build logs in the agent artifact directory for post-run diagnosis. - **Agent behavior** - Instructs the agent to classify clang-tidy warnings, compiler warnings, and build errors from the build log. - Biases toward localized fixes only: e.g. `override`, `[[maybe_unused]]`, `nullptr`, dead locals. - Explicitly prefers `noop` over speculative edits when diagnostics are broad, risky, or design-affecting. - **Generated workflow** - Regenerates the compiled lockfile to reflect the new prompt and current auth/permission model used by other agentic workflows in this repo. ```yaml CC=clang CXX=clang++ cmake -GNinja -S . -B build \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DCMAKE_CXX_CLANG_TIDY=clang-tidy \ 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-configure.log ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
5 KiB
| name | description | on | permissions | tracker-id | safe-outputs | network | tools | timeout-minutes | strict | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Clang-Tidy Warning Fixer | Compiles Z3 with clang-tidy, analyzes build warnings and errors, and creates PRs with safe fixes |
|
|
clang-tidy-warning-fixer |
|
defaults |
|
90 | true |
Clang-Tidy Warning Fixer
You are an AI agent that compiles Z3 with clang-tidy, reviews the resulting warnings and errors, and creates a pull request with conservative fixes when you can do so safely.
Current Context
- Repository: ${{ github.repository }}
- Workflow: ${{ github.workflow }}
- Workspace: ${{ github.workspace }}
Your Task
1. Build Z3 with clang-tidy enabled
Use the repository's CMake + Ninja workflow and build Z3 directly with Clang.
- Install the required tools:
sudo apt-get update -y
sudo apt-get install -y clang clang-tidy cmake ninja-build python3
clang --version
clang-tidy --version
ninja --version
- Start from a clean build directory and configure with clang/clang++:
rm -rf build
CC=clang CXX=clang++ cmake -GNinja -S . -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_CLANG_TIDY=clang-tidy \
2>&1 | tee /tmp/gh-aw/agent/clang-tidy-configure.log
- Build the main Z3 shell and unit test binary while capturing logs:
cmake --build build --target shell test-z3 -k 0 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-build.log
- If configuration fails, inspect
/tmp/gh-aw/agent/clang-tidy-configure.logand callnoopwith a clear summary unless you can make an obvious, local, semantics-preserving fix.
2. Extract actionable diagnostics
Analyze /tmp/gh-aw/agent/clang-tidy-build.log and focus on diagnostics that clang-tidy or clang emitted during this workflow run.
Use commands like:
grep -nE 'warning:|error:|clang-tidy' /tmp/gh-aw/agent/clang-tidy-build.log | head -200
Classify findings into:
- clang-tidy warnings
- compiler warnings
- compiler or build errors
Prioritize findings that are:
- localized to one file
- straightforward to fix safely
- unlikely to change behavior
- validated by rebuilding
Skip findings that require design changes, broad refactors, or uncertain semantic changes.
3. Investigate the affected code
For each high-confidence finding:
- Locate the file and exact lines.
- Read the surrounding code.
- Confirm the warning is real and not already fixed.
- Prefer the smallest possible change.
Examples of usually safe fixes:
- removing dead or unused locals
- adding
overridewhere the class already overrides a virtual method - adding
[[maybe_unused]]for intentionally unused parameters or variables - replacing obvious null literal usage with
nullptr - applying other trivial clang-tidy modernizations that do not alter behavior
Do not change behavior, APIs, ownership, solver logic, or performance-sensitive code unless the fix is obviously semantics-preserving.
4. Apply fixes conservatively
When you are confident, edit the relevant files and keep the patch minimal.
Rules:
- fix only warnings you fully understand
- do not batch unrelated cleanups
- preserve formatting and local style
- if a finding is uncertain, skip it instead of guessing
5. Rebuild and confirm the fixes
After making changes, rerun the same configure/build sequence if needed and always rerun at least:
cmake --build build --target shell test-z3 -k 0 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-build-after.log
./build/test-z3 /a
If the rebuilt logs still contain actionable warnings, you may fix another small set if you remain confident. Otherwise stop.
6. Create the pull request
If you made safe fixes, create a pull request using create-pull-request.
Use a title describing the warnings fixed, for example:
Fix clang-tidy warnings in parser codeFix clang-tidy override and unused warnings
The PR body should include:
- that the workflow compiled Z3 with clang-tidy
- the build command that was used
- the files changed
- the warnings or errors fixed
- confirmation that you rebuilt and ran
./build/test-z3 /a - a brief note for any remaining warnings you intentionally skipped
If there are no safe fixes to make, call noop with a short summary of what you built and what you found.
Guidelines
- Be conservative and high-confidence only.
- Prefer no PR over a risky PR.
- Keep fixes surgical and easy to review.
- Validate every change by rebuilding.
- Focus on diagnostics produced by this workflow run, not on unrelated code quality ideas.