if a decl is both 'static' and weak or static and inline, its linkage

type should be internal, not weak/linkonce.

llvm-svn: 50611
This commit is contained in:
Chris Lattner
2008-05-04 01:44:26 +00:00
parent cfcabaeb7f
commit bc22b5b327
2 changed files with 9 additions and 10 deletions

View File

@@ -459,17 +459,19 @@ void CodeGenModule::EmitGlobalVarInit(const VarDecl *D) {
// FIXME: else handle -fvisibility
// Set the llvm linkage type as appropriate.
if (D->getAttr<DLLImportAttr>())
if (D->getStorageClass() == VarDecl::Static)
GV->setLinkage(llvm::Function::InternalLinkage);
else if (D->getAttr<DLLImportAttr>())
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>())
GV->setLinkage(llvm::GlobalVariable::WeakLinkage);
} else {
else {
// FIXME: This isn't right. This should handle common linkage and other
// stuff.
switch (D->getStorageClass()) {
case VarDecl::Static: assert(0 && "This case handled above");
case VarDecl::Auto:
case VarDecl::Register:
assert(0 && "Can't have auto or register globals");
@@ -481,9 +483,6 @@ void CodeGenModule::EmitGlobalVarInit(const VarDecl *D) {
case VarDecl::PrivateExtern:
// todo: common
break;
case VarDecl::Static:
GV->setLinkage(llvm::GlobalVariable::InternalLinkage);
break;
}
}
}