Deleted Added
full compact
SemaInit.cpp (207619) SemaInit.cpp (208600)
1//===--- SemaInit.cpp - Semantic Analysis for Initializers ----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 610 unchanged lines hidden (view full) ---

619 // an aggregate.
620 // FIXME: In C++0x, this is yet another form of initialization.
621 SemaRef.Diag(IList->getLocStart(), diag::err_init_non_aggr_init_list)
622 << DeclType << IList->getSourceRange();
623 hadError = true;
624 } else if (DeclType->isReferenceType()) {
625 CheckReferenceType(Entity, IList, DeclType, Index,
626 StructuredList, StructuredIndex);
1//===--- SemaInit.cpp - Semantic Analysis for Initializers ----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 610 unchanged lines hidden (view full) ---

619 // an aggregate.
620 // FIXME: In C++0x, this is yet another form of initialization.
621 SemaRef.Diag(IList->getLocStart(), diag::err_init_non_aggr_init_list)
622 << DeclType << IList->getSourceRange();
623 hadError = true;
624 } else if (DeclType->isReferenceType()) {
625 CheckReferenceType(Entity, IList, DeclType, Index,
626 StructuredList, StructuredIndex);
627 } else if (DeclType->isObjCInterfaceType()) {
627 } else if (DeclType->isObjCObjectType()) {
628 SemaRef.Diag(IList->getLocStart(), diag::err_init_objc_class)
629 << DeclType;
630 hadError = true;
631 } else {
632 SemaRef.Diag(IList->getLocStart(), diag::err_illegal_initializer_type)
633 << DeclType;
634 hadError = true;
635 }

--- 1343 unchanged lines hidden (view full) ---

1979 case EK_VectorElement:
1980 return 0;
1981 }
1982
1983 // Silence GCC warning
1984 return 0;
1985}
1986
628 SemaRef.Diag(IList->getLocStart(), diag::err_init_objc_class)
629 << DeclType;
630 hadError = true;
631 } else {
632 SemaRef.Diag(IList->getLocStart(), diag::err_illegal_initializer_type)
633 << DeclType;
634 hadError = true;
635 }

--- 1343 unchanged lines hidden (view full) ---

