https://github.com/farzonl created https://github.com/llvm/llvm-project/pull/122772
In the below code B varies over the arg list via a loop. However, the diagnostics do not vary with the loop. Fix so that diagnostics can vary with B. >From 9df164c835e7df5bf4ea863bd9735bb0e456cb6c Mon Sep 17 00:00:00 2001 From: Farzon Lotfi <farzonlo...@microsoft.com> Date: Mon, 13 Jan 2025 14:26:23 -0500 Subject: [PATCH] [NFC] Fixed Diagnostics that assumed only two arguments --- clang/lib/Sema/SemaHLSL.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index 65ddee05a21512..169a6a6903891c 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -1688,8 +1688,9 @@ static bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) { auto *VecTyA = ArgTyA->getAs<VectorType>(); SourceLocation BuiltinLoc = TheCall->getBeginLoc(); + ExprResult B; for (unsigned i = 1; i < TheCall->getNumArgs(); ++i) { - ExprResult B = TheCall->getArg(i); + B = TheCall->getArg(i); QualType ArgTyB = B.get()->getType(); auto *VecTyB = ArgTyB->getAs<VectorType>(); if (VecTyA == nullptr && VecTyB == nullptr) @@ -1712,8 +1713,7 @@ static bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) { // HLSLVectorTruncation. S->Diag(BuiltinLoc, diag::err_vec_builtin_incompatible_vector) << TheCall->getDirectCallee() << /*useAllTerminology*/ true - << SourceRange(TheCall->getArg(0)->getBeginLoc(), - TheCall->getArg(1)->getEndLoc()); + << SourceRange(A.get()->getBeginLoc(), B.get()->getEndLoc()); retValue = true; } return retValue; @@ -1724,8 +1724,7 @@ static bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) { // requires a VectorSplat on Arg0 or Arg1 S->Diag(BuiltinLoc, diag::err_vec_builtin_non_vector) << TheCall->getDirectCallee() << /*useAllTerminology*/ true - << SourceRange(TheCall->getArg(0)->getBeginLoc(), - TheCall->getArg(1)->getEndLoc()); + << SourceRange(A.get()->getBeginLoc(), B.get()->getEndLoc()); return true; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits