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
This commit is contained in:
Dario Domizioli
2014-09-19 22:06:24 +00:00
parent 44a7c7f1aa
commit c4fb8ca7aa
4 changed files with 35 additions and 1 deletions

View File

@@ -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<DLLExportAttr>())
GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
}
void CodeGenModule::setNonAliasAttributes(const Decl *D,
llvm::GlobalObject *GO) {
SetCommonAttributes(D, GO);