================
@@ -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,
----------------
llvm-beanz wrote:
> We can talk about it Monday. But as is and builtin will be inconsistent with
> the errors we are using for all other hls builtins that do this same check.
There are no builtins doing this same check. `and`'s arguments _must_ be bool
or vector of bool.
There probably is a valid criticism that the diagnostic in the current change
is less than ideal because it uses the same diagnostic that
`CheckFloatOrHalfRepresentation` does. Instead it should probably use language
more like `err_typecheck_expect_scalar_or_vector` to emit a diagnostic that
clearly denotes parameters should be `bool` or vector of `bool`.
https://github.com/llvm/llvm-project/pull/127098
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits