[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

Tex Riddell via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 7 17:41:30 PST 2024


================
@@ -2161,6 +2186,22 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
       return true;
     break;
   }
+  case Builtin::BI__builtin_hlsl_buffer_update_counter: {
+    if (SemaRef.checkArgCount(TheCall, 2) ||
+        CheckResourceHandle(&SemaRef, TheCall, 0) ||
+        CheckInt(&SemaRef, TheCall, 1))
+      return true;
----------------
tex3d wrote:

Shouldn't this be a specific int type (not an integer type of any size/signedness)?  If so, couldn't we have a check function that takes a single type and call it like `CheckArgType(&SemaRef, TheCall, 1, SemaRef.Context.IntTy)`?

Or perhaps it could just be checked and diagnosed here instead?
```suggestion
    if (SemaRef.checkArgCount(TheCall, 2) ||
        CheckResourceHandle(&SemaRef, TheCall, 0))
      return true;
    if (TheCall->getArg(ArgIndex)->getType() != SemaRef.Context.IntTy) {
      S->Diag(TheCall->getArg(0)->getExprLoc(), diag::err_typecheck_expect_int)
        << ArgType;
      return true;
    }
```

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


More information about the cfe-commits mailing list