diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-14 06:44:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-14 06:44:48 +0000 |
commit | 92028dad66e317561b0e40360e329a9a443eaeb4 (patch) | |
tree | 1279ce97691ffc622b6de5c4ac3cf97b8ca3f868 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 169a5c963f5f20c407c67966812b7ee1957e9242 (diff) | |
download | bcm5719-llvm-92028dad66e317561b0e40360e329a9a443eaeb4.tar.gz bcm5719-llvm-92028dad66e317561b0e40360e329a9a443eaeb4.zip |
defer emission of always_inline, extern_inline, and inline functions (when
not in c89 mode).
llvm-svn: 69032
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 5ef57ffdcc2..c771461704d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -482,18 +482,23 @@ bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) { if (FD->hasAttr<ConstructorAttr>() || FD->hasAttr<DestructorAttr>()) return false; - // FIXME: What about inline, and/or extern inline? - if (FD->getStorageClass() != FunctionDecl::Static) - return false; - } else { - const VarDecl *VD = cast<VarDecl>(Global); - assert(VD->isFileVarDecl() && "Invalid decl"); - - if (VD->getStorageClass() != VarDecl::Static) - return false; + GVALinkage Linkage = GetLinkageForFunctionOrMethodDecl(FD); + + // static, static inline, always_inline, and extern inline functions can + // always be deferred. + if (Linkage == GVA_Internal || Linkage == GVA_ExternInline) + return true; + + // inline functions can be deferred unless we're in C89 mode. + if (Linkage == GVA_Inline && (Features.C99 || Features.CPlusPlus)) + return true; + + return false; } - - return true; + + const VarDecl *VD = cast<VarDecl>(Global); + assert(VD->isFileVarDecl() && "Invalid decl"); + return VD->getStorageClass() == VarDecl::Static; } void CodeGenModule::EmitGlobal(const ValueDecl *Global) { |