1979 case EK_VectorElement:
1980 return 0;
1981 }
1982
1983 // Silence GCC warning
1984 return 0;
1985}
1986
1987bool InitializedEntity::allowsNRVO() const {
1988 switch (getKind()) {
1989 case EK_Result:
1990 case EK_Exception:
1991 return LocAndNRVO.NRVO;
1992
1993 case EK_Variable:
1994 case EK_Parameter:
1995 case EK_Member:
1996 case EK_New:
1997 case EK_Temporary:
1998 case EK_Base:
1999 case EK_ArrayElement:
2000 case EK_VectorElement:
2001 break;
2002 }
2003
2004 return false;
2005}
2006
1987//===----------------------------------------------------------------------===//
1988// Initialization sequence
1989//===----------------------------------------------------------------------===//
1990
1991void InitializationSequence::Step::Destroy() {
1992 switch (Kind) {
1993 case SK_ResolveAddressOfOverloadedFunction:
1994 case SK_CastDerivedToBaseRValue:

--- 34 unchanged lines hidden (view full) ---

2029 case FK_RValueReferenceBindingToLValue:
2030 case FK_ReferenceInitDropsQualifiers:
2031 case FK_ReferenceInitFailed:
2032 case FK_ConversionFailed:
2033 case FK_TooManyInitsForScalar:
2034 case FK_ReferenceBindingToInitList:
2035 case FK_InitListBadDestinationType:
2036 case FK_DefaultInitOfConst:
2007//===----------------------------------------------------------------------===//
2008// Initialization sequence
2009//===----------------------------------------------------------------------===//
2010
2011void InitializationSequence::Step::Destroy() {
2012 switch (Kind) {
2013 case SK_ResolveAddressOfOverloadedFunction:
2014 case SK_CastDerivedToBaseRValue:

--- 34 unchanged lines hidden (view full) ---

2049 case FK_RValueReferenceBindingToLValue:
2050 case FK_ReferenceInitDropsQualifiers:
2051 case FK_ReferenceInitFailed:
2052 case FK_ConversionFailed:
2053 case FK_TooManyInitsForScalar:
2054 case FK_ReferenceBindingToInitList:
2055 case FK_InitListBadDestinationType:
2056 case FK_DefaultInitOfConst:
2057 case FK_Incomplete:
2037 return false;
2038
2039 case FK_ReferenceInitOverloadFailed:
2040 case FK_UserConversionOverloadFailed:
2041 case FK_ConstructorOverloadFailed:
2042 return FailedOverloadResult == OR_Ambiguous;
2043 }
2044

--- 195 unchanged lines hidden (view full) ---

2240 OverloadCandidateSet &CandidateSet = Sequence.getFailedCandidateSet();
2241 CandidateSet.clear();
2242
2243 // Determine whether we are allowed to call explicit constructors or
2244 // explicit conversion operators.
2245 bool AllowExplicit = Kind.getKind() == InitializationKind::IK_Direct;
2246
2247 const RecordType *T1RecordType = 0;
2058 return false;
2059
2060 case FK_ReferenceInitOverloadFailed:
2061 case FK_UserConversionOverloadFailed:
2062 case FK_ConstructorOverloadFailed:
2063 return FailedOverloadResult == OR_Ambiguous;
2064 }
2065

--- 195 unchanged lines hidden (view full) ---

2261 OverloadCandidateSet &CandidateSet = Sequence.getFailedCandidateSet();
2262 CandidateSet.clear();
2263
2264 // Determine whether we are allowed to call explicit constructors or
2265 // explicit conversion operators.
2266 bool AllowExplicit = Kind.getKind() == InitializationKind::IK_Direct;
2267
2268 const RecordType *T1RecordType = 0;
2248 if (AllowRValues && (T1RecordType = T1->getAs<RecordType>())) {
2269 if (AllowRValues && (T1RecordType = T1->getAs<RecordType>()) &&
2270 !S.RequireCompleteType(Kind.getLocation(), T1, 0)) {
2249 // The type we're converting to is a class type. Enumerate its constructors
2250 // to see if there is a suitable conversion.
2251 CXXRecordDecl *T1RecordDecl = cast<CXXRecordDecl>(T1RecordType->getDecl());
2271 // The type we're converting to is a class type. Enumerate its constructors
2272 // to see if there is a suitable conversion.
2273 CXXRecordDecl *T1RecordDecl = cast<CXXRecordDecl>(T1RecordType->getDecl());
2252
2253 DeclarationName ConstructorName
2254 = S.Context.DeclarationNames.getCXXConstructorName(
2255 S.Context.getCanonicalType(T1).getUnqualifiedType());
2256 DeclContext::lookup_iterator Con, ConEnd;
2257 for (llvm::tie(Con, ConEnd) = T1RecordDecl->lookup(ConstructorName);
2258 Con != ConEnd; ++Con) {
2259 NamedDecl *D = *Con;
2260 DeclAccessPair FoundDecl = DeclAccessPair::make(D, D->getAccess());

--- 15 unchanged lines hidden (view full) ---

2276 &Initializer, 1, CandidateSet);
2277 else
2278 S.AddOverloadCandidate(Constructor, FoundDecl,
2279 &Initializer, 1, CandidateSet);
2280 }
2281 }
2282 }
2283
2274 DeclarationName ConstructorName
2275 = S.Context.DeclarationNames.getCXXConstructorName(
2276 S.Context.getCanonicalType(T1).getUnqualifiedType());
2277 DeclContext::lookup_iterator Con, ConEnd;
2278 for (llvm::tie(Con, ConEnd) = T1RecordDecl->lookup(ConstructorName);
2279 Con != ConEnd; ++Con) {
2280 NamedDecl *D = *Con;
2281 DeclAccessPair FoundDecl = DeclAccessPair::make(D, D->getAccess());

--- 15 unchanged lines hidden (view full) ---

2297 &Initializer, 1, CandidateSet);
2298 else
2299 S.AddOverloadCandidate(Constructor, FoundDecl,
2300 &Initializer, 1, CandidateSet);
2301 }
2302 }
2303 }
2304
2284 if (const RecordType *T2RecordType = T2->getAs<RecordType>()) {
2305 const RecordType *T2RecordType = 0;
2306 if ((T2RecordType = T2->getAs<RecordType>()) &&
2307 !S.RequireCompleteType(Kind.getLocation(), T2, 0)) {
2285 // The type we're converting from is a class type, enumerate its conversion
2286 // functions.
2287 CXXRecordDecl *T2RecordDecl = cast<CXXRecordDecl>(T2RecordType->getDecl());
2288
2289 // Determine the type we are converting to. If we are allowed to
2290 // convert to an rvalue, take the type that the destination type
2291 // refers to.
2292 QualType ToType = AllowRValues? cv1T1 : DestType;

--- 329 unchanged lines hidden (view full) ---

2622 // Determine whether we are allowed to call explicit constructors or
2623 // explicit conversion operators.
2624 bool AllowExplicit = (Kind.getKind() == InitializationKind::IK_Direct ||
2625 Kind.getKind() == InitializationKind::IK_Value ||
2626 Kind.getKind() == InitializationKind::IK_Default);
2627
2628 // The type we're constructing needs to be complete.
2629 if (S.RequireCompleteType(Kind.getLocation(), DestType, 0)) {
2308 // The type we're converting from is a class type, enumerate its conversion
2309 // functions.
2310 CXXRecordDecl *T2RecordDecl = cast<CXXRecordDecl>(T2RecordType->getDecl());
2311
2312 // Determine the type we are converting to. If we are allowed to
2313 // convert to an rvalue, take the type that the destination type
2314 // refers to.
2315 QualType ToType = AllowRValues? cv1T1 : DestType;

--- 329 unchanged lines hidden (view full) ---

2645 // Determine whether we are allowed to call explicit constructors or
2646 // explicit conversion operators.
2647 bool AllowExplicit = (Kind.getKind() == InitializationKind::IK_Direct ||
2648 Kind.getKind() == InitializationKind::IK_Value ||
2649 Kind.getKind() == InitializationKind::IK_Default);
2650
2651 // The type we're constructing needs to be complete.
2652 if (S.RequireCompleteType(Kind.getLocation(), DestType, 0)) {
2630 Sequence.SetFailed(InitializationSequence::FK_ConversionFailed);
2653 Sequence.SetFailed(InitializationSequence::FK_Incomplete);
2631 return;
2632 }
2633
2634 // The type we're converting to is a class type. Enumerate its constructors
2635 // to see if one is suitable.
2636 const RecordType *DestRecordType = DestType->getAs<RecordType>();
2637 assert(DestRecordType && "Constructor initialization requires record type");
2638 CXXRecordDecl *DestRecordDecl

--- 96 unchanged lines hidden (view full) ---

2735 // but Entity doesn't have a way to capture that (yet).
2736 if (ClassDecl->hasUserDeclaredConstructor())
2737 return TryConstructorInitialization(S, Entity, Kind, 0, 0, T, Sequence);
2738
2739 // -- if T is a (possibly cv-qualified) non-union class type
2740 // without a user-provided constructor, then the object is
2741 // zero-initialized and, if T���s implicitly-declared default
2742 // constructor is non-trivial, that constructor is called.
2654 return;
2655 }
2656
2657 // The type we're converting to is a class type. Enumerate its constructors
2658 // to see if one is suitable.
2659 const RecordType *DestRecordType = DestType->getAs<RecordType>();
2660 assert(DestRecordType && "Constructor initialization requires record type");
2661 CXXRecordDecl *DestRecordDecl

--- 96 unchanged lines hidden (view full) ---

2758 // but Entity doesn't have a way to capture that (yet).
2759 if (ClassDecl->hasUserDeclaredConstructor())
2760 return TryConstructorInitialization(S, Entity, Kind, 0, 0, T, Sequence);
2761
2762 // -- if T is a (possibly cv-qualified) non-union class type
2763 // without a user-provided constructor, then the object is
2764 // zero-initialized and, if T���s implicitly-declared default
2765 // constructor is non-trivial, that constructor is called.
2743 if ((ClassDecl->getTagKind() == TagDecl::TK_class ||
2744 ClassDecl->getTagKind() == TagDecl::TK_struct) &&
2766 if ((ClassDecl->getTagKind() == TTK_Class ||
2767 ClassDecl->getTagKind() == TTK_Struct) &&
2745 !ClassDecl->hasTrivialConstructor()) {
2746 Sequence.AddZeroInitializationStep(Entity.getType());
2747 return TryConstructorInitialization(S, Entity, Kind, 0, 0, T, Sequence);
2748 }
2749 }
2750 }
2751
2752 Sequence.AddZeroInitializationStep(Entity.getType());

--- 482 unchanged lines hidden (view full) ---

3235 // side effects. [...]
3236 // - when a temporary class object that has not been bound to a
3237 // reference (12.2) would be copied/moved to a class object
3238 // with the same cv-unqualified type, the copy/move operation
3239 // can be omitted by constructing the temporary object
3240 // directly into the target of the omitted copy/move
3241 //
3242 // Note that the other three bullets are handled elsewhere. Copy
2768 !ClassDecl->hasTrivialConstructor()) {
2769 Sequence.AddZeroInitializationStep(Entity.getType());
2770 return TryConstructorInitialization(S, Entity, Kind, 0, 0, T, Sequence);
2771 }
2772 }
2773 }
2774
2775 Sequence.AddZeroInitializationStep(Entity.getType());

