diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-07-18 05:26:13 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-07-18 05:26:13 +0000 |
commit | dce67a70a86db8758c926a76fdd980f5369d5746 (patch) | |
tree | 09c44f9dc494113bc9e18f99996d922e31b86b80 /lib/CodeGen | |
parent | 2acc6e3feda5e4f7d9009bdcf8b1cd777fecfe2d (diff) |
In C99, emit an inline function when encountering an extern redeclaration.
Fixes PR10233!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135377 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 2bd5df23eb..f3c3c247d2 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -597,7 +597,7 @@ void CodeGenModule::EmitLLVMUsed() { void CodeGenModule::EmitDeferred() { // Emit code for any potentially referenced deferred decls. Since a // previously unused static decl may become used during the generation of code - // for a static function, iterate until no changes are made. + // for a static function, iterate until no changes are made. while (!DeferredDeclsToEmit.empty() || !DeferredVTables.empty()) { if (!DeferredVTables.empty()) { @@ -740,8 +740,21 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { } // Forward declarations are emitted lazily on first use. - if (!FD->doesThisDeclarationHaveABody()) + if (!FD->doesThisDeclarationHaveABody()) { + if (!FD->doesDeclarationForceExternallyVisibleDefinition()) + return; + + const FunctionDecl *InlineDefinition = 0; + FD->getBody(InlineDefinition); + + llvm::StringRef MangledName = getMangledName(GD); + llvm::StringMap<GlobalDecl>::iterator DDI = + DeferredDecls.find(MangledName); + if (DDI != DeferredDecls.end()) + DeferredDecls.erase(DDI); + EmitGlobalDefinition(InlineDefinition); return; + } } else { const VarDecl *VD = cast<VarDecl>(Global); assert(VD->isFileVarDecl() && "Cannot emit local var decl as global."); |