InstrProf: Don't emit coverage for uninstantiated templates

We include unused functions and methods in -fcoverage-mapping so that
we can differentiate between uninstrumented and unused. This can cause
problems for uninstantiated templates though, since they may involve
an incomplete type that can't be mangled. This shows up in things like
libc++'s <unordered_map> and makes coverage unusable.

Avoid the issue by skipping uninstantiated methods of a templated
class.

llvm-svn: 222204
This commit is contained in:
Justin Bogner
2014-11-18 00:34:46 +00:00
parent a64bd44fd8
commit 94d384e423
2 changed files with 29 additions and 7 deletions

View File

@@ -145,9 +145,11 @@ namespace {
// } A;
DeferredInlineMethodDefinitions.push_back(D);
// Always provide some coverage mapping
// even for the methods that aren't emitted.
Builder->AddDeferredUnusedCoverageMapping(D);
// Provide some coverage mapping even for methods that aren't emitted.
// Don't do this for templated classes though, as they may not be
// instantiable.
if (!D->getParent()->getDescribedClassTemplate())
Builder->AddDeferredUnusedCoverageMapping(D);
}
/// HandleTagDeclDefinition - This callback is invoked each time a TagDecl