aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-08-06 23:38:16 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-08-06 23:38:16 +0000
commit9889652dbc10060cd604861ed2e5bc6719f845b0 (patch)
tree0795f4bf34586a0531550176bb962c03d3139ac9
parent566a6faa54235590ab8d7d177dfac08586f545b0 (diff)
Patch toward synthesizing copy constructors.
Work in progress. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78355 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp23
-rw-r--r--lib/CodeGen/CodeGenModule.cpp6
2 files changed, 21 insertions, 8 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 22c099f8dc..0f155ec648 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -240,13 +240,22 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
}
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();
+ const CXXRecordDecl *ClassDecl =
+ cast<CXXRecordDecl>(CD->getDeclContext());
+ (void) ClassDecl;
+ if (CD->isCopyConstructor(getContext())) {
+ assert(!ClassDecl->hasUserDeclaredCopyConstructor() &&
+ "bogus constructor is being synthesize");
+ StartFunction(FD, FD->getResultType(), Fn, Args, SourceLocation());
+ FinishFunction();
+ }
+ else {
+ assert(!ClassDecl->hasUserDeclaredConstructor() &&
+ "bogus constructor is being synthesize");
+ StartFunction(FD, FD->getResultType(), Fn, Args, SourceLocation());
+ EmitCtorPrologue(CD);
+ FinishFunction();
+ }
}
// Destroy the 'this' declaration.
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 249764e9d9..8e53651c8e 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -645,7 +645,11 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(const char *MangledName,
else if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
const CXXRecordDecl *ClassDecl =
cast<CXXRecordDecl>(CD->getDeclContext());
- if (!ClassDecl->hasUserDeclaredConstructor())
+ if (CD->isCopyConstructor(getContext())) {
+ if (!ClassDecl->hasUserDeclaredCopyConstructor())
+ DeferredDeclsToEmit.push_back(D);
+ }
+ else if (!ClassDecl->hasUserDeclaredConstructor())
DeferredDeclsToEmit.push_back(D);
}
}