--- 482 unchanged lines hidden (view full) ---

3258 // side effects. [...]
3259 // - when a temporary class object that has not been bound to a
3260 // reference (12.2) would be copied/moved to a class object
3261 // with the same cv-unqualified type, the copy/move operation
3262 // can be omitted by constructing the temporary object
3263 // directly into the target of the omitted copy/move
3264 //
3265 // Note that the other three bullets are handled elsewhere. Copy
3243 // elision for return statements and throw expressions are (FIXME:
3244 // not yet) handled as part of constructor initialization, while
3245 // copy elision for exception handlers is handled by the run-time.
3266 // elision for return statements and throw expressions are handled as part
3267 // of constructor initialization, while copy elision for exception handlers
3268 // is handled by the run-time.
3246 bool Elidable = CurInitExpr->isTemporaryObject() &&
3247 S.Context.hasSameUnqualifiedType(T, CurInitExpr->getType());
3248 SourceLocation Loc;
3249 switch (Entity.getKind()) {
3250 case InitializedEntity::EK_Result:
3251 Loc = Entity.getReturnLoc();
3252 break;
3253

--- 258 unchanged lines hidden (view full) ---

3512 Expr *CurInitExpr = (Expr *)CurInit.get();
3513 QualType SourceType = CurInitExpr? CurInitExpr->getType() : QualType();
3514
3515 switch (Step->Kind) {
3516 case SK_ResolveAddressOfOverloadedFunction:
3517 // Overload resolution determined which function invoke; update the
3518 // initializer to reflect that choice.
3519 S.CheckAddressOfMemberAccess(CurInitExpr, Step->Function.FoundDecl);
3269 bool Elidable = CurInitExpr->isTemporaryObject() &&
3270 S.Context.hasSameUnqualifiedType(T, CurInitExpr->getType());
3271 SourceLocation Loc;
3272 switch (Entity.getKind()) {
3273 case InitializedEntity::EK_Result:
3274 Loc = Entity.getReturnLoc();
3275 break;
3276

--- 258 unchanged lines hidden (view full) ---

3535 Expr *CurInitExpr = (Expr *)CurInit.get();
3536 QualType SourceType = CurInitExpr? CurInitExpr->getType() : QualType();
3537
3538 switch (Step->Kind) {
3539 case SK_ResolveAddressOfOverloadedFunction:
3540 // Overload resolution determined which function invoke; update the
3541 // initializer to reflect that choice.
3542 S.CheckAddressOfMemberAccess(CurInitExpr, Step->Function.FoundDecl);
3543 S.DiagnoseUseOfDecl(Step->Function.FoundDecl, Kind.getLocation());
3520 CurInit = S.FixOverloadedFunctionReference(move(CurInit),
3521 Step->Function.FoundDecl,
3522 Step->Function.Function);
3523 break;
3524
3525 case SK_CastDerivedToBaseRValue:
3526 case SK_CastDerivedToBaseLValue: {
3527 // We have a derived-to-base cast that produces either an rvalue or an

--- 4 unchanged lines hidden (view full) ---

3532 // Casts to inaccessible base classes are allowed with C-style casts.
3533 bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast();
3534 if (S.CheckDerivedToBaseConversion(SourceType, Step->Type,
3535 CurInitExpr->getLocStart(),
3536 CurInitExpr->getSourceRange(),
3537 &BasePath, IgnoreBaseAccess))
3538 return S.ExprError();
3539
3544 CurInit = S.FixOverloadedFunctionReference(move(CurInit),
3545 Step->Function.FoundDecl,
3546 Step->Function.Function);
3547 break;
3548
3549 case SK_CastDerivedToBaseRValue:
3550 case SK_CastDerivedToBaseLValue: {
3551 // We have a derived-to-base cast that produces either an rvalue or an

--- 4 unchanged lines hidden (view full) ---

3556 // Casts to inaccessible base classes are allowed with C-style casts.
3557 bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast();
3558 if (S.CheckDerivedToBaseConversion(SourceType, Step->Type,
3559 CurInitExpr->getLocStart(),
3560 CurInitExpr->getSourceRange(),
3561 &BasePath, IgnoreBaseAccess))
3562 return S.ExprError();
3563
3564 if (S.BasePathInvolvesVirtualBase(BasePath)) {
3565 QualType T = SourceType;
3566 if (const PointerType *Pointer = T->getAs<PointerType>())
3567 T = Pointer->getPointeeType();
3568 if (const RecordType *RecordTy = T->getAs<RecordType>())
3569 S.MarkVTableUsed(CurInitExpr->getLocStart(),
3570 cast<CXXRecordDecl>(RecordTy->getDecl()));
3571 }
3572
3540 CurInit = S.Owned(new (S.Context) ImplicitCastExpr(Step->Type,
3541 CastExpr::CK_DerivedToBase,
3542 (Expr*)CurInit.release(),
3543 BasePath,
3544 Step->Kind == SK_CastDerivedToBaseLValue));
3545 break;
3546 }
3547

--- 66 unchanged lines hidden (view full) ---

3614 // Build the an expression that constructs a temporary.
3615 CurInit = S.BuildCXXConstructExpr(Loc, Step->Type, Constructor,
3616 move_arg(ConstructorArgs));
3617 if (CurInit.isInvalid())
3618 return S.ExprError();
3619
3620 S.CheckConstructorAccess(Kind.getLocation(), Constructor, Entity,
3621 FoundFn.getAccess());
3573 CurInit = S.Owned(new (S.Context) ImplicitCastExpr(Step->Type,
3574 CastExpr::CK_DerivedToBase,
3575 (Expr*)CurInit.release(),
3576 BasePath,
3577 Step->Kind == SK_CastDerivedToBaseLValue));
3578 break;
3579 }
3580

--- 66 unchanged lines hidden (view full) ---

3647 // Build the an expression that constructs a temporary.
3648 CurInit = S.BuildCXXConstructExpr(Loc, Step->Type, Constructor,
3649 move_arg(ConstructorArgs));
3650 if (CurInit.isInvalid())
3651 return S.ExprError();
3652
3653 S.CheckConstructorAccess(Kind.getLocation(), Constructor, Entity,
3654 FoundFn.getAccess());
3655 S.DiagnoseUseOfDecl(FoundFn, Kind.getLocation());
3622
3623 CastKind = CastExpr::CK_ConstructorConversion;
3624 QualType Class = S.Context.getTypeDeclType(Constructor->getParent());
3625 if (S.Context.hasSameUnqualifiedType(SourceType, Class) ||
3626 S.IsDerivedFrom(SourceType, Class))
3627 IsCopy = true;
3628
3629 CreatedObject = true;
3630 } else {
3631 // Build a call to the conversion function.
3632 CXXConversionDecl *Conversion = cast<CXXConversionDecl>(Fn);
3633 IsLvalue = Conversion->getResultType()->isLValueReferenceType();
3634 S.CheckMemberOperatorAccess(Kind.getLocation(), CurInitExpr, 0,
3635 FoundFn);
3656
3657 CastKind = CastExpr::CK_ConstructorConversion;
3658 QualType Class = S.Context.getTypeDeclType(Constructor->getParent());
3659 if (S.Context.hasSameUnqualifiedType(SourceType, Class) ||
3660 S.IsDerivedFrom(SourceType, Class))
3661 IsCopy = true;
3662
3663 CreatedObject = true;
3664 } else {
3665 // Build a call to the conversion function.
3666 CXXConversionDecl *Conversion = cast<CXXConversionDecl>(Fn);
3667 IsLvalue = Conversion->getResultType()->isLValueReferenceType();
3668 S.CheckMemberOperatorAccess(Kind.getLocation(), CurInitExpr, 0,
3669 FoundFn);
3670 S.DiagnoseUseOfDecl(FoundFn, Kind.getLocation());
3636
3637 // FIXME: Should we move this initialization into a separate
3638 // derived-to-base conversion? I believe the answer is "no", because
3639 // we don't want to turn off access control here for c-style casts.
3640 if (S.PerformObjectArgumentInitialization(CurInitExpr, /*Qualifier=*/0,
3641 FoundFn, Conversion))
3642 return S.ExprError();
3643

--- 74 unchanged lines hidden (view full) ---

3718 CurInit = S.Owned(InitList);
3719 break;
3720 }
3721
3722 case SK_ConstructorInitialization: {
3723 unsigned NumArgs = Args.size();
3724 CXXConstructorDecl *Constructor
3725 = cast<CXXConstructorDecl>(Step->Function.Function);
3671
3672 // FIXME: Should we move this initialization into a separate
3673 // derived-to-base conversion? I believe the answer is "no", because
3674 // we don't want to turn off access control here for c-style casts.
3675 if (S.PerformObjectArgumentInitialization(CurInitExpr, /*Qualifier=*/0,
3676 FoundFn, Conversion))
3677 return S.ExprError();
3678

--- 74 unchanged lines hidden (view full) ---

3753 CurInit = S.Owned(InitList);
3754 break;
3755 }
3756
3757 case SK_ConstructorInitialization: {
3758 unsigned NumArgs = Args.size();
3759 CXXConstructorDecl *Constructor
3760 = cast<CXXConstructorDecl>(Step->Function.Function);
3726
3761
3727 // Build a call to the selected constructor.
3728 ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(S);
3729 SourceLocation Loc = Kind.getLocation();
3730
3731 // Determine the arguments required to actually perform the constructor
3732 // call.
3733 if (S.CompleteConstructorCall(Constructor, move(Args),
3734 Loc, ConstructorArgs))

--- 20 unchanged lines hidden (view full) ---

3755 CXXConstructExpr::ConstructionKind ConstructKind =
3756 CXXConstructExpr::CK_Complete;
3757
3758 if (Entity.getKind() == InitializedEntity::EK_Base) {
3759 ConstructKind = Entity.getBaseSpecifier()->isVirtual() ?
3760 CXXConstructExpr::CK_VirtualBase :
3761 CXXConstructExpr::CK_NonVirtualBase;
3762 }
3762 // Build a call to the selected constructor.
3763 ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(S);
3764 SourceLocation Loc = Kind.getLocation();
3765
3766 // Determine the arguments required to actually perform the constructor
3767 // call.
3768 if (S.CompleteConstructorCall(Constructor, move(Args),
3769 Loc, ConstructorArgs))

--- 20 unchanged lines hidden (view full) ---

3790 CXXConstructExpr::ConstructionKind ConstructKind =
3791 CXXConstructExpr::CK_Complete;
3792
3793 if (Entity.getKind() == InitializedEntity::EK_Base) {
3794 ConstructKind = Entity.getBaseSpecifier()->isVirtual() ?
3795 CXXConstructExpr::CK_VirtualBase :
3796 CXXConstructExpr::CK_NonVirtualBase;
3797 }
3763 CurInit = S.BuildCXXConstructExpr(Loc, Entity.getType(),
3764 Constructor,
3765 move_arg(ConstructorArgs),
3766 ConstructorInitRequiresZeroInit,
3767 ConstructKind);
3798
3799 // If the entity allows NRVO, mark the construction as elidable
3800 // unconditionally.
3801 if (Entity.allowsNRVO())
3802 CurInit = S.BuildCXXConstructExpr(Loc, Entity.getType(),
3803 Constructor, /*Elidable=*/true,
3804 move_arg(ConstructorArgs),
3805 ConstructorInitRequiresZeroInit,
3806 ConstructKind);
3807 else
3808 CurInit = S.BuildCXXConstructExpr(Loc, Entity.getType(),
3809 Constructor,
3810 move_arg(ConstructorArgs),
3811 ConstructorInitRequiresZeroInit,
3812 ConstructKind);
3768 }
3769 if (CurInit.isInvalid())
3770 return S.ExprError();
3771
3772 // Only check access if all of that succeeded.
3773 S.CheckConstructorAccess(Loc, Constructor, Entity,
3774 Step->Function.FoundDecl.getAccess());
3813 }
3814 if (CurInit.isInvalid())
3815 return S.ExprError();
3816
3817 // Only check access if all of that succeeded.
3818 S.CheckConstructorAccess(Loc, Constructor, Entity,
3819 Step->Function.FoundDecl.getAccess());
3820 S.DiagnoseUseOfDecl(Step->Function.FoundDecl, Loc);
3775
3776 if (shouldBindAsTemporary(Entity))
3777 CurInit = S.MaybeBindToTemporary(CurInit.takeAs<Expr>());
3778
3779 break;
3780 }
3781
3782 case SK_ZeroInitialization: {

--- 304 unchanged lines hidden (view full) ---

4087 << Entity.getName();
4088 S.Diag(Entity.getDecl()->getLocation(), diag::note_previous_decl)
4089 << Entity.getName();
4090 } else {
4091 S.Diag(Kind.getLocation(), diag::err_default_init_const)
4092 << DestType << (bool)DestType->getAs<RecordType>();
4093 }
4094 break;
3821
3822 if (shouldBindAsTemporary(Entity))
3823 CurInit = S.MaybeBindToTemporary(CurInit.takeAs<Expr>());
3824
3825 break;
3826 }
3827
3828 case SK_ZeroInitialization: {

--- 304 unchanged lines hidden (view full) ---

4133 << Entity.getName();
4134 S.Diag(Entity.getDecl()->getLocation(), diag::note_previous_decl)
4135 << Entity.getName();
4136 } else {
4137 S.Diag(Kind.getLocation(), diag::err_default_init_const)
4138 << DestType << (bool)DestType->getAs<RecordType>();
4139 }
4140 break;
4141
4142 case FK_Incomplete:
4143 S.RequireCompleteType(Kind.getLocation(), DestType,
4144 diag::err_init_incomplete_type);
4145 break;
4095 }
4096
4097 PrintInitLocationNote(S, Entity);
4098 return true;
4099}
4100
4101void InitializationSequence::dump(llvm::raw_ostream &OS) const {
4102 switch (SequenceKind) {

--- 62 unchanged lines hidden (view full) ---

4165
4166 case FK_ConstructorOverloadFailed:
4167 OS << "constructor overloading failed";
4168 break;
4169
4170 case FK_DefaultInitOfConst:
4171 OS << "default initialization of a const variable";
4172 break;
4146 }
4147
4148 PrintInitLocationNote(S, Entity);
4149 return true;
4150}
4151
4152void InitializationSequence::dump(llvm::raw_ostream &OS) const {
4153 switch (SequenceKind) {

--- 62 unchanged lines hidden (view full) ---

4216
4217 case FK_ConstructorOverloadFailed:
4218 OS << "constructor overloading failed";
4219 break;
4220
4221 case FK_DefaultInitOfConst:
4222 OS << "default initialization of a const variable";
4223 break;
4224
4225 case FK_Incomplete:
4226 OS << "initialization of incomplete type";
4227 break;
4173 }
4174 OS << '\n';
4175 return;
4176 }
4177
4178 case DependentSequence:
4179 OS << "Dependent sequence: ";
4180 return;

--- 135 unchanged lines hidden ---
4228 }
4229 OS << '\n';
4230 return;
4231 }
4232
4233 case DependentSequence:
4234 OS << "Dependent sequence: ";
4235 return;

--- 135 unchanged lines hidden ---