diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-03-29 14:19:55 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-03-29 14:19:55 +0000 |
commit | af3698066a1ea2e5ab4cc08ae9a59620cf18adb7 (patch) | |
tree | 6611f457cde58103bfc8f8c9005b7437ca7a2c0b /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 238b508aafd6199a98c09e5a600452e3496f03c3 (diff) | |
download | bcm5719-llvm-af3698066a1ea2e5ab4cc08ae9a59620cf18adb7.tar.gz bcm5719-llvm-af3698066a1ea2e5ab4cc08ae9a59620cf18adb7.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index addf8d09e41..92f49379f1b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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 { |