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;clangsupports 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
clangorclang++driver when you are linking as well as when you are compiling. This will causeclangto link with any libraries required by the profiling system. You do not need to explicitly link with a profiling library when usingclang.