llvm-project/clang/test
Douglas Gregor 94f9a4820a 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
2010-05-05 05:51:00 +00:00
..
ASTMerge Instead of counting totally diagnostics, split the count into a count 2010-04-07 18:47:42 +00:00
Analysis Refactor the AnalysisConsumer to analyze functions after the whole 2010-04-30 04:14:20 +00:00
CXX An access is permitted if the current template instantiates to the appropriate 2010-05-04 05:11:27 +00:00
CodeCompletion When code completion produces an overload set as its results (e.g., 2010-04-06 20:19:47 +00:00
CodeGen Emit the globals, metadata, etc. associated with static variables even when 2010-05-04 20:45:42 +00:00
CodeGenCXX Reimplement code generation for copying fields in the 2010-05-05 05:51:00 +00:00
CodeGenObjC Test case for NeXt's -fno-constant-cfstrings option. 2010-04-26 17:59:24 +00:00
CodeGenObjCXX Fixes a code gen. crash when ivar object has trivial constructor. 2010-05-04 19:29:32 +00:00
Coverage Rename -dump-record-layouts to -fdump-record-layouts now that the option behaves like aa flag. 2010-04-10 19:09:13 +00:00
Driver Driver: Add support for -fobjc-abi-version=. 2010-04-28 23:25:24 +00:00
FixIt Teach clang -fixit to modify files in-place, or -fixit=suffix to create new 2010-04-24 01:30:46 +00:00
Frontend Fix PR5982, a refacto in checking for '=' in a -D argument. 2010-01-10 00:46:21 +00:00
Headers Make sure we don't include mm_malloc.h in this test, it includes errno.h which 2010-03-26 20:17:23 +00:00
Index Rework clang_annotateTokens() to annotate tokens with information that more closely matches 2010-05-05 00:55:23 +00:00
Lexer push some source location information down through the compiler, 2010-04-20 20:35:58 +00:00
Misc Introduce a limit on the depth of the macro instantiation backtrace 2010-05-04 17:13:42 +00:00
PCH Completely reimplement __builtin_offsetof, based on a patch by Roberto 2010-04-28 22:16:22 +00:00
Parser Fix a tentative-parse error with unqualified template ids in cast expressions. 2010-04-30 03:11:01 +00:00
Preprocessor Fix pasto in this test 2010-04-30 03:07:23 +00:00
Rewriter make the rewriter add a #ifndef around the #define of __attribute__. 2010-04-13 17:33:56 +00:00
Sema When instantiating a function that was declared via a typedef, e.g., 2010-05-04 18:18:31 +00:00
SemaCXX When creating a call to a base subobject's operator= in an 2010-05-04 15:20:55 +00:00
SemaObjC Diagnose unused exception parameters under a different warning group 2010-05-03 18:51:14 +00:00
SemaObjCXX Test for my last patch. 2010-05-03 21:06:59 +00:00
SemaTemplate When instantiating a function that was declared via a typedef, e.g., 2010-05-04 18:18:31 +00:00
CMakeLists.txt Add test cases for r98003 and r98006. 2010-03-08 23:38:27 +00:00
Makefile grr, lit only hates me, not the rest of the world. 2010-04-20 04:33:06 +00:00
TestRunner.sh Switch TestRunner.sh to just use 'lit'. 2009-09-20 22:00:23 +00:00
cxx-sections.data Update C++ section data and directory structure to reflect N2914 2009-06-30 16:45:27 +00:00
lit.cfg tests: Mangle '-vg' onto the end of the triple when running under valgrind, so 2010-03-20 21:13:08 +00:00
lit.site.cfg.in Rework site config for cmake to be generated at configure time, and only pass 2009-11-07 23:53:32 +00:00
make_test_dirs.pl Add the structure for a C++ test suite that mimics the structure of the C++ standard 2009-06-13 06:06:53 +00:00