clang-1/test/CXX
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
..
basic Fix ADL for types declared in transparent decls, from Alp Toker! 2010-04-30 07:08:38 +00:00
class Turn access control on by default in -cc1. 2010-04-09 19:03:51 +00:00
class.access Complete reimplementation of the synthesis for implicitly-defined copy 2010-05-01 20:49:11 +00:00
class.derived Implement computation of the final overriders for each virtual 2010-03-23 23:47:56 +00:00
conv Turn access control on by default in -cc1. 2010-04-09 19:03:51 +00:00
dcl.dcl Change the 'declared at' diagnostic to say 'declared here'. 2010-04-23 02:20:12 +00:00
dcl.decl Actually produce base paths for CastExprs of kind CK_DerivedToBase. 2010-04-24 19:06:50 +00:00
except/except.handle Improve diagnostics when we fail to convert from a source type to a 2010-04-09 00:35:39 +00:00
expr Restore r101841 without modification. Also mark 'operator delete' as used for 2010-04-20 02:18:25 +00:00
lex Fix for PR6220: compute the correct type for multicharacter literals. 2010-02-03 18:21:45 +00:00
over Implement C++ [over.ics.user]p3, which restricts the final conversion 2010-04-12 23:42:09 +00:00
special Add test case for PR6141, which was fixed a few days ago 2010-02-24 21:54:27 +00:00
stmt.stmt/stmt.select change Scope::WithinElse to be a normal scope flag, widen the 2010-04-12 06:12:50 +00:00
temp When performing partial ordering of class template partial 2010-04-29 06:31:36 +00:00