<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 - Local typedef information is missing in case of template clas"
   href="https://bugs.llvm.org/show_bug.cgi?id=52262">52262</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Local typedef information is missing in case of template clas
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>12.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>christina.schimpe@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>If a typedef is defined inside a class, the tag DW_TAG_typedef is listed as a
child entry of that class (tag DW_TAG_class_type). 
For clang the child entry relationship is lost, if the class has a template
parameter.

Steps to reproduce:
Compiling a program such as 

template<typename DataT>
class Cfoo
{
  typedef float myfloat;
public:
  DataT me0;
  const DataT me1=1;
  const myfloat me2=2.0;
};

int main()
{
   Cfoo<int> cfoo;
   return 0;
}

yields the following DWARF output for the DW_TAG_typedef tag of "myfloat":

0x00000052:   DW_TAG_class_type
                DW_AT_calling_convention        (DW_CC_pass_by_value)
                DW_AT_name      ("Cfoo<int>")
                DW_AT_byte_size (0x0c)
                DW_AT_decl_file ("/tmp/no_localtypdefinfo.cc")
                DW_AT_decl_line (2)

0x0000005b:     DW_TAG_template_type_parameter
                  DW_AT_type    (0x00000098 "int")
                  DW_AT_name    ("DataT")

0x00000064:     DW_TAG_member
                  DW_AT_name    ("me0")
                  DW_AT_type    (0x00000098 "int")
                  DW_AT_decl_file       ("/tmp/no_localtypdefinfo.cc")
                  DW_AT_decl_line       (6)
                  DW_AT_data_member_location    (0x00)
                  DW_AT_accessibility   (DW_ACCESS_public)

0x00000071:     DW_TAG_member
                  DW_AT_name    ("me1")
                  DW_AT_type    (0x0000009f "const int")
                  DW_AT_decl_file       ("/tmp/no_localtypdefinfo.cc")
                  DW_AT_decl_line       (7)
                  DW_AT_data_member_location    (0x04)
                  DW_AT_accessibility   (DW_ACCESS_public)

0x0000007e:     DW_TAG_member
                  DW_AT_name    ("me2")
                  DW_AT_type    (0x000000a4 "const myfloat")
                  DW_AT_decl_file       ("/tmp/no_localtypdefinfo.cc")
                  DW_AT_decl_line       (8)
                  DW_AT_data_member_location    (0x08)
                  DW_AT_accessibility   (DW_ACCESS_public)

...

0x00000096:       NULL

0x00000097:     NULL

...

0x000000a4:   DW_TAG_const_type
                DW_AT_type      (0x000000a9 "myfloat")

0x000000a9:   DW_TAG_typedef
                DW_AT_type      (0x000000b4 "float")
                DW_AT_name      ("myfloat")
                DW_AT_decl_file ("/tmp/no_localtypdefinfo.cc")
                DW_AT_decl_line (4)

The tag DW_TAG_typdef is NOT a child entry of the tag DW_TAG_class_type.

Compiling a class without template parameter such as:

class Cfoo
{
  typedef float myfloat;
public:
  const myfloat me2=2.0;
};


int main()
{
   Cfoo cfoo;
   return 0;
}

yields the following DWARF output for the DW_TAG_typedef tag of "myfloat":

0x00000052:   DW_TAG_class_type
                DW_AT_calling_convention        (DW_CC_pass_by_value)
                DW_AT_name      ("Cfoo")
                DW_AT_byte_size (0x04)
                DW_AT_decl_file ("/tmp/existing_localtypdefinfo.cc")
                DW_AT_decl_line (1)

0x0000005b:     DW_TAG_member
                  DW_AT_name    ("me2")
                  DW_AT_type    (0x00000080 "const myfloat")
                  DW_AT_decl_file       ("/tmp/existing_localtypdefinfo.cc")
                  DW_AT_decl_line       (5)
                  DW_AT_data_member_location    (0x00)
                  DW_AT_accessibility   (DW_ACCESS_public)

0x00000068:     DW_TAG_typedef
                  DW_AT_type    (0x00000085 "float")
                  DW_AT_name    ("myfloat")
                  DW_AT_decl_file       ("/tmp/existing_localtypdefinfo.cc")
                  DW_AT_decl_line       (3)

The tag DW_TAG_typedef is now a child entry of the tag DW_TAG_class_type.

Command lines to build and run the case:
clang++ -g -O0 no_localtypdefinfo.cc -o no_localtypdefinfo</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>