[cfe-commits] r78355 - in /cfe/trunk/lib/CodeGen: CodeGenFunction.cpp CodeGenModule.cpp
Fariborz Jahanian
fjahanian at apple.com
Thu Aug 6 16:38:16 PDT 2009
Author: fjahanian
Date: Thu Aug 6 18:38:16 2009
New Revision: 78355
URL: http://llvm.org/viewvc/llvm-project?rev=78355&view=rev
Log:
Patch toward synthesizing copy constructors.
Work in progress.
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=78355&r1=78354&r2=78355&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Aug 6 18:38:16 2009
@@ -240,13 +240,22 @@
}
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.
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=78355&r1=78354&r2=78355&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Aug 6 18:38:16 2009
@@ -645,7 +645,11 @@
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);
}
}
More information about the cfe-commits
mailing list