]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/patches/patch-r262809-clang-r203007-destructor-calling-conv.diff
MFC: r259428
[FreeBSD/stable/9.git] / contrib / llvm / patches / patch-r262809-clang-r203007-destructor-calling-conv.diff
1 Pull in r203007 from upstream clang trunk (by Rafael Espindola):
2
3   Don't produce an alias between destructors with different calling conventions.
4
5   Fixes pr19007.
6
7 Introduced here: http://svn.freebsd.org/changeset/base/262809
8
9 Index: tools/clang/lib/CodeGen/CGCXX.cpp
10 ===================================================================
11 --- tools/clang/lib/CodeGen/CGCXX.cpp
12 +++ tools/clang/lib/CodeGen/CGCXX.cpp
13 @@ -92,7 +92,13 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(c
14    if (!ClassLayout.getBaseClassOffset(UniqueBase).isZero())
15      return true;
16  
17 +  // Give up if the calling conventions don't match. We could update the call,
18 +  // but it is probably not worth it.
19    const CXXDestructorDecl *BaseD = UniqueBase->getDestructor();
20 +  if (BaseD->getType()->getAs<FunctionType>()->getCallConv() !=
21 +      D->getType()->getAs<FunctionType>()->getCallConv())
22 +    return true;
23 +
24    return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base),
25                                    GlobalDecl(BaseD, Dtor_Base),
26                                    false);
27 Index: tools/clang/test/CodeGenCXX/ctor-dtor-alias.cpp
28 ===================================================================
29 --- tools/clang/test/CodeGenCXX/ctor-dtor-alias.cpp
30 +++ tools/clang/test/CodeGenCXX/ctor-dtor-alias.cpp
31 @@ -1,5 +1,5 @@
32 -// RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s
33 -// RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s
34 +// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s
35 +// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s
36  
37  // RUN: %clang_cc1 -cc1 -triple x86_64--netbsd -emit-llvm \
38  // RUN: -mconstructor-aliases -O2 %s -o - | FileCheck --check-prefix=CHECK-RAUW %s
39 @@ -133,6 +133,22 @@ namespace test8 {
40    zed foo;
41  }
42  
43 +namespace test9 {
44 +struct foo {
45 +  __attribute__((stdcall)) ~foo() {
46 +  }
47 +};
48 +
49 +struct bar : public foo {};
50 +
51 +void zed() {
52 +  // Test that we produce a call to bar's destructor. We used to call foo's, but
53 +  // it has a different calling conversion.
54 +  // CHECK-DAG: call void @_ZN5test93barD2Ev
55 +  bar ptr;
56 +}
57 +}
58 +
59  // CHECK-RAUW: @_ZTV1C = linkonce_odr unnamed_addr constant [4 x i8*] [{{[^@]*}}@_ZTI1C {{[^@]*}}@_ZN1CD2Ev {{[^@]*}}@_ZN1CD0Ev {{[^@]*}}]
60  // r194296 replaced C::~C with B::~B without emitting the later.
61