aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp12
-rw-r--r--lib/CodeGen/CodeGenModule.cpp8
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index bb53dcc39e..708100e2a0 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -238,7 +238,17 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
EmitDtorEpilogue(DD);
FinishFunction(S->getRBracLoc());
}
-
+ else
+ if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
+ assert(
+ !cast<CXXRecordDecl>(CD->getDeclContext())->
+ hasUserDeclaredConstructor() &&
+ "bogus constructor is being synthesize");
+ StartFunction(FD, FD->getResultType(), Fn, Args, SourceLocation());
+ EmitCtorPrologue(CD);
+ FinishFunction();
+ }
+
// Destroy the 'this' declaration.
if (CXXThisDecl)
CXXThisDecl->Destroy(getContext());
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 2cc0aab22a..bc3bd0bfa9 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -640,6 +640,14 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(const char *MangledName,
// top-level declarations.
if (FD->isThisDeclarationADefinition() && MayDeferGeneration(FD))
DeferredDeclsToEmit.push_back(D);
+ // A called constructor which has no definition or declaration need be
+ // synthesized.
+ else if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
+ const CXXRecordDecl *ClassDecl =
+ cast<CXXRecordDecl>(CD->getDeclContext());
+ if (!ClassDecl->hasUserDeclaredConstructor())
+ DeferredDeclsToEmit.push_back(D);
+ }
}
// This function doesn't have a complete type (for example, the return