forked from OSchip/llvm-project
ArrayRef'ize InitializationSequence constructor and InitializationSequence::Diagnose()
Patch by Robert Wilhelm. llvm-svn: 181022
This commit is contained in:
parent
aabf533656
commit
8f8930fc01
|
@ -779,13 +779,10 @@ public:
|
|||
/// \param Kind the kind of initialization being performed.
|
||||
///
|
||||
/// \param Args the argument(s) provided for initialization.
|
||||
///
|
||||
/// \param NumArgs the number of arguments provided for initialization.
|
||||
InitializationSequence(Sema &S,
|
||||
const InitializedEntity &Entity,
|
||||
const InitializationKind &Kind,
|
||||
Expr **Args,
|
||||
unsigned NumArgs);
|
||||
MultiExprArg Args);
|
||||
|
||||
~InitializationSequence();
|
||||
|
||||
|
@ -823,7 +820,7 @@ public:
|
|||
bool Diagnose(Sema &S,
|
||||
const InitializedEntity &Entity,
|
||||
const InitializationKind &Kind,
|
||||
Expr **Args, unsigned NumArgs);
|
||||
ArrayRef<Expr *> Args);
|
||||
|
||||
/// \brief Determine the kind of initialization sequence computed.
|
||||
enum SequenceKind getKind() const { return SequenceKind; }
|
||||
|
|
|
@ -333,7 +333,7 @@ static bool tryDiagnoseOverloadedCast(Sema &S, CastType CT,
|
|||
: (CT == CT_Functional)? InitializationKind::CreateFunctionalCast(range,
|
||||
listInitialization)
|
||||
: InitializationKind::CreateCast(/*type range?*/ range);
|
||||
InitializationSequence sequence(S, entity, initKind, &src, 1);
|
||||
InitializationSequence sequence(S, entity, initKind, src);
|
||||
|
||||
assert(sequence.Failed() && "initialization succeeded on second try?");
|
||||
switch (sequence.getFailureKind()) {
|
||||
|
@ -1418,7 +1418,7 @@ TryStaticImplicitCast(Sema &Self, ExprResult &SrcExpr, QualType DestType,
|
|||
? InitializationKind::CreateFunctionalCast(OpRange, ListInitialization)
|
||||
: InitializationKind::CreateCast(OpRange);
|
||||
Expr *SrcExprRaw = SrcExpr.get();
|
||||
InitializationSequence InitSeq(Self, Entity, InitKind, &SrcExprRaw, 1);
|
||||
InitializationSequence InitSeq(Self, Entity, InitKind, SrcExprRaw);
|
||||
|
||||
// At this point of CheckStaticCast, if the destination is a reference,
|
||||
// or the expression is an overload expression this has to work.
|
||||
|
|
|
@ -7476,15 +7476,13 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
|
|||
: InitializationKind::CreateCopy(VDecl->getLocation(),
|
||||
Init->getLocStart());
|
||||
|
||||
Expr **Args = &Init;
|
||||
unsigned NumArgs = 1;
|
||||
if (CXXDirectInit) {
|
||||
Args = CXXDirectInit->getExprs();
|
||||
NumArgs = CXXDirectInit->getNumExprs();
|
||||
}
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, Args, NumArgs);
|
||||
ExprResult Result = InitSeq.Perform(*this, Entity, Kind,
|
||||
MultiExprArg(Args, NumArgs), &DclT);
|
||||
MultiExprArg Args = Init;
|
||||
if (CXXDirectInit)
|
||||
Args = MultiExprArg(CXXDirectInit->getExprs(),
|
||||
CXXDirectInit->getNumExprs());
|
||||
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, Args);
|
||||
ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Args, &DclT);
|
||||
if (Result.isInvalid()) {
|
||||
VDecl->setInvalidDecl();
|
||||
return;
|
||||
|
@ -7934,7 +7932,7 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl,
|
|||
InitializationKind Kind
|
||||
= InitializationKind::CreateDefault(Var->getLocation());
|
||||
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, 0, 0);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, MultiExprArg());
|
||||
ExprResult Init = InitSeq.Perform(*this, Entity, Kind, MultiExprArg());
|
||||
if (Init.isInvalid())
|
||||
Var->setInvalidDecl();
|
||||
|
|
|
@ -709,7 +709,7 @@ static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D,
|
|||
|
||||
// Check that all arguments are lockable objects.
|
||||
checkAttrArgsAreLockableObjs(S, D, Attr, Args);
|
||||
if (Args.size() == 0)
|
||||
if (Args.empty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -858,7 +858,7 @@ static bool checkLocksRequiredCommon(Sema &S, Decl *D,
|
|||
|
||||
// check that all arguments are lockable objects
|
||||
checkAttrArgsAreLockableObjs(S, D, Attr, Args);
|
||||
if (Args.size() == 0)
|
||||
if (Args.empty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -265,7 +265,7 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, Expr *Arg,
|
|||
Param);
|
||||
InitializationKind Kind = InitializationKind::CreateCopy(Param->getLocation(),
|
||||
EqualLoc);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, &Arg, 1);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, Arg);
|
||||
ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Arg);
|
||||
if (Result.isInvalid())
|
||||
return true;
|
||||
|
@ -2157,14 +2157,12 @@ Sema::ActOnCXXInClassMemberInitializer(Decl *D, SourceLocation InitLoc,
|
|||
Diag(FD->getLocation(), diag::warn_dangling_std_initializer_list)
|
||||
<< /*at end of ctor*/1 << InitExpr->getSourceRange();
|
||||
}
|
||||
Expr **Inits = &InitExpr;
|
||||
unsigned NumInits = 1;
|
||||
InitializedEntity Entity = InitializedEntity::InitializeMember(FD);
|
||||
InitializationKind Kind = FD->getInClassInitStyle() == ICIS_ListInit
|
||||
? InitializationKind::CreateDirectList(InitExpr->getLocStart())
|
||||
: InitializationKind::CreateCopy(InitExpr->getLocStart(), InitLoc);
|
||||
InitializationSequence Seq(*this, Entity, Kind, Inits, NumInits);
|
||||
Init = Seq.Perform(*this, Entity, Kind, MultiExprArg(Inits, NumInits));
|
||||
InitializationSequence Seq(*this, Entity, Kind, InitExpr);
|
||||
Init = Seq.Perform(*this, Entity, Kind, InitExpr);
|
||||
if (Init.isInvalid()) {
|
||||
FD->setInvalidDecl();
|
||||
return;
|
||||
|
@ -2527,23 +2525,19 @@ Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init,
|
|||
// foo(foo)
|
||||
// where foo is not also a parameter to the constructor.
|
||||
// TODO: implement -Wuninitialized and fold this into that framework.
|
||||
Expr **Args;
|
||||
unsigned NumArgs;
|
||||
MultiExprArg Args;
|
||||
if (ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
|
||||
Args = ParenList->getExprs();
|
||||
NumArgs = ParenList->getNumExprs();
|
||||
Args = MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
|
||||
} else if (InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
|
||||
Args = InitList->getInits();
|
||||
NumArgs = InitList->getNumInits();
|
||||
Args = MultiExprArg(InitList->getInits(), InitList->getNumInits());
|
||||
} else {
|
||||
// Template instantiation doesn't reconstruct ParenListExprs for us.
|
||||
Args = &Init;
|
||||
NumArgs = 1;
|
||||
Args = Init;
|
||||
}
|
||||
|
||||
if (getDiagnostics().getDiagnosticLevel(diag::warn_field_is_uninit, IdLoc)
|
||||
!= DiagnosticsEngine::Ignored)
|
||||
for (unsigned i = 0; i < NumArgs; ++i)
|
||||
for (unsigned i = 0, e = Args.size(); i != e; ++i)
|
||||
// FIXME: Warn about the case when other fields are used before being
|
||||
// initialized. For example, let this field be the i'th field. When
|
||||
// initializing the i'th field, throw a warning if any of the >= i'th
|
||||
|
@ -2564,8 +2558,7 @@ Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init,
|
|||
bool InitList = false;
|
||||
if (isa<InitListExpr>(Init)) {
|
||||
InitList = true;
|
||||
Args = &Init;
|
||||
NumArgs = 1;
|
||||
Args = Init;
|
||||
|
||||
if (isStdInitializerList(Member->getType(), 0)) {
|
||||
Diag(IdLoc, diag::warn_dangling_std_initializer_list)
|
||||
|
@ -2582,10 +2575,8 @@ Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init,
|
|||
: InitializationKind::CreateDirect(IdLoc, InitRange.getBegin(),
|
||||
InitRange.getEnd());
|
||||
|
||||
InitializationSequence InitSeq(*this, MemberEntity, Kind, Args, NumArgs);
|
||||
ExprResult MemberInit = InitSeq.Perform(*this, MemberEntity, Kind,
|
||||
MultiExprArg(Args, NumArgs),
|
||||
0);
|
||||
InitializationSequence InitSeq(*this, MemberEntity, Kind, Args);
|
||||
ExprResult MemberInit = InitSeq.Perform(*this, MemberEntity, Kind, Args, 0);
|
||||
if (MemberInit.isInvalid())
|
||||
return true;
|
||||
|
||||
|
@ -2621,12 +2612,10 @@ Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init,
|
|||
Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
|
||||
|
||||
bool InitList = true;
|
||||
Expr **Args = &Init;
|
||||
unsigned NumArgs = 1;
|
||||
MultiExprArg Args = Init;
|
||||
if (ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
|
||||
InitList = false;
|
||||
Args = ParenList->getExprs();
|
||||
NumArgs = ParenList->getNumExprs();
|
||||
Args = MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
|
||||
}
|
||||
|
||||
SourceRange InitRange = Init->getSourceRange();
|
||||
|
@ -2637,10 +2626,9 @@ Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init,
|
|||
InitList ? InitializationKind::CreateDirectList(NameLoc)
|
||||
: InitializationKind::CreateDirect(NameLoc, InitRange.getBegin(),
|
||||
InitRange.getEnd());
|
||||
InitializationSequence InitSeq(*this, DelegationEntity, Kind, Args, NumArgs);
|
||||
InitializationSequence InitSeq(*this, DelegationEntity, Kind, Args);
|
||||
ExprResult DelegationInit = InitSeq.Perform(*this, DelegationEntity, Kind,
|
||||
MultiExprArg(Args, NumArgs),
|
||||
0);
|
||||
Args, 0);
|
||||
if (DelegationInit.isInvalid())
|
||||
return true;
|
||||
|
||||
|
@ -2760,12 +2748,10 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo,
|
|||
|
||||
// Initialize the base.
|
||||
bool InitList = true;
|
||||
Expr **Args = &Init;
|
||||
unsigned NumArgs = 1;
|
||||
MultiExprArg Args = Init;
|
||||
if (ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
|
||||
InitList = false;
|
||||
Args = ParenList->getExprs();
|
||||
NumArgs = ParenList->getNumExprs();
|
||||
Args = MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
|
||||
}
|
||||
|
||||
InitializedEntity BaseEntity =
|
||||
|
@ -2774,9 +2760,8 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo,
|
|||
InitList ? InitializationKind::CreateDirectList(BaseLoc)
|
||||
: InitializationKind::CreateDirect(BaseLoc, InitRange.getBegin(),
|
||||
InitRange.getEnd());
|
||||
InitializationSequence InitSeq(*this, BaseEntity, Kind, Args, NumArgs);
|
||||
ExprResult BaseInit = InitSeq.Perform(*this, BaseEntity, Kind,
|
||||
MultiExprArg(Args, NumArgs), 0);
|
||||
InitializationSequence InitSeq(*this, BaseEntity, Kind, Args);
|
||||
ExprResult BaseInit = InitSeq.Perform(*this, BaseEntity, Kind, Args, 0);
|
||||
if (BaseInit.isInvalid())
|
||||
return true;
|
||||
|
||||
|
@ -2862,8 +2847,7 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
|
|||
|
||||
InitializationKind InitKind = InitializationKind::CreateDirect(
|
||||
Constructor->getLocation(), SourceLocation(), SourceLocation());
|
||||
InitializationSequence InitSeq(SemaRef, InitEntity, InitKind,
|
||||
Args.data(), Args.size());
|
||||
InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, Args);
|
||||
BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, Args);
|
||||
break;
|
||||
}
|
||||
|
@ -2872,7 +2856,7 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
|
|||
case IIK_Default: {
|
||||
InitializationKind InitKind
|
||||
= InitializationKind::CreateDefault(Constructor->getLocation());
|
||||
InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, 0, 0);
|
||||
InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, MultiExprArg());
|
||||
BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, MultiExprArg());
|
||||
break;
|
||||
}
|
||||
|
@ -2910,10 +2894,8 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
|
|||
InitializationKind InitKind
|
||||
= InitializationKind::CreateDirect(Constructor->getLocation(),
|
||||
SourceLocation(), SourceLocation());
|
||||
InitializationSequence InitSeq(SemaRef, InitEntity, InitKind,
|
||||
&CopyCtorArg, 1);
|
||||
BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
|
||||
MultiExprArg(&CopyCtorArg, 1));
|
||||
InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, CopyCtorArg);
|
||||
BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3064,8 +3046,7 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
|
|||
InitializationKind::CreateDirect(Loc, SourceLocation(), SourceLocation());
|
||||
|
||||
Expr *CtorArgE = CtorArg.takeAs<Expr>();
|
||||
InitializationSequence InitSeq(SemaRef, Entities.back(), InitKind,
|
||||
&CtorArgE, 1);
|
||||
InitializationSequence InitSeq(SemaRef, Entities.back(), InitKind, CtorArgE);
|
||||
|
||||
ExprResult MemberInit
|
||||
= InitSeq.Perform(SemaRef, Entities.back(), InitKind,
|
||||
|
@ -3104,7 +3085,7 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
|
|||
InitializationKind InitKind =
|
||||
InitializationKind::CreateDefault(Loc);
|
||||
|
||||
InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, 0, 0);
|
||||
InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, MultiExprArg());
|
||||
ExprResult MemberInit =
|
||||
InitSeq.Perform(SemaRef, InitEntity, InitKind, MultiExprArg());
|
||||
|
||||
|
@ -10642,9 +10623,8 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S,
|
|||
|
||||
Expr *opaqueValue =
|
||||
new (Context) OpaqueValueExpr(Loc, initType, VK_LValue, OK_Ordinary);
|
||||
InitializationSequence sequence(*this, entity, initKind, &opaqueValue, 1);
|
||||
ExprResult result = sequence.Perform(*this, entity, initKind,
|
||||
MultiExprArg(&opaqueValue, 1));
|
||||
InitializationSequence sequence(*this, entity, initKind, opaqueValue);
|
||||
ExprResult result = sequence.Perform(*this, entity, initKind, opaqueValue);
|
||||
if (result.isInvalid())
|
||||
Invalid = true;
|
||||
else {
|
||||
|
@ -11907,7 +11887,7 @@ void Sema::SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation) {
|
|||
InitializationKind InitKind =
|
||||
InitializationKind::CreateDefault(ObjCImplementation->getLocation());
|
||||
|
||||
InitializationSequence InitSeq(*this, InitEntity, InitKind, 0, 0);
|
||||
InitializationSequence InitSeq(*this, InitEntity, InitKind, MultiExprArg());
|
||||
ExprResult MemberInit =
|
||||
InitSeq.Perform(*this, InitEntity, InitKind, MultiExprArg());
|
||||
MemberInit = MaybeCreateExprWithCleanups(MemberInit);
|
||||
|
|
|
@ -2766,8 +2766,7 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) {
|
|||
// C++11 [lex.ext]p6: The literal L is treated as a call of the form
|
||||
// operator "" X (ch)
|
||||
return BuildCookedLiteralOperatorCall(*this, UDLScope, UDSuffix, UDSuffixLoc,
|
||||
llvm::makeArrayRef(&Lit, 1),
|
||||
Tok.getLocation());
|
||||
Lit, Tok.getLocation());
|
||||
}
|
||||
|
||||
ExprResult Sema::ActOnIntegerConstant(SourceLocation Loc, uint64_t Val) {
|
||||
|
@ -2864,7 +2863,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
|
|||
// Perform literal operator lookup to determine if we're building a raw
|
||||
// literal or a cooked one.
|
||||
LookupResult R(*this, OpName, UDSuffixLoc, LookupOrdinaryName);
|
||||
switch (LookupLiteralOperator(UDLScope, R, llvm::makeArrayRef(&CookedTy, 1),
|
||||
switch (LookupLiteralOperator(UDLScope, R, CookedTy,
|
||||
/*AllowRawAndTemplate*/true)) {
|
||||
case LOLR_Error:
|
||||
return ExprError();
|
||||
|
@ -2880,8 +2879,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
|
|||
Lit = IntegerLiteral::Create(Context, ResultVal, CookedTy,
|
||||
Tok.getLocation());
|
||||
}
|
||||
return BuildLiteralOperatorCall(R, OpNameInfo,
|
||||
llvm::makeArrayRef(&Lit, 1),
|
||||
return BuildLiteralOperatorCall(R, OpNameInfo, Lit,
|
||||
Tok.getLocation());
|
||||
}
|
||||
|
||||
|
@ -2897,8 +2895,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
|
|||
Expr *Lit = StringLiteral::Create(
|
||||
Context, StringRef(TokSpelling.data(), Length), StringLiteral::Ascii,
|
||||
/*Pascal*/false, StrTy, &TokLoc, 1);
|
||||
return BuildLiteralOperatorCall(R, OpNameInfo,
|
||||
llvm::makeArrayRef(&Lit, 1), TokLoc);
|
||||
return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
|
||||
}
|
||||
|
||||
case LOLR_Template:
|
||||
|
@ -3703,7 +3700,7 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
|
|||
/*FIXME:EqualLoc*/UninstExpr->getLocStart());
|
||||
Expr *ResultE = Result.takeAs<Expr>();
|
||||
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, &ResultE, 1);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, ResultE);
|
||||
Result = InitSeq.Perform(*this, Entity, Kind, ResultE);
|
||||
if (Result.isInvalid())
|
||||
return ExprError();
|
||||
|
@ -4473,7 +4470,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
|
|||
= InitializationKind::CreateCStyleCast(LParenLoc,
|
||||
SourceRange(LParenLoc, RParenLoc),
|
||||
/*InitList=*/true);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, &LiteralExpr, 1);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, LiteralExpr);
|
||||
ExprResult Result = InitSeq.Perform(*this, Entity, Kind, LiteralExpr,
|
||||
&literalType);
|
||||
if (Result.isInvalid())
|
||||
|
@ -8611,7 +8608,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
|
|||
InitializationKind::CreateDirectList(RHSExpr->getLocStart());
|
||||
InitializedEntity Entity =
|
||||
InitializedEntity::InitializeTemporary(LHSExpr->getType());
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, &RHSExpr, 1);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
|
||||
ExprResult Init = InitSeq.Perform(*this, Entity, Kind, RHSExpr);
|
||||
if (Init.isInvalid())
|
||||
return Init;
|
||||
|
@ -11053,9 +11050,9 @@ static ExprResult captureInLambda(Sema &S, LambdaScopeInfo *LSI,
|
|||
|
||||
InitializationKind InitKind
|
||||
= InitializationKind::CreateDirect(Loc, Loc, Loc);
|
||||
InitializationSequence Init(S, Entities.back(), InitKind, &Ref, 1);
|
||||
InitializationSequence Init(S, Entities.back(), InitKind, Ref);
|
||||
ExprResult Result(true);
|
||||
if (!Init.Diagnose(S, Entities.back(), InitKind, &Ref, 1))
|
||||
if (!Init.Diagnose(S, Entities.back(), InitKind, Ref))
|
||||
Result = Init.Perform(S, Entities.back(), InitKind, Ref);
|
||||
|
||||
// If this initialization requires any cleanups (e.g., due to a
|
||||
|
|
|
@ -839,23 +839,20 @@ Sema::ActOnCXXTypeConstructExpr(ParsedType TypeRep,
|
|||
ExprResult
|
||||
Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo,
|
||||
SourceLocation LParenLoc,
|
||||
MultiExprArg exprs,
|
||||
MultiExprArg Exprs,
|
||||
SourceLocation RParenLoc) {
|
||||
QualType Ty = TInfo->getType();
|
||||
SourceLocation TyBeginLoc = TInfo->getTypeLoc().getBeginLoc();
|
||||
|
||||
if (Ty->isDependentType() || CallExpr::hasAnyTypeDependentArguments(exprs)) {
|
||||
if (Ty->isDependentType() || CallExpr::hasAnyTypeDependentArguments(Exprs)) {
|
||||
return Owned(CXXUnresolvedConstructExpr::Create(Context, TInfo,
|
||||
LParenLoc,
|
||||
exprs,
|
||||
Exprs,
|
||||
RParenLoc));
|
||||
}
|
||||
|
||||
unsigned NumExprs = exprs.size();
|
||||
Expr **Exprs = exprs.data();
|
||||
|
||||
bool ListInitialization = LParenLoc.isInvalid();
|
||||
assert((!ListInitialization || (NumExprs == 1 && isa<InitListExpr>(Exprs[0])))
|
||||
assert((!ListInitialization || (Exprs.size() == 1 && isa<InitListExpr>(Exprs[0])))
|
||||
&& "List initialization must have initializer list as expression.");
|
||||
SourceRange FullRange = SourceRange(TyBeginLoc,
|
||||
ListInitialization ? Exprs[0]->getSourceRange().getEnd() : RParenLoc);
|
||||
|
@ -864,7 +861,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo,
|
|||
// If the expression list is a single expression, the type conversion
|
||||
// expression is equivalent (in definedness, and if defined in meaning) to the
|
||||
// corresponding cast expression.
|
||||
if (NumExprs == 1 && !ListInitialization) {
|
||||
if (Exprs.size() == 1 && !ListInitialization) {
|
||||
Expr *Arg = Exprs[0];
|
||||
return BuildCXXFunctionalCastExpr(TInfo, LParenLoc, Arg, RParenLoc);
|
||||
}
|
||||
|
@ -887,15 +884,13 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo,
|
|||
return ExprError();
|
||||
|
||||
InitializedEntity Entity = InitializedEntity::InitializeTemporary(TInfo);
|
||||
InitializationKind Kind
|
||||
= NumExprs ? ListInitialization
|
||||
? InitializationKind::CreateDirectList(TyBeginLoc)
|
||||
: InitializationKind::CreateDirect(TyBeginLoc,
|
||||
LParenLoc, RParenLoc)
|
||||
: InitializationKind::CreateValue(TyBeginLoc,
|
||||
LParenLoc, RParenLoc);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, Exprs, NumExprs);
|
||||
ExprResult Result = InitSeq.Perform(*this, Entity, Kind, exprs);
|
||||
InitializationKind Kind =
|
||||
Exprs.size() ? ListInitialization
|
||||
? InitializationKind::CreateDirectList(TyBeginLoc)
|
||||
: InitializationKind::CreateDirect(TyBeginLoc, LParenLoc, RParenLoc)
|
||||
: InitializationKind::CreateValue(TyBeginLoc, LParenLoc, RParenLoc);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, Exprs);
|
||||
ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Exprs);
|
||||
|
||||
if (!Result.isInvalid() && ListInitialization &&
|
||||
isa<InitListExpr>(Result.get())) {
|
||||
|
@ -1414,7 +1409,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
|
|||
|
||||
InitializedEntity Entity
|
||||
= InitializedEntity::InitializeNew(StartLoc, InitType);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, Inits, NumInits);
|
||||
InitializationSequence InitSeq(*this, Entity, Kind, MultiExprArg(Inits, NumInits));
|
||||
ExprResult FullInit = InitSeq.Perform(*this, Entity, Kind,
|
||||
MultiExprArg(Inits, NumInits));
|
||||
if (FullInit.isInvalid())
|
||||
|
@ -3498,8 +3493,7 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
|
|||
InitializedEntity To(InitializedEntity::InitializeTemporary(Args[0]));
|
||||
InitializationKind InitKind(InitializationKind::CreateDirect(KWLoc, KWLoc,
|
||||
RParenLoc));
|
||||
InitializationSequence Init(S, To, InitKind,
|
||||
ArgExprs.begin(), ArgExprs.size());
|
||||
InitializationSequence Init(S, To, InitKind, ArgExprs);
|
||||
if (Init.Failed())
|
||||
return false;
|
||||
|
||||
|
@ -3657,7 +3651,7 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT,
|
|||
EnterExpressionEvaluationContext Unevaluated(Self, Sema::Unevaluated);
|
||||
Sema::SFINAETrap SFINAE(Self, /*AccessCheckingSFINAE=*/true);
|
||||
Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl());
|
||||
InitializationSequence Init(Self, To, Kind, &FromPtr, 1);
|
||||
InitializationSequence Init(Self, To, Kind, FromPtr);
|
||||
if (Init.Failed())
|
||||
return false;
|
||||
|
||||
|
@ -4057,7 +4051,7 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
|
|||
QualType T = Self.Context.getLValueReferenceType(ToType);
|
||||
InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);
|
||||
|
||||
InitializationSequence InitSeq(Self, Entity, Kind, &From, 1);
|
||||
InitializationSequence InitSeq(Self, Entity, Kind, From);
|
||||
if (InitSeq.isDirectReferenceBinding()) {
|
||||
ToType = T;
|
||||
HaveConversion = true;
|
||||
|
@ -4065,7 +4059,7 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
|
|||
}
|
||||
|
||||
if (InitSeq.isAmbiguous())
|
||||
return InitSeq.Diagnose(Self, Entity, Kind, &From, 1);
|
||||
return InitSeq.Diagnose(Self, Entity, Kind, From);
|
||||
}
|
||||
|
||||
// -- If E2 is an rvalue, or if the conversion above cannot be done:
|
||||
|
@ -4085,14 +4079,14 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
|
|||
if (FRec == TRec || FDerivedFromT) {
|
||||
if (TTy.isAtLeastAsQualifiedAs(FTy)) {
|
||||
InitializedEntity Entity = InitializedEntity::InitializeTemporary(TTy);
|
||||
InitializationSequence InitSeq(Self, Entity, Kind, &From, 1);
|
||||
InitializationSequence InitSeq(Self, Entity, Kind, From);
|
||||
if (InitSeq) {
|
||||
HaveConversion = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (InitSeq.isAmbiguous())
|
||||
return InitSeq.Diagnose(Self, Entity, Kind, &From, 1);
|
||||
return InitSeq.Diagnose(Self, Entity, Kind, From);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4110,11 +4104,11 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
|
|||
TTy = TTy.getUnqualifiedType();
|
||||
|
||||
InitializedEntity Entity = InitializedEntity::InitializeTemporary(TTy);
|
||||
InitializationSequence InitSeq(Self, Entity, Kind, &From, 1);
|
||||
InitializationSequence InitSeq(Self, Entity, Kind, From);
|
||||
HaveConversion = !InitSeq.Failed();
|
||||
ToType = TTy;
|
||||
if (InitSeq.isAmbiguous())
|
||||
return InitSeq.Diagnose(Self, Entity, Kind, &From, 1);
|
||||
return InitSeq.Diagnose(Self, Entity, Kind, From);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -4187,7 +4181,7 @@ static bool ConvertForConditional(Sema &Self, ExprResult &E, QualType T) {
|
|||
InitializationKind Kind = InitializationKind::CreateCopy(E.get()->getLocStart(),
|
||||
SourceLocation());
|
||||
Expr *Arg = E.take();
|
||||
InitializationSequence InitSeq(Self, Entity, Kind, &Arg, 1);
|
||||
InitializationSequence InitSeq(Self, Entity, Kind, Arg);
|
||||
ExprResult Result = InitSeq.Perform(Self, Entity, Kind, Arg);
|
||||
if (Result.isInvalid())
|
||||
return true;
|
||||
|
@ -4636,8 +4630,8 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc,
|
|||
= InitializedEntity::InitializeTemporary(Composite1);
|
||||
InitializationKind Kind
|
||||
= InitializationKind::CreateCopy(Loc, SourceLocation());
|
||||
InitializationSequence E1ToC1(*this, Entity1, Kind, &E1, 1);
|
||||
InitializationSequence E2ToC1(*this, Entity1, Kind, &E2, 1);
|
||||
InitializationSequence E1ToC1(*this, Entity1, Kind, E1);
|
||||
InitializationSequence E2ToC1(*this, Entity1, Kind, E2);
|
||||
|
||||
if (E1ToC1 && E2ToC1) {
|
||||
// Conversion to Composite1 is viable.
|
||||
|
@ -4646,8 +4640,8 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc,
|
|||
// Composite2 is also viable.
|
||||
InitializedEntity Entity2
|
||||
= InitializedEntity::InitializeTemporary(Composite2);
|
||||
InitializationSequence E1ToC2(*this, Entity2, Kind, &E1, 1);
|
||||
InitializationSequence E2ToC2(*this, Entity2, Kind, &E2, 1);
|
||||
InitializationSequence E1ToC2(*this, Entity2, Kind, E1);
|
||||
InitializationSequence E2ToC2(*this, Entity2, Kind, E2);
|
||||
if (E1ToC2 && E2ToC2) {
|
||||
// Both Composite1 and Composite2 are viable and are different;
|
||||
// this is an ambiguity.
|
||||
|
@ -4675,8 +4669,8 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc,
|
|||
// Check whether Composite2 is viable.
|
||||
InitializedEntity Entity2
|
||||
= InitializedEntity::InitializeTemporary(Composite2);
|
||||
InitializationSequence E1ToC2(*this, Entity2, Kind, &E1, 1);
|
||||
InitializationSequence E2ToC2(*this, Entity2, Kind, &E2, 1);
|
||||
InitializationSequence E1ToC2(*this, Entity2, Kind, E1);
|
||||
InitializationSequence E2ToC2(*this, Entity2, Kind, E2);
|
||||
if (!E1ToC2 || !E2ToC2)
|
||||
return QualType();
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element,
|
|||
InitializationKind Kind
|
||||
= InitializationKind::CreateCopy(Element->getLocStart(),
|
||||
SourceLocation());
|
||||
InitializationSequence Seq(S, Entity, Kind, &Element, 1);
|
||||
InitializationSequence Seq(S, Entity, Kind, Element);
|
||||
if (!Seq.Failed())
|
||||
return Seq.Perform(S, Entity, Kind, Element);
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ void InitListChecker::CheckValueInitializable(const InitializedEntity &Entity) {
|
|||
SourceLocation Loc;
|
||||
InitializationKind Kind = InitializationKind::CreateValue(Loc, Loc, Loc,
|
||||
true);
|
||||
InitializationSequence InitSeq(SemaRef, Entity, Kind, 0, 0);
|
||||
InitializationSequence InitSeq(SemaRef, Entity, Kind, MultiExprArg());
|
||||
if (InitSeq.Failed())
|
||||
hadError = true;
|
||||
}
|
||||
|
@ -328,9 +328,9 @@ void InitListChecker::FillInValueInitForField(unsigned Init, FieldDecl *Field,
|
|||
|
||||
InitializationKind Kind = InitializationKind::CreateValue(Loc, Loc, Loc,
|
||||
true);
|
||||
InitializationSequence InitSeq(SemaRef, MemberEntity, Kind, 0, 0);
|
||||
InitializationSequence InitSeq(SemaRef, MemberEntity, Kind, MultiExprArg());
|
||||
if (!InitSeq) {
|
||||
InitSeq.Diagnose(SemaRef, MemberEntity, Kind, 0, 0);
|
||||
InitSeq.Diagnose(SemaRef, MemberEntity, Kind, ArrayRef<Expr *>());
|
||||
hadError = true;
|
||||
return;
|
||||
}
|
||||
|
@ -446,9 +446,9 @@ InitListChecker::FillInValueInitializations(const InitializedEntity &Entity,
|
|||
if (!InitExpr && !ILE->hasArrayFiller()) {
|
||||
InitializationKind Kind = InitializationKind::CreateValue(Loc, Loc, Loc,
|
||||
true);
|
||||
InitializationSequence InitSeq(SemaRef, ElementEntity, Kind, 0, 0);
|
||||
InitializationSequence InitSeq(SemaRef, ElementEntity, Kind, MultiExprArg());
|
||||
if (!InitSeq) {
|
||||
InitSeq.Diagnose(SemaRef, ElementEntity, Kind, 0, 0);
|
||||
InitSeq.Diagnose(SemaRef, ElementEntity, Kind, ArrayRef<Expr *>());
|
||||
hadError = true;
|
||||
return;
|
||||
}
|
||||
|
@ -809,12 +809,12 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity,
|
|||
// FIXME: Better EqualLoc?
|
||||
InitializationKind Kind =
|
||||
InitializationKind::CreateCopy(expr->getLocStart(), SourceLocation());
|
||||
InitializationSequence Seq(SemaRef, Entity, Kind, &expr, 1);
|
||||
InitializationSequence Seq(SemaRef, Entity, Kind, expr);
|
||||
|
||||
if (Seq) {
|
||||
if (!VerifyOnly) {
|
||||
ExprResult Result =
|
||||
Seq.Perform(SemaRef, Entity, Kind, MultiExprArg(&expr, 1));
|
||||
Seq.Perform(SemaRef, Entity, Kind, expr);
|
||||
if (Result.isInvalid())
|
||||
hadError = true;
|
||||
|
||||
|
@ -844,8 +844,8 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity,
|
|||
hadError = true;
|
||||
else {
|
||||
ExprRes = SemaRef.DefaultFunctionArrayLvalueConversion(ExprRes.take());
|
||||
if (ExprRes.isInvalid())
|
||||
hadError = true;
|
||||
if (ExprRes.isInvalid())
|
||||
hadError = true;
|
||||
}
|
||||
UpdateStructuredListElement(StructuredList, StructuredIndex,
|
||||
ExprRes.takeAs<Expr>());
|
||||
|
@ -2808,7 +2808,7 @@ static bool TryInitializerListConstruction(Sema &S,
|
|||
|
||||
static OverloadingResult
|
||||
ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
MultiExprArg Args,
|
||||
OverloadCandidateSet &CandidateSet,
|
||||
ArrayRef<NamedDecl *> Ctors,
|
||||
OverloadCandidateSet::iterator &Best,
|
||||
|
@ -2834,7 +2834,7 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc,
|
|||
// If we're performing copy initialization using a copy constructor, we
|
||||
// suppress user-defined conversions on the arguments. We do the same for
|
||||
// move constructors.
|
||||
if ((CopyInitializing || (InitListSyntax && NumArgs == 1)) &&
|
||||
if ((CopyInitializing || (InitListSyntax && Args.size() == 1)) &&
|
||||
Constructor->isCopyOrMoveConstructor())
|
||||
SuppressUserConversions = true;
|
||||
}
|
||||
|
@ -2844,8 +2844,7 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc,
|
|||
(!OnlyListConstructors || S.isInitListConstructor(Constructor))) {
|
||||
if (ConstructorTmpl)
|
||||
S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl,
|
||||
/*ExplicitArgs*/ 0,
|
||||
llvm::makeArrayRef(Args, NumArgs),
|
||||
/*ExplicitArgs*/ 0, Args,
|
||||
CandidateSet, SuppressUserConversions);
|
||||
else {
|
||||
// C++ [over.match.copy]p1:
|
||||
|
@ -2855,10 +2854,9 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc,
|
|||
// context of direct-initialization, explicit conversion functions
|
||||
// are also considered.
|
||||
bool AllowExplicitConv = AllowExplicit && !CopyInitializing &&
|
||||
NumArgs == 1 &&
|
||||
Args.size() == 1 &&
|
||||
Constructor->isCopyOrMoveConstructor();
|
||||
S.AddOverloadCandidate(Constructor, FoundDecl,
|
||||
llvm::makeArrayRef(Args, NumArgs), CandidateSet,
|
||||
S.AddOverloadCandidate(Constructor, FoundDecl, Args, CandidateSet,
|
||||
SuppressUserConversions,
|
||||
/*PartialOverloading=*/false,
|
||||
/*AllowExplicit=*/AllowExplicitConv);
|
||||
|
@ -2878,11 +2876,10 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc,
|
|||
static void TryConstructorInitialization(Sema &S,
|
||||
const InitializedEntity &Entity,
|
||||
const InitializationKind &Kind,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
QualType DestType,
|
||||
MultiExprArg Args, QualType DestType,
|
||||
InitializationSequence &Sequence,
|
||||
bool InitListSyntax = false) {
|
||||
assert((!InitListSyntax || (NumArgs == 1 && isa<InitListExpr>(Args[0]))) &&
|
||||
assert((!InitListSyntax || (Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
|
||||
"InitListSyntax must come with a single initializer list argument.");
|
||||
|
||||
// The type we're constructing needs to be complete.
|
||||
|
@ -2931,15 +2928,14 @@ static void TryConstructorInitialization(Sema &S,
|
|||
// If the initializer list has no elements and T has a default constructor,
|
||||
// the first phase is omitted.
|
||||
if (ILE->getNumInits() != 0 || !DestRecordDecl->hasDefaultConstructor())
|
||||
Result = ResolveConstructorOverload(S, Kind.getLocation(), Args, NumArgs,
|
||||
Result = ResolveConstructorOverload(S, Kind.getLocation(), Args,
|
||||
CandidateSet, Ctors, Best,
|
||||
CopyInitialization, AllowExplicit,
|
||||
/*OnlyListConstructor=*/true,
|
||||
InitListSyntax);
|
||||
|
||||
// Time to unwrap the init list.
|
||||
Args = ILE->getInits();
|
||||
NumArgs = ILE->getNumInits();
|
||||
Args = MultiExprArg(ILE->getInits(), ILE->getNumInits());
|
||||
}
|
||||
|
||||
// C++11 [over.match.list]p1:
|
||||
|
@ -2949,7 +2945,7 @@ static void TryConstructorInitialization(Sema &S,
|
|||
// elements of the initializer list.
|
||||
if (Result == OR_No_Viable_Function) {
|
||||
AsInitializerList = false;
|
||||
Result = ResolveConstructorOverload(S, Kind.getLocation(), Args, NumArgs,
|
||||
Result = ResolveConstructorOverload(S, Kind.getLocation(), Args,
|
||||
CandidateSet, Ctors, Best,
|
||||
CopyInitialization, AllowExplicit,
|
||||
/*OnlyListConstructors=*/false,
|
||||
|
@ -3156,8 +3152,8 @@ static void TryListInitialization(Sema &S,
|
|||
return;
|
||||
|
||||
// - Otherwise, if T is a class type, constructors are considered.
|
||||
Expr *Arg = InitList;
|
||||
TryConstructorInitialization(S, Entity, Kind, &Arg, 1, DestType,
|
||||
Expr *InitListAsExpr = InitList;
|
||||
TryConstructorInitialization(S, Entity, Kind, InitListAsExpr, DestType,
|
||||
Sequence, /*InitListSyntax*/true);
|
||||
} else
|
||||
Sequence.SetFailed(
|
||||
|
@ -3771,12 +3767,11 @@ static void TryValueInitialization(Sema &S,
|
|||
// building the constructor call. This affects the semantics of a few
|
||||
// things (such as whether an explicit default constructor can be called).
|
||||
Expr *InitListAsExpr = InitList;
|
||||
Expr **Args = InitList ? &InitListAsExpr : 0;
|
||||
unsigned NumArgs = InitList ? 1 : 0;
|
||||
MultiExprArg Args(&InitListAsExpr, InitList ? 1 : 0);
|
||||
bool InitListSyntax = InitList;
|
||||
|
||||
return TryConstructorInitialization(S, Entity, Kind, Args, NumArgs, T,
|
||||
Sequence, InitListSyntax);
|
||||
return TryConstructorInitialization(S, Entity, Kind, Args, T, Sequence,
|
||||
InitListSyntax);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3799,7 +3794,7 @@ static void TryDefaultInitialization(Sema &S,
|
|||
// constructor for T is called (and the initialization is ill-formed if
|
||||
// T has no accessible default constructor);
|
||||
if (DestType->isRecordType() && S.getLangOpts().CPlusPlus) {
|
||||
TryConstructorInitialization(S, Entity, Kind, 0, 0, DestType, Sequence);
|
||||
TryConstructorInitialization(S, Entity, Kind, MultiExprArg(), DestType, Sequence);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4171,8 +4166,7 @@ static bool TryOCLZeroEventInitialization(Sema &S,
|
|||
InitializationSequence::InitializationSequence(Sema &S,
|
||||
const InitializedEntity &Entity,
|
||||
const InitializationKind &Kind,
|
||||
Expr **Args,
|
||||
unsigned NumArgs)
|
||||
MultiExprArg Args)
|
||||
: FailedCandidateSet(Kind.getLocation()) {
|
||||
ASTContext &Context = S.Context;
|
||||
|
||||
|
@ -4180,7 +4174,7 @@ InitializationSequence::InitializationSequence(Sema &S,
|
|||
// need to do this before checking whether types are dependent
|
||||
// because lowering a pseudo-object expression might well give us
|
||||
// something of dependent type.
|
||||
for (unsigned I = 0; I != NumArgs; ++I)
|
||||
for (unsigned I = 0, E = Args.size(); I != E; ++I)
|
||||
if (Args[I]->getType()->isNonOverloadPlaceholderType()) {
|
||||
// FIXME: should we be doing this here?
|
||||
ExprResult result = S.CheckPlaceholderExpr(Args[I]);
|
||||
|
@ -4200,7 +4194,7 @@ InitializationSequence::InitializationSequence(Sema &S,
|
|||
QualType DestType = Entity.getType();
|
||||
|
||||
if (DestType->isDependentType() ||
|
||||
Expr::hasAnyTypeDependentArguments(llvm::makeArrayRef(Args, NumArgs))) {
|
||||
Expr::hasAnyTypeDependentArguments(Args)) {
|
||||
SequenceKind = DependentSequence;
|
||||
return;
|
||||
}
|
||||
|
@ -4210,7 +4204,7 @@ InitializationSequence::InitializationSequence(Sema &S,
|
|||
|
||||
QualType SourceType;
|
||||
Expr *Initializer = 0;
|
||||
if (NumArgs == 1) {
|
||||
if (Args.size() == 1) {
|
||||
Initializer = Args[0];
|
||||
if (!isa<InitListExpr>(Initializer))
|
||||
SourceType = Initializer->getType();
|
||||
|
@ -4232,7 +4226,7 @@ InitializationSequence::InitializationSequence(Sema &S,
|
|||
// (8.3.2), shall be initialized by an object, or function, of type T or
|
||||
// by an object that can be converted into a T.
|
||||
// (Therefore, multiple arguments are not permitted.)
|
||||
if (NumArgs != 1)
|
||||
if (Args.size() != 1)
|
||||
SetFailed(FK_TooManyInitsForReference);
|
||||
else
|
||||
TryReferenceInitialization(S, Entity, Kind, Args[0], *this);
|
||||
|
@ -4241,7 +4235,7 @@ InitializationSequence::InitializationSequence(Sema &S,
|
|||
|
||||
// - If the initializer is (), the object is value-initialized.
|
||||
if (Kind.getKind() == InitializationKind::IK_Value ||
|
||||
(Kind.getKind() == InitializationKind::IK_Direct && NumArgs == 0)) {
|
||||
(Kind.getKind() == InitializationKind::IK_Direct && Args.empty())) {
|
||||
TryValueInitialization(S, Entity, Kind, *this);
|
||||
return;
|
||||
}
|
||||
|
@ -4338,7 +4332,7 @@ InitializationSequence::InitializationSequence(Sema &S,
|
|||
(Kind.getKind() == InitializationKind::IK_Copy &&
|
||||
(Context.hasSameUnqualifiedType(SourceType, DestType) ||
|
||||
S.IsDerivedFrom(SourceType, DestType))))
|
||||
TryConstructorInitialization(S, Entity, Kind, Args, NumArgs,
|
||||
TryConstructorInitialization(S, Entity, Kind, Args,
|
||||
Entity.getType(), *this);
|
||||
// - Otherwise (i.e., for the remaining copy-initialization cases),
|
||||
// user-defined conversion sequences that can convert from the source
|
||||
|
@ -4351,11 +4345,11 @@ InitializationSequence::InitializationSequence(Sema &S,
|
|||
return;
|
||||
}
|
||||
|
||||
if (NumArgs > 1) {
|
||||
if (Args.size() > 1) {
|
||||
SetFailed(FK_TooManyInitsForScalar);
|
||||
return;
|
||||
}
|
||||
assert(NumArgs == 1 && "Zero-argument case handled above");
|
||||
assert(Args.size() == 1 && "Zero-argument case handled above");
|
||||
|
||||
// - Otherwise, if the source type is a (possibly cv-qualified) class
|
||||
// type, conversion functions are considered.
|
||||
|
@ -4725,8 +4719,7 @@ static ExprResult CopyObject(Sema &S,
|
|||
// Determine the arguments required to actually perform the
|
||||
// constructor call (we might have derived-to-base conversions, or
|
||||
// the copy constructor may have default arguments).
|
||||
if (S.CompleteConstructorCall(Constructor, MultiExprArg(&CurInitExpr, 1),
|
||||
Loc, ConstructorArgs))
|
||||
if (S.CompleteConstructorCall(Constructor, CurInitExpr, Loc, ConstructorArgs))
|
||||
return ExprError();
|
||||
|
||||
// Actually perform the constructor call.
|
||||
|
@ -4985,8 +4978,7 @@ InitializationSequence::Perform(Sema &S,
|
|||
MultiExprArg Args,
|
||||
QualType *ResultType) {
|
||||
if (Failed()) {
|
||||
unsigned NumArgs = Args.size();
|
||||
Diagnose(S, Entity, Kind, Args.data(), NumArgs);
|
||||
Diagnose(S, Entity, Kind, Args);
|
||||
return ExprError();
|
||||
}
|
||||
|
||||
|
@ -5741,7 +5733,7 @@ static void emitBadConversionNotes(Sema &S, const InitializedEntity &entity,
|
|||
bool InitializationSequence::Diagnose(Sema &S,
|
||||
const InitializedEntity &Entity,
|
||||
const InitializationKind &Kind,
|
||||
Expr **Args, unsigned NumArgs) {
|
||||
ArrayRef<Expr *> Args) {
|
||||
if (!Failed())
|
||||
return false;
|
||||
|
||||
|
@ -5749,7 +5741,7 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
switch (Failure) {
|
||||
case FK_TooManyInitsForReference:
|
||||
// FIXME: Customize for the initialized entity?
|
||||
if (NumArgs == 0) {
|
||||
if (Args.empty()) {
|
||||
// Dig out the reference subobject which is uninitialized and diagnose it.
|
||||
// If this is value-initialization, this could be nested some way within
|
||||
// the target type.
|
||||
|
@ -5761,7 +5753,7 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
(void)Diagnosed;
|
||||
} else // FIXME: diagnostic below could be better!
|
||||
S.Diag(Kind.getLocation(), diag::err_reference_has_multiple_inits)
|
||||
<< SourceRange(Args[0]->getLocStart(), Args[NumArgs - 1]->getLocEnd());
|
||||
<< SourceRange(Args.front()->getLocStart(), Args.back()->getLocEnd());
|
||||
break;
|
||||
|
||||
case FK_ArrayNeedsInitList:
|
||||
|
@ -5808,16 +5800,14 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
<< DestType << Args[0]->getType()
|
||||
<< Args[0]->getSourceRange();
|
||||
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates, Args);
|
||||
break;
|
||||
|
||||
case OR_No_Viable_Function:
|
||||
S.Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
|
||||
<< Args[0]->getType() << DestType.getNonReferenceType()
|
||||
<< Args[0]->getSourceRange();
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args);
|
||||
break;
|
||||
|
||||
case OR_Deleted: {
|
||||
|
@ -5910,7 +5900,7 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
R = SourceRange(InitList->getInit(0)->getLocEnd(),
|
||||
InitList->getLocEnd());
|
||||
else
|
||||
R = SourceRange(Args[0]->getLocEnd(), Args[NumArgs - 1]->getLocEnd());
|
||||
R = SourceRange(Args.front()->getLocEnd(), Args.back()->getLocEnd());
|
||||
|
||||
R.setBegin(S.PP.getLocForEndOfToken(R.getBegin()));
|
||||
if (Kind.isCStyleOrFunctionalCast())
|
||||
|
@ -5935,15 +5925,14 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
case FK_ListConstructorOverloadFailed:
|
||||
case FK_ConstructorOverloadFailed: {
|
||||
SourceRange ArgsRange;
|
||||
if (NumArgs)
|
||||
ArgsRange = SourceRange(Args[0]->getLocStart(),
|
||||
Args[NumArgs - 1]->getLocEnd());
|
||||
if (Args.size())
|
||||
ArgsRange = SourceRange(Args.front()->getLocStart(),
|
||||
Args.back()->getLocEnd());
|
||||
|
||||
if (Failure == FK_ListConstructorOverloadFailed) {
|
||||
assert(NumArgs == 1 && "List construction from other than 1 argument.");
|
||||
assert(Args.size() == 1 && "List construction from other than 1 argument.");
|
||||
InitListExpr *InitList = cast<InitListExpr>(Args[0]);
|
||||
Args = InitList->getInits();
|
||||
NumArgs = InitList->getNumInits();
|
||||
Args = MultiExprArg(InitList->getInits(), InitList->getNumInits());
|
||||
}
|
||||
|
||||
// FIXME: Using "DestType" for the entity we're printing is probably
|
||||
|
@ -5952,8 +5941,7 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
case OR_Ambiguous:
|
||||
S.Diag(Kind.getLocation(), diag::err_ovl_ambiguous_init)
|
||||
<< DestType << ArgsRange;
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates, Args);
|
||||
break;
|
||||
|
||||
case OR_No_Viable_Function:
|
||||
|
@ -6000,8 +5988,7 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
|
||||
S.Diag(Kind.getLocation(), diag::err_ovl_no_viable_function_in_init)
|
||||
<< DestType << ArgsRange;
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args);
|
||||
break;
|
||||
|
||||
case OR_Deleted: {
|
||||
|
@ -6519,7 +6506,7 @@ Sema::CanPerformCopyInitialization(const InitializedEntity &Entity,
|
|||
|
||||
InitializationKind Kind
|
||||
= InitializationKind::CreateCopy(InitE->getLocStart(), SourceLocation());
|
||||
InitializationSequence Seq(*this, Entity, Kind, &InitE, 1);
|
||||
InitializationSequence Seq(*this, Entity, Kind, InitE);
|
||||
return !Seq.Failed();
|
||||
}
|
||||
|
||||
|
@ -6541,10 +6528,10 @@ Sema::PerformCopyInitialization(const InitializedEntity &Entity,
|
|||
InitializationKind Kind = InitializationKind::CreateCopy(InitE->getLocStart(),
|
||||
EqualLoc,
|
||||
AllowExplicit);
|
||||
InitializationSequence Seq(*this, Entity, Kind, &InitE, 1);
|
||||
InitializationSequence Seq(*this, Entity, Kind, InitE);
|
||||
Init.release();
|
||||
|
||||
ExprResult Result = Seq.Perform(*this, Entity, Kind, MultiExprArg(&InitE, 1));
|
||||
ExprResult Result = Seq.Perform(*this, Entity, Kind, InitE);
|
||||
|
||||
if (!Result.isInvalid() && TopLevelOfInitList)
|
||||
DiagnoseNarrowingInInitList(*this, Seq, Entity.getType(),
|
||||
|
|
|
@ -2309,7 +2309,7 @@ Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
|
|||
InitializationKind Kind
|
||||
= InitializationKind::CreateCopy(Value->getLocStart(),
|
||||
Value->getLocStart());
|
||||
InitializationSequence Seq(*this, Entity, Kind, &InitExpr, 1);
|
||||
InitializationSequence Seq(*this, Entity, Kind, InitExpr);
|
||||
|
||||
// [...] If overload resolution fails, or if the type of the first
|
||||
// parameter of the selected constructor is not an rvalue reference
|
||||
|
@ -2342,7 +2342,7 @@ Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
|
|||
|
||||
// Complete type-checking the initialization of the return type
|
||||
// using the constructor we found.
|
||||
Res = Seq.Perform(*this, Entity, Kind, MultiExprArg(&Value, 1));
|
||||
Res = Seq.Perform(*this, Entity, Kind, Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue