llvm-project/clang/lib/Sema
Douglas Gregor b139cd5843 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.

llvm-svn: 102853
2010-05-01 20:49:11 +00:00
..
AnalysisBasedWarnings.cpp Don't perform AnalysisBasedWarnings in Sema or run the static analyzer when a 2010-04-30 21:49:25 +00:00
AnalysisBasedWarnings.h Remove micro-optimization for not issueing CFG-based warnings for 'static inline' functions 2010-04-08 18:51:44 +00:00
CMakeLists.txt Refactor CFG-based warnings in Sema to be run by a worked object called AnalysisBasedWarnings. 2010-03-20 21:06:02 +00:00
CXXFieldCollector.h ActOnTagDefinitionError is supposed to 'unwind' ActOnTagStartDefinition, not 2010-03-17 19:25:57 +00:00
CodeCompleteConsumer.cpp Add raw_ostream operators to NamedDecl for convenience. Switch over all users of getNameAsString on a stream. 2010-04-17 09:33:03 +00:00
IdentifierResolver.cpp Optimize the implementation of IdDeclInfo pooling in the IdentifierResolver. 2010-02-15 19:38:00 +00:00
IdentifierResolver.h Eliminate dead code. 2010-01-02 21:44:36 +00:00
JumpDiagnostics.cpp Improve the AST representation of Objective-C @try/@catch/@finally 2010-04-23 22:50:49 +00:00
Lookup.h Recommit r102215, this time being more careful to only set the "principal 2010-04-24 01:30:58 +00:00
Makefile Allow users to set CPPFLAGS and CXXFLAGS on the make command line. 2010-03-12 22:55:16 +00:00
ParseAST.cpp push some source location information down through the compiler, 2010-04-20 20:35:58 +00:00
Sema.cpp Add base paths to CK_UncheckedDerivedToBase and CK_DerivedToBaseMemberPointer. 2010-04-24 19:22:20 +00:00
Sema.h Complete reimplementation of the synthesis for implicitly-defined copy 2010-05-01 20:49:11 +00:00
SemaAccess.cpp Add another 'catch all' access diagnostic. 2010-04-23 03:41:35 +00:00
SemaAttr.cpp Rip out the last remaining implicit use of OverloadedFunctionDecl in Sema: 2009-12-02 08:25:40 +00:00
SemaCXXCast.cpp Add base paths for CK_BaseToDerived and CK_BaseToDerivedMemberPointer. 2010-04-24 19:36:51 +00:00
SemaCXXScopeSpec.cpp It turns out that basically every caller to RequireCompleteDeclContext 2010-05-01 00:40:08 +00:00
SemaChecking.cpp Add FunctionDecl::isVariadic() to match BlockDecl::isVariadic() and ObjCMethodDecl::isVariadic(). 2010-04-29 16:49:01 +00:00
SemaCodeComplete.cpp It turns out that basically every caller to RequireCompleteDeclContext 2010-05-01 00:40:08 +00:00
SemaDecl.cpp It turns out that basically every caller to RequireCompleteDeclContext 2010-05-01 00:40:08 +00:00
SemaDeclAttr.cpp Add calling convention related attributes to related declaration. Mark attributes invalid on type related checking so to add them to declarations only when everything is ok. 2010-04-30 13:10:51 +00:00
SemaDeclCXX.cpp Complete reimplementation of the synthesis for implicitly-defined copy 2010-05-01 20:49:11 +00:00
SemaDeclObjC.cpp More of Sema to implement initialization of 2010-04-28 16:11:27 +00:00
SemaExceptionSpec.cpp Reinstate my CodeModificationHint -> FixItHint renaming patch, without 2010-03-31 17:46:05 +00:00
SemaExpr.cpp Complete reimplementation of the synthesis for implicitly-defined copy 2010-05-01 20:49:11 +00:00
SemaExprCXX.cpp When determining a standard conversion sequence involves resolving the 2010-04-29 18:24:40 +00:00
SemaExprObjC.cpp With -fno-constant-cfstrrings, class NSConstantString 2010-04-23 23:19:04 +00:00
SemaInit.cpp When explicitly building a temporary object (CXXTemporaryObjectExpr), 2010-04-27 20:36:09 +00:00
SemaInit.h Whenever we complain about a failed initialization of a function or 2010-04-22 00:20:18 +00:00
SemaLookup.cpp It turns out that basically every caller to RequireCompleteDeclContext 2010-05-01 00:40:08 +00:00
SemaObjCProperty.cpp Properties cannot be synthesized by-dafult in 2010-04-29 17:52:18 +00:00
SemaOverload.cpp When determining a standard conversion sequence involves resolving the 2010-04-29 18:24:40 +00:00
SemaOverload.h Improve our handling of user-defined conversions as part of overload 2010-04-17 22:01:05 +00:00
SemaStmt.cpp Refactor Objective-C @catch parameter checking by detangling it from 2010-04-26 17:32:49 +00:00
SemaTemplate.cpp It turns out that basically every caller to RequireCompleteDeclContext 2010-05-01 00:40:08 +00:00
SemaTemplate.h After performing template argument deduction for a function template, 2010-03-28 02:42:43 +00:00
SemaTemplateDeduction.cpp When performing partial ordering of class template partial 2010-04-29 06:31:36 +00:00
SemaTemplateInstantiate.cpp Clean up our handling of local instantiation scopes, which keep track 2010-04-30 18:55:50 +00:00
SemaTemplateInstantiateDecl.cpp Clean up our handling of local instantiation scopes, which keep track 2010-04-30 18:55:50 +00:00
SemaType.cpp Add calling convention related attributes to related declaration. Mark attributes invalid on type related checking so to add them to declarations only when everything is ok. 2010-04-30 13:10:51 +00:00
TargetAttributesSema.cpp Don't emit a warning about a dllimport attribute being used in a typedef 2010-02-21 05:12:56 +00:00
TargetAttributesSema.h Generalize target weirdness handling having proper layering in mind: 2010-01-10 12:58:08 +00:00
TreeTransform.h Fix a thinko that caused us not to compute __builtin_offset as a 2010-04-30 20:35:01 +00:00