CodeGen: Don't crash when replacing functions

The peculiarities of C99 create scenario where an LLVM IR function
declaration may need to be replaced with a definition baring a different
type because the prototype and definition are not required to agree.

However, we were not properly deferring this when it occurred.

This fixes PR19280.

llvm-svn: 205099
This commit is contained in:
David Majnemer
2014-03-29 14:19:55 +00:00
parent 238b508aaf
commit af3698066a
2 changed files with 15 additions and 6 deletions

View File

@@ -1177,12 +1177,14 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
if (!FD->doesDeclarationForceExternallyVisibleDefinition())
return;
const FunctionDecl *InlineDefinition = 0;
FD->getBody(InlineDefinition);
StringRef MangledName = getMangledName(GD);
DeferredDecls.erase(MangledName);
EmitGlobalDefinition(InlineDefinition);
// Compute the function info and LLVM type.
const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
llvm::Type *Ty = getTypes().GetFunctionType(FI);
GetOrCreateLLVMFunction(MangledName, Ty, GD, /*ForVTable=*/false,
/*DontDefer=*/false);
return;
}
} else {