diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-06-30 16:58:07 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-06-30 16:58:07 +0000 |
| commit | 749b8ed5af885c65434483e194985c51cf07ba15 (patch) | |
| tree | 37eefc96c4d430e60bbb03d05e4b80b7e7ac4271 | |
| parent | 36d97d8938ee826893f7b9204eeaa248bb0a80e4 (diff) | |
| download | bcm5719-llvm-749b8ed5af885c65434483e194985c51cf07ba15.tar.gz bcm5719-llvm-749b8ed5af885c65434483e194985c51cf07ba15.zip | |
reduce nesting.
llvm-svn: 107292
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index cc97d86995f..6e12e1b9044 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -379,35 +379,39 @@ llvm::GlobalValue::LinkageTypes CodeGenModule::getFunctionLinkage(const FunctionDecl *D) { GVALinkage Linkage = GetLinkageForFunction(getContext(), D, Features); - if (Linkage == GVA_Internal) { + if (Linkage == GVA_Internal) return llvm::Function::InternalLinkage; - } else if (D->hasAttr<DLLExportAttr>()) { + + if (D->hasAttr<DLLExportAttr>()) return llvm::Function::DLLExportLinkage; - } else if (D->hasAttr<WeakAttr>()) { + + if (D->hasAttr<WeakAttr>()) return llvm::Function::WeakAnyLinkage; - } else if (Linkage == GVA_C99Inline) { - // In C99 mode, 'inline' functions are guaranteed to have a strong - // definition somewhere else, so we can use available_externally linkage. + + // In C99 mode, 'inline' functions are guaranteed to have a strong + // definition somewhere else, so we can use available_externally linkage. + if (Linkage == GVA_C99Inline) return llvm::Function::AvailableExternallyLinkage; - } else if (Linkage == GVA_CXXInline || Linkage == GVA_TemplateInstantiation) { - // In C++, the compiler has to emit a definition in every translation unit - // that references the function. We should use linkonce_odr because - // a) if all references in this translation unit are optimized away, we - // don't need to codegen it. b) if the function persists, it needs to be - // merged with other definitions. c) C++ has the ODR, so we know the - // definition is dependable. + + // In C++, the compiler has to emit a definition in every translation unit + // that references the function. We should use linkonce_odr because + // a) if all references in this translation unit are optimized away, we + // don't need to codegen it. b) if the function persists, it needs to be + // merged with other definitions. c) C++ has the ODR, so we know the + // definition is dependable. + if (Linkage == GVA_CXXInline || Linkage == GVA_TemplateInstantiation) return llvm::Function::LinkOnceODRLinkage; - } else if (Linkage == GVA_ExplicitTemplateInstantiation) { - // An explicit instantiation of a template has weak linkage, since - // explicit instantiations can occur in multiple translation units - // and must all be equivalent. However, we are not allowed to - // throw away these explicit instantiations. + + // An explicit instantiation of a template has weak linkage, since + // explicit instantiations can occur in multiple translation units + // and must all be equivalent. However, we are not allowed to + // throw away these explicit instantiations. + if (Linkage == GVA_ExplicitTemplateInstantiation) return llvm::Function::WeakODRLinkage; - } else { - assert(Linkage == GVA_StrongExternal); - // Otherwise, we have strong external linkage. - return llvm::Function::ExternalLinkage; - } + + // Otherwise, we have strong external linkage. + assert(Linkage == GVA_StrongExternal); + return llvm::Function::ExternalLinkage; } |

