Skip to content

Add LLVM coverage instrumentation workflow#1

Merged
joce merged 1 commit intomasterfrom
claude/awesome-curie
Apr 7, 2026
Merged

Add LLVM coverage instrumentation workflow#1
joce merged 1 commit intomasterfrom
claude/awesome-curie

Conversation

@joce
Copy link
Copy Markdown
Owner

@joce joce commented Apr 7, 2026

Overview

Introduce LLVM-based source coverage measurement for greenflame_core using Clang's instrumentation-based coverage (llvm-cov).

Changes

  • CMakeLists.txt: Add GREENFLAME_ENABLE_COVERAGE option that applies -fprofile-instr-generate -fcoverage-mapping flags to greenflame_core when enabled
  • tests/CMakeLists.txt: Apply coverage flags and link options to greenflame_tests when coverage is enabled
  • CMakePresets.json: Add x64-coverage-clang preset with coverage instrumentation enabled
  • scripts/coverage.ps1: New helper script that:
    • Configures and builds with coverage flags
    • Runs tests with LLVM_PROFILE_FILE set
    • Merges raw profiles with llvm-profdata
    • Generates summary and HTML reports scoped to src/greenflame_core/
    • Automatically adds LLVM tools to PATH from VS install
  • docs/coverage.md: Comprehensive coverage guide covering prerequisites, workflow, implementation details, and manual steps
  • docs/testing.md: Link to coverage documentation

Usage

.\scripts\coverage.ps1

Requires Clang compiler and LLVM tools from Visual Studio's "C++ Clang compiler for Windows" component.

@joce joce merged commit d5ecc2d into master Apr 7, 2026
5 checks passed
@joce joce deleted the claude/awesome-curie branch April 7, 2026 03:02
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: c09ff35476

ℹ️ 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 on lines +42 to +43
if ($env:VSINSTALLDIR -and
-not (Get-Command "llvm-cov" -ErrorAction SilentlyContinue)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add VS LLVM bin when either coverage tool is missing

The PATH bootstrap only runs when llvm-cov is absent, but the script later requires both llvm-cov and llvm-profdata. On machines where llvm-cov is already on PATH (for example from another LLVM install) but llvm-profdata is missing or version-mismatched, this block skips adding Visual Studio's LLVM bin and the run fails or mixes incompatible tool versions. Gate this on both tools (or always prepend VS LLVM when VSINSTALLDIR is set) so the toolchain is consistent.

Useful? React with 👍 / 👎.

Comment on lines +97 to +100
# ── merge profile data ────────────────────────────────────────────────────────
Write-Host ""
Write-Host "=== Merge profile data ==="
llvm-profdata merge -sparse $ProfRaw -o $ProfData
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prevent stale profraw reuse before merge

The merge step unconditionally consumes coverage.profraw without ensuring it was produced by the current test run. If a previous run left coverage.profraw behind and the current run crashes or exits before flushing profile data, llvm-profdata merge will still succeed on stale data and produce an incorrect coverage report for this invocation. Remove any existing raw profile before running tests (or verify fresh timestamp/existence after test execution) to avoid reporting outdated coverage.

Useful? React with 👍 / 👎.

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.

1 participant