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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user