@@ -1465,25 +1465,6 @@ bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) {
14651465 return true ;
14661466}
14671467
1468- bool CheckArgTypeWithoutImplicits (
1469- Sema *S, Expr *Arg, QualType ExpectedType,
1470- llvm::function_ref<bool (clang::QualType PassedType)> Check) {
1471-
1472- QualType ArgTy = Arg->IgnoreImpCasts ()->getType ();
1473-
1474- clang::QualType BaseType =
1475- ArgTy->isVectorType ()
1476- ? ArgTy->getAs <clang::VectorType>()->getElementType ()
1477- : ArgTy;
1478-
1479- if (Check (BaseType)) {
1480- S->Diag (Arg->getBeginLoc (), diag::err_typecheck_convert_incompatible)
1481- << ArgTy << ExpectedType << 1 << 0 << 0 ;
1482- return true ;
1483- }
1484- return false ;
1485- }
1486-
14871468bool CheckArgsTypesAreCorrect (
14881469 Sema *S, CallExpr *TheCall, QualType ExpectedType,
14891470 llvm::function_ref<bool (clang::QualType PassedType)> Check) {
@@ -1510,12 +1491,16 @@ bool CheckAllArgsHaveFloatRepresentation(Sema *S, CallExpr *TheCall) {
15101491 checkAllFloatTypes);
15111492}
15121493
1513- bool CheckArgIsFloatOrIntWithoutImplicits (Sema *S, Expr *Arg ) {
1494+ bool CheckNotFloatAndInt (Sema *S, CallExpr *TheCall ) {
15141495 auto checkFloat = [](clang::QualType PassedType) -> bool {
1515- return !PassedType->isFloat32Type () && !PassedType->isIntegerType ();
1496+ clang::QualType BaseType =
1497+ PassedType->isVectorType ()
1498+ ? PassedType->getAs <clang::VectorType>()->getElementType ()
1499+ : PassedType;
1500+ return !(BaseType->isFloat32Type () || BaseType->isIntegerType ());
15161501 };
15171502
1518- return CheckArgTypeWithoutImplicits (S, Arg , S->Context .FloatTy , checkFloat);
1503+ return CheckArgsTypesAreCorrect (S, TheCall , S->Context .FloatTy , checkFloat);
15191504}
15201505
15211506bool CheckFloatOrHalfRepresentations (Sema *S, CallExpr *TheCall) {
@@ -1676,8 +1661,7 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
16761661 if (SemaRef.checkArgCount (TheCall, 1 ))
16771662 return true ;
16781663
1679- Expr *Arg = TheCall->getArg (0 );
1680- if (CheckArgIsFloatOrIntWithoutImplicits (&SemaRef, Arg))
1664+ if (CheckNotFloatAndInt (&SemaRef, TheCall))
16811665 return true ;
16821666
16831667 break ;
0 commit comments