summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGClass.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* simplify EmitAggMemberInitializer a bit and make it work in 32-bit mode,Chris Lattner2010-05-061-3/+2
| | | | | | fixing PR7063. llvm-svn: 103171
* Reimplement code generation for copying fields in theDouglas Gregor2010-05-051-215/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* When inheriting a default argument expression, inherit the full expression,John McCall2010-05-041-1/+3
| | | | | | | | | not just the inner expression. This is important if the expression has any temporaries. Fixes PR 7028. Basically a symptom of really tragic method names. llvm-svn: 102998
* Remove OldGetAddressOfBaseClass - bye bye ambiguities.Anders Carlsson2010-05-031-91/+0
| | | | llvm-svn: 102889
* Get rid of the last caller of OldGetAddressOfBaseClass.Anders Carlsson2010-05-031-8/+16
| | | | llvm-svn: 102888
* More work towards getting rid of OldGetAddressOfBaseClass.Anders Carlsson2010-05-031-1/+10
| | | | llvm-svn: 102887
* Get rid of a call to GetAddressOfDirectBaseInCompleteClass.Anders Carlsson2010-05-021-4/+7
| | | | llvm-svn: 102886
* Have getSubVTTIndex take a BaseSubobject instead of just a base.Anders Carlsson2010-05-021-1/+7
| | | | llvm-svn: 102885
* Pass ForVirtualBase all the way to GetVTTParameter.Anders Carlsson2010-05-021-4/+8
| | | | llvm-svn: 102883
* Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall.Anders Carlsson2010-05-021-8/+13
| | | | llvm-svn: 102882
* Revert my last change and add a 'ForVirtualBase' parameter to ↵Anders Carlsson2010-05-021-5/+2
| | | | | | EmitCXXConstructorCall instead. llvm-svn: 102881
* Pass the construction kind down to EmitCXXConstructorCall.Anders Carlsson2010-05-021-2/+6
| | | | llvm-svn: 102880
* Remove another unused function.Anders Carlsson2010-05-021-36/+0
| | | | llvm-svn: 102871
* Remove an unused function.Anders Carlsson2010-05-021-83/+0
| | | | llvm-svn: 102870
* Complete reimplementation of the synthesis for implicitly-defined copyDouglas Gregor2010-05-011-92/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | assignment operators. Previously, Sema provided type-checking and template instantiation for copy assignment operators, then CodeGen would synthesize the actual body of the copy constructor. Unfortunately, the two were not in sync, and CodeGen might pick a copy-assignment operator that is different from what Sema chose, leading to strange failures, e.g., link-time failures when CodeGen called a copy-assignment operator that was not instantiation, run-time failures when copy-assignment operators were overloaded for const/non-const references and the wrong one was picked, and run-time failures when by-value copy-assignment operators did not have their arguments properly copy-initialized. This implementation synthesizes the implicitly-defined copy assignment operator bodies in Sema, so that the resulting ASTs encode exactly what CodeGen needs to do; there is no longer any special code in CodeGen to synthesize copy-assignment operators. The synthesis of the body is relatively simple, and we generate one of three different kinds of copy statements for each base or member: - For a class subobject, call the appropriate copy-assignment operator, after overload resolution has determined what that is. - For an array of scalar types or an array of class types that have trivial copy assignment operators, construct a call to __builtin_memcpy. - For an array of class types with non-trivial copy assignment operators, synthesize a (possibly nested!) for loop whose inner statement calls the copy constructor. - For a scalar type, use built-in assignment. This patch fixes at least a few tests cases in Boost.Spirit that were failing because CodeGen picked the wrong copy-assignment operator (leading to link-time failures), and I suspect a number of undiagnosed problems will also go away with this change. Some of the diagnostics we had previously have gotten worse with this change, since we're going through generic code for our type-checking. I will improve this in a subsequent patch. llvm-svn: 102853
* Simplify EmitCopyCtorCall.Anders Carlsson2010-05-011-12/+5
| | | | llvm-svn: 102849
* Simplify EmitClassAggrMemberwiseCopy.Anders Carlsson2010-05-011-18/+7
| | | | llvm-svn: 102848
* Clean up EmitClassMemberwiseCopy further.Anders Carlsson2010-05-011-20/+9
| | | | llvm-svn: 102846
* Get rid of a parameter from EmitClassMemberwiseCopy.Anders Carlsson2010-05-011-3/+3
| | | | llvm-svn: 102845
* When defining implicit copy constructors, use SetBaseOrMemberInitializers to ↵Anders Carlsson2010-05-011-12/+0
| | | | | | initialize the bases. llvm-svn: 102842
* Remove an unnecessary parameter from EmitClassCopyAssignment.Anders Carlsson2010-04-301-11/+6
| | | | llvm-svn: 102747
* Account for the VTT argument when making an implicit copy constructor forJohn McCall2010-04-301-1/+13
| | | | | | | | | a class with virtual bases. Just a patch until Sema starts (correctly) doing most of this analysis. Fixes PR 6622. llvm-svn: 102692
* Get the base class addresses before calling EmitClassCopyAssignment.Anders Carlsson2010-04-301-5/+8
| | | | llvm-svn: 102676
* Remove an unnecessary argument to EmitClassCopyAssignment.Anders Carlsson2010-04-291-9/+7
| | | | llvm-svn: 102674
* Land another cleanup patch.Anders Carlsson2010-04-251-14/+8
| | | | llvm-svn: 102293
* Revert enough of my patches to fix self-host again :(Anders Carlsson2010-04-251-37/+76
| | | | llvm-svn: 102289
* Cleanup SynthesizeCXXCopyConstructor.Anders Carlsson2010-04-241-16/+9
| | | | llvm-svn: 102286
* Clean up SynthesizeCXXCopyAssignment a little.Anders Carlsson2010-04-241-15/+11
| | | | llvm-svn: 102285
* RenameGetAddressOfBaseOfCompleteClass to ↵Anders Carlsson2010-04-241-20/+20
| | | | | | GetAddressOfDirectBaseInCompleteClass to reflect that it only handles direct bases. llvm-svn: 102284
* More cleanup.Anders Carlsson2010-04-241-23/+15
| | | | llvm-svn: 102282
* Simplify EmitClassMemberwiseCopy now that it's only used for fields.Anders Carlsson2010-04-241-25/+13
| | | | llvm-svn: 102281
* DefineImplicitCopyConstructor now uses SetBaseOrMemberInitializers to create ↵Anders Carlsson2010-04-241-12/+0
| | | | | | implicit base initializers. (Member initializers are still handled by CodeGenFunction::SynthesizeCXXCopyConstructor for now). llvm-svn: 102279
* Rename GetAddressOfBaseClass to OldGetAddressOfBaseClass.Anders Carlsson2010-04-241-48/+10
| | | | llvm-svn: 102275
* Get rid of the old GetNonVirtualBaseClassOffset and change all call sites to ↵Anders Carlsson2010-04-241-25/+0
| | | | | | use the new version. llvm-svn: 102274
* Change CodeGenFunction::GetAddressOfDerivedClass to take a BasePath.Anders Carlsson2010-04-241-7/+21
| | | | llvm-svn: 102273
* Convert more call sites over to the new GetAddressOfBaseClass.Anders Carlsson2010-04-241-1/+1
| | | | llvm-svn: 102272
* Add a new GetAddressOfBaseClass overload that takes a base path and. Use it ↵Anders Carlsson2010-04-241-0/+104
| | | | | | for derived-to-base casts. llvm-svn: 102270
* Comment out an assert for now.Anders Carlsson2010-04-211-0/+3
| | | | llvm-svn: 102007
* Back out r101911 and see if it makes the bots happy.Anders Carlsson2010-04-201-28/+13
| | | | llvm-svn: 101921
* Fix a bug which triggered the assertion I added yesterday. Basically, when ↵Anders Carlsson2010-04-201-13/+28
| | | | | | we initialize the vtable pointer for a virtual base, and there was another path from the most derived class to another base with the same class type, we would use the wrong base. llvm-svn: 101911
* Move code to apply a non-virtual and virtual offset out into a separate ↵Anders Carlsson2010-04-201-19/+31
| | | | | | function. llvm-svn: 101909
* Pass the nearest virtual base decl to InitializeVTablePointers. No ↵Anders Carlsson2010-04-201-10/+7
| | | | | | functionality change right now. llvm-svn: 101872
* Assert that the path from the derived to the base class in ↵Anders Carlsson2010-04-201-0/+7
| | | | | | CodeGenFunction::GetAddressOfBaseClass is not ambiguous. llvm-svn: 101869
* Keep track of the actual storage specifier written on a variable orDouglas Gregor2010-04-191-0/+1
| | | | | | | | function declaration, since it may end up being changed (e.g., "extern" can become "static" if a prior declaration was static). Patch by Enea Zaffanella and Paolo Bolzoni. llvm-svn: 101826
* Have the CXXBaseOrMemberInitializer keep track of whether an initializer ↵Anders Carlsson2010-04-121-11/+1
| | | | | | initializes a virtual base or not. llvm-svn: 101004
* the big refactoring bits of PR3782.Rafael Espindola2010-03-301-1/+1
| | | | | | | | This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. llvm-svn: 99920
* Remove the old vtable layout code.Anders Carlsson2010-03-301-36/+0
| | | | llvm-svn: 99869
* Use the new function in EmitClassAggrMemberwiseCopy, fixing the same assert ↵Anders Carlsson2010-03-301-15/+2
| | | | | | as seen in PR6628 but for arrays this time. llvm-svn: 99867
* Factor emitting a call to a copy constructor out into a separate function.Anders Carlsson2010-03-301-40/+53
| | | | llvm-svn: 99866
* Introduce a CXXTemporariesCleanupScope RAII object and use it to cleanup the ↵Anders Carlsson2010-03-301-25/+21
| | | | | | temporaries code. llvm-svn: 99865
OpenPOWER on IntegriCloud