================
@@ -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;
+    Expr *OffsetExpr = TheCall->getArg(1);
+    std::optional<llvm::APSInt> Offset =
+        OffsetExpr->getIntegerConstantExpr(SemaRef.getASTContext());
+    if (!Offset.has_value() || abs(Offset->getExtValue()) != 1) {
+      SemaRef.Diag(TheCall->getArg(1)->getBeginLoc(),
----------------
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;
    Expr *OffsetExpr = TheCall->getArg(1);
    SourceLocation OffsetLoc = OffsetExpr->getExprLoc();
    if (OffsetExpr->getType() != SemaRef.Context.IntTy) {
      S->Diag(OffsetLoc, diag::err_typecheck_expect_int) << ArgType;
      return true;
    }
    std::optional<llvm::APSInt> Offset =
        OffsetExpr->getIntegerConstantExpr(SemaRef.getASTContext());
    if (!Offset.has_value() || abs(Offset->getExtValue()) != 1) {
      SemaRef.Diag(OffsetLoc,
```

https://github.com/llvm/llvm-project/pull/114148
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to