Граф коммитов

98 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner 985f73960a simplify EmitAggMemberInitializer a bit and make it work in 32-bit mode,
fixing PR7063.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103171 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-06 06:35:23 +00:00
Douglas Gregor fb8cc25342 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103079 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-05 05:51:00 +00:00
John McCall 3d6c1782c4 When inheriting a default argument expression, inherit the full expression,
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102998 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-04 01:53:42 +00:00
Anders Carlsson 43373963ac Remove OldGetAddressOfBaseClass - bye bye ambiguities.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102889 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-03 00:32:27 +00:00
Anders Carlsson 8246cc7f85 Get rid of the last caller of OldGetAddressOfBaseClass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102888 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-03 00:29:58 +00:00
Anders Carlsson 4235840554 More work towards getting rid of OldGetAddressOfBaseClass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102887 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-03 00:07:07 +00:00
Anders Carlsson 77fae58f6d Get rid of a call to GetAddressOfDirectBaseInCompleteClass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102886 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 23:57:15 +00:00
Anders Carlsson c11bb21910 Have getSubVTTIndex take a BaseSubobject instead of just a base.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102885 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 23:53:25 +00:00
Anders Carlsson 314e622d20 Pass ForVirtualBase all the way to GetVTTParameter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102883 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 23:33:10 +00:00
Anders Carlsson 8e6404ca28 Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102882 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 23:29:11 +00:00
Anders Carlsson 155ed4a233 Revert my last change and add a 'ForVirtualBase' parameter to EmitCXXConstructorCall instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102881 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 23:20:53 +00:00
Anders Carlsson 24eb78e38a Pass the construction kind down to EmitCXXConstructorCall.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102880 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 23:01:10 +00:00
Anders Carlsson 82929316cc Remove another unused function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102871 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 18:13:35 +00:00
Anders Carlsson 05dd1f6292 Remove an unused function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102870 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 18:12:22 +00:00
Douglas Gregor 06a9f3680d Complete reimplementation of the synthesis for implicitly-defined copy
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102853 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01 20:49:11 +00:00
Anders Carlsson bfe7e91c12 Simplify EmitCopyCtorCall.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102849 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01 17:07:40 +00:00
Anders Carlsson 43db20e955 Simplify EmitClassAggrMemberwiseCopy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102848 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01 17:02:18 +00:00
Anders Carlsson f62756f45b Clean up EmitClassMemberwiseCopy further.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102846 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01 16:54:05 +00:00
Anders Carlsson 1d1d1185b4 Get rid of a parameter from EmitClassMemberwiseCopy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102845 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01 16:49:43 +00:00
Anders Carlsson 59b7f1538d When defining implicit copy constructors, use SetBaseOrMemberInitializers to initialize the bases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102842 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01 16:39:01 +00:00
Anders Carlsson 106d9ea61c Remove an unnecessary parameter from EmitClassCopyAssignment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102747 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30 19:45:28 +00:00
John McCall c743571e24 Account for the VTT argument when making an implicit copy constructor for
a class with virtual bases.  Just a patch until Sema starts (correctly) doing
most of this analysis.

Fixes PR 6622.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102692 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30 05:56:45 +00:00
Anders Carlsson f406d9c687 Get the base class addresses before calling EmitClassCopyAssignment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102676 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30 00:04:01 +00:00
Anders Carlsson 9ffdd45c56 Remove an unnecessary argument to EmitClassCopyAssignment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102674 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 23:51:42 +00:00
Anders Carlsson 9675466570 Land another cleanup patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102293 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-25 01:03:12 +00:00
Anders Carlsson 8e142ccf11 Revert enough of my patches to fix self-host again :(
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102289 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-25 00:52:09 +00:00
Anders Carlsson df1147e6d4 Cleanup SynthesizeCXXCopyConstructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102286 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 23:11:18 +00:00
Anders Carlsson 5f7cc730d7 Clean up SynthesizeCXXCopyAssignment a little.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102285 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 23:09:21 +00:00
Anders Carlsson 8561a8666c RenameGetAddressOfBaseOfCompleteClass to GetAddressOfDirectBaseInCompleteClass to reflect that it only handles direct bases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102284 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 23:01:49 +00:00
Anders Carlsson f500de5bdf More cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102282 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 22:43:39 +00:00
Anders Carlsson 6444c417b4 Simplify EmitClassMemberwiseCopy now that it's only used for fields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102281 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 22:36:50 +00:00
Anders Carlsson e127abe8bb DefineImplicitCopyConstructor now uses SetBaseOrMemberInitializers to create implicit base initializers. (Member initializers are still handled by CodeGenFunction::SynthesizeCXXCopyConstructor for now).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102279 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 22:25:18 +00:00
Anders Carlsson a88ad5618f Rename GetAddressOfBaseClass to OldGetAddressOfBaseClass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102275 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 21:51:08 +00:00
Anders Carlsson e04d45e052 Get rid of the old GetNonVirtualBaseClassOffset and change all call sites to use the new version.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102274 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 21:27:51 +00:00
Anders Carlsson a04efdf635 Change CodeGenFunction::GetAddressOfDerivedClass to take a BasePath.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102273 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 21:23:59 +00:00
Anders Carlsson fc89c31a32 Convert more call sites over to the new GetAddressOfBaseClass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102272 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 21:12:55 +00:00
Anders Carlsson 34a2d384c7 Add a new GetAddressOfBaseClass overload that takes a base path and. Use it for derived-to-base casts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102270 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 21:06:20 +00:00
Anders Carlsson c2a9b79739 Comment out an assert for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102007 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-21 18:03:05 +00:00
Anders Carlsson 3e79c30807 Back out r101911 and see if it makes the bots happy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101921 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 18:05:10 +00:00
Anders Carlsson 36fd6beef1 Fix a bug which triggered the assertion I added yesterday. Basically, when 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101911 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 16:22:16 +00:00
Anders Carlsson 9dc228a1b9 Move code to apply a non-virtual and virtual offset out into a separate function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101909 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 16:03:35 +00:00
Anders Carlsson b3b772ea15 Pass the nearest virtual base decl to InitializeVTablePointers. No functionality change right now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101872 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 05:22:15 +00:00
Anders Carlsson 2692d8284c Assert that the path from the derived to the base class in CodeGenFunction::GetAddressOfBaseClass is not ambiguous.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101869 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 05:07:22 +00:00
Douglas Gregor 16573fa970 Keep track of the actual storage specifier written on a variable or
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101826 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 22:54:31 +00:00
Anders Carlsson 80638c5e63 Have the CXXBaseOrMemberInitializer keep track of whether an initializer initializes a virtual base or not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101004 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12 00:51:03 +00:00
Rafael Espindola 264ba48dc9 the big refactoring bits of PR3782.
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99920 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 20:24:48 +00:00
Anders Carlsson bfb7a1d6eb Remove the old vtable layout code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99869 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 03:43:47 +00:00
Anders Carlsson 8887bdcd40 Use the new function in EmitClassAggrMemberwiseCopy, fixing the same assert as seen in PR6628 but for arrays this time.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99867 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 03:30:08 +00:00
Anders Carlsson 21c9ad9d29 Factor emitting a call to a copy constructor out into a separate function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99866 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 03:27:09 +00:00
Anders Carlsson 44ec82b4a1 Introduce a CXXTemporariesCleanupScope RAII object and use it to cleanup the temporaries code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99865 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 03:14:41 +00:00