[llvm-bugs] [Bug 39616] New: clang-cl doesn't output the template parameter on variable templates

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 9 19:32:37 PST 2018


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

            Bug ID: 39616
           Summary: clang-cl doesn't output the template parameter on
                    variable templates
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: rnk at google.com
          Reporter: zturner at google.com
                CC: aleksandr.urakov at jetbrains.com,
                    jdevlieghere at apple.com, llvm-bugs at lists.llvm.org,
                    mosescu at google.com

template<typename T>
constexpr T Pi = T(3.1415926);


template<typename T>
extern void unresolved(const T *);

int main(int argc, char **argv) {
  unresolved(&Pi<int>);
  unresolved(&Pi<double>);
  unresolved(&Pi<long double>);
  return (int)(Pi<int> + Pi<double> + Pi<long double>);
}

compile and link with both MSVC and clang:

MSVC:
  1) cl.exe /Z7 /GS- /GR- /Fovariable-cl.obj /c variable.cpp
  2) link.exe /debug:full /incremental:no /nodefaultlib /force:unresolved
/entry:main variable-cl.obj

Clang:
  1) clang-cl.exe /Z7 /GS- /GR- -Xclang -fkeep-static-consts /c variable.cpp
  2) lld-link.exe /debug:full /incremental:no /nodefaultlib /force:unresolved
/entry:main variable.obj

Then dump the globals from each and compare:

$ bin\llvm-pdbutil.exe dump -globals variable.pdb


                       Global Symbols
============================================================
  Records
      20 | S_PROCREF [size = 20] `main`
           module = 1, sum name = 0, offset = 52
      40 | S_LDATA32 [size = 20] `Pi`
           type = 0x1003 (const int), addr = 0002:0000
      60 | S_LDATA32 [size = 20] `Pi`
           type = 0x1004 (const double), addr = 0002:0008
      80 | S_LDATA32 [size = 20] `Pi`
           type = 0x1004 (const double), addr = 0002:0016


$ bin\llvm-pdbutil.exe dump -globals variable-cl.pdb

                       Global Symbols
============================================================
  Records
      20 | S_PROCREF [size = 20] `main`
           module = 1, sum name = 0, offset = 176
      40 | S_LDATA32 [size = 24] `Pi<int>`
           type = 0x1051 (const int), addr = 0002:0000
      64 | S_LDATA32 [size = 28] `Pi<double>`
           type = 0x1052 (const double), addr = 0002:0008
      92 | S_LDATA32 [size = 32] `Pi<long double>`
           type = 0x1052 (const double), addr = 0002:0016

As you can see, MSVC puts the template parameter type into the name, whereas we
do not.

The result of this is that in LLDB we can't view variable templates because we
can't look them up (there is actually another bug preventing this as well on
the LLDB side, but fixing this is step 1).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181110/55894ea7/attachment.html>


More information about the llvm-bugs mailing list