================ @@ -105,35 +136,27 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID, if (SemaRef.checkArgCount(TheCall, 3)) return true; - // check if the all arguments have floating representation - for (unsigned i = 0; i < TheCall->getNumArgs(); ++i) { - ExprResult Arg = TheCall->getArg(i); - QualType ArgTy = Arg.get()->getType(); - if (!ArgTy->hasFloatingRepresentation()) { - SemaRef.Diag(Arg.get()->getBeginLoc(), - diag::err_builtin_invalid_arg_type) - << i + 1 << /* scalar or vector */ 5 << /* no int */ 0 << /* fp */ 1 - << ArgTy; - return true; - } - } + if (CheckAllArgsHaveFloatRepresentation(&SemaRef, TheCall)) + return true; - // check if all arguments are of the same type - ExprResult A = TheCall->getArg(0); - ExprResult B = TheCall->getArg(1); - ExprResult C = TheCall->getArg(2); - if (!(SemaRef.getASTContext().hasSameUnqualifiedType(A.get()->getType(), - B.get()->getType()) && - SemaRef.getASTContext().hasSameUnqualifiedType(A.get()->getType(), - C.get()->getType()))) { - SemaRef.Diag(TheCall->getBeginLoc(), - diag::err_vec_builtin_incompatible_vector) - << TheCall->getDirectCallee() << /*useAllTerminology*/ true - << SourceRange(A.get()->getBeginLoc(), C.get()->getEndLoc()); + if (CheckAllArgsHaveSameType(&SemaRef, TheCall)) ---------------- kmpeng wrote:
You're right, it would be better to just check the first value then do `CheckAllArgsHaveSameType`. The only caveat I can think of would be that it would change the error messages for tests, e.g. the error message for ``` float test_int_scalar_inputs2(float p0, int p1, int p2) ``` would change from `2nd argument must be a scalar or vector of floating-point types (was 'int')` to `all arguments to '__builtin_spirv_faceforward' must have the same type`, which I think is fine. If we want to make this change for `smoothstep` though, we would probably want to do it in a separate PR right? https://github.com/llvm/llvm-project/pull/135878 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits