зеркало из https://github.com/microsoft/clang-1.git
ArrayRef'ize some SemaOverload methods
Patch by Robert Wilhelm. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181544 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
f632730ffb
Коммит
9e00f12a25
|
@ -2160,14 +2160,13 @@ public:
|
|||
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn,
|
||||
UnresolvedLookupExpr *ULE,
|
||||
SourceLocation LParenLoc,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
MultiExprArg Args,
|
||||
SourceLocation RParenLoc,
|
||||
Expr *ExecConfig,
|
||||
bool AllowTypoCorrection=true);
|
||||
|
||||
bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
SourceLocation RParenLoc,
|
||||
MultiExprArg Args, SourceLocation RParenLoc,
|
||||
OverloadCandidateSet *CandidateSet,
|
||||
ExprResult *Result);
|
||||
|
||||
|
@ -2187,8 +2186,9 @@ public:
|
|||
|
||||
ExprResult
|
||||
BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
|
||||
SourceLocation LParenLoc, Expr **Args,
|
||||
unsigned NumArgs, SourceLocation RParenLoc);
|
||||
SourceLocation LParenLoc,
|
||||
MultiExprArg Args,
|
||||
SourceLocation RParenLoc);
|
||||
ExprResult
|
||||
BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
|
@ -2945,7 +2945,7 @@ public:
|
|||
ObjCMethodDecl *Getter,
|
||||
SourceLocation Loc);
|
||||
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
|
||||
Expr **Args, unsigned NumArgs);
|
||||
ArrayRef<Expr *> Args);
|
||||
|
||||
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
|
||||
Decl *LambdaContextDecl = 0,
|
||||
|
@ -3256,7 +3256,7 @@ public:
|
|||
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
||||
FunctionDecl *FDecl,
|
||||
const FunctionProtoType *Proto,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
ArrayRef<Expr *> Args,
|
||||
SourceLocation RParenLoc,
|
||||
bool ExecConfig = false);
|
||||
void CheckStaticArrayArgument(SourceLocation CallLoc,
|
||||
|
@ -3271,7 +3271,7 @@ public:
|
|||
Expr *ExecConfig = 0, bool IsExecConfig = false);
|
||||
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
|
||||
SourceLocation LParenLoc,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
ArrayRef<Expr *> Arg,
|
||||
SourceLocation RParenLoc,
|
||||
Expr *Config = 0,
|
||||
bool IsExecConfig = false);
|
||||
|
@ -6778,7 +6778,7 @@ public:
|
|||
FunctionDecl *FDecl,
|
||||
const FunctionProtoType *Proto,
|
||||
unsigned FirstProtoArg,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
ArrayRef<Expr *> Args,
|
||||
SmallVector<Expr *, 8> &AllArgs,
|
||||
VariadicCallType CallType = VariadicDoesNotApply,
|
||||
bool AllowExplicit = false,
|
||||
|
|
|
@ -8557,7 +8557,7 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T,
|
|||
|
||||
ExprResult Call = S.BuildCallToMemberFunction(/*Scope=*/0,
|
||||
OpEqualRef.takeAs<Expr>(),
|
||||
Loc, &From, 1, Loc);
|
||||
Loc, From, Loc);
|
||||
if (Call.isInvalid())
|
||||
return StmtError();
|
||||
|
||||
|
@ -10081,12 +10081,14 @@ Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
|
|||
Proto->isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
|
||||
SmallVector<Expr *, 8> AllArgs;
|
||||
bool Invalid = GatherArgumentsForCall(Loc, Constructor,
|
||||
Proto, 0, Args, NumArgs, AllArgs,
|
||||
Proto, 0,
|
||||
llvm::makeArrayRef(Args, NumArgs),
|
||||
AllArgs,
|
||||
CallType, AllowExplicit,
|
||||
IsListInitialization);
|
||||
ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
|
||||
|
||||
DiagnoseSentinelCalls(Constructor, Loc, AllArgs.data(), AllArgs.size());
|
||||
DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
|
||||
|
||||
CheckConstructorCall(Constructor,
|
||||
llvm::makeArrayRef<const Expr *>(AllArgs.data(),
|
||||
|
|
|
@ -316,7 +316,7 @@ std::string Sema::getDeletedOrUnavailableSuffix(const FunctionDecl *FD) {
|
|||
/// if so, it checks that the requirements of the sentinel are
|
||||
/// satisfied.
|
||||
void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
|
||||
Expr **args, unsigned numArgs) {
|
||||
ArrayRef<Expr *> Args) {
|
||||
const SentinelAttr *attr = D->getAttr<SentinelAttr>();
|
||||
if (!attr)
|
||||
return;
|
||||
|
@ -370,14 +370,14 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
|
|||
|
||||
// If there aren't enough arguments for all the formal parameters,
|
||||
// the sentinel, and the args after the sentinel, complain.
|
||||
if (numArgs < numFormalParams + numArgsAfterSentinel + 1) {
|
||||
if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
|
||||
Diag(Loc, diag::warn_not_enough_argument) << D->getDeclName();
|
||||
Diag(D->getLocation(), diag::note_sentinel_here) << calleeType;
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, find the sentinel expression.
|
||||
Expr *sentinelExpr = args[numArgs - numArgsAfterSentinel - 1];
|
||||
Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
|
||||
if (!sentinelExpr) return;
|
||||
if (sentinelExpr->isValueDependent()) return;
|
||||
if (Context.isSentinelNullExpr(sentinelExpr)) return;
|
||||
|
@ -3811,7 +3811,7 @@ bool
|
|||
Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
||||
FunctionDecl *FDecl,
|
||||
const FunctionProtoType *Proto,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
ArrayRef<Expr *> Args,
|
||||
SourceLocation RParenLoc,
|
||||
bool IsExecConfig) {
|
||||
// Bail out early if calling a builtin with custom typechecking.
|
||||
|
@ -3833,8 +3833,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
|||
|
||||
// If too few arguments are available (and we don't have default
|
||||
// arguments for the remaining parameters), don't make the call.
|
||||
if (NumArgs < NumArgsInProto) {
|
||||
if (NumArgs < MinArgs) {
|
||||
if (Args.size() < NumArgsInProto) {
|
||||
if (Args.size() < MinArgs) {
|
||||
if (MinArgs == 1 && FDecl && FDecl->getParamDecl(0)->getDeclName())
|
||||
Diag(RParenLoc, MinArgs == NumArgsInProto && !Proto->isVariadic()
|
||||
? diag::err_typecheck_call_too_few_args_one
|
||||
|
@ -3846,7 +3846,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
|||
? diag::err_typecheck_call_too_few_args
|
||||
: diag::err_typecheck_call_too_few_args_at_least)
|
||||
<< FnKind
|
||||
<< MinArgs << NumArgs << Fn->getSourceRange();
|
||||
<< MinArgs << static_cast<unsigned>(Args.size())
|
||||
<< Fn->getSourceRange();
|
||||
|
||||
// Emit the location of the prototype.
|
||||
if (FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
|
||||
|
@ -3860,7 +3861,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
|||
|
||||
// If too many are passed and not variadic, error on the extras and drop
|
||||
// them.
|
||||
if (NumArgs > NumArgsInProto) {
|
||||
if (Args.size() > NumArgsInProto) {
|
||||
if (!Proto->isVariadic()) {
|
||||
if (NumArgsInProto == 1 && FDecl && FDecl->getParamDecl(0)->getDeclName())
|
||||
Diag(Args[NumArgsInProto]->getLocStart(),
|
||||
|
@ -3868,18 +3869,20 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
|||
? diag::err_typecheck_call_too_many_args_one
|
||||
: diag::err_typecheck_call_too_many_args_at_most_one)
|
||||
<< FnKind
|
||||
<< FDecl->getParamDecl(0) << NumArgs << Fn->getSourceRange()
|
||||
<< FDecl->getParamDecl(0) << static_cast<unsigned>(Args.size())
|
||||
<< Fn->getSourceRange()
|
||||
<< SourceRange(Args[NumArgsInProto]->getLocStart(),
|
||||
Args[NumArgs-1]->getLocEnd());
|
||||
Args.back()->getLocEnd());
|
||||
else
|
||||
Diag(Args[NumArgsInProto]->getLocStart(),
|
||||
MinArgs == NumArgsInProto
|
||||
? diag::err_typecheck_call_too_many_args
|
||||
: diag::err_typecheck_call_too_many_args_at_most)
|
||||
<< FnKind
|
||||
<< NumArgsInProto << NumArgs << Fn->getSourceRange()
|
||||
<< NumArgsInProto << static_cast<unsigned>(Args.size())
|
||||
<< Fn->getSourceRange()
|
||||
<< SourceRange(Args[NumArgsInProto]->getLocStart(),
|
||||
Args[NumArgs-1]->getLocEnd());
|
||||
Args.back()->getLocEnd());
|
||||
|
||||
// Emit the location of the prototype.
|
||||
if (FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
|
||||
|
@ -3895,7 +3898,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
|||
VariadicCallType CallType = getVariadicCallType(FDecl, Proto, Fn);
|
||||
|
||||
Invalid = GatherArgumentsForCall(Call->getLocStart(), FDecl,
|
||||
Proto, 0, Args, NumArgs, AllArgs, CallType);
|
||||
Proto, 0, Args, AllArgs, CallType);
|
||||
if (Invalid)
|
||||
return true;
|
||||
unsigned TotalNumArgs = AllArgs.size();
|
||||
|
@ -3909,15 +3912,15 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc,
|
|||
FunctionDecl *FDecl,
|
||||
const FunctionProtoType *Proto,
|
||||
unsigned FirstProtoArg,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
ArrayRef<Expr *> Args,
|
||||
SmallVector<Expr *, 8> &AllArgs,
|
||||
VariadicCallType CallType,
|
||||
bool AllowExplicit,
|
||||
bool IsListInitialization) {
|
||||
unsigned NumArgsInProto = Proto->getNumArgs();
|
||||
unsigned NumArgsToCheck = NumArgs;
|
||||
unsigned NumArgsToCheck = Args.size();
|
||||
bool Invalid = false;
|
||||
if (NumArgs != NumArgsInProto)
|
||||
if (Args.size() != NumArgsInProto)
|
||||
// Use default arguments for missing arguments
|
||||
NumArgsToCheck = NumArgsInProto;
|
||||
unsigned ArgIx = 0;
|
||||
|
@ -3927,7 +3930,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc,
|
|||
|
||||
Expr *Arg;
|
||||
ParmVarDecl *Param;
|
||||
if (ArgIx < NumArgs) {
|
||||
if (ArgIx < Args.size()) {
|
||||
Arg = Args[ArgIx++];
|
||||
|
||||
if (RequireCompleteType(Arg->getLocStart(),
|
||||
|
@ -3988,7 +3991,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc,
|
|||
// return __unknown_anytype aren't *really* variadic.
|
||||
if (Proto->getResultType() == Context.UnknownAnyTy &&
|
||||
FDecl && FDecl->isExternC()) {
|
||||
for (unsigned i = ArgIx; i != NumArgs; ++i) {
|
||||
for (unsigned i = ArgIx, e = Args.size(); i != e; ++i) {
|
||||
QualType paramType; // ignored
|
||||
ExprResult arg = checkUnknownAnyArg(CallLoc, Args[i], paramType);
|
||||
Invalid |= arg.isInvalid();
|
||||
|
@ -3997,7 +4000,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc,
|
|||
|
||||
// Otherwise do argument promotion, (C99 6.5.2.2p7).
|
||||
} else {
|
||||
for (unsigned i = ArgIx; i != NumArgs; ++i) {
|
||||
for (unsigned i = ArgIx, e = Args.size(); i != e; ++i) {
|
||||
ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], CallType,
|
||||
FDecl);
|
||||
Invalid |= Arg.isInvalid();
|
||||
|
@ -4006,7 +4009,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc,
|
|||
}
|
||||
|
||||
// Check for array bounds violations.
|
||||
for (unsigned i = ArgIx; i != NumArgs; ++i)
|
||||
for (unsigned i = ArgIx, e = Args.size(); i != e; ++i)
|
||||
CheckArrayAccess(Args[i]);
|
||||
}
|
||||
return Invalid;
|
||||
|
@ -4198,8 +4201,7 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
|
|||
}
|
||||
|
||||
if (Fn->getType() == Context.BoundMemberTy) {
|
||||
return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs.data(),
|
||||
ArgExprs.size(), RParenLoc);
|
||||
return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs, RParenLoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4212,11 +4214,11 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
|
|||
OverloadExpr *ovl = find.Expression;
|
||||
if (isa<UnresolvedLookupExpr>(ovl)) {
|
||||
UnresolvedLookupExpr *ULE = cast<UnresolvedLookupExpr>(ovl);
|
||||
return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, ArgExprs.data(),
|
||||
ArgExprs.size(), RParenLoc, ExecConfig);
|
||||
return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, ArgExprs,
|
||||
RParenLoc, ExecConfig);
|
||||
} else {
|
||||
return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs.data(),
|
||||
ArgExprs.size(), RParenLoc);
|
||||
return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs,
|
||||
RParenLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4240,9 +4242,8 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
|
|||
else if (isa<MemberExpr>(NakedFn))
|
||||
NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
|
||||
|
||||
return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs.data(),
|
||||
ArgExprs.size(), RParenLoc, ExecConfig,
|
||||
IsExecConfig);
|
||||
return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
|
||||
ExecConfig, IsExecConfig);
|
||||
}
|
||||
|
||||
ExprResult
|
||||
|
@ -4292,7 +4293,7 @@ ExprResult Sema::ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
|
|||
ExprResult
|
||||
Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
|
||||
SourceLocation LParenLoc,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
ArrayRef<Expr *> Args,
|
||||
SourceLocation RParenLoc,
|
||||
Expr *Config, bool IsExecConfig) {
|
||||
FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
|
||||
|
@ -4318,17 +4319,12 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
|
|||
CallExpr *TheCall;
|
||||
if (Config)
|
||||
TheCall = new (Context) CUDAKernelCallExpr(Context, Fn,
|
||||
cast<CallExpr>(Config),
|
||||
llvm::makeArrayRef(Args,NumArgs),
|
||||
Context.BoolTy,
|
||||
VK_RValue,
|
||||
cast<CallExpr>(Config), Args,
|
||||
Context.BoolTy, VK_RValue,
|
||||
RParenLoc);
|
||||
else
|
||||
TheCall = new (Context) CallExpr(Context, Fn,
|
||||
llvm::makeArrayRef(Args, NumArgs),
|
||||
Context.BoolTy,
|
||||
VK_RValue,
|
||||
RParenLoc);
|
||||
TheCall = new (Context) CallExpr(Context, Fn, Args, Context.BoolTy,
|
||||
VK_RValue, RParenLoc);
|
||||
|
||||
// Bail out early if calling a builtin with custom typechecking.
|
||||
if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID))
|
||||
|
@ -4391,8 +4387,8 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
|
|||
|
||||
const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FuncT);
|
||||
if (Proto) {
|
||||
if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, NumArgs,
|
||||
RParenLoc, IsExecConfig))
|
||||
if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
|
||||
IsExecConfig))
|
||||
return ExprError();
|
||||
} else {
|
||||
assert(isa<FunctionNoProtoType>(FuncT) && "Unknown FunctionType!");
|
||||
|
@ -4401,11 +4397,11 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
|
|||
// Check if we have too few/too many template arguments, based
|
||||
// on our knowledge of the function definition.
|
||||
const FunctionDecl *Def = 0;
|
||||
if (FDecl->hasBody(Def) && NumArgs != Def->param_size()) {
|
||||
if (FDecl->hasBody(Def) && Args.size() != Def->param_size()) {
|
||||
Proto = Def->getType()->getAs<FunctionProtoType>();
|
||||
if (!Proto || !(Proto->isVariadic() && NumArgs >= Def->param_size()))
|
||||
if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->param_size()))
|
||||
Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
|
||||
<< (NumArgs > Def->param_size()) << FDecl << Fn->getSourceRange();
|
||||
<< (Args.size() > Def->param_size()) << FDecl << Fn->getSourceRange();
|
||||
}
|
||||
|
||||
// If the function we're calling isn't a function prototype, but we have
|
||||
|
@ -4415,7 +4411,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
|
|||
}
|
||||
|
||||
// Promote the arguments (C99 6.5.2.2p6).
|
||||
for (unsigned i = 0; i != NumArgs; i++) {
|
||||
for (unsigned i = 0, e = Args.size(); i != e; i++) {
|
||||
Expr *Arg = Args[i];
|
||||
|
||||
if (Proto && i < Proto->getNumArgs()) {
|
||||
|
@ -4456,7 +4452,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
|
|||
|
||||
// Check for sentinels
|
||||
if (NDecl)
|
||||
DiagnoseSentinelCalls(NDecl, LParenLoc, Args, NumArgs);
|
||||
DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
|
||||
|
||||
// Do special checking on direct calls to functions.
|
||||
if (FDecl) {
|
||||
|
|
|
@ -1334,7 +1334,8 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
|
|||
Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply;
|
||||
|
||||
if (GatherArgumentsForCall(PlacementLParen, OperatorNew,
|
||||
Proto, 1, PlaceArgs, NumPlaceArgs,
|
||||
Proto, 1,
|
||||
llvm::makeArrayRef(PlaceArgs, NumPlaceArgs),
|
||||
AllPlaceArgs, CallType))
|
||||
return ExprError();
|
||||
|
||||
|
@ -1343,7 +1344,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
|
|||
PlaceArgs = &AllPlaceArgs[0];
|
||||
|
||||
DiagnoseSentinelCalls(OperatorNew, PlacementLParen,
|
||||
PlaceArgs, NumPlaceArgs);
|
||||
llvm::makeArrayRef(PlaceArgs, NumPlaceArgs));
|
||||
|
||||
// FIXME: Missing call to CheckFunctionCall or equivalent
|
||||
}
|
||||
|
|
|
@ -1323,7 +1323,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType,
|
|||
}
|
||||
}
|
||||
|
||||
DiagnoseSentinelCalls(Method, SelLoc, Args, NumArgs);
|
||||
DiagnoseSentinelCalls(Method, SelLoc, llvm::makeArrayRef(Args, NumArgs));
|
||||
|
||||
// Do additional checkings on method.
|
||||
IsError |= CheckObjCMethodCall(Method, SelLoc,
|
||||
|
|
|
@ -854,11 +854,11 @@ static bool checkPlaceholderForOverload(Sema &S, Expr *&E,
|
|||
|
||||
/// checkArgPlaceholdersForOverload - Check a set of call operands for
|
||||
/// placeholders.
|
||||
static bool checkArgPlaceholdersForOverload(Sema &S, Expr **args,
|
||||
unsigned numArgs,
|
||||
static bool checkArgPlaceholdersForOverload(Sema &S,
|
||||
MultiExprArg Args,
|
||||
UnbridgedCastsSet &unbridged) {
|
||||
for (unsigned i = 0; i != numArgs; ++i)
|
||||
if (checkPlaceholderForOverload(S, args[i], &unbridged))
|
||||
for (unsigned i = 0, e = Args.size(); i != e; ++i)
|
||||
if (checkPlaceholderForOverload(S, Args[i], &unbridged))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -9890,7 +9890,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
|
|||
/// \returns true when an the ExprResult output parameter has been set.
|
||||
bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn,
|
||||
UnresolvedLookupExpr *ULE,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
MultiExprArg Args,
|
||||
SourceLocation RParenLoc,
|
||||
OverloadCandidateSet *CandidateSet,
|
||||
ExprResult *Result) {
|
||||
|
@ -9913,15 +9913,14 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn,
|
|||
#endif
|
||||
|
||||
UnbridgedCastsSet UnbridgedCasts;
|
||||
if (checkArgPlaceholdersForOverload(*this, Args, NumArgs, UnbridgedCasts)) {
|
||||
if (checkArgPlaceholdersForOverload(*this, Args, UnbridgedCasts)) {
|
||||
*Result = ExprError();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Add the functions denoted by the callee to the set of candidate
|
||||
// functions, including those from argument-dependent lookup.
|
||||
AddOverloadedCallCandidates(ULE, llvm::makeArrayRef(Args, NumArgs),
|
||||
*CandidateSet);
|
||||
AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
|
||||
|
||||
// If we found nothing, try to recover.
|
||||
// BuildRecoveryCallExpr diagnoses the error itself, so we just bail
|
||||
|
@ -9933,8 +9932,7 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn,
|
|||
// classes.
|
||||
if (getLangOpts().MicrosoftMode && CurContext->isDependentContext() &&
|
||||
(isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
|
||||
CallExpr *CE = new (Context) CallExpr(Context, Fn,
|
||||
llvm::makeArrayRef(Args, NumArgs),
|
||||
CallExpr *CE = new (Context) CallExpr(Context, Fn, Args,
|
||||
Context.DependentTy, VK_RValue,
|
||||
RParenLoc);
|
||||
CE->setTypeDependent(true);
|
||||
|
@ -9954,7 +9952,7 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn,
|
|||
static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
|
||||
UnresolvedLookupExpr *ULE,
|
||||
SourceLocation LParenLoc,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
MultiExprArg Args,
|
||||
SourceLocation RParenLoc,
|
||||
Expr *ExecConfig,
|
||||
OverloadCandidateSet *CandidateSet,
|
||||
|
@ -9962,8 +9960,7 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
|
|||
OverloadingResult OverloadResult,
|
||||
bool AllowTypoCorrection) {
|
||||
if (CandidateSet->empty())
|
||||
return BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc,
|
||||
llvm::MutableArrayRef<Expr *>(Args, NumArgs),
|
||||
return BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc, Args,
|
||||
RParenLoc, /*EmptyLookup=*/true,
|
||||
AllowTypoCorrection);
|
||||
|
||||
|
@ -9974,16 +9971,15 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
|
|||
if (SemaRef.DiagnoseUseOfDecl(FDecl, ULE->getNameLoc()))
|
||||
return ExprError();
|
||||
Fn = SemaRef.FixOverloadedFunctionReference(Fn, (*Best)->FoundDecl, FDecl);
|
||||
return SemaRef.BuildResolvedCallExpr(Fn, FDecl, LParenLoc, Args, NumArgs,
|
||||
RParenLoc, ExecConfig);
|
||||
return SemaRef.BuildResolvedCallExpr(Fn, FDecl, LParenLoc, Args, RParenLoc,
|
||||
ExecConfig);
|
||||
}
|
||||
|
||||
case OR_No_Viable_Function: {
|
||||
// Try to recover by looking for viable functions which the user might
|
||||
// have meant to call.
|
||||
ExprResult Recovery = BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc,
|
||||
llvm::MutableArrayRef<Expr *>(Args, NumArgs),
|
||||
RParenLoc,
|
||||
Args, RParenLoc,
|
||||
/*EmptyLookup=*/false,
|
||||
AllowTypoCorrection);
|
||||
if (!Recovery.isInvalid())
|
||||
|
@ -9992,16 +9988,14 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
|
|||
SemaRef.Diag(Fn->getLocStart(),
|
||||
diag::err_ovl_no_viable_function_in_call)
|
||||
<< ULE->getName() << Fn->getSourceRange();
|
||||
CandidateSet->NoteCandidates(SemaRef, OCD_AllCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
CandidateSet->NoteCandidates(SemaRef, OCD_AllCandidates, Args);
|
||||
break;
|
||||
}
|
||||
|
||||
case OR_Ambiguous:
|
||||
SemaRef.Diag(Fn->getLocStart(), diag::err_ovl_ambiguous_call)
|
||||
<< ULE->getName() << Fn->getSourceRange();
|
||||
CandidateSet->NoteCandidates(SemaRef, OCD_ViableCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
CandidateSet->NoteCandidates(SemaRef, OCD_ViableCandidates, Args);
|
||||
break;
|
||||
|
||||
case OR_Deleted: {
|
||||
|
@ -10010,15 +10004,14 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
|
|||
<< ULE->getName()
|
||||
<< SemaRef.getDeletedOrUnavailableSuffix((*Best)->Function)
|
||||
<< Fn->getSourceRange();
|
||||
CandidateSet->NoteCandidates(SemaRef, OCD_AllCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
CandidateSet->NoteCandidates(SemaRef, OCD_AllCandidates, Args);
|
||||
|
||||
// We emitted an error for the unvailable/deleted function call but keep
|
||||
// the call in the AST.
|
||||
FunctionDecl *FDecl = (*Best)->Function;
|
||||
Fn = SemaRef.FixOverloadedFunctionReference(Fn, (*Best)->FoundDecl, FDecl);
|
||||
return SemaRef.BuildResolvedCallExpr(Fn, FDecl, LParenLoc, Args, NumArgs,
|
||||
RParenLoc, ExecConfig);
|
||||
return SemaRef.BuildResolvedCallExpr(Fn, FDecl, LParenLoc, Args, RParenLoc,
|
||||
ExecConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10035,22 +10028,22 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
|
|||
ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
|
||||
UnresolvedLookupExpr *ULE,
|
||||
SourceLocation LParenLoc,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
MultiExprArg Args,
|
||||
SourceLocation RParenLoc,
|
||||
Expr *ExecConfig,
|
||||
bool AllowTypoCorrection) {
|
||||
OverloadCandidateSet CandidateSet(Fn->getExprLoc());
|
||||
ExprResult result;
|
||||
|
||||
if (buildOverloadedCallSet(S, Fn, ULE, Args, NumArgs, LParenLoc,
|
||||
&CandidateSet, &result))
|
||||
if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
|
||||
&result))
|
||||
return result;
|
||||
|
||||
OverloadCandidateSet::iterator Best;
|
||||
OverloadingResult OverloadResult =
|
||||
CandidateSet.BestViableFunction(*this, Fn->getLocStart(), Best);
|
||||
|
||||
return FinishOverloadedCallExpr(*this, S, Fn, ULE, LParenLoc, Args, NumArgs,
|
||||
return FinishOverloadedCallExpr(*this, S, Fn, ULE, LParenLoc, Args,
|
||||
RParenLoc, ExecConfig, &CandidateSet,
|
||||
&Best, OverloadResult,
|
||||
AllowTypoCorrection);
|
||||
|
@ -10716,8 +10709,9 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
|
|||
/// member function.
|
||||
ExprResult
|
||||
Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
||||
SourceLocation LParenLoc, Expr **Args,
|
||||
unsigned NumArgs, SourceLocation RParenLoc) {
|
||||
SourceLocation LParenLoc,
|
||||
MultiExprArg Args,
|
||||
SourceLocation RParenLoc) {
|
||||
assert(MemExprE->getType() == Context.BoundMemberTy ||
|
||||
MemExprE->getType() == Context.OverloadTy);
|
||||
|
||||
|
@ -10758,8 +10752,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
}
|
||||
|
||||
CXXMemberCallExpr *call
|
||||
= new (Context) CXXMemberCallExpr(Context, MemExprE,
|
||||
llvm::makeArrayRef(Args, NumArgs),
|
||||
= new (Context) CXXMemberCallExpr(Context, MemExprE, Args,
|
||||
resultType, valueKind, RParenLoc);
|
||||
|
||||
if (CheckCallReturnType(proto->getResultType(),
|
||||
|
@ -10767,14 +10760,14 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
call, 0))
|
||||
return ExprError();
|
||||
|
||||
if (ConvertArgumentsForCall(call, op, 0, proto, Args, NumArgs, RParenLoc))
|
||||
if (ConvertArgumentsForCall(call, op, 0, proto, Args, RParenLoc))
|
||||
return ExprError();
|
||||
|
||||
return MaybeBindToTemporary(call);
|
||||
}
|
||||
|
||||
UnbridgedCastsSet UnbridgedCasts;
|
||||
if (checkArgPlaceholdersForOverload(*this, Args, NumArgs, UnbridgedCasts))
|
||||
if (checkArgPlaceholdersForOverload(*this, Args, UnbridgedCasts))
|
||||
return ExprError();
|
||||
|
||||
MemberExpr *MemExpr;
|
||||
|
@ -10818,7 +10811,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
// Microsoft supports direct constructor calls.
|
||||
if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
|
||||
AddOverloadCandidate(cast<CXXConstructorDecl>(Func), I.getPair(),
|
||||
llvm::makeArrayRef(Args, NumArgs), CandidateSet);
|
||||
Args, CandidateSet);
|
||||
} else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
|
||||
// If explicit template arguments were provided, we can't call a
|
||||
// non-template member function.
|
||||
|
@ -10826,15 +10819,13 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
continue;
|
||||
|
||||
AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType,
|
||||
ObjectClassification,
|
||||
llvm::makeArrayRef(Args, NumArgs), CandidateSet,
|
||||
ObjectClassification, Args, CandidateSet,
|
||||
/*SuppressUserConversions=*/false);
|
||||
} else {
|
||||
AddMethodTemplateCandidate(cast<FunctionTemplateDecl>(Func),
|
||||
I.getPair(), ActingDC, TemplateArgs,
|
||||
ObjectType, ObjectClassification,
|
||||
llvm::makeArrayRef(Args, NumArgs),
|
||||
CandidateSet,
|
||||
Args, CandidateSet,
|
||||
/*SuppressUsedConversions=*/false);
|
||||
}
|
||||
}
|
||||
|
@ -10858,16 +10849,14 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
Diag(UnresExpr->getMemberLoc(),
|
||||
diag::err_ovl_no_viable_member_function_in_call)
|
||||
<< DeclName << MemExprE->getSourceRange();
|
||||
CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args);
|
||||
// FIXME: Leaking incoming expressions!
|
||||
return ExprError();
|
||||
|
||||
case OR_Ambiguous:
|
||||
Diag(UnresExpr->getMemberLoc(), diag::err_ovl_ambiguous_member_call)
|
||||
<< DeclName << MemExprE->getSourceRange();
|
||||
CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args);
|
||||
// FIXME: Leaking incoming expressions!
|
||||
return ExprError();
|
||||
|
||||
|
@ -10877,8 +10866,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
<< DeclName
|
||||
<< getDeletedOrUnavailableSuffix(Best->Function)
|
||||
<< MemExprE->getSourceRange();
|
||||
CandidateSet.NoteCandidates(*this, OCD_AllCandidates,
|
||||
llvm::makeArrayRef(Args, NumArgs));
|
||||
CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args);
|
||||
// FIXME: Leaking incoming expressions!
|
||||
return ExprError();
|
||||
}
|
||||
|
@ -10888,8 +10876,8 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
// If overload resolution picked a static member, build a
|
||||
// non-member call based on that function.
|
||||
if (Method->isStatic()) {
|
||||
return BuildResolvedCallExpr(MemExprE, Method, LParenLoc,
|
||||
Args, NumArgs, RParenLoc);
|
||||
return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args,
|
||||
RParenLoc);
|
||||
}
|
||||
|
||||
MemExpr = cast<MemberExpr>(MemExprE->IgnoreParens());
|
||||
|
@ -10901,8 +10889,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
|
||||
assert(Method && "Member call to something that isn't a method?");
|
||||
CXXMemberCallExpr *TheCall =
|
||||
new (Context) CXXMemberCallExpr(Context, MemExprE,
|
||||
llvm::makeArrayRef(Args, NumArgs),
|
||||
new (Context) CXXMemberCallExpr(Context, MemExprE, Args,
|
||||
ResultType, VK, RParenLoc);
|
||||
|
||||
// Check for a valid return type.
|
||||
|
@ -10925,11 +10912,11 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
// Convert the rest of the arguments
|
||||
const FunctionProtoType *Proto =
|
||||
Method->getType()->getAs<FunctionProtoType>();
|
||||
if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args, NumArgs,
|
||||
if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
|
||||
RParenLoc))
|
||||
return ExprError();
|
||||
|
||||
DiagnoseSentinelCalls(Method, LParenLoc, Args, NumArgs);
|
||||
DiagnoseSentinelCalls(Method, LParenLoc, Args);
|
||||
|
||||
if (CheckFunctionCall(Method, TheCall, Proto))
|
||||
return ExprError();
|
||||
|
@ -10965,7 +10952,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
|
|||
ExprResult Object = Owned(Obj);
|
||||
|
||||
UnbridgedCastsSet UnbridgedCasts;
|
||||
if (checkArgPlaceholdersForOverload(*this, Args, NumArgs, UnbridgedCasts))
|
||||
if (checkArgPlaceholdersForOverload(*this, MultiExprArg(Args, NumArgs),
|
||||
UnbridgedCasts))
|
||||
return ExprError();
|
||||
|
||||
assert(Object.get()->getType()->isRecordType() && "Requires object type argument");
|
||||
|
@ -11243,7 +11231,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
|
|||
|
||||
if (IsError) return true;
|
||||
|
||||
DiagnoseSentinelCalls(Method, LParenLoc, Args, NumArgs);
|
||||
DiagnoseSentinelCalls(Method, LParenLoc, llvm::makeArrayRef(Args, NumArgs));
|
||||
|
||||
if (CheckFunctionCall(Method, TheCall, Proto))
|
||||
return true;
|
||||
|
@ -11473,7 +11461,7 @@ Sema::BuildForRangeBeginEndCall(Scope *S, SourceLocation Loc,
|
|||
/*NeedsADL=*/true, /*Overloaded=*/false,
|
||||
FoundNames.begin(), FoundNames.end());
|
||||
|
||||
bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, &Range, 1, Loc,
|
||||
bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc,
|
||||
CandidateSet, CallExpr);
|
||||
if (CandidateSet->empty() || CandidateSetError) {
|
||||
*CallExpr = ExprError();
|
||||
|
@ -11487,7 +11475,7 @@ Sema::BuildForRangeBeginEndCall(Scope *S, SourceLocation Loc,
|
|||
*CallExpr = ExprError();
|
||||
return FRS_NoViableFunction;
|
||||
}
|
||||
*CallExpr = FinishOverloadedCallExpr(*this, S, Fn, Fn, Loc, &Range, 1,
|
||||
*CallExpr = FinishOverloadedCallExpr(*this, S, Fn, Fn, Loc, Range,
|
||||
Loc, 0, CandidateSet, &Best,
|
||||
OverloadResult,
|
||||
/*AllowTypoCorrection=*/false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче