[clang] [HLSL] Implement the 'and' HLSL function (PR #127098)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 16 09:09:42 PST 2025


================
@@ -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:

> I'm happy to take suggestions and file tickets for what needs to improve, but I don't think this is the PR to do it. 
On this point I actually disagree. We should get this PR into a state where its diagnostics are at the high quality we want, then we can work back to the other diagnostics and correct them.

https://github.com/llvm/llvm-project/pull/127098


More information about the cfe-commits mailing list