Skip to content

Commit dc55076

Browse files
kikairoyajeremyd2019
authored andcommitted
[Cygwin] RTTI and VTable should be dllexport-ed (llvm#139798)
Behaves as same as both of Clang and GCC targetting MinGW. Required for compatibility for Cygwin-GCC. Divided from llvm#138773
1 parent 685a699 commit dc55076

File tree

8 files changed

+20
-10
lines changed

8 files changed

+20
-10
lines changed

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3749,7 +3749,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM,
37493749
bool IsDLLImport = RD->hasAttr<DLLImportAttr>();
37503750

37513751
// Don't import the RTTI but emit it locally.
3752-
if (CGM.getTriple().isWindowsGNUEnvironment())
3752+
if (CGM.getTriple().isOSCygMing())
37533753
return false;
37543754

37553755
if (CGM.getVTables().isVTableExternal(RD)) {
@@ -4035,10 +4035,7 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM,
40354035
return llvm::GlobalValue::ExternalLinkage;
40364036
// MinGW always uses LinkOnceODRLinkage for type info.
40374037
if (RD->isDynamicClass() &&
4038-
!CGM.getContext()
4039-
.getTargetInfo()
4040-
.getTriple()
4041-
.isWindowsGNUEnvironment())
4038+
!CGM.getContext().getTargetInfo().getTriple().isOSCygMing())
40424039
return CGM.getVTableLinkage(RD);
40434040
}
40444041

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6163,7 +6163,7 @@ static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) {
61636163
}
61646164
} MarkingDllexportedContext(S, Class, ClassAttr->getLocation());
61656165

6166-
if (S.Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
6166+
if (S.Context.getTargetInfo().getTriple().isOSCygMing())
61676167
S.MarkVTableUsed(Class->getLocation(), Class, true);
61686168

61696169
for (Decl *Member : Class->decls()) {

clang/test/CodeGenCXX/dllexport-missing-key.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s
2+
// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s
23

34
class __declspec(dllexport) QAbstractLayoutStyleInfo {
45
public:

clang/test/CodeGenCXX/dllimport-missing-key.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s
2+
// RUN: %clang_cc1 -triple i686-pc-cygwin -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s
23

34
class __declspec(dllimport) QObjectData {
45
public:

clang/test/CodeGenCXX/dllimport-rtti.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=MSVC
2-
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
1+
// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=MSVC
2+
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
3+
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
4+
// RUN: %clang_cc1 -triple i686-pc-cygwin -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
5+
// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
36

47
struct __declspec(dllimport) S {
58
virtual void f() {}

clang/test/CodeGenCXX/rtti-mingw64.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -emit-llvm -o - | FileCheck %s
2+
// RUN: %clang_cc1 -triple x86_64-pc-cygwin %s -emit-llvm -o - | FileCheck %s
3+
24
struct A { int a; };
35
struct B : virtual A { int b; };
46
B b;

clang/test/CodeGenCXX/virt-dtor-key.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
// RUN: %clang_cc1 -triple i386-linux -emit-llvm %s -o - | FileCheck %s
2-
// RUN: %clang_cc1 -triple i386-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
1+
// RUN: %clang_cc1 -triple i686-linux -emit-llvm %s -o - | FileCheck %s
2+
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
3+
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
4+
// RUN: %clang_cc1 -triple i686-pc-cygwin -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
5+
// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
6+
37
// CHECK: @_ZTI3foo ={{.*}} constant
48
// CHECK-MINGW: @_ZTI3foo = linkonce_odr
59
class foo {

clang/test/CodeGenCXX/vtable-key-function-ios.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
55
// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
6+
// RUN: %clang_cc1 %s -triple=x86_64-pc-cygwin -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
7+
// RUN: %clang_cc1 %s -triple=x86_64-pc-cygwin -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
68

79
// The 'a' variants ask for the vtable first.
810
// The 'b' variants ask for the vtable second.

0 commit comments

Comments
 (0)