<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [Windows]Clang Coverage attempts to mangle name of not fully instantiated class template function"
href="https://bugs.llvm.org/show_bug.cgi?id=32679">32679</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Windows]Clang Coverage attempts to mangle name of not fully instantiated class template function
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>adamf88@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18293" name="attach_18293" title="My patch to solve this issue, source code and build script">attachment 18293</a> <a href="attachment.cgi?id=18293&action=edit" title="My patch to solve this issue, source code and build script">[details]</a></span>
My patch to solve this issue, source code and build script
Clang Coverage reports an error when trying to mangle name of not fully
instantiated class template function on Windows.
>From the code below, Clang tries to create mangled name of the function "Max".
Sample code:
“
template <typename T, bool has_infinity>
struct RangeBase;
template<typename T>
struct RangeBase<T, true>
{
static constexpr T Min()
{
return -1;
}
static constexpr T Max()
{
return -1;
}
};
int main()
{
//if uncommented then compiles properly
//RangeBase<float, true>::Max();
RangeBase<float, true>::Min();
return 0;
}
“
Compilation Command:
clang++ -cc1 -triple i686-pc-windows-msvc19.0.0 -emit-obj
-fprofile-instrument=clang -O0 -std=c++14 -fdelayed-template-parsing
-fcoverage-mapping -o "<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - Need to add product version numbers"
href="show_bug.cgi?id=1">bug1</a>.obj" <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - Need to add product version numbers"
href="show_bug.cgi?id=1">bug1</a>.cpp
Error message after compilation:
error: cannot mangle this template type parameter type yet
1>CL : error : cannot mangle this template type parameter type yet
1><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - Need to add product version numbers"
href="show_bug.cgi?id=1">bug1</a>.cpp(12,2): error : cannot mangle this template type parameter type yet
1> static constexpr T Max()
1> ^~~~~~~~~~~~~~~~~~~~~~~~
It look like the problem starts in file ModuleBuilder.cpp in function
HandleInlineFunctionDefinition.
This function calls AddDeferredUnusedCoverageMapping which adds function "Max"
to the DenseMap DeferredEmptyCoverageMappingDecls.
Later there is an attempt to mangle name of this partially instantiated
function.
I suppose name of this function shouldn’t be mangled. It shouldn't even be in
this Map.
I have created simple patch: <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - Need to add product version numbers"
href="show_bug.cgi?id=1">bug1</a>Patch.patch (in attachment). It should solve
this issue.
My simple Patch (also in attachment):
Index: ModuleBuilder.cpp
===================================================================
--- ModuleBuilder.cpp (revision 300404)
+++ ModuleBuilder.cpp (working copy)
@@ -197,7 +197,9 @@
// 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 (!MD->getParent()->getDescribedClassTemplate())
+ const CXXRecordDecl *RD = MD->getParent();
+ if (!RD->getDescribedClassTemplate() &&
+ !isa<ClassTemplatePartialSpecializationDecl>(RD))
Builder->AddDeferredUnusedCoverageMapping(MD);
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>