diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 6 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 13 |
2 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 1b94c595616..bacb610a50a 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -159,14 +159,14 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD) { // TODO: Set up linkage and many other things. Note, this is a simple // approximation of what we really want. - if (FD->getAttr<DLLImportAttr>()) + if (FD->getStorageClass() == FunctionDecl::Static) + CurFn->setLinkage(llvm::Function::InternalLinkage); + else if (FD->getAttr<DLLImportAttr>()) CurFn->setLinkage(llvm::Function::DLLImportLinkage); else if (FD->getAttr<DLLExportAttr>()) CurFn->setLinkage(llvm::Function::DLLExportLinkage); else if (FD->getAttr<WeakAttr>() || FD->isInline()) CurFn->setLinkage(llvm::Function::WeakLinkage); - else if (FD->getStorageClass() == FunctionDecl::Static) - CurFn->setLinkage(llvm::Function::InternalLinkage); if (FD->getAttr<FastCallAttr>()) CurFn->setCallingConv(llvm::CallingConv::Fast); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index bf1f0d823d7..306abd120bd 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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; } } } |