https://bugs.llvm.org/show_bug.cgi?id=41615

            Bug ID: 41615
           Summary: clang-cl: codeview debug info written by clang isn't
                    sufficient for natvis files that reference static
                    members
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangb...@nondot.org
          Reporter: nicolaswe...@gmx.de
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@metafoo.co.uk

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="http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
  <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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to