summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-05 05:51:00 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-05 05:51:00 +0000
commit94f9a4820a90782569a8c4f8577e01bee87204a5 (patch)
treed4e3cd993e164d064abe0f0733aff984ea4418c3 /clang/lib/CodeGen/CodeGenFunction.h
parent58fe1756fb11ee441561cad8ea2acbe7888be913 (diff)
downloadbcm5719-llvm-94f9a4820a90782569a8c4f8577e01bee87204a5.tar.gz
bcm5719-llvm-94f9a4820a90782569a8c4f8577e01bee87204a5.zip
Reimplement code generation for copying fields in the
implicitly-generated copy constructor. Previously, Sema would perform some checking and instantiation to determine which copy constructors, etc., would be called, then CodeGen would attempt to figure out which copy constructor to call... but would get it wrong, or poke at an uninstantiated default argument, or fail in other ways. The new scheme is similar to what we now do for the implicit copy-assignment operator, where Sema performs all of the semantic analysis and builds specific ASTs that look similar to the ASTs we'd get from explicitly writing the copy constructor, so that CodeGen need only do a direct translation. However, it's not quite that simple because one cannot explicit write elementwise copy-construction of an array. So, I've extended CXXBaseOrMemberInitializer to contain a list of indexing variables used to copy-construct the elements. For example, if we have: struct A { A(const A&); }; struct B { A array[2][3]; }; then we generate an implicit copy assignment operator for B that looks something like this: B::B(const B &other) : array[i0][i1](other.array[i0][i1]) { } CodeGen will loop over the invented variables i0 and i1 to visit all elements in the array, so that each element in the destination array will be copy-constructed from the corresponding element in the source array. Of course, if we're dealing with arrays of scalars or class types with trivial copy-assignment operators, we just generate a memcpy rather than a loop. Fixes PR6928, PR5989, and PR6887. Boost.Regex now compiles and passes all of its regression tests. Conspicuously missing from this patch is handling for the exceptional case, where we need to destruct those objects that we have constructed. I'll address that case separately. llvm-svn: 103079
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h13
1 files changed, 2 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 90a3ec4a4b1..74f0a488b56 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -531,7 +531,8 @@ public:
/// GenerateThunk - Generate a thunk for the given method.
void GenerateThunk(llvm::Function *Fn, GlobalDecl GD, const ThunkInfo &Thunk);
- void EmitCtorPrologue(const CXXConstructorDecl *CD, CXXCtorType Type);
+ void EmitCtorPrologue(const CXXConstructorDecl *CD, CXXCtorType Type,
+ FunctionArgList &Args);
/// InitializeVTablePointer - Initialize the vtable pointer of the given
/// subobject.
@@ -554,8 +555,6 @@ public:
void InitializeVTablePointers(const CXXRecordDecl *ClassDecl);
- void SynthesizeCXXCopyConstructor(const FunctionArgList &Args);
-
/// EmitDtorEpilogue - Emit all code that comes at the end of class's
/// destructor. This is to call destructors on members and base classes in
/// reverse order of their construction.
@@ -802,14 +801,6 @@ public:
const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl);
- void EmitClassAggrMemberwiseCopy(llvm::Value *DestValue,
- llvm::Value *SrcValue,
- const ConstantArrayType *Array,
- const CXXRecordDecl *ClassDecl);
-
- void EmitClassMemberwiseCopy(llvm::Value *DestValue, llvm::Value *SrcValue,
- const CXXRecordDecl *ClassDecl);
-
void EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor,
CXXCtorType CtorType,
const FunctionArgList &Args);
OpenPOWER on IntegriCloud