[PATCH] D40567: Always show template parameters in IR type names

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 10:11:00 PST 2017


sepavloff created this revision.
Herald added subscribers: JDevlieghere, eraman.

If a module contains opaque type and another one contains definition
of equivalent type in sense of C++, `llvm-link` merges these types.
In this procedure it can rely only on type name. An issue arises if
the type is a class template specialization. See the example.

File 1

  template<typename T> struct ABC;
  ABC<int> *var_1;

File 2

  template<typename T> struct ABC {
    T *f;
  };
  extern ABC<int> var_1;
  ABC<int*> var_2;

llvm-link produces module:

  %struct.ABC = type { i32** }
  @var_1 = global %struct.ABC* null, align 8
  @var_2 = global %struct.ABC zeroinitializer, align 8

Incomplete type `ABC<int>` from the first module becomes `ABC<int*>`. It
happens because structure types obtained from template specialization
share the same type name and differ from each other only by version
suffixes, in the example the types are named as `ABC` and `ABC.0`.
`llvm-link` cannot correctly merge these types.

This change enables template arguments in class template specializations.
Clang already prints them in class context, now they will appear in the
class name itself.


https://reviews.llvm.org/D40567

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/apple-kext-indirect-call.cpp
  test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
  test/CodeGenCXX/captured-statements.cpp
  test/CodeGenCXX/const-init-cxx11.cpp
  test/CodeGenCXX/constructor-init.cpp
  test/CodeGenCXX/ctor-dtor-alias.cpp
  test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
  test/CodeGenCXX/debug-info-template.cpp
  test/CodeGenCXX/dllexport-pr26549.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport.cpp
  test/CodeGenCXX/float128-declarations.cpp
  test/CodeGenCXX/float16-declarations.cpp
  test/CodeGenCXX/mangle-abi-tag.cpp
  test/CodeGenCXX/mangle-ms-templates-memptrs-2.cpp
  test/CodeGenCXX/microsoft-abi-extern-template.cpp
  test/CodeGenCXX/microsoft-abi-vftables.cpp
  test/CodeGenCXX/ms-property.cpp
  test/CodeGenCXX/noinline-template.cpp
  test/CodeGenCXX/pr29160.cpp
  test/CodeGenCXX/static-init-3.cpp
  test/CodeGenCXX/template-anonymous-types.cpp
  test/CodeGenCXX/template-instantiation.cpp
  test/CodeGenCXX/template-linkage.cpp
  test/CodeGenCXX/value-init.cpp
  test/CodeGenCXX/virtual-base-destructor-call.cpp
  test/CodeGenCoroutines/coro-await.cpp
  test/CodeGenObjCXX/arc-cxx11-init-list.mm
  test/CodeGenObjCXX/property-lvalue-capture.mm
  test/OpenMP/declare_reduction_codegen.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_parallel_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/target_teams_codegen.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40567.124600.patch
Type: text/x-patch
Size: 53703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171128/416946f7/attachment-0001.bin>


More information about the cfe-commits mailing list