From 317dcc3f2f37c95619a4db9c6d4c084983fdf7ba Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 5 Dec 2016 22:40:20 +0000 Subject: [PATCH] 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. llvm-svn: 288721 --- clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 +- clang/test/CodeGenCXX/windows-itanium-type-info.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 48d47d2..db648f2 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3133,7 +3133,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force, if (DLLExport || (RD && RD->hasAttr())) { TypeName->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); - } else if (RD && RD->hasAttr()) { + } else if (CGM.getLangOpts().RTTI && RD && RD->hasAttr()) { TypeName->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); diff --git a/clang/test/CodeGenCXX/windows-itanium-type-info.cpp b/clang/test/CodeGenCXX/windows-itanium-type-info.cpp index ecc227d..ad89318 100644 --- a/clang/test/CodeGenCXX/windows-itanium-type-info.cpp +++ b/clang/test/CodeGenCXX/windows-itanium-type-info.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -fno-rtti -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-EH-IMPORT namespace __cxxabiv1 { class __declspec(dllexport) __fundamental_type_info { @@ -19,6 +20,10 @@ derived::~derived() { method(); } +void f() { + throw base(); +} + // CHECK-DAG: @_ZTIi = dllexport constant // CHECK-DAG: @_ZTSi = dllexport constant @@ -30,3 +35,6 @@ derived::~derived() { // CHECK-DAG: @_ZTS4base = external dllimport constant // CHECK-NOT: @_ZTV4base = external dllimport constant +// CHECK-EH-IMPORT: @_ZTS4base = linkonce_odr constant +// CHECK-EH-IMPORT: @_ZTI4base = linkonce_odr constant + -- 2.7.4