================ @@ -2245,6 +2245,36 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { break; } + case Builtin::BI__builtin_hlsl_and: { + if (SemaRef.checkArgCount(TheCall, 2)) + return true; + if (CheckVectorElementCallArgs(&SemaRef, TheCall)) + return true; + + // CheckVectorElementCallArgs(...) guarantees both args are the same type. + assert(TheCall->getArg(0)->getType() == TheCall->getArg(1)->getType() && + "Both args must be of the same type"); + + // check that the arguments are bools or, if vectors, + // vectors of bools + QualType ArgTy = TheCall->getArg(0)->getType(); + if (const auto *VecTy = ArgTy->getAs<VectorType>()) { + ArgTy = VecTy->getElementType(); + } + if (!getASTContext().hasSameUnqualifiedType(ArgTy, ---------------- Icohedron wrote:
I did try that. I had defined the following function: ```c++ static bool CheckBoolRepresentation(Sema *S, CallExpr *TheCall) { auto checkAllBoolTypes = [](clang::QualType PassedType) -> bool { return !PassedType->isBooleanType(); }; return CheckAllArgTypesAreCorrect(S, TheCall, S->Context.BoolTy, checkAllBoolTypes); } ``` and when I tried to use it, I got a strange errors when running the test ``` ******************** TEST 'Clang :: CodeGenHLSL/builtins/and.hlsl' FAILED *************** ***** Exit Code: 2 Command Output (stderr): -- ******************** TEST 'Clang :: CodeGenHLSL/builtins/and.hlsl' FAILED *************** ***** Exit Code: 2 Command Output (stderr): -- RUN: at line 2: /workspace/feature-and/build/bin/clang -cc1 -internal-isystem /workspace/feature-and/build/lib/clang/21/include -nostdsysteminc -finclude-default-header -triple dxil-pc-shadermodel6.3-library /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl -emit-llvm -O1 -o - | /workspace/feature-and/build/bin/FileCheck /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl + /workspace/feature-and/build/bin/clang -cc1 -internal-isystem /workspace/feature-and/build/lib/clang/21/include -nostdsysteminc -finclude-default-header -triple dxil-pc-shadermodel6.3-library /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl -emit-llvm -O1 -o - + /workspace/feature-and/build/bin/FileCheck /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl:23:14: error: passing 'bool2' (aka 'vector<bool, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(bool)))) bool' (vector of 2 'bool' values) 23 | return and(x, y); | ^ /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl:33:14: error: passing 'bool3' (aka 'vector<bool, 3>') to parameter of incompatible type '__attribute__((__vector_size__(3 * sizeof(bool)))) bool' (vector of 3 'bool' values) 33 | return and(x, y); | ^ /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl:43:14: error: passing 'bool4' (aka 'vector<bool, 4>') to parameter of incompatible type '__attribute__((__vector_size__(4 * sizeof(bool)))) bool' (vector of 4 'bool' values) 43 | return and(x, y); | ^ /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl:55:14: error: passing 'vector<bool, 4>' (vector of 4 'bool' values) to parameter of incompatible type '__attribute__((__vector_size__(4 * sizeof(bool)))) bool' (vector of 4 'bool' values) 55 | return and(x, y); | ^ /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl:67:14: error: passing 'vector<bool, 4>' (vector of 4 'bool' values) to parameter of incompatible type '__attribute__((__vector_size__(4 * sizeof(bool)))) bool' (vector of 4 'bool' values) 67 | return and(x, y); | ^ 5 errors generated. FileCheck error: '<stdin>' is empty. FileCheck command line: /workspace/feature-and/build/bin/FileCheck /workspace/feature-and/clang/test/CodeGenHLSL/builtins/and.hlsl -- ``` https://github.com/llvm/llvm-project/pull/127098 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits