llvm-project/clang/test/CodeGenCXX/speculative-vtt.cpp
Richard Smith c195c25b22 Don't speculatively emit VTTs for classes unless we are able to correctly emit references to all the functions they will (directly or indirectly) reference.
Summary:
This fixes a miscompile where we'd emit a VTT for a class that ends up
referencing an inline virtual member function that we can't actually
emit a body for (because we never instantiated it in the current TU),
which in a corner case of a corner case can lead to link errors.

Reviewers: rjmccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D54768

llvm-svn: 347692
2018-11-27 19:33:49 +00:00

14 lines
494 B
C++

// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -O2 -disable-llvm-passes -emit-llvm -o - | FileCheck %s
struct A { virtual ~A(); };
template<typename T> struct B : virtual A {
~B() override {}
};
struct C : B<int>, B<float> { C(); ~C() override; };
struct D : C { ~D() override; };
// We must not create a reference to B<int>::~B() here, because we're not going to emit it.
// CHECK-NOT: @_ZN1BIiED1Ev
// CHECK-NOT: @_ZTC1D0_1BIiE =
// CHECK-NOT: @_ZTT1D = available_externally
D *p = new D;