From 94d384e4231e5e1e511873e421fdb63b175d64f0 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Tue, 18 Nov 2014 00:34:46 +0000 Subject: 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 and makes coverage unusable. Avoid the issue by skipping uninstantiated methods of a templated class. llvm-svn: 222204 --- clang/lib/CodeGen/ModuleBuilder.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/ModuleBuilder.cpp') diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp index 6c60b4e..ee6f6f9 100644 --- a/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/clang/lib/CodeGen/ModuleBuilder.cpp @@ -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 -- cgit v1.1