Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit e2bb4a6

Browse files
committed
CodeGen: fix windows itanium RTTI in EH mode
When emitting RTTI for EH only, we would mark the locally defined (LinkOnceODR) RTTI definition as dllimport, which is incorrect. Ensure that if we are generating the type information for EH only, it is marked as LinkOnceODR and we do not make it dllimport. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288721 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent bd6b03c commit e2bb4a6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Diff for: lib/CodeGen/ItaniumCXXABI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3133,7 +3133,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force,
31333133
if (DLLExport || (RD && RD->hasAttr<DLLExportAttr>())) {
31343134
TypeName->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
31353135
GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
3136-
} else if (RD && RD->hasAttr<DLLImportAttr>()) {
3136+
} else if (CGM.getLangOpts().RTTI && RD && RD->hasAttr<DLLImportAttr>()) {
31373137
TypeName->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
31383138
GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
31393139

Diff for: test/CodeGenCXX/windows-itanium-type-info.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -emit-llvm %s -o - | FileCheck %s
1+
// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s
2+
// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -fno-rtti -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-EH-IMPORT
23

34
namespace __cxxabiv1 {
45
class __declspec(dllexport) __fundamental_type_info {
@@ -19,6 +20,10 @@ derived::~derived() {
1920
method();
2021
}
2122

23+
void f() {
24+
throw base();
25+
}
26+
2227
// CHECK-DAG: @_ZTIi = dllexport constant
2328
// CHECK-DAG: @_ZTSi = dllexport constant
2429

@@ -30,3 +35,6 @@ derived::~derived() {
3035
// CHECK-DAG: @_ZTS4base = external dllimport constant
3136
// CHECK-NOT: @_ZTV4base = external dllimport constant
3237

38+
// CHECK-EH-IMPORT: @_ZTS4base = linkonce_odr constant
39+
// CHECK-EH-IMPORT: @_ZTI4base = linkonce_odr constant
40+

0 commit comments

Comments
 (0)