[clang] [HLSL][Sema] Fixed Diagnostics that assumed only two arguments (PR #122772)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 16 12:34:01 PST 2025
================
@@ -1688,13 +1688,21 @@ static bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) {
auto *VecTyA = ArgTyA->getAs<VectorType>();
SourceLocation BuiltinLoc = TheCall->getBeginLoc();
+ bool AllBArgAreVectors = true;
for (unsigned i = 1; i < TheCall->getNumArgs(); ++i) {
ExprResult B = TheCall->getArg(i);
QualType ArgTyB = B.get()->getType();
auto *VecTyB = ArgTyB->getAs<VectorType>();
- if (VecTyA == nullptr && VecTyB == nullptr)
- return false;
-
+ if (VecTyB == nullptr)
+ AllBArgAreVectors &= false;
+ if (VecTyA && VecTyB == nullptr) {
+ // Note: if we get here 'B' is scalar which
+ // requires a VectorSplat on ArgN
+ S->Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
+ << TheCall->getDirectCallee() << /*useAllTerminology*/ true
+ << SourceRange(A.get()->getBeginLoc(), B.get()->getEndLoc());
+ return true;
----------------
farzonl wrote:
I suppose we could, but it would be the same error text over and over again since the error text is not positional.
That makes it not easy to test this other than via error count. we don't have any tests on what gets highlighted via begin and end locations so i've just been spot checking location\arg highlighting.
https://github.com/llvm/llvm-project/pull/122772
More information about the cfe-commits
mailing list