3

I'm starting to work with llvm-cov to produce coverage statistics for my project. llvm-cov has several categories: line coverage, function coverage and region coverage. But they all consider only instantiated functions, functions which are not instantiated are simply ignored. This way it is easy to get close to 100% coverage for files which have a low percentage of instantiated functions, which is not what I want. Is it possible to make llvm-cov consider even uninstantiated functions or make it produce separate coverage statistics?

Jakub Klinkovský
  • 1,248
  • 1
  • 12
  • 33
  • Could you give an example of an uninstantiated function that lacks coverage? For C++ code, functions that are specialized but not used should be covered. To my knowledge, functions that are not specialized at all are not handled -- this is probably a bug. – vedantk Apr 13 '20 at 19:19
  • @vedantk: For example any template function which is not used. – Jakub Klinkovský Apr 14 '20 at 08:30

1 Answers1

1

At the moment, unfortunately not. This is a missing capability in llvm-cov.

The reason for this is that clang does not emit any code for unspecialized templates, and the coverage generation logic depends on clang emitting code for a function. This is a weird limitation. The compiler does have enough information to describe these templates.

Edit: Of course, another point to consider is that C++ translation units tend to contain absolutely enormous amounts of unspecialized/uninstantiated templates, and if the compiler were to emit coverage mapping regions for each of these, compile-time and binary size would likely regress massively.

vedantk
  • 356
  • 3
  • 5