Skip to content

Instantly share code, notes, and snippets.

@flounderK
Created April 11, 2025 02:53
Show Gist options
  • Save flounderK/de6bce77ea4bea357eff227542eae65b to your computer and use it in GitHub Desktop.
Save flounderK/de6bce77ea4bea357eff227542eae65b to your computer and use it in GitHub Desktop.
gather code coverage with clang
clang -fprofile-instr-generate -fcoverage-mapping -o main main.c
LLVM_PROFILE_FILE="prof.profraw" ./main
# merge many profraw files into a profdata
llvm-profdata merge -sparse prof.profraw -o prof.profdata
# show coverage
llvm-cov show ./main -instr-profile=prof.profdata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment