================ @@ -2164,30 +2085,49 @@ static bool CheckModifiableLValue(Sema *S, CallExpr *TheCall, return true; } -static bool CheckNoDoubleVectors(Sema *S, CallExpr *TheCall) { - auto checkDoubleVector = [](clang::QualType PassedType) -> bool { - if (const auto *VecTy = PassedType->getAs<VectorType>()) - return VecTy->getElementType()->isDoubleType(); - return false; - }; - return CheckAllArgTypesAreCorrect(S, TheCall, S->Context.FloatTy, - checkDoubleVector); +static bool CheckNoDoubleVectors(Sema *S, SourceLocation Loc, int ArgOrdinal, + clang::QualType PassedType) { + if (const auto *VecTy = PassedType->getAs<VectorType>()) + if (VecTy->getElementType()->isDoubleType()) + return S->Diag(Loc, diag::err_builtin_invalid_arg_type) + << ArgOrdinal << /* scalar */ 1 << /* no int */ 0 << /* fp */ 1 + << PassedType; + return false; } -static bool CheckFloatingOrIntRepresentation(Sema *S, CallExpr *TheCall) { - auto checkAllSignedTypes = [](clang::QualType PassedType) -> bool { - return !PassedType->hasIntegerRepresentation() && - !PassedType->hasFloatingRepresentation(); - }; - return CheckAllArgTypesAreCorrect(S, TheCall, S->Context.IntTy, - checkAllSignedTypes); + +static bool CheckFloatingOrIntRepresentation(Sema *S, SourceLocation Loc, + int ArgOrdinal, + clang::QualType PassedType) { + if (!PassedType->hasIntegerRepresentation() && + !PassedType->hasFloatingRepresentation()) + return S->Diag(Loc, diag::err_builtin_invalid_arg_type) + << ArgOrdinal << /* scalar or vector of */ 5 << /* integer */ 1 + << /* fp */ 1 << PassedType; + return false; } -static bool CheckUnsignedIntRepresentation(Sema *S, CallExpr *TheCall) { - auto checkAllUnsignedTypes = [](clang::QualType PassedType) -> bool { - return !PassedType->hasUnsignedIntegerRepresentation(); - }; - return CheckAllArgTypesAreCorrect(S, TheCall, S->Context.UnsignedIntTy, - checkAllUnsignedTypes); +static bool CheckUnsignedIntVecRepresentation(Sema *S, SourceLocation Loc, + int ArgOrdinal, + clang::QualType PassedType) { + QualType EltTy = PassedType; + if (auto *VecTy = EltTy->getAs<VectorType>()) + EltTy = VecTy->getElementType(); + + if (!PassedType->getAs<VectorType>() || !EltTy->isUnsignedIntegerType()) + return S->Diag(Loc, diag::err_builtin_invalid_arg_type) + << ArgOrdinal << /* vector of */ 4 << /* uint */ 3 << /* no fp */ 0 + << PassedType; + return false; ---------------- hekota wrote:
You can avoid testing `getAs<VectorType>()` twice here as well as in the `CheckFloatOrHalfVecRepresentation` function like this: ```suggestion if (auto *VecTy = EltTy->getAs<VectorType>()) if (VecTy->getElementType()->isUnsignedIntegerType()) return false; return S->Diag(Loc, diag::err_builtin_invalid_arg_type) << ArgOrdinal << /* vector of */ 4 << /* uint */ 3 << /* no fp */ 0 << PassedType; ``` ``` https://github.com/llvm/llvm-project/pull/138429 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits