<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 - clang-cl: codeview debug info written by clang isn't sufficient for natvis files that reference static members"
href="https://bugs.llvm.org/show_bug.cgi?id=41615">41615</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl: codeview debug info written by clang isn't sufficient for natvis files that reference static members
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>C:\src\repro2>type test.cc
struct S {
static const int kFoo = 18;
S();
int a;
};
const int S::kFoo;
S::S() { // Just here so s in main isn't optimized away
a = 4;
}
int main() {
S s;
return S::kFoo + s.a;
}
C:\src\repro2>type test.natvis
<?xml version="1.0" encoding="utf-8" ?>
<AutoVisualizer
xmlns="<a href="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">http://schemas.microsoft.com/vstudio/debugger/natvis/2010</a>">
<Type Name="S">
<DisplayString>kFoo = {kFoo}</DisplayString>
</Type>
</AutoVisualizer>
C:\src\repro2>cl test.cc /nologo /Z7 /link /natvis:test.natvis
C:\src\repro2>devenv /debugexe test.exe
Then ctrl-o, open test.cc, add breakpoint on the return line in main by
clicking in left margin, F5 to start debugging. Note that `s` has `kFoo = 18`
in its description.
Now the same with clang-cl (and link.exe, so no lld-link pdb writing):
C:\src\repro2>
"..\chrome\src\third_party\llvm-build\Release+Asserts/bin/clang-cl" test.cc
/nologo /Z7 /link /natvis:test.natvis
And hit F5 in MSVC again. This time, s instead shows up as `{a=4}`, and if you
go to Tools->Options->Debugging->Output Window and change "Natvis diagnostic
messages" (6th from top in msvc2017) to "Warning" the output window contains:
Natvis: test.natvis (from C:\src\repro2\test.pdb)(5,28): Error: identifier
"kFoo" is undefined
Error while evaluating 'kFoo' in the context of type 'test.exe!S'.
Natvis: test.natvis (from C:\src\repro2\test.pdb)(5,28): Error: identifier
"kFoo" is undefined
Error while evaluating 'kFoo' in the context of type 'test.exe!S'.
merlynop@ms suggests this might be due to clang-cl not writing a S_CONSTANT
record.</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>