I tried to create a coverage report using llvm-cov
of clang
executing the Static Analyzer tests via the check-clang-analysis
build target.
I found that the LLVM_BUILD_INSTRUMENTED_COVERAGE=ON
CMake option does this according to the documentation:
https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#collecting-coverage-reports-for-the-llvm-project
However, I’m getting this result for executing the llvm/utils/prepare-code-coverage-artifact.py
script:
:: Merging raw profiles...Done!
:: Preparing html report for ['build/with-coverage/bin/clang']...warning: 10942 functions have mismatched data
warning: 10942 functions have mismatched data
Done!
Does anyone know how to set up such coverage reports?
Why do I get this 10942 functions have mismatched data
warning?
Here is my reproducer:
git clone git@github.com:llvm/llvm-project.git
cd llvm-project
cmake -S llvm -B build/with-coverage -GNinja \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_ASM_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_USE_LINKER=lld \
-DLLVM_ENABLE_DUMP=ON \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_BUILD_INSTRUMENTED_COVERAGE=ON \
-DLLVM_COV=$(which llvm-cov) \
-DLLVM_PROFDATA=$(which llvm-profdata)
ninja -C build/with-coverage check-clang-analysis
llvm/utils/prepare-code-coverage-artifact.py \
--preserve-profiles \
-C build/with-coverage \
$(which llvm-profdata) \
$(which llvm-cov) \
build/with-coverage/profiles \
my-coverage-output-dir \
build/with-coverage/bin/clang
/CC Some folks, as per