<div dir="ltr">Hi,<div><br></div><div>I have been experimenting with the SanitizerCoverage tool and I'm particularly interested in edge-level coverage.  I tried applying this to some tests I have in a small project and everything makes sense except one function where a factory is being used.  The closing brace is identified as not covered.  I created the following basic example that exhibits similar behavior:</div><div><br></div><div><div><font face="monospace, monospace">#include <memory></font></div><div><font face="monospace, monospace">#include <vector></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">auto usesFactory(int size) -> std::unique_ptr<std::vector<int>> {</font></div><div><font face="monospace, monospace">  auto v = std::make_unique<std::vector<int>>();</font></div><div><font face="monospace, monospace">  v->reserve(size);</font></div><div><font face="monospace, monospace">  return v;</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">int main() {</font></div><div><font face="monospace, monospace">  auto v = usesFactory(5);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  return 0;</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>If you compile and run this per the <a href="http://clang.llvm.org/docs/SanitizerCoverage.html">SanitizerCoverage documentation</a>, you should see that there are multiple (three in my case) instances of missing coverage on the line for usesFactory()'s closing brace.  I tried two things to figure out how to eliminate this: -fno-exceptions and adding an additional test where the mocked factory (taking the place of std::make_unique and reserve) throws an exception.  In my actual test, -fno-exceptions removes all the missing coverage statements, but throwing an exception through "make_unique and reserve" doesn't.  Using -fno-exceptions in this code example only removes two out of three missing coverage statements.</div><div><br></div><div>Although I'm interested to know how to reach these edges, I've really been trying to find a way for clang to tell me the control flow graph it's using when generating the instrumentation.  I've tried the debug.DumpCFG static analysis tool, but that doesn't seem to know anything about exceptions or any other surprising control flow that would generate these edges.  Additionally, I tried <font face="monospace, monospace">clang++ ... -emit-llvm -S main.cpp -o main.llvm; opt -dot-cfg main.llvm </font><font face="arial, helvetica, sans-serif">as well as just looking at assembly after the coverage instrumentation is added.  Unfortunately I haven't been able to make much sense of these and I don't know if this is the best way forward anyway.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I would really appreciate any help identifying these mysterious edges or, even better, finding a way to see the CFG that clang is using when generating the coverage instrumentation code.  If the answer is that a new tool probably needs to be written for that, I'd be happy to take a shot at it.  If the answer is that it's not possible to get such a descriptive source-level CFG from the coverage tool then I'll be a sad panda.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Thanks,</font></div><div><font face="arial, helvetica, sans-serif">Brandon</font></div></div>