diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-06 16:20:49 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-06 16:20:49 +0000 |
commit | 8e79b8491f4609f3fb08c41befbf17201efc4726 (patch) | |
tree | 091c8f688ec698fa30074c6c778e369b56a4878f /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 0658cac53253a4c8488b46d782d0c6f0af7a06cf (diff) | |
download | bcm5719-llvm-8e79b8491f4609f3fb08c41befbf17201efc4726.tar.gz bcm5719-llvm-8e79b8491f4609f3fb08c41befbf17201efc4726.zip |
IRgen support for weak_import.
- <rdar://problem/6652110> clang should support weak_import
llvm-svn: 66270
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3f930feaaa0..953413d8247 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -263,8 +263,12 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D, } else GV->setLinkage(llvm::Function::DLLImportLinkage); } - } else if (D->getAttr<WeakAttr>()) + } else if (D->getAttr<WeakAttr>() || + D->getAttr<WeakImportAttr>()) { + // "extern_weak" is overloaded in LLVM; we probably should have + // separate linkage types for this. GV->setLinkage(llvm::Function::ExternalWeakLinkage); + } } else { if (IsInternal) { GV->setLinkage(llvm::Function::InternalLinkage); @@ -276,7 +280,8 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D, GV->setLinkage(llvm::Function::DLLExportLinkage); } else GV->setLinkage(llvm::Function::DLLExportLinkage); - } else if (D->getAttr<WeakAttr>() || IsInline) + } else if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>() || + IsInline) GV->setLinkage(llvm::Function::WeakLinkage); } } @@ -602,7 +607,7 @@ void CodeGenModule::EmitGlobalDefinition(const ValueDecl *D) { if (D->getStorageClass() == VarDecl::PrivateExtern) setGlobalVisibility(GV, VisibilityAttr::HiddenVisibility); - if (D->getAttr<WeakAttr>()) + if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>()) GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage); if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) { @@ -737,7 +742,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { GV->setLinkage(llvm::Function::DLLImportLinkage); else if (D->getAttr<DLLExportAttr>()) GV->setLinkage(llvm::Function::DLLExportLinkage); - else if (D->getAttr<WeakAttr>()) + else if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>()) GV->setLinkage(llvm::GlobalVariable::WeakLinkage); else { // FIXME: This isn't right. This should handle common linkage and other |