Code Coverage From the Command Line With Clang
Having searched the Internet several times to find out how to get coverage information out of
clang
, I ended up feeling rather confused. I’m sure I’m not the only one. The reason for the confusion is fairly simple;clang
supports two different coverage tools, one of which uses a tool with a name that used to be used by the other one![…]
In both cases, you need to pass the coverage options to the
clang
orclang++
driver when you are linking as well as when you are compiling. This will causeclang
to link with any libraries required by the profiling system. You do not need to explicitly link with a profiling library when usingclang
.