From 2357aeec0da2740838963880edd97e43f14cb6fd Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 7 Jul 2011 20:25:10 +0000 Subject: A redeclaration of an inline method in C99 mode should trigger emission of that function. Fixes PR10233! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134634 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index ddef39726f..b2905299e4 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::iterator DDI = + DeferredDecls.find(MangledName); + if (DDI != DeferredDecls.end()) + DeferredDecls.erase(DDI); + EmitGlobalDefinition(InlineDefinition); return; + } } else { const VarDecl *VD = cast(Global); assert(VD->isFileVarDecl() && "Cannot emit local var decl as global."); -- cgit v1.2.3-18-g5258