forked from OSchip/llvm-project
03282f2fe1
After taking C++98 implicit moves out in D104500, we put it back in, but now in a new form which preserves compatibility with pure C++98 programs, while at the same time giving almost all the goodies from P1825. * We use the exact same rules as C++20 with regards to which id-expressions are move eligible. The previous incarnation would only benefit from the proper subset which is copy ellidable. This means we can implicit move, in addition: * Parameters. * RValue references. * Exception variables. * Variables with higher-than-natural required alignment. * Objects with different type from the function return type. * We preserve the two-overload resolution, with one small tweak to the first one: If we either pick a (possibly converting) constructor which does not take an rvalue reference, or a user conversion operator which is not ref-qualified, we abort into the second overload resolution. This gives C++98 almost all the implicit move patterns which we had created test cases for, while at the same time preserving the meaning of these three patterns, which are found in pure C++98 programs: * Classes with both const and non-const copy constructors, but no move constructors, continue to have their non-const copy constructor selected. * We continue to reject as ambiguous the following pattern: ``` struct A { A(B &); }; struct B { operator A(); }; A foo(B x) { return x; } ``` * We continue to pick the copy constructor in the following pattern: ``` class AutoPtrRef { }; struct AutoPtr { AutoPtr(AutoPtr &); AutoPtr(); AutoPtr(AutoPtrRef); operator AutoPtrRef(); }; AutoPtr test_auto_ptr() { AutoPtr p; return p; } ``` Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: Quuxplusone Differential Revision: https://reviews.llvm.org/D105756 |
||
---|---|---|
.. | ||
Inputs | ||
NSString-type.mm | ||
abstract-class-type-ivar.mm | ||
arc-0x.mm | ||
arc-bool-conversion.mm | ||
arc-bridged-cast.mm | ||
arc-libstdcxx.mm | ||
arc-memfunc.mm | ||
arc-nsconsumed-errors.mm | ||
arc-objc-lifetime.mm | ||
arc-overloading.mm | ||
arc-ppe.mm | ||
arc-ptr-comparison.mm | ||
arc-system-header.mm | ||
arc-templates.mm | ||
arc-type-conversion.mm | ||
arc-type-traits.mm | ||
arc-unavailable-for-weakref.mm | ||
arc-unbridged-cast.mm | ||
argument-dependent-lookup.mm | ||
attr-swift_name-cxx.mm | ||
attr-trivial-abi.mm | ||
base-type-as-written.mm | ||
block-capture.mm | ||
block-cleanup.mm | ||
block-for-lambda-conversion.mm | ||
block-variable-move.mm | ||
blocks.mm | ||
boxing-illegal-types.mm | ||
bridge-cast-redecl.mm | ||
builtin-objcsuper.mm | ||
capturing-flexible-array-in-block.mm | ||
category-lookup.mm | ||
class-method-self.mm | ||
class-templ-error-null-init.mm | ||
composite-objc-pointertype.mm | ||
comptypes-1.mm | ||
comptypes-7.mm | ||
conditional-expr.mm | ||
const-cast.mm | ||
contextual-convert-to-id.mm | ||
conversion-ranking.mm | ||
conversion-to-objc-pointer-2.mm | ||
conversion-to-objc-pointer.mm | ||
crash.mm | ||
cstyle-block-pointer-cast.mm | ||
cstyle-cast.mm | ||
cxx1y-lambda.mm | ||
cxxoperator-selector.mm | ||
debugger-cast-result-to-id.mm | ||
debugger-support.mm | ||
decltype.mm | ||
deduction.mm | ||
delay-parsing-cfunctions.mm | ||
delay-parsing-cplusfuncs.mm | ||
delay-parsing-func-tryblock.mm | ||
dllexport.mm | ||
dllimport.mm | ||
exceptions-fragile.mm | ||
exceptions.mm | ||
expr-objcxx.mm | ||
flexible-array.mm | ||
foreach-block.mm | ||
foreach.mm | ||
format-strings.mm | ||
fragile-abi-object-assign.m | ||
function-pointer-void-star.mm | ||
gc-attributes.mm | ||
goto.mm | ||
instancetype.mm | ||
instantiate-expr.mm | ||
instantiate-message.mm | ||
instantiate-method-return.mm | ||
instantiate-property-access.mm | ||
instantiate-stmt.mm | ||
interface-return-type.mm | ||
is-base-of.mm | ||
ivar-construct.mm | ||
ivar-lookup.mm | ||
ivar-reference-type.mm | ||
ivar-struct.mm | ||
linkage-spec.mm | ||
lit.local.cfg | ||
literals.mm | ||
message.mm | ||
microsoft-abi-byval.mm | ||
missing-lhs-gun-extension.mm | ||
namespace-lookup.mm | ||
no-crash-thread-safety-analysis.mm | ||
noescape.mm | ||
null_objc_pointer.mm | ||
nullability-completeness-cferror.mm | ||
nullability-consistency-arrays.mm | ||
nullability-consistency.mm | ||
nullability-pragmas.mm | ||
nullptr.mm | ||
objc-boxed-expressions-nsvalue.mm | ||
objc-container-subscripting.mm | ||
objc-decls-inside-namespace.mm | ||
objc-extern-c.mm | ||
objc-pointer-conv.mm | ||
objc-weak-type-traits.mm | ||
objc-weak.mm | ||
objc2-merge-gc-attribue-decl.mm | ||
objcbridge-attribute-arc.mm | ||
objcbridge-attribute.mm | ||
objcbridge-related-attribute.mm | ||
objcbridge-static-cast.mm | ||
objcxx_openmp.mm | ||
old-style-cast.mm | ||
overload-gc.mm | ||
overload.mm | ||
parameterized_classes.mm | ||
parameterized_classes_arc.mm | ||
parameterized_classes_subst.mm | ||
parameters.mm | ||
pointer-to-objc-pointer-conv.mm | ||
pr32725.mm | ||
propert-dot-error.mm | ||
properties.mm | ||
property-invalid-type.mm | ||
property-reference.mm | ||
property-synthesis-error.mm | ||
property-type-mismatch.mm | ||
protocol-lookup.mm | ||
pseudo-destructor.mm | ||
references.mm | ||
reinterpret-cast-objc-pointertype.mm | ||
related-result-type-inference.mm | ||
reserved-keyword-methods.mm | ||
sel-address.mm | ||
standard-conversion-to-bool.mm | ||
static-cast.mm | ||
synchronized.mm | ||
thread-safety-analysis.h | ||
type-traits-is-pointer.mm | ||
typeloc-data-alignment.mm | ||
typo-correction.mm | ||
unknown-anytype.mm | ||
vararg-non-pod.mm | ||
vla.mm | ||
void_to_obj.mm | ||
warn-called-once.mm | ||
warn-implicit-self-in-block.mm | ||
warn-missing-super.mm | ||
warn-objc-literal-conversion.mm | ||
warn-strict-selector-match.mm | ||
warn-thread-safety-analysis.mm |