aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-07-18 05:26:13 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-07-18 05:26:13 +0000
commit26da4ddfa6d1269731adc1432bf10fb22dde9ba7 (patch)
tree48d7ffbab42e2d4b3a86513c7f58c67ca5c5ea3e /clang/lib/CodeGen/CodeGenModule.cpp
parent14b3b4df6ff599c665ffb625920e93c0cbae663a (diff)
downloadllvm-26da4ddfa6d1269731adc1432bf10fb22dde9ba7.zip
llvm-26da4ddfa6d1269731adc1432bf10fb22dde9ba7.tar.gz
llvm-26da4ddfa6d1269731adc1432bf10fb22dde9ba7.tar.bz2
In C99, emit an inline function when encountering an extern redeclaration.
Fixes PR10233! llvm-svn: 135377
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 2bd5df2..f3c3c24 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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.");