diff options
| author | Hans Wennborg <hans@hanshq.net> | 2014-05-30 16:59:42 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2014-05-30 16:59:42 +0000 |
| commit | 6ecc88615e99eaac5bfeb28207416e93118bbfa7 (patch) | |
| tree | f3459218160cf8abc5e33cb4b6739ad0db0a57d1 /lib/CodeGen/CGVTables.cpp | |
| parent | f6da0fd888382d274bbb0bfceab4724c701b4922 (diff) | |
| download | clang-6ecc88615e99eaac5bfeb28207416e93118bbfa7.tar.gz clang-6ecc88615e99eaac5bfeb28207416e93118bbfa7.tar.bz2 clang-6ecc88615e99eaac5bfeb28207416e93118bbfa7.tar.xz | |
Start adding support for dllimport/dllexport on classes (PR11170)
This implements the central part of support for dllimport/dllexport on
classes: allowing the attribute on class declarations, inheriting it
to class members, and forcing emission of exported members. It's based
on Nico Rieck's patch from http://reviews.llvm.org/D1099.
This patch doesn't propagate dllexport to bases that are template
specializations, which is an interesting problem. It also doesn't
look at the rules when redeclaring classes with different attributes,
I'd like to do that separately.
Differential Revision: http://reviews.llvm.org/D3877
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209908 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVTables.cpp')
| -rw-r--r-- | lib/CodeGen/CGVTables.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index d10db5a683..8984a707c4 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -651,18 +651,31 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { // internal linkage. if (Context.getLangOpts().AppleKext) return llvm::Function::InternalLinkage; - + + llvm::GlobalVariable::LinkageTypes DiscardableODRLinkage = + llvm::GlobalValue::LinkOnceODRLinkage; + llvm::GlobalVariable::LinkageTypes NonDiscardableODRLinkage = + llvm::GlobalValue::WeakODRLinkage; + if (RD->hasAttr<DLLExportAttr>()) { + // Cannot discard exported vtables. + DiscardableODRLinkage = NonDiscardableODRLinkage; + } else if (RD->hasAttr<DLLImportAttr>()) { + // Imported vtables are available externally. + DiscardableODRLinkage = llvm::GlobalVariable::AvailableExternallyLinkage; + NonDiscardableODRLinkage = llvm::GlobalVariable::AvailableExternallyLinkage; + } + switch (RD->getTemplateSpecializationKind()) { case TSK_Undeclared: case TSK_ExplicitSpecialization: case TSK_ImplicitInstantiation: - return llvm::GlobalVariable::LinkOnceODRLinkage; + return DiscardableODRLinkage; case TSK_ExplicitInstantiationDeclaration: llvm_unreachable("Should not have been asked to emit this"); case TSK_ExplicitInstantiationDefinition: - return llvm::GlobalVariable::WeakODRLinkage; + return NonDiscardableODRLinkage; } llvm_unreachable("Invalid TemplateSpecializationKind!"); |
