@@ -1274,11 +1274,8 @@ static bool SemaBuiltinPipePackets(Sema &S, CallExpr *Call) {
12741274// \return True if a semantic error has been found, false otherwise.
12751275static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID,
12761276 CallExpr *Call) {
1277- if (Call->getNumArgs() != 1) {
1278- S.Diag(Call->getBeginLoc(), diag::err_opencl_builtin_to_addr_arg_num)
1279- << Call->getDirectCallee() << Call->getSourceRange();
1277+ if (checkArgCount(S, Call, 1))
12801278 return true;
1281- }
12821279
12831280 auto RT = Call->getArg(0)->getType();
12841281 if (!RT->isPointerType() || RT->getPointeeType()
@@ -5708,21 +5705,8 @@ bool Sema::SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
57085705 if (checkVAStartABI(*this, BuiltinID, Fn))
57095706 return true;
57105707
5711- if (TheCall->getNumArgs() > 2) {
5712- Diag(TheCall->getArg(2)->getBeginLoc(),
5713- diag::err_typecheck_call_too_many_args)
5714- << 0 /*function call*/ << 2 << TheCall->getNumArgs()
5715- << Fn->getSourceRange()
5716- << SourceRange(TheCall->getArg(2)->getBeginLoc(),
5717- (*(TheCall->arg_end() - 1))->getEndLoc());
5708+ if (checkArgCount(*this, TheCall, 2))
57185709 return true;
5719- }
5720-
5721- if (TheCall->getNumArgs() < 2) {
5722- return Diag(TheCall->getEndLoc(),
5723- diag::err_typecheck_call_too_few_args_at_least)
5724- << 0 /*function call*/ << 2 << TheCall->getNumArgs();
5725- }
57265710
57275711 // Type-check the first argument normally.
57285712 if (checkBuiltinArgument(*this, TheCall, 0))
@@ -5832,15 +5816,8 @@ bool Sema::SemaBuiltinVAStartARMMicrosoft(CallExpr *Call) {
58325816/// SemaBuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
58335817/// friends. This is declared to take (...), so we have to check everything.
58345818bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
5835- if (TheCall->getNumArgs() < 2)
5836- return Diag(TheCall->getEndLoc(), diag::err_typecheck_call_too_few_args)
5837- << 0 << 2 << TheCall->getNumArgs() /*function call*/;
5838- if (TheCall->getNumArgs() > 2)
5839- return Diag(TheCall->getArg(2)->getBeginLoc(),
5840- diag::err_typecheck_call_too_many_args)
5841- << 0 /*function call*/ << 2 << TheCall->getNumArgs()
5842- << SourceRange(TheCall->getArg(2)->getBeginLoc(),
5843- (*(TheCall->arg_end() - 1))->getEndLoc());
5819+ if (checkArgCount(*this, TheCall, 2))
5820+ return true;
58445821
58455822 ExprResult OrigArg0 = TheCall->getArg(0);
58465823 ExprResult OrigArg1 = TheCall->getArg(1);
@@ -5878,15 +5855,8 @@ bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
58785855/// to check everything. We expect the last argument to be a floating point
58795856/// value.
58805857bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) {
5881- if (TheCall->getNumArgs() < NumArgs)
5882- return Diag(TheCall->getEndLoc(), diag::err_typecheck_call_too_few_args)
5883- << 0 << NumArgs << TheCall->getNumArgs() /*function call*/;
5884- if (TheCall->getNumArgs() > NumArgs)
5885- return Diag(TheCall->getArg(NumArgs)->getBeginLoc(),
5886- diag::err_typecheck_call_too_many_args)
5887- << 0 /*function call*/ << NumArgs << TheCall->getNumArgs()
5888- << SourceRange(TheCall->getArg(NumArgs)->getBeginLoc(),
5889- (*(TheCall->arg_end() - 1))->getEndLoc());
5858+ if (checkArgCount(*this, TheCall, NumArgs))
5859+ return true;
58905860
58915861 // __builtin_fpclassify is the only case where NumArgs != 1, so we can count
58925862 // on all preceding parameters just being int. Try all of those.
@@ -5990,17 +5960,8 @@ bool Sema::SemaBuiltinComplex(CallExpr *TheCall) {
59905960// vector short vec_xxsldwi(vector short, vector short, int);
59915961bool Sema::SemaBuiltinVSX(CallExpr *TheCall) {
59925962 unsigned ExpectedNumArgs = 3;
5993- if (TheCall->getNumArgs() < ExpectedNumArgs)
5994- return Diag(TheCall->getEndLoc(),
5995- diag::err_typecheck_call_too_few_args_at_least)
5996- << 0 /*function call*/ << ExpectedNumArgs << TheCall->getNumArgs()
5997- << TheCall->getSourceRange();
5998-
5999- if (TheCall->getNumArgs() > ExpectedNumArgs)
6000- return Diag(TheCall->getEndLoc(),
6001- diag::err_typecheck_call_too_many_args_at_most)
6002- << 0 /*function call*/ << ExpectedNumArgs << TheCall->getNumArgs()
6003- << TheCall->getSourceRange();
5963+ if (checkArgCount(*this, TheCall, ExpectedNumArgs))
5964+ return true;
60045965
60055966 // Check the third argument is a compile time constant
60065967 if (!TheCall->getArg(2)->isIntegerConstantExpr(Context))
0 commit comments