Issue 134156
Summary [CodeView] Simple types in template parameters aren't renamed
Labels new issue
Assignees
Reporter Nerixyz
    `clang-cl` and `cl` produce different names for simple types used in template arguments. They produce the same simple type names for the member. I'm not sure if this is a Clang or LLVM issue. I'm guessing this is an issue with LLVM, because it's the one turning `long long` into `__int64` ([`DebugInfo/CodeView/TypeIndex.cpp`](https://github.com/llvm/llvm-project/blob/564e04b703dc5df062f862e32c00bf1a1716f96f/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp#L26-L91)).

**Reproduction**
```cpp
// main.cpp
template <typename T> class Foo {
  T bar;
};
template class Foo<long long>;
```
Compile with `clang-cl` and `cl`:
```console
> clang-cl main.cpp /Zi -o clang-output
> cl main.cpp /Zi -o msvc-output
```
Check names in PDB:
```console
> llvm-pdbutil pretty clang-output.pdb -classes --include-types=Foo
Summary for F:\Dev\cpp-test\clang-output.pdb
  Size: 7008256 bytes
  Guid: {F75AB9BC-7C91-462D-866C-06174965CC9F}
  Age: 1
  Attributes: HasPrivateSymbols
---TYPES---
  Classes: (Showing 911 items)
    class Foo<long long> [sizeof = 8] {
      data +0x00 [sizeof=8] __int64 bar
 }
> llvm-pdbutil pretty msvc-output.pdb -classes --include-types=Foo
Summary for F:\Dev\cpp-test\msvc-output.pdb
  Size: 7008256 bytes
  Guid: {AA4A4274-D8EE-49E0-9121-A2A5FF45EE17}
  Age: 1
 Attributes: HasPrivateSymbols
---TYPES---
  Classes: (Showing 911 items)
 class Foo<__int64> [sizeof = 8] {
      data +0x00 [sizeof=8] __int64 bar
    }
```

Notice the different names for the type of the class - `Foo<long long>` (clang-cl) and `Foo<__int64>` (cl).

The relevant part of the generated IR:
```llvm
!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "Foo<long long>", file: !12, line: 1, size: 64, flags: DIFlagTypePassByValue, elements: !19, templateParams: !22, identifier: ".?AV?$Foo@_J@@")
!19 = !{!20}
!20 = !DIDerivedType(tag: DW_TAG_member, name: "bar", scope: !18, file: !12, line: 2, baseType: !21, size: 64)
!21 = !DIBasicType(name: "long long", size: 64, encoding: DW_ATE_signed)
!22 = !{!23}
!23 = !DITemplateTypeParameter(name: "T", type: !21)
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to