summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/ItaniumCXXABI.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-08-06 20:56:55 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-08-06 20:56:55 +0000
commitbe9022c50229b3491afe550a938384db75fe62b6 (patch)
tree9d2b563c1154d36297326c45b95326fd345eee85 /clang/lib/CodeGen/ItaniumCXXABI.cpp
parent366acc175e49a6ebb7087a430a83ba17cc06211c (diff)
downloadbcm5719-llvm-be9022c50229b3491afe550a938384db75fe62b6.tar.gz
bcm5719-llvm-be9022c50229b3491afe550a938384db75fe62b6.zip
[ItaniumCXXABI] Don't import RTTI data for classes with key functions
MinGW has some pretty strange behvaior around RTTI and dllimport/dllexport: - RTTI data is never imported - RTTI data is only exported if the class has no key function. llvm-svn: 244266
Diffstat (limited to 'clang/lib/CodeGen/ItaniumCXXABI.cpp')
-rw-r--r--clang/lib/CodeGen/ItaniumCXXABI.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index cb506c32cba..115bf19d97f 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2450,10 +2450,13 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM,
// FIXME: this may need to be reconsidered if the key function
// changes.
+ // N.B. We must always emit the RTTI data ourselves if there exists a key
+ // function.
+ bool IsDLLImport = RD->hasAttr<DLLImportAttr>();
if (CGM.getVTables().isVTableExternal(RD))
- return true;
+ return IsDLLImport ? false : true;
- if (RD->hasAttr<DLLImportAttr>())
+ if (IsDLLImport)
return true;
}
@@ -2683,8 +2686,15 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM,
const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
if (RD->hasAttr<WeakAttr>())
return llvm::GlobalValue::WeakODRLinkage;
- if (RD->isDynamicClass())
- return CGM.getVTableLinkage(RD);
+ if (RD->isDynamicClass()) {
+ llvm::GlobalValue::LinkageTypes LT = CGM.getVTableLinkage(RD);
+ // MinGW won't export the RTTI information when there is a key function.
+ // Make sure we emit our own copy instead of attempting to dllimport it.
+ if (RD->hasAttr<DLLImportAttr>() &&
+ llvm::GlobalValue::isAvailableExternallyLinkage(LT))
+ LT = llvm::GlobalValue::LinkOnceODRLinkage;
+ return LT;
+ }
}
return llvm::GlobalValue::LinkOnceODRLinkage;
OpenPOWER on IntegriCloud