summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-21 00:24:10 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-21 00:24:10 +0000
commit3c81dabd76accd809295f94f6d6e2eb9ad45dce0 (patch)
tree681d610fd31950f57e4ddca88fe60498e743b0d8 /clang/lib/CodeGen/CodeGenModule.cpp
parent0f35659b9aaad4e6d0883b9d1a6999b4c1022418 (diff)
downloadbcm5719-llvm-3c81dabd76accd809295f94f6d6e2eb9ad45dce0.tar.gz
bcm5719-llvm-3c81dabd76accd809295f94f6d6e2eb9ad45dce0.zip
Emit extern_weak when needed.
- PR3629. llvm-svn: 65203
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 7432b01e255..ccba324aa02 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -264,7 +264,8 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D,
} else
GV->setLinkage(llvm::Function::DLLImportLinkage);
}
- }
+ } else if (D->getAttr<WeakAttr>())
+ GV->setLinkage(llvm::Function::ExternalWeakLinkage);
} else {
if (IsInternal) {
GV->setLinkage(llvm::Function::InternalLinkage);
@@ -287,11 +288,10 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D,
setGlobalVisibility(GV, attr->getVisibility());
// FIXME: else handle -fvisibility
- if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
- // Prefaced with special LLVM marker to indicate that the name
- // should not be munged.
+ // Prefaced with special LLVM marker to indicate that the name
+ // should not be munged.
+ if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>())
GV->setName("\01" + ALA->getLabel());
- }
if (const SectionAttr *SA = D->getAttr<SectionAttr>())
GV->setSection(SA->getName());
@@ -598,8 +598,13 @@ void CodeGenModule::EmitGlobalDefinition(const ValueDecl *D) {
GV->setConstant(D->getType().isConstant(Context));
+ // FIXME: Merge with other attribute handling code.
+
if (D->getStorageClass() == VarDecl::PrivateExtern)
setGlobalVisibility(GV, VisibilityAttr::HiddenVisibility);
+
+ if (D->getAttr<WeakAttr>())
+ GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
}
// Make sure the result is of the correct type.
OpenPOWER on IntegriCloud