From c4fb8ca7aa4dfbd7a78cbff92d7065dff7e583e3 Mon Sep 17 00:00:00 2001 From: Dario Domizioli Date: Fri, 19 Sep 2014 22:06:24 +0000 Subject: Fix ctor/dtor aliases losing 'dllexport' (for Itanium ABI) This patch makes sure that the dllexport attribute is transferred to the alias when such alias is created. It only affects the Itanium ABI because for the MSVC ABI a workaround is in place to not generate aliases of dllexport ctors/dtors. A new CodeGenModule function is provided, CodeGenModule::setAliasAttributes, to factor the code for transferring attributes to aliases. llvm-svn: 218159 --- clang/lib/CodeGen/CodeGenModule.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 5e87fc2799c6..6e7da49a44d4 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -786,6 +786,16 @@ void CodeGenModule::SetCommonAttributes(const Decl *D, addUsedGlobal(GV); } +void CodeGenModule::setAliasAttributes(const Decl *D, + llvm::GlobalValue *GV) { + SetCommonAttributes(D, GV); + + // Process the dllexport attribute based on whether the original definition + // (not necessarily the aliasee) was exported. + if (D->hasAttr()) + GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); +} + void CodeGenModule::setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO) { SetCommonAttributes(D, GO); -- cgit v1.2.3