@@ -1470,25 +1470,6 @@ bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) {
14701470 return true ;
14711471}
14721472
1473- bool CheckArgTypeWithoutImplicits (
1474- Sema *S, Expr *Arg, QualType ExpectedType,
1475- llvm::function_ref<bool (clang::QualType PassedType)> Check) {
1476-
1477- QualType ArgTy = Arg->IgnoreImpCasts ()->getType ();
1478-
1479- clang::QualType BaseType =
1480- ArgTy->isVectorType ()
1481- ? ArgTy->getAs <clang::VectorType>()->getElementType ()
1482- : ArgTy;
1483-
1484- if (Check (BaseType)) {
1485- S->Diag (Arg->getBeginLoc (), diag::err_typecheck_convert_incompatible)
1486- << ArgTy << ExpectedType << 1 << 0 << 0 ;
1487- return true ;
1488- }
1489- return false ;
1490- }
1491-
14921473bool CheckArgsTypesAreCorrect (
14931474 Sema *S, CallExpr *TheCall, QualType ExpectedType,
14941475 llvm::function_ref<bool (clang::QualType PassedType)> Check) {
@@ -1515,12 +1496,16 @@ bool CheckAllArgsHaveFloatRepresentation(Sema *S, CallExpr *TheCall) {
15151496 checkAllFloatTypes);
15161497}
15171498
1518- bool CheckArgIsFloatOrIntWithoutImplicits (Sema *S, Expr *Arg ) {
1499+ bool CheckNotFloatAndInt (Sema *S, CallExpr *TheCall ) {
15191500 auto checkFloat = [](clang::QualType PassedType) -> bool {
1520- return !PassedType->isFloat32Type () && !PassedType->isIntegerType ();
1501+ clang::QualType BaseType =
1502+ PassedType->isVectorType ()
1503+ ? PassedType->getAs <clang::VectorType>()->getElementType ()
1504+ : PassedType;
1505+ return !(BaseType->isFloat32Type () || BaseType->isIntegerType ());
15211506 };
15221507
1523- return CheckArgTypeWithoutImplicits (S, Arg , S->Context .FloatTy , checkFloat);
1508+ return CheckArgsTypesAreCorrect (S, TheCall , S->Context .FloatTy , checkFloat);
15241509}
15251510
15261511bool CheckFloatOrHalfRepresentations (Sema *S, CallExpr *TheCall) {
@@ -1784,8 +1769,7 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
17841769 if (SemaRef.checkArgCount (TheCall, 1 ))
17851770 return true ;
17861771
1787- Expr *Arg = TheCall->getArg (0 );
1788- if (CheckArgIsFloatOrIntWithoutImplicits (&SemaRef, Arg))
1772+ if (CheckNotFloatAndInt (&SemaRef, TheCall))
17891773 return true ;
17901774
17911775 break ;
0 commit comments