@@ -1274,11 +1274,8 @@ static bool SemaBuiltinPipePackets(Sema &S, CallExpr *Call) {
1274
1274
// \return True if a semantic error has been found, false otherwise.
1275
1275
static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID,
1276
1276
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))
1280
1278
return true;
1281
- }
1282
1279
1283
1280
auto RT = Call->getArg(0)->getType();
1284
1281
if (!RT->isPointerType() || RT->getPointeeType()
@@ -5708,21 +5705,8 @@ bool Sema::SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
5708
5705
if (checkVAStartABI(*this, BuiltinID, Fn))
5709
5706
return true;
5710
5707
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))
5718
5709
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
- }
5726
5710
5727
5711
// Type-check the first argument normally.
5728
5712
if (checkBuiltinArgument(*this, TheCall, 0))
@@ -5832,15 +5816,8 @@ bool Sema::SemaBuiltinVAStartARMMicrosoft(CallExpr *Call) {
5832
5816
/// SemaBuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
5833
5817
/// friends. This is declared to take (...), so we have to check everything.
5834
5818
bool 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;
5844
5821
5845
5822
ExprResult OrigArg0 = TheCall->getArg(0);
5846
5823
ExprResult OrigArg1 = TheCall->getArg(1);
@@ -5878,15 +5855,8 @@ bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
5878
5855
/// to check everything. We expect the last argument to be a floating point
5879
5856
/// value.
5880
5857
bool 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;
5890
5860
5891
5861
// __builtin_fpclassify is the only case where NumArgs != 1, so we can count
5892
5862
// on all preceding parameters just being int. Try all of those.
@@ -5990,17 +5960,8 @@ bool Sema::SemaBuiltinComplex(CallExpr *TheCall) {
5990
5960
// vector short vec_xxsldwi(vector short, vector short, int);
5991
5961
bool Sema::SemaBuiltinVSX(CallExpr *TheCall) {
5992
5962
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;
6004
5965
6005
5966
// Check the third argument is a compile time constant
6006
5967
if (!TheCall->getArg(2)->isIntegerConstantExpr(Context))
0 commit